mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
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>
This commit is contained in:
committed by
Tejun Heo
parent
7a8464555d
commit
6944e6d8a6
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user