Re: [PATCH] iio: fix pointer cast warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/14/2012 05:40 PM, walter harms wrote:
> 
> 
> Am 14.07.2012 18:23, schrieb Peter Meerwald:
>> fix compile warning reported by Fengguang Wu:
>>
>> drivers/iio/light/adjd_s311.c: In function 'adjd_s311_trigger_handler':
>> drivers/iio/light/adjd_s311.c:188:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>> drivers/iio/light/adjd_s311.c:188:4: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
>>
>>    185              }
>>    186
>>    187              if (indio_dev->scan_timestamp)
>>  > 188                      *(s64 *)((phys_addr_t)data->buffer + ALIGN(len, sizeof(s64)))
>>    189                              = time_ns;
>>    190              iio_push_to_buffer(buffer, (u8 *)data->buffer, time_ns);
>>    191
>>
>> Signed-off-by: Peter Meerwald <pmeerw@xxxxxxxxxx>
>> Reported-by: Fengguang Wu <fengguang.wu@xxxxxxxxx>
merged this one and the other two. Thanks Peter and Fengguang.
>> ---
>>  drivers/iio/light/adjd_s311.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c
>> index e485142..1cbb449 100644
>> --- a/drivers/iio/light/adjd_s311.c
>> +++ b/drivers/iio/light/adjd_s311.c
>> @@ -185,7 +185,7 @@ static irqreturn_t adjd_s311_trigger_handler(int irq, void *p)
>>  	}
>>  
>>  	if (indio_dev->scan_timestamp)
>> -		*(s64 *)((phys_addr_t)data->buffer + ALIGN(len, sizeof(s64)))
>> +		*(s64 *)((u8 *)data->buffer + ALIGN(len, sizeof(s64)))
>>  			= time_ns;
>>  	iio_push_to_buffer(buffer, (u8 *)data->buffer, time_ns);
>>  
> 
> a few lines below is an othern cast (u8 *)data->buffer, i do not see the rest of the code,
> but perhaps adding a helper will help here to improve readability ?
> 
> just my 2 cents,
> re,
>  wh
Not really in this case. This stuff is all here because we are
filling up a data record with different sized elements.
As most of them in this driver are 16 bit, the data->buffer is 16 bit
hence the need for these type casts.  Not sure where the phys_addr_t
misuse here first came from, but it's thankfully only in a couple of
drivers.

Jonathan


--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux