Subject: DHCP enum usage fixes
To: , <mellon@netbsd.org>
From: Ben Harris <bjh21@netbsd.org>
List: tech-net
Date: 01/06/2002 14:24:47
It's possible that NetBSD/arm will change to using -fshort-enums by
default some time soon.  It looks like the ISC DHCP code will need some
fixes to make this work.  Specifically:

is_identifier (in dhctoken.h) compares an enum dhcp_token against EOF,
which isn't a valid element of that enumeration.  My fix is to add EOF to
the enum.

ns_parserr (in ns_parse.c) can return -1, but its return type is an enum
that doesn't include -1 as a possible value.  Again, I've added it.

These fixes are probably not optimal, but they're enough (with some
"comparison is always true" fixes) to get DHCP to compile with
-fshort-enums.

Any thoughts?

Index: dist/dhcp/includes/dhctoken.h
===================================================================
RCS file: /cvsroot/basesrc/dist/dhcp/includes/dhctoken.h,v
retrieving revision 1.1
diff -u -r1.1 dhctoken.h
--- dist/dhcp/includes/dhctoken.h	2001/08/03 11:35:35	1.1
+++ dist/dhcp/includes/dhctoken.h	2002/01/03 22:34:35
@@ -42,6 +42,7 @@
  */

 enum dhcp_token {
+	XEOF = EOF,
 	SEMI = ';',
 	DOT = '.',
 	COLON = ':',
Index: dist/dhcp/includes/isc-dhcp/result.h
===================================================================
RCS file: /cvsroot/basesrc/dist/dhcp/includes/isc-dhcp/result.h,v
retrieving revision 1.1
diff -u -r1.1 result.h
--- dist/dhcp/includes/isc-dhcp/result.h	2001/08/03 11:35:35	1.1
+++ dist/dhcp/includes/isc-dhcp/result.h	2002/01/03 22:34:35
@@ -26,6 +26,7 @@
 ISC_LANG_BEGINDECLS

 typedef enum {
+	ISC_R_MINUSONE = -1,
 	ISC_R_SUCCESS = 0,
 	ISC_R_NOMEMORY = 1,
 	ISC_R_TIMEDOUT = 2,

-- 
Ben Harris                                                   <bjh21@netbsd.org>
Portmaster, NetBSD/arm26               <URL:http://www.netbsd.org/Ports/arm26/>