Subject: [patch] menuc bug in mdb.c
To: None <tech-userlevel@NetBSD.org>
From: Devon H. O'Dell <devon.odell@coyotepoint.com>
List: tech-userlevel
Date: 11/13/2007 10:58:48
This is a multi-part message in MIME format.
--------------050806050605010805050804
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hey All,
In playing with menuc for a work project, I found an issue in
menu_sys.defs / mdb.c where the generated output actually fails to
compile when dynamic menus are not enabled. I suppose this hasn't been
noticed because it's not actually used outside of sysinst.
num_menus Is only declared if dynamic menus are enabled, however it is
referenced outside of #ifdef protection in process_menu(). The attached
patch to mdb.c generates a declaration for this in case dynamic menus
are not used. I think the placement is ok. I worried about the placement
of the patch in mdb.c versus doing something else in menu_sys.defs, but
I noticed that there are quite a few expectations about various symbols
being defined by the generator / used in the defs file, so I figure this
fix is as good as any.
Haven't received mailing list confirmation yet, so please CC me on
replies. I've also filed a PR for this bug.
Thanks!
--dho
--------------050806050605010805050804
Content-Type: text/plain;
name="mdb.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="mdb.diff"
? mdb.diff
Index: mdb.c
===================================================================
RCS file: /workspaces/cvsroot/nbsrc/usr.bin/menuc/mdb.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mdb.c
--- mdb.c 26 Oct 2006 03:06:40 -0000 1.1.1.1
+++ mdb.c 13 Nov 2007 15:48:22 -0000
@@ -361,6 +361,10 @@
/* menus */
+ if (!do_dynamic) {
+ (void) fprintf (out_file, "static int num_menus = %d;\n", menu_no);
+ }
+
(void) fprintf (out_file, "static struct menudesc menu_def[] = {\n");
for (i=0; i<menu_no; i++) {
(void) fprintf (out_file,
--------------050806050605010805050804--