lkml.org 
[lkml]   [2002]   [May]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] Some useless cleanup
Replying to Denis Vlasenko:
> Well, it isn't bad, but what's the point in multiple
> set_xxxxxx(char *dst, char *src) functions?
>
> Maybe it makes more sense to have a generic macro
> which copies string into char[N] buffer, avoiding overflow.
>

Generic plan. I has something in mind when asked, but not this ...

Actually in task_t.comm we have 2 cases
1. strncpy(a, b, sz)
2. snprintf(a, n, blah-blah...)

I thought somebody will beat me for completely eliminating strcpyn and
replacing it with snprintf in ALL CASES which is more expensive.

> A macro:
>
> #define STRNCPY(dst,src) \
> do { \
> /* todo: put clever check that dst is char[] here */ \
> strncpy((dst), (src), sizeof(dst)-1); \
> dst[sizeof(dst)-1] = '\0'; \
> } while(0)

Abstracting .comm access can result in, finally, replacing comm[16] with,
for example, *comm

Or if we require to do match_comm (netfilter match, connections belong to
process specified by name) job we can patchhook somewhere in set_xxx to
avoid excessive for_each_tasked strcmps.

... more?

--
Paul P 'Stingray' Komkoff 'Greatest' Jr // (icq)23200764 // (irc)Spacebar
PPKJ1-RIPE // (smtp)i@stingr.net // (http)stingr.net // (pgp)0xA4B4ECA4
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:25    [W:0.130 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site