Cppcheck issue fix
authorjunsuk77.oh <junsuk77.oh@samsung.com>
Wed, 3 Apr 2013 01:28:38 +0000 (10:28 +0900)
committerjunsuk77.oh <junsuk77.oh@samsung.com>
Wed, 3 Apr 2013 01:28:38 +0000 (10:28 +0900)
Change-Id: I15c39ec4b3206db06a5b915d95c6c6ac389c297e
Signed-off-by: junsuk77.oh <junsuk77.oh@samsung.com>
packaging/app2sd.spec
plugin/app2sd/src/app2sd_interface.c
plugin/app2sd/src/app2sd_internals.c
plugin/app2sd/src/app2sd_internals_registry.c
plugin/app2sd/src/app2sd_internals_utils.c

index e096e54..235d059 100755 (executable)
@@ -1,7 +1,7 @@
 Name:       app2sd
 Summary:    Application installation on external memory
-Version:    0.5
-Release:    9
+Version:    0.5.12
+Release:    1
 Group:      Application Framework/Application Installer
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index 3e9fe76..110eb0e 100755 (executable)
@@ -519,7 +519,7 @@ int app2sd_pre_app_upgrade(const char *pkgid, GList* dir_list,
        curr_size = _app2sd_calculate_file_size(app_path);
        curr_size = (curr_size/1024)/1024;
 
-       if (curr_size<=0) {
+       if (curr_size==0) {
                app2ext_print
                    ("App2SD Error: App Entry is not present in SD Card\n");
                return APP2EXT_ERROR_LOOPBACK_DEVICE_UNAVAILABLE;
@@ -630,6 +630,7 @@ int app2sd_post_app_upgrade(const char *pkgid,
        return ret;
 }
 
+#if 0
 /**
  * Reserved API for forced cleanup
  *
@@ -701,6 +702,7 @@ int app2sd_force_cleanup(const char *pkgid){
        }
        return ret;
 }
+#endif
 
 /* This is the plug-in load function. The plugin has to bind its functions to function pointers of handle
        @param[in/out]          st_interface    Specifies the storage interface.
index d2649a7..9aba3fb 100755 (executable)
@@ -48,7 +48,8 @@ char *_app2sd_find_associated_device_node(const char *pkgid)
        char delims[] = ":";
        char *result = NULL;
        char app_path[FILENAME_MAX] = { '\0' };
-
+       char dev[FILENAME_MAX] = {0,};
+       char *devnode = NULL;
        snprintf(app_path, FILENAME_MAX, "%s%s", APP2SD_PATH,
                 pkgid);
        result = (char *)_app2sd_find_associated_device(app_path);
@@ -58,16 +59,20 @@ char *_app2sd_find_associated_device_node(const char *pkgid)
                return NULL;
        }
        /*process the string*/
-       if (strstr(result, "/dev") == NULL) {
+       snprintf(dev, FILENAME_MAX-1, "%s", result);
+       if (strstr(dev, "/dev") == NULL) {
                app2ext_print
                    ("App2SD Error! Unable to find the associated File\n");
+
+               free(result);
                return NULL;
        } else {
-               ret_result = strtok(result, delims);
+               ret_result = strtok(dev, delims);
+               if (ret_result)
+                       devnode = strdup(ret_result);
        }
-
-       return ret_result;
-
+       free(result);
+       return devnode;
 }
 
 char *_app2sd_create_loopdevice_node(void)
@@ -101,7 +106,8 @@ char *_app2sd_create_loopdevice_node(void)
                app2ext_print("Device node candidate is %s \n", dev_path);
                dev_t dev_node;
                dev_node = makedev(DEV_MAJOR, count);
-               if ((ret = mknod(dev_path, S_IFBLK | mode, dev_node)) < 0) {
+               ret = mknod(dev_path, S_IFBLK | mode, dev_node);
+               if (ret < 0) {
                        app2ext_print
                            ("Error while creating the device node: errno is %d\n",
                             errno);
@@ -1233,7 +1239,6 @@ int _app2sd_update_loopback_device_size(const char *pkgid,
        int ret = 0;
        char *device_node = NULL;
        char *old_device_node = NULL;
-       char *result = NULL;
        int err_res = 0;
        char app_mmc_path[FILENAME_MAX] = { 0, };
        char app_archive_path[FILENAME_MAX] = { 0, };
index 6f29fc9..b0d0f2e 100755 (executable)
@@ -152,47 +152,6 @@ int _app2sd_remove_password_from_db(const char *pkgid)
 }
 
 /*
- *@_app2sd_access_password_from_db
- *This function is to find out whther password exists for an application.
- * param[in]: pkgid: package id
- * return: On success, it will return zero , else value<0 if fail.
- */
-int _app2sd_access_password_from_db(const char *pkgid)
-{
-       char query[MAX_QUERY_LEN] = { 0 };
-       int access_flag = 0;
-       int i;
-       sqlite3_stmt *stmt = NULL;
-       const char *tail = NULL;
-
-       snprintf(query, MAX_QUERY_LEN,
-                "select * from app2sd where pkgid LIKE '%s'", pkgid);
-       app2ext_print("\n access querys is %s ", query);
-
-       if (SQLITE_OK != sqlite3_prepare(app2sd_db, query,
-                                        strlen(query), &stmt, &tail)) {
-               app2ext_print("sqlite3_prepare error\n");
-               return -1;
-       }
-       for (i = 0; SQLITE_ROW == sqlite3_step(stmt); i++) {
-               app2ext_print("\n entry available in sqlite");
-               access_flag = 1;
-
-       }
-       if (SQLITE_OK != sqlite3_finalize(stmt)) {
-               app2ext_print("error : sqlite3_finalize\n");
-               return -1;
-       }
-       if (access_flag == 1) {
-               app2ext_print("\n app2sd  value is accessible  ");
-               return APP2EXT_SUCCESS;
-       } else {
-               app2ext_print("\n app2sd  value is  not accessible  ");
-               return -1;
-       }
-}
-
-/*
  *@_app2sd_get_password_from_db
  *This function is to retrive password from DB
  * param[in]: pkgid: package id
index 23a8c30..aaf9c63 100755 (executable)
@@ -271,7 +271,15 @@ char *_app2sd_encrypt_device(const char *device, const char *pkgid,
                close(1);
                close(2);
                result = dup(my_pipe[1]);
+               if (result < 0) {
+                       fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+                       _exit(-1);
+               }
                result = dup(my_pipe[1]);
+               if (result < 0) {
+                       fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+                       _exit(-1);
+               }
                if (execvp(argv[0], (char *const *)argv) < 0) {
                        fprintf(stderr, "execvp failed %d....%s\n", errno, strerror(errno));    /*Don't use d_msg_app2sd */
                }
@@ -280,6 +288,8 @@ char *_app2sd_encrypt_device(const char *device, const char *pkgid,
                /* parent */
                close(my_pipe[1]);
                result = read(my_pipe[0], buf, FILENAME_MAX);
+               if (result < 0)
+                       fprintf(stderr, "read failed %d....%s\n", errno, strerror(errno));
                break;
        }
 
@@ -316,7 +326,15 @@ char *_app2sd_detach_loop_device(const char *device)
                close(1);
                close(2);
                result = dup(my_pipe[1]);
+               if (result < 0) {
+                       fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+                       _exit(-1);
+               }
                result = dup(my_pipe[1]);
+               if (result < 0) {
+                       fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+                       _exit(-1);
+               }
                if (execvp(argv[0], (char *const *)argv) < 0) {
                        fprintf(stderr, "execvp failed\n");     /*Don't use d_msg_app2sd */
                }
@@ -325,6 +343,8 @@ char *_app2sd_detach_loop_device(const char *device)
                /* parent */
                close(my_pipe[1]);
                result = read(my_pipe[0], buf, FILENAME_MAX);
+               if (result < 0)
+                       fprintf(stderr, "read failed %d....%s\n", errno, strerror(errno));
                break;
        }
 
@@ -362,7 +382,15 @@ char *_app2sd_find_associated_device(const char *mmc_app_path)
                close(1);
                close(2);
                result = dup(my_pipe[1]);
+               if (result < 0) {
+                       fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+                       _exit(-1);
+               }
                result = dup(my_pipe[1]);
+               if (result < 0) {
+                       fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+                       _exit(-1);
+               }
                if (execvp(argv[0], (char *const *)argv) < 0) {
                        fprintf(stderr, "execvp failed\n");     /*Don't use d_msg_app2sd */
                }
@@ -371,6 +399,8 @@ char *_app2sd_find_associated_device(const char *mmc_app_path)
                /* parent */
                close(my_pipe[1]);
                result = read(my_pipe[0], buf, FILENAME_MAX);
+               if (result < 0)
+                       fprintf(stderr, "read failed %d....%s\n", errno, strerror(errno));
                break;
        }
 
@@ -408,7 +438,15 @@ char *_app2sd_find_free_device(void)
                close(1);
                close(2);
                result = dup(my_pipe[1]);
+               if (result < 0) {
+                       fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+                       _exit(-1);
+               }
                result = dup(my_pipe[1]);
+               if (result < 0) {
+                       fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+                       _exit(-1);
+               }
                if (execvp(argv[0], (char *const *)argv) < 0) {
                        fprintf(stderr, "execvp failed\n");     /*Don't use d_msg_app2sd */
                }
@@ -417,6 +455,8 @@ char *_app2sd_find_free_device(void)
                /* parent */
                close(my_pipe[1]);
                result = read(my_pipe[0], buf, FILENAME_MAX);
+               if (result < 0)
+                       fprintf(stderr, "read failed %d....%s\n", errno, strerror(errno));
                break;
        }