summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd/0001-Use-uintmax_t-for-handling-rlim_t.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0001-Use-uintmax_t-for-handling-rlim_t.patch')
-rw-r--r--meta/recipes-core/systemd/systemd/0001-Use-uintmax_t-for-handling-rlim_t.patch89
1 files changed, 89 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0001-Use-uintmax_t-for-handling-rlim_t.patch b/meta/recipes-core/systemd/systemd/0001-Use-uintmax_t-for-handling-rlim_t.patch
new file mode 100644
index 0000000000..779dc78fd3
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0001-Use-uintmax_t-for-handling-rlim_t.patch
@@ -0,0 +1,89 @@
1From b2d4171c6e521cf1e70331fb769234d63a4a6d44 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 27 Oct 2017 13:00:41 -0700
4Subject: [PATCH] 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
18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19---
20Upstream-Status: Submitted [https://github.com/systemd/systemd/pull/7199]
21
22 src/basic/format-util.h | 8 --------
23 src/basic/rlimit-util.c | 8 ++++----
24 src/core/execute.c | 8 ++++----
25 3 files changed, 8 insertions(+), 16 deletions(-)
26
27diff --git a/src/basic/format-util.h b/src/basic/format-util.h
28index ae42a8f89..144249cd6 100644
29--- a/src/basic/format-util.h
30+++ b/src/basic/format-util.h
31@@ -60,14 +60,6 @@
32 # define PRI_TIMEX "li"
33 #endif
34
35-#if SIZEOF_RLIM_T == 8
36-# define RLIM_FMT "%" PRIu64
37-#elif SIZEOF_RLIM_T == 4
38-# define RLIM_FMT "%" PRIu32
39-#else
40-# error Unknown rlim_t size
41-#endif
42-
43 #if SIZEOF_DEV_T == 8
44 # define DEV_FMT "%" PRIu64
45 #elif SIZEOF_DEV_T == 4
46diff --git a/src/basic/rlimit-util.c b/src/basic/rlimit-util.c
47index ca834df62..41fcebb74 100644
48--- a/src/basic/rlimit-util.c
49+++ b/src/basic/rlimit-util.c
50@@ -284,13 +284,13 @@ int rlimit_format(const struct rlimit *rl, char **ret) {
51 if (rl->rlim_cur >= RLIM_INFINITY && rl->rlim_max >= RLIM_INFINITY)
52 s = strdup("infinity");
53 else if (rl->rlim_cur >= RLIM_INFINITY)
54- (void) asprintf(&s, "infinity:" RLIM_FMT, rl->rlim_max);
55+ (void) asprintf(&s, "infinity:%ju", (uintmax_t)rl->rlim_max);
56 else if (rl->rlim_max >= RLIM_INFINITY)
57- (void) asprintf(&s, RLIM_FMT ":infinity", rl->rlim_cur);
58+ (void) asprintf(&s, "%ju:infinity", (uintmax_t)rl->rlim_cur);
59 else if (rl->rlim_cur == rl->rlim_max)
60- (void) asprintf(&s, RLIM_FMT, rl->rlim_cur);
61+ (void) asprintf(&s, "%ju", (uintmax_t)rl->rlim_cur);
62 else
63- (void) asprintf(&s, RLIM_FMT ":" RLIM_FMT, rl->rlim_cur, rl->rlim_max);
64+ (void) asprintf(&s, "%ju:%ju", (uintmax_t)rl->rlim_cur, (uintmax_t)rl->rlim_max);
65
66 if (!s)
67 return -ENOMEM;
68diff --git a/src/core/execute.c b/src/core/execute.c
69index d72e5bf08..d38946002 100644
70--- a/src/core/execute.c
71+++ b/src/core/execute.c
72@@ -3443,10 +3443,10 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
73
74 for (i = 0; i < RLIM_NLIMITS; i++)
75 if (c->rlimit[i]) {
76- fprintf(f, "%s%s: " RLIM_FMT "\n",
77- prefix, rlimit_to_string(i), c->rlimit[i]->rlim_max);
78- fprintf(f, "%s%sSoft: " RLIM_FMT "\n",
79- prefix, rlimit_to_string(i), c->rlimit[i]->rlim_cur);
80+ fprintf(f, "%s%s: %ju\n",
81+ prefix, rlimit_to_string(i), (uintmax_t)c->rlimit[i]->rlim_max);
82+ fprintf(f, "%s%sSoft: %ju\n",
83+ prefix, rlimit_to_string(i), (uintmax_t)c->rlimit[i]->rlim_cur);
84 }
85
86 if (c->ioprio_set) {
87--
882.14.3
89