| To: | shemminger@xxxxxxxx |
|---|---|
| Subject: | Re: [PATCH] (2/4) support large number of network devices -- name hash |
| From: | YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@xxxxxxxxxxxxxx> |
| Date: | Thu, 22 Jan 2004 11:10:54 +0900 (JST) |
| Cc: | davem@xxxxxxxxxx, netdev@xxxxxxxxxxx, yoshfuji@xxxxxxxxxxxxxx |
| In-reply-to: | <20040119112850.3b3575a7.shemminger@osdl.org> |
| Organization: | USAGI Project |
| References: | <20040116154814.7c7f31ac.shemminger@osdl.org> <20040117.112244.90941296.yoshfuji@linux-ipv6.org> <20040119112850.3b3575a7.shemminger@osdl.org> |
| Sender: | netdev-bounce@xxxxxxxxxxx |
In article <20040119112850.3b3575a7.shemminger@xxxxxxxx> (at Mon, 19 Jan 2004
11:28:50 -0800), Stephen Hemminger <shemminger@xxxxxxxx> says:
> Use strnlen, great idea, thanks.
> - size_t len = min(strlen(name),(size_t)(IFNAMSIZ-1));
> - unsigned hash = full_name_hash(name, len);
> + unsigned hash = full_name_hash(name,
> + strnlen(name, IFNAMSIZ-1));
I prefer IFNAMSIZ over IFNAMSIZ-1 here
bacause maximum length of valid name is IFNAMSIZ-1.
strnlen(3):
size_t strnlen(const char *s, size_t maxlen);
:
The strnlen function returns strlen(s), if that is less than maxlen, or
maxlen if there is no '\0' character among the first maxlen characters
pointed to by s.
If strnlen(name,IFNAMSIZ) returns IFNAMSIZ, name is not terminated.
while strnlen(name,IFNAMSIZ-1) does not tell whether it is terminated or not.
--yoshfuji
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [PROBLEM] r8169 deadlocks, Francois Romieu |
|---|---|
| Next by Date: | Re: [PATCH] IPV6: add missing sentinel for addrconf procfs, David S. Miller |
| Previous by Thread: | Re: [PATCH] (2/4) support large number of network devices -- name hash, Stephen Hemminger |
| Next by Thread: | [PATCH] (3/4) support large number of network devices -- hash ifindex, Stephen Hemminger |
| Indexes: | [Date] [Thread] [Top] [All Lists] |