Skip to content

Commit 6944e6d

Browse files
EricccTaiwanhtejun
authored andcommitted
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). Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 7a84645 commit 6944e6d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • tools/testing/selftests/sched_ext

tools/testing/selftests/sched_ext/util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ int file_write_long(const char *path, long val)
6060
char buf[64];
6161
int ret;
6262

63-
ret = sprintf(buf, "%lu", val);
63+
ret = sprintf(buf, "%ld", val);
6464
if (ret < 0)
6565
return ret;
6666

67-
if (write_text(path, buf, sizeof(buf)) <= 0)
67+
if (write_text(path, buf, ret) <= 0)
6868
return -1;
6969

7070
return 0;

0 commit comments

Comments
 (0)