* [PATCH] btrfs: reuse kbasename helper
@ 2013-08-12 11:41 Andy Shevchenko
2013-08-20 18:48 ` Josef Bacik
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2013-08-12 11:41 UTC (permalink / raw)
To: Chris Mason, linux-btrfs; +Cc: Andy Shevchenko
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>
---
fs/btrfs/send.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index d3f3b43..4fdc99d 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -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"
@@ -2591,20 +2592,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 = 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;
--
1.8.4.rc1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs: reuse kbasename helper
2013-08-12 11:41 [PATCH] btrfs: reuse kbasename helper Andy Shevchenko
@ 2013-08-20 18:48 ` Josef Bacik
0 siblings, 0 replies; 2+ messages in thread
From: Josef Bacik @ 2013-08-20 18:48 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Chris Mason, linux-btrfs
On Mon, Aug 12, 2013 at 02:41:10PM +0300, Andy Shevchenko wrote:
> 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>
Introduces a compile error
fs/btrfs/send.c: In function ‘record_ref’:
fs/btrfs/send.c:2615:12: warning: assignment discards ‘const’ qualifier from
pointer target type [enabled by default]
fs/btrfs/send.c:2605:8: warning: unused variable ‘tmp’ [-Wunused-variable]
Thanks,
Josef
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-08-20 18:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-12 11:41 [PATCH] btrfs: reuse kbasename helper Andy Shevchenko
2013-08-20 18:48 ` Josef Bacik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).