[PATCH i-g-t v3 1/3] lib/igt_sysfs: Use same var for sizeof()

Lucas De Marchi lucas.demarchi at intel.com
Wed Feb 28 06:32:09 UTC 2024


Let's guarantee we always pass the same pointer to vsnprintf: if we are
using the array size, pass that instead of buf that could point to
something else in an eventual refactor.

Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi at intel.com>
---
 lib/igt_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 51b610114..2b0225138 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -513,7 +513,7 @@ int igt_sysfs_vprintf(int dir, const char *attr, const char *fmt, va_list ap)
 		return -errno;
 
 	va_copy(tmp, ap);
-	ret = vsnprintf(buf, sizeof(stack), fmt, tmp);
+	ret = vsnprintf(stack, sizeof(stack), fmt, tmp);
 	va_end(tmp);
 	if (igt_debug_on(ret < 0))
 		return -EINVAL;
-- 
2.43.0



More information about the igt-dev mailing list