All of lore.kernel.org
 help / color / mirror / Atom feed
* [MDADM PATCH 0/2] Fix some building errors
@ 2017-03-01  6:12 Xiao Ni
  2017-03-01  6:12 ` [MDADM PATCH 1/2] Add Wimplicit-fallthrough=0 in Makefile Xiao Ni
  2017-03-01  6:12 ` [MDADM PATCH 2/2] Specify suitable size when write to buffer Xiao Ni
  0 siblings, 2 replies; 5+ messages in thread
From: Xiao Ni @ 2017-03-01  6:12 UTC (permalink / raw)
  To: linux-raid; +Cc: Jes.Sorensen, ncroxon

Hi Jes

There are some error buildings in Fedora release 26 (Rawhide)
The gcc version is gcc (GCC) 7.0.1 20170211 (Red Hat 7.0.1-0.8)

There are three types of errors:
1. Fall through 
mdadm.c:149:28: error: this statement may fall through [-Werror=implicit-fallthrough=]
    if (mode == ASSEMBLE || mode == BUILD ||
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        mode == CREATE || mode == GROW ||
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        mode == INCREMENTAL || mode == MANAGE)
        ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
mdadm.c:151:3: note: here
   case Brief:
   ^~~~
2. format-overflow
Detail.c: In function ‘Detail’:
Detail.c:584:31: error: ‘%s’ directive writing up to 255 bytes into a region of size 189 [-Werror=format-overflow=]
     sprintf(path, "/sys/block/%s/md/metadata_version",
                               ^~
Detail.c:584:5: note: ‘sprintf’ output between 32 and 287 bytes into a destination of size 200
     sprintf(path, "/sys/block/%s/md/metadata_version",
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      de->d_name);
      ~~~~~~~~~~~
3. format-truncation
super-intel.c: In function ‘examine_super_imsm’:
super-intel.c:1815:30: error: ‘%s’ directive output may be truncated writing up to 31 bytes into a region of size 24 [-Werror=format-truncation=]
  snprintf(str, MPB_SIG_LEN, "%s", mpb->sig);
                              ^~
super-intel.c:1815:2: note: ‘snprintf’ output between 1 and 32 bytes into a destination of size 24
  snprintf(str, MPB_SIG_LEN, "%s", mpb->sig);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Xiao Ni (2):
  Add Wimplicit-fallthrough=0 in Makefile
  Specify suitable size when write to buffer

 Detail.c      | 2 +-
 Makefile      | 2 +-
 super-intel.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.7.4


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

* [MDADM PATCH 1/2] Add Wimplicit-fallthrough=0 in Makefile
  2017-03-01  6:12 [MDADM PATCH 0/2] Fix some building errors Xiao Ni
@ 2017-03-01  6:12 ` Xiao Ni
  2017-03-06 20:30   ` jes.sorensen
  2017-03-01  6:12 ` [MDADM PATCH 2/2] Specify suitable size when write to buffer Xiao Ni
  1 sibling, 1 reply; 5+ messages in thread
From: Xiao Ni @ 2017-03-01  6:12 UTC (permalink / raw)
  To: linux-raid; +Cc: Jes.Sorensen, ncroxon

There are many errors like 'error: this statement may fall through'. 
But the logic is right. So add the flag Wimplicit-fallthrough=0 
to disable the error messages. The method I use is from 
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
#index-Wimplicit-fallthrough-375
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index a6f464c..b9f52e0 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,7 @@ KLIBC_GCC = gcc -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIB
 
 CC ?= $(CROSS_COMPILE)gcc
 CXFLAGS ?= -ggdb
-CWFLAGS = -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter
+CWFLAGS = -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter -Wimplicit-fallthrough=0
 ifdef WARN_UNUSED
 CWFLAGS += -Wp,-D_FORTIFY_SOURCE=2 -O3
 endif
-- 
2.7.4


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

* [MDADM PATCH 2/2] Specify suitable size when write to buffer
  2017-03-01  6:12 [MDADM PATCH 0/2] Fix some building errors Xiao Ni
  2017-03-01  6:12 ` [MDADM PATCH 1/2] Add Wimplicit-fallthrough=0 in Makefile Xiao Ni
@ 2017-03-01  6:12 ` Xiao Ni
  2017-03-06 21:21   ` jes.sorensen
  1 sibling, 1 reply; 5+ messages in thread
From: Xiao Ni @ 2017-03-01  6:12 UTC (permalink / raw)
  To: linux-raid; +Cc: Jes.Sorensen, ncroxon

---
 Detail.c      | 2 +-
 super-intel.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Detail.c b/Detail.c
index 509b0d4..f4d4241 100644
--- a/Detail.c
+++ b/Detail.c
@@ -575,7 +575,7 @@ This is pretty boring
 			printf("  Member Arrays :");
 
 			while (dir && (de = readdir(dir)) != NULL) {
-				char path[200];
+				char path[320];
 				char vbuf[1024];
 				int nlen = strlen(sra->sys_name);
 				dev_t devid;
diff --git a/super-intel.c b/super-intel.c
index d5e9517..ea50265 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -1811,7 +1811,7 @@ static void examine_super_imsm(struct supertype *st, char *homehost)
 	__u32 reserved = imsm_reserved_sectors(super, super->disks);
 	struct dl *dl;
 
-	snprintf(str, MPB_SIG_LEN, "%s", mpb->sig);
+	snprintf(str, MAX_SIGNATURE_LENGTH, "%s", mpb->sig);
 	printf("          Magic : %s\n", str);
 	snprintf(str, strlen(MPB_VERSION_RAID0), "%s", get_imsm_version(mpb));
 	printf("        Version : %s\n", get_imsm_version(mpb));
-- 
2.7.4


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

* Re: [MDADM PATCH 1/2] Add Wimplicit-fallthrough=0 in Makefile
  2017-03-01  6:12 ` [MDADM PATCH 1/2] Add Wimplicit-fallthrough=0 in Makefile Xiao Ni
@ 2017-03-06 20:30   ` jes.sorensen
  0 siblings, 0 replies; 5+ messages in thread
From: jes.sorensen @ 2017-03-06 20:30 UTC (permalink / raw)
  To: Xiao Ni; +Cc: linux-raid, ncroxon

Xiao Ni <xni@redhat.com> writes:
> There are many errors like 'error: this statement may fall through'. 
> But the logic is right. So add the flag Wimplicit-fallthrough=0 
> to disable the error messages. The method I use is from 
> https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
> #index-Wimplicit-fallthrough-375
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index a6f464c..b9f52e0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -43,7 +43,7 @@ KLIBC_GCC = gcc -nostdinc -iwithprefix include
> -I$(KLIBC)/klibc/include -I$(KLIB
>  
>  CC ?= $(CROSS_COMPILE)gcc
>  CXFLAGS ?= -ggdb
> -CWFLAGS = -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter
> +CWFLAGS = -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter -Wimplicit-fallthrough=0

Hi Xiao,

I am not sure how long -Wimplicit-fallthrough has existed. I want to
make sure we allow for this to compile with older compilers as well.

Could you please make it a check so this flag is only set if the version
of gcc supports it?

Thanks,
Jes



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

* Re: [MDADM PATCH 2/2] Specify suitable size when write to buffer
  2017-03-01  6:12 ` [MDADM PATCH 2/2] Specify suitable size when write to buffer Xiao Ni
@ 2017-03-06 21:21   ` jes.sorensen
  0 siblings, 0 replies; 5+ messages in thread
From: jes.sorensen @ 2017-03-06 21:21 UTC (permalink / raw)
  To: Xiao Ni; +Cc: linux-raid, ncroxon

Xiao Ni <xni@redhat.com> writes:
> ---
>  Detail.c      | 2 +-
>  super-intel.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Detail.c b/Detail.c
> index 509b0d4..f4d4241 100644
> --- a/Detail.c
> +++ b/Detail.c
> @@ -575,7 +575,7 @@ This is pretty boring
>  			printf("  Member Arrays :");
>  
>  			while (dir && (de = readdir(dir)) != NULL) {
> -				char path[200];
> +				char path[320];
>  				char vbuf[1024];
>  				int nlen = strlen(sra->sys_name);
>  				dev_t devid;
> diff --git a/super-intel.c b/super-intel.c
> index d5e9517..ea50265 100644
> --- a/super-intel.c
> +++ b/super-intel.c
> @@ -1811,7 +1811,7 @@ static void examine_super_imsm(struct supertype *st, char *homehost)
>  	__u32 reserved = imsm_reserved_sectors(super, super->disks);
>  	struct dl *dl;
>  
> -	snprintf(str, MPB_SIG_LEN, "%s", mpb->sig);
> +	snprintf(str, MAX_SIGNATURE_LENGTH, "%s", mpb->sig);
>  	printf("          Magic : %s\n", str);
>  	snprintf(str, strlen(MPB_VERSION_RAID0), "%s", get_imsm_version(mpb));
>  	printf("        Version : %s\n", get_imsm_version(mpb));

Hi Xiao,

This is really two independent changes, so they should come in two
seperate patches. All the patches needs their own commit messages and
signed-off-by lines.

Thanks,
Jes

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

end of thread, other threads:[~2017-03-06 21:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-01  6:12 [MDADM PATCH 0/2] Fix some building errors Xiao Ni
2017-03-01  6:12 ` [MDADM PATCH 1/2] Add Wimplicit-fallthrough=0 in Makefile Xiao Ni
2017-03-06 20:30   ` jes.sorensen
2017-03-01  6:12 ` [MDADM PATCH 2/2] Specify suitable size when write to buffer Xiao Ni
2017-03-06 21:21   ` jes.sorensen

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.