| From b315c53f2803b84e35fe646aa82702b82e8ecd98 Mon Sep 17 00:00:00 2001 |
| From: Stewart Smith <stewart@linux.vnet.ibm.com> |
| Date: Thu, 25 Aug 2016 20:07:58 +1000 |
| Subject: [PATCH 08/10] Fix compiler can assume address will never be NULL |
| error with GCC6 |
| MIME-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| 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. |
| |
| ../../../../src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H: |
| In constructor ‘PRDF::AttnTypeRegister::AttnTypeRegister(PRDF::SCAN_COMM_REGISTE |
| R_CLASS&, PRDF::SCAN_COMM_REGISTER_CLASS&, PRDF::SCAN_COMM_REGISTER_CLASS&, PRDF |
| ::SCAN_COMM_REGISTER_CLASS&)’: |
| ../../../../src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H:4 |
| 42:21: error: the compiler can assume that the address of ‘i_check’ will never b |
| e NULL [-Werror=address] |
| iv_check( NULL == &i_check ? &cv_null : &i_check), |
| ~~^~~~~~~~~~~ |
| ../../../../src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H:4 |
| 43:21: error: the compiler can assume that the address of ‘i_recov’ will never b |
| e NULL [-Werror=address] |
| iv_recov( NULL == &i_recov ? &cv_null : &i_recov), |
| ~~^~~~~~~~~~~ |
| ../../../../src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H:4 |
| 44:22: error: 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), |
| ~~^~~~~~~~~~~~~ |
| ../../../../src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H:4 |
| 45:22: error: 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), |
| ~~^~~~~~~~~~~~ |
| |
| Change-Id: Iecd8636da67aac24f64f73fd82b1f7ccbfced900 |
| Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> |
| --- |
| .../common/framework/register/prdfOperatorRegister.H | 16 ++++++++-------- |
| .../prdf/common/framework/register/prdfScanFacility.C | 2 +- |
| 2 files changed, 9 insertions(+), 9 deletions(-) |
| |
| diff --git a/src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H b/src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H |
| index b0513e4..a26a76e 100755 |
| --- a/src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H |
| +++ b/src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H |
| @@ -434,15 +434,15 @@ 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 ) : |
| + 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( ), |
| - 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_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_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 0d379cf..cad5ce8 100755 |
| --- a/src/usr/diag/prdf/common/framework/register/prdfScanFacility.C |
| +++ b/src/usr/diag/prdf/common/framework/register/prdfScanFacility.C |
| @@ -166,7 +166,7 @@ SCAN_COMM_REGISTER_CLASS & ScanFacility::GetAttnTypeRegister( |
| SCAN_COMM_REGISTER_CLASS * i_special, |
| SCAN_COMM_REGISTER_CLASS * i_proccs ) |
| { |
| - AttnTypeRegister r(*i_check, *i_recov, *i_special, *i_proccs); |
| + AttnTypeRegister r(i_check, i_recov, i_special, i_proccs); |
| return iv_attnRegFw.get(r); |
| } |
| |
| -- |
| 2.7.4 |
| |