Skip to contentSkip to conversation

sched_ext/selftests: Fix format specifier and buffer length in file_write_long()

PATCH Applied Cheng-Yang Chou 2 participants 2 messages Mar 4

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched_ext/selftests: Fix format specifier and buffer length in file_write_long()

Use %ld (not %lu) for signed long, and pass the actual string length returned by sprintf() to write_text() instead of sizeof(buf).

---
 tools/testing/selftests/sched_ext/util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/sched_ext/util.c +2 -2
index e47769c91918..2111329ed289 100644
@@ -60,11 +60,11 @@ int file_write_long(const char *path, long val)
 	char buf[64];
 	int ret;
 
-	ret = sprintf(buf, "%lu", val);
+	ret = sprintf(buf, "%ld", val);
 	if (ret < 0)
 		return ret;
 
-	if (write_text(path, buf, sizeof(buf)) <= 0)
+	if (write_text(path, buf, ret) <= 0)
 		return -1;
 
 	return 0;
Signature · 1 line
2.48.1
reviewer Applied
#1 lore raw

Hello,

Applied to sched_ext/for-7.0-fixes.

Thanks.

--
tejun