Re: [Patch] libcldc,cldcli: Use humanized error messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 26 Aug 2009 22:26:50 -0400, Jeff Garzik <jeff@xxxxxxxxxx> wrote:
> On 08/26/2009 10:06 PM, Pete Zaitcev wrote:

> > Signed-off-by: Pete Zaitcev<zaitcev@xxxxxxxxxx>
> 
> applied a modified version, see attached...  after that short IRC 
> discussion, I think an array with a range check would be nicer than 
> coding it (though the C compiler should make a nice, efficient table 
> from 'switch' statement for us...)

I don't think it's enough. Look:

+static const char *cld_errlist[] =
+{
+	[CLE_OK]		= "Success",
+	[CLE_SESS_EXISTS]	= "Session exists",

When you do indexed initializations, it's possible to create
empty array elements (currently there are none because indexes
are contiguous). So, the following needs a NULL check:

+	return cld_errlist[ecode];
+}

-- Pete
--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Fedora Clound]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux