Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH 0/5] Cleanup warnings from clang
@ 2014-12-19  6:13 Qu Wenruo
  2014-12-19  6:13 ` [PATCH 1/5] btrfs-progs: Makefile: Move linker only option to LDFLAGS Qu Wenruo
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Qu Wenruo @ 2014-12-19  6:13 UTC (permalink / raw)
  To: linux-btrfs

Cleanup warning when compile btrfs-progs with clang.

Clang analyser also reports about 60+ errors, but it will be another
patchset fixing it later.

Qu Wenruo (5):
  btrfs-progs: Makefile: Move linker only option to LDFLAGS
  btrfs-progs: Fix a clang dead-judgement warning in disk-io.c.
  btrfs-progs: Remove a unused function root_gtp_mask().
  btrfs-progs: Remove a unused function offset_to_bitmap()
  btrfs-progs: Remove deprecated _BSD_SOURCE macro.

 Makefile           |  3 ++-
 cmds-receive.c     |  2 +-
 disk-io.c          |  9 ++++++---
 free-space-cache.c | 16 ----------------
 radix-tree.c       |  5 -----
 5 files changed, 9 insertions(+), 26 deletions(-)

-- 
2.1.3


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

* [PATCH 1/5] btrfs-progs: Makefile: Move linker only option to LDFLAGS
  2014-12-19  6:13 [PATCH 0/5] Cleanup warnings from clang Qu Wenruo
@ 2014-12-19  6:13 ` Qu Wenruo
  2014-12-19  6:13 ` [PATCH 2/5] btrfs-progs: Fix a clang dead-judgement warning in disk-io.c Qu Wenruo
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Qu Wenruo @ 2014-12-19  6:13 UTC (permalink / raw)
  To: linux-btrfs

Move the linker only option -rdynamic to LDFLAGS.
This resolve lots of the following warning if using clang as CC:
clang: warning: argument unused during compilation: '-rdynamic'

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index e1b0a88..be0f48b 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,8 @@ CC = gcc
 LN = ln
 AR = ar
 AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -DBTRFS_FLAT_INCLUDES -fno-strict-aliasing -fPIC
-CFLAGS = -g -O1 -fno-strict-aliasing -rdynamic
+CFLAGS = -g -O1 -fno-strict-aliasing
+LDFLAGS = -rdynamic
 objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
 	  root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \
 	  extent-cache.o extent_io.o volumes.o utils.o repair.o \
-- 
2.1.3


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

* [PATCH 2/5] btrfs-progs: Fix a clang dead-judgement warning in disk-io.c.
  2014-12-19  6:13 [PATCH 0/5] Cleanup warnings from clang Qu Wenruo
  2014-12-19  6:13 ` [PATCH 1/5] btrfs-progs: Makefile: Move linker only option to LDFLAGS Qu Wenruo
@ 2014-12-19  6:13 ` Qu Wenruo
  2014-12-19  6:13 ` [PATCH 3/5] btrfs-progs: Remove a unused function root_gtp_mask() Qu Wenruo
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Qu Wenruo @ 2014-12-19  6:13 UTC (permalink / raw)
  To: linux-btrfs

When compiled with clang, the following warning is outputted.

disk-io.c:1017:15: warning: comparison of unsigned expression < 0 is
always false [-Wtautological-compare]
        if (dev_size < 0)
            ~~~~~~~~ ^ ~
1 warning generated.

This is because dev_size is defined as unsigned type, but lseek() will
return singed valued.
So the judgement will always to false.

Use temporary off_t return value to solve it.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 disk-io.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/disk-io.c b/disk-io.c
index 03edf8e..2bf8586 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1009,13 +1009,16 @@ int btrfs_scan_fs_devices(int fd, const char *path,
 {
 	u64 total_devs;
 	u64 dev_size;
+	off_t seek_ret;
 	int ret;
 	if (!sb_bytenr)
 		sb_bytenr = BTRFS_SUPER_INFO_OFFSET;
 
-	dev_size = lseek(fd, 0, SEEK_END);
-	if (dev_size < 0)
-		return (int)(dev_size);
+	seek_ret = lseek(fd, 0, SEEK_END);
+	if (seek_ret < 0)
+		return -errno;
+
+	dev_size = seek_ret;
 	lseek(fd, 0, SEEK_SET);
 	if (sb_bytenr > dev_size) {
 		fprintf(stderr, "Superblock bytenr is larger than device size\n");
-- 
2.1.3


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

* [PATCH 3/5] btrfs-progs: Remove a unused function root_gtp_mask().
  2014-12-19  6:13 [PATCH 0/5] Cleanup warnings from clang Qu Wenruo
  2014-12-19  6:13 ` [PATCH 1/5] btrfs-progs: Makefile: Move linker only option to LDFLAGS Qu Wenruo
  2014-12-19  6:13 ` [PATCH 2/5] btrfs-progs: Fix a clang dead-judgement warning in disk-io.c Qu Wenruo
@ 2014-12-19  6:13 ` Qu Wenruo
  2014-12-19  6:13 ` [PATCH 4/5] btrfs-progs: Remove a unused function offset_to_bitmap() Qu Wenruo
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Qu Wenruo @ 2014-12-19  6:13 UTC (permalink / raw)
  To: linux-btrfs

Fix the following clang warning when compiling btrfs-progs:

radix-tree.c:78:21: warning: unused function 'root_gfp_mask'
[-Wunused-function]
static inline gfp_t root_gfp_mask(struct radix_tree_root *root)
                    ^
1 warning generated.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 radix-tree.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/radix-tree.c b/radix-tree.c
index 7457944..f259ab5 100644
--- a/radix-tree.c
+++ b/radix-tree.c
@@ -75,11 +75,6 @@ struct radix_tree_preload {
 };
 static struct radix_tree_preload radix_tree_preloads = { 0, };
 
-static inline gfp_t root_gfp_mask(struct radix_tree_root *root)
-{
-	return root->gfp_mask & __GFP_BITS_MASK;
-}
-
 static int internal_nodes = 0;
 /*
  * This assumes that the caller has performed appropriate preallocation, and
-- 
2.1.3


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

* [PATCH 4/5] btrfs-progs: Remove a unused function offset_to_bitmap()
  2014-12-19  6:13 [PATCH 0/5] Cleanup warnings from clang Qu Wenruo
                   ` (2 preceding siblings ...)
  2014-12-19  6:13 ` [PATCH 3/5] btrfs-progs: Remove a unused function root_gtp_mask() Qu Wenruo
@ 2014-12-19  6:13 ` Qu Wenruo
  2014-12-19  6:13 ` [PATCH 5/5] btrfs-progs: Remove deprecated _BSD_SOURCE macro Qu Wenruo
  2014-12-19  9:27 ` [PATCH 0/5] Cleanup warnings from clang Satoru Takeuchi
  5 siblings, 0 replies; 9+ messages in thread
From: Qu Wenruo @ 2014-12-19  6:13 UTC (permalink / raw)
  To: linux-btrfs

Fix the following clang warning:

free-space-cache.c:464:19: warning: unused function 'offset_to_bitmap'
[-Wunused-function]
static inline u64 offset_to_bitmap(struct btrfs_free_space_ctl *ctl,
                  ^
1 warning generated.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 free-space-cache.c | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/free-space-cache.c b/free-space-cache.c
index 220449e..99ad420 100644
--- a/free-space-cache.c
+++ b/free-space-cache.c
@@ -461,22 +461,6 @@ static inline unsigned long bytes_to_bits(u64 bytes, u32 unit)
 	return (unsigned long)(bytes / unit);
 }
 
-static inline u64 offset_to_bitmap(struct btrfs_free_space_ctl *ctl,
-				   u64 offset)
-{
-	u64 bitmap_start;
-	u64 bytes_per_bitmap;
-	u32 sectorsize = ctl->sectorsize;
-
-	bytes_per_bitmap = BITS_PER_BITMAP(sectorsize) * ctl->unit;
-	bitmap_start = offset - ctl->start;
-	bitmap_start = bitmap_start / bytes_per_bitmap;
-	bitmap_start *= bytes_per_bitmap;
-	bitmap_start += ctl->start;
-
-	return bitmap_start;
-}
-
 static int tree_insert_offset(struct rb_root *root, u64 offset,
 			      struct rb_node *node, int bitmap)
 {
-- 
2.1.3


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

* [PATCH 5/5] btrfs-progs: Remove deprecated _BSD_SOURCE macro.
  2014-12-19  6:13 [PATCH 0/5] Cleanup warnings from clang Qu Wenruo
                   ` (3 preceding siblings ...)
  2014-12-19  6:13 ` [PATCH 4/5] btrfs-progs: Remove a unused function offset_to_bitmap() Qu Wenruo
@ 2014-12-19  6:13 ` Qu Wenruo
  2014-12-19 13:52   ` David Sterba
  2014-12-19  9:27 ` [PATCH 0/5] Cleanup warnings from clang Satoru Takeuchi
  5 siblings, 1 reply; 9+ messages in thread
From: Qu Wenruo @ 2014-12-19  6:13 UTC (permalink / raw)
  To: linux-btrfs

Fix the following gcc(>4.9) and clang warning:

In file included from cmds-receive.c:24:
In file included from ./kerncompat.h:22:
In file included from /usr/include/stdio.h:27:
/usr/include/features.h:148:3: warning: "_BSD_SOURCE and _SVID_SOURCE
are deprecated, use _DEFAULT_SOURCE" [-W#warnings]
  ^
1 warning generated.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 cmds-receive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmds-receive.c b/cmds-receive.c
index 358df1f..5bc8f8c 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -19,7 +19,7 @@
 #define _GNU_SOURCE
 #define _POSIX_C_SOURCE 200809
 #define _XOPEN_SOURCE 700
-#define _BSD_SOURCE
+#define _DEFAILT_SOURCE
 
 #include "kerncompat.h"
 
-- 
2.1.3


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

* Re: [PATCH 0/5] Cleanup warnings from clang
  2014-12-19  6:13 [PATCH 0/5] Cleanup warnings from clang Qu Wenruo
                   ` (4 preceding siblings ...)
  2014-12-19  6:13 ` [PATCH 5/5] btrfs-progs: Remove deprecated _BSD_SOURCE macro Qu Wenruo
@ 2014-12-19  9:27 ` Satoru Takeuchi
  2014-12-19 14:05   ` David Sterba
  5 siblings, 1 reply; 9+ messages in thread
From: Satoru Takeuchi @ 2014-12-19  9:27 UTC (permalink / raw)
  To: Qu Wenruo, linux-btrfs

Hi,

On 2014/12/19 15:13, Qu Wenruo wrote:
> Cleanup warning when compile btrfs-progs with clang.
> 
> Clang analyser also reports about 60+ errors, but it will be another
> patchset fixing it later.
> 
> Qu Wenruo (5):
>    btrfs-progs: Makefile: Move linker only option to LDFLAGS
>    btrfs-progs: Fix a clang dead-judgement warning in disk-io.c.
>    btrfs-progs: Remove a unused function root_gtp_mask().
>    btrfs-progs: Remove a unused function offset_to_bitmap()
>    btrfs-progs: Remove deprecated _BSD_SOURCE macro.

All these patches looks good to me.

Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>

Thanks,
Satoru

> 
>   Makefile           |  3 ++-
>   cmds-receive.c     |  2 +-
>   disk-io.c          |  9 ++++++---
>   free-space-cache.c | 16 ----------------
>   radix-tree.c       |  5 -----
>   5 files changed, 9 insertions(+), 26 deletions(-)
> 


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

* Re: [PATCH 5/5] btrfs-progs: Remove deprecated _BSD_SOURCE macro.
  2014-12-19  6:13 ` [PATCH 5/5] btrfs-progs: Remove deprecated _BSD_SOURCE macro Qu Wenruo
@ 2014-12-19 13:52   ` David Sterba
  0 siblings, 0 replies; 9+ messages in thread
From: David Sterba @ 2014-12-19 13:52 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On Fri, Dec 19, 2014 at 02:13:12PM +0800, Qu Wenruo wrote:
> -#define _BSD_SOURCE
> +#define _DEFAILT_SOURCE

_DEFAULT_SOURCE, I'll fix that.

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

* Re: [PATCH 0/5] Cleanup warnings from clang
  2014-12-19  9:27 ` [PATCH 0/5] Cleanup warnings from clang Satoru Takeuchi
@ 2014-12-19 14:05   ` David Sterba
  0 siblings, 0 replies; 9+ messages in thread
From: David Sterba @ 2014-12-19 14:05 UTC (permalink / raw)
  To: Satoru Takeuchi; +Cc: Qu Wenruo, linux-btrfs

On Fri, Dec 19, 2014 at 06:27:36PM +0900, Satoru Takeuchi wrote:
> > Qu Wenruo (5):
> >    btrfs-progs: Makefile: Move linker only option to LDFLAGS
> >    btrfs-progs: Fix a clang dead-judgement warning in disk-io.c.
> >    btrfs-progs: Remove a unused function root_gtp_mask().
> >    btrfs-progs: Remove a unused function offset_to_bitmap()
> >    btrfs-progs: Remove deprecated _BSD_SOURCE macro.
> 
> All these patches looks good to me.
> 
> Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>

All added.

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

end of thread, other threads:[~2014-12-19 14:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-19  6:13 [PATCH 0/5] Cleanup warnings from clang Qu Wenruo
2014-12-19  6:13 ` [PATCH 1/5] btrfs-progs: Makefile: Move linker only option to LDFLAGS Qu Wenruo
2014-12-19  6:13 ` [PATCH 2/5] btrfs-progs: Fix a clang dead-judgement warning in disk-io.c Qu Wenruo
2014-12-19  6:13 ` [PATCH 3/5] btrfs-progs: Remove a unused function root_gtp_mask() Qu Wenruo
2014-12-19  6:13 ` [PATCH 4/5] btrfs-progs: Remove a unused function offset_to_bitmap() Qu Wenruo
2014-12-19  6:13 ` [PATCH 5/5] btrfs-progs: Remove deprecated _BSD_SOURCE macro Qu Wenruo
2014-12-19 13:52   ` David Sterba
2014-12-19  9:27 ` [PATCH 0/5] Cleanup warnings from clang Satoru Takeuchi
2014-12-19 14:05   ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox