[PATCH evdev] Fix relative events with swapped axes

2011-12-15 Thread przanoni
From: Paulo Zanoni paulo.r.zan...@intel.com

After we swap the axes, we only call valuator_mask_set for axes that are
not zero, so we need to unset the axes that became zero when swapped.

Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
---
 src/evdev.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

Same bug as the previous one, but now with relative events.

Easy to test: just use xinput to change the Evdev Axes Swap property
of your mouse and try to control it. Try to move on a straight vertical
or horizontal line to see what happens.

diff --git a/src/evdev.c b/src/evdev.c
index b1f9b2e..562c7e7 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -408,6 +408,10 @@ EvdevProcessValuators(InputInfoPtr pInfo)
 tmp = pEvdev-delta[REL_X];
 pEvdev-delta[REL_X] = pEvdev-delta[REL_Y];
 pEvdev-delta[REL_Y] = tmp;
+if (pEvdev-delta[REL_X] == 0)
+valuator_mask_unset(pEvdev-vals, REL_X);
+if (pEvdev-delta[REL_Y] == 0)
+valuator_mask_unset(pEvdev-vals, REL_Y);
 }
 if (pEvdev-invert_x)
 pEvdev-delta[REL_X] *= -1;
-- 
1.7.7.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH evdev] Fix absolute events with swapped axes

2011-12-14 Thread przanoni
From: Paulo Zanoni paulo.r.zan...@intel.com

We were correctly swapping the valuator values, but we were not
calling valuator_mask_unset() when needed, so the cursor kept jumping
to the edges.

This patch does the swapping before the main for, so we don't need to
store unswapped_{x,y} and unswapped_isset_{x,y} even when we don't need
to swap.

Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
---
 src/evdev.c |   31 ++-
 1 files changed, 22 insertions(+), 9 deletions(-)

Another solution to the problem would involve keeping the unswapped_x
and unswapped_y variables, and also adding unswapped_isset_{x,y}, but I
believe this one looks better because it just computes these values if
swap_axes is actually set.

How I tested:
 - disabled synaptics
 - configured my touchpad to report absolute events with evdev
   - Option Mode Absolute
 - xinput --set-prop SynPS/2 Synaptics TouchPad Evdev Axes Swap 1

If you move your finger across the touchpad when the axes are inverted
the cursor keeps jumping to the edges (because we set the valuators to 0
when what we really wanted was to call valuator_mask_unset). After the
patch, the cursor acts as we expect. Also, the edges of the touchpad
match the edges of the screen (the values are scaled correctly).

diff --git a/src/evdev.c b/src/evdev.c
index 428d3c1..b1f9b2e 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -436,10 +436,30 @@ EvdevProcessValuators(InputInfoPtr pInfo)
  * just works.
  */
 else if (pEvdev-abs_queued  pEvdev-in_proximity) {
-int unswapped_x = valuator_mask_get(pEvdev-vals, 0);
-int unswapped_y = valuator_mask_get(pEvdev-vals, 1);
 int i;
 
+if (pEvdev-swap_axes) {
+int swapped_isset[2] = {0, 0};
+int swapped_values[2];
+
+for(i = 0; i = 1; i++)
+if (valuator_mask_isset(pEvdev-vals, i)) {
+swapped_isset[1 - i] = 1;
+swapped_values[1 - i] =
+xf86ScaleAxis(valuator_mask_get(pEvdev-vals, i),
+  pEvdev-absinfo[1 - i].maximum,
+  pEvdev-absinfo[1 - i].minimum,
+  pEvdev-absinfo[i].maximum,
+  pEvdev-absinfo[i].minimum);
+}
+
+for (i = 0; i = 1; i++)
+if (swapped_isset[i])
+valuator_mask_set(pEvdev-vals, i, swapped_values[i]);
+else
+valuator_mask_unset(pEvdev-vals, i);
+}
+
 for (i = 0; i = 1; i++) {
 int val;
 int calib_min;
@@ -458,13 +478,6 @@ EvdevProcessValuators(InputInfoPtr pInfo)
 calib_max = pEvdev-calibration.max_y;
 }
 
-if (pEvdev-swap_axes)
-val = xf86ScaleAxis((i == 0 ? unswapped_y : unswapped_x),
-pEvdev-absinfo[i].maximum,
-pEvdev-absinfo[i].minimum,
-pEvdev-absinfo[1 - i].maximum,
-pEvdev-absinfo[1 - i].minimum);
-
 if (pEvdev-flags  EVDEV_CALIBRATED)
 val = xf86ScaleAxis(val, pEvdev-absinfo[i].maximum,
 pEvdev-absinfo[i].minimum, calib_max,
-- 
1.7.7.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH] Fix segfault when there's no config dir

2011-11-28 Thread przanoni
From: Paulo Zanoni paulo.r.zan...@intel.com

Also, call AddConfigDirFiles only if we found a file, protecting
ourselves from future changes to the AddConfigDirFiles function.

Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
---
 hw/xfree86/parser/scan.c |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 9099227..54fa474 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -852,13 +852,16 @@ OpenConfigDir(const char *path, const char *cmdline, 
const char *projroot,
 
/* match files named *.conf */
num = scandir(dirpath, list, ConfigFilter, alphasort);
-   found = AddConfigDirFiles(dirpath, list, num);
+   if (num  0)
+   found = AddConfigDirFiles(dirpath, list, num);
+   else
+   found = FALSE;
if (!found) {
free(dirpath);
dirpath = NULL;
}
-   while (num--)
-   free(list[num]);
+   while (num  0)
+   free(list[--num]);
free(list);
}
 
-- 
1.7.7.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH] Fix segfault when there's no config dir

