소스 검색

Fix unused result in remaining warnings

This is the last warnings fix, from now on we should keep -Werror on all builds.
Renato Golin 13 년 전
부모
커밋
9afa022097
5개의 변경된 파일21개의 추가작업 그리고 9개의 파일을 삭제
  1. 4 1
      esp/tools/soapplus/msggenerator.cpp
  2. 3 2
      system/jlib/jdebug.cpp
  3. 4 1
      system/jlib/jfile.cpp
  4. 4 2
      system/jlib/jthread.cpp
  5. 6 3
      system/jlib/jutil.cpp

+ 4 - 1
esp/tools/soapplus/msggenerator.cpp

@@ -546,7 +546,10 @@ StringBuffer& MessageGenerator::generateMessage(const char* method, const char*
                 WaitForSingleObject(pinfo.hProcess, INFINITE);
 #else
                 cmdline.appendf("vi %s", tmpfname.str());
-                system(cmdline.str());
+                if (system(cmdline.str()) == -1) {
+                    ERRLOG("MessageGenerator::generateMessage: could not execute command %s", cmdline.str());
+                    throwUnexpected();
+                }
 #endif
                 message.clear().loadFile(tmpfname.str(), true);
             }

+ 3 - 2
system/jlib/jdebug.cpp

@@ -1849,11 +1849,12 @@ public:
 #else
         FILE* procfp;
         procfp = fopen("/proc/uptime", "r");
+        int matched = 0;
         if (procfp) {
-            fscanf(procfp, "%lf %lf\n", &OldSystemTime, &OldIdleTime);
+            matched = fscanf(procfp, "%lf %lf\n", &OldSystemTime, &OldIdleTime);
             fclose(procfp);
         }
-        else
+        if (!procfp || matched == 0 || matched == EOF)
             OldSystemTime = 0;
         primaryfs.append("/");
 #endif

+ 4 - 1
system/jlib/jfile.cpp

@@ -4856,7 +4856,10 @@ StringBuffer &makeAbsolutePath(const char *relpath,StringBuffer &out)
 #else
     char path[PATH_MAX+1];
     path[0] = 0;
-    realpath(relpath,path);
+    if (!realpath(relpath,path)) {
+        ERRLOG("makeAbsolutePath: could not get absolute path of %s", relpath);
+        throwUnexpected();
+    }
 #endif
     return out.append(path);
 }

+ 4 - 2
system/jlib/jthread.cpp

@@ -1784,8 +1784,10 @@ public:
 
             unsigned argc;
             char **argv=splitargs(prog,argc);
-            if (dir.get())
-                chdir(dir);
+            if (dir.get() && chdir(dir) == -1) {
+                ERRLOG("CLinuxPipeProcess::run: could not change dir to %s", dir.get());
+                throwUnexpected();
+            }
             execvp(argv[0],argv);
             _exit(START_FAILURE);    // must be _exit!!     
         }

+ 6 - 3
system/jlib/jutil.cpp

@@ -1361,9 +1361,12 @@ int make_daemon(bool printpid)
         exit(EXIT_SUCCESS);
     }
 
-    freopen("/dev/null", "r", stdin);
-    freopen("/dev/null", "w", stdout);
-    freopen("/dev/null", "w", stderr);
+    if (!freopen("/dev/null", "r", stdin) ||
+        !freopen("/dev/null", "w", stdout) ||
+        !freopen("/dev/null", "w", stderr)) {
+        PrintLog("reopen std in/out/err failed\n");
+        return(EXIT_FAILURE);
+    }
 
     return(EXIT_SUCCESS);
 #else