Date: Wed, 15 Mar 1995 10:31:13 -0800 (PST) From: "Rodney W. Grimes" <rgrimes@gndrsh.aac.dev.com> To: dufault@hda.com (Peter Dufault) Cc: charnier@lirmm.fr, current@FreeBSD.org Subject: Re: scsi_sense Message-ID: <199503151831.KAA13156@gndrsh.aac.dev.com> In-Reply-To: <199503151812.NAA00750@hda.com> from "Peter Dufault" at Mar 15, 95 01:12:14 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> > Philippe Charnier writes: > > > > Hello, > > > > > > from scsi_sence.c (in src/sys/scsi) > > > > {0x26, 0x03, "Threshold parameters not supported" }, > > {0x46, 0x00, "Unsuccessful soft reset" }, > > #endif /* NO_SCSI_SENSE */ > > {0xff, 0xff, 0 }, > > }; > > > > char *scsi_sense_desc(int asc, int ascq) > > { > > int i; > > for (i = 0; i < sizeof(tab) / sizeof(tab[0]); i++) > > if (tab[i].asc == asc && tab[i].ascq == ascq) > > return tab[i].desc; > > > > return "no available sense description"; > > } > > > > Why this code don't use {0xff, 0xff, 0 } as a end of list? > > Because we know the table size. I agree with Peter here, the way he has coded it is more efficent. But I do have a concert about the 0xff, 0xff, 0 at the end of the table. What happens if (and don't say no device should ever return this value you never know what might go wrong) a device returns asc=0xff, ascq=0xff. We end up returning a null pointer, this is not good :-(. How about: {0xff, 0xff, "Sense values are invalid (0xFF, 0xFF)"}, That way if this boundary condition is ever seen atleast we do return a pointer to a string that does tell what is wrong! -- Rod Grimes rgrimes@gndrsh.aac.dev.com Accurate Automation Company Custom computers for FreeBSD
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199503151831.KAA13156>