From: Anders Kaseorg Date: Sat, 5 Nov 2016 00:17:32 +0000 (-0400) Subject: Remove NULL checks for AFS_NONNULL parameters X-Git-Tag: upstream/1.8.0_pre1^2~15 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=3704fc6f2e6716d95446cd10aa2ec798be13472c;p=packages%2Fo%2Fopenafs.git Remove NULL checks for AFS_NONNULL parameters Recent GCC warns about opr_Assert(p != NULL), where p is an __attribute__((__nonnull__)) parameter, just like clang did before those clang warnings were silenced by 11852, 11853. Now, we could go and add more autoconf tests and pragmas to silence the GCC versions of these warnings. However, I maintain that silencing the warnings is the wrong approach. The asserts in question have no purpose. They do not add any safety, because GCC and clang are optimizing them away at compile time (without proof!—they take the declaration at its word that NULL will never be passed). Just remove them. Fixes these warnings (errors with --enable-checking) from GCC 6.2: In file included from casestrcpy.c:17:0: casestrcpy.c: In function ‘opr_lcstring’: casestrcpy.c:26:31: error: nonnull argument ‘d’ compared to NULL [-Werror=nonnull-compare] opr_Assert(s != NULL && d != NULL); ^ /…/openafs/include/afs/opr.h:28:15: note: in definition of macro ‘__opr_Assert’ do {if (!(ex)) opr_AssertionFailed(__FILE__, __LINE__);} while(0) ^~ casestrcpy.c:26:5: note: in expansion of macro ‘opr_Assert’ opr_Assert(s != NULL && d != NULL); ^~~~~~~~~~ casestrcpy.c:26:18: error: nonnull argument ‘s’ compared to NULL [-Werror=nonnull-compare] opr_Assert(s != NULL && d != NULL); ^ /…/openafs/include/afs/opr.h:28:15: note: in definition of macro ‘__opr_Assert’ do {if (!(ex)) opr_AssertionFailed(__FILE__, __LINE__);} while(0) ^~ casestrcpy.c:26:5: note: in expansion of macro ‘opr_Assert’ opr_Assert(s != NULL && d != NULL); ^~~~~~~~~~ casestrcpy.c: In function ‘opr_ucstring’: casestrcpy.c:46:31: error: nonnull argument ‘d’ compared to NULL [-Werror=nonnull-compare] opr_Assert(s != NULL && d != NULL); ^ /…/openafs/include/afs/opr.h:28:15: note: in definition of macro ‘__opr_Assert’ do {if (!(ex)) opr_AssertionFailed(__FILE__, __LINE__);} while(0) ^~ casestrcpy.c:46:5: note: in expansion of macro ‘opr_Assert’ opr_Assert(s != NULL && d != NULL); ^~~~~~~~~~ casestrcpy.c:46:18: error: nonnull argument ‘s’ compared to NULL [-Werror=nonnull-compare] opr_Assert(s != NULL && d != NULL); ^ /…/openafs/include/afs/opr.h:28:15: note: in definition of macro ‘__opr_Assert’ do {if (!(ex)) opr_AssertionFailed(__FILE__, __LINE__);} while(0) ^~ casestrcpy.c:46:5: note: in expansion of macro ‘opr_Assert’ opr_Assert(s != NULL && d != NULL); ^~~~~~~~~~ casestrcpy.c: In function ‘opr_strcompose’: /…/openafs/include/afs/opr.h:28:12: error: nonnull argument ‘buf’ compared to NULL [-Werror=nonnull-compare] do {if (!(ex)) opr_AssertionFailed(__FILE__, __LINE__);} while(0) ^ /…/openafs/include/afs/opr.h:37:25: note: in expansion of macro ‘__opr_Assert’ # define opr_Assert(ex) __opr_Assert(ex) ^~~~~~~~~~~~ casestrcpy.c:98:5: note: in expansion of macro ‘opr_Assert’ opr_Assert(buf != NULL); ^~~~~~~~~~ kalocalcell.c: In function ‘ka_CellToRealm’: /…/openafs/include/afs/opr.h:28:12: error: nonnull argument ‘realm’ compared to NULL [-Werror=nonnull-compare] do {if (!(ex)) opr_AssertionFailed(__FILE__, __LINE__);} while(0) ^ /…/openafs/include/afs/opr.h:37:25: note: in expansion of macro ‘__opr_Assert’ # define opr_Assert(ex) __opr_Assert(ex) ^~~~~~~~~~~~ kalocalcell.c:117:5: note: in expansion of macro ‘opr_Assert’ opr_Assert(realm != NULL); ^~~~~~~~~~ Change-Id: I6fd618ed49255d7b3de2f8f3424d9659890829c0 Reviewed-on: https://gerrit.openafs.org/12442 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- diff --git a/src/kauth/kalocalcell.c b/src/kauth/kalocalcell.c index c28cb4aba..7c2f4994c 100644 --- a/src/kauth/kalocalcell.c +++ b/src/kauth/kalocalcell.c @@ -114,8 +114,6 @@ ka_CellToRealm(char *cell, char *realm, int *local) { int code = 0; - opr_Assert(realm != NULL); - LOCK_GLOBAL_MUTEX; code = ka_ExpandCell(cell, realm, local); ucstring(realm, realm, MAXKTCREALMLEN); diff --git a/src/opr/casestrcpy.c b/src/opr/casestrcpy.c index 37f5c4cab..8cfe37d99 100644 --- a/src/opr/casestrcpy.c +++ b/src/opr/casestrcpy.c @@ -23,7 +23,6 @@ lcstring(char *d, const char *s, int n) char *original_d = d; char c; - opr_Assert(s != NULL && d != NULL); while (n) { c = *s++; if (isupper(c)) @@ -43,7 +42,6 @@ ucstring(char *d, const char *s, int n) char *original_d = d; char c; - opr_Assert(s != NULL && d != NULL); while (n) { c = *s++; if (islower(c)) @@ -95,7 +93,6 @@ strcompose(char *buf, size_t len, ...) char *str; size_t slen; - opr_Assert(buf != NULL); if (len <= 0) return NULL;