scan-build: Dead store: Dead assignment

Value stored to 'max' is never read
Value stored to 'min' is never read

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
scan-build: Unix API: Allocator sizeof operand mismatch

Result of 'calloc' is converted to a pointer of type 'unsigned long',
which is incompatible with sizeof operand type 'long'

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
scan-build: Memory Error: Memory leak

strjoinsplit requires the caller to free memory

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
scan-build: Logic error: Result of operation is garbage or undefined

Assuming nitems is less than we expect, its possible for
get_mapped_area to return before writing values to its in-parameters.
This adds an additional verification to the returned data type.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
scan-build: Unix API: Undefined allocation of 0 bytes

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
scan-build: Logic error: Dereference of null pointer

If no match is found within the 'while' loop, the value of 'ndevices'
will be -1 at the point we reach 'if (!ndevices)' since we use the
post-decrement operator. In addition to never producing the expected
error message, this also results in a NULL dereference immediately
afterwards.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
scan-build: Logic error: Branch condition evaluates to a garbage value

1 (line 88): 'attr_id' declared without an initial value
2 (line 96): ASSUME Loop condition is false. Execution continues on line
107
3 (line 107): Branch condition evaluates to a garbage value

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
scan-build: Undefined or garbage value returned to caller

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
scan-build: Function call argument is an uninitialized value

The isdv4ParseTouchQuery and isdv4ParseTouchData functions
return 0 and -1 if errors occur. At the moment, only the -1
case is being handled, which can result in the callers using
uninitialized ISDV4TouchQueryReply or ISDV4TouchData results.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
scan-build: Logic error: Cast region with wrong size

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
scan-build: Logic error: Potential unintended use of sizeof() on pointer type

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
scan-build: security: Potential insecure memory buffer bounds restriction in call 'strcat'

The 'argv' strings passed into strjoinsplit are concatenated and
stored within the 'buff' array on the stack. Although we are
careful to ensure there is enough room remaining to store *argv
and a separating ' ' character before performing strcat, we also
need to ensure that there's room for the null terminator that
strcat itself will append.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Replace strjoinsplit

There's not much to like about this function's implementation. The
few scan-build warnings specific to this particular function suggested
it should be put to pasture and replaced with something better.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
clang-warning: extra ';' outside of a function

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
clang-warning: enumeration value 'FORMAT_DEFAULT' not explicitly handled in switch

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
clang-warning: -Wconditional-uninitialized

../src/xf86Wacom.c:511:16: warning: variable 'i' may be uninitialized when used here [-Wconditional-uninitialized]
                pInfo->name, i + 1, wait);

xsetwacom.c:2308:36: warning: variable 'x' may be uninitialized when used here [-Wconditional-uninitialized]
                return set_output_area(dpy, dev, x, y, width, height);
                                                 ^
xsetwacom.c:2308:39: warning: variable 'y' may be uninitialized when used here [-Wconditional-uninitialized]
                return set_output_area(dpy, dev, x, y, width, height);
                                                    ^
xsetwacom.c:2308:42: warning: variable 'width' may be uninitialized when used here [-Wconditional-uninitialized]
                return set_output_area(dpy, dev, x, y, width, height);
                                                       ^~~~~
xsetwacom.c:2308:49: warning: variable 'height' may be uninitialized when used here [-Wconditional-uninitialized]
                return set_output_area(dpy, dev, x, y, width, height);
                                                              ^~~~~~
isdv4-serial-inputattach.c:107:6: warning: variable 'attr_id' may be uninitialized when used here [-Wconditional-uninitialized]
        if (attr_id && sscanf(attr_id, "WACf%x", &id) == 1 && id >= 0x8)
            ^~~~~~~
isdv4-serial-inputattach.c:179:22: warning: variable 'baudrate' may be uninitialized when used here [-Wconditional-uninitialized]
        set_serial_attr(fd, baudrate);
                            ^~~~~~~~

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
clang-warning: -Wmissing-prototypes

xsetwacom.c:2098:6: warning: no previous prototype for function 'get_mapped_area' [-Wmissing-prototypes]
Bool get_mapped_area(Display *dpy, XDevice *dev, int *width, int *height, int *x_org, int *y_org)
     ^
isdv4-serial-inputattach.c:81:5: warning: no previous prototype for function 'get_baud_rate' [-Wmissing-prototypes]
int get_baud_rate(int fd)
    ^
isdv4-serial-inputattach.c:117:6: warning: no previous prototype for function 'sighandler' [-Wmissing-prototypes]
void sighandler(int signum)
     ^

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
clang-warning: -Wdocumentation-unknown-command

../src/wcmCommon.c:740:4: warning: unknown command tag name [-Wdocumentation-unknown-command]
 * @retval SUPPRESS_ALL Ignore this event completely.
   ^
../src/wcmCommon.c:1041:4: warning: unknown command tag name [-Wdocumentation-unknown-command]
 * @rebaes
   ^
../src/wcmUSB.c:1120:4: warning: unknown command tag name [-Wdocumentation-unknown-command]
 * @device_id id of the device
   ^
../src/wcmValidateDevice.c:524:52: warning: unknown command tag name [-Wdocumentation-unknown-command]
 * hotplug. The server will come back and call the @wcmHotplugDevice
                                                   ^
../src/wcmValidateDevice.c:753:4: warning: unknown command tag name [-Wdocumentation-unknown-command]
 * @retvalue True on success or False otherwise.
   ^
../src/wcmValidateDevice.c:1020:4: warning: unknown command tag name [-Wdocumentation-unknown-command]
 * @retvalue True on success or False otherwise.
   ^

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
clang-warning: -Wunreachable-code-break

../src/wcmXCommand.c:439:5: warning: 'break' will never be executed [-Wunreachable-code-break]
                                break;
                                ^~~~~

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
clang-warning: -Wunreachable-code-return

../src/wcmUSB.c:1140:9: warning: 'return' will never be executed [-Wunreachable-code-return]
        return 0;
               ^

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>