]> sourceware.org Git - lvm2.git/commitdiff
lvmetad: check for pointers not NULL
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 9 Nov 2015 08:25:12 +0000 (09:25 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 9 Nov 2015 09:19:19 +0000 (10:19 +0100)
Check for  arg_vgid_lookup and arg_name_lookup not being NULL.
Drop checking arg_vgid and arg_name for NULL since they
are already dereference earlier - thus mostly must be NOT NULL.

(If that would be possible larger rework of this function would be
required).

daemons/lvmetad/lvmetad-core.c

index 78af69b36520fc3f7344a6816b6087fe0d802c25..eb343ab35085c8785911072a6377a57a56254474 100644 (file)
@@ -1378,7 +1378,7 @@ static int update_metadata(lvmetad_state *s, const char *arg_name, const char *a
         * A lookup of the name arg was successful in finding arg_vgid_lookup,
         * but that resulting vgid doesn't match the arg_vgid.
         */
-       if (arg_vgid_lookup && arg_vgid && strcmp(arg_vgid_lookup, arg_vgid)) {
+       if (arg_vgid_lookup && strcmp(arg_vgid_lookup, arg_vgid)) {
                if (arg_name_lookup) {
                        /*
                         * This shouldn't happen.
@@ -1419,7 +1419,7 @@ static int update_metadata(lvmetad_state *s, const char *arg_name, const char *a
         * A lookup of the vgid arg was successful in finding arg_name_lookup,
         * but that resulting name doesn't match the arg_name.
         */
-       if (arg_name_lookup && arg_name && strcmp(arg_name_lookup, arg_name)) {
+       if (arg_name_lookup && strcmp(arg_name_lookup, arg_name)) {
                if (arg_vgid_lookup) {
                        /*
                         * This shouldn't happen.
@@ -1459,7 +1459,7 @@ static int update_metadata(lvmetad_state *s, const char *arg_name, const char *a
         * An existing VG has unchanged name and vgid.
         */
        if (!new_vgid && !new_name) {
-               if (strcmp(arg_name_lookup, arg_name)) {
+               if (arg_name_lookup && strcmp(arg_name_lookup, arg_name)) {
                        /* This shouldn't happen. */
                        ERROR(s, "update_metadata arg_vgid %s arg_name %s mismatch arg_name_lookup %s",
                              arg_vgid, arg_name, arg_name_lookup);
@@ -1467,7 +1467,7 @@ static int update_metadata(lvmetad_state *s, const char *arg_name, const char *a
                        goto update;
                }
 
-               if (strcmp(arg_vgid_lookup, arg_vgid)) {
+               if (arg_vgid_lookup && strcmp(arg_vgid_lookup, arg_vgid)) {
                        /*
                         * This shouldn't usually happen, but could when
                         * disks are moved (or filters are changed?)
This page took 0.047987 seconds and 5 git commands to generate.