diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2019-05-16 20:53:42 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2019-05-18 06:42:03 -0400 |
commit | 1f0e3238352a497a59a36e0b8a5b4723c634b2e1 (patch) | |
tree | d49a598905cf10e28ff7d21a627e2f90a6e79ada /src/Display.c | |
parent | fb78a7c881adbe46f1f8c6e8e429bc8963c9b3e8 (diff) |
fix most clang --analyze warnings about null-pointers
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
Diffstat (limited to 'src/Display.c')
-rw-r--r-- | src/Display.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/Display.c b/src/Display.c index 459bce7..e4cf87d 100644 --- a/src/Display.c +++ b/src/Display.c @@ -555,6 +555,7 @@ PerDisplayTablePtr _XtperDisplayList = NULL; XtPerDisplay _XtSortPerDisplayList(Display *dpy) { register PerDisplayTablePtr pd, opd = NULL; + XtPerDisplay result = NULL; LOCK_PROCESS; for (pd = _XtperDisplayList; @@ -567,17 +568,18 @@ XtPerDisplay _XtSortPerDisplayList(Display *dpy) XtErrorMsg(XtNnoPerDisplay, "getPerDisplay", XtCXtToolkitError, "Couldn't find per display information", NULL, NULL); - } - - if (pd != _XtperDisplayList) { /* move it to the front */ - /* opd points to the previous one... */ + } else { + if (pd != _XtperDisplayList) { /* move it to the front */ + /* opd points to the previous one... */ - opd->next = pd->next; - pd->next = _XtperDisplayList; - _XtperDisplayList = pd; + opd->next = pd->next; + pd->next = _XtperDisplayList; + _XtperDisplayList = pd; + } + result = &(pd->perDpy); } UNLOCK_PROCESS; - return &(pd->perDpy); + return result; } XtAppContext XtDisplayToApplicationContext(Display *dpy) @@ -590,7 +592,7 @@ XtAppContext XtDisplayToApplicationContext(Display *dpy) static void CloseDisplay(Display *dpy) { - register XtPerDisplay xtpd; + register XtPerDisplay xtpd = NULL; register PerDisplayTablePtr pd, opd = NULL; XrmDatabase db; @@ -607,12 +609,13 @@ static void CloseDisplay(Display *dpy) XtErrorMsg(XtNnoPerDisplay, "closeDisplay", XtCXtToolkitError, "Couldn't find per display information", NULL, NULL); - } + } else { - if (pd == _XtperDisplayList) _XtperDisplayList = pd->next; - else opd->next = pd->next; + if (pd == _XtperDisplayList) _XtperDisplayList = pd->next; + else opd->next = pd->next; - xtpd = &(pd->perDpy); + xtpd = &(pd->perDpy); + } if (xtpd != NULL) { int i; |