Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1543358 > unrolled thread

[PATCH 11/13] fs: fix unsigned enum warning with gcc-4.2

Started byArnd Bergmann <arnd@arndb.de>
First post2016-12-16 12:00 +0100
Last post2017-01-03 23:50 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 11/13] fs: fix unsigned enum warning with gcc-4.2 Arnd Bergmann <arnd@arndb.de> - 2016-12-16 12:00 +0100
    Re: [PATCH 11/13] fs: fix unsigned enum warning with gcc-4.2 Brendan Gregg <brendan.d.gregg@gmail.com> - 2017-01-03 23:50 +0100

#1543358 — [PATCH 11/13] fs: fix unsigned enum warning with gcc-4.2

FromArnd Bergmann <arnd@arndb.de>
Date2016-12-16 12:00 +0100
Subject[PATCH 11/13] fs: fix unsigned enum warning with gcc-4.2
Message-ID<sOYp3-2rU-13@gated-at.bofh.it>
With arm-linux-gcc-4.2, almost every file we build in the kernel ends
up with this warning:

include/linux/fs.h:2648: warning: comparison of unsigned expression < 0 is always false

Later versions don't have this problem, but it's easy enough to
work around.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/fs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 398cf20a706d..782c2a292fd7 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2645,7 +2645,7 @@ static const char * const kernel_read_file_str[] = {
 
 static inline const char *kernel_read_file_id_str(enum kernel_read_file_id id)
 {
-	if (id < 0 || id >= READING_MAX_ID)
+	if ((unsigned)id >= READING_MAX_ID)
 		return kernel_read_file_str[READING_UNKNOWN];
 
 	return kernel_read_file_str[id];
-- 
2.9.0

[toc] | [next] | [standalone]


#1550267

FromBrendan Gregg <brendan.d.gregg@gmail.com>
Date2017-01-03 23:50 +0100
Message-ID<sVG41-4nb-31@gated-at.bofh.it>
In reply to#1543358
On Fri, Dec 16, 2016 at 2:56 AM, Arnd Bergmann <arnd@arndb.de> wrote:
>
> With arm-linux-gcc-4.2, almost every file we build in the kernel ends
> up with this warning:
>
> include/linux/fs.h:2648: warning: comparison of unsigned expression < 0 is always false
>

Thanks, I'd like to see this fixed as a similar warning gets printed
whenever running many of the bcc/BPF tools, which gets annoying and is
user-visible. eg:

# /usr/share/bcc/tools/xfsslower 1
In file included from /virtual/main.c:3:
/lib/modules/4.8.6-300.fc25.x86_64/build/include/linux/fs.h:2677:9:
warning: comparison of unsigned enum expression < 0 is always false
[-Wtautological-compare]
        if (id < 0 || id >= READING_MAX_ID)
            ~~ ^ ~
1 warning generated.
Tracing XFS operations slower than 1 ms
TIME     COMM           PID    T BYTES   OFF_KB   LAT(ms) FILENAME
14:44:27 cksum          4414   R 65536   0           1.02 chcon
14:44:27 cksum          4414   R 65536   0           1.20 cpio
14:44:27 cksum          4414   R 65536   0           1.01 diff
14:44:27 cksum          4414   R 65536   0           1.15 dir
[...]

This patch fixes the warning.

Brendan

>
> Later versions don't have this problem, but it's easy enough to
> work around.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  include/linux/fs.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 398cf20a706d..782c2a292fd7 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2645,7 +2645,7 @@ static const char * const kernel_read_file_str[] = {
>
>  static inline const char *kernel_read_file_id_str(enum kernel_read_file_id id)
>  {
> -       if (id < 0 || id >= READING_MAX_ID)
> +       if ((unsigned)id >= READING_MAX_ID)
>                 return kernel_read_file_str[READING_UNKNOWN];
>
>         return kernel_read_file_str[id];
> --
> 2.9.0
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web