Skip to content

Commit

Permalink
Do not check if address is 0/NULL/nullptr
Browse files Browse the repository at this point in the history
The compiler (GCC and Clang) will report that comparing address of an
object to 0/NULL/nullptr will always be false. The address is not
the same as pointer.

The following errors are reported by GCC (6.0.0, r233941):

    L1Trigger/GlobalCaloTrigger/plugins/L1GctEmulator.cc:130:9: error: the compiler can assume that the address of 'c' will never be NULL [-Werror=address]
    L1Trigger/GlobalCaloTrigger/plugins/L1GctPrintLuts.cc:159:9: error: the compiler can assume that the address of 'c' will never be NULL [-Werror=address]
    L1Trigger/GlobalCaloTrigger/test/gctTestFunctions.cc:55:12: error: the compiler can assume that the address of 'c' will never be NULL [-Werror=address]
    L1Trigger/GlobalCaloTrigger/test/L1GctTest.cc:207:12: error: the compiler can assume that the address of 'c' will never be NULL [-Werror=address]
    L1Trigger/L1TGlobal/src/L1TMenuEditor/xsd/cxx/tree/elements.hxx:380:21: error: the compiler can assume that the address of 'x' will never be NULL [-Werror=address]

Signed-off-by: David Abdurachmanov <David.Abdurachmanov@cern.ch>
  • Loading branch information
David Abdurachmanov authored and David Abdurachmanov committed Mar 7, 2016
1 parent 5cd610a commit ff3d04c
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 19 deletions.
6 changes: 0 additions & 6 deletions L1Trigger/GlobalCaloTrigger/plugins/L1GctEmulator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ void L1GctEmulator::endJob()
int L1GctEmulator::configureGct(const edm::EventSetup& c)
{
int success = 0;
if (&c==0) {
success = -1;
if (m_verbose) {
edm::LogWarning("L1GctConfigFailure") << "Cannot find EventSetup information." << std::endl;
}
}

if (success == 0) {
// get data from EventSetup
Expand Down
4 changes: 0 additions & 4 deletions L1Trigger/GlobalCaloTrigger/plugins/L1GctPrintLuts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ L1GctPrintLuts::beginJob()
int L1GctPrintLuts::configureGct(const edm::EventSetup& c)
{
int success = 0;
if (&c==0) {
success = -1;
edm::LogWarning("L1GctConfigFailure") << "Cannot find EventSetup information." << std::endl;
}

if (success == 0) {
// get data from EventSetup
Expand Down
2 changes: 0 additions & 2 deletions L1Trigger/GlobalCaloTrigger/test/L1GctTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ L1GctTest::endJob() {
void
L1GctTest::configureGct(const edm::EventSetup& c)
{
assert(&c!=0);

// get data from EventSetup
edm::ESHandle< L1GctJetFinderParams > jfPars ;
c.get< L1GctJetFinderParamsRcd >().get( jfPars ) ; // which record?
Expand Down
2 changes: 0 additions & 2 deletions L1Trigger/GlobalCaloTrigger/test/gctTestFunctions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ gctTestFunctions::~gctTestFunctions() {
/// Configuration method
void gctTestFunctions::configure(const edm::EventSetup& c)
{
assert(&c!=0);

// get data from EventSetup
edm::ESHandle< L1GctJetFinderParams > jfPars ;
c.get< L1GctJetFinderParamsRcd >().get( jfPars ) ; // which record?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,7 @@ namespace xsd
* @return A reference to the instance.
*/
type&
operator= (const type& x)
{
while (&x == 0) /* unused */;
return *this;
}
operator= (const type& x) = delete;

// Container API.
//
Expand Down

0 comments on commit ff3d04c

Please sign in to comment.