Skip to content

Commit

Permalink
Merge pull request #19646 from davidlange6/clangTidyTest12-misc-strin…
Browse files Browse the repository at this point in the history
…g-compare

clang check misc-string-compare
  • Loading branch information
cmsbuild authored Jul 13, 2017
2 parents e69f6b1 + a922a87 commit 8a01259
Show file tree
Hide file tree
Showing 47 changed files with 256 additions and 257 deletions.
2 changes: 1 addition & 1 deletion Alignment/CocoaUtilities/src/ALIFileIn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ ALIint ALIFileIn::getWordsInLine(std::vector<ALIstring>& wordlist)
// copy(ALIstring_iter(istr_line), ALIstring_iter(), back_inserter(wordlist));

if ( wordlist.size() != 0 ) {
if( (*(wordlist.end()-1)).compare("\\") == 0 ) { //use '\' to mark continuing line
if( (*(wordlist.end()-1)) == "\\" ) { //use '\' to mark continuing line
wordlist.pop_back();
} else {
break;
Expand Down
4 changes: 2 additions & 2 deletions CalibCalorimetry/EcalLaserSorting/src/LaserSorter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1167,11 +1167,11 @@ int LaserSorter::readFormatVersion(std::ifstream& in,

const string lmf = string("LMF");

if(in.good() && lmf.compare(magic)==0){
if(in.good() && lmf==magic){
vers = (data >>24) & 0xFF;
}

if(lmf.compare(magic)!=0){
if(lmf!=magic){
edm::LogWarning("LaserSorter") << "File " << fileName
<< "is not an LMF file.\n";
}
Expand Down
8 changes: 4 additions & 4 deletions CalibTracker/SiStripChannelGain/src/APVGainHelpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ int APVGain::subdetectorId(uint32_t det_id) {
*/
int APVGain::subdetectorId(const std::string& tag) {
std::string d = tag.substr(0,3);
if ( d.compare("TIB")==0 ) return 3;
if ( d.compare("TID")==0 ) return 4;
if ( d.compare("TOB")==0 ) return 5;
if ( d.compare("TEC")==0 ) return 6;
if ( d=="TIB" ) return 3;
if ( d=="TID" ) return 4;
if ( d=="TOB" ) return 5;
if ( d=="TEC" ) return 6;
return 0;
};

Expand Down
68 changes: 34 additions & 34 deletions CalibTracker/SiStripCommon/src/TkDetMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -775,73 +775,73 @@ std::string TkDetMap::getLayerName(int& in) const {
}

int TkDetMap::getLayerNum(const std::string& in) const {
if(in.compare( "TIB_L1")==0)
if(in=="TIB_L1")
return TkLayerMap::TIB_L1;
if(in.compare( "TIB_L2")==0)
if(in=="TIB_L2")
return TkLayerMap::TIB_L2;
if(in.compare( "TIB_L3")==0)
if(in=="TIB_L3")
return TkLayerMap::TIB_L3;
if(in.compare( "TIB_L4")==0)
if(in=="TIB_L4")
return TkLayerMap::TIB_L4;
if(in.compare( "TIDP_D1")==0)
if(in=="TIDP_D1")
return TkLayerMap::TIDP_D1;
if(in.compare( "TIDP_D2")==0)
if(in=="TIDP_D2")
return TkLayerMap::TIDP_D2;
if(in.compare( "TIDP_D3")==0)
if(in=="TIDP_D3")
return TkLayerMap::TIDP_D3;
if(in.compare( "TIDM_D1")==0)
if(in=="TIDM_D1")
return TkLayerMap::TIDM_D1;
if(in.compare( "TIDM_D2")==0)
if(in=="TIDM_D2")
return TkLayerMap::TIDM_D2;
if(in.compare( "TIDM_D3")==0)
if(in=="TIDM_D3")
return TkLayerMap::TIDM_D3;
if(in.compare( "TOB_L1")==0)
if(in=="TOB_L1")
return TkLayerMap::TOB_L1;
if(in.compare( "TOB_L2")==0)
if(in=="TOB_L2")
return TkLayerMap::TOB_L2;
if(in.compare( "TOB_L3")==0)
if(in=="TOB_L3")
return TkLayerMap::TOB_L3;
if(in.compare( "TOB_L4")==0)
if(in=="TOB_L4")
return TkLayerMap::TOB_L4;
if(in.compare( "TOB_L5")==0)
if(in=="TOB_L5")
return TkLayerMap::TOB_L5;
if(in.compare( "TOB_L6")==0)
if(in=="TOB_L6")
return TkLayerMap::TOB_L6;
if(in.compare( "TECP_W1")==0)
if(in=="TECP_W1")
return TkLayerMap::TECP_W1;
if(in.compare( "TECP_W2")==0)
if(in=="TECP_W2")
return TkLayerMap::TECP_W2;
if(in.compare( "TECP_W3")==0)
if(in=="TECP_W3")
return TkLayerMap::TECP_W3;
if(in.compare( "TECP_W4")==0)
if(in=="TECP_W4")
return TkLayerMap::TECP_W4;
if(in.compare( "TECP_W5")==0)
if(in=="TECP_W5")
return TkLayerMap::TECP_W5;
if(in.compare( "TECP_W6")==0)
if(in=="TECP_W6")
return TkLayerMap::TECP_W6;
if(in.compare( "TECP_W7")==0)
if(in=="TECP_W7")
return TkLayerMap::TECP_W7;
if(in.compare( "TECP_W8")==0)
if(in=="TECP_W8")
return TkLayerMap::TECP_W8;
if(in.compare( "TECP_W9")==0)
if(in=="TECP_W9")
return TkLayerMap::TECP_W9;
if(in.compare( "TECM_W1")==0)
if(in=="TECM_W1")
return TkLayerMap::TECM_W1;
if(in.compare( "TECM_W2")==0)
if(in=="TECM_W2")
return TkLayerMap::TECM_W2;
if(in.compare( "TECM_W3")==0)
if(in=="TECM_W3")
return TkLayerMap::TECM_W3;
if(in.compare( "TECM_W4")==0)
if(in=="TECM_W4")
return TkLayerMap::TECM_W4;
if(in.compare( "TECM_W5")==0)
if(in=="TECM_W5")
return TkLayerMap::TECM_W5;
if(in.compare( "TECM_W6")==0)
if(in=="TECM_W6")
return TkLayerMap::TECM_W6;
if(in.compare( "TECM_W7")==0)
if(in=="TECM_W7")
return TkLayerMap::TECM_W7;
if(in.compare( "TECM_W8")==0)
if(in=="TECM_W8")
return TkLayerMap::TECM_W8;
if(in.compare( "TECM_W9")==0)
if(in=="TECM_W9")
return TkLayerMap::TECM_W9;
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion CondCore/CondDB/src/DbConnectionString.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace cond {
//We test here that the signature string, if defined, is actually set to sig, otherwise we throw an exception
std::string signatureParameter( "sig" );
if( !signature.empty() ) {
if( signature.compare( signatureParameter ) == 0 ) {
if( signature == signatureParameter ) {
std::string::size_type s = finalConn.rfind('/');
finalConn.insert( s, "(security="+signature+')' );
} else {
Expand Down
2 changes: 1 addition & 1 deletion CondCore/CondDB/src/Time.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace cond {

TimeType timeTypeFromName( const std::string& name ){
for (auto const &i : s_timeTypeMap)
if (name.compare(i.first) == 0)
if (name == i.first)
return i.second;
const cond::TimeTypeSpecs & theSpec = cond::findSpecs( name );
return theSpec.type;
Expand Down
4 changes: 2 additions & 2 deletions CondCore/CondDB/src/Types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ namespace cond {

SynchronizationType synchronizationTypeFromName( const std::string& name ){
for (auto const &i : s_synchronizationTypeArray)
if (name.compare(i.first)==0) return i.second;
if (name==i.first) return i.second;
for (auto const &i : s_obsoleteSynchronizationTypeArray)
if (name.compare(i.first)==0) return i.second;
if (name==i.first) return i.second;
throwException( "SynchronizationType \""+name+"\" is unknown.","synchronizationTypeFromName");
}

Expand Down
2 changes: 1 addition & 1 deletion CondCore/Utilities/test/testBasicPayload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ int main (int argc, char** argv)
bool generate = false;
if (argc > 1) {
std::string option = std::string(argv[1]);
generate = (option.compare("generate")==0);
generate = (option=="generate");
}

int ret = 0;
Expand Down
8 changes: 4 additions & 4 deletions CondTools/Hcal/plugins/HcalGainsCheck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ void HcalGainsCheck::analyze(const edm::Event& ev, const edm::EventSetup& es)


// dump gains:
if(dumpupdate.compare("null")!=0){
if(dumpupdate!="null"){
std::ofstream outStream(dumpupdate.c_str());
std::cout << "--- Dumping Gains - update ---" << std::endl;
HcalDbASCIIIO::dumpObject (outStream, (*myNewGains) );
}
if(dumprefs.compare("null")!=0){
if(dumprefs!="null"){
std::ofstream outStream2(dumprefs.c_str());
std::cout << "--- Dumping Gains - reference ---" << std::endl;
HcalDbASCIIIO::dumpObject (outStream2, (*myRefGains) );
Expand Down Expand Up @@ -158,7 +158,7 @@ void HcalGainsCheck::analyze(const edm::Event& ev, const edm::EventSetup& es)
// push back into new vector the corresponding updated conditions,
// or if it doesn't exist, the reference

if(outfile.compare("null")!=0){
if(outfile!="null"){
HcalGains *resultGains = new HcalGains(refGains->topo());
for (std::vector<DetId>::const_iterator it = listRefChan.begin(); it != listRefChan.end(); it++)
{
Expand Down Expand Up @@ -214,7 +214,7 @@ void HcalGainsCheck::analyze(const edm::Event& ev, const edm::EventSetup& es)
void
HcalGainsCheck::endJob()
{
if(rootfile.compare("null")!=0){
if(rootfile!="null"){
f->Write();
}
f->Close();
Expand Down
6 changes: 3 additions & 3 deletions CondTools/Hcal/plugins/HcalPedestalWidthsCheck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ void HcalPedestalWidthsCheck::analyze(const edm::Event& ev, const edm::EventSetu


// dump pedestals:
if(dumpupdate.compare("null")!=0){
if(dumpupdate!="null"){
std::ofstream outStream(dumpupdate.c_str());
std::cout << "--- Dumping PedestalWidths - update ---" << std::endl;
HcalDbASCIIIO::dumpObject (outStream, (*myNewPeds) );
}
if(dumprefs.compare("null")!=0){
if(dumprefs!="null"){
std::ofstream outStream2(dumprefs.c_str());
std::cout << "--- Dumping PedestalWidths - reference ---" << std::endl;
HcalDbASCIIIO::dumpObject (outStream2, (*myRefPeds) );
Expand Down Expand Up @@ -105,7 +105,7 @@ void HcalPedestalWidthsCheck::analyze(const edm::Event& ev, const edm::EventSetu
}
std::cout << "These are identical" << std::endl;
}
if(outfile.compare("null")!=0){
if(outfile!="null"){
for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++)
{
DetId mydetid = *it;
Expand Down
6 changes: 3 additions & 3 deletions CondTools/Hcal/plugins/HcalPedestalsCheck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ void HcalPedestalsCheck::analyze(const edm::Event& ev, const edm::EventSetup& es
const HcalElectronicsMap* myRefEMap = refEMap.product();

// dump pedestals:
if(!(dumprefs.compare("null")==0)){
if(!(dumprefs=="null")){
std::ofstream outStream(dumprefs.c_str());
std::cout << "--- Dumping Pedestals - reference ---" << std::endl;
HcalDbASCIIIO::dumpObject (outStream, (*myRefPeds) );
}
if(!(dumpupdate.compare("null")==0)){
if(!(dumpupdate=="null")){
std::ofstream outStream2(dumpupdate.c_str());
std::cout << "--- Dumping Pedestals - updated ---" << std::endl;
HcalDbASCIIIO::dumpObject (outStream2, (*myNewPeds) );
Expand Down Expand Up @@ -104,7 +104,7 @@ void HcalPedestalsCheck::analyze(const edm::Event& ev, const edm::EventSetup& es
}
if(!failflag) std::cout << "These are identical to within deltaP" << std::endl;
}
if(!(outfile.compare("null")==0))
if(!(outfile=="null"))
{
// first get the list of all channels from the update
std::vector<DetId> listNewChan = myNewPeds->getAllChannels();
Expand Down
6 changes: 3 additions & 3 deletions CondTools/Hcal/plugins/HcalQIEDataCheck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ void HcalQIEDataCheck::analyze(const edm::Event& ev, const edm::EventSetup& es)
es.get<HcalElectronicsMapRcd>().get("reference",refEMap);
const HcalElectronicsMap* myRefEMap = refEMap.product();

if(dumpupdate.compare("null")!=0){
if(dumpupdate!="null"){
std::ofstream outStream(dumpupdate.c_str());
std::cout << "--- Dumping QIEs - update ---" << std::endl;
HcalDbASCIIIO::dumpObject (outStream, (*myNewQIEs) );
}
if(dumprefs.compare("null")!=0){
if(dumprefs!="null"){
std::ofstream outStream2(dumprefs.c_str());
std::cout << "--- Dumping QIEs - reference ---" << std::endl;
HcalDbASCIIIO::dumpObject (outStream2, (*myRefQIEs) );
Expand Down Expand Up @@ -108,7 +108,7 @@ void HcalQIEDataCheck::analyze(const edm::Event& ev, const edm::EventSetup& es)
//implement compare qies -- different epsilon for slope and offset?
// }

if(outfile.compare("null")!=0){
if(outfile!="null"){
for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++)
{
DetId mydetid = *it;
Expand Down
6 changes: 3 additions & 3 deletions DQM/BeamMonitor/plugins/Vx3DHLTAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ void Vx3DHLTAnalyzer::reset (string ResetType)
}


if (ResetType.compare("scratch") == 0)
if (ResetType == "scratch")
{
runNumber = 0;
numberGoodFits = 0;
Expand Down Expand Up @@ -696,7 +696,7 @@ void Vx3DHLTAnalyzer::reset (string ResetType)
if (internalDebug == true) cout << "[Vx3DHLTAnalyzer]::\tReset issued: scratch" << endl;
if ((debugMode == true) && (outputDebugFile.is_open() == true)) outputDebugFile << "Reset -scratch- issued\n" << endl;
}
else if (ResetType.compare("whole") == 0)
else if (ResetType == "whole")
{
Vx_X->Reset();
Vx_Y->Reset();
Expand All @@ -718,7 +718,7 @@ void Vx3DHLTAnalyzer::reset (string ResetType)
if (internalDebug == true) cout << "[Vx3DHLTAnalyzer]::\tReset issued: whole" << endl;
if ((debugMode == true) && (outputDebugFile.is_open() == true)) outputDebugFile << "Reset -whole- issued\n" << endl;
}
else if (ResetType.compare("hitCounter") == 0)
else if (ResetType == "hitCounter")
{
totalHits = 0;

Expand Down
4 changes: 2 additions & 2 deletions DQM/CSCMonitorModule/plugins/CSCDQM_Collection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace cscdqm {
///
/// Load histogram definition
///
if (nodeName.compare(XML_BOOK_DEFINITION) == 0) {
if (nodeName == XML_BOOK_DEFINITION) {

CoHistoProps dp;
getNodeProperties(node, dp);
Expand All @@ -88,7 +88,7 @@ namespace cscdqm {
///
/// Load histogram
///
if (nodeName.compare(XML_BOOK_HISTOGRAM) == 0) {
if (nodeName == XML_BOOK_HISTOGRAM) {

CoHistoProps hp;

Expand Down
2 changes: 1 addition & 1 deletion DQM/CSCMonitorModule/plugins/CSCDQM_Detector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ namespace cscdqm {
bool mask = false;
unsigned int num = 0;

if (token.compare("*") != 0) {
if (token != "*") {
if(stringToNumber<unsigned int>(num, token, std::dec)) {
mask = true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion DQM/CSCMonitorModule/plugins/CSCDQM_HistoDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ namespace cscdqm {
*/
static const bool getHistoIdByName(const std::string& p_name, HistoId& p_id) {
for (HistoId i = 0; i < h::namesSize; i++) {
if (p_name.compare(h::names[i]) == 0) {
if (p_name == h::names[i]) {
p_id = i;
return true;
}
Expand Down
36 changes: 18 additions & 18 deletions DQM/CSCMonitorModule/plugins/CSCDQM_Utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ namespace cscdqm {
* @return chamber y-axis position
*/
int Utility::getCSCTypeBin(const std::string& cstr) {
if (cstr.compare("ME-4/2") == 0) return 0;
if (cstr.compare("ME-4/1") == 0) return 1;
if (cstr.compare("ME-3/2") == 0) return 2;
if (cstr.compare("ME-3/1") == 0) return 3;
if (cstr.compare("ME-2/2") == 0) return 4;
if (cstr.compare("ME-2/1") == 0) return 5;
if (cstr.compare("ME-1/3") == 0) return 6;
if (cstr.compare("ME-1/2") == 0) return 7;
if (cstr.compare("ME-1/1") == 0) return 8;
if (cstr.compare("ME+1/1") == 0) return 9;
if (cstr.compare("ME+1/2") == 0) return 10;
if (cstr.compare("ME+1/3") == 0) return 11;
if (cstr.compare("ME+2/1") == 0) return 12;
if (cstr.compare("ME+2/2") == 0) return 13;
if (cstr.compare("ME+3/1") == 0) return 14;
if (cstr.compare("ME+3/2") == 0) return 15;
if (cstr.compare("ME+4/1") == 0) return 16;
if (cstr.compare("ME+4/2") == 0) return 17;
if (cstr == "ME-4/2") return 0;
if (cstr == "ME-4/1") return 1;
if (cstr == "ME-3/2") return 2;
if (cstr == "ME-3/1") return 3;
if (cstr == "ME-2/2") return 4;
if (cstr == "ME-2/1") return 5;
if (cstr == "ME-1/3") return 6;
if (cstr == "ME-1/2") return 7;
if (cstr == "ME-1/1") return 8;
if (cstr == "ME+1/1") return 9;
if (cstr == "ME+1/2") return 10;
if (cstr == "ME+1/3") return 11;
if (cstr == "ME+2/1") return 12;
if (cstr == "ME+2/2") return 13;
if (cstr == "ME+3/1") return 14;
if (cstr == "ME+3/2") return 15;
if (cstr == "ME+4/1") return 16;
if (cstr == "ME+4/2") return 17;
return 0;
}

Expand Down
Loading

0 comments on commit 8a01259

Please sign in to comment.