[rfc] xioctl()

Mike Frysinger vapier at gentoo.org
Sat Jun 23 20:37:32 UTC 2007


On Saturday 23 June 2007, Tito wrote:
> On Saturday 23 June 2007 22:11:53 Tito wrote:
> > On Saturday 23 June 2007 20:10:39 Bernhard Fischer wrote:
> > > On Sat, Jun 23, 2007 at 01:31:19PM -0400, Mike Frysinger wrote:
> > > >On Saturday 23 June 2007, Mike Frysinger wrote:
> > > >> +int xioctl(int fd, int request, unsigned long arg)
> > > >> +{
> > > >> +       int ret = ioctl(fd, request, arg);
> > > >> +       if (ret != 0)
> > > >> +               bb_perror_msg_and_die("ioctl");
> > > >> +       return ret;
> > > >> +}
> > > >
> > > >actually now that i think about it, considering the usage here (people
> > > > usually only care if it fails, they dont want to read the return
> > > > value), we probably can do:
> > > >void xioctl(...)
> > >
> > > Sounds ok to me. I had a patch which did this but did not apply it (and
> > > forgot to ask..) since i though that discarding the information about
> > > which ioctl it was that failed would not be well received, back then.
> > >
> > > Let's hear what vda says, i'd say fore! :)
> > > _______________________________________________
> > > busybox mailing list
> > > busybox at busybox.net
> > > http://busybox.net/cgi-bin/mailman/listinfo/busybox
> >
> > Hi,
> > in hdparm.c we already have:
> >
> > /* Busybox messages and functions */
> > static int bb_ioctl(int fd, int request, void *argp, const char *string)
> > {
> > 	int e = ioctl(fd, request, argp);
> > 	if (e && string)
> > 		bb_perror_msg(" %s", string);
> > 	return e;
> > }
> >
> > so that we can pass also an error message if needed, maybe this could be
> > also
> >
> > static int bb_ioctl(int fd, int request, void *argp, ...)
> > {
> > 	va_list p;
> > 	char *string;
> > 	va_start(p, request);
> > 	string = va_arg(va_list p,  (char *));
> >
> > 	int e = ioctl(fd, request, argp);
> > 	if (e && string)
> > 		bb_perror_msg(" %s", string);
> > 	va_end(p);
> > 	return e;
> > }
> >
> > untested, just an idea.
> >
> > Ciao,
> > Tito
>
> or better:
>
> static void xioctl(int fd, int request, void *argp, ...)
>  {
>  	va_list p;
>  	char *string;
>  	va_start(p, argp);
>  	string = va_arg(va_list p,  (char *));
>
>  	int e = ioctl(fd, request, argp);
>  	if (e)
>  		bb_perror_msg_and_die(" %s", (string) ? string : "ioctl");
>  	va_end(p);
>   }

i saw the hdparm code, but that's the only case i saw where the fail was 
conditional, so i'm not sure hdparm is worth folding in
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: This is a digitally signed message part.
Url : http://lists.busybox.net/pipermail/busybox/attachments/20070623/9542f39f/attachment-0002.pgp 


More information about the busybox mailing list