[Sheepdog] [PATCH, RFC] collie: use exit codes to distinguish between errors

Chris Webb chris at arachsys.com
Thu Jun 16 18:52:47 CEST 2011


MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp> writes:

> At Thu, 16 Jun 2011 17:01:40 +0100,
> Chris Webb wrote:
> > 
> > > >  		} else if (ret == SD_RES_NO_OBJ) {
> > > >  			fprintf(stderr, "no such attribute, %s\n", key);
> > > >  		} else
> > > >  			fprintf(stderr, "failed to find attr oid, %s\n",
> > > >  				sd_strerror(ret));
> > > > -		return 1;
> > > > +		return EXIT_MISSING;
> > > 
> > > Should we return EXIT_FAILURE if (ret != SD_RES_NO_OBJ)?
> > 
> > I picked EXIT_MISSING because both branches quoted above report an error
> > about something not being found to stderr, but I'm happy to replace with
> > EXIT_FAILURE for the 'attr oid not found' case if you think that's more
> > appropriate? What circumstances can this happen in?
> 
> For example, if a disk I/O error happens, we cannot find the object.
> I think the above error message is a bit confusing.  If there is no
> such an attribute and no error is reported, find_vdi_attr_oid()
> returns SD_RES_NO_OBJ, so EXIT_FAILURE is better when ret != SD_RES_NO_OBJ.

Yes, I agree---it would be very weird to get 'not found' with a disk error.

Best wishes,

Chris.



More information about the sheepdog mailing list