[lkml]   [2002]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [TRIVIAL] strlen("literal string") -> (sizeof("literal string")-1)
In message <Pine.LNX.4.44.0208290938180.3234-100000@hawkeye.luckynet.adm> you w
> Hi,
> On Thu, 29 Aug 2002, Rusty Russell wrote:
> > If you really care about that, try:
> >
> > /* Be paranoid in case someone uses strlen(&("FOO"[0])) */
> > #define strlen(x) \
> > (__builtin_constant_p(x) && sizeof(x) != sizeof(char *)
> > ? (sizeof(x) - 1) : __strlen(x))
> I must say that doesn't make the code any cleaner, which leads to it being
> not as clean as Keith suggested. It was a code cleanup, not a code messup.

Think harder.

This code would exist in one place: those (four) architectures which
insist on having an inline strlen function. These guys already eat
inline asm for breakfast: it's *their* jobs to jump through hoops so
the driver writers can write simple code and have it work well.

Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

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