]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tools/cpupower: fix error return value in cpupower_write_sysfs()
authorKaushlendra Kumar <kaushlendra.kumar@intel.com>
Thu, 28 Aug 2025 06:30:00 +0000 (12:00 +0530)
committerShuah Khan <skhan@linuxfoundation.org>
Tue, 16 Sep 2025 22:21:50 +0000 (16:21 -0600)
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>
tools/power/cpupower/lib/cpupower.c

index ce8dfb8e46abdaf68c6df78365dbda47139593d2..d7f7ec6f151c2754af0c9b0c79d78ea98480c88f 100644 (file)
@@ -56,7 +56,7 @@ unsigned int cpupower_write_sysfs(const char *path, char *buf, size_t buflen)
        if (numwritten < 1) {
                perror(path);
                close(fd);
-               return -1;
+               return 0;
        }
 
        close(fd);