All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: use kbasename in btrfsic_mount
@ 2015-11-27  8:11 Rasmus Villemoes
  2015-11-27  8:31 ` David Sterba
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Rasmus Villemoes @ 2015-11-27  8:11 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba
  Cc: Rasmus Villemoes, linux-btrfs, linux-kernel

This is more readable.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---

I think the following strlcpy may be somewhat fragile since obviously
ds->name and p overlap. It certainly relies on strlcpy doing a forward
copy, and since different architectures can have their own strlcpy,
that's hard to verify (and also won't necessarily continue to hold).

Maybe

  if (p != ds->name)
    memmove(ds->name, p, strlen(p)+1);

instead.


 fs/btrfs/check-integrity.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 0340c57bf377..55a5cff390b9 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -95,6 +95,7 @@
 #include <linux/genhd.h>
 #include <linux/blkdev.h>
 #include <linux/vmalloc.h>
+#include <linux/string.h>
 #include "ctree.h"
 #include "disk-io.h"
 #include "hash.h"
@@ -3136,11 +3137,7 @@ int btrfsic_mount(struct btrfs_root *root,
 		ds->state = state;
 		bdevname(ds->bdev, ds->name);
 		ds->name[BDEVNAME_SIZE - 1] = '\0';
-		for (p = ds->name; *p != '\0'; p++);
-		while (p > ds->name && *p != '/')
-			p--;
-		if (*p == '/')
-			p++;
+		p = kbasename(ds->name);
 		strlcpy(ds->name, p, sizeof(ds->name));
 		btrfsic_dev_state_hashtable_add(ds,
 						&btrfsic_dev_state_hashtable);
-- 
2.6.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: use kbasename in btrfsic_mount
  2015-11-27  8:11 [PATCH] btrfs: use kbasename in btrfsic_mount Rasmus Villemoes
@ 2015-11-27  8:31 ` David Sterba
  2015-11-27  8:32 ` kbuild test robot
  2015-11-27  9:37 ` Andy Shevchenko
  2 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2015-11-27  8:31 UTC (permalink / raw)
  To: Rasmus Villemoes; +Cc: Chris Mason, Josef Bacik, linux-btrfs, linux-kernel

On Fri, Nov 27, 2015 at 09:11:31AM +0100, Rasmus Villemoes wrote:
> This is more readable.
> 
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>

Reviewed-by: David Sterba <dsterba@suse.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: use kbasename in btrfsic_mount
  2015-11-27  8:11 [PATCH] btrfs: use kbasename in btrfsic_mount Rasmus Villemoes
  2015-11-27  8:31 ` David Sterba
@ 2015-11-27  8:32 ` kbuild test robot
  2015-11-27  8:38   ` Rasmus Villemoes
  2015-11-27  9:37 ` Andy Shevchenko
  2 siblings, 1 reply; 5+ messages in thread
From: kbuild test robot @ 2015-11-27  8:32 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: kbuild-all, Chris Mason, Josef Bacik, David Sterba,
	Rasmus Villemoes, linux-btrfs, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1638 bytes --]

Hi Rasmus,

[auto build test WARNING on: v4.4-rc2]
[also build test WARNING on: next-20151127]

url:    https://github.com/0day-ci/linux/commits/Rasmus-Villemoes/btrfs-use-kbasename-in-btrfsic_mount/20151127-161249
config: i386-randconfig-s1-201547 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   fs/btrfs/check-integrity.c: In function 'btrfsic_mount':
>> fs/btrfs/check-integrity.c:3140:5: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      p = kbasename(ds->name);
        ^

vim +/const +3140 fs/btrfs/check-integrity.c

  3124			char *p;
  3125	
  3126			if (!device->bdev || !device->name)
  3127				continue;
  3128	
  3129			ds = btrfsic_dev_state_alloc();
  3130			if (NULL == ds) {
  3131				printk(KERN_INFO
  3132				       "btrfs check-integrity: kmalloc() failed!\n");
  3133				mutex_unlock(&btrfsic_mutex);
  3134				return -1;
  3135			}
  3136			ds->bdev = device->bdev;
  3137			ds->state = state;
  3138			bdevname(ds->bdev, ds->name);
  3139			ds->name[BDEVNAME_SIZE - 1] = '\0';
> 3140			p = kbasename(ds->name);
  3141			strlcpy(ds->name, p, sizeof(ds->name));
  3142			btrfsic_dev_state_hashtable_add(ds,
  3143							&btrfsic_dev_state_hashtable);
  3144		}
  3145	
  3146		ret = btrfsic_process_superblock(state, fs_devices);
  3147		if (0 != ret) {
  3148			mutex_unlock(&btrfsic_mutex);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 22744 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: use kbasename in btrfsic_mount
  2015-11-27  8:32 ` kbuild test robot
@ 2015-11-27  8:38   ` Rasmus Villemoes
  0 siblings, 0 replies; 5+ messages in thread
From: Rasmus Villemoes @ 2015-11-27  8:38 UTC (permalink / raw)
  To: kbuild test robot
  Cc: kbuild-all, Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
	linux-kernel

On Fri, Nov 27 2015, kbuild test robot <lkp@intel.com> wrote:

> Hi Rasmus,
>
> [auto build test WARNING on: v4.4-rc2]
> [also build test WARNING on: next-20151127]
>
> url:    https://github.com/0day-ci/linux/commits/Rasmus-Villemoes/btrfs-use-kbasename-in-btrfsic_mount/20151127-161249
> config: i386-randconfig-s1-201547 (attached as .config)
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=i386 
>
> All warnings (new ones prefixed by >>):
>
>    fs/btrfs/check-integrity.c: In function 'btrfsic_mount':
>>> fs/btrfs/check-integrity.c:3140:5: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
>       p = kbasename(ds->name);
>         ^
>

Baah. Ok, that's easy to fix. Sorry for not compile-testing this myself.

Rasmus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: use kbasename in btrfsic_mount
  2015-11-27  8:11 [PATCH] btrfs: use kbasename in btrfsic_mount Rasmus Villemoes
  2015-11-27  8:31 ` David Sterba
  2015-11-27  8:32 ` kbuild test robot
@ 2015-11-27  9:37 ` Andy Shevchenko
  2 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-11-27  9:37 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
	linux-kernel@vger.kernel.org

On Fri, Nov 27, 2015 at 10:11 AM, Rasmus Villemoes
<linux@rasmusvillemoes.dk> wrote:
> This is more readable.

Actually, Rasmus, a bit of offtopic here, but I would like to have
your opinion for that clean up:
http://www.spinics.net/lists/kernel/msg1411600.html



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-27  9:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-27  8:11 [PATCH] btrfs: use kbasename in btrfsic_mount Rasmus Villemoes
2015-11-27  8:31 ` David Sterba
2015-11-27  8:32 ` kbuild test robot
2015-11-27  8:38   ` Rasmus Villemoes
2015-11-27  9:37 ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.