[PATCH] powerpc: fix i2c device string format

Segher Boessenkool segher at kernel.crashing.org
Fri Aug 10 05:45:46 EST 2007


>> strncpy() won't put a terminating zero on there, is everything
>> that uses the resulting string okay with that?  Also, if the
>> name gets cut short, it might match some _other_ expected name.
>
> On Wed, 1 Aug 2007, Scott Wood wrote:
>
>> You could use strlcpy() instead, which always leaves a zero 
>> terminator.
>
> The patch below does exactly this - uses strlcpy() to guarantee 
> strings in
> i2c device type and driver_name fields are 0-terminated.

You're not checking the return values of these calls.  This would
be a good function to put attribute warn_unused_result on :-)


Segher




More information about the Linuxppc-dev mailing list