[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <51356FED.4070909@asianux.com>
Date: Tue, 05 Mar 2013 12:09:17 +0800
From: Chen Gang <gang.chen@...anux.com>
To: Ben Hutchings <bhutchings@...arflare.com>
CC: David Laight <David.Laight@...LAB.COM>,
venkat.x.venkatsubra@...cle.com,
David Miller <davem@...emloft.net>, rds-devel@....oracle.com,
netdev <netdev@...r.kernel.org>
Subject: Re: [PATCH] net/rds: using strlcpy instead of strncpy
于 2013年03月05日 11:37, Ben Hutchings 写道:
>> I think what I have done is just like your choice "2."
>> > for me, I think they are equal:
>> >
>> > - strncpy(ctr.name, names[i], sizeof(ctr.name) - 1);
>> > + strlcpy(ctr.name, names[i], sizeof(ctr.name));
>> >
>> >
>> > strncpy(ctr.name, names[i], sizeof(ctr.name) - 1);
>> > + ctr.name[sizeof(ctr.name) - 1] = '\0';
> They are not. strncpy() pads with zeroes to the end of the given buffer
> whereas strlcpy() adds only a single zero byte (and truncates if
> necessary to fit the zero byte).
ok, thank you. they are really not the same (originally, I did not
notice it)
could you supply the reason:
why need we zero all of ctr.name ?
(for me, I think, keeping ctr.name just a zero-based string is ok)
thanks.
:-)
--
Chen Gang
Asianux Corporation
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists