Browse Source

[3312] Reduce scope of variables (cppcheck report)

Mukund Sivaraman 11 years ago
parent
commit
c415976948

+ 1 - 1
src/bin/d2/tests/nc_trans_unittests.cc

@@ -326,8 +326,8 @@ public:
         ASSERT_EQ(NameChangeTransaction::NOP_EVT,
                   name_change->getNextEvent());
 
-        int cnt = 0;
         while (name_change->getNextEvent() == NameChangeTransaction::NOP_EVT) {
+            int cnt = 0;
             ASSERT_NO_THROW(cnt = runTimedIO(run_time));
             if (cnt == 0) {
                 FAIL() << "IO Service stopped unexpectedly";

+ 2 - 2
src/lib/dns/python/rdata_python.cc

@@ -104,9 +104,9 @@ Rdata_init(PyObject* self_p, PyObject* args, PyObject*) {
     const char* s;
     const char* data;
     Py_ssize_t len;
-    s_Rdata* self(static_cast<s_Rdata*>(self_p));
-
     try {
+        s_Rdata* self = static_cast<s_Rdata*>(self_p);
+
         // Create from string
         if (PyArg_ParseTuple(args, "O!O!s", &rrtype_type, &rrtype,
                              &rrclass_type, &rrclass,

+ 1 - 1
src/lib/dns/python/rrset_python.cc

@@ -251,9 +251,9 @@ PyObject*
 RRset_toWire(PyObject* self_p, PyObject* args) {
     PyObject* bytes;
     PyObject* mr;
-    const s_RRset* self(static_cast<const s_RRset*>(self_p));
 
     try {
+        const s_RRset* self = static_cast<const s_RRset*>(self_p);
         if (PyArg_ParseTuple(args, "O", &bytes) && PySequence_Check(bytes)) {
             PyObject* bytes_o = bytes;
 

+ 5 - 5
src/lib/log/message_dictionary.cc

@@ -63,13 +63,13 @@ MessageDictionary::load(const char* messages[]) {
     vector<std::string> duplicates;
     int i = 0;
     while (messages[i]) {
-
-        // ID present, so note it and point to text.
-        const MessageID ident(messages[i++]);
+        // ID present, so point to text.
+        ++i;
         if (messages[i]) {
-
+            const MessageID ident(messages[i - 1]);
             // Text not null, note it and point to next ident.
-            string text(messages[i++]);
+            const std::string text(messages[i]);
+            ++i;
 
             // Add ID and text to message dictionary, noting if the ID was
             // already present.