Skip to contentSkip to conversation

lib/igt_aux.h: Cast is confusing old gcc

PATCH In review Rodrigo Vivi 2 participants 2 messages Nov 29, 2016 – Nov 30, 2016 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/igt_aux.h: Cast is confusing old gcc

I noticed in some machines igt compilation was breaking after igt_dummyload was introduced.

I don't know exactly why, but it seems this cast seems to let old gcc a bit confused. Without the cast everything works properly.

Compilation Error log:
CC igt_dummyload.lo
In file included from igt.h:30:0,
from igt_dummyload.c:25:
igt_aux.h:288:39: error: initializer element is not constant

 #define __IGT_INIT_LIST(name) (struct igt_list){ &(name), &(name) }
                                       ^
igt_aux.h:289:47: note: in expansion of macro ‘__IGT_INIT_LIST’
 #define IGT_LIST(name) struct igt_list name = __IGT_INIT_LIST(name);
                                               ^
igt_dummyload.c:50:8: note: in expansion of macro ‘IGT_LIST’
 static IGT_LIST(spin_list);
        ^

make[4]: *** [igt_dummyload.lo] Error 1

Cc Abdiel Janulgue <[email protected]>
---
 lib/igt_aux.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/igt_aux.h +1 -1
index 177bd1d..6989448 100644
@@ -285,7 +285,7 @@ struct igt_list {
 	struct igt_list *next;
 };
 
-#define __IGT_INIT_LIST(name) (struct igt_list){ &(name), &(name) }
+#define __IGT_INIT_LIST(name) { &(name), &(name) }
 #define IGT_LIST(name) struct igt_list name = __IGT_INIT_LIST(name);
 
 static inline void igt_list_init(struct igt_list *list)
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Rodrigo Vivi

I noticed in some machines igt compilation was breaking after igt_dummyload was introduced.

I don't know exactly why, but it seems this cast seems to let old gcc a bit confused. Without the cast everything works properly.

Thanks, this is how kernel's LIST_HEAD_INIT looks like anyway

Quoted 28 lines

Compilation Error log:
CC igt_dummyload.lo
In file included from igt.h:30:0,
from igt_dummyload.c:25:
igt_aux.h:288:39: error: initializer element is not constant

 #define __IGT_INIT_LIST(name) (struct igt_list){ &(name), &(name) }
                                       ^
igt_aux.h:289:47: note: in expansion of macro ‘__IGT_INIT_LIST’
 #define IGT_LIST(name) struct igt_list name = __IGT_INIT_LIST(name);
                                               ^
igt_dummyload.c:50:8: note: in expansion of macro ‘IGT_LIST’
 static IGT_LIST(spin_list);
        ^

make[4]: *** [igt_dummyload.lo] Error 1

Cc Abdiel Janulgue <[email protected]>
---
 lib/igt_aux.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/igt_aux.h +0 -0
index 177bd1d..6989448 100644

lib/igt_aux.h struct igt_list { · line 291

Quoted 8 lines
lib/igt_aux.h +1 -1
@@ -285,7 +285,7 @@ struct igt_list {
 	struct igt_list *next;
 };
 
-#define __IGT_INIT_LIST(name) (struct igt_list){ &(name), &(name) }
+#define __IGT_INIT_LIST(name) { &(name), &(name) }
 #define IGT_LIST(name) struct igt_list name = __IGT_INIT_LIST(name);
 
 static inline void igt_list_init(struct igt_list *list)

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx