Make sure the second argument to container_of() is initialized
PATCH 1/1 Make sure the second argument to container_of() is initialized
From: Michel Dänzer <[email protected]>
Fixes warnings and miscompilation resulting in crashes with clang.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94249
--- amdgpu/amdgpu_vamgr.c | 2 +- util_double_list.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
amdgpu/amdgpu_vamgr.c +1 -1
@@ -157,7 +157,7 @@ amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size, drm_private voidamdgpu_vamgr_free_va (struct amdgpu_bo_va_mgr *mgr,uint64_t va,uint64_t size) { -struct amdgpu_bo_va_hole *hole; +struct amdgpu_bo_va_hole *hole =NULL ;if (va ==AMDGPU_INVALID_VA_ADDRESS )return ;
util_double_list.h +5 -5
@@ -114,29 +114,29 @@ static inline void list_delinit(struct list_head *item)#endif #define LIST_FOR_EACH_ENTRY (pos, head, member) \ - for (pos = container_of((head)->next, pos, member); \ + for (pos = NULL, pos = container_of((head)->next, pos, member); \ &pos->member != (head); \ pos = container_of(pos->member.next, pos, member))#define LIST_FOR_EACH_ENTRY_SAFE (pos, storage, head, member) \ - for (pos = container_of((head)->next, pos, member), \ + for (pos = NULL, pos = container_of((head)->next, pos, member), \ storage = container_of(pos->member.next, pos, member); \ &pos->member != (head); \ pos = storage, storage = container_of(storage->member.next, storage, member))#define LIST_FOR_EACH_ENTRY_SAFE_REV (pos, storage, head, member) \ - for (pos = container_of((head)->prev, pos, member), \ + for (pos = NULL, pos = container_of((head)->prev, pos, member), \ storage = container_of(pos->member.prev, pos, member); \ &pos->member != (head); \ pos = storage, storage = container_of(storage->member.prev, storage, member))#define LIST_FOR_EACH_ENTRY_FROM (pos, start, head, member) \ - for (pos = container_of((start), pos, member); \ + for (pos = NULL, pos = container_of((start), pos, member); \ &pos->member != (head); \ pos = container_of(pos->member.next, pos, member))#define LIST_FOR_EACH_ENTRY_FROM_REV (pos, start, head, member) \ - for (pos = container_of((start), pos, member); \ + for (pos = NULL, pos = container_of((start), pos, member); \ &pos->member != (head); \ pos = container_of(pos->member.prev, pos, member))
Signature · 6 lines
2.8.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
Fixes warnings and miscompilation resulting in crashes with clang.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94249
Signed-off-by Michel Dänzer <[email protected]>
Quoted 60 lines
--- amdgpu/amdgpu_vamgr.c | 2 +- util_double_list.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)amdgpu/amdgpu_vamgr.c +1
-1@@ -157,7 +157,7 @@ amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size, drm_private voidamdgpu_vamgr_free_va (struct amdgpu_bo_va_mgr *mgr,uint64_t va,uint64_t size) { -struct amdgpu_bo_va_hole *hole; +struct amdgpu_bo_va_hole *hole =NULL ;if (va ==AMDGPU_INVALID_VA_ADDRESS )return ;util_double_list.h +5
-6@@ -114,29 +114,29 @@ static inline void list_delinit(struct list_head *item)#endif #define LIST_FOR_EACH_ENTRY (pos, head, member) \ - for (pos = container_of((head)->next, pos, member); \ + for (pos = NULL, pos = container_of((head)->next, pos, member); \ &pos->member != (head); \ pos = container_of(pos->member.next, pos, member))#define LIST_FOR_EACH_ENTRY_SAFE (pos, storage, head, member) \ - for (pos = container_of((head)->next, pos, member), \ + for (pos = NULL, pos = container_of((head)->next, pos, member), \ storage = container_of(pos->member.next, pos, member); \ &pos->member != (head); \ pos = storage, storage = container_of(storage->member.next, storage, member))#define LIST_FOR_EACH_ENTRY_SAFE_REV (pos, storage, head, member) \ - for (pos = container_of((head)->prev, pos, member), \ + for (pos = NULL, pos = container_of((head)->prev, pos, member), \ storage = container_of(pos->member.prev, pos, member); \ &pos->member != (head); \ pos = storage, storage = container_of(storage->member.prev, storage, member))#define LIST_FOR_EACH_ENTRY_FROM (pos, start, head, member) \ - for (pos = container_of((start), pos, member); \ + for (pos = NULL, pos = container_of((start), pos, member); \ &pos->member != (head); \ pos = container_of(pos->member.next, pos, member))#define LIST_FOR_EACH_ENTRY_FROM_REV (pos, start, head, member) \ - for (pos = container_of((start), pos, member); \ + for (pos = NULL, pos = container_of((start), pos, member); \ &pos->member != (head); \ pos = container_of(pos->member.prev, pos, member)) --2.8.1
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 3 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
Fixes warnings and miscompilation resulting in crashes with clang.
How annoying. Seems like this would affect most (current and future) uses of container_of, and so it would be better to switch to the Linux kernel version of container_of, where the second parameter is the type...
Cheers,
Nicolai
Quoted 51 lines
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94249
Signed-off-by Michel Dänzer <[email protected]>--- amdgpu/amdgpu_vamgr.c | 2 +- util_double_list.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)amdgpu/amdgpu_vamgr.c +1
-1@@ -157,7 +157,7 @@ amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size, drm_private voidamdgpu_vamgr_free_va (struct amdgpu_bo_va_mgr *mgr,uint64_t va,uint64_t size) { -struct amdgpu_bo_va_hole *hole; +struct amdgpu_bo_va_hole *hole =NULL ;if (va ==AMDGPU_INVALID_VA_ADDRESS )return ;util_double_list.h +3
-4@@ -114,29 +114,29 @@ static inline void list_delinit(struct list_head *item)#endif #define LIST_FOR_EACH_ENTRY (pos, head, member) \ - for (pos = container_of((head)->next, pos, member); \ + for (pos = NULL, pos = container_of((head)->next, pos, member); \ &pos->member != (head); \ pos = container_of(pos->member.next, pos, member))#define LIST_FOR_EACH_ENTRY_SAFE (pos, storage, head, member) \ - for (pos = container_of((head)->next, pos, member), \ + for (pos = NULL, pos = container_of((head)->next, pos, member), \ storage = container_of(pos->member.next, pos, member); \ &pos->member != (head); \ pos = storage, storage = container_of(storage->member.next, storage, member))#define LIST_FOR_EACH_ENTRY_SAFE_REV (pos, storage, head, member) \ - for (pos = container_of((head)->prev, pos, member), \ + for (pos = NULL, pos = container_of((head)->prev, pos, member), \ storage = container_of(pos->member.prev, pos, member); \ &pos->member != (head); \ pos = storage, storage = container_of(storage->member.prev, storage, member))#define LIST_FOR_EACH_ENTRY_FROM (pos, start, head, member) \ - for (pos = container_of((start), pos, member); \
util_double_list.h static inline void list_delinit(struct list_head *item) · line 142
Quoted 10 lines
util_double_list.h +2
-1+for (pos =NULL , pos =container_of ((start), pos, member); \ &pos->member != (head); \ pos = container_of(pos->member.next, pos, member))#define LIST_FOR_EACH_ENTRY_FROM_REV (pos, start, head, member) \ - for (pos = container_of((start), pos, member); \ + for (pos = NULL, pos = container_of((start), pos, member); \ &pos->member != (head); \ pos = container_of(pos->member.prev, pos, member))
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines · Nicolai Hähnle
Quoted 3 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
Fixes warnings and miscompilation resulting in crashes with clang.
How annoying. Seems like this would affect most (current and future) uses of
container_of, and so it would be better to switch to the Linux kernel version ofcontainer_of, where the second parameter is the type...
Rob proposed http://hastebin.com/vefenavoje.coffee on IRC, using typeof(). I'm fine with going for that instead of my patch, just FYI: My patch was based on xserver's list.h, which works with compilers which don't support typeof(). Not sure that's relevant for libdrm though.
Signature · 7 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Michel Dänzer
Quoted 5 lines · Nicolai Hähnle
Quoted 3 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
Fixes warnings and miscompilation resulting in crashes with clang.
Quoted 8 lines
Quoted 3 lines
How annoying. Seems like this would affect most (current and future) uses of
container_of, and so it would be better to switch to the Linux kernel version ofcontainer_of, where the second parameter is the type...Rob proposed http://hastebin.com/vefenavoje.coffee on IRC, using
typeof(). I'm fine with going for that instead of my patch, just FYI: My patch was based on xserver'slist.h, which works with compilers which don't supporttypeof(). Not sure that's relevant for libdrm though.
Actually I already went ahead and pushed that patch too. Although there may be other list implementations that need the same thing.
BR,
-R
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel