* [PATCH] tools/cpupower: fix error return value in cpupower_write_sysfs()
@ 2025-08-28 6:30 Kaushlendra Kumar
2025-09-16 22:24 ` Shuah Khan
0 siblings, 1 reply; 2+ messages in thread
From: Kaushlendra Kumar @ 2025-08-28 6:30 UTC (permalink / raw)
To: trenn, shuah, jwyatt, jkacur; +Cc: linux-pm, Kaushlendra Kumar
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).
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
tools/power/cpupower/lib/cpupower.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/power/cpupower/lib/cpupower.c b/tools/power/cpupower/lib/cpupower.c
index ce8dfb8e46ab..d7f7ec6f151c 100644
--- a/tools/power/cpupower/lib/cpupower.c
+++ b/tools/power/cpupower/lib/cpupower.c
@@ -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);
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tools/cpupower: fix error return value in cpupower_write_sysfs()
2025-08-28 6:30 [PATCH] tools/cpupower: fix error return value in cpupower_write_sysfs() Kaushlendra Kumar
@ 2025-09-16 22:24 ` Shuah Khan
0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2025-09-16 22:24 UTC (permalink / raw)
To: Kaushlendra Kumar, trenn, shuah, jwyatt, jkacur; +Cc: linux-pm, Shuah Khan
On 8/28/25 00:30, Kaushlendra Kumar wrote:
> 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).
>
> Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
> ---
Thanks. Applied to git.kernel.org/pub/scm/linux/kernel/git/shuah/linux.git
cpupower branch.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-16 22:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-28 6:30 [PATCH] tools/cpupower: fix error return value in cpupower_write_sysfs() Kaushlendra Kumar
2025-09-16 22:24 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox