On 23-Jun-21 1:03 PM, David Hunt wrote:
From: Anatoly Burakov <anatoly.bura...@intel.com>

Currently, ACPI and PSTATE modes have lots of code duplication,
confusing logic, and a bunch of other issues that can, and have, led to
various bugs and resource leaks.

This commit factors out the common parts of sysfs reading/writing for
ACPI and PSTATE drivers.

Signed-off-by: Anatoly Burakov <anatoly.bura...@intel.com>
Signed-off-by: David Hunt <david.h...@intel.com>

---
changes in v5
* fixed bugs raised by Richael Zhuang in review - open file rw+, etc.
* removed FOPS* and FOPEN* macros, which contained control statements.
* fixed some checkpatch warnings.
changes in v6
* fixed check of fputs return, negative on error.
---
  lib/power/meson.build            |   7 +
  lib/power/power_acpi_cpufreq.c   | 192 ++++------------
  lib/power/power_common.c         | 146 ++++++++++++
  lib/power/power_common.h         |  17 ++
  lib/power/power_pstate_cpufreq.c | 374 ++++++++++---------------------
  5 files changed, 335 insertions(+), 401 deletions(-)

diff --git a/lib/power/meson.build b/lib/power/meson.build
index c1097d32f1..74c5f3a294 100644
--- a/lib/power/meson.build
+++ b/lib/power/meson.build
@@ -5,6 +5,13 @@ if not is_linux
      build = false
      reason = 'only supported on Linux'
  endif
+
+# we do some snprintf magic so silence format-nonliteral
+flag_nonliteral = '-Wno-format-nonliteral'
+if cc.has_argument(flag_nonliteral)
+       cflags += flag_nonliteral
+endif
+

I'll do a more thorough review later, but i suspect that we can drop this, if we fix the functions to have a GCC printf format attribute:

https://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Function-Attributes.html

See "format" section. I'm not sure this is supported by other compilers though, so maybe it's better to keep it.

--
Thanks,
Anatoly

Reply via email to