Coverity: fix issues in libatrace [1/1]

PD#SWPL-172614

Problem:
Some coverity issues has been found
1.resource leak
2.macro redefinition

Solution:
1.close fd at necessary positions
2.modify definition rule

Verify:
coverity scan

Signed-off-by: kirk.wang <kirk.wang@amlogic.com>
Change-Id: I2cf22c8d9f7f9d7c85d40b626a2fc8923e0c7187
diff --git a/libatrace/atrace.c b/libatrace/atrace.c
index 99c8a33..69770d2 100644
--- a/libatrace/atrace.c
+++ b/libatrace/atrace.c
@@ -36,6 +36,7 @@
     write(atrace_marker_fd, buf, len); \
 }
 
+#ifndef atomic_store_explicit
 #define atomic_store_explicit(PTR, VAL, MO)             \
   __extension__                             \
   ({                                    \
@@ -43,6 +44,7 @@
     __typeof__ (*__atomic_store_ptr) __atomic_store_tmp = (VAL);    \
     __atomic_store (__atomic_store_ptr, &__atomic_store_tmp, (MO)); \
   })
+#endif
 
 int                     atrace_marker_fd     = -1;
 atomic_bool             atrace_is_ready      = ATOMIC_VAR_INIT(false);
diff --git a/libatrace/atrace_cmd.cpp b/libatrace/atrace_cmd.cpp
index 907ff87..91b40f7 100644
--- a/libatrace/atrace_cmd.cpp
+++ b/libatrace/atrace_cmd.cpp
@@ -279,7 +279,9 @@
   if (fd == -1) {
     return false;
   }
-  return ReadFdToString(fd, content);
+  bool result =  ReadFdToString(fd, content);
+  close(fd);
+  return result;
 }
 
 bool WriteFully(int fd, const void* data, size_t byte_count) {
@@ -769,6 +771,7 @@
             break;
         }
     }
+    close(traceFD);
 }
 
 // Read the current kernel trace and write it to stdout.