summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd/0006-Use-uintmax_t-for-handling-rlim_t.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0006-Use-uintmax_t-for-handling-rlim_t.patch')
-rw-r--r--meta/recipes-core/systemd/systemd/0006-Use-uintmax_t-for-handling-rlim_t.patch106
1 files changed, 106 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0006-Use-uintmax_t-for-handling-rlim_t.patch b/meta/recipes-core/systemd/systemd/0006-Use-uintmax_t-for-handling-rlim_t.patch
new file mode 100644
index 0000000000..4be14b72ec
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0006-Use-uintmax_t-for-handling-rlim_t.patch
@@ -0,0 +1,106 @@
1From 96e975a2412a20e5f80bd3ab144057d275eb8597 Mon Sep 17 00:00:00 2001
2From: Chen Qi <Qi.Chen@windriver.com>
3Date: Mon, 25 Feb 2019 15:12:41 +0800
4Subject: [PATCH 06/22] Use uintmax_t for handling rlim_t
5
6PRIu{32,64} is not right format to represent rlim_t type
7therefore use %ju and typecast the rlim_t variables to
8uintmax_t.
9
10Fixes portablility errors like
11
12execute.c:3446:36: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'rlim_t {aka long long unsigned int}' [-Werror=format=]
13| fprintf(f, "%s%s: " RLIM_FMT "\n",
14| ^~~~~~~~
15| prefix, rlimit_to_string(i), c->rlimit[i]->rlim_max);
16| ~~~~~~~~~~~~~~~~~~~~~~
17
18Upstream-Status: Denied [https://github.com/systemd/systemd/pull/7199]
19
20Signed-off-by: Khem Raj <raj.khem@gmail.com>
21[Rebased for v241]
22Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
23---
24 src/basic/format-util.h | 8 +-------
25 src/basic/rlimit-util.c | 12 ++++++------
26 src/core/execute.c | 4 ++--
27 3 files changed, 9 insertions(+), 15 deletions(-)
28
29diff --git a/src/basic/format-util.h b/src/basic/format-util.h
30index 8719df3e29..9becc96066 100644
31--- a/src/basic/format-util.h
32+++ b/src/basic/format-util.h
33@@ -34,13 +34,7 @@ assert_cc(sizeof(gid_t) == sizeof(uint32_t));
34 # error Unknown timex member size
35 #endif
36
37-#if SIZEOF_RLIM_T == 8
38-# define RLIM_FMT "%" PRIu64
39-#elif SIZEOF_RLIM_T == 4
40-# define RLIM_FMT "%" PRIu32
41-#else
42-# error Unknown rlim_t size
43-#endif
44+#define RLIM_FMT "%ju"
45
46 #if SIZEOF_DEV_T == 8
47 # define DEV_FMT "%" PRIu64
48diff --git a/src/basic/rlimit-util.c b/src/basic/rlimit-util.c
49index c1f0b2b974..61c5412582 100644
50--- a/src/basic/rlimit-util.c
51+++ b/src/basic/rlimit-util.c
52@@ -44,7 +44,7 @@ int setrlimit_closest(int resource, const struct rlimit *rlim) {
53 fixed.rlim_max == highest.rlim_max)
54 return 0;
55
56- log_debug("Failed at setting rlimit " RLIM_FMT " for resource RLIMIT_%s. Will attempt setting value " RLIM_FMT " instead.", rlim->rlim_max, rlimit_to_string(resource), fixed.rlim_max);
57+ log_debug("Failed at setting rlimit " RLIM_FMT " for resource RLIMIT_%s. Will attempt setting value " RLIM_FMT " instead.", (uintmax_t)rlim->rlim_max, rlimit_to_string(resource), (uintmax_t)fixed.rlim_max);
58
59 return RET_NERRNO(setrlimit(resource, &fixed));
60 }
61@@ -307,13 +307,13 @@ int rlimit_format(const struct rlimit *rl, char **ret) {
62 if (rl->rlim_cur >= RLIM_INFINITY && rl->rlim_max >= RLIM_INFINITY)
63 r = free_and_strdup(&s, "infinity");
64 else if (rl->rlim_cur >= RLIM_INFINITY)
65- r = asprintf(&s, "infinity:" RLIM_FMT, rl->rlim_max);
66+ r = asprintf(&s, "infinity:" RLIM_FMT, (uintmax_t)rl->rlim_max);
67 else if (rl->rlim_max >= RLIM_INFINITY)
68- r = asprintf(&s, RLIM_FMT ":infinity", rl->rlim_cur);
69+ r = asprintf(&s, RLIM_FMT ":infinity", (uintmax_t)rl->rlim_cur);
70 else if (rl->rlim_cur == rl->rlim_max)
71- r = asprintf(&s, RLIM_FMT, rl->rlim_cur);
72+ r = asprintf(&s, RLIM_FMT, (uintmax_t)rl->rlim_cur);
73 else
74- r = asprintf(&s, RLIM_FMT ":" RLIM_FMT, rl->rlim_cur, rl->rlim_max);
75+ r = asprintf(&s, RLIM_FMT ":" RLIM_FMT, (uintmax_t)rl->rlim_cur, (uintmax_t)rl->rlim_max);
76 if (r < 0)
77 return -ENOMEM;
78
79@@ -422,7 +422,7 @@ int rlimit_nofile_safe(void) {
80 rl.rlim_max = MIN(rl.rlim_max, (rlim_t) read_nr_open());
81 rl.rlim_cur = MIN((rlim_t) FD_SETSIZE, rl.rlim_max);
82 if (setrlimit(RLIMIT_NOFILE, &rl) < 0)
83- return log_debug_errno(errno, "Failed to lower RLIMIT_NOFILE's soft limit to " RLIM_FMT ": %m", rl.rlim_cur);
84+ return log_debug_errno(errno, "Failed to lower RLIMIT_NOFILE's soft limit to " RLIM_FMT ": %m", (uintmax_t)rl.rlim_cur);
85
86 return 1;
87 }
88diff --git a/src/core/execute.c b/src/core/execute.c
89index bd3da0c401..df1870fd2f 100644
90--- a/src/core/execute.c
91+++ b/src/core/execute.c
92@@ -1045,9 +1045,9 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
93 for (unsigned i = 0; i < RLIM_NLIMITS; i++)
94 if (c->rlimit[i]) {
95 fprintf(f, "%sLimit%s: " RLIM_FMT "\n",
96- prefix, rlimit_to_string(i), c->rlimit[i]->rlim_max);
97+ prefix, rlimit_to_string(i), (uintmax_t)c->rlimit[i]->rlim_max);
98 fprintf(f, "%sLimit%sSoft: " RLIM_FMT "\n",
99- prefix, rlimit_to_string(i), c->rlimit[i]->rlim_cur);
100+ prefix, rlimit_to_string(i), (uintmax_t)c->rlimit[i]->rlim_cur);
101 }
102
103 if (c->ioprio_set) {
104--
1052.34.1
106