2011-11-25 Thread przanoni
From: Paulo Zanoni paulo.r.zan...@intel.com

Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
---
 hw/xfree86/parser/scan.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Sorry. I guess this should be pushed soon...

diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 9b6c356..31c6499 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -855,8 +855,8 @@ OpenConfigDir(const char *path, const char *cmdline, const 
char *projroot,
free(dirpath);
dirpath = NULL;
}
-   while (num--)
-   free(list[num]);
+   while (num  0)
+   free(list[--num]);
free(list);
}
 
-- 
1.7.7.1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 1/4] Correctly free config file names

2011-11-03 Thread przanoni
From: Paulo Zanoni paulo.r.zan...@intel.com

We call xf86penConfigDirFiles twice, so we overwrite the configDirPath
variable, losing the pointer. If we move the pointer management to the
upper layer (the function callers), they will be able to call these
functions as many times as they want, but they'll have to free those
returned values.

v2: don't leak inside XWin

4,097 bytes in 1 blocks are definitely lost in loss record 625 of 632
   at 0x4C2779D: malloc (in vgpreload_memcheck-amd64-linux.so)
   by 0x4D7899: DoSubstitution (scan.c:615)
   by 0x4D87B0: OpenConfigDir (scan.c:845)
   by 0x4D8A2D: xf86openConfigDirFiles (scan.c:955)
   by 0x49031F: xf86HandleConfigFile (xf86Config.c:2327)
   by 0x49A9BF: InitOutput (xf86Init.c:365)
   by 0x425A7A: main (main.c:204)

Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
---

Tested only on Xorg, not Xwin. Should work, but...


 hw/xfree86/common/xf86Config.c |6 +-
 hw/xfree86/parser/scan.c   |   22 --
 hw/xfree86/parser/xf86Parser.h |8 
 hw/xwin/winconfig.c|4 +++-
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index cb4be42..5ab3e67 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -2301,7 +2301,7 @@ checkInput(serverLayoutPtr layout, Bool implicit_layout) {
 ConfigStatus
 xf86HandleConfigFile(Bool autoconfig)
 {
-const char *filename, *dirname, *sysdirname;
+char *filename, *dirname, *sysdirname;
 char *filesearch, *dirsearch;
 MessageType filefrom = X_DEFAULT;
 MessageType dirfrom = X_DEFAULT;
@@ -2353,6 +2353,10 @@ xf86HandleConfigFile(Bool autoconfig)
return CONFIG_NOFILE;
 }
 
+free(filename);
+free(dirname);
+free(sysdirname);
+
 if ((xf86configptr = xf86readConfigFile ()) == NULL) {
xf86Msg(X_ERROR, Problem parsing the config file\n);
return CONFIG_PARSE_ERROR;
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 99b3257..668237b 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -101,8 +101,6 @@ static int builtinIndex = 0;
 static int configPos = 0;  /* current readers position */
 static int configLineNo = 0;   /* linenumber */
 static char *configBuf, *configRBuf;   /* buffer for lines */
-static char *configPath;   /* path to config file */
-static char *configDirPath;/* path to config dir */
 static char *configSection = NULL; /* name of current section being parsed 
*/
 static int numFiles = 0;   /* number of config files */
 static int curFileIndex = 0;   /* index of current config file */
@@ -892,7 +890,8 @@ xf86initConfigFiles(void)
  * of the located files.
  *
  * The return value is a pointer to the actual name of the file that was
- * opened.  When no file is found, the return value is NULL.
+ * opened.  When no file is found, the return value is NULL. The caller should
+ * free() the returned value.
  *
  * The escape sequences allowed in the search path are defined above.
  *
@@ -914,7 +913,7 @@ xf86initConfigFiles(void)
%P/lib/X11/%X
 #endif
 
-const char *
+char *
 xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
 {
if (!path || !path[0])
@@ -923,8 +922,7 @@ xf86openConfigFile(const char *path, const char *cmdline, 
const char *projroot)
projroot = PROJECTROOT;
 
/* Search for a config file */
-   configPath = OpenConfigFile(path, cmdline, projroot, XCONFIGFILE);
-   return configPath;
+   return OpenConfigFile(path, cmdline, projroot, XCONFIGFILE);
 }
 
 /*
@@ -937,12 +935,13 @@ xf86openConfigFile(const char *path, const char *cmdline, 
const char *projroot)
  * fails if it is not found.
  *
  * The return value is a pointer to the actual name of the direcoty that was
- * opened.  When no directory is found, the return value is NULL.
+ * opened.  When no directory is found, the return value is NULL. The caller
+ * should free() the returned value.
  *
  * The escape sequences allowed in the search path are defined above.
  *
  */
-const char *
+char *
 xf86openConfigDirFiles(const char *path, const char *cmdline,
   const char *projroot)
 {
@@ -952,8 +951,7 @@ xf86openConfigDirFiles(const char *path, const char 
*cmdline,
projroot = PROJECTROOT;
 
/* Search for the multiconf directory */
-   configDirPath = OpenConfigDir(path, cmdline, projroot, XCONFIGDIR);
-   return configDirPath;
+   return OpenConfigDir(path, cmdline, projroot, XCONFIGDIR);
 }
 
 void
@@ -961,10 +959,6 @@ xf86closeConfigFile (void)
 {
int i;
 
-   free (configPath);
-   configPath = NULL;
-   free (configDirPath);
-   configDirPath = NULL;
free (configRBuf);
configRBuf = NULL;
free 

[PATCH 2/4] parser: free scandir's list

2011-11-03 Thread przanoni
From: Paulo Zanoni paulo.r.zan...@intel.com

v2: move the free()s to the function that calls scandir

80 bytes in 1 blocks are definitely lost in loss record 411 of 631
   at 0x4C2779D: malloc (vgpreload_memcheck-amd64-linux.so)
   by 0x4C27927: realloc (vgpreload_memcheck-amd64-linux.so)
   by 0x696A80D: scandir (scandir.c:108)
   by 0x4D8828: OpenConfigDir (scan.c:854)
   by 0x4D8A43: xf86openConfigDirFiles (scan.c:952)
   by 0x49031F: xf86HandleConfigFile (xf86Config.c:2327)
   by 0x49A9E3: InitOutput (xf86Init.c:365)
   by 0x425A7A: main (main.c:204)

Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
---

If we're going to move free(list) to outside the AddConfigDirFiles function,
we must also move the free(list[i]). IMHO, keeping these split as it was
before is not a good idea. So either we keep this or v1.


 hw/xfree86/parser/scan.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 668237b..78d57c4 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -798,14 +798,12 @@ AddConfigDirFiles(const char *dirpath, struct dirent 
**list, int num)
   files opened\n);
warnOnce = TRUE;
}
-   free(list[i]);
continue;
}
 
path = malloc(PATH_MAX + 1);
snprintf(path, PATH_MAX + 1, %s/%s, dirpath,
 list[i]-d_name);
-   free(list[i]);
file = fopen(path, r);
if (!file) {
free(path);
@@ -856,8 +854,10 @@ OpenConfigDir(const char *path, const char *cmdline, const 
char *projroot,
if (!found) {
free(dirpath);
dirpath = NULL;
-   free(list);
}
+   while (num--)
+   free(list[num]);
+   free(list);
}
 
free(pathcopy);
-- 
1.7.7

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 1/5] dix: don't InitXTestDevices if there's no XTest extension

2011-11-01 Thread przanoni
From: Paulo Zanoni paulo.r.zan...@intel.com

Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
---
 dix/devices.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/dix/devices.c b/dix/devices.c
index 673a360..9d67c06 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -681,7 +681,10 @@ InitCoreDevices(void)
 !EnableDevice(inputInfo.keyboard, TRUE))
 FatalError(Failed to enable core devices.);
 
-InitXTestDevices();
+#ifdef XTEST
+if (!noTestExtensions)
+   InitXTestDevices();
+#endif
 }
 
 /**
-- 
1.7.7

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 2/5] Correctly free config file names

2011-11-01 Thread przanoni
From: Paulo Zanoni paulo.r.zan...@intel.com

We call xf86penConfigDirFiles twice, so we overwrite the configDirPath
variable, losing the pointer. If we move the pointer management to the
upper layer (the function callers), they will be able to call these
functions as many times as they want, but they'll have to free those
returned values.

4,097 bytes in 1 blocks are definitely lost in loss record 625 of 632
   at 0x4C2779D: malloc (in vgpreload_memcheck-amd64-linux.so)
   by 0x4D7899: DoSubstitution (scan.c:615)
   by 0x4D87B0: OpenConfigDir (scan.c:845)
   by 0x4D8A2D: xf86openConfigDirFiles (scan.c:955)
   by 0x49031F: xf86HandleConfigFile (xf86Config.c:2327)
   by 0x49A9BF: InitOutput (xf86Init.c:365)
   by 0x425A7A: main (main.c:204)

Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
---
 hw/xfree86/common/xf86Config.c |6 +-
 hw/xfree86/parser/scan.c   |   22 --
 hw/xfree86/parser/xf86Parser.h |8 
 3 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index cb4be42..5ab3e67 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -2301,7 +2301,7 @@ checkInput(serverLayoutPtr layout, Bool implicit_layout) {
 ConfigStatus
 xf86HandleConfigFile(Bool autoconfig)
 {
-const char *filename, *dirname, *sysdirname;
+char *filename, *dirname, *sysdirname;
 char *filesearch, *dirsearch;
 MessageType filefrom = X_DEFAULT;
 MessageType dirfrom = X_DEFAULT;
@@ -2353,6 +2353,10 @@ xf86HandleConfigFile(Bool autoconfig)
return CONFIG_NOFILE;
 }
 
+free(filename);
+free(dirname);
+free(sysdirname);
+
 if ((xf86configptr = xf86readConfigFile ()) == NULL) {
xf86Msg(X_ERROR, Problem parsing the config file\n);
return CONFIG_PARSE_ERROR;
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 99b3257..668237b 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -101,8 +101,6 @@ static int builtinIndex = 0;
 static int configPos = 0;  /* current readers position */
 static int configLineNo = 0;   /* linenumber */
 static char *configBuf, *configRBuf;   /* buffer for lines */
-static char *configPath;   /* path to config file */
-static char *configDirPath;/* path to config dir */
 static char *configSection = NULL; /* name of current section being parsed 
*/
 static int numFiles = 0;   /* number of config files */
 static int curFileIndex = 0;   /* index of current config file */
@@ -892,7 +890,8 @@ xf86initConfigFiles(void)
  * of the located files.
  *
  * The return value is a pointer to the actual name of the file that was
- * opened.  When no file is found, the return value is NULL.
+ * opened.  When no file is found, the return value is NULL. The caller should
+ * free() the returned value.
  *
  * The escape sequences allowed in the search path are defined above.
  *
@@ -914,7 +913,7 @@ xf86initConfigFiles(void)
%P/lib/X11/%X
 #endif
 
-const char *
+char *
 xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
 {
if (!path || !path[0])
@@ -923,8 +922,7 @@ xf86openConfigFile(const char *path, const char *cmdline, 
const char *projroot)
projroot = PROJECTROOT;
 
/* Search for a config file */
-   configPath = OpenConfigFile(path, cmdline, projroot, XCONFIGFILE);
-   return configPath;
+   return OpenConfigFile(path, cmdline, projroot, XCONFIGFILE);
 }
 
 /*
@@ -937,12 +935,13 @@ xf86openConfigFile(const char *path, const char *cmdline, 
const char *projroot)
  * fails if it is not found.
  *
  * The return value is a pointer to the actual name of the direcoty that was
- * opened.  When no directory is found, the return value is NULL.
+ * opened.  When no directory is found, the return value is NULL. The caller
+ * should free() the returned value.
  *
  * The escape sequences allowed in the search path are defined above.
  *
  */
-const char *
+char *
 xf86openConfigDirFiles(const char *path, const char *cmdline,
   const char *projroot)
 {
@@ -952,8 +951,7 @@ xf86openConfigDirFiles(const char *path, const char 
*cmdline,
projroot = PROJECTROOT;
 
/* Search for the multiconf directory */
-   configDirPath = OpenConfigDir(path, cmdline, projroot, XCONFIGDIR);
-   return configDirPath;
+   return OpenConfigDir(path, cmdline, projroot, XCONFIGDIR);
 }
 
 void
@@ -961,10 +959,6 @@ xf86closeConfigFile (void)
 {
int i;
 
-   free (configPath);
-   configPath = NULL;
-   free (configDirPath);
-   configDirPath = NULL;
free (configRBuf);
configRBuf = NULL;
free (configBuf);
diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h
index a8785c5..c31fdc4 100644
--- 

[PATCH 3/5] parser: free scandir's list

2011-11-01 Thread przanoni
From: Paulo Zanoni paulo.r.zan...@intel.com

It seems appropriate to make the function that frees the list elements
also free the list.

80 bytes in 1 blocks are definitely lost in loss record 411 of 631
   at 0x4C2779D: malloc (vgpreload_memcheck-amd64-linux.so)
   by 0x4C27927: realloc (vgpreload_memcheck-amd64-linux.so)
   by 0x696A80D: scandir (scandir.c:108)
   by 0x4D8828: OpenConfigDir (scan.c:854)
   by 0x4D8A43: xf86openConfigDirFiles (scan.c:952)
   by 0x49031F: xf86HandleConfigFile (xf86Config.c:2327)
   by 0x49A9E3: InitOutput (xf86Init.c:365)
   by 0x425A7A: main (main.c:204)

Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
---
 hw/xfree86/parser/scan.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 668237b..96ea703 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -818,6 +818,7 @@ AddConfigDirFiles(const char *dirpath, struct dirent 
**list, int num)
numFiles++;
}
 
+   free(list);
return openedFile;
 }
 
@@ -856,7 +857,6 @@ OpenConfigDir(const char *path, const char *cmdline, const 
char *projroot,
if (!found) {
free(dirpath);
dirpath = NULL;
-   free(list);
}
}
 
-- 
1.7.7

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 4/5] parser: free val.str after xf86getBoolValue

2011-11-01 Thread przanoni
From: Paulo Zanoni paulo.r.zan...@intel.com

After we convert the value to a boolean, we discard the string.

This is just one example:

3 bytes in 1 blocks are definitely lost in loss record 5 of 657
   at 0x4C2779D: malloc (vgpreload_memcheck-amd64-linux.so)
   by 0x4D744D: xf86getToken (scan.c:400)
   by 0x4D75F1: xf86getSubToken (scan.c:462)
   by 0x4DB3E0: xf86parseInputClassSection (InputClass.c:189)
   by 0x4D664C: xf86readConfigFile (read.c:184)
   by 0x490556: xf86HandleConfigFile (xf86Config.c:2360)
   by 0x49AA77: InitOutput (xf86Init.c:365)
   by 0x425A7A: main (main.c:204)

Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
---
 hw/xfree86/parser/InputClass.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/hw/xfree86/parser/InputClass.c b/hw/xfree86/parser/InputClass.c
index 3f80170..1128995 100644
--- a/hw/xfree86/parser/InputClass.c
+++ b/hw/xfree86/parser/InputClass.c
@@ -182,6 +182,7 @@ xf86parseInputClassSection(void)
 Error(QUOTE_MSG, MatchIsKeyboard);
 ptr-is_keyboard.set = xf86getBoolValue(ptr-is_keyboard.val,
 val.str);
