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

From: Borislav Petkov
Date: Fri Oct 16 2020 - 04:38:08 EST


On Thu, Oct 15, 2020 at 11:49:32AM -0600, Shuah Khan wrote:
> Is there a reason to move "int fd"?

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?

> 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?

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette