From bb3ec0a1bdf1e351c4d4cf210f625f7bce2581dc Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Thu, 25 Aug 2016 20:07:58 +1000 Subject: [PATCH] Fix compiler can assume address will never be NULL error with GCC6 So, it turns out that relying on the address of something passed by reference being able to be NULL isn't exactly a good idea, or remotely obvious code. So, instead, do the sane thing and pass a pointer and check it. In constructor ?PRDF::AttnTypeRegister::AttnTypeRegister(...)?: the compiler can assume that the address of ?i_check? will never be NULL [-Werror=address] iv_check( NULL == &i_check ? &cv_null : &i_check), ~~^~~~~~~~~~~ the compiler can assume that the address of ?i_recov? will never be NULL [-Werror=address] iv_recov( NULL == &i_recov ? &cv_null : &i_recov), ~~^~~~~~~~~~~ the compiler can assume that the address of ?i_special? will never be NULL [-Werror=address] iv_special(NULL == &i_special ? &cv_null : &i_special), ~~^~~~~~~~~~~~~ the compiler can assume that the address of ?i_proccs? will never be NULL [-Werror=address] iv_proccs( NULL == &i_proccs ? &cv_null : &i_proccs), ~~^~~~~~~~~~~~ src/usr/diag/prdf/common/framework/register/prdfErrorRegister.C:123: the compiler can assume that the address of ?r? will never be NULL [-Werror=address] PRDF_ASSERT( &r != NULL ); Change-Id: I46181487cea89c8918899bab2ab17c82b68122ee Signed-off-by: Stewart Smith Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/36899 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Tested-by: Jenkins OP Build CI Reviewed-by: Zane C. Shelley Reviewed-by: Brian J. Stegmiller Reviewed-by: Benjamin J. Weisenbeck Reviewed-by: Daniel M. Crowell --- .../framework/register/prdfErrorRegister.C | 2 -- .../framework/register/prdfOperatorRegister.H | 20 +++++++++---------- .../framework/register/prdfScanFacility.C | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/usr/diag/prdf/common/framework/register/prdfErrorRegister.C b/src/usr/diag/prdf/common/framework/register/prdfErrorRegister.C index f3939d1f5b2..a4825427c72 100755 --- a/src/usr/diag/prdf/common/framework/register/prdfErrorRegister.C +++ b/src/usr/diag/prdf/common/framework/register/prdfErrorRegister.C @@ -120,8 +120,6 @@ ErrorRegister::ErrorRegister( SCAN_COMM_REGISTER_CLASS & r, ResolutionMap & rm, ErrorRegisterType(), scr(r), scr_rc(SUCCESS), rMap(rm), xNoErrorOnZeroScr(false), xScrId(scrId) { - PRDF_ASSERT( &r != NULL ); - PRDF_ASSERT( &rm != NULL ); } /*---------------------------------------------------------------------*/ diff --git a/src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H b/src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H index 893ee7ca06d..07d5ac981e5 100755 --- a/src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H +++ b/src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H @@ -513,17 +513,17 @@ class AttnTypeRegister : public SCAN_COMM_REGISTER_CLASS iv_bs = &iv_iBS; } - AttnTypeRegister( SCAN_COMM_REGISTER_CLASS & i_check, - SCAN_COMM_REGISTER_CLASS & i_recov, - SCAN_COMM_REGISTER_CLASS & i_special, - SCAN_COMM_REGISTER_CLASS & i_proccs, - SCAN_COMM_REGISTER_CLASS & i_hostattn ) : + AttnTypeRegister( SCAN_COMM_REGISTER_CLASS *i_check, + SCAN_COMM_REGISTER_CLASS *i_recov, + SCAN_COMM_REGISTER_CLASS *i_special, + SCAN_COMM_REGISTER_CLASS *i_proccs, + SCAN_COMM_REGISTER_CLASS *i_hostattn ) : SCAN_COMM_REGISTER_CLASS( ), - iv_check( NULL == &i_check ? &cv_null : &i_check), - iv_recov( NULL == &i_recov ? &cv_null : &i_recov), - iv_special( NULL == &i_special ? &cv_null : &i_special), - iv_proccs( NULL == &i_proccs ? &cv_null : &i_proccs), - iv_hostattn( NULL == &i_hostattn ? &cv_null : &i_hostattn), + iv_check( NULL == i_check ? &cv_null : i_check), + iv_recov( NULL == i_recov ? &cv_null : i_recov), + iv_special( NULL == i_special ? &cv_null : i_special), + iv_proccs( NULL == i_proccs ? &cv_null : i_proccs), + iv_hostattn( NULL == i_hostattn ? &cv_null : i_hostattn), iv_iBS(0) // will fully initialize this inside ctor. { uint32_t l_length = 1024; diff --git a/src/usr/diag/prdf/common/framework/register/prdfScanFacility.C b/src/usr/diag/prdf/common/framework/register/prdfScanFacility.C index 6c46dea931b..ad045614df8 100755 --- a/src/usr/diag/prdf/common/framework/register/prdfScanFacility.C +++ b/src/usr/diag/prdf/common/framework/register/prdfScanFacility.C @@ -160,7 +160,7 @@ SCAN_COMM_REGISTER_CLASS & ScanFacility::GetAttnTypeRegister( SCAN_COMM_REGISTER_CLASS * i_proccs, SCAN_COMM_REGISTER_CLASS * i_hostattn ) { - AttnTypeRegister r(*i_check, *i_recov, *i_special, *i_proccs, *i_hostattn); + AttnTypeRegister r(i_check, i_recov, i_special, i_proccs, i_hostattn); return iv_attnRegFw.get(r); }