From 7e514f29d8295d1e35ab204130ead53ddf17208e Mon Sep 17 00:00:00 2001 From: Felix Cai Date: Wed, 2 Jan 2019 01:34:34 +0800 Subject: [PATCH] fix warning while compiling rocketmq_static MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. the return value of "UtilAll::ReplaceFile" is bool, not integer. 2. gcc suggest parentheses around '&&' within '||'。 --- src/MQClientAPIImpl.cpp | 4 ++-- src/consumer/OffsetStore.cpp | 2 +- src/producer/DefaultMQProducer.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MQClientAPIImpl.cpp b/src/MQClientAPIImpl.cpp index 621708622..244d674d3 100644 --- a/src/MQClientAPIImpl.cpp +++ b/src/MQClientAPIImpl.cpp @@ -152,7 +152,7 @@ string MQClientAPIImpl::fetchNameServerAddr(const string& NSDomain) { // update the snapshot local file if nameSrv changes or // m_firstFetchNameSrv==true if (writeDataToFile(fileBak, addrs, true)) { - if (UtilAll::ReplaceFile(fileBak, file) == -1) + if (!UtilAll::ReplaceFile(fileBak, file)) LOG_ERROR("could not rename bak file:%s", strerror(errno)); } } @@ -160,7 +160,7 @@ string MQClientAPIImpl::fetchNameServerAddr(const string& NSDomain) { if (!boost::filesystem::exists(snapshot_file)) { // the name server snapshot local file maybe deleted by force, create it if (writeDataToFile(fileBak, m_nameSrvAddr, true)) { - if (UtilAll::ReplaceFile(fileBak, file) == -1) + if (!UtilAll::ReplaceFile(fileBak, file)) LOG_ERROR("could not rename bak file:%s", strerror(errno)); } } diff --git a/src/consumer/OffsetStore.cpp b/src/consumer/OffsetStore.cpp index a7463a6c0..25d1b3204 100644 --- a/src/consumer/OffsetStore.cpp +++ b/src/consumer/OffsetStore.cpp @@ -214,7 +214,7 @@ void LocalFileOffsetStore::persistAll(const std::vector& mqs) { "persistAll:open offset store file failed", -1); } s.close(); - if (UtilAll::ReplaceFile(storefile_bak, m_storeFile) == -1) + if (!UtilAll::ReplaceFile(storefile_bak, m_storeFile)) LOG_ERROR("could not rename bak file:%s", strerror(errno)); m_offsetTable_tmp.clear(); } else { diff --git a/src/producer/DefaultMQProducer.cpp b/src/producer/DefaultMQProducer.cpp index 4c39bd24d..1411ebdf4 100755 --- a/src/producer/DefaultMQProducer.cpp +++ b/src/producer/DefaultMQProducer.cpp @@ -244,7 +244,7 @@ void DefaultMQProducer::setMaxMessageSize(int maxMessageSize) { int DefaultMQProducer::getCompressLevel() const { return m_compressLevel; } void DefaultMQProducer::setCompressLevel(int compressLevel) { - assert(compressLevel >= 0 && compressLevel <= 9 || compressLevel == -1); + assert((compressLevel >= 0 && compressLevel <= 9) || compressLevel == -1); m_compressLevel = compressLevel; }