[PATCH] Xi: make the scope of len match its lifetime.
Jamey Sharp
jamey at minilop.net
Wed Dec 9 18:16:37 PST 2009
The clang static analyzer gets confused by reusing the same variable.
Reported-by: Tomas Carnecky <tom at dbservice.com>
Signed-off-by: Jamey Sharp <jamey at minilop.net>
---
What do you think of this patch in place of the "set len to zero to
avoid confusing clang" patch? Does this also make clang happy? Am I the
only one who'd prefer this approach over introducing a useless
initialization? :-)
(Blue!)
Xi/xiquerydevice.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
index 435868d..59edcf5 100644
--- a/Xi/xiquerydevice.c
+++ b/Xi/xiquerydevice.c
@@ -428,7 +428,6 @@ ListDeviceClasses(ClientPtr client, DeviceIntPtr dev,
char *any, uint16_t *nclasses)
{
int total_len = 0;
- int len;
int i;
int rc;
@@ -437,26 +436,26 @@ ListDeviceClasses(ClientPtr client, DeviceIntPtr dev,
if (dev->button)
{
- (*nclasses)++;
- len = ListButtonInfo(dev, (xXIButtonInfo*)any, rc == Success);
+ int len = ListButtonInfo(dev, (xXIButtonInfo*)any, rc == Success);
any += len;
total_len += len;
+ (*nclasses)++;
}
if (dev->key)
{
- (*nclasses)++;
- len = ListKeyInfo(dev, (xXIKeyInfo*)any);
+ int len = ListKeyInfo(dev, (xXIKeyInfo*)any);
any += len;
total_len += len;
+ (*nclasses)++;
}
for (i = 0; dev->valuator && i < dev->valuator->numAxes; i++)
{
- (*nclasses)++;
- len = ListValuatorInfo(dev, (xXIValuatorInfo*)any, i, rc == Success);
+ int len = ListValuatorInfo(dev, (xXIValuatorInfo*)any, i, rc == Success);
any += len;
total_len += len;
+ (*nclasses)++;
}
return total_len;
--
1.6.5
More information about the xorg-devel
mailing list