commit 9c5c4ff
Michael Forney
·
2014-01-31 22:48:30 +0000 UTC
parent b32c3d6
drm: Use snprintf return value to calculate sysfs paths
1 files changed,
+5,
-5
M
drm.c
M
drm.c
+5,
-5
1@@ -46,17 +46,17 @@ static const struct drm_driver * find_driver(int fd)
2 if (fstat(fd, &st) == -1)
3 return NULL;
4
5- snprintf(path, sizeof path, "/sys/dev/char/%u:%u/",
6- major(st.st_rdev), minor(st.st_rdev));
7- path_part = path + strlen(path);
8+ path_part = path + snprintf(path, sizeof path,
9+ "/sys/dev/char/%u:%u/device/",
10+ major(st.st_rdev), minor(st.st_rdev));
11
12- strcpy(path_part, "device/vendor");
13+ strcpy(path_part, "vendor");
14 file = fopen(path, "r");
15 fgets(id, sizeof id, file);
16 fclose(file);
17 vendor_id = strtoul(id, NULL, 0);
18
19- strcpy(path_part, "device/device");
20+ strcpy(path_part, "device");
21 file = fopen(path, "r");
22 fgets(id, sizeof id, file);
23 fclose(file);