B
Bill Waddington
Long time lurker, 1st time poster. I hope this is sufficiently
c related. If not, send me to my room.
I'm porting a driver to a 64-bit platform. I get handed a struct:
typedef struct {
...
size_t dmac_size
} ddi_dma_cookie_t;
On a 64-bit build size_t is 64 bits wide, but all actual values will
fit in a 32 bit variable. Eventually I need to write dmac_size into
a 32-bit device register:
uint32_t dma_count = dma_cookie.dmac_size;
ddi_put32(..., dma_count);
dmac_size is 64 bits wide, ddi_put32 insists on a 32 bit value, so
lint and or the compiler complain about assigning a 64 to a 32. If
I use a cast they complain about casting 64 to 32. The code runs
fine, but I would like a warning-free compile for those cases where
a customer does the compiling.
Is there a "c" way to quiet this kind of warning via casts or passing
through some intermediate variable? Maybe this tool set is too picky.
Tried the FAQ, hope I didn't miss it.
Thanks,
Bill
c related. If not, send me to my room.
I'm porting a driver to a 64-bit platform. I get handed a struct:
typedef struct {
...
size_t dmac_size
} ddi_dma_cookie_t;
On a 64-bit build size_t is 64 bits wide, but all actual values will
fit in a 32 bit variable. Eventually I need to write dmac_size into
a 32-bit device register:
uint32_t dma_count = dma_cookie.dmac_size;
ddi_put32(..., dma_count);
dmac_size is 64 bits wide, ddi_put32 insists on a 32 bit value, so
lint and or the compiler complain about assigning a 64 to a 32. If
I use a cast they complain about casting 64 to 32. The code runs
fine, but I would like a warning-free compile for those cases where
a customer does the compiling.
Is there a "c" way to quiet this kind of warning via casts or passing
through some intermediate variable? Maybe this tool set is too picky.
Tried the FAQ, hope I didn't miss it.
Thanks,
Bill