public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Thunder from the hill <thunder@lightweight.ods.org>
Cc: junio@siamese.dyndns.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [TRIVIAL] strlen("literal string") -> (sizeof("literal string")-1)
Date: Fri, 30 Aug 2002 13:50:25 +1000	[thread overview]
Message-ID: <20020830005909.816302C04F@lists.samba.org> (raw)
In-Reply-To: Your message of "Thu, 29 Aug 2002 09:39:14 CST." <Pine.LNX.4.44.0208290938180.3234-100000@hawkeye.luckynet.adm>

In message <Pine.LNX.4.44.0208290938180.3234-100000@hawkeye.luckynet.adm> 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.

  parent reply	other threads:[~2002-08-30  5:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fa.lrmcokv.1q28k2s@ifi.uio.no>
     [not found] ` <fa.pm2g4iv.k0s9jg@ifi.uio.no>
2002-08-29  0:49   ` [TRIVIAL] strlen("literal string") -> (sizeof("literal string")-1) junio
2002-08-29  3:15     ` Rusty Russell
2002-08-29 15:39       ` Thunder from the hill
2002-08-29 15:48         ` Dave Jones
2002-08-30  3:50         ` Rusty Russell [this message]
     [not found] <20020829031008.T7920@devserv.devel.redhat.com.suse.lists.linux.kernel>
     [not found] ` <Pine.LNX.4.44.0208290955280.2070-100000@home.transmeta.com.suse.lists.linux.kernel>
2002-08-29 17:23   ` Andi Kleen
2002-08-29 17:51     ` Alexander Viro
2002-08-29 17:53       ` Andi Kleen
     [not found] <fa.iks3ohv.1flge08@ifi.uio.no>
2002-08-28 21:31 ` junkio
2002-08-28 21:55   ` Jim Treadway
2002-08-29  3:09   ` Rusty Russell
2002-08-29  3:26     ` Daniel Jacobowitz
2002-08-29  6:29       ` Rusty Russell
2002-08-29  7:10         ` Jakub Jelinek
2002-08-29 16:56           ` Linus Torvalds
2002-08-29 20:38             ` Denis Zaitsev
2002-09-06 12:53   ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020830005909.816302C04F@lists.samba.org \
    --to=rusty@rustcorp.com.au \
    --cc=junio@siamese.dyndns.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thunder@lightweight.ods.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox