On Tue, Apr 11, 2017 at 01:20:33PM -0700, Jason Gerecke wrote: > Use of 'sizeof(keys)' is incorrect here since we don't care about the > length of the pointer itself, but rather of the array it points to. > Update function definitions to pass around a length parameter as needed. > > Signed-off-by: Jason Gerecke <jason.gere...@wacom.com> > --- > src/xdrv/wcmConfig.c | 4 ++-- > src/xdrv/wcmUSB.c | 4 ++-- > src/xdrv/wcmValidateDevice.c | 6 +++--- > 3 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/src/xdrv/wcmConfig.c b/src/xdrv/wcmConfig.c > index 2b89224..117e403 100755 > --- a/src/xdrv/wcmConfig.c > +++ b/src/xdrv/wcmConfig.c > @@ -21,7 +21,7 @@ > #include "wcmFilter.h" > #include <fcntl.h> > > -extern int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* keys, int* > tablet_id); > +extern int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* keys, > size_t nkeys, int* tablet_id);
don't name this nkeys, that suggests *number* of keys rather than bytes. you're using it as bytes everywhere though. Just rename it to keys_sz or sz, or something. Cheers, Peter > extern void wcmIsDisplay(WacomCommonPtr common); > #ifdef WCM_XORG_XSERVER_1_4 > extern Bool wcmIsAValidType(LocalDevicePtr local, const char *type, > unsigned long* keys); > @@ -658,7 +658,7 @@ static LocalDevicePtr xf86WcmInit(InputDriverPtr drv, > IDevPtr dev, int flags) > if(device) > { > /* initialize supported keys for Xorg server 1.4 or later */ > - wcmDeviceTypeKeys(fakeLocal, keys, &tablet_id); > + wcmDeviceTypeKeys(fakeLocal, keys, sizeof(keys), &tablet_id); > > /* check if the type is valid for the device > * that is not defined in xorg.conf > diff --git a/src/xdrv/wcmUSB.c b/src/xdrv/wcmUSB.c > index 092d370..ce82539 100755 > --- a/src/xdrv/wcmUSB.c > +++ b/src/xdrv/wcmUSB.c > @@ -37,7 +37,7 @@ > static int lastToolSerial = 0; > #endif > > -extern int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* keys, int* > tablet_id); > +extern int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* keys, > size_t nkeys, int* tablet_id); > extern void wcmIsDisplay(WacomCommonPtr common); > static Bool usbDetect(LocalDevicePtr); > Bool usbWcmInit(LocalDevicePtr pDev, char* id, float *version); > @@ -595,7 +595,7 @@ Bool usbWcmInit(LocalDevicePtr local, char* id, float > *version) > > #ifndef WCM_XORG_XSERVER_1_4 > /* older servers/kernels normally fail the first time */ > - wcmDeviceTypeKeys(local, common->wcmKeys, &common->tablet_id); > + wcmDeviceTypeKeys(local, common->wcmKeys, sizeof(common->wcmKeys), > &common->tablet_id); > wcmIsDisplay(common); > #endif /* WCM_XORG_XSERVER_1_4 */ > > diff --git a/src/xdrv/wcmValidateDevice.c b/src/xdrv/wcmValidateDevice.c > index bdaa5e1..9049108 100755 > --- a/src/xdrv/wcmValidateDevice.c > +++ b/src/xdrv/wcmValidateDevice.c > @@ -156,7 +156,7 @@ Bool wcmIsAValidType(LocalDevicePtr local, const char* > type, unsigned long* keys > #endif /* WCM_XORG_XSERVER_1_4 */ > > /* Choose valid types according to device ID */ > -int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* keys, int* > tablet_id) > +int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* keys, size_t > nkeys, int* tablet_id) > { > int ret = 1, fd = -1; > unsigned int id = 0; > @@ -172,7 +172,7 @@ int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned > long* keys, int* tablet_id) > return 0; > } > > - memset(keys, 0, sizeof(keys)); > + memset(keys, 0, nkeys); > *tablet_id = 0; > > /* serial ISDV4 devices */ > @@ -247,7 +247,7 @@ int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned > long* keys, int* tablet_id) > struct input_id wacom_id; > > /* test if the tool is defined in the kernel */ > - if (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keys)), keys) < 0) > + if (ioctl(fd, EVIOCGBIT(EV_KEY, nkeys), keys) < 0) > { > xf86Msg(X_ERROR, "%s: wcmDeviceTypeKeys unable to " > "ioctl USB key bits.\n", local->name); > -- > 2.12.0 > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Linuxwacom-devel mailing list > Linuxwacom-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel