[PATCH libXi] Add some () to shut up coverity

Josh Triplett josh at joshtriplett.org
Fri Nov 11 16:34:26 PST 2011


Yes, this is an array of *nclasses pointers.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/XExtInt.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/XExtInt.c b/src/XExtInt.c
index aa341e9..372956e 100644
--- a/src/XExtInt.c
+++ b/src/XExtInt.c
@@ -1528,7 +1528,7 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int *nclasses)
     ptr_wire = (char*)from;
     ptr_lib = to->classes;
     to->classes = next_block(&ptr_lib, *nclasses * sizeof(XIAnyClassInfo*));
-    memset(to->classes, 0, sizeof(*nclasses * sizeof(XIAnyClassInfo*)));
+    memset(to->classes, 0, sizeof((*nclasses) * sizeof(XIAnyClassInfo*)));

That doesn't look right at all.  (*nclasses) * sizeof(XIAnyClassInfo*)
makes sense, but it has an extra sizeof() wrapped around it.  As a
result, I'd expect that to return the size of whatever integer type
holds the result of the multiplication, rather than the size of the
array.

- Josh Triplett


More information about the xorg-devel mailing list