Skip to content

Commit

Permalink
Fix compiler can assume address will never be NULL error with GCC6
Browse files Browse the repository at this point in the history
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 <stewart@linux.vnet.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/36899
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Reviewed-by: Zane C. Shelley <zshelle@us.ibm.com>
Reviewed-by: Brian J. Stegmiller <bjs@us.ibm.com>
Reviewed-by: Benjamin J. Weisenbeck <bweisenb@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
stewartsmith authored and dcrowell77 committed Mar 21, 2017
1 parent 579dc1d commit bb3ec0a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
Expand Up @@ -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 );
}

/*---------------------------------------------------------------------*/
Expand Down
20 changes: 10 additions & 10 deletions src/usr/diag/prdf/common/framework/register/prdfOperatorRegister.H
Expand Up @@ -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;
Expand Down
Expand Up @@ -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);
}

Expand Down

0 comments on commit bb3ec0a

Please sign in to comment.