Re: [TRIVIAL] strlen("literal string") -> (sizeof("literal string")-1)

From: Thunder from the hill (thunder@lightweight.ods.org)
Date: Thu Aug 29 2002 - 10:39:14 EST


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.

                        Thunder

-- 
--./../...-/. -.--/---/..-/.-./..././.-../..-. .---/..-/.../- .-
--/../-./..-/-/./--..-- ../.----./.-../.-.. --./../...-/. -.--/---/..-
.- -/---/--/---/.-./.-./---/.--/.-.-.-
--./.-/-.../.-./.././.-../.-.-.-

- 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/



This archive was generated by hypermail 2b29 : Sat Aug 31 2002 - 22:00:26 EST