From 29abb4e1c324fea93912b0a0fce06cfe4088453e Mon Sep 17 00:00:00 2001 From: licunlong Date: Thu, 29 Feb 2024 20:13:25 +0800 Subject: [PATCH] fix the compilation warning caused by misusing const --- ...til-log-more-information-when-runnin.patch | 62 +++++++++---------- systemd.spec | 5 +- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/process-util-log-more-information-when-runnin.patch b/process-util-log-more-information-when-runnin.patch index cb57740..6e0c022 100644 --- a/process-util-log-more-information-when-runnin.patch +++ b/process-util-log-more-information-when-runnin.patch @@ -14,10 +14,10 @@ Subject: [PATCH] process-util: log more information when running 4 files changed, 66 insertions(+) diff --git a/src/basic/process-util.c b/src/basic/process-util.c -index b6bf83c..aaf5e87 100644 +index 4e93c9b..78ad30b 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c -@@ -49,6 +49,7 @@ +@@ -54,6 +54,7 @@ #include "stdio-util.h" #include "string-table.h" #include "string-util.h" @@ -25,11 +25,11 @@ index b6bf83c..aaf5e87 100644 #include "terminal-util.h" #include "user-util.h" #include "utf8.h" -@@ -258,6 +259,36 @@ int get_process_cmdline(pid_t pid, size_t max_columns, ProcessCmdlineFlags flags +@@ -342,6 +343,36 @@ int pidref_get_cmdline_strv(const PidRef *pid, ProcessCmdlineFlags flags, char * return 0; } -+int print_process_cmdline_with_arg(pid_t pid, int argc, char *argv[], char *filter[]) { ++int print_process_cmdline_with_arg(pid_t pid, int argc, char *argv[], const char * const *filter) { + bool is_filtered = false; + int r; + const char *arg_cmdline = "["; @@ -41,7 +41,7 @@ index b6bf83c..aaf5e87 100644 + return r; + } else { + for (int i = 0; i < argc; i++ ) { -+ if (filter && strv_find(filter, argv[i])) { ++ if (filter && strv_find((char * const *) filter, argv[i])) { + is_filtered = true; + break; + } @@ -63,19 +63,19 @@ index b6bf83c..aaf5e87 100644 _cleanup_free_ char *s = NULL, *class = NULL; const char *p; diff --git a/src/basic/process-util.h b/src/basic/process-util.h -index 96da0bb..135386c 100644 +index 060c0c2..d211188 100644 --- a/src/basic/process-util.h +++ b/src/basic/process-util.h -@@ -40,6 +40,7 @@ typedef enum ProcessCmdlineFlags { +@@ -41,6 +41,7 @@ typedef enum ProcessCmdlineFlags { int pid_get_comm(pid_t pid, char **ret); int pidref_get_comm(const PidRef *pid, char **ret); -+int print_process_cmdline_with_arg(pid_t pid, int argc, char *argv[], char *filter[]); ++int print_process_cmdline_with_arg(pid_t pid, int argc, char *argv[], const char * const *filter); int pid_get_cmdline(pid_t pid, size_t max_columns, ProcessCmdlineFlags flags, char **ret); int pidref_get_cmdline(const PidRef *pid, size_t max_columns, ProcessCmdlineFlags flags, char **ret); int pid_get_cmdline_strv(pid_t pid, ProcessCmdlineFlags flags, char ***ret); diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c -index 4e7fd04..6143505 100644 +index dd6f6c9..3b049c7 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -2,6 +2,7 @@ @@ -86,12 +86,12 @@ index 4e7fd04..6143505 100644 #include #include "sd-daemon.h" -@@ -1153,6 +1154,14 @@ static int run(int argc, char *argv[]) { +@@ -1226,6 +1227,14 @@ static int run(int argc, char *argv[]) { _cleanup_(loop_device_unrefp) LoopDevice *loop_device = NULL; _cleanup_(umount_and_freep) char *mounted_dir = NULL; int r; + pid_t ppid; -+ char *filter[] = { ++ const char * const filter[] = { + "status", "show", "cat", + "is-active", "is-failed", "is-enabled", "is-system-running", + "list-units", "list-sockets", "list-timers", "list-dependencies", @@ -101,7 +101,7 @@ index 4e7fd04..6143505 100644 setlocale(LC_ALL, ""); log_setup(); -@@ -1166,6 +1175,9 @@ static int run(int argc, char *argv[]) { +@@ -1239,6 +1248,9 @@ static int run(int argc, char *argv[]) { if (r <= 0) goto finish; @@ -112,33 +112,33 @@ index 4e7fd04..6143505 100644 log_full(arg_no_warn ? LOG_DEBUG : LOG_WARNING, "%s%s/proc/ is not mounted. This is not a supported mode of operation. Please fix\n" diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c -index 1864f8a..3a844cf 100644 +index 957e214..d9e9ab1 100644 --- a/src/test/test-process-util.c +++ b/src/test/test-process-util.c -@@ -798,4 +798,26 @@ static int intro(void) { +@@ -951,4 +951,26 @@ static int intro(void) { return EXIT_SUCCESS; } +TEST(print_process_cmdline_with_arg) { + pid_t pid = getpid(); -+ char *arg_filter_empty[] = {"", NULL}; -+ char *arg_filter_1_in[] = {"status", NULL}; -+ char *arg_filter_1_no[] = {"stop", NULL}; -+ char *arg_filter_2_in[] = {"restart", "status", NULL}; -+ char *arg_filter_2_no[] = {"restart", "stop", NULL}; -+ char *arg_var_1[1] = {"systemctl"}; -+ char *arg_var_10[10] = {"systemctl", "restart", "1", "2", "3", "4", "5", "6", "7", "8"}; -+ char *arg_var_filter[3] = {"systemctl", "status", "dbus.service"}; ++ const char * const arg_filter_empty[] = {"", NULL}; ++ const char * const arg_filter_1_in[] = {"status", NULL}; ++ const char * const arg_filter_1_no[] = {"stop", NULL}; ++ const char * const arg_filter_2_in[] = {"restart", "status", NULL}; ++ const char * const arg_filter_2_no[] = {"restart", "stop", NULL}; ++ const char *arg_var_1[1] = {"systemctl"}; ++ const char *arg_var_10[10] = {"systemctl", "restart", "1", "2", "3", "4", "5", "6", "7", "8"}; ++ const char *arg_var_filter[3] = {"systemctl", "status", "dbus.service"}; + assert_se(print_process_cmdline_with_arg(pid, 0, NULL, NULL) >=0); -+ assert_se(print_process_cmdline_with_arg(pid, 1, arg_var_1, NULL) >= 0); -+ assert_se(print_process_cmdline_with_arg(pid, 10, arg_var_10, NULL) >= 0); -+ assert_se(print_process_cmdline_with_arg(897349, 1, arg_var_1, NULL) < 0); -+ assert_se(print_process_cmdline_with_arg(897349, 10, arg_var_10, NULL) < 0); -+ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_empty) >= 0); -+ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_1_in) >= 0); -+ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_1_no) >= 0); -+ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_2_in) >= 0); -+ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_2_no) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 1, (char **) arg_var_1, NULL) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 10, (char **) arg_var_10, NULL) >= 0); ++ assert_se(print_process_cmdline_with_arg(897349, 1, (char **) arg_var_1, NULL) < 0); ++ assert_se(print_process_cmdline_with_arg(897349, 10, (char **) arg_var_10, NULL) < 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, (char **) arg_var_filter, arg_filter_empty) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, (char **) arg_var_filter, arg_filter_1_in) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, (char **) arg_var_filter, arg_filter_1_no) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, (char **) arg_var_filter, arg_filter_2_in) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, (char **) arg_var_filter, arg_filter_2_no) >= 0); +} + DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro); diff --git a/systemd.spec b/systemd.spec index d6d0d6f..63c25f5 100644 --- a/systemd.spec +++ b/systemd.spec @@ -25,7 +25,7 @@ Name: systemd Url: https://www.freedesktop.org/wiki/Software/systemd Version: 255 -Release: 3 +Release: 4 License: MIT and LGPLv2+ and GPLv2+ Summary: System and Service Manager @@ -1630,6 +1630,9 @@ fi %{_libdir}/security/pam_systemd_loadkey.so %changelog +* Thu Feb 29 2024 licunlong - 255-4 +- fix the compilation warning caused by misusing const + * Wed Feb 28 2024 huyubiao - 255-3 - 1.add cpuset-cgv1 and freezer-cgv1 macros and enabled by default 2.add missing sw_64 macro in prep phase