Re: [PATCH 1/4] tools/power/cpupower: Read energy_perf_bias from sysfs

From: Shuah Khan
Date: Thu Oct 29 2020 - 17:38:47 EST


On 10/16/20 2:37 AM, Borislav Petkov wrote:
On Thu, Oct 15, 2020 at 11:49:32AM -0600, Shuah Khan wrote:
Is there a reason to move "int fd"?

Sorry for a late response.

Okay. Looked odd since it didn't need changing.

Habit from tip - we sort function-local variables in a reverse fir tree
order. And since I'm adding cpupower_write_sysfs(), I made them look
consistent.

+ numwritten = write(fd, buf, buflen - 1);
+ if (numwritten < 1) {
+ perror("write failed");

Please add filename to the error message

perror(path);

or do you want me to build a string with an error message and filename?

Right. It will be great if you can add filename to the message.

Please add return check for snprintf, please add a define for
"cpu%u/power/energy_perf_bias" since it is hardcoded in
read/write functions.

None of the other snprintf() calls in cpupower do that. Nothing checks
snprintf() retval and the last part of the sysfs path is a naked string.

Why is this different?


All of the other ones should be changed as such. Why add more?

thanks,
-- Shuah