OSDN Git Service

Consistently use strerror(3) rather than reporting raw errno values.
authorElliott Hughes <enh@google.com>
Fri, 11 Jun 2010 23:13:15 +0000 (16:13 -0700)
committerElliott Hughes <enh@google.com>
Fri, 11 Jun 2010 23:34:38 +0000 (16:34 -0700)
We were doing the decoding almost everywhere, leaving just this handful of
places to fix.

Change-Id: I76100c213ded50e544eb6f740fea0b1633068b92

vm/Ddm.c
vm/Profile.c
vm/alloc/HeapSource.c
vm/native/dalvik_system_Zygote.c

index f76901f..1aaebe0 100644 (file)
--- a/vm/Ddm.c
+++ b/vm/Ddm.c
@@ -411,7 +411,8 @@ static bool getThreadStats(pid_t pid, pid_t tid, unsigned long* pUtime,
     int cc;
     cc = read(fd, lineBuf, sizeof(lineBuf)-1);
     if (cc <= 0) {
-        LOGI("Unable to read '%s': got %d (errno=%d)\n", nameBuf, cc, errno);
+        const char* msg = (cc == 0) ? "unexpected EOF" : strerror(errno);
+        LOGI("Unable to read '%s': %s\n", nameBuf, msg);
         close(fd);
         return false;
     }
index 657dd5a..a8d1d8a 100644 (file)
@@ -641,7 +641,8 @@ void dvmMethodTraceStop(void)
         /* append the profiling data */
         if (fwrite(state->buf, finalCurOffset, 1, state->traceFile) != 1) {
             int err = errno;
-            LOGE("trace fwrite(%d) failed, errno=%d\n", finalCurOffset, err);
+            LOGE("trace fwrite(%d) failed: %s\n",
+                finalCurOffset, strerror(err));
             dvmThrowExceptionFmt("Ljava/lang/RuntimeException;",
                 "Trace data write failed: %s", strerror(err));
         }
index f332d52..f9234f0 100644 (file)
@@ -332,8 +332,8 @@ createMspace(void *base, size_t startSize, size_t absoluteMaxSize)
         /* There's no guarantee that errno has meaning when the call
          * fails, but it often does.
          */
-        LOGE_HEAP("Can't create VM heap of size (%u,%u) (errno=%d)\n",
-            startSize/2, absoluteMaxSize, errno);
+        LOGE_HEAP("Can't create VM heap of size (%u,%u): %s\n",
+            startSize/2, absoluteMaxSize, strerror(errno));
     }
 
     return msp;
index 4337f4d..8b09b96 100644 (file)
@@ -103,7 +103,7 @@ static void sigchldHandler(int s)
 
     if (pid < 0) {
         LOG(LOG_WARN, ZYGOTE_LOG_TAG,
-            "Zygote SIGCHLD error (%d) in waitpid\n",errno);
+            "Zygote SIGCHLD error in waitpid: %s\n",strerror(errno));
     }
 }
 
@@ -128,7 +128,7 @@ static void setSignalHandler()
     err = sigaction (SIGCHLD, &sa, NULL);
 
     if (err < 0) {
-        LOGW("Error setting SIGCHLD handler errno: %d", errno);
+        LOGW("Error setting SIGCHLD handler: %s", strerror(errno));
     }
 }
 
@@ -147,7 +147,7 @@ static void unsetSignalHandler()
     err = sigaction (SIGCHLD, &sa, NULL);
 
     if (err < 0) {
-        LOGW("Error unsetting SIGCHLD handler errno: %d", errno);
+        LOGW("Error unsetting SIGCHLD handler: %s", strerror(errno));
     }
 }
 
@@ -308,15 +308,15 @@ static void enableDebugFeatures(u4 debugFlags)
          * to disable that
          */
         if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0) {
-            LOGE("could not set dumpable bit flag for pid %d, errno=%d",
-                 getpid(), errno);
+            LOGE("could not set dumpable bit flag for pid %d: %s",
+                 getpid(), strerror(errno));
         } else {
             struct rlimit rl;
             rl.rlim_cur = 0;
             rl.rlim_max = RLIM_INFINITY;
             if (setrlimit(RLIMIT_CORE, &rl) < 0) {
-                LOGE("could not disable core file generation "
-                     "for pid %d, errno=%d", getpid(), errno);
+                LOGE("could not disable core file generation for pid %d: %s",
+                    getpid(), strerror(errno));
             }
         }
     }
@@ -366,7 +366,7 @@ static pid_t forkAndSpecializeCommon(const u4* args)
             err = prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
 
             if (err < 0) {
-                LOGW("cannot PR_SET_KEEPCAPS errno: %d", errno);
+                LOGW("cannot PR_SET_KEEPCAPS: %s", strerror(errno));
             }
         }
 
@@ -375,23 +375,23 @@ static pid_t forkAndSpecializeCommon(const u4* args)
         err = setgroupsIntarray(gids);
 
         if (err < 0) {
-            LOGW("cannot setgroups() errno: %d", errno);
+            LOGW("cannot setgroups(): %s", strerror(errno));
         }
 
         err = setrlimitsFromArray(rlimits);
 
         if (err < 0) {
-            LOGW("cannot setrlimit() errno: %d", errno);
+            LOGW("cannot setrlimit(): %s", strerror(errno));
         }
 
         err = setgid(gid);
         if (err < 0) {
-            LOGW("cannot setgid(%d) errno: %d", gid, errno);
+            LOGW("cannot setgid(%d): %s", gid, strerror(errno));
         }
 
         err = setuid(uid);
         if (err < 0) {
-            LOGW("cannot setuid(%d) errno: %d", uid, errno);
+            LOGW("cannot setuid(%d): %s", uid, strerror(errno));
         }
 
         /*