From: Brad King Date: Wed, 21 Oct 2015 15:59:45 +0000 (-0400) Subject: Invert logic of ternary pointer checks X-Git-Tag: v3.1.900a~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fe3bcb8c9be3e9476665d8b167f40cd905aac70;p=thirdparty%2Flibarchive.git Invert logic of ternary pointer checks 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. --- diff --git a/libarchive/archive_read.c b/libarchive/archive_read.c index 41842d4e5..033ed8b57 100644 --- a/libarchive/archive_read.c +++ b/libarchive/archive_read.c @@ -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 diff --git a/libarchive/archive_read_support_format_7zip.c b/libarchive/archive_read_support_format_7zip.c index 8dc5607fc..90901acb7 100644 --- a/libarchive/archive_read_support_format_7zip.c +++ b/libarchive/archive_read_support_format_7zip.c @@ -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); } diff --git a/libarchive/archive_write.c b/libarchive/archive_write.c index 9f707f07d..e3fa3357b 100644 --- a/libarchive/archive_write.c +++ b/libarchive/archive_write.c @@ -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