[PATCH:xserver] Fix uninitialized variable warnings reported by clang. (was Re: [PATCH:xf86-video-ati] Fix uninitialized variable warnings reported by clang.)

Thomas Klausner wiz at NetBSD.org
Tue Dec 15 02:04:51 PST 2015


Like this?
 Thomas


On Tue, Dec 15, 2015 at 05:25:49PM +0900, Michel Dänzer wrote:
> On 12.12.2015 00:46, Thomas Klausner wrote:
> > Signed-off-by: Thomas Klausner <wiz at NetBSD.org>
> > ---
> >  src/radeon_drm_queue.c | 8 ++++----
> >  src/radeon_kms.c       | 2 +-
> >  2 files changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/src/radeon_drm_queue.c b/src/radeon_drm_queue.c
> > index 5e54ef8..84d0509 100644
> > --- a/src/radeon_drm_queue.c
> > +++ b/src/radeon_drm_queue.c
> > @@ -59,7 +59,7 @@ radeon_drm_queue_handler(int fd, unsigned int frame, unsigned int sec,
> >  			 unsigned int usec, void *user_ptr)
> >  {
> >  	struct radeon_drm_queue_entry *user_data = user_ptr;
> > -	struct radeon_drm_queue_entry *e, *tmp;
> > +	struct radeon_drm_queue_entry *e = NULL, *tmp;
> >  
> >  	xorg_list_for_each_entry_safe(e, tmp, &radeon_drm_queue, list) {
> >  		if (e == user_data) {
> > @@ -119,7 +119,7 @@ radeon_drm_abort_one(struct radeon_drm_queue_entry *e)
> >  void
> >  radeon_drm_abort_client(ClientPtr client)
> >  {
> > -    struct radeon_drm_queue_entry *e, *tmp;
> > +    struct radeon_drm_queue_entry *e = NULL, *tmp;
> >  
> >      xorg_list_for_each_entry_safe(e, tmp, &radeon_drm_queue, list) {
> >  	if (e->client == client)
> > @@ -142,7 +142,7 @@ radeon_drm_abort_entry(struct radeon_drm_queue_entry *entry)
> >  void
> >  radeon_drm_abort_id(uint64_t id)
> >  {
> > -    struct radeon_drm_queue_entry *e, *tmp;
> > +    struct radeon_drm_queue_entry *e = NULL, *tmp;
> >  
> >      xorg_list_for_each_entry_safe(e, tmp, &radeon_drm_queue, list) {
> >  	if (e->id == id) {
> > @@ -170,7 +170,7 @@ radeon_drm_queue_init()
> >  void
> >  radeon_drm_queue_close(ScrnInfoPtr scrn)
> >  {
> > -    struct radeon_drm_queue_entry *e, *tmp;
> > +    struct radeon_drm_queue_entry *e = NULL, *tmp;
> >  
> >      xorg_list_for_each_entry_safe(e, tmp, &radeon_drm_queue, list) {
> >  	if (e->scrn == scrn)
> > diff --git a/src/radeon_kms.c b/src/radeon_kms.c
> > index d459740..d6d17bc 100644
> > --- a/src/radeon_kms.c
> > +++ b/src/radeon_kms.c
> > @@ -303,7 +303,7 @@ static void
> >  radeon_dirty_update(ScreenPtr screen)
> >  {
> >  	RegionPtr region;
> > -	PixmapDirtyUpdatePtr ent;
> > +	PixmapDirtyUpdatePtr ent = NULL;
> >  
> >  	if (xorg_list_is_empty(&screen->pixmap_dirty_list))
> >  		return;
> > 
> 
> NAK. This needs to be fixed in the xorg_list_for_each(_safe) macros in
> xserver's list.h.
> 
> 
> -- 
> Earthling Michel Dänzer               |               http://www.amd.com
> Libre software enthusiast             |             Mesa and X developer
> 
-------------- next part --------------
>From 7fca2f2a3ffc86ff2b9abf7cd0e4c1e624338f01 Mon Sep 17 00:00:00 2001
From: Thomas Klausner <wiz at NetBSD.org>
Date: Tue, 15 Dec 2015 11:03:39 +0100
Subject: [PATCH:xserver 3/3] Fix uninitialized variable warnings reported by
 clang.

Signed-off-by: Thomas Klausner <wiz at NetBSD.org>
---
 include/list.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/list.h b/include/list.h
index 39f1985..f41d418 100644
--- a/include/list.h
+++ b/include/list.h
@@ -317,6 +317,7 @@ xorg_list_is_empty(struct xorg_list *head)
  * See xorg_list_for_each_entry for more details.
  */
 #define xorg_list_for_each_entry_safe(pos, tmp, head, member)		\
+    pos = NULL;								\
     for (pos = __container_of((head)->next, pos, member),		\
 	 tmp = __container_of(pos->member.next, pos, member);		\
 	 &pos->member != (head);					\
-- 
2.6.4



More information about the xorg-devel mailing list