Re: [PATCH] cpufreq: Use int type to store negative error codes
From: Qianfeng Rong
Date: Sat Aug 30 2025 - 03:32:42 EST
在 2025/8/30 0:52, Rafael J. Wysocki 写道:
On Fri, Aug 29, 2025 at 10:44 AM Qianfeng Rong <rongqianfeng@xxxxxxxx> wrote:
Change the 'ret' variable from unsigned int to int to store negative error
codes directly or returned by other functions.
You need to say upfront that this is about speedstep_get_freqs() specifically.
Yes, my commit message was a little unclear. I will improve it.
Change the return type of
the speedstep_get_freqs() function from unsigned int to int as well.
Storing the negative error codes in unsigned type, doesn't cause an issue
at runtime but it's ugly as pants.
Which isn't really a technical term.
Yes, I should have used more normal words.
Additionally, assigning negative error codes to unsigned type may trigger a GCC warning
when the -Wsign-conversion flag is enabled.
Is the latter a motivation for this change?
That's one aspect. On the other hand, I think code that assigns negative
values to an unsigned type is confusing, so I want to fix such code.
Best regards, Qianfeng