Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Fri, 30 Aug 2002 01:54:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Fri, 30 Aug 2002 01:54:25 -0400 Received: from dp.samba.org ([66.70.73.150]:60606 "EHLO lists.samba.org") by vger.kernel.org with ESMTP id ; Fri, 30 Aug 2002 01:54:24 -0400 From: Rusty Russell To: Thunder from the hill Cc: junio@siamese.dyndns.org, Linux Kernel Mailing List Subject: Re: [TRIVIAL] strlen("literal string") -> (sizeof("literal string")-1) In-reply-to: Your message of "Thu, 29 Aug 2002 09:39:14 CST." Date: Fri, 30 Aug 2002 13:50:25 +1000 Message-Id: <20020830005909.816302C04F@lists.samba.org> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1140 Lines: 30 In message you w rite: > 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. Rusty. -- 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 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/