changeset 30:9c027507d9bf

Bug 1872: Reduce the code about strerror_r() and macros. reviewed-by: yasuenag
author KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp>
date Thu, 17 Jul 2014 14:18:26 +0900
parents 835c846563fb
children 778bd93bc33a
files agent/ChangeLog agent/src/logManager.cpp
diffstat 2 files changed, 8 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/agent/ChangeLog	Wed Jul 16 22:54:43 2014 +0900
+++ b/agent/ChangeLog	Thu Jul 17 14:18:26 2014 +0900
@@ -1,3 +1,7 @@
+2014-07-16  KUBOTA Yuji  <kubota.yuji@lab.ntt.co.jp>
+
+	* Bug 1872: Reduce the code about strerror_r() and macros.
+
 2014-07-16  Yasumasa Suenaga  <yasuenag@gmail.com>
 
 	* Bug 1866: HeapStats agent should be adapted to JDK-8032235
--- a/agent/src/logManager.cpp	Wed Jul 16 22:54:43 2014 +0900
+++ b/agent/src/logManager.cpp	Thu Jul 17 14:18:26 2014 +0900
@@ -1260,22 +1260,10 @@
     /* Copy file. */
     result = copyFile(copyFileList[i], basePath);
     if(unlikely(result != 0)){
-      char error_string[1024];
 
-#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
-      /* XSI-compliant version of strerror_r() */
-      strerror_r(result, error_string, 1024);
-#endif
-
-      PRINT_WARN_MSG_HEADER << "Failure copy file."
-                << " path:\"" << copyFileList[i] << "\""
-#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
-                << " cause:\"" << error_string << "\""
-#else
-                /* GNU-specific version of strerror_r() */
-                << " cause:\"" << strerror_r(result, error_string, 1024) << "\""
-#endif
-                << NEWLINE;
+      char message[512+PATH_MAX] = {0};
+      sprintf(message, "Failure copy file. path:\"%s\"", copyFileList[i]);
+      PRINT_WARN_MSG_AND_ERRNO(message,result);
 
       /* If disk is full. */
       if(unlikely(isRaisedDiskFull(result))){
@@ -1386,7 +1374,7 @@
     /* If catch a failure during the copy process, show warn messages. */
     if (unlikely(result != 0)) {
       char message[512+PATH_MAX] = {0};
-      sprintf(message, "Failure copy file. path: %s", streamList[i]);
+      sprintf(message, "Failure copy file. path:\"%s\"", streamList[i]);
       PRINT_WARN_MSG_AND_ERRNO(message,result);
 
       /* If disk is full. */