xserver: Branch 'master' - 4 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 18 04:50:16 UTC 2020


 dix/devices.c              |    3 ---
 hw/dmx/examples/xbell.c    |    9 ++++++++-
 hw/xfree86/int10/generic.c |   12 ++++++------
 xkb/XKBMisc.c              |    6 +++---
 4 files changed, 17 insertions(+), 13 deletions(-)

New commits:
commit e538601128c1a8bb4247a817da2bbb3f671811b3
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sun Nov 1 15:52:48 2020 -0800

    int10: wrap entire V_ADDR_R* macros in parens for safer expansion
    
    Resolves warnings from Oracle Parfait static analyser:
    
    Error: Misleading macro
       Misleading macro [misleading-macro]:
          misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
            at line 392 of hw/xfree86/int10/generic.c.
            '|' operator has higher precedence than ternary '?:' operator inside macro body at line 431
            low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 431
       Misleading macro [misleading-macro]:
          misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
            at line 392 of hw/xfree86/int10/generic.c.
            '<<' operator has higher precedence than ternary '?:' operator inside macro body at line 431
            low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 431
       Misleading macro [misleading-macro]:
          misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
            at line 392 of hw/xfree86/int10/generic.c.
            '<<' operator has higher precedence than ternary '?:' operator inside macro body at line 442
            low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 442
       Misleading macro [misleading-macro]:
          misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
            at line 392 of hw/xfree86/int10/generic.c.
            '<<' operator has higher precedence than ternary '?:' operator inside macro body at line 443
            low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 443
       Misleading macro [misleading-macro]:
          misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
            at line 392 of hw/xfree86/int10/generic.c.
            '|' operator has higher precedence than ternary '?:' operator inside macro body at line 443
            low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 441
       Misleading macro [misleading-macro]:
          misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
            at line 392 of hw/xfree86/int10/generic.c.
            '<<' operator has higher precedence than ternary '?:' operator inside macro body at line 443
            low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 443
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c
index 1811efb14..191571192 100644
--- a/hw/xfree86/int10/generic.c
+++ b/hw/xfree86/int10/generic.c
@@ -389,14 +389,14 @@ xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num)
 
 #define VRAM(addr) ((addr >= V_RAM) && (addr < (V_RAM + VRAM_SIZE)))
 #define V_ADDR_RB(addr) \
-	(VRAM(addr)) ? MMIO_IN8((uint8_t*)VRAM_BASE,VRAM_ADDR(addr)) \
-	   : *(uint8_t*) V_ADDR(addr)
+	((VRAM(addr)) ? MMIO_IN8((uint8_t*)VRAM_BASE,VRAM_ADDR(addr)) \
+	   : *(uint8_t*) V_ADDR(addr))
 #define V_ADDR_RW(addr) \
-	(VRAM(addr)) ? MMIO_IN16((uint16_t*)VRAM_BASE,VRAM_ADDR(addr)) \
-	   : ldw_u((void *)V_ADDR(addr))
+	((VRAM(addr)) ? MMIO_IN16((uint16_t*)VRAM_BASE,VRAM_ADDR(addr)) \
+	   : ldw_u((void *)V_ADDR(addr)))
 #define V_ADDR_RL(addr) \
-	(VRAM(addr)) ? MMIO_IN32((uint32_t*)VRAM_BASE,VRAM_ADDR(addr)) \
-	   : ldl_u((void *)V_ADDR(addr))
+	((VRAM(addr)) ? MMIO_IN32((uint32_t*)VRAM_BASE,VRAM_ADDR(addr)) \
+	   : ldl_u((void *)V_ADDR(addr)))
 
 #define V_ADDR_WB(addr,val) \
 	if(VRAM(addr)) \
commit a6574033f464c7cde02bce8f1b130ff6b2b2d9eb
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sun Nov 1 15:45:08 2020 -0800

    xkb: always set *mask_rtrn in XkbVirtualModsToReal
    
    Resolves warning from Oracle Parfait static analyser:
    
    Error: Uninitialised memory
       Uninitialised memory variable [uninitialised-mem-var] (CWE 457):
          Possible access to uninitialised memory referenced by variable 'mask'
            at line 721 of xkb/XKBMisc.c in function 'XkbUpdateKeyTypeVirtualMods'.
            Path in callee avoiding write at line 720
              mask allocated at line 718
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/xkb/XKBMisc.c b/xkb/XKBMisc.c
index f17194528..2bad695e0 100644
--- a/xkb/XKBMisc.c
+++ b/xkb/XKBMisc.c
@@ -663,14 +663,14 @@ XkbVirtualModsToReal(XkbDescPtr xkb, unsigned virtual_mask, unsigned *mask_rtrn)
     register int i, bit;
     register unsigned mask;
 
-    if (xkb == NULL)
+    if ((xkb == NULL) || (xkb->server == NULL)) {
+        *mask_rtrn = 0;
         return FALSE;
+    }
     if (virtual_mask == 0) {
         *mask_rtrn = 0;
         return TRUE;
     }
-    if (xkb->server == NULL)
-        return FALSE;
     for (i = mask = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
         if (virtual_mask & bit)
             mask |= xkb->server->vmods[i];
commit 034e792662a1c0c6ab52190e457b1f017bec01c6
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sun Nov 1 13:55:59 2020 -0800

    dmx: example code should set a good example
    
    Resolves warning from Oracle Parfait static analyser:
    
    Error: Unchecked result
       Unchecked result [unchecked-result-call-X]:
          Unchecked return value from call to XOpenDisplay. Value display must be ch
    ecked to ensure this function was successful.
            at line 73 of hw/dmx/examples/xbell.c in function 'main'.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/dmx/examples/xbell.c b/hw/dmx/examples/xbell.c
index 543db24bf..e64b9c90c 100644
--- a/hw/dmx/examples/xbell.c
+++ b/hw/dmx/examples/xbell.c
@@ -70,7 +70,7 @@ pks(XKeyboardState * ks)
 int
 main(int argc, char **argv)
 {
-    Display *display = XOpenDisplay(NULL);
+    Display *display;
     XKeyboardControl kc;
     XKeyboardState ks;
     unsigned long vm;
@@ -86,6 +86,13 @@ main(int argc, char **argv)
     kc.bell_pitch = atoi(argv[3]);
     kc.bell_duration = atoi(argv[4]);
 
+    display = XOpenDisplay(NULL);
+    if (display == NULL) {
+        fprintf (stderr, "%s: unable to open display \"%s\".\n",
+                 argv[0], XDisplayName (NULL));
+        exit(1);
+    }
+
     printf("Setting:\n");
     pkc(&kc, vm);
     XChangeKeyboardControl(display, vm, &kc);
commit d00594ebc7941a5491ad5583d6890ab7dc2ffc43
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sun Nov 1 13:38:21 2020 -0800

    AddInputDevice: only need to check once if we failed to calloc dev
    
    Resolves warning from Oracle Parfait static analyser:
    
    Warning: Impossible or redundant condition
       Impossible or redundant condition [impossible-redundant-condition]:
          Condition 'dev != NULL' of branch is determined by previous branch
            at line 270 of dix/devices.c in function 'AddInputDevice'.
              Condition 'dev != NULL' from this branch implies following branch is always true at line 262
    
    Fixes: commit 493ad83323
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/dix/devices.c b/dix/devices.c
index 7bf5ac072..59a4dbfee 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -267,9 +267,6 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
         return NULL;
     }
 
-    if (!dev)
-        return (DeviceIntPtr) NULL;
-
     dev->last.scroll = NULL;
     dev->last.touches = NULL;
     dev->id = devid;


More information about the xorg-commit mailing list