[Lsb-messages] /var/www/bzr/lsb/devel/misc-test r2396: rework cmdchk slightly: use null-terminated lists

Mats Wichmann mats at linuxfoundation.org
Sat Sep 28 15:03:05 UTC 2013


------------------------------------------------------------
revno: 2396
committer: Mats Wichmann <mats at linuxfoundation.org>
branch nick: misc-test
timestamp: Sat 2013-09-28 09:03:05 -0600
message:
  rework cmdchk slightly: use null-terminated lists
modified:
  cmdchk/cmdchk.c
  cmdchk/cmds.h
  cmdchk/mkcmdlist
  package/Makefile
-------------- next part --------------
=== modified file 'cmdchk/cmdchk.c'
--- a/cmdchk/cmdchk.c	2011-02-25 21:49:00 +0000
+++ b/cmdchk/cmdchk.c	2013-09-28 15:03:05 +0000
@@ -159,7 +159,8 @@
     struct cmds *cp;
     char tmp_string[TMP_STRING_SIZE + 1];
     char journal_filename[TMP_STRING_SIZE + 1];
-    int i, j;
+    int i;
+    int testcount = 0;
     int option_index = 0;
     int desktop_mode = 1; // default to all modules in cert
     struct utsname unameb;
@@ -286,41 +287,37 @@
      * it's too bad because we do the same loops below, but we need
      * this info line before we start that
      */
-    j = 0;
-    for (i = 0, cp = core_cmdlist;
-	 i < sizeof(core_cmdlist) / sizeof(struct cmds); i++, cp++) {
+    for (cp = core_cmdlist; cp->cmdname; cp++) {
 	if (cp->cmdappearedin <= LSB_Versions_Numeric[LSB_Version]
 	    && (cp->cmdwithdrawnin == 0
 		|| cp->cmdwithdrawnin > LSB_Versions_Numeric[LSB_Version]))
-	    j++;
+	    testcount++;
     }
     if (desktop_mode) {
-	for (i = 0, cp = desktop_cmdlist;
-	     i < sizeof(desktop_cmdlist) / sizeof(struct cmds); i++, cp++)
+	for (cp = desktop_cmdlist; cp->cmdname; cp++) {
 	    if (cp->cmdappearedin <= LSB_Versions_Numeric[LSB_Version]
 		&& (cp->cmdwithdrawnin == 0
-		    || cp->cmdwithdrawnin >
-		    LSB_Versions_Numeric[LSB_Version]))
-		j++;
+		    || cp->cmdwithdrawnin > LSB_Versions_Numeric[LSB_Version]))
+		testcount++;
+	}
     }
-    snprintf(tmp_string, TMP_STRING_SIZE, "\"total tests in cmdchk %d\"", j);
+    snprintf(tmp_string, TMP_STRING_SIZE, 
+                         "\"total tests in cmdchk %d\"", testcount);
     tetj_scenario_info(journal, tmp_string);
 
-    for (i = 0, cp = core_cmdlist;
-	 i < sizeof(core_cmdlist) / sizeof(struct cmds); i++, cp++) {
+    for (cp = core_cmdlist; cp->cmdname; cp++) {
 	if (cp->cmdappearedin <= LSB_Versions_Numeric[LSB_Version]
 	    && (cp->cmdwithdrawnin == 0
 		|| cp->cmdwithdrawnin > LSB_Versions_Numeric[LSB_Version]))
 	    check_cmd(cp, journal);
     }
     if (desktop_mode) {
-	for (i = 0, cp = desktop_cmdlist;
-	     i < sizeof(desktop_cmdlist) / sizeof(struct cmds); i++, cp++)
+	for (cp = desktop_cmdlist; cp->cmdname; cp++) {
 	    if (cp->cmdappearedin <= LSB_Versions_Numeric[LSB_Version]
 		&& (cp->cmdwithdrawnin == 0
-		    || cp->cmdwithdrawnin >
-		    LSB_Versions_Numeric[LSB_Version]))
+		    || cp->cmdwithdrawnin > LSB_Versions_Numeric[LSB_Version]))
 		check_cmd(cp, journal);
+	}
     }
     tetj_close_journal(journal);
     exit(0);

=== modified file 'cmdchk/cmds.h'
--- a/cmdchk/cmds.h	2012-05-24 11:30:53 +0000
+++ b/cmdchk/cmds.h	2013-09-28 15:03:05 +0000
@@ -6,6 +6,7 @@
 	int cmdappearedin;
 	int cmdwithdrawnin;
 };
+
 struct cmds core_cmdlist[] = {
 	{"[", "", 13, 0},
 	{"ar", "", 10, 0},
@@ -158,8 +159,10 @@
 	{"xdg-open", "", 32, 0},
 	{"xdg-screensaver", "", 32, 0},
 	{"zcat", "/bin/zcat", 32, 0},
+	{0, 0, 0, 0}
 };
 
 struct cmds desktop_cmdlist[] = {
+	{0, 0, 0, 0}
 };
 

=== modified file 'cmdchk/mkcmdlist'
--- a/cmdchk/mkcmdlist	2012-05-24 11:30:53 +0000
+++ b/cmdchk/mkcmdlist	2013-09-28 15:03:05 +0000
@@ -27,7 +27,8 @@
 print CMDS "\tchar *cmdpath;\n";
 print CMDS "\tint cmdappearedin;\n";
 print CMDS "\tint cmdwithdrawnin;\n";
-print CMDS "};\nstruct cmds core_cmdlist[] = {\n";
+print CMDS "};\n\n";
+print CMDS "struct cmds core_cmdlist[] = {\n";
 
 # Note: place all commands to core_cmdlist,
 # independently of actual specification module
@@ -55,7 +56,9 @@
 	print CMDS "	{\"$entry->{'Cname'}\", \"$entry->{'Cpath'}\", $cmdappearedin, $cmdwithdrawnin},\n";
 }
 $sth->finish;
-print CMDS "};\n\nstruct cmds desktop_cmdlist[] = {\n";
+print CMDS "	{0, 0, 0, 0}\n";
+print CMDS "};\n\n";
+print CMDS "struct cmds desktop_cmdlist[] = {\n";
 
 # Probably we'll want core/desktop separation in future,
 # but currently we simply leave desktop_cmdlist empty
@@ -85,6 +88,7 @@
 	print CMDS "	{\"$entry->{'Cname'}\", \"$entry->{'Cpath'}\", $cmdappearedin, $cmdwithdrawnin},\n";
 }
 $sth->finish;
+print CMDS "	{0, 0, 0, 0}\n";
 print CMDS "};\n\n";
 
 close(CMDS);

=== modified file 'package/Makefile'
--- a/package/Makefile	2013-09-24 13:15:19 +0000
+++ b/package/Makefile	2013-09-28 15:03:05 +0000
@@ -20,11 +20,11 @@
 # Release number of package relative to specification version
 # Should have leading "."
 # a big number (80-99) is leading up to the next minor spec
-SUB_VERSION=.18
+SUB_VERSION=.19
 
 # We define this here instead of directly in the spec file as
 # we need to be able to work out what the produced rpm files will be called
-RPM_PACKAGE_RELEASE=4
+RPM_PACKAGE_RELEASE=1
 
 # Derive date string for daily snapshots
 ISO_DATE:=$(shell date +"%Y%m%d")



More information about the lsb-messages mailing list