[U-Boot] [PATCH 05/17] stdio: remove useless strncpy

Simon Glass sjg at chromium.org
Thu Nov 15 23:25:02 CET 2012


Hi Wolfgang,

On Sat, Nov 3, 2012 at 8:31 AM, Wolfgang Denk <wd at denx.de> wrote:
> Dear Simon Glass,
>
> In message <1351902453-27956-6-git-send-email-sjg at chromium.org> you wrote:
>> From: Vincent Palatin <vpalatin at chromium.org>
>>
>> The name is already copied when we memopy the whole structure.
>
> memopy?
>

Done

>> --- a/common/stdio.c
>> +++ b/common/stdio.c
>> @@ -135,7 +135,6 @@ struct stdio_dev* stdio_clone(struct stdio_dev *dev)
>>               return NULL;
>>
>>       memcpy(_dev, dev, sizeof(struct stdio_dev));
>> -     strncpy(_dev->name, dev->name, 16);
>
> _dev contains just the pointer, not the data, so why can we omit
> copying the data?

I will add more detail to the commit message:

    This is because struct stdio_dev has this field:

        char    name[16];               /* Device name
         */

    So the data is inline, rather than being a pointer.


>
> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> "It is better for civilization to be going down the drain than to  be
> coming up it."                                          - Henry Allen

Regards,
Simon


More information about the U-Boot mailing list