Add add_binary() wrapper 34/151934/1
authorAlexander Aksenov <a.aksenov@samsung.com>
Fri, 22 Sep 2017 09:54:20 +0000 (12:54 +0300)
committerAlexander Aksenov <a.aksenov@samsung.com>
Fri, 22 Sep 2017 10:08:17 +0000 (13:08 +0300)
Change-Id: I4727174d416112a502782e12b81f8841c49f20dc
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
helper/dahelper.c
helper/got_patching.c
include/dahelper.h

index 3373beb8dc6b29f666b62e2977a27bc222daa930..b19176188ca25d2291be63d2c2f6ee6b92f1a77d 100755 (executable)
@@ -187,7 +187,7 @@ int add_binary(char *path)
 
        if (!SLIST_EMPTY(&gTraceInfo.bins_info.bins_list) &&
                (_find_binary_no_lock(real_path) != NULL)) {
-               ret = EALREADY;
+               ret = -EALREADY;
                goto free_real_path;
        }
 
@@ -213,6 +213,18 @@ add_bin_unlock:
        return ret;
 }
 
+/* Return 0 if binary added or already exists, -errcode otherwise */
+int add_binary_on_demand(char *path)
+{
+       int ret;
+
+       ret = add_binary(path);
+       if (!ret || ret == -EALREADY)
+               return 0;
+
+       return ret;
+}
+
 /* Returns 0 on success, -errcode on fail */
 int remove_binary(char *path)
 {
index 1b6143f3902860c1e1de4ddba681888d4268f06a..c21e963824ea0227363796ffc4823bb6f21cde03 100644 (file)
@@ -124,11 +124,11 @@ static void _process_target_bins(char *bins_data, size_t avail_size)
                ptr += len;
 
                /* TODO Think about removing binaries */
-               ret = add_binary(path);
-               if (ret < 0)
+               ret = add_binary_on_demand(path);
+               if (!ret)
                        PRINTERR("Adding failed, error code %d", ret);
-               /* add_binary() allocates new buffer with realpath(), so this
-                * path should be freed */
+               /* add_binary_on_demand() allocates new buffer with realpath(),
+                * so this path should be freed */
                free(path);
        }
 }
index 21a3bae39de2e8237dc2c9029a02c7b5669bdf42..ecf9eadd216e6cd542548e32d00fd5f4fa13ac8f 100755 (executable)
@@ -133,6 +133,7 @@ void on_orientation_changed(int angle, bool capi);
 
 /* Binaries list functions */
 int add_binary(char *path);
+int add_binary_on_demand(char *path);
 bool check_binary(const char *path);
 int remove_binary(char *path);
 void cleanup_binaries(void);