]> sourceware.org Git - lvm2.git/commitdiff
cov: ensure cname exists before derefering it
authorZdenek Kabelac <zkabelac@redhat.com>
Tue, 25 Jun 2019 13:29:26 +0000 (15:29 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 9 Aug 2019 10:57:07 +0000 (12:57 +0200)
Just make it clear to analyzers  cname can't be NULL.
TODO: maybe exclude NULL at front of the function...

tools/command.c

index 724040e39a6cccecc75dacf276e87433791d4283..2e69effcb550e32adaaf812cf9088df4c34cfc8d 100644 (file)
@@ -1935,7 +1935,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
                         * see print_common_options_cmd()
                         */
 
-                       if ((cname->variants > 1) && cname->common_options[opt_enum])
+                       if (cname && (cname->variants > 1) && cname->common_options[opt_enum])
                                continue;
 
                        printf("\n\t[");
@@ -1975,7 +1975,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
                         * see print_common_options_cmd()
                         */
 
-                       if ((cname->variants > 1) && cname->common_options[opt_enum])
+                       if (cname && (cname->variants > 1) && cname->common_options[opt_enum])
                                continue;
 
                        printf("\n\t[");
@@ -3438,7 +3438,7 @@ static int _print_man(char *name, char *des_file, int secondary)
 
                if (!prev_cmd || strcmp(prev_cmd->name, cmd->name)) {
                        printf(".SH NAME\n");
-                       if (cname->desc)
+                       if (cname && cname->desc)
                                printf("%s - %s\n", lvmname, cname->desc);
                        else
                                printf("%s\n", lvmname);
This page took 0.034599 seconds and 5 git commands to generate.