+free(val.str);
 if (!ptr-is_keyboard.set)
 Error(BOOL_MSG, MatchIsKeyboard);
 break;
@@ -190,6 +191,7 @@ xf86parseInputClassSection(void)
 Error(QUOTE_MSG, MatchIsPointer);
 ptr-is_pointer.set = xf86getBoolValue(ptr-is_pointer.val,
val.str);
+free(val.str);
 if (!ptr-is_pointer.set)
 Error(BOOL_MSG, MatchIsPointer);
 break;
@@ -198,6 +200,7 @@ xf86parseInputClassSection(void)
 Error(QUOTE_MSG, MatchIsJoystick);
 ptr-is_joystick.set = xf86getBoolValue(ptr-is_joystick.val,
 val.str);
+free(val.str);
 if (!ptr-is_joystick.set)
 Error(BOOL_MSG, MatchIsJoystick);
 break;
@@ -206,6 +209,7 @@ xf86parseInputClassSection(void)
 Error(QUOTE_MSG, MatchIsTablet);
 ptr-is_tablet.set = xf86getBoolValue(ptr-is_tablet.val,
   val.str);
+free(val.str);
 if (!ptr-is_tablet.set)
 Error(BOOL_MSG, MatchIsTablet);
 break;
@@ -214,6 +218,7 @@ xf86parseInputClassSection(void)
 Error(QUOTE_MSG, MatchIsTouchpad);
 ptr-is_touchpad.set = xf86getBoolValue(ptr-is_touchpad.val,
 val.str);
+free(val.str);
 if (!ptr-is_touchpad.set)
 Error(BOOL_MSG, MatchIsTouchpad);
 break;
@@ -222,6 +227,7 @@ xf86parseInputClassSection(void)
 Error(QUOTE_MSG, MatchIsTouchscreen);
 ptr-is_touchscreen.set = 
xf86getBoolValue(ptr-is_touchscreen.val,
val.str);
+free(val.str);
 if (!ptr-is_touchscreen.set)
 Error(BOOL_MSG, MatchIsTouchscreen);
 break;
-- 
1.7.7

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 5/5] parser: free val.str after xstrtokenize

2011-11-01 Thread przanoni
From: Paulo Zanoni paulo.r.zan...@intel.com

After we tokenize val.str, we discard it.

This is just one example:
6 bytes in 1 blocks are definitely lost in loss record 24 of 652
   at 0x4C2779D: malloc (in vgpreload_memcheck-amd64-linux.so)
   by 0x4D744D: xf86getToken (scan.c:400)
   by 0x4D75F1: xf86getSubToken (scan.c:462)
   by 0x4DB060: xf86parseInputClassSection (InputClass.c:145)
   by 0x4D664C: xf86readConfigFile (read.c:184)
   by 0x490556: xf86HandleConfigFile (xf86Config.c:2360)
   by 0x49AA77: InitOutput (xf86Init.c:365)
   by 0x425A7A: main (main.c:204)

Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
---
 hw/xfree86/parser/InputClass.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/hw/xfree86/parser/InputClass.c b/hw/xfree86/parser/InputClass.c
index 1128995..2cdc912 100644
--- a/hw/xfree86/parser/InputClass.c
+++ b/hw/xfree86/parser/InputClass.c
@@ -128,54 +128,63 @@ xf86parseInputClassSection(void)
 Error(QUOTE_MSG, MatchProduct);
 add_group_entry(ptr-match_product,
 xstrtokenize(val.str, TOKEN_SEP));
+free(val.str);
 break;
 case MATCH_VENDOR:
 if (xf86getSubToken((ptr-comment)) != STRING)
 Error(QUOTE_MSG, MatchVendor);
 add_group_entry(ptr-match_vendor,
 xstrtokenize(val.str, TOKEN_SEP));
+free(val.str);
 break;
 case MATCH_DEVICE_PATH:
 if (xf86getSubToken((ptr-comment)) != STRING)
 Error(QUOTE_MSG, MatchDevicePath);
 add_group_entry(ptr-match_device,
 xstrtokenize(val.str, TOKEN_SEP));
+free(val.str);
 break;
 case MATCH_OS:
 if (xf86getSubToken((ptr-comment)) != STRING)
 Error(QUOTE_MSG, MatchOS);
 add_group_entry(ptr-match_os,
 xstrtokenize(val.str, TOKEN_SEP));
+free(val.str);
 break;
 case MATCH_PNPID:
 if (xf86getSubToken((ptr-comment)) != STRING)
 Error(QUOTE_MSG, MatchPnPID);
 add_group_entry(ptr-match_pnpid,
 xstrtokenize(val.str, TOKEN_SEP));
+free(val.str);
 break;
 case MATCH_USBID:
 if (xf86getSubToken((ptr-comment)) != STRING)
 Error(QUOTE_MSG, MatchUSBID);
 add_group_entry(ptr-match_usbid,
 xstrtokenize(val.str, TOKEN_SEP));
+free(val.str);
 break;
 case MATCH_DRIVER:
 if (xf86getSubToken((ptr-comment)) != STRING)
 Error(QUOTE_MSG, MatchDriver);
 add_group_entry(ptr-match_driver,
 xstrtokenize(val.str, TOKEN_SEP));
+free(val.str);
 break;
 case MATCH_TAG:
 if (xf86getSubToken((ptr-comment)) != STRING)
 Error(QUOTE_MSG, MatchTag);
 add_group_entry(ptr-match_tag,
 xstrtokenize(val.str, TOKEN_SEP));
+free(val.str);
 break;
 case MATCH_LAYOUT:
 if (xf86getSubToken((ptr-comment)) != STRING)
 Error(QUOTE_MSG, MatchLayout);
 add_group_entry(ptr-match_layout,
 xstrtokenize(val.str, TOKEN_SEP));
+free(val.str);
 break;
 case MATCH_IS_KEYBOARD:
 if (xf86getSubToken((ptr-comment)) != STRING)
-- 
1.7.7

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 1/3] glx: fix memory leak when destroying screen

2011-10-29 Thread przanoni
From: Paulo Zanoni paulo.r.zan...@intel.com

1,152 bytes in 1 blocks are definitely lost in loss record 536 of 575
   at 0x4C25E84: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x483820: __glXScreenInit (glxscreens.c:357)
   by 0x48271C: __glXDRIscreenProbe (glxdriswrast.c:469)
   by 0x4812BE: GlxExtensionInit (glxext.c:327)
   by 0x41FB14: InitExtensions (miinitext.c:471)
   by 0x5685AE: main (main.c:208)

Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
---
 glx/glxscreens.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/glx/glxscreens.c b/glx/glxscreens.c
index c4ad426..ebb9747 100644
--- a/glx/glxscreens.c
+++ b/glx/glxscreens.c
@@ -422,4 +422,5 @@ void __glXScreenDestroy(__GLXscreen *screen)
 free(screen-GLXvendor);
 free(screen-GLXextensions);
 free(screen-GLextensions);
+free(screen-visuals);
 }
-- 
1.7.7

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 2/3] glx: don't leak fbconfigs

2011-10-29 Thread przanoni
From: Paulo Zanoni paulo.r.zan...@intel.com

29,952 (208 direct, 29,744 indirect) bytes in 1 blocks are definitely lost in 
loss record 573 of 573
   at 0x4C2779D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x4829BC: createModeFromConfig (glxdricommon.c:131)
   by 0x482C09: glxConvertConfigs (glxdricommon.c:185)
   by 0x482788: __glXDRIscreenProbe (glxdriswrast.c:468)
   by 0x4812FA: GlxExtensionInit (glxext.c:327)
   by 0x41FB14: InitExtensions (miinitext.c:471)
   by 0x568636: main (main.c:208)

Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
---
 glx/glxscreens.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/glx/glxscreens.c b/glx/glxscreens.c
index ebb9747..928cf0c 100644
--- a/glx/glxscreens.c
+++ b/glx/glxscreens.c
@@ -419,6 +419,15 @@ void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr 
pScreen)
 
 void __glXScreenDestroy(__GLXscreen *screen)
 {
+__GLXconfig *head, *next;
+
+head = screen-fbconfigs;
+while (head) {
+   next = head-next;
+   free(head);
+   head = next;
+}
+
 free(screen-GLXvendor);
 free(screen-GLXextensions);
 free(screen-GLextensions);
-- 
1.7.7

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel