public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* novice coding in /linux/net/ipv4/util.c From: DJ Barrow <dj.barrow@asitatech.com>
@ 2002-04-22 15:12 DJ Barrow
  2002-04-22 15:48 ` Richard B. Johnson
  0 siblings, 1 reply; 8+ messages in thread
From: DJ Barrow @ 2002-04-22 15:12 UTC (permalink / raw)
  To: Kernel Mailing List

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 *) &in;
        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));

^ permalink raw reply	[flat|nested] 8+ messages in thread
[parent not found: <20020422151025Z314220-22651+13849@vger.kernel.org.suse.lists.linux.kernel>]

end of thread, other threads:[~2002-04-23 14:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-22 15:12 novice coding in /linux/net/ipv4/util.c From: DJ Barrow <dj.barrow@asitatech.com> DJ Barrow
2002-04-22 15:48 ` Richard B. Johnson
2002-04-22 16:03   ` DJ Barrow
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox