Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/cpupower: fix error return value in cpupower_write_sysfs()

The cpupower_write_sysfs() function currently returns -1 on
write failure, but the function signature indicates it should
return an unsigned int. Returning -1 from an unsigned function
results in a large positive value rather than indicating
an error condition.

Fix this by returning 0 on failure, which is more appropriate
for an unsigned return type and maintains consistency with typical
success/failure semantics where 0 indicates failure and non-zero
indicates success (bytes written).

Link: https://lore.kernel.org/r/20250828063000.803229-1-kaushlendra.kumar@intel.com
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Kaushlendra Kumar and committed by
Shuah Khan
57b100d4 f83ec76b

+1 -1
+1 -1
tools/power/cpupower/lib/cpupower.c
··· 56 56 if (numwritten < 1) { 57 57 perror(path); 58 58 close(fd); 59 - return -1; 59 + return 0; 60 60 } 61 61 62 62 close(fd);