Stewart Smith | 8b90e5b | 2016-11-03 13:43:24 +1100 | [diff] [blame] | 1 | From b315c53f2803b84e35fe646aa82702b82e8ecd98 Mon Sep 17 00:00:00 2001 |
| 2 | From: Stewart Smith <stewart@linux.vnet.ibm.com> |
| 3 | Date: Thu, 25 Aug 2016 20:07:58 +1000 |
| 4 | Subject: [PATCH 08/10] Fix compiler can assume address will never be NULL |
| 5 | error with GCC6 |
| 6 | MIME-Version: 1.0 |
| 7 | Content-Type: text/plain; charset=UTF-8 |
| 8 | Content-Transfer-Encoding: 8bit |
| 9 | |
| 10 | So, it turns out that relying on the address of something passed by |
| 11 | reference being able to be NULL isn't exactly a good idea, or remotely |
| 12 | obvious code. So, instead, do the sane thing and pass a pointer and |
| 13 | check it. |
| 14 | |
| 15 | ../../../../src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H: |
| 16 | In constructor ‘PRDF::AttnTypeRegister::AttnTypeRegister(PRDF::SCAN_COMM_REGISTE |
| 17 | R_CLASS&, PRDF::SCAN_COMM_REGISTER_CLASS&, PRDF::SCAN_COMM_REGISTER_CLASS&, PRDF |
| 18 | ::SCAN_COMM_REGISTER_CLASS&)’: |
| 19 | ../../../../src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H:4 |
| 20 | 42:21: error: the compiler can assume that the address of ‘i_check’ will never b |
| 21 | e NULL [-Werror=address] |
| 22 | iv_check( NULL == &i_check ? &cv_null : &i_check), |
| 23 | ~~^~~~~~~~~~~ |
| 24 | ../../../../src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H:4 |
| 25 | 43:21: error: the compiler can assume that the address of ‘i_recov’ will never b |
| 26 | e NULL [-Werror=address] |
| 27 | iv_recov( NULL == &i_recov ? &cv_null : &i_recov), |
| 28 | ~~^~~~~~~~~~~ |
| 29 | ../../../../src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H:4 |
| 30 | 44:22: error: the compiler can assume that the address of ‘i_special’ will never |
| 31 | be NULL [-Werror=address] |
| 32 | iv_special(NULL == &i_special ? &cv_null : &i_special), |
| 33 | ~~^~~~~~~~~~~~~ |
| 34 | ../../../../src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H:4 |
| 35 | 45:22: error: the compiler can assume that the address of ‘i_proccs’ will never |
| 36 | be NULL [-Werror=address] |
| 37 | iv_proccs( NULL == &i_proccs ? &cv_null : &i_proccs), |
| 38 | ~~^~~~~~~~~~~~ |
| 39 | |
| 40 | Change-Id: Iecd8636da67aac24f64f73fd82b1f7ccbfced900 |
| 41 | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> |
| 42 | --- |
| 43 | .../common/framework/register/prdfOperatorRegister.H | 16 ++++++++-------- |
| 44 | .../prdf/common/framework/register/prdfScanFacility.C | 2 +- |
| 45 | 2 files changed, 9 insertions(+), 9 deletions(-) |
| 46 | |
| 47 | diff --git a/src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H b/src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H |
| 48 | index b0513e4..a26a76e 100755 |
| 49 | --- a/src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H |
| 50 | +++ b/src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H |
| 51 | @@ -434,15 +434,15 @@ class AttnTypeRegister : public SCAN_COMM_REGISTER_CLASS |
| 52 | iv_bs = &iv_iBS; |
| 53 | } |
| 54 | |
| 55 | - AttnTypeRegister( SCAN_COMM_REGISTER_CLASS & i_check, |
| 56 | - SCAN_COMM_REGISTER_CLASS & i_recov, |
| 57 | - SCAN_COMM_REGISTER_CLASS & i_special, |
| 58 | - SCAN_COMM_REGISTER_CLASS & i_proccs ) : |
| 59 | + AttnTypeRegister( SCAN_COMM_REGISTER_CLASS *i_check, |
| 60 | + SCAN_COMM_REGISTER_CLASS *i_recov, |
| 61 | + SCAN_COMM_REGISTER_CLASS *i_special, |
| 62 | + SCAN_COMM_REGISTER_CLASS *i_proccs ) : |
| 63 | SCAN_COMM_REGISTER_CLASS( ), |
| 64 | - iv_check( NULL == &i_check ? &cv_null : &i_check), |
| 65 | - iv_recov( NULL == &i_recov ? &cv_null : &i_recov), |
| 66 | - iv_special(NULL == &i_special ? &cv_null : &i_special), |
| 67 | - iv_proccs( NULL == &i_proccs ? &cv_null : &i_proccs), |
| 68 | + iv_check( NULL == i_check ? &cv_null : i_check), |
| 69 | + iv_recov( NULL == i_recov ? &cv_null : i_recov), |
| 70 | + iv_special(NULL == i_special ? &cv_null : i_special), |
| 71 | + iv_proccs( NULL == i_proccs ? &cv_null : i_proccs), |
| 72 | iv_iBS(0) // will fully initialize this inside ctor. |
| 73 | { |
| 74 | uint32_t l_length = 1024; |
| 75 | diff --git a/src/usr/diag/prdf/common/framework/register/prdfScanFacility.C b/src/usr/diag/prdf/common/framework/register/prdfScanFacility.C |
| 76 | index 0d379cf..cad5ce8 100755 |
| 77 | --- a/src/usr/diag/prdf/common/framework/register/prdfScanFacility.C |
| 78 | +++ b/src/usr/diag/prdf/common/framework/register/prdfScanFacility.C |
| 79 | @@ -166,7 +166,7 @@ SCAN_COMM_REGISTER_CLASS & ScanFacility::GetAttnTypeRegister( |
| 80 | SCAN_COMM_REGISTER_CLASS * i_special, |
| 81 | SCAN_COMM_REGISTER_CLASS * i_proccs ) |
| 82 | { |
| 83 | - AttnTypeRegister r(*i_check, *i_recov, *i_special, *i_proccs); |
| 84 | + AttnTypeRegister r(i_check, i_recov, i_special, i_proccs); |
| 85 | return iv_attnRegFw.get(r); |
| 86 | } |
| 87 | |
| 88 | -- |
| 89 | 2.7.4 |
| 90 | |