Fix svace issue 94/224194/1 accepted/tizen/5.5/unified/20200217.054211 submit/tizen_5.5/20200214.104438
authorYunmi Ha <yunmi.ha@samsung.com>
Thu, 6 Feb 2020 07:55:03 +0000 (16:55 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Fri, 7 Feb 2020 04:52:34 +0000 (04:52 +0000)
- Remove unreachable code
- Replace strtok to strtok_r
- Add initialize code

Change-Id: Ia17c0dbfc104b839b4debcb3140aa660563ad91d
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
(cherry picked from commit 136d8016a80e79e5ae1626c7061a0b5dcb7dd50f)

src/block/block.c
src/block/utils.c

index 879fdf6..5aa182e 100644 (file)
@@ -2877,12 +2877,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 */
@@ -3463,7 +3457,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 3588914..572cad3 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;
        }