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

Rob Landley rob at landley.net
Thu Apr 13 22:44:00 UTC 2006


On Wednesday 12 April 2006 8:22 am, Denis Vlasenko wrote:
> 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:

But people do build small busyboxes with only one or two applets, and if this 
is a net loss when only one or two applets use it, is it really worth the 
extra complexity?

> -       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?!

Apparently nobody's cared before now.  The most prominent error seems to be 
that somebody else is already listening on that socket, in which case bind 
should have noticed.

But yeah, that should be fixed.

>         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.

Can't the xbind() message give a sufficiently detailed error?

Rob
-- 
Never bet against the cheap plastic solution.



More information about the busybox mailing list