commit 9c5c4ff61fd9635eb81be109808b2dc5334249d6
parent b32c3d6ab060810905d49dec18b475557de31d36
Author: Michael Forney <mforney@mforney.org>
Date: Fri, 31 Jan 2014 14:48:30 -0800
drm: Use snprintf return value to calculate sysfs paths
Diffstat:
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drm.c b/drm.c
@@ -46,17 +46,17 @@ static const struct drm_driver * find_driver(int fd)
if (fstat(fd, &st) == -1)
return NULL;
- snprintf(path, sizeof path, "/sys/dev/char/%u:%u/",
- major(st.st_rdev), minor(st.st_rdev));
- path_part = path + strlen(path);
+ path_part = path + snprintf(path, sizeof path,
+ "/sys/dev/char/%u:%u/device/",
+ major(st.st_rdev), minor(st.st_rdev));
- strcpy(path_part, "device/vendor");
+ strcpy(path_part, "vendor");
file = fopen(path, "r");
fgets(id, sizeof id, file);
fclose(file);
vendor_id = strtoul(id, NULL, 0);
- strcpy(path_part, "device/device");
+ strcpy(path_part, "device");
file = fopen(path, "r");
fgets(id, sizeof id, file);
fclose(file);