Addressed build warnings in OICMiddle example.
authorOssama Othman <ossama.othman@intel.com>
Mon, 11 May 2015 20:06:39 +0000 (13:06 -0700)
committerErich Keane <erich.keane@intel.com>
Tue, 12 May 2015 16:56:56 +0000 (16:56 +0000)
Fixed OICMiddle compile-time warnings regarding potential use of an
uninitialized variable, as well as an ignored getline() result.

Change-Id: I6ce5a7212ea87cfc506cc97ca97a873c308bf17c
Signed-off-by: Ossama Othman <ossama.othman@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/955
Reviewed-by: John Light <john.j.light@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
examples/OICMiddle/LineInput.cpp

index 52a8528..685d33a 100644 (file)
@@ -52,9 +52,8 @@ int LineInput::run()
     while (true) {
         fputs(">", stdout);
         len = 0;
-        getline(&line, &len, stdin);
-        int n = strlen(line);
-        if (!n)
+        const ssize_t n = getline(&line, &len, stdin);
+        if (n <= 0)
             continue;
         if (m_observer) {
             m_observer->cancelObserve();
@@ -382,7 +381,7 @@ ParseState LineInput::putCharInElem(char c, char *& e, ParseState newState)
 LineResult LineInput::parseLine(string lineIn, elements_t& elems)
 {
     const char *d;
-    char c, *e, delim;
+    char c, *e, delim = 0;
     bool isSep1, isSep2;
     size_t len = lineIn.size();
     ParseState state = PS_Between;