cppcheck fixes 59/47759/3
authorPawel Kubik <p.kubik@samsung.com>
Mon, 7 Sep 2015 09:17:45 +0000 (11:17 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Thu, 10 Sep 2015 13:01:05 +0000 (06:01 -0700)
[Feature]       Small code fixes based on cppcheck
[Cause]         Minimizing possible runtime errors
[Solution]      Fix the code using cppcheck suggestions, suppress
                false-positives
[Verification]  Compile, run cppcheck

Change-Id: I94fab8e50879f78f3ccb503fd18606e9cbfabfb5

29 files changed:
cli/cli-exception.hpp
client/exception.hpp
client/vasum-client-impl.cpp
common/api/ipc-method-result-builder.hpp
common/base-exception.hpp
common/lxc/exception.hpp
common/utils/exception.hpp
libs/dbus/exception.hpp
libs/ipc/exception.hpp
libs/ipc/internals/finish-request.hpp
libs/ipc/internals/method-request.hpp
libs/ipc/internals/processor.cpp
libs/ipc/internals/processor.hpp
libs/ipc/internals/remove-peer-request.hpp
libs/ipc/internals/result-builder.hpp
libs/ipc/internals/send-result-request.hpp
libs/ipc/internals/signal-request.hpp
libs/ipc/method-result.cpp
libs/ipc/method-result.hpp
libs/ipc/service.hpp
libs/lxcpp/exception.hpp
server/exception.hpp
server/zones-manager.cpp
tests/cppcheck/cppcheck.sh
tests/cppcheck/cppcheck.suppress
tests/unit_tests/ipc/ut-ipc.cpp
tests/unit_tests/server/ut-zones-manager.cpp
tests/unit_tests/utils/ut-worker.cpp
zone-daemon/exception.hpp

index 982f52d..f0d5e0f 100644 (file)
@@ -38,12 +38,12 @@ namespace cli {
  */
 struct CliException: public VasumException {
 
-    CliException(const std::string& error) : VasumException(error) {}
+    explicit CliException(const std::string& error) : VasumException(error) {}
 };
 
 struct IOException: public CliException {
 
-    IOException(const std::string& error) : CliException(error) {}
+    explicit IOException(const std::string& error) : CliException(error) {}
 };
 
 } // namespace cli
index d4be66b..98ebf81 100644 (file)
@@ -37,27 +37,27 @@ namespace vasum {
  */
 struct ClientException: public VasumException {
 
-    ClientException(const std::string& error) : VasumException(error) {}
+    explicit ClientException(const std::string& error) : VasumException(error) {}
 };
 
 struct IOException: public ClientException {
 
-    IOException(const std::string& error) : ClientException(error) {}
+    explicit IOException(const std::string& error) : ClientException(error) {}
 };
 
 struct OperationFailedException: public ClientException {
 
-    OperationFailedException(const std::string& error) : ClientException(error) {}
+    explicit OperationFailedException(const std::string& error) : ClientException(error) {}
 };
 
 struct InvalidArgumentException: public ClientException {
 
-    InvalidArgumentException(const std::string& error) : ClientException(error) {}
+    explicit InvalidArgumentException(const std::string& error) : ClientException(error) {}
 };
 
 struct InvalidResponseException: public ClientException {
 
-    InvalidResponseException(const std::string& error) : ClientException(error) {}
+    explicit InvalidResponseException(const std::string& error) : ClientException(error) {}
 };
 
 }
index e3aca1d..41cc919 100644 (file)
@@ -899,4 +899,3 @@ VsmStatus Client::vsm_clean_up_zones_root() noexcept
             std::make_shared<api::Void>());
     });
 }
-
index e9554d0..cad5d8a 100644 (file)
@@ -40,7 +40,7 @@ const std::string IPC_CONNECTION_PREFIX = "ipc://";
 
 class IPCMethodResultBuilder: public MethodResultBuilder {
 public:
-    IPCMethodResultBuilder(const ipc::MethodResult::Pointer& methodResult);
+    explicit IPCMethodResultBuilder(const ipc::MethodResult::Pointer& methodResult);
     ~IPCMethodResultBuilder() {}
 
 private:
index 645fa41..05e1fd6 100644 (file)
@@ -38,7 +38,7 @@ namespace vasum {
  */
 struct VasumException: public std::runtime_error {
 
-    VasumException(const std::string& error) : std::runtime_error(error) {}
+    explicit VasumException(const std::string& error) : std::runtime_error(error) {}
 };
 
 } // namespace vasum
index 379fe43..40c7d5f 100644 (file)
@@ -37,12 +37,12 @@ namespace vasum {
  */
 struct LxcException: public VasumException {
 
-    LxcException(const std::string& error) : VasumException(error) {}
+    explicit LxcException(const std::string& error) : VasumException(error) {}
 };
 
 struct KeyNotFoundException: public LxcException {
 
-    KeyNotFoundException(const std::string& error) : LxcException(error) {}
+    explicit KeyNotFoundException(const std::string& error) : LxcException(error) {}
 };
 
 } // namespace vasum
index fda0554..232b090 100644 (file)
@@ -36,12 +36,12 @@ namespace utils {
  */
 struct UtilsException: public std::runtime_error {
 
-    UtilsException(const std::string& error) : std::runtime_error(error) {}
+    explicit UtilsException(const std::string& error) : std::runtime_error(error) {}
 };
 
 struct ProvisionExistsException: public UtilsException {
 
-    ProvisionExistsException(const std::string& error) : UtilsException(error) {}
+    explicit ProvisionExistsException(const std::string& error) : UtilsException(error) {}
 };
 
 /**
index a09bdbc..b38877c 100644 (file)
@@ -34,7 +34,7 @@ namespace dbus {
  */
 struct DbusException: public std::runtime_error {
 
-    DbusException(const std::string& error = "") : std::runtime_error(error) {}
+    explicit DbusException(const std::string& error = "") : std::runtime_error(error) {}
 };
 
 /**
@@ -42,7 +42,7 @@ struct DbusException: public std::runtime_error {
  */
 struct DbusIOException: public DbusException {
 
-    DbusIOException(const std::string& error = "") : DbusException(error) {}
+    explicit DbusIOException(const std::string& error = "") : DbusException(error) {}
 };
 
 /**
@@ -50,7 +50,7 @@ struct DbusIOException: public DbusException {
  */
 struct DbusOperationException: public DbusException {
 
-    DbusOperationException(const std::string& error = "") : DbusException(error) {}
+    explicit DbusOperationException(const std::string& error = "") : DbusException(error) {}
 };
 
 /**
@@ -58,7 +58,7 @@ struct DbusOperationException: public DbusException {
  */
 struct DbusCustomException: public DbusException {
 
-    DbusCustomException(const std::string& error = "") : DbusException(error) {}
+    explicit DbusCustomException(const std::string& error = "") : DbusException(error) {}
 };
 
 /**
@@ -66,7 +66,7 @@ struct DbusCustomException: public DbusException {
  */
 struct DbusInvalidArgumentException: public DbusException {
 
-    DbusInvalidArgumentException(const std::string& error = "") : DbusException(error) {}
+    explicit DbusInvalidArgumentException(const std::string& error = "") : DbusException(error) {}
 };
 
 } // namespace dbus
index 140619c..3fe7a5b 100644 (file)
@@ -36,7 +36,7 @@ namespace ipc {
  * @defgroup IPCException   IPCException
  */
 struct IPCException: public std::runtime_error {
-    IPCException(const std::string& message)
+    explicit IPCException(const std::string& message)
         : std::runtime_error(message) {}
 };
 
@@ -45,7 +45,7 @@ struct IPCException: public std::runtime_error {
  * @ingroup IPCException
  */
 struct IPCParsingException: public IPCException {
-    IPCParsingException(const std::string& message = "Exception during reading/parsing data from the socket")
+    explicit IPCParsingException(const std::string& message = "Exception during reading/parsing data from the socket")
         : IPCException(message) {}
 };
 
@@ -54,7 +54,7 @@ struct IPCParsingException: public IPCException {
  * @ingroup IPCException
  */
 struct IPCSerializationException: public IPCException {
-    IPCSerializationException(const std::string& message = "Exception during writing/serializing data to the socket")
+    explicit IPCSerializationException(const std::string& message = "Exception during writing/serializing data to the socket")
         : IPCException(message) {}
 };
 
@@ -63,7 +63,7 @@ struct IPCSerializationException: public IPCException {
  * @ingroup IPCException
  */
 struct IPCPeerDisconnectedException: public IPCException {
-    IPCPeerDisconnectedException(const std::string& message = "No such peer. Might got disconnected.")
+    explicit IPCPeerDisconnectedException(const std::string& message = "No such peer. Might got disconnected.")
         : IPCException(message) {}
 };
 
@@ -72,7 +72,7 @@ struct IPCPeerDisconnectedException: public IPCException {
  * @ingroup IPCException
  */
 struct IPCNaughtyPeerException: public IPCException {
-    IPCNaughtyPeerException(const std::string& message = "Peer performed a forbidden action.")
+    explicit IPCNaughtyPeerException(const std::string& message = "Peer performed a forbidden action.")
         : IPCException(message) {}
 };
 
@@ -81,7 +81,7 @@ struct IPCNaughtyPeerException: public IPCException {
  * @ingroup IPCException
  */
 struct IPCRemovedPeerException: public IPCException {
-    IPCRemovedPeerException(const std::string& message = "Removing peer")
+    explicit IPCRemovedPeerException(const std::string& message = "Removing peer")
         : IPCException(message) {}
 };
 
@@ -90,7 +90,7 @@ struct IPCRemovedPeerException: public IPCException {
  * @ingroup IPCException
  */
 struct IPCClosingException: public IPCException {
-    IPCClosingException(const std::string& message = "Closing IPC")
+    explicit IPCClosingException(const std::string& message = "Closing IPC")
         : IPCException(message) {}
 };
 
@@ -99,7 +99,7 @@ struct IPCClosingException: public IPCException {
  * @ingroup IPCException
  */
 struct IPCTimeoutException: public IPCException {
-    IPCTimeoutException(const std::string& message)
+    explicit IPCTimeoutException(const std::string& message)
         : IPCException(message) {}
 };
 
index 5a948bd..934c135 100644 (file)
@@ -43,4 +43,4 @@ public:
 
 } // namespace ipc
 
-#endif // COMMON_IPC_INTERNALS_FINISH_REQUEST_HPP
\ No newline at end of file
+#endif // COMMON_IPC_INTERNALS_FINISH_REQUEST_HPP
index 663cbde..53d9d44 100644 (file)
@@ -41,7 +41,7 @@ public:
 
     template<typename SentDataType, typename ReceivedDataType>
     static std::shared_ptr<MethodRequest> create(const MethodID methodID,
-                                                 const PeerID peerID,
+                                                 const PeerID& peerID,
                                                  const std::shared_ptr<SentDataType>& data,
                                                  const typename ResultHandler<ReceivedDataType>::type& process);
 
@@ -54,7 +54,7 @@ public:
     ResultBuilderHandler process;
 
 private:
-    MethodRequest(const MethodID methodID, const PeerID peerID)
+    MethodRequest(const MethodID methodID, const PeerID& peerID)
         : methodID(methodID),
           peerID(peerID),
           messageID(getNextMessageID())
@@ -64,7 +64,7 @@ private:
 
 template<typename SentDataType, typename ReceivedDataType>
 std::shared_ptr<MethodRequest> MethodRequest::create(const MethodID methodID,
-                                                     const PeerID peerID,
+                                                     const PeerID& peerID,
                                                      const std::shared_ptr<SentDataType>& data,
                                                      const typename ResultHandler<ReceivedDataType>::type& process)
 {
index fdbcbe8..164d735 100644 (file)
@@ -92,7 +92,7 @@ Processor::Peers::iterator Processor::getPeerInfoIterator(const FileDescriptor f
     });
 }
 
-Processor::Peers::iterator Processor::getPeerInfoIterator(const PeerID peerID)
+Processor::Peers::iterator Processor::getPeerInfoIterator(const PeerID peerID)
 {
     return std::find_if(mPeerInfo.begin(), mPeerInfo.end(), [peerID](const PeerInfo & peerInfo) {
         return peerID == peerInfo.peerID;
@@ -162,16 +162,16 @@ FileDescriptor Processor::getEventFD()
 }
 
 void Processor::sendResult(const MethodID methodID,
-                           const PeerID peerID,
-                           const MessageID messageID,
+                           const PeerID& peerID,
+                           const MessageID& messageID,
                            const std::shared_ptr<void>& data)
 {
     auto requestPtr = std::make_shared<SendResultRequest>(methodID, peerID, messageID, data);
     mRequestQueue.pushFront(Event::SEND_RESULT, requestPtr);
 }
 
-void Processor::sendError(const PeerID peerID,
-                          const MessageID messageID,
+void Processor::sendError(const PeerID& peerID,
+                          const MessageID& messageID,
                           const int errorCode,
                           const std::string& message)
 {
@@ -180,8 +180,8 @@ void Processor::sendError(const PeerID peerID,
 }
 
 void Processor::sendVoid(const MethodID methodID,
-                         const PeerID peerID,
-                         const MessageID messageID)
+                         const PeerID& peerID,
+                         const MessageID& messageID)
 {
     auto data = std::make_shared<EmptyData>();
     auto requestPtr = std::make_shared<SendResultRequest>(methodID, peerID, messageID, data);
@@ -208,7 +208,7 @@ PeerID Processor::addPeer(const std::shared_ptr<Socket>& socketPtr)
     return requestPtr->peerID;
 }
 
-void Processor::removePeerSyncInternal(const PeerID peerID, Lock& lock)
+void Processor::removePeerSyncInternal(const PeerID& peerID, Lock& lock)
 {
     LOGS(mLogPrefix + "Processor removePeer peerID: " << peerID);
 
@@ -329,7 +329,7 @@ bool Processor::handleInput(const FileDescriptor fd)
     }
 }
 
-void Processor::onNewSignals(const PeerID peerID, std::shared_ptr<RegisterSignalsProtocolMessage>& data)
+void Processor::onNewSignals(const PeerID& peerID, std::shared_ptr<RegisterSignalsProtocolMessage>& data)
 {
     LOGS(mLogPrefix + "Processor onNewSignals peerID: " << peerID);
 
@@ -338,7 +338,7 @@ void Processor::onNewSignals(const PeerID peerID, std::shared_ptr<RegisterSignal
     }
 }
 
-void Processor::onErrorSignal(const PeerID, std::shared_ptr<ErrorProtocolMessage>& data)
+void Processor::onErrorSignal(const PeerID&, std::shared_ptr<ErrorProtocolMessage>& data)
 {
     LOGS(mLogPrefix + "Processor onErrorSignal messageID: " << data->messageID);
 
@@ -351,7 +351,7 @@ void Processor::onErrorSignal(const PeerID, std::shared_ptr<ErrorProtocolMessage
 }
 
 bool Processor::onReturnValue(Peers::iterator& peerIt,
-                              const MessageID messageID)
+                              const MessageID& messageID)
 {
     LOGS(mLogPrefix + "Processor onReturnValue messageID: " << messageID);
 
@@ -388,7 +388,7 @@ bool Processor::onReturnValue(Peers::iterator& peerIt,
 
 bool Processor::onRemoteSignal(Peers::iterator& peerIt,
                                __attribute__((unused)) const MethodID methodID,
-                               __attribute__((unused)) const MessageID messageID,
+                               __attribute__((unused)) const MessageID& messageID,
                                std::shared_ptr<SignalHandlers> signalCallbacks)
 {
     LOGS(mLogPrefix + "Processor onRemoteSignal; methodID: " << methodID << " messageID: " << messageID);
@@ -422,7 +422,7 @@ bool Processor::onRemoteSignal(Peers::iterator& peerIt,
 
 bool Processor::onRemoteMethod(Peers::iterator& peerIt,
                                const MethodID methodID,
-                               const MessageID messageID,
+                               const MessageID& messageID,
                                std::shared_ptr<MethodHandlers> methodCallbacks)
 {
     LOGS(mLogPrefix + "Processor onRemoteMethod; methodID: " << methodID << " messageID: " << messageID);
index e383a57..91edfc1 100644 (file)
@@ -217,8 +217,8 @@ public:
      * @param data data to send
      */
     void sendResult(const MethodID methodID,
-                    const PeerID peerID,
-                    const MessageID messageID,
+                    const PeerID& peerID,
+                    const MessageID& messageID,
                     const std::shared_ptr<void>& data);
 
     /**
@@ -229,8 +229,8 @@ public:
      * @param errorCode code of the error
      * @param message description of the error
      */
-    void sendError(const PeerID peerID,
-                   const MessageID messageID,
+    void sendError(const PeerID& peerID,
+                   const MessageID& messageID,
                    const int errorCode,
                    const std::string& message);
 
@@ -242,8 +242,8 @@ public:
      * @param messageID id of the message to which it replies
      */
     void sendVoid(const MethodID methodID,
-                  const PeerID peerID,
-                  const MessageID messageID);
+                  const PeerID& peerID,
+                  const MessageID& messageID);
 
     /**
      * Removes the callback associated with specific method id.
@@ -267,7 +267,7 @@ public:
      */
     template<typename SentDataType, typename ReceivedDataType>
     std::shared_ptr<ReceivedDataType> callSync(const MethodID methodID,
-                                               const PeerID peerID,
+                                               const PeerID& peerID,
                                                const std::shared_ptr<SentDataType>& data,
                                                unsigned int timeoutMS = 5000);
 
@@ -283,7 +283,7 @@ public:
      */
     template<typename SentDataType, typename ReceivedDataType>
     MessageID callAsync(const MethodID methodID,
-                        const PeerID peerID,
+                        const PeerID& peerID,
                         const std::shared_ptr<SentDataType>& data,
                         const typename ResultHandler<ReceivedDataType>::type& process);
 
@@ -352,7 +352,7 @@ private:
 
     struct RegisterSignalsProtocolMessage {
         RegisterSignalsProtocolMessage() = default;
-        RegisterSignalsProtocolMessage(const std::vector<MethodID>& ids)
+        explicit RegisterSignalsProtocolMessage(const std::vector<MethodID>& ids)
             : ids(ids) {}
 
         std::vector<MethodID> ids;
@@ -365,7 +365,7 @@ private:
 
     struct ErrorProtocolMessage {
         ErrorProtocolMessage() = default;
-        ErrorProtocolMessage(const MessageID messageID, const int code, const std::string& message)
+        ErrorProtocolMessage(const MessageID& messageID, const int code, const std::string& message)
             : messageID(messageID), code(code), message(message) {}
 
         MessageID messageID;
@@ -461,7 +461,7 @@ private:
 
     template<typename SentDataType, typename ReceivedDataType>
     MessageID callAsyncInternal(const MethodID methodID,
-                                const PeerID peerID,
+                                const PeerID& peerID,
                                 const std::shared_ptr<SentDataType>& data,
                                 const typename ResultHandler<ReceivedDataType>::type& process);
 
@@ -475,7 +475,7 @@ private:
 
     template<typename SentDataType>
     void signalInternal(const MethodID methodID,
-                        const PeerID peerID,
+                        const PeerID& peerID,
                         const std::shared_ptr<SentDataType>& data);
 
     // Request handlers
@@ -487,28 +487,28 @@ private:
     bool onFinishRequest(FinishRequest& request);
 
     bool onReturnValue(Peers::iterator& peerIt,
-                       const MessageID messageID);
+                       const MessageID& messageID);
     bool onRemoteMethod(Peers::iterator& peerIt,
                         const MethodID methodID,
-                        const MessageID messageID,
+                        const MessageID& messageID,
                         std::shared_ptr<MethodHandlers> methodCallbacks);
     bool onRemoteSignal(Peers::iterator& peerIt,
                         const MethodID methodID,
-                        const MessageID messageID,
+                        const MessageID& messageID,
                         std::shared_ptr<SignalHandlers> signalCallbacks);
 
     void removePeerInternal(Peers::iterator peerIt,
                             const std::exception_ptr& exceptionPtr);
-    void removePeerSyncInternal(const PeerID peerID, Lock& lock);
+    void removePeerSyncInternal(const PeerID& peerID, Lock& lock);
 
-    void onNewSignals(const PeerID peerID,
+    void onNewSignals(const PeerID& peerID,
                       std::shared_ptr<RegisterSignalsProtocolMessage>& data);
 
-    void onErrorSignal(const PeerID peerID,
+    void onErrorSignal(const PeerID& peerID,
                        std::shared_ptr<ErrorProtocolMessage>& data);
 
     Peers::iterator getPeerInfoIterator(const FileDescriptor fd);
-    Peers::iterator getPeerInfoIterator(const PeerID peerID);
+    Peers::iterator getPeerInfoIterator(const PeerID& peerID);
 
 };
 
@@ -616,7 +616,7 @@ void Processor::setSignalHandler(const MethodID methodID,
 
 template<typename SentDataType, typename ReceivedDataType>
 MessageID Processor::callAsync(const MethodID methodID,
-                               const PeerID peerID,
+                               const PeerID& peerID,
                                const std::shared_ptr<SentDataType>& data,
                                const typename ResultHandler<ReceivedDataType>::type& process)
 {
@@ -626,7 +626,7 @@ MessageID Processor::callAsync(const MethodID methodID,
 
 template<typename SentDataType, typename ReceivedDataType>
 MessageID Processor::callAsyncInternal(const MethodID methodID,
-                                       const PeerID peerID,
+                                       const PeerID& peerID,
                                        const std::shared_ptr<SentDataType>& data,
                                        const typename ResultHandler<ReceivedDataType>::type& process)
 {
@@ -638,7 +638,7 @@ MessageID Processor::callAsyncInternal(const MethodID methodID,
 
 template<typename SentDataType, typename ReceivedDataType>
 std::shared_ptr<ReceivedDataType> Processor::callSync(const MethodID methodID,
-                                                      const PeerID peerID,
+                                                      const PeerID& peerID,
                                                       const std::shared_ptr<SentDataType>& data,
                                                       unsigned int timeoutMS)
 {
@@ -692,7 +692,7 @@ std::shared_ptr<ReceivedDataType> Processor::callSync(const MethodID methodID,
 
 template<typename SentDataType>
 void Processor::signalInternal(const MethodID methodID,
-                               const PeerID peerID,
+                               const PeerID& peerID,
                                const std::shared_ptr<SentDataType>& data)
 {
     auto requestPtr = SignalRequest::create<SentDataType>(methodID, peerID, data);
index c9f7ec7..e124227 100644 (file)
@@ -37,7 +37,7 @@ public:
     RemovePeerRequest(const RemovePeerRequest&) = delete;
     RemovePeerRequest& operator=(const RemovePeerRequest&) = delete;
 
-    RemovePeerRequest(const PeerID peerID,
+    RemovePeerRequest(const PeerID& peerID,
                       const std::shared_ptr<std::condition_variable>& conditionPtr)
         : peerID(peerID),
           conditionPtr(conditionPtr)
index 97134e3..b9c9471 100644 (file)
@@ -39,12 +39,12 @@ public:
           mExceptionPtr(nullptr)
     {}
 
-    ResultBuilder(const std::exception_ptr& exceptionPtr)
+    explicit ResultBuilder(const std::exception_ptr& exceptionPtr)
         : mData(nullptr),
           mExceptionPtr(exceptionPtr)
     {}
 
-    ResultBuilder(const std::shared_ptr<void>& data)
+    explicit ResultBuilder(const std::shared_ptr<void>& data)
         : mData(data),
           mExceptionPtr(nullptr)
 
@@ -68,9 +68,3 @@ typedef std::function<void(ResultBuilder&)> ResultBuilderHandler;
 } // namespace ipc
 
 #endif // COMMON_IPC_RESULT_BUILDER_HPP
-
-
-
-
-
-
index a6ed2b4..de512c0 100644 (file)
@@ -36,8 +36,8 @@ public:
     SendResultRequest& operator=(const SendResultRequest&) = delete;
 
     SendResultRequest(const MethodID methodID,
-                      const PeerID peerID,
-                      const MessageID messageID,
+                      const PeerID& peerID,
+                      const MessageID& messageID,
                       const std::shared_ptr<void>& data)
         : methodID(methodID),
           peerID(peerID),
index 904d3f3..aa597c0 100644 (file)
@@ -38,7 +38,7 @@ public:
 
     template<typename SentDataType>
     static std::shared_ptr<SignalRequest> create(const MethodID methodID,
-                                                 const PeerID peerID,
+                                                 const PeerID& peerID,
                                                  const std::shared_ptr<SentDataType>& data);
 
     MethodID methodID;
@@ -48,7 +48,7 @@ public:
     SerializeCallback serialize;
 
 private:
-    SignalRequest(const MethodID methodID, const PeerID peerID)
+    SignalRequest(const MethodID methodID, const PeerID& peerID)
         : methodID(methodID),
           peerID(peerID),
           messageID(getNextMessageID())
@@ -58,7 +58,7 @@ private:
 
 template<typename SentDataType>
 std::shared_ptr<SignalRequest> SignalRequest::create(const MethodID methodID,
-                                                     const PeerID peerID,
+                                                     const PeerID& peerID,
                                                      const std::shared_ptr<SentDataType>& data)
 {
     std::shared_ptr<SignalRequest> request(new SignalRequest(methodID, peerID));
index 97eb450..f110689 100644 (file)
@@ -31,8 +31,8 @@ namespace ipc {
 
 MethodResult::MethodResult(Processor& processor,
                            const MethodID methodID,
-                           const MessageID messageID,
-                           const PeerID peerID)
+                           const MessageID& messageID,
+                           const PeerID& peerID)
     : mProcessor(processor),
       mMethodID(methodID),
       mPeerID(peerID),
@@ -54,7 +54,7 @@ void MethodResult::setError(const int code, const std::string& message)
     mProcessor.sendError(mPeerID, mMessageID, code, message);
 }
 
-PeerID MethodResult::getPeerID()
+PeerID MethodResult::getPeerID() const
 {
     return mPeerID;
 }
index c1729f7..c6fce37 100644 (file)
@@ -43,8 +43,8 @@ public:
 
     MethodResult(Processor& processor,
                  const MethodID methodID,
-                 const MessageID messageID,
-                 const PeerID peerID);
+                 const MessageID& messageID,
+                 const PeerID& peerID);
 
 
     template<typename Data>
@@ -55,7 +55,7 @@ public:
 
     void setVoid();
     void setError(const int code, const std::string& message);
-    PeerID getPeerID();
+    PeerID getPeerID() const;
 
 private:
     Processor& mProcessor;
index a5f7c86..6d953dd 100644 (file)
@@ -191,7 +191,7 @@ public:
      */
     template<typename SentDataType, typename ReceivedDataType>
     std::shared_ptr<ReceivedDataType> callSync(const MethodID methodID,
-                                               const PeerID peerID,
+                                               const PeerID& peerID,
                                                const std::shared_ptr<SentDataType>& data,
                                                unsigned int timeoutMS = 5000);
 
@@ -208,7 +208,7 @@ public:
      */
     template<typename SentDataType, typename ReceivedDataType>
     void callAsync(const MethodID methodID,
-                   const PeerID peerID,
+                   const PeerID& peerID,
                    const std::shared_ptr<SentDataType>& data,
                    const typename ResultHandler<ReceivedDataType>::type& resultCallback);
 
@@ -251,7 +251,7 @@ void Service::setSignalHandler(const MethodID methodID,
 
 template<typename SentDataType, typename ReceivedDataType>
 std::shared_ptr<ReceivedDataType> Service::callSync(const MethodID methodID,
-                                                    const PeerID peerID,
+                                                    const PeerID& peerID,
                                                     const std::shared_ptr<SentDataType>& data,
                                                     unsigned int timeoutMS)
 {
@@ -263,7 +263,7 @@ std::shared_ptr<ReceivedDataType> Service::callSync(const MethodID methodID,
 
 template<typename SentDataType, typename ReceivedDataType>
 void Service::callAsync(const MethodID methodID,
-                        const PeerID peerID,
+                        const PeerID& peerID,
                         const std::shared_ptr<SentDataType>& data,
                         const typename ResultHandler<ReceivedDataType>::type& resultCallback)
 {
index af81779..7764282 100644 (file)
@@ -32,57 +32,57 @@ namespace lxcpp {
  * Base class for exceptions in lxcpp
  */
 struct Exception: public std::runtime_error {
-    Exception(const std::string& message)
+    explicit Exception(const std::string& message)
         : std::runtime_error(message) {}
 };
 
 struct NotImplementedException: public Exception {
-    NotImplementedException(const std::string& message = "Functionality not yet implemented")
+    explicit NotImplementedException(const std::string& message = "Functionality not yet implemented")
         : Exception(message) {}
 };
 
 struct ProcessSetupException: public Exception {
-    ProcessSetupException(const std::string& message = "Error while setting up a process")
+    explicit ProcessSetupException(const std::string& message = "Error while setting up a process")
         : Exception(message) {}
 };
 
 struct FileSystemSetupException: public Exception {
-    FileSystemSetupException(const std::string& message = "Error during a file system operation")
+    explicit FileSystemSetupException(const std::string& message = "Error during a file system operation")
         : Exception(message) {}
 };
 
 struct EnvironmentSetupException: public Exception {
-    EnvironmentSetupException(const std::string& message = "Error during handling environment variables")
+    explicit EnvironmentSetupException(const std::string& message = "Error during handling environment variables")
         : Exception(message) {}
 };
 
 struct CredentialSetupException: public Exception {
-    CredentialSetupException(const std::string& message = "Error during handling environment variables")
+    explicit CredentialSetupException(const std::string& message = "Error during handling environment variables")
         : Exception(message) {}
 };
 
 struct CapabilitySetupException: public Exception {
-    CapabilitySetupException(const std::string& message = "Error during a capability operation")
+    explicit CapabilitySetupException(const std::string& message = "Error during a capability operation")
         : Exception(message) {}
 };
 
 struct BadArgument: public Exception {
-    BadArgument(const std::string& message = "Bad argument passed")
+    explicit BadArgument(const std::string& message = "Bad argument passed")
         : Exception(message) {}
 };
 
 struct NoSuchValue: public Exception {
-    NoSuchValue(const std::string& message = "Value not found")
+    explicit NoSuchValue(const std::string& message = "Value not found")
         : Exception(message) {}
 };
 
 struct NetworkException : public Exception {
-    NetworkException (const std::string& message = "Error during setting up a network")
+    explicit NetworkException (const std::string& message = "Error during setting up a network")
         : Exception(message) {}
 };
 
 struct ConfigureException: public Exception {
-    ConfigureException(const std::string& message = "Error while configuring a container")
+    explicit ConfigureException(const std::string& message = "Error while configuring a container")
         : Exception(message) {}
 };
 
index e1b3be4..e72df76 100644 (file)
@@ -37,7 +37,7 @@ namespace vasum {
  */
 struct ServerException: public VasumException {
 
-    ServerException(const std::string& error) : VasumException(error) {}
+    explicit ServerException(const std::string& error) : VasumException(error) {}
 };
 
 /**
@@ -46,7 +46,7 @@ struct ServerException: public VasumException {
  */
 struct ZoneOperationException: public ServerException {
 
-    ZoneOperationException(const std::string& error) : ServerException(error) {}
+    explicit ZoneOperationException(const std::string& error) : ServerException(error) {}
 };
 
 /**
@@ -54,7 +54,7 @@ struct ZoneOperationException: public ServerException {
  */
 struct InvalidZoneIdException : public ServerException {
 
-    InvalidZoneIdException(const std::string& error) : ServerException(error) {}
+    explicit InvalidZoneIdException(const std::string& error) : ServerException(error) {}
 };
 
 /**
@@ -62,7 +62,7 @@ struct InvalidZoneIdException : public ServerException {
  */
 struct ZoneConnectionException: public ServerException {
 
-    ZoneConnectionException(const std::string& error) : ServerException(error) {}
+    explicit ZoneConnectionException(const std::string& error) : ServerException(error) {}
 };
 
 /**
@@ -70,7 +70,7 @@ struct ZoneConnectionException: public ServerException {
  */
 struct HostConnectionException: public ServerException {
 
-    HostConnectionException(const std::string& error) : ServerException(error) {}
+    explicit HostConnectionException(const std::string& error) : ServerException(error) {}
 };
 
 /**
@@ -79,12 +79,12 @@ struct HostConnectionException: public ServerException {
 */
 struct InputMonitorException: public ServerException {
 
-    InputMonitorException(const std::string& error) : ServerException(error) {}
+    explicit InputMonitorException(const std::string& error) : ServerException(error) {}
 };
 
 struct TimeoutException: public InputMonitorException {
 
-    TimeoutException(const std::string& error) : InputMonitorException (error) {}
+    explicit TimeoutException(const std::string& error) : InputMonitorException (error) {}
 };
 
 }
index 55e63f5..baf3ed1 100644 (file)
@@ -1266,7 +1266,7 @@ void ZonesManager::createZone(const std::string& id,
     } catch (std::runtime_error& e) {
         LOGE("Generate config failed: " << e.what());
         utils::launchAsRoot(std::bind(removeAllWrapper, zonePathStr));
-        throw e;
+        throw;
     }
 
     LOGT("Creating new zone");
@@ -1275,7 +1275,7 @@ void ZonesManager::createZone(const std::string& id,
     } catch (std::runtime_error& e) {
         LOGE("Creating new zone failed: " << e.what());
         utils::launchAsRoot(std::bind(removeAllWrapper, zonePathStr));
-        throw e;
+        throw;
     }
 
     mDynamicConfig.zoneIds.push_back(id);
index b8bb637..bbe96b5 100755 (executable)
@@ -11,5 +11,7 @@ OPT+=" -I common"
 OPT+=" -I libs"
 OPT+=" -I client"
 OPT+=" -I server"
+OPT+=" -I tests/unit_tests"
+OPT+=" -I tests/unit_tests/socket_test_service"
 OPT+=" -U__NR_capset"
-cppcheck ${OPT} --template=gcc ./ 1>/dev/null
+cppcheck ${OPT} --template=gcc $@ ./ 1>/dev/null
index d3b098f..8d7380b 100644 (file)
@@ -1,7 +1,26 @@
 // public API functions (or write tests to use them all)
 unusedFunction:wrapper/wrapper-compatibility.cpp
 unusedFunction:wrapper/wrapper.cpp
+unusedFunction:libs/config/kvstore.cpp
+unusedFunction:libs/ipc/internals/processor.cpp
+unusedFunction:server/zones-manager.cpp
+unusedFunction:libs/lxcpp/container-impl.cpp
+unusedFunction:libs/lxcpp/filesystem.cpp
+unusedFunction:libs/lxcpp/network.cpp
+unusedFunction:libs/lxcpp/network-config.cpp
+unusedFunction:client/vasum-client.cpp
+unusedFunction:common/netlink/netlink-message.cpp
+unusedFunction:common/utils/fd-utils.cpp
+unusedFunction:server/zone.cpp
 
-// lambda not recognized to catch exception (v1.68)
-exceptThrowInNoexecptFunction:client/vasum-client-impl.cpp
+// lambda not recognized to catch exception (v1.69)
+throwInNoexceptFunction:client/vasum-client-impl.cpp
 
+// complains that all constructors with 1 argument should be explicit
+noExplicitConstructor
+
+// required for C abstraction
+unusedStructMember:common/utils/initctl.cpp
+
+// functions called by external utilities
+unusedFunction:tests/unit_tests/ut.cpp
index 853faa2..5ba540e 100644 (file)
@@ -237,7 +237,7 @@ void testEcho(Client& c, const MethodID methodID)
     BOOST_CHECK_EQUAL(recvData->intVal, sentData->intVal);
 }
 
-void testEcho(Service& s, const MethodID methodID, const PeerID peerID)
+void testEcho(Service& s, const MethodID methodID, const PeerID& peerID)
 {
     std::shared_ptr<SendData> sentData(new SendData(56));
     std::shared_ptr<RecvData> recvData = s.callSync<SendData, RecvData>(methodID, peerID, sentData, TIMEOUT);
index 819da53..6d6a71d 100644 (file)
@@ -163,7 +163,7 @@ public:
 
     void signalSubscribe(const DbusConnection::SignalCallback& callback)
     {
-        mClient->signalSubscribe(callback, isHost() ? api::dbus::BUS_NAME : api::dbus::BUS_NAME);
+        mClient->signalSubscribe(callback, api::dbus::BUS_NAME);
     }
 
     void callSwitchToDefault()
@@ -225,12 +225,9 @@ public:
                                                    interface.c_str(),
                                                    method.c_str(),
                                                    parameters);
-        GVariantPtr result = mClient->callMethod(isHost() ? api::dbus::BUS_NAME :
-                                                            api::dbus::BUS_NAME,
-                                                 isHost() ? api::dbus::OBJECT_PATH :
-                                                            api::dbus::OBJECT_PATH,
-                                                 isHost() ? api::dbus::INTERFACE :
-                                                            api::dbus::INTERFACE,
+        GVariantPtr result = mClient->callMethod(api::dbus::BUS_NAME,
+                                                 api::dbus::OBJECT_PATH,
+                                                 api::dbus::INTERFACE,
                                                  api::dbus::METHOD_PROXY_CALL,
                                                  packedParameters,
                                                  "(v)");
index 52c14fd..b05aef0 100644 (file)
@@ -166,7 +166,7 @@ BOOST_AUTO_TEST_CASE(NoCopy)
         Task(Task&& r) : count(r.count) {}
         Task& operator=(const Task&) = delete;
         Task& operator=(Task&&) = delete;
-        void operator() () {}
+        void operator() () const {}
 
     };
 
index 5fcf54d..9889e62 100644 (file)
@@ -37,7 +37,7 @@ namespace zone_daemon {
  */
 struct ZoneDaemonException: public VasumException {
 
-    ZoneDaemonException(const std::string& error) : VasumException(error) {}
+    explicit ZoneDaemonException(const std::string& error) : VasumException(error) {}
 };