From 1bd1a033e71790bcc60acccac32d4195cae40b6e Mon Sep 17 00:00:00 2001 From: Ashutosh Dixit Date: Fri, 1 Jul 2022 20:05:34 -0700 Subject: lib/igt_device_scan: Fix -Wdangling-pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [12/1181] Compiling C object lib/libigt_device_scan.a.p/igt_device_scan.c.o ../lib/igt_device_scan.c: In function ‘igt_device_add_attr’: ../lib/igt_device_scan.c:368:57: warning: dangling pointer ‘v’ to ‘linkto’ may be used [-Wdangling-pointer=] 368 | g_hash_table_insert(dev->attrs_ht, strdup(key), strdup(v)); | ^~~~~~~~~ ../lib/igt_device_scan.c:351:22: note: ‘linkto’ declared here 351 | char linkto[PATH_MAX]; | ^~~~~~ Reviewed-by: Ville Syrjälä Signed-off-by: Ashutosh Dixit --- lib/igt_device_scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c index a1cee7a4..b51275e4 100644 --- a/lib/igt_device_scan.c +++ b/lib/igt_device_scan.c @@ -337,6 +337,7 @@ static void igt_device_add_prop(struct igt_device *dev, static void igt_device_add_attr(struct igt_device *dev, const char *key, const char *value) { + char linkto[PATH_MAX]; const char *v = value; if (!key) @@ -348,7 +349,6 @@ static void igt_device_add_attr(struct igt_device *dev, if (!v) { struct stat st; char path[PATH_MAX]; - char linkto[PATH_MAX]; int len; snprintf(path, sizeof(path), "%s/%s", dev->syspath, key); -- cgit v1.2.3