From: DJ Barrow <dj.barrow@asitatech.com>
To: root@chaos.analogic.com,
"Brian O'Sullivan" <brian.osullivan@asitatech.com>
Cc: Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: novice coding in /linux/net/ipv4/util.c From: DJ Barrow <dj.barrow@asitatech.com>
Date: Mon, 22 Apr 2002 17:03:50 +0100 [thread overview]
Message-ID: <20020422160154Z314241-22651+13871@vger.kernel.org> (raw)
In-Reply-To: <Pine.LNX.3.95.1020422113750.11343A-100000@chaos.analogic.com>
Richard,
I agree The least offensive way would be to pass in a sring from the caller,
I didn't spot the second endian bug till you mentioned it ;-).
I wish Linus would finally get rid of the errno global as this is equally
stupid on smp machines or else make an errno_array[NR_CPUS] array
& make errno a #define errno errno_array[smp_processor_id()] or
something similar, plenty of others have posted patches for that
rubbish.
Alan Cox is on the list of Authors, he must have wrote it ;-)
On Monday 22 April 2002 16:48, Richard B. Johnson wrote:
> On Mon, 22 Apr 2002, DJ Barrow wrote:
> > Hi ,
> > While debugging last night with Brian O'Sullivan I found this beauty.
> >
> > char *in_ntoa(__u32 in)
> > {
> > static char buff[18];
> > char *p;
> >
> > p = (char *) ∈
> > sprintf(buff, "%d.%d.%d.%d",
> > (p[0] & 255), (p[1] & 255), (p[2] & 255), (p[3] & 255));
> > return(buff);
> > }
> >
> > This textbook peice of novice coding which has existed since 2.2.14.
> > For those who can't spot the error, please note that this function is
> > returning a static string, excellent stuff if you are hoping to reuse the
> > same function like the following
> > printk("%s %s\n",in_ntoa(addr1),in_ntoa(addr2));
> > -
>
> I love it! Last guy wins! I wonder how you fix it without having to
> pass it a pointer to something the caller owns? This is, truly,
> non-trivial. Also, this is in ../linux/net, not something specific
> to Intel, and there is no macro to handle the network-order. It
> just 'comes-out-right' with Intel machines.
>
> Cheers,
> Dick Johnson
>
> Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
>
> Windows-2000/Professional isn't.
next prev parent reply other threads:[~2002-04-22 16:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-22 15:12 DJ Barrow
2002-04-22 15:48 ` Richard B. Johnson
2002-04-22 16:03 ` DJ Barrow [this message]
2002-04-22 16:21 ` Ben Greear
2002-04-22 20:32 ` Olaf Titz
[not found] <20020422151025Z314220-22651+13849@vger.kernel.org.suse.lists.linux.kernel>
2002-04-22 17:07 ` Andi Kleen
2002-04-22 17:19 ` DJ Barrow
2002-04-23 14:15 ` David S. Miller
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=20020422160154Z314241-22651+13871@vger.kernel.org \
--to=dj.barrow@asitatech.com \
--cc=brian.osullivan@asitatech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=root@chaos.analogic.com \
/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
all inboxes | Powered by JetHome®