[PATCH evemu] Only overwrite NULL names on evemu_read()

Peter Hutterer peter.hutterer at who-t.net
Mon Nov 11 15:08:45 PST 2013


If a caller has provided a device name to evemu_new(), parse the name but
don't copy it in to the device struct.

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

diff --git a/src/evemu.c b/src/evemu.c
index 3d88c8d..ff498d2 100644
--- a/src/evemu.c
+++ b/src/evemu.c
@@ -421,8 +421,10 @@ static int parse_name(struct evemu_device *dev, const char *line, struct version
 	int matched;
 	char *devname = NULL;
 
-	if ((matched = sscanf(line, "N: %m[^\n]\n", &devname)) > 0)
-		evemu_set_name(dev, devname);
+	if ((matched = sscanf(line, "N: %m[^\n]\n", &devname)) > 0) {
+		if (strlen(dev->name) == 0)
+			evemu_set_name(dev, devname);
+	}
 
 	if (devname != NULL)
 		free(devname);
-- 
1.8.3.1



More information about the Input-tools mailing list