]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
btrfs: reuse kbasename helper
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 21 Aug 2013 07:32:13 +0000 (10:32 +0300)
committerChris Mason <chris.mason@fusionio.com>
Sun, 1 Sep 2013 12:16:36 +0000 (08:16 -0400)
To get name of the file from a pathname let's use kbasename() helper. It allows
to simplify code a bit.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/send.c

index cbe92da5f33bb8df91d1b93907d9b8bd09b2d6cb..b4b15467426b0cfab6033c449a043e216991c464 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/radix-tree.h>
 #include <linux/crc32c.h>
 #include <linux/vmalloc.h>
+#include <linux/string.h>
 
 #include "send.h"
 #include "backref.h"
@@ -2601,7 +2602,6 @@ static int record_ref(struct list_head *head, u64 dir,
                      u64 dir_gen, struct fs_path *path)
 {
        struct recorded_ref *ref;
-       char *tmp;
 
        ref = kmalloc(sizeof(*ref), GFP_NOFS);
        if (!ref)
@@ -2611,20 +2611,14 @@ static int record_ref(struct list_head *head, u64 dir,
        ref->dir_gen = dir_gen;
        ref->full_path = path;
 
-       tmp = strrchr(ref->full_path->start, '/');
-       if (!tmp) {
-               ref->name_len = ref->full_path->end - ref->full_path->start;
-               ref->name = ref->full_path->start;
+       ref->name = (char *)kbasename(ref->full_path->start);
+       ref->name_len = ref->full_path->end - ref->name;
+       ref->dir_path = ref->full_path->start;
+       if (ref->name == ref->full_path->start)
                ref->dir_path_len = 0;
-               ref->dir_path = ref->full_path->start;
-       } else {
-               tmp++;
-               ref->name_len = ref->full_path->end - tmp;
-               ref->name = tmp;
-               ref->dir_path = ref->full_path->start;
+       else
                ref->dir_path_len = ref->full_path->end -
                                ref->full_path->start - 1 - ref->name_len;
-       }
 
        list_add_tail(&ref->list, head);
        return 0;