refactoring : remove unused parameter. 99/162299/1
authorINSUN PYO <insun.pyo@samsung.com>
Thu, 30 Nov 2017 05:58:40 +0000 (14:58 +0900)
committerJung <pr.jung@samsung.com>
Thu, 30 Nov 2017 06:47:39 +0000 (06:47 +0000)
Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
Change-Id: I655750c0fde5cf606ca3195e49656891a4510980
(cherry picked from commit 99675bf459ff204ce429ade2648d328104df6737)

src/block/block.c

index 4df4812..658cf8f 100644 (file)
@@ -907,40 +907,30 @@ static struct block_device *find_block_device_by_id(int id)
        return NULL;
 }
 
-static char *get_operation_char(enum block_dev_operation op,
-               char *name, unsigned int len)
+static const char *get_operation_char(enum block_dev_operation op)
 {
-       char *str = "unknown";
-
-       if (!name)
-               return NULL;
-
        switch (op) {
        case BLOCK_DEV_MOUNT:
-               str = "MOUNT";
-               break;
+               return "MOUNT";
+
        case BLOCK_DEV_UNMOUNT:
-               str = "UNMOUNT";
-               break;
+               return "UNMOUNT";
+
        case BLOCK_DEV_FORMAT:
-               str = "FORMAT";
-               break;
+               return "FORMAT";
+
        case BLOCK_DEV_INSERT:
-               str = "INSERT";
-               break;
+               return "INSERT";
+
        case BLOCK_DEV_REMOVE:
-               str = "REMOVE";
-               break;
+               return "REMOVE";
+
        case BLOCK_LUKS_CLOSE:
-               str = "LUKS CLOSE";
-               break;
-       default:
-               _E("invalid operation (%d)", op);
-               break;
+               return "LUKS CLOSE";
        }
 
-       snprintf(name, len, "%s", str);
-       return name;
+       _E("invalid operation (%d)", op);
+       return "unknown";
 }
 
 static void create_external_apps_directory(void)
@@ -959,10 +949,9 @@ static int pipe_trigger(enum block_dev_operation op,
 {
        struct pipe_data pdata = { op, bdev, result };
        int n;
-       char name[16];
 
        _D("op : %s, bdev : %p, result : %d",
-                       get_operation_char(pdata.op, name, sizeof(name)),
+                       get_operation_char(pdata.op),
                        pdata.bdev, pdata.result);
 
        // Multi thread should not write at the same time
@@ -979,7 +968,6 @@ static bool pipe_cb(int fd, void *data)
        int n;
        int thread_id;
        int ret;
-       char name[16];
 
        n = read(fd, &pdata, sizeof(pdata));
        if (n != sizeof(pdata) || !pdata.bdev) {
@@ -988,7 +976,7 @@ static bool pipe_cb(int fd, void *data)
        }
 
        _I("op : %s, bdev : %p, result : %d",
-                       get_operation_char(pdata.op, name, sizeof(name)),
+                       get_operation_char(pdata.op),
                        pdata.bdev, pdata.result);
 
        if (pdata.op == BLOCK_DEV_MOUNT && pdata.result < 0) {
@@ -1651,7 +1639,6 @@ static void remove_operation(struct block_device *bdev)
 {
        struct operation_queue *op;
        dd_list *l, *next;
-       char name[16];
        int thread_id;
 
        assert(bdev);
@@ -1663,7 +1650,7 @@ static void remove_operation(struct block_device *bdev)
        DD_LIST_FOREACH_SAFE(bdev->op_queue, l, next, op) {
                if (op->done) {
                        _D("Remove operation (%s, %s)",
-                                       get_operation_char(op->op, name, sizeof(name)),
+                                       get_operation_char(op->op),
                                        bdev->data->devnode);
 
                        DD_LIST_REMOVE(bdev->op_queue, op);
@@ -1777,7 +1764,6 @@ static void trigger_operation(struct block_device *bdev, dd_list *queue, struct
        int ret = 0;
        int thread_id;
        char devnode[PATH_MAX];
-       char name[16];
        enum block_dev_operation operation;
        bool unmounted = false;
 
@@ -1801,21 +1787,21 @@ static void trigger_operation(struct block_device *bdev, dd_list *queue, struct
                operation = op->op;
 
                _D("Thread id %d Trigger operation (%s, %s)", thread_id,
-                       get_operation_char(operation, name, sizeof(name)), devnode);
+                       get_operation_char(operation), devnode);
 
                unmounted = false;
                if (operation == BLOCK_DEV_INSERT && bdev->removed) {
                        check_removed(bdev, &queue, &op);
                        operation = op->op;
                        _D("Trigger operation again (%s, %s)",
-                               get_operation_char(operation, name, sizeof(name)), devnode);
+                               get_operation_char(operation), devnode);
                }
                if (operation == BLOCK_DEV_MOUNT) {
                        unmounted = check_unmount(bdev, &queue, &op);
                        if (unmounted) {
                                operation = op->op;
                                _D("Trigger operation again (%s, %s)",
-                                       get_operation_char(operation, name, sizeof(name)), devnode);
+                                       get_operation_char(operation), devnode);
                        }
                }
 
@@ -1998,14 +1984,13 @@ static int add_operation(struct block_device *bdev,
        int ret;
        int thread_id;
        bool start_th;
-       char name[16];
 
        if (!bdev)
                return -EINVAL;
 
 
        _I("Add operation (%s, %s)",
-                       get_operation_char(operation, name, sizeof(name)),
+                       get_operation_char(operation),
                        bdev->data->devnode);
 
        thread_id = bdev->thread_id;