Fix svace issue 05/224105/1 accepted/tizen/unified/20200210.131806 submit/tizen/20200207.103010
authorYunmi Ha <yunmi.ha@samsung.com>
Thu, 6 Feb 2020 07:55:03 +0000 (16:55 +0900)
committerYunmi Ha <yunmi.ha@samsung.com>
Thu, 6 Feb 2020 07:55:03 +0000 (16:55 +0900)
- Remove unreachable code
- Replace strtok to strtok_r
- Add initialize code

Change-Id: Ia17c0dbfc104b839b4debcb3140aa660563ad91d
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
src/block/block.c
src/block/utils.c

index 9f0463c39d9bffde26a1db825df778deea7a111a..6fdc6789a424f601439db6a7e4e05e192814c827 100644 (file)
@@ -2858,12 +2858,6 @@ static GVariant *request_mount_block(GDBusConnection *conn,
                bdev->on_private_op = REQ_PRIVATE;
                bdev->private_pid = dbus_handle_get_sender_pid(NULL, sender);
                _D("Private operation state(%d). pid=%d.", bdev->on_private_op, bdev->private_pid);
-       } else {
-               if (bdev->on_private_op != REQ_NORMAL) {
-                       _E("Failed to process mount operation.");
-                       ret = -EPERM;
-                       goto out;
-               }
        }
 
        /* if requester want to use a specific mount point */
@@ -3423,7 +3417,7 @@ static GVariant *request_get_mmc_primary(GDBusConnection *conn,
                GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
 {
        struct block_device *bdev;
-       struct block_data *data, nodata = {0,};
+       struct block_data *data = NULL, nodata = {0,};
        dd_list *elem;
        bool found = false;
        int i;
index 35889142273fa08d9ed0171bdb81eb8d1d16026a..572cad3574b9feb18ea888778243a4f6296c48b4 100644 (file)
@@ -146,6 +146,7 @@ bool is_in_use_partition(const char *partition)
        char *line = NULL;
        size_t len = 0;
        bool ret = false;
+       char *saveptr;
 
        if (asprintf(&cmd, "/usr/bin/fuser -m %s", partition) < 0) {
                _E("Failed to call asprintf: %m");
@@ -159,7 +160,7 @@ bool is_in_use_partition(const char *partition)
                return false;
 
        if (getline(&line, &len, fp) != -1) {
-               if (strtok(line, " ") != NULL)
+               if (strtok_r(line, " ", &saveptr) != NULL)
                        ret = true;
        }