Skip to contentSkip to conversation

Warnings from gcc 4.9 (on FreeBSD)

DISCUSSION Bruce Cran 2 participants 2 messages Nov 8, 2013

lore
Share & tools
lore

Bruce Cran

author
#0 lore raw

Building using gcc 4.9 (on FreeBSD 11-CURRENT) generates a few warnings about undefined behaviour:

CC cconv.o
In file included from thread_options.h:5:0,

                 from cconv.c:3:
cconv.c: In function 'convert_thread_options_to_cpu':
os/os.h:197:16: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  __le32_to_cpu(*__val);   \
                ^
os/os.h:176:28: note: in definition of macro '__le32_to_cpu'
 #define __le32_to_cpu(x)  (x)
                            ^
cconv.c:78:17: note: in expansion of macro 'le32_to_cpu'
   o->rwmix[i] = le32_to_cpu(top->rwmix[i]);
                 ^

cconv.c:63:2: note: containing loop
for (i = 0; i < DDIR_RWDIR_CNT; i++) {
^
In file included from thread_options.h:5:0,

                 from cconv.c:3:
cconv.c: In function 'convert_thread_options_to_net':
os/os.h:209:16: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  __cpu_to_le32(*__val);   \
                ^
os/os.h:179:28: note: in definition of macro '__cpu_to_le32'
 #define __cpu_to_le32(x)  (x)
                            ^
cconv.c:372:19: note: in expansion of macro 'cpu_to_le32'
   top->rwmix[i] = cpu_to_le32(o->rwmix[i]);
                   ^

cconv.c:352:2: note: containing loop
for (i = 0; i < DDIR_RWDIR_CNT; i++) {
^
In file included from thread_options.h:5:0,

                 from cconv.c:3:
cconv.c: In function 'fio_test_cconv':
os/os.h:209:16: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  __cpu_to_le32(*__val);   \
                ^
os/os.h:179:28: note: in definition of macro '__cpu_to_le32'
 #define __cpu_to_le32(x)  (x)
                            ^
cconv.c:372:19: note: in expansion of macro 'cpu_to_le32'
   top->rwmix[i] = cpu_to_le32(o->rwmix[i]);
                   ^

cconv.c:352:2: note: containing loop
for (i = 0; i < DDIR_RWDIR_CNT; i++) {
^
In file included from thread_options.h:5:0,

                 from cconv.c:3:
os/os.h:197:16: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  __le32_to_cpu(*__val);   \
                ^
os/os.h:176:28: note: in definition of macro '__le32_to_cpu'
 #define __le32_to_cpu(x)  (x)
                            ^
cconv.c:78:17: note: in expansion of macro 'le32_to_cpu'
   o->rwmix[i] = le32_to_cpu(top->rwmix[i]);
                 ^

cconv.c:63:2: note: containing loop
for (i = 0; i < DDIR_RWDIR_CNT; i++) {
^

Signature · 1 line
Bruce Cran
#1 lore raw
Quoted 17 lines · Bruce Cran

Building using gcc 4.9 (on FreeBSD 11-CURRENT) generates a few warnings about undefined behaviour:

CC cconv.o
In file included from thread_options.h:5:0,

                 from cconv.c:3:
cconv.c: In function 'convert_thread_options_to_cpu':
os/os.h:197:16: warning: iteration 2u invokes undefined behavior
[-Waggressive-loop-optimizations]
  __le32_to_cpu(*__val);   \
                ^
os/os.h:176:28: note: in definition of macro '__le32_to_cpu'
 #define __le32_to_cpu(x)  (x)
                            ^
cconv.c:78:17: note: in expansion of macro 'le32_to_cpu'
   o->rwmix[i] = le32_to_cpu(top->rwmix[i]);
                 ^
Quoted 3 lines

cconv.c:63:2: note: containing loop
for (i = 0; i < DDIR_RWDIR_CNT; i++) {
^

Wow, gcc is really outdoing itself in making warnings obtuse. The below should fix it up. We don't really use rwmix with TRIM, but lets just extend it since that basically should be supported.

server.h +1 -1
index aefd41832483..5d9b6ccadae3 100644
@@ -38,7 +38,7 @@ struct fio_net_cmd_reply {
 };
 
 enum {
-	FIO_SERVER_VER			= 25,
+	FIO_SERVER_VER			= 26,
 
 	FIO_SERVER_MAX_FRAGMENT_PDU	= 1024,
 
thread_options.h +2 -2
index 3f345c56b3ba..484b16a56e75 100644
@@ -157,7 +157,7 @@ struct thread_options {
 #endif
 	unsigned int iolog;
 	unsigned int rwmixcycle;
-	unsigned int rwmix[2];
+	unsigned int rwmix[DDIR_RWDIR_CNT];
 	unsigned int nice;
 	unsigned int ioprio;
 	unsigned int ioprio_class;
@@ -362,7 +362,7 @@ struct thread_options_pack {
 	uint32_t verify_cpumask_set;
 	uint32_t iolog;
 	uint32_t rwmixcycle;
-	uint32_t rwmix[2];
+	uint32_t rwmix[DDIR_RWDIR_CNT];
 	uint32_t nice;
 	uint32_t ioprio;
 	uint32_t ioprio_class;
Signature · 1 line
Jens Axboe