* [PATCH] tools/cpupower: fix error return value in cpupower_write_sysfs()
@ 2025-08-28 6:30 Kaushlendra Kumar
0 siblings, 0 replies; only message 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] only message in thread
only message in thread, other threads:[~2025-08-28 6:31 UTC | newest]
Thread overview: (only message) (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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).