Care the return value of "[f]close" and "dlXXX"
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 13 Aug 2013 01:15:37 +0000 (10:15 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 13 Aug 2013 01:15:37 +0000 (10:15 +0900)
[model] Redwood
[binary_type] AP
[customer] Docomo/Orange/Open
[issue#] N/A
[problem]
[cause]
[solution]
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: Ifbc75aeb62c099bc966bb103e33022478b38359b

src/critical_log.c
src/fault.c
src/so_handler.c
src/update_monitor.c

index ee198e5..cf5a94e 100644 (file)
@@ -158,7 +158,9 @@ HAPI int critical_log_fini(void)
        }
 
        if (s_info.fp) {
-               fclose(s_info.fp);
+               if (fclose(s_info.fp) != 0) {
+                       ErrPrint("fclose: %s\n", strerror(errno));
+               }
                s_info.fp = NULL;
        }
 
index 5f5974e..4d002fa 100644 (file)
@@ -95,7 +95,9 @@ static void signal_handler(int signum, siginfo_t *info, void *unused)
                        if (write(fd, so_fname, strlen(so_fname)) != strlen(so_fname)) {
                                ErrPrint("Failed to recording the fault SO filename (%s)\n", so_fname);
                        }
-                       close(fd);
+                       if (close(fd) < 0) {
+                               ErrPrint("close: %s\n", strerror(errno));
+                       }
                }
        }
 
index e973c1b..53fdd4d 100644 (file)
@@ -126,7 +126,9 @@ static void delete_livebox(struct so_item *item)
        }
 
        heap_monitor_del_target(item->so_fname);
-       dlclose(item->handle);
+       if (dlclose(item->handle) != 0) {
+               ErrPrint("dlclose: %s\n", dlerror());
+       }
        free(item->so_fname);
        free(item->pkgname);
        free(item);
@@ -135,6 +137,7 @@ static void delete_livebox(struct so_item *item)
 static struct so_item *new_adaptor(const char *pkgname, const char *abi)
 {
        struct so_item *item;
+       char *errmsg;
 
        item = calloc(1, sizeof(*item));
        if (!item) {
@@ -178,6 +181,11 @@ static struct so_item *new_adaptor(const char *pkgname, const char *abi)
        }
        fault_unmark_call(pkgname, __func__, __func__, USE_ALARM);
 
+       errmsg = dlerror();
+       if (errmsg) {
+               DbgPrint("dlerror(can be ignored): %s\n", errmsg);
+       }
+
        item->adaptor.create = (adaptor_create_t)dlsym(item->handle, "livebox_create");
        if (!item->adaptor.create) {
                ErrPrint("symbol: livebox_create - %s\n", dlerror());
@@ -282,6 +290,7 @@ static struct so_item *new_adaptor(const char *pkgname, const char *abi)
 static struct so_item *new_livebox(const char *pkgname)
 {
        struct so_item *item;
+       char *errmsg;
 
        item = calloc(1, sizeof(*item));
        if (!item) {
@@ -325,6 +334,11 @@ static struct so_item *new_livebox(const char *pkgname)
        }
        fault_unmark_call(pkgname, __func__, __func__, USE_ALARM);
 
+       errmsg = dlerror();
+       if (errmsg) {
+               DbgPrint("dlerror(can be ignored): %s\n", errmsg);
+       }
+
        item->livebox.create = (create_t)dlsym(item->handle, "livebox_create");
        if (!item->livebox.create) {
                ErrPrint("symbol: livebox_create - %s\n", dlerror());
index bd077bc..9162e3d 100644 (file)
@@ -157,7 +157,9 @@ HAPI int update_monitor_init(void)
 
        if (s_info.iwd < 0) {
                ErrPrint("Error: %s\n", strerror(errno));
-               close(s_info.ifd);
+               if (close(s_info.ifd) < 0) {
+                       ErrPrint("close: %s\n", strerror(errno));
+               }
                s_info.ifd = LB_STATUS_ERROR_INVALID;
                return LB_STATUS_ERROR_IO;
        }
@@ -171,7 +173,9 @@ HAPI int update_monitor_init(void)
                }
                s_info.iwd = -EINVAL;
 
-               close(s_info.ifd);
+               if (close(s_info.ifd) < 0) {
+                       ErrPrint("close: %s\n", strerror(errno));
+               }
                s_info.ifd = LB_STATUS_ERROR_INVALID;
                return LB_STATUS_ERROR_FAULT;
        }
@@ -196,7 +200,9 @@ HAPI int update_monitor_fini(void)
 
                s_info.iwd = LB_STATUS_ERROR_INVALID;
 
-               close(s_info.ifd);
+               if (close(s_info.ifd) < 0) {
+                       ErrPrint("close: %s\n", strerror(errno));
+               }
                s_info.ifd = LB_STATUS_ERROR_INVALID;
        }