hdt: Hide show/set help when no module is defined
authorPierre-Alexandre Meyer <pierre@mouraf.org>
Sun, 22 Mar 2009 02:51:21 +0000 (19:51 -0700)
committerPierre-Alexandre Meyer <pierre@mouraf.org>
Sun, 22 Mar 2009 02:51:21 +0000 (19:51 -0700)
Impact: Help output improved.

Small improvement in the module help output: the module_descr structure can be
defined but without any module. Add this sanity check.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
com32/hdt/hdt-cli-hdt.c

index fe2c11e..41bb30c 100644 (file)
@@ -112,7 +112,8 @@ static void show_cli_help(int argc __unused, char** argv __unused,
        }
 
        /* List secondly the show modules of the mode */
-       if (current_mode->show_modules != NULL ) {
+       if (current_mode->show_modules != NULL &&
+           current_mode->show_modules->nb_modules != 0) {
                printf("show commands:\n");
                for (j = 0; j < current_mode->show_modules->nb_modules; j++) {
                        printf("\t%s\n",
@@ -121,7 +122,8 @@ static void show_cli_help(int argc __unused, char** argv __unused,
        }
 
        /* List thirdly the set modules of the mode */
-       if (current_mode->set_modules != NULL ) {
+       if (current_mode->set_modules != NULL &&
+           current_mode->set_modules->nb_modules != 0) {
                printf("set commands:\n");
                for (j = 0; j < current_mode->set_modules->nb_modules; j++) {
                        printf("\t%s\n",