From owner-freebsd-current Wed Mar 15 10:44:56 1995 Return-Path: current-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id KAA07080 for current-outgoing; Wed, 15 Mar 1995 10:44:56 -0800 Received: from gndrsh.aac.dev.com (gndrsh.aac.dev.com [198.145.92.241]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id KAA07071 for ; Wed, 15 Mar 1995 10:44:52 -0800 Received: (from rgrimes@localhost) by gndrsh.aac.dev.com (8.6.8/8.6.6) id KAA13156; Wed, 15 Mar 1995 10:31:13 -0800 From: "Rodney W. Grimes" Message-Id: <199503151831.KAA13156@gndrsh.aac.dev.com> Subject: Re: scsi_sense To: dufault@hda.com (Peter Dufault) Date: Wed, 15 Mar 1995 10:31:13 -0800 (PST) Cc: charnier@lirmm.fr, current@FreeBSD.org In-Reply-To: <199503151812.NAA00750@hda.com> from "Peter Dufault" at Mar 15, 95 01:12:14 pm X-Mailer: ELM [version 2.4 PL23] Content-Type: text Content-Length: 1404 Sender: current-owner@FreeBSD.org Precedence: bulk > > 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