Skip to content

Commit 57b100d

Browse files
kaushlenshuahkh
authored andcommitted
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>
1 parent f83ec76 commit 57b100d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tools/power/cpupower/lib/cpupower.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ unsigned int cpupower_write_sysfs(const char *path, char *buf, size_t buflen)
5656
if (numwritten < 1) {
5757
perror(path);
5858
close(fd);
59-
return -1;
59+
return 0;
6060
}
6161

6262
close(fd);

0 commit comments

Comments
 (0)