[PATCH] add a few new xfuns and use them as appropriate

Denis Vlasenko vda at ilport.com.ua
Wed Apr 12 12:22:24 UTC 2006


On Wednesday 12 April 2006 15:06, Bernhard Fischer wrote:
> >Rediffed patches are attached.
> 
> Cool, thanks.
> 
> I saw that you didn't add a license to the new files in libbb.
> Can we put them under LGPLv2.1 or later?

Sure. LGPL or GPL is fine with me.

> PS:
> The stat4 patch seems to add to the size a bit with gcc >= 4.1 in contrast
> to the other patches so i'm hesitating to apply it for now..

That's because it adds two functions and uses them only five times total
so far. But there are additional places where we can (and should)
call them and save a few more bytes:

-       if (bind(s, (struct sockaddr *)&a, sizeof(a)) < 0)
-               bb_perror_msg_and_die("bind() failed");
-       listen(s, 50);
+       bb_xbind(s, (struct sockaddr *)&a, sizeof(a));
+       listen(s, 50); /* bb_xlisten? */
        sprintf(msg, "accepting UDP packets on addr:port %s:%d\n",
                iface_addr, (int)listen_port);

Wow! There were no error check for listen?!

        addr.sin_port = htons(port);

-       if (bind(s, (struct sockaddr *)&addr, len) < 0)
+       if (bind(s, (struct sockaddr *)&addr, len) < 0) /* bb_xbind? */
                bb_perror_msg_and_die("Cannot bind() port %i", IDENT_PORT);

-       if (listen(s, 5) < 0)
+       if (listen(s, 5) < 0) /* bb_xlisten? */
                bb_perror_msg_and_die("Cannot listen() on port %i", IDENT_PORT);

I did not convert these because that would make bind error messages
less informative, can do it later.
--
vda



More information about the busybox mailing list