]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched_ext/selftests: Fix format specifier and buffer length in file_write_long()
authorCheng-Yang Chou <yphbchou0911@gmail.com>
Wed, 4 Mar 2026 19:57:57 +0000 (03:57 +0800)
committerTejun Heo <tj@kernel.org>
Wed, 4 Mar 2026 22:07:43 +0000 (12:07 -1000)
Use %ld (not %lu) for signed long, and pass the actual string length
returned by sprintf() to write_text() instead of sizeof(buf).

Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
tools/testing/selftests/sched_ext/util.c

index e47769c919187cd5cfa179b697cdb644a5e5235b..2111329ed28935d6389570eaa986dec7b62bf6b0 100644 (file)
@@ -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;