Parcourir la source

[master] Assign rcode

Strictly, this is done to silence clang-analyzer. In every case,
parseAnswer() does set rcode (which is passed by reference) unless it
throws.  It looks like clang-analyzer gets confused by the exception
paths.

In any case, it's good to initialize it to the unexpected case and not
depend on parseAnswer().
Mukund Sivaraman il y a 12 ans
Parent
commit
aea6e2d1a3
1 fichiers modifiés avec 4 ajouts et 4 suppressions
  1. 4 4
      src/lib/config/ccsession.cc

+ 4 - 4
src/lib/config/ccsession.cc

@@ -456,7 +456,7 @@ ModuleCCSession::ModuleCCSession(
 
     ConstElementPtr answer, env;
     session_.group_recvmsg(env, answer, false, seq);
-    int rcode;
+    int rcode = -1;
     ConstElementPtr err = parseAnswer(rcode, answer);
     if (rcode != 0) {
         LOG_ERROR(config_logger, CONFIG_MOD_SPEC_REJECT).arg(answer->str());
@@ -535,7 +535,7 @@ ModuleCCSession::handleConfigUpdate(ConstElementPtr new_config) {
         ConstElementPtr diff = removeIdentical(new_config, getLocalConfig());
         // handle config update
         answer = config_handler_(diff);
-        int rcode;
+        int rcode = -1;
         parseAnswer(rcode, answer);
         if (rcode == 0) {
             ElementPtr local_config = getLocalConfig();
@@ -652,7 +652,7 @@ ModuleCCSession::fetchRemoteSpec(const std::string& module, bool is_filename) {
         unsigned int seq = session_.group_sendmsg(cmd, "ConfigManager");
         ConstElementPtr env, answer;
         session_.group_recvmsg(env, answer, false, seq);
-        int rcode;
+        int rcode = -1;
         ConstElementPtr spec_data = parseAnswer(rcode, answer);
         if (rcode == 0 && spec_data) {
             // received OK, construct the spec out of it
@@ -689,7 +689,7 @@ ModuleCCSession::addRemoteConfig(const std::string& spec_name,
 
     ConstElementPtr env, answer;
     session_.group_recvmsg(env, answer, false, seq);
-    int rcode;
+    int rcode = -1;
     ConstElementPtr new_config = parseAnswer(rcode, answer);
     ElementPtr local_config;
     if (rcode == 0 && new_config) {