xserver: Branch 'master' - 8 commits
Adam Jackson
ajax at kemper.freedesktop.org
Thu Apr 5 18:21:42 UTC 2018
dix/getevents.c | 2 +-
hw/dmx/config/dmxparse.c | 2 +-
hw/dmx/dmxpixmap.c | 2 +-
hw/dmx/dmxprop.c | 4 ++--
hw/dmx/input/dmxarg.c | 25 ++++++-------------------
hw/xfree86/utils/gtf/gtf.c | 2 +-
mi/miexpose.c | 2 +-
xkb/XKBGAlloc.c | 11 ++++++-----
8 files changed, 19 insertions(+), 31 deletions(-)
New commits:
commit 6f0903ddc905f44272b85942323a467d82fef644
Author: Adam Jackson <ajax at redhat.com>
Date: Thu Apr 5 13:09:38 2018 -0400
dix: Hush an almost certainly bogus warning
../dix/getevents.c: In function ‘transformAbsolute’:
../dix/getevents.c:1195:28: warning: ‘oy’ may be used uninitialized in this function [-Wmaybe-uninitialized]
struct pixman_f_vector p = {.v = {*x, *y, 1} };
^
../dix/getevents.c:1234:22: note: ‘oy’ was declared here
double x, y, ox, oy;
^~
This one is truly special. Even though both ox and oy are set and read
along the same paths, only oy is marked for this warning! Initializing
just oy = 0.0 fixes it entirely, but let's not make a weird thing
weirder.
Signed-off-by: Adam Jackson <ajax at redhat.com>
Acked-by: Keith Packard <keithp at keithp.com>
diff --git a/dix/getevents.c b/dix/getevents.c
index 0d87453e5..d8955969a 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1231,7 +1231,7 @@ transformRelative(DeviceIntPtr dev, ValuatorMask *mask)
static void
transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
{
- double x, y, ox, oy;
+ double x, y, ox = 0.0, oy = 0.0;
int has_x, has_y;
has_x = valuator_mask_isset(mask, 0);
commit 57e872301f5e836be2efb8f952f9c9711650b447
Author: Adam Jackson <ajax at redhat.com>
Date: Thu Apr 5 13:07:09 2018 -0400
mi: Hush an almost certainly bogus warning
In file included from ../mi/miexpose.c:83:
../mi/miexpose.c: In function ‘miHandleExposures’:
../include/regionstr.h:174:22: warning: ‘expBox.y2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
(_pReg)->extents = *(_pBox);
~~~~~~~~~~~~~~~~~^~~~~~~~~~
../mi/miexpose.c:139:12: note: ‘expBox.y2’ was declared here
BoxRec expBox;
^~~~~~
etc. It's initialized if (extents), and then only read if (extents),
but gcc doesn't seem to figure that out. Whatever, bzero it to be
explicit.
Signed-off-by: Adam Jackson <ajax at redhat.com>
Acked-by: Keith Packard <keithp at keithp.com>
diff --git a/mi/miexpose.c b/mi/miexpose.c
index 148d1a63b..c34530c34 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -136,7 +136,7 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
the window background
*/
WindowPtr pSrcWin;
- BoxRec expBox;
+ BoxRec expBox = { 0, };
Bool extents;
/* avoid work if we can */
commit 83913de25d35709b3ab7b0ab124b73924145d2dd
Author: Adam Jackson <ajax at redhat.com>
Date: Thu Apr 5 12:59:11 2018 -0400
xkb: Silence some compiler warnings
Of the form:
../xkb/XKBGAlloc.c: In function ‘SrvXkbAddGeomKeyAlias’:
../xkb/XKBGAlloc.c:591:13: warning: ‘strncpy’ specified bound 4 equals destination size [-Wstringop-truncation]
strncpy(alias->real, realStr, XkbKeyNameLength);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is intentional; the code that reads from these fields never reads
more than 4 bytes anyway. Rephrase things in terms of memcpy so that's
clear. Obviously this is awful but in XKB awful is par.
Signed-off-by: Adam Jackson <ajax at redhat.com>
Acked-by: Keith Packard <keithp at keithp.com>
diff --git a/xkb/XKBGAlloc.c b/xkb/XKBGAlloc.c
index e9f55fa43..8958b0c52 100644
--- a/xkb/XKBGAlloc.c
+++ b/xkb/XKBGAlloc.c
@@ -588,7 +588,8 @@ XkbAddGeomKeyAlias(XkbGeometryPtr geom, char *aliasStr, char *realStr)
i++, alias++) {
if (strncmp(alias->alias, aliasStr, XkbKeyNameLength) == 0) {
memset(alias->real, 0, XkbKeyNameLength);
- strncpy(alias->real, realStr, XkbKeyNameLength);
+ memcpy(alias->real, realStr,
+ min(XkbKeyNameLength, strlen(realStr)));
return alias;
}
}
@@ -598,8 +599,8 @@ XkbAddGeomKeyAlias(XkbGeometryPtr geom, char *aliasStr, char *realStr)
}
alias = &geom->key_aliases[geom->num_key_aliases];
memset(alias, 0, sizeof(XkbKeyAliasRec));
- strncpy(alias->alias, aliasStr, XkbKeyNameLength);
- strncpy(alias->real, realStr, XkbKeyNameLength);
+ memcpy(alias->alias, aliasStr, min(XkbKeyNameLength, strlen(aliasStr)));
+ memcpy(alias->real, realStr, min(XkbKeyNameLength, strlen(realStr)));
geom->num_key_aliases++;
return alias;
}
@@ -814,8 +815,8 @@ XkbAddGeomOverlayKey(XkbOverlayPtr overlay,
(_XkbAllocOverlayKeys(row, 1) != Success))
return NULL;
key = &row->keys[row->num_keys];
- strncpy(key->under.name, under, XkbKeyNameLength);
- strncpy(key->over.name, over, XkbKeyNameLength);
+ memcpy(key->under.name, under, min(XkbKeyNameLength, strlen(under)));
+ memcpy(key->over.name, over, min(XkbKeyNameLength, strlen(over)));
row->num_keys++;
return key;
}
commit d13cd3862e9ccd35c91a06680d02f2fc8fd03420
Author: Adam Jackson <ajax at redhat.com>
Date: Thu Apr 5 12:48:26 2018 -0400
dmx: Silence a string truncation warning.
../hw/dmx/config/dmxparse.c: In function ‘dmxConfigCreateOption’:
../hw/dmx/config/dmxparse.c:385:13: warning: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
strncpy(option->string + offset, p->string, len);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../hw/dmx/config/dmxparse.c:383:23: note: length computed here
int len = strlen(p->string);
^~~~~~~~~~~~~~~~~
The thing it's warning about is intentional, the surrounding code does
its own nul-termination. Make that obvious by using memcpy instead.
Signed-off-by: Adam Jackson <ajax at redhat.com>
Acked-by: Keith Packard <keithp at keithp.com>
diff --git a/hw/dmx/config/dmxparse.c b/hw/dmx/config/dmxparse.c
index cf510844d..f66143a6a 100644
--- a/hw/dmx/config/dmxparse.c
+++ b/hw/dmx/config/dmxparse.c
@@ -382,7 +382,7 @@ dmxConfigCreateOption(DMXConfigTokenPtr pStart,
if (p->string) {
int len = strlen(p->string);
- strncpy(option->string + offset, p->string, len);
+ memcpy(option->string + offset, p->string, len);
offset += len;
if (p->next)
option->string[offset++] = ' ';
commit 176f26e96ab9958c84c98c88f31729d0240c420e
Author: Adam Jackson <ajax at redhat.com>
Date: Thu Apr 5 12:45:51 2018 -0400
dmx: Clean up some argument parsing code
This threw:
../hw/dmx/input/dmxarg.c: In function ‘dmxArgParse’:
../hw/dmx/input/dmxarg.c:128:5: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
strncpy(tmp, string, len);
^~~~~~~~~~~~~~~~~~~~~~~~~
../hw/dmx/input/dmxarg.c:126:11: note: length computed here
len = strlen(string) + 2;
^~~~~~~~~~~~~~
This code predates xstrtokenize, but that's no excuse.
Signed-off-by: Adam Jackson <ajax at redhat.com>
Acked-by: Keith Packard <keithp at keithp.com>
diff --git a/hw/dmx/input/dmxarg.c b/hw/dmx/input/dmxarg.c
index 6c21ae959..582ed3faa 100644
--- a/hw/dmx/input/dmxarg.c
+++ b/hw/dmx/input/dmxarg.c
@@ -114,30 +114,17 @@ dmxArgC(dmxArg a)
dmxArg
dmxArgParse(const char *string)
{
- char *tmp;
- char *start, *pt;
+ int i = 0;
dmxArg a = dmxArgCreate();
- int done;
- int len;
if (!string)
return a;
- len = strlen(string) + 2;
- tmp = malloc(len);
- strncpy(tmp, string, len);
-
- for (start = pt = tmp, done = 0; !done && *pt; start = ++pt) {
- for (; *pt && *pt != ','; pt++);
- if (!*pt)
- done = 1;
- *pt = '\0';
- dmxArgAdd(a, start);
- }
- if (!done)
- dmxArgAdd(a, ""); /* Final comma */
-
- free(tmp);
+ a->argv = (const char **)xstrtokenize(string, ",");
+ if (a->argv)
+ for (i = 0; a->argv[i] != NULL; i++);
+ a->argc = i;
+
return a;
}
commit be99072a1a20af44d2457b8c86bd9041f61efa79
Author: Adam Jackson <ajax at redhat.com>
Date: Thu Apr 5 12:35:59 2018 -0400
dmx: Fix a read-from-uninitialized warning
../hw/dmx/dmxpixmap.c: In function ‘dmxBitmapToRegion’:
../include/regionstr.h:174:22: warning: ‘Box.x1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
(_pReg)->extents = *(_pBox);
~~~~~~~~~~~~~~~~~^~~~~~~~~~
../hw/dmx/dmxpixmap.c:208:12: note: ‘Box.x1’ was declared here
BoxRec Box;
^~~
Signed-off-by: Adam Jackson <ajax at redhat.com>
Acked-by: Keith Packard <keithp at keithp.com>
diff --git a/hw/dmx/dmxpixmap.c b/hw/dmx/dmxpixmap.c
index 17aca9224..7b317eaef 100644
--- a/hw/dmx/dmxpixmap.c
+++ b/hw/dmx/dmxpixmap.c
@@ -205,7 +205,7 @@ dmxBitmapToRegion(PixmapPtr pPixmap)
RegionPtr pReg, pTmpReg;
int x, y;
unsigned long previousPixel, currentPixel;
- BoxRec Box;
+ BoxRec Box = { 0, };
Bool overlap;
if (!dmxScreen->beDisplay) {
commit c3b190f9da3a8cd6f98c127220683dd20aed0f9b
Author: Adam Jackson <ajax at redhat.com>
Date: Thu Apr 5 12:31:04 2018 -0400
dmx: Fix some snprintf warnings.
snprintf doesn't terminate the string if it truncates, so things like
this are lurking crashers:
../hw/dmx/dmxprop.c: In function ‘dmxPropertyIdentifier.part.0’:
../hw/dmx/dmxprop.c:94:36: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 123 [-Wformat-truncation=]
snprintf(buf, sizeof(buf), "%s:%s:%s", DMX_IDENT, hostname, display);
^~ ~~~~~~~~
../hw/dmx/dmxprop.c:94:5: note: ‘snprintf’ output 7 or more bytes (assuming 262) into a destination of size 128
snprintf(buf, sizeof(buf), "%s:%s:%s", DMX_IDENT, hostname, display);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../hw/dmx/dmxprop.c: In function ‘dmxPropertyWindow’:
../hw/dmx/dmxprop.c:372:36: warning: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 127 [-Wformat-truncation=]
snprintf(buf, sizeof(buf), "%s,%d", id, dmxScreen->index);
^~
../hw/dmx/dmxprop.c:372:5: note: ‘snprintf’ output between 3 and 140 bytes into a destination of size 128
snprintf(buf, sizeof(buf), "%s,%d", id, dmxScreen->index);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We could be more precise about termination, but meh.
Signed-off-by: Adam Jackson <ajax at redhat.com>
Acked-by: Keith Packard <keithp at keithp.com>
diff --git a/hw/dmx/dmxprop.c b/hw/dmx/dmxprop.c
index 4c85268b7..7dfa04af5 100644
--- a/hw/dmx/dmxprop.c
+++ b/hw/dmx/dmxprop.c
@@ -84,7 +84,7 @@ dmxPropertyIdentifier(void)
/* RATS: These buffers are only used in
* length-limited calls. */
char hostname[256];
- static char buf[128];
+ static char buf[512];
static int initialized = 0;
if (initialized++)
@@ -346,7 +346,7 @@ dmxPropertyWindow(DMXScreenInfo * dmxScreen)
Display *dpy = dmxScreen->beDisplay;
Window win = dmxScreen->scrnWin;
DMXScreenInfo *other;
- char buf[128]; /* RATS: only used with snprintf */
+ char buf[1024]; /* RATS: only used with snprintf */
if (!dpy)
return; /* FIXME: What should be done here if Xdmx is started
commit 4c1453393feaebd688571ed1ba16c21703119ced
Author: Adam Jackson <ajax at redhat.com>
Date: Thu Apr 5 12:21:53 2018 -0400
gtf: Warning fix
../hw/xfree86/utils/gtf/gtf.c: In function ‘print_fb_mode’:
../hw/xfree86/utils/gtf/gtf.c:241:50: warning: cast from function call of type ‘double’ to non-matching type ‘int’ [-Wbad-function-cast]
printf(" timings %d %d %d %d %d %d %d\n", (int) rint(1000000.0 / m->pclk), /* pixclock in picoseconds */
That's pretty nitpicky of you, gcc, but at least it's easy to fix.
Signed-off-by: Adam Jackson <ajax at redhat.com>
Acked-by: Keith Packard <keithp at keithp.com>
diff --git a/hw/xfree86/utils/gtf/gtf.c b/hw/xfree86/utils/gtf/gtf.c
index c31bc8f93..818ee0fd7 100644
--- a/hw/xfree86/utils/gtf/gtf.c
+++ b/hw/xfree86/utils/gtf/gtf.c
@@ -238,7 +238,7 @@ print_fb_mode(mode * m)
printf(" # PCLK: %.2f MHz, H: %.2f kHz, V: %.2f Hz\n",
m->pclk, m->h_freq, m->v_freq);
printf(" geometry %d %d %d %d 32\n", m->hr, m->vr, m->hr, m->vr);
- printf(" timings %d %d %d %d %d %d %d\n", (int) rint(1000000.0 / m->pclk), /* pixclock in picoseconds */
+ printf(" timings %d %d %d %d %d %d %d\n", (int)lrint(1000000.0 / m->pclk), /* pixclock in picoseconds */
m->hfl - m->hse, /* left margin (in pixels) */
m->hss - m->hr, /* right margin (in pixels) */
m->vfl - m->vse, /* upper margin (in pixel lines) */
More information about the xorg-commit
mailing list