From 5e2e760d3a7b6a671f21169bf5220f482eb2c17d Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 29 Jun 2016 13:10:08 +0200 Subject: Avoid 'siAddr' maybe being used uninitialized in XAddHost and XRemoveHost. Backported from X.org (libX11). Host.c has mainly been copied over from libX11, contaning 7db7451 as the top commit (which also contains the greatest change and silences the resp. compiler warning. commit 7db74514e454d3fc4ff70aa08ddac66bfffda4dd Author: Alan Coopersmith Date: Tue Jul 23 22:18:46 2013 -0700 Refactor common code from XAddHost & XRemoveHost into single function On the Xlib side, the only real difference is the mode flag we send to the server with the address, so just make that an argument to the function with the common code for packing the address into the request. (Aside from labels, gcc 4.7.2 generates identical code before & after this change due to inlining, verified via diff of gcc -S output.) Signed-off-by: Alan Coopersmith --- nx-X11/lib/X11/Host.c | 73 ++++++++++++++++++--------------------------------- 1 file changed, 26 insertions(+), 47 deletions(-) (limited to 'nx-X11/lib') diff --git a/nx-X11/lib/X11/Host.c b/nx-X11/lib/X11/Host.c index 58e9e4a1c..5fcb687cc 100644 --- a/nx-X11/lib/X11/Host.c +++ b/nx-X11/lib/X11/Host.c @@ -44,31 +44,31 @@ X Window System is a trademark of The Open Group. #endif #include "Xlibint.h" -int -XAddHost ( - register Display *dpy, - XHostAddress *host) +static inline int +changehost (Display *dpy, XHostAddress *host, BYTE mode) { - register xChangeHostsReq *req; - register int length; + xChangeHostsReq *req; + int length; XServerInterpretedAddress *siAddr; int addrlen; - - if (host->family == FamilyServerInterpreted) { - siAddr = (XServerInterpretedAddress *) host->address; - addrlen = siAddr->typelength + siAddr->valuelength + 1; - } else { - addrlen = host->length; - } - length = (addrlen + 3) & ~0x3; /* round up */ - + siAddr = host->family == FamilyServerInterpreted ? + (XServerInterpretedAddress *)host->address : NULL; + addrlen = siAddr ? + siAddr->typelength + siAddr->valuelength + 1 : host->length; + + length = (addrlen + 3) & ~0x3; /* round up */ + LockDisplay(dpy); GetReqExtra (ChangeHosts, length, req); - req->mode = HostInsert; + if (!req) { + UnlockDisplay(dpy); + return 0; + } + req->mode = mode; req->hostFamily = host->family; req->hostLength = addrlen; - if (host->family == FamilyServerInterpreted) { + if (siAddr) { char *dest = (char *) NEXTPTR(req,xChangeHostsReq); memcpy(dest, siAddr->type, siAddr->typelength); dest[siAddr->typelength] = '\0'; @@ -82,40 +82,19 @@ XAddHost ( } int -XRemoveHost ( +XAddHost ( register Display *dpy, XHostAddress *host) { - register xChangeHostsReq *req; - register int length; - XServerInterpretedAddress *siAddr; - int addrlen; - - if (host->family == FamilyServerInterpreted) { - siAddr = (XServerInterpretedAddress *) host->address; - addrlen = siAddr->typelength + siAddr->valuelength + 1; - } else { - addrlen = host->length; - } - - length = (addrlen + 3) & ~0x3; /* round up */ + return changehost(dpy, host, HostInsert); +} - LockDisplay(dpy); - GetReqExtra (ChangeHosts, length, req); - req->mode = HostDelete; - req->hostFamily = host->family; - req->hostLength = addrlen; - if (host->family == FamilyServerInterpreted) { - char *dest = (char *) NEXTPTR(req,xChangeHostsReq); - memcpy(dest, siAddr->type, siAddr->typelength); - dest[siAddr->typelength] = '\0'; - memcpy(dest + siAddr->typelength + 1,siAddr->value,siAddr->valuelength); - } else { - memcpy((char *) NEXTPTR(req,xChangeHostsReq), host->address, addrlen); - } - UnlockDisplay(dpy); - SyncHandle(); - return 1; +int +XRemoveHost ( + register Display *dpy, + XHostAddress *host) +{ + return changehost(dpy, host, HostDelete); } int -- cgit v1.2.3 From ed61433e1fda7bf83f912d6d7b750b77f47dce07 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 29 Jun 2016 13:17:04 +0200 Subject: nx-X11/lib/X11/LiHosts.c: Drop unused variable (in XListHosts). --- nx-X11/lib/X11/LiHosts.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'nx-X11/lib') diff --git a/nx-X11/lib/X11/LiHosts.c b/nx-X11/lib/X11/LiHosts.c index bd0864448..59e2ae318 100644 --- a/nx-X11/lib/X11/LiHosts.c +++ b/nx-X11/lib/X11/LiHosts.c @@ -71,11 +71,7 @@ XHostAddress *XListHosts ( } if (reply.nHosts) { - unsigned int l; nbytes = reply.length << 2; /* compute number of bytes in reply */ - l = (unsigned) (nbytes + - (reply.nHosts * sizeof(XHostAddress)) + - (reply.nHosts * sizeof(XServerInterpretedAddress))); op = outbuf = (XHostAddress *) Xmalloc((unsigned) (nbytes + (reply.nHosts * sizeof(XHostAddress)) + -- cgit v1.2.3 From 365fa4f3e7f7af34f919290ae3a19f6806d09ffb Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 29 Jun 2016 13:20:30 +0200 Subject: nx-X11/lib/X11/XKBMisc.c: Drop conditional always evaluating as True. Backported from X.org, patch found in janitor cleanup commit... commit 8ba0ca32a63c532f128bdca7f1bf982cab8e12be Author: Paulo Cesar Pereira de Andrade Date: Wed Jan 28 20:31:42 2009 -0200 --- nx-X11/lib/X11/XKBMisc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11/lib') diff --git a/nx-X11/lib/X11/XKBMisc.c b/nx-X11/lib/X11/XKBMisc.c index 04ac0c7ea..d1f75a93a 100644 --- a/nx-X11/lib/X11/XKBMisc.c +++ b/nx-X11/lib/X11/XKBMisc.c @@ -666,7 +666,7 @@ register int i; int width,nOldGroups,oldWidth,newTypes[XkbNumKbdGroups]; if ((!xkb) || (!XkbKeycodeInRange(xkb,key)) || (!xkb->map) || - (!xkb->map->types)||(!newTypes)||((groups&XkbAllGroupsMask)==0)|| + (!xkb->map->types)||((groups&XkbAllGroupsMask)==0)|| (nGroups>XkbNumKbdGroups)) { return BadMatch; } -- cgit v1.2.3 From 3569ac1712169d34c4b29ca301458ec0c325eed1 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 29 Jun 2016 13:24:38 +0200 Subject: nx-X11/lib/X11/lcFile.c: Drop conditional always evaluating as True. Backported from X.org, patch found in janitor cleanup commit... commit 8ba0ca32a63c532f128bdca7f1bf982cab8e12be Author: Paulo Cesar Pereira de Andrade Date: Wed Jan 28 20:31:42 2009 -0200 --- nx-X11/lib/X11/lcFile.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'nx-X11/lib') diff --git a/nx-X11/lib/X11/lcFile.c b/nx-X11/lib/X11/lcFile.c index 2e0a49db4..e1812ad91 100644 --- a/nx-X11/lib/X11/lcFile.c +++ b/nx-X11/lib/X11/lcFile.c @@ -437,8 +437,7 @@ _XlcFileName( char buf[PATH_MAX], *name; name = NULL; - if ((5 + (args[i] ? strlen (args[i]) : 0) + - (cat ? strlen (cat) : 0)) < PATH_MAX) { + if ((5 + (args[i] ? strlen (args[i]) : 0) + strlen(cat)) < PATH_MAX) { sprintf(buf, "%s/%s.dir", args[i], cat); name = resolve_name(siname, buf, RtoL); } -- cgit v1.2.3 From eddd4876bb40cf0cd7826f34eff2128e86fed42a Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 29 Jun 2016 13:28:23 +0200 Subject: nx-X11/lib/X11/imInsClbk.c: Fix warning 'right-hand operand of comma expression has no effect' in _XimFilterPropertyNotify. --- nx-X11/lib/X11/imInsClbk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11/lib') diff --git a/nx-X11/lib/X11/imInsClbk.c b/nx-X11/lib/X11/imInsClbk.c index acf9f7b63..744ee824c 100644 --- a/nx-X11/lib/X11/imInsClbk.c +++ b/nx-X11/lib/X11/imInsClbk.c @@ -111,7 +111,7 @@ _XimFilterPropertyNotify( } lock = True; - for( ii = 0; ii < nitems; ii++, atoms ) { + for( ii = 0; ii < nitems; ii++ ) { if(XGetSelectionOwner (display, atoms[ii])) { for( icb = callback_list; icb; icb = icb->next ) { if( !icb->call && !icb->destroy ) { -- cgit v1.2.3 From b34b47ed5463af3659dae21f3a2c2d68264fab3b Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 29 Jun 2016 13:30:08 +0200 Subject: =?UTF-8?q?nx-X11/lib/X11/imTrX.c:=20Fix=20warning=20=E2=80=98len?= =?UTF-8?q?=E2=80=99=20may=20be=20used=20uninitialized=20in=20this=20funct?= =?UTF-8?q?ion=20(=5FXimRead).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nx-X11/lib/X11/imTrX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11/lib') diff --git a/nx-X11/lib/X11/imTrX.c b/nx-X11/lib/X11/imTrX.c index 7d00bb3f7..4aa587662 100644 --- a/nx-X11/lib/X11/imTrX.c +++ b/nx-X11/lib/X11/imTrX.c @@ -436,7 +436,7 @@ _XimXRead(Xim im, XPointer recv_buf, int buf_len, int *ret_len) { XEvent *ev; XEvent event; - int len; + int len = 0; XSpecRec *spec = (XSpecRec *)im->private.proto.spec; XPointer arg = spec->ev; -- cgit v1.2.3 From f0af82cbbac03a128a573144da61a693ffa09e28 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 29 Jun 2016 15:07:16 +0200 Subject: nx-X11/lib/X11/XKBMisc.c: Avoid warning about maybe non-assigned variables (mask, newMask). --- nx-X11/lib/X11/XKBMisc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'nx-X11/lib') diff --git a/nx-X11/lib/X11/XKBMisc.c b/nx-X11/lib/X11/XKBMisc.c index d1f75a93a..7f0e59e7a 100644 --- a/nx-X11/lib/X11/XKBMisc.c +++ b/nx-X11/lib/X11/XKBMisc.c @@ -834,7 +834,7 @@ XkbUpdateKeyTypeVirtualMods( XkbDescPtr xkb, XkbChangesPtr changes) { register unsigned int i; -unsigned int mask; +unsigned int mask = 0; XkbVirtualModsToReal(xkb,type->mods.vmods,&mask); type->mods.mask= type->mods.real_mods|mask; @@ -888,7 +888,7 @@ unsigned int checkState = 0; XkbUpdateKeyTypeVirtualMods(xkb,&xkb->map->types[i],changed,changes); } if (changed&xkb->ctrls->internal.vmods) { - unsigned int newMask; + unsigned int newMask = 0; XkbVirtualModsToReal(xkb,xkb->ctrls->internal.vmods,&newMask); newMask|= xkb->ctrls->internal.real_mods; if (xkb->ctrls->internal.mask!=newMask) { @@ -900,7 +900,7 @@ unsigned int checkState = 0; } } if (changed&xkb->ctrls->ignore_lock.vmods) { - unsigned int newMask; + unsigned int newMask = 0; XkbVirtualModsToReal(xkb,xkb->ctrls->ignore_lock.vmods,&newMask); newMask|= xkb->ctrls->ignore_lock.real_mods; if (xkb->ctrls->ignore_lock.mask!=newMask) { @@ -916,7 +916,7 @@ unsigned int checkState = 0; map= &xkb->indicators->maps[0]; for (i=0;imods.vmods&changed) { - unsigned int newMask; + unsigned int newMask = 0; XkbVirtualModsToReal(xkb,map->mods.vmods,&newMask); newMask|= map->mods.real_mods; if (newMask!=map->mods.mask) { @@ -933,7 +933,7 @@ unsigned int checkState = 0; XkbCompatMapPtr compat; compat= xkb->compat; for (i=0;igroups[i].vmods,&newMask); newMask|= compat->groups[i].real_mods; if (compat->groups[i].mask!=newMask) { -- cgit v1.2.3