]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Invert logic of ternary pointer checks
authorBrad King <brad.king@kitware.com>
Wed, 21 Oct 2015 15:59:45 +0000 (11:59 -0400)
committerBrad King <brad.king@kitware.com>
Mon, 26 Oct 2015 14:17:49 +0000 (10:17 -0400)
A PGI compiler warning is triggered by expressions like

  ptr == NULL ? NULL : ptr

that the PGI compiler handles incorrectly.  It chooses the pointer type
of the first option (void*) and warns about conversion of the second
without a cast.  Flip the expression logic to

  ptr != NULL ? ptr : NULL

to help the compiler choose the proper result type.

libarchive/archive_read.c
libarchive/archive_read_support_format_7zip.c
libarchive/archive_write.c

index 41842d4e5f1b555553c9d3d857e663f4f87e11bf..033ed8b57accddf571a2d6d985336d0535f3f4e3 100644 (file)
@@ -1157,7 +1157,7 @@ static const char *
 _archive_filter_name(struct archive *_a, int n)
 {
        struct archive_read_filter *f = get_filter(_a, n);
-       return f == NULL ? NULL : f->name;
+       return f != NULL ? f->name : NULL;
 }
 
 static int64_t
index 8dc5607fcd8f9b83082be6b09455125f468024a0..90901acb710fff13d8737c13df21272bb430525b 100644 (file)
@@ -1201,7 +1201,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
                        }
                        archive_set_error(&a->archive, err,
                            "Internal error initializing decompressor: %s",
-                           detail == NULL ? "??" : detail);
+                           detail != NULL ? detail : "??");
                        zip->bzstream_valid = 0;
                        return (ARCHIVE_FAILED);
                }
index 9f707f07d7509f5cb9156afbcb7afa05fa6a7f01..e3fa3357ba7b3d6b9dc3fd14f42312ff24b41aed 100644 (file)
@@ -725,7 +725,7 @@ static const char *
 _archive_filter_name(struct archive *_a, int n)
 {
        struct archive_write_filter *f = filter_lookup(_a, n);
-       return f == NULL ? NULL : f->name;
+       return f != NULL ? f->name : NULL;
 }
 
 static int64_t