From f5584659bfbd77507794b3299bc0bc752655bd77 Mon Sep 17 00:00:00 2001 From: Kate Hsuan Date: Tue, 16 Jul 2024 12:34:33 +0800 Subject: [PATCH] Update to release 0.0.6 Update to release 0.0.6 A patch fixed the compiler "above array bound" error --- ...Fix-compiler-above-array-bound-error.patch | 51 +++ 22.patch | 32 -- 29.patch | 314 ------------------ intel-lpmd.spec | 9 +- sources | 2 +- 5 files changed, 55 insertions(+), 353 deletions(-) create mode 100644 0001-lpmd_cpu-Fix-compiler-above-array-bound-error.patch delete mode 100644 22.patch delete mode 100644 29.patch diff --git a/0001-lpmd_cpu-Fix-compiler-above-array-bound-error.patch b/0001-lpmd_cpu-Fix-compiler-above-array-bound-error.patch new file mode 100644 index 0000000..e24985d --- /dev/null +++ b/0001-lpmd_cpu-Fix-compiler-above-array-bound-error.patch @@ -0,0 +1,51 @@ +From 1918cd77f5f26eeb4f9288ed45072068e1b4da34 Mon Sep 17 00:00:00 2001 +From: Kate Hsuan +Date: Tue, 16 Jul 2024 11:31:00 +0800 +Subject: [PATCH] lpmd_cpu: Fix compiler above array bound error +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +n file included from /usr/include/glib-2.0/glib.h:64, + from src/lpmd.h:48, + from src/lpmd_cpu.c:52: +src/lpmd_cpu.c: In function ‘add_cpu’: +src/lpmd_cpu.c:408:66: error: array subscript 8 is above array bounds of ‘struct lpm_cpus[7]’ [-Werror=array-bounds=] + 408 | lpmd_log_debug ("\tDetected %s CPU%d\n", cpumasks[idx].name, cpu); + | ~~~~~~~~^~~~~ +src/lpmd_cpu.c:67:24: note: while referencing ‘cpumasks’ + 67 | static struct lpm_cpus cpumasks[CPUMASK_MAX] = { + | ^~~~~~~~ +cc1: all warnings being treated as errors +make[2]: *** [Makefile:686: src/intel_lpmd-lpmd_cpu.o] Error 1 +make[1]: *** [Makefile:868: all-recursive] Error 1 +make: *** [Makefile:459: all] Error 2 +--- + src/lpmd_cpu.c | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/src/lpmd_cpu.c b/src/lpmd_cpu.c +index 310bf65..808ae4b 100644 +--- a/src/lpmd_cpu.c ++++ b/src/lpmd_cpu.c +@@ -402,10 +402,14 @@ int add_cpu(int cpu, enum cpumask_idx idx) + if (idx & (CPUMASK_HFI | CPUMASK_HFI_SUV | CPUMASK_HFI_BANNED)) + return 0; + +- if (idx == CPUMASK_LPM_DEFAULT) ++ if (idx == CPUMASK_LPM_DEFAULT) { + lpmd_log_info ("\tDetected %s CPU%d\n", cpumasks[idx].name, cpu); +- else +- lpmd_log_debug ("\tDetected %s CPU%d\n", cpumasks[idx].name, cpu); ++ } else { ++ if (idx < CPUMASK_MAX) ++ lpmd_log_debug ("\tDetected %s CPU%d\n", cpumasks[idx].name, cpu); ++ else ++ lpmd_log_debug ("\tIncorrect CPU ID for CPU%d\n", cpu); ++ } + + return 0; + } +-- +2.45.2 + diff --git a/22.patch b/22.patch deleted file mode 100644 index b38b186..0000000 --- a/22.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 3717c7186895951f58b429d67b954e23a1986b05 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Ali=20Erdin=C3=A7=20K=C3=B6ro=C4=9Flu?= - -Date: Fri, 9 Feb 2024 17:17:09 +0200 -Subject: [PATCH] Update lpmd_cpu.c - -Werror unused-variable fixes ---- - src/lpmd_cpu.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/src/lpmd_cpu.c b/src/lpmd_cpu.c -index f4dec42..bddd3a7 100644 ---- a/src/lpmd_cpu.c -+++ b/src/lpmd_cpu.c -@@ -804,7 +804,7 @@ static int detect_lpm_cpus_cmd(char *cmd) - */ - static int is_cpu_atom(int cpu) - { -- unsigned int eax, ebx, ecx, edx, subleaf; -+ unsigned int eax, ebx, ecx, edx; - unsigned int type; - - if (cpu_migrate(cpu) < 0) { -@@ -906,7 +906,6 @@ static int detect_cpu_l3(int cpu) - */ - static int detect_lpm_cpus_l3(void) - { -- char path[MAX_STR_LENGTH]; - int i; - - for (i = 0; i < topo_max_cpus; i++) { diff --git a/29.patch b/29.patch deleted file mode 100644 index 12d875e..0000000 --- a/29.patch +++ /dev/null @@ -1,314 +0,0 @@ -From 32ff889c57597fb0c1161ce4a380d333a8efc024 Mon Sep 17 00:00:00 2001 -From: Kate Hsuan -Date: Fri, 7 Jun 2024 10:46:31 +0800 -Subject: [PATCH 1/3] lpmd_dbus_server: Drop the codes for dbus-glib - -dbus-glib was deprecated so the related codes can be removed. ---- - src/lpmd.h | 3 --- - src/lpmd_dbus_server.c | 54 ------------------------------------------ - 2 files changed, 57 deletions(-) - -diff --git a/src/lpmd.h b/src/lpmd.h -index 12661f6..55aced3 100644 ---- a/src/lpmd.h -+++ b/src/lpmd.h -@@ -45,9 +45,6 @@ - - #ifdef GLIB_SUPPORT - #include --#include --#include --#include - #include - #include - -diff --git a/src/lpmd_dbus_server.c b/src/lpmd_dbus_server.c -index 15364db..ae4fa55 100644 ---- a/src/lpmd_dbus_server.c -+++ b/src/lpmd_dbus_server.c -@@ -56,7 +56,6 @@ dbus_interface_s_uv__mo_de__en_te_r(PrefObject *obj, GError **error); - static gboolean - dbus_interface_s_uv__mo_de__ex_it(PrefObject *obj, GError **error); - --#include "intel_lpmd_dbus_interface.h" - - static gboolean - (*intel_lpmd_dbus_exit_callback)(void); -@@ -71,8 +70,6 @@ static void pref_object_init(PrefObject *obj) - static void pref_object_class_init(PrefObjectClass *_class) - { - g_assert (_class != NULL); -- -- dbus_g_object_type_install_info ( PREF_TYPE_OBJECT, &dbus_glib_dbus_interface_object_info); - } - - static gboolean dbus_interface_terminate(PrefObject *obj, GError **error) -@@ -130,7 +127,6 @@ static gboolean dbus_interface_s_uv__mo_de__ex_it(PrefObject *obj, GError **erro - return TRUE; - } - --#ifdef GDBUS - #pragma GCC diagnostic push - - static GDBusInterfaceVTable interface_vtable; -@@ -318,53 +314,3 @@ int intel_dbus_server_init(gboolean (*exit_handler)(void)) { - return LPMD_SUCCESS; - } - #pragma GCC diagnostic pop --#else --int intel_dbus_server_init(gboolean (*exit_handler)(void)) --{ -- DBusGConnection *bus; -- DBusGProxy *bus_proxy; -- GError *error = NULL; -- guint result; -- PrefObject *value_obj; -- -- intel_lpmd_dbus_exit_callback = exit_handler; -- -- bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); -- if (error != NULL) { -- lpmd_log_error ("Couldn't connect to session bus: %s:\n", error->message); -- return LPMD_FATAL_ERROR; -- } -- -- // Get a bus proxy instance -- bus_proxy = dbus_g_proxy_new_for_name (bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, -- DBUS_INTERFACE_DBUS); -- if (bus_proxy == NULL) { -- lpmd_log_error ("Failed to get a proxy for D-Bus:\n"); -- return LPMD_FATAL_ERROR; -- } -- -- lpmd_log_debug ("Registering the well-known name (%s)\n", INTEL_LPMD_SERVICE_NAME); -- // register the well-known name -- if (!dbus_g_proxy_call (bus_proxy, "RequestName", &error, G_TYPE_STRING, -- INTEL_LPMD_SERVICE_NAME, G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, -- &result, G_TYPE_INVALID)) { -- lpmd_log_error ("D-Bus.RequestName RPC failed: %s\n", error->message); -- return LPMD_FATAL_ERROR; -- } -- lpmd_log_debug ("RequestName returned %d.\n", result); -- if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { -- lpmd_log_error ("Failed to get the primary well-known name:\n"); -- return LPMD_FATAL_ERROR; -- } -- value_obj = (PrefObject*) g_object_new (PREF_TYPE_OBJECT, NULL); -- if (value_obj == NULL) { -- lpmd_log_error ("Failed to create one Value instance:\n"); -- return LPMD_FATAL_ERROR; -- } -- -- lpmd_log_debug ("Registering it on the D-Bus.\n"); -- dbus_g_connection_register_g_object (bus, INTEL_LPMD_SERVICE_OBJECT_PATH, G_OBJECT (value_obj)); -- -- return LPMD_SUCCESS; --} --#endif - -From fcd0e2a84deb27c3efa0348a19a3d66ed0c58f64 Mon Sep 17 00:00:00 2001 -From: Kate Hsuan -Date: Fri, 7 Jun 2024 10:50:33 +0800 -Subject: [PATCH 2/3] build: Remove dbus-glib build dependency - -dbus-glib was deprecated so the build dependency can be dropped. ---- - Makefile.am | 7 +------ - configure.ac | 10 ---------- - 2 files changed, 1 insertion(+), 16 deletions(-) - -diff --git a/Makefile.am b/Makefile.am -index 6d7c890..2f92a1a 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -6,7 +6,7 @@ ACLOCAL_AMFLAGS = - - # Global C Flags - AM_CFLAGS = \ -- ${DBUS_CFLAGS} \ -+ ${GLIB_CFLAGS} \ - $(XML_CFLAGS) \ - -DTDRUNDIR=\"$(lpmd_rundir)\" \ - -DTDCONFDIR=\"$(lpmd_confdir)\" \ -@@ -29,7 +29,6 @@ intel_lpmd_CPPFLAGS = \ - - intel_lpmd_includedir = @top_srcdir@ - intel_lpmd_LDADD = \ -- $(DBUS_LIBS) \ - $(GLIB_LIBS) \ - $(LIBNL_LIBS) \ - $(LIBM) \ -@@ -39,7 +38,6 @@ intel_lpmd_LDADD = \ - $(SYSTEMD_LIBS) - - BUILT_SOURCES = \ -- intel_lpmd_dbus_interface.h \ - lpmd-resource.c - - intel_lpmd_SOURCES = \ -@@ -58,9 +56,6 @@ intel_lpmd_SOURCES = \ - man8_MANS = man/intel_lpmd.8 - man5_MANS = man/intel_lpmd_config.xml.5 - --intel_lpmd_dbus_interface.h: $(top_srcdir)/src/intel_lpmd_dbus_interface.xml -- $(AM_V_GEN) dbus-binding-tool --prefix=dbus_interface --mode=glib-server --output=$@ $< -- - lpmd-resource.c: $(top_srcdir)/lpmd-resource.gresource.xml - $(AM_V_GEN) glib-compile-resources --generate-source lpmd-resource.gresource.xml - -diff --git a/configure.ac b/configure.ac -index 2b70a97..39fa352 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -55,18 +55,8 @@ GETTEXT_PACKAGE=intel_lpmd - AC_SUBST(GETTEXT_PACKAGE) - AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package]) - --dnl --dnl Checks for new dbus-glib property access function --dnl --AC_CHECK_LIB([dbus-glib-1], [dbus_glib_global_set_disable_legacy_property_access], ac_have_dg_prop="1", ac_have_dg_prop="0") --AC_DEFINE_UNQUOTED(HAVE_DBUS_GLIB_DISABLE_LEGACY_PROP_ACCESS, $ac_have_dg_prop, [Define if you have a dbus-glib with dbus_glib_global_set_disable_legacy_property_access()]) -- --PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.1 dbus-glib-1 >= 0.94) --AC_SUBST(DBUS_CFLAGS) --AC_SUBST(DBUS_LIBS) - - GLIB_VERSION_DEFINES="-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26" --DBUS_CFLAGS="$DBUS_CFLAGS $GLIB_VERSION_DEFINES" - - PKG_CHECK_MODULES(GLIB, gio-unix-2.0 >= 2.22 gmodule-2.0) - GLIB_CFLAGS="$GLIB_CFLAGS $GLIB_VERSION_DEFINES" - -From 8dc503c7c98a6d28c3d8150f9fa56b6d7bc542fa Mon Sep 17 00:00:00 2001 -From: Kate Hsuan -Date: Fri, 7 Jun 2024 15:55:16 +0800 -Subject: [PATCH 3/3] tools: intel_lpmd_control: Drop dbus-glib from cli - -Deprecate the dbus-glib dependency from cli. Moreover, the cli backend -was switch to GDbus. ---- - tools/Makefile | 7 +++-- - tools/intel_lpmd_control.c | 63 +++++++++++++++++++++++--------------- - 2 files changed, 44 insertions(+), 26 deletions(-) - -diff --git a/tools/Makefile b/tools/Makefile -index 670a74e..642e00d 100755 ---- a/tools/Makefile -+++ b/tools/Makefile -@@ -1,4 +1,7 @@ --CFLAGS_DBUS_GLIB = $(shell pkg-config --cflags --libs dbus-glib-1) -+CFLAGS_GLIB = $(shell pkg-config --cflags --libs glib-2.0) \ -+ $(shell pkg-config --cflags --libs gio-2.0) \ -+ $(shell pkg-config --cflags --libs gobject-2.0) -+ - - bindir ?= /usr/bin - -@@ -7,7 +10,7 @@ CFLAGS ?= -g -Wall -Werror - all: intel_lpmd_control - - intel_lpmd_control: intel_lpmd_control.c -- gcc $< -o $@ $(CFLAGS) $(CFLAGS_DBUS_GLIB) $(LDFLAGS) -+ gcc $< -o $@ $(CFLAGS) $(CFLAGS_GLIB) $(LDFLAGS) - - clean: - rm -f intel_lpmd_control -diff --git a/tools/intel_lpmd_control.c b/tools/intel_lpmd_control.c -index 8d7f1b7..42b78b5 100644 ---- a/tools/intel_lpmd_control.c -+++ b/tools/intel_lpmd_control.c -@@ -21,24 +21,31 @@ - */ - - #include -+#include -+#include - #include - #include --#include -+ -+#include -+#include -+ -+#include -+#include - - #define INTEL_LPMD_SERVICE_NAME "org.freedesktop.intel_lpmd" - #define INTEL_LPMD_SERVICE_OBJECT_PATH "/org/freedesktop/intel_lpmd" - #define INTEL_LPMD_SERVICE_INTERFACE "org.freedesktop.intel_lpmd" - --int main(int argc, char **argv) -+int -+main(int argc, char **argv) - { -+ g_autoptr(GDBusConnection) connection = NULL; -+ g_autoptr (GString) command = NULL; - GError *error = NULL; -- DBusGConnection *bus; -- DBusGProxy *proxy; -- char command[20]; - - if (geteuid () != 0) { -- fprintf (stderr, "Must run as root\n"); -- exit (0); -+ g_warning ("Must run as root"); -+ exit (1); - } - - if (argc < 2) { -@@ -49,28 +56,36 @@ int main(int argc, char **argv) - } - - if (!strncmp (argv[1], "ON", 2)) -- strcpy (command, "LPM_FORCE_ON"); -+ command = g_string_new ("LPM_FORCE_ON"); - else if (!strncmp (argv[1], "OFF", 3)) -- strcpy (command, "LPM_FORCE_OFF"); -+ command = g_string_new ("LPM_FORCE_OFF"); - else if (!strncmp (argv[1], "AUTO", 4)) -- strcpy (command, "LPM_AUTO"); -+ command = g_string_new ("LPM_AUTO"); - else { -- fprintf (stderr, "intel_lpmd_control: Invalid command\n"); -- exit (0); -+ g_warning ("intel_lpmd_control: Invalid command"); -+ exit (1); - } - -- bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); -- if (!bus) { -- g_warning ("Unable to connect to system bus: %s", error->message); -- g_error_free (error); -- } -- -- proxy = dbus_g_proxy_new_for_name (bus, INTEL_LPMD_SERVICE_NAME, -- INTEL_LPMD_SERVICE_OBJECT_PATH, -- INTEL_LPMD_SERVICE_INTERFACE); -+ connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); -+ if (connection == NULL) -+ return FALSE; -+ -+ g_dbus_connection_call_sync (connection, -+ INTEL_LPMD_SERVICE_NAME, -+ INTEL_LPMD_SERVICE_OBJECT_PATH, -+ INTEL_LPMD_SERVICE_INTERFACE, -+ command->str, -+ NULL, -+ NULL, -+ G_DBUS_CALL_FLAGS_NONE, -+ -1, -+ NULL, -+ &error); - -- if (!dbus_g_proxy_call (proxy, command, &error, G_TYPE_INVALID, G_TYPE_INVALID)) { -- g_warning ("Failed to send message: %s", error->message); -- g_error_free (error); -+ if (error != NULL) { -+ g_warning ("Fail on connecting lpmd: %s", error->message); -+ exit (1); - } -+ -+ return 0; - } diff --git a/intel-lpmd.spec b/intel-lpmd.spec index ed073be..26e0b7e 100644 --- a/intel-lpmd.spec +++ b/intel-lpmd.spec @@ -1,7 +1,7 @@ %global daemon_name intel_lpmd Name: intel-lpmd -Version: 0.0.3 +Version: 0.0.6 Release: %autorelease Summary: Intel Low Power Mode Daemon @@ -9,11 +9,8 @@ License: GPL-2.0-or-later URL: https://github.com/intel/intel-lpmd Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz -# https://github.com/intel/intel-lpmd/pull/22 -Patch0: 22.patch -# https://github.com/intel/intel-lpmd/pull/29 -# Drop dbus-glib dependency -Patch1: 29.patch +# Fix compiler error +Patch0: 0001-lpmd_cpu-Fix-compiler-above-array-bound-error.patch ExclusiveArch: x86_64 diff --git a/sources b/sources index 0c912b5..9d90131 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (intel-lpmd-0.0.3.tar.gz) = 1de0ec7ef316d3b8052e487578acb2f70f9d65af866a48ff6fff10528882f619b0700fb986f44f8b6504a0f0a17a40a7e963085d85bc4723ef81e93454e65bfa +SHA512 (intel-lpmd-0.0.6.tar.gz) = b29e4525aa76b169f4d246903f8b3d500d936e14085ba12ce3f31a0c6dfb80bebdd9adfd92ef5db9a5d2ee772c7fe8d6c9662f19de6346ef5354a082b4cb63dc