On Sun, Sep 02, 2012 at 08:36:57PM +0200, Otto Moerbeek wrote:
> On Sun, Sep 02, 2012 at 04:18:17PM +0200, rustyBSD wrote:
> 
> > Le 02/09/2012 16:06, rustyBSD a ?crit :
> > > [demime 1.01d removed an attachment of type text/x-patch which had a name 
> > > of scsi.c.diff]
> > Mmhhh...
> > 
> > --- scsi.c    Sun Sep  2 15:47:45 2012
> > +++ scsi.c    Sun Sep  2 16:00:42 2012
> > @@ -223,6 +223,7 @@
> >          case 'z':
> >          {
> >              char *p = malloc(count + 1);
> > +            if (!p) err(errno, "malloc failed");
> 
> Confusing errno and exit code. Just use 1. Or err(1, NULL). The
> default message is clear enough.
> 
> >              p[count] = 0;
> >              strncpy(p, (char *)arg, count);
> >              if (letter == 'z')
> > @@ -307,6 +308,8 @@
> >              data_fmt = cget(&h, 0);
> >  
> >              scsireq->databuf = malloc(count);
> > +            if (!scsireq->databuf)
> > +                err(errno, "malloc failed");
> 
> Same here.
> 
> And I prefer == NULL to !. I know it's equivalent, but reserveig ! for
> boolean values makes sense.
> 
>       -Otto
> 
> >  
> >              if (data_phase == out) {
> >                  if (strcmp(data_fmt, "-") == 0)    {
> 

It looks like the err() was caused by an incomplete mickey transition
from fprint(stderr ...)/exit(n) to err(). And previous exit(n)'s were
using errno as the exit value.

A quick look shows that there are likely some fprintf()/exit()'s
that could still be replaced with errx().

.... Ken

Reply via email to