diff options
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0013-Use-uintmax_t-for-handling-rlim_t.patch')
-rw-r--r-- | meta/recipes-core/systemd/systemd/0013-Use-uintmax_t-for-handling-rlim_t.patch | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0013-Use-uintmax_t-for-handling-rlim_t.patch b/meta/recipes-core/systemd/systemd/0013-Use-uintmax_t-for-handling-rlim_t.patch new file mode 100644 index 0000000000..69b3c15121 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0013-Use-uintmax_t-for-handling-rlim_t.patch | |||
@@ -0,0 +1,90 @@ | |||
1 | From a0ac0cfd90af6431c64d1b276f422a2092d569b3 Mon Sep 17 00:00:00 2001 | ||
2 | From: Chen Qi <Qi.Chen@windriver.com> | ||
3 | Date: Mon, 2 Jul 2018 13:44:21 +0800 | ||
4 | Subject: [PATCH 13/19] Use uintmax_t for handling rlim_t | ||
5 | |||
6 | PRIu{32,64} is not right format to represent rlim_t type | ||
7 | therefore use %ju and typecast the rlim_t variables to | ||
8 | uintmax_t. | ||
9 | |||
10 | Fixes portablility errors like | ||
11 | |||
12 | execute.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 | |||
18 | Upstream-Status: Denied [https://github.com/systemd/systemd/pull/7199] | ||
19 | |||
20 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
21 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
22 | --- | ||
23 | src/basic/format-util.h | 8 -------- | ||
24 | src/basic/rlimit-util.c | 8 ++++---- | ||
25 | src/core/execute.c | 8 ++++---- | ||
26 | 3 files changed, 8 insertions(+), 16 deletions(-) | ||
27 | |||
28 | diff --git a/src/basic/format-util.h b/src/basic/format-util.h | ||
29 | index 160550cd6..61245d1e3 100644 | ||
30 | --- a/src/basic/format-util.h | ||
31 | +++ b/src/basic/format-util.h | ||
32 | @@ -43,14 +43,6 @@ | ||
33 | # define PRI_TIMEX "li" | ||
34 | #endif | ||
35 | |||
36 | -#if SIZEOF_RLIM_T == 8 | ||
37 | -# define RLIM_FMT "%" PRIu64 | ||
38 | -#elif SIZEOF_RLIM_T == 4 | ||
39 | -# define RLIM_FMT "%" PRIu32 | ||
40 | -#else | ||
41 | -# error Unknown rlim_t size | ||
42 | -#endif | ||
43 | - | ||
44 | #if SIZEOF_DEV_T == 8 | ||
45 | # define DEV_FMT "%" PRIu64 | ||
46 | #elif SIZEOF_DEV_T == 4 | ||
47 | diff --git a/src/basic/rlimit-util.c b/src/basic/rlimit-util.c | ||
48 | index be1ba615e..e328ce499 100644 | ||
49 | --- a/src/basic/rlimit-util.c | ||
50 | +++ b/src/basic/rlimit-util.c | ||
51 | @@ -299,13 +299,13 @@ int rlimit_format(const struct rlimit *rl, char **ret) { | ||
52 | if (rl->rlim_cur >= RLIM_INFINITY && rl->rlim_max >= RLIM_INFINITY) | ||
53 | s = strdup("infinity"); | ||
54 | else if (rl->rlim_cur >= RLIM_INFINITY) | ||
55 | - (void) asprintf(&s, "infinity:" RLIM_FMT, rl->rlim_max); | ||
56 | + (void) asprintf(&s, "infinity:%ju", (uintmax_t)rl->rlim_max); | ||
57 | else if (rl->rlim_max >= RLIM_INFINITY) | ||
58 | - (void) asprintf(&s, RLIM_FMT ":infinity", rl->rlim_cur); | ||
59 | + (void) asprintf(&s, "%ju:infinity", (uintmax_t)rl->rlim_cur); | ||
60 | else if (rl->rlim_cur == rl->rlim_max) | ||
61 | - (void) asprintf(&s, RLIM_FMT, rl->rlim_cur); | ||
62 | + (void) asprintf(&s, "%ju", (uintmax_t)rl->rlim_cur); | ||
63 | else | ||
64 | - (void) asprintf(&s, RLIM_FMT ":" RLIM_FMT, rl->rlim_cur, rl->rlim_max); | ||
65 | + (void) asprintf(&s, "%ju:%ju", (uintmax_t)rl->rlim_cur, (uintmax_t)rl->rlim_max); | ||
66 | |||
67 | if (!s) | ||
68 | return -ENOMEM; | ||
69 | diff --git a/src/core/execute.c b/src/core/execute.c | ||
70 | index 8ac69d1a0..efedf3842 100644 | ||
71 | --- a/src/core/execute.c | ||
72 | +++ b/src/core/execute.c | ||
73 | @@ -3976,10 +3976,10 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) { | ||
74 | |||
75 | for (i = 0; i < RLIM_NLIMITS; i++) | ||
76 | if (c->rlimit[i]) { | ||
77 | - fprintf(f, "Limit%s%s: " RLIM_FMT "\n", | ||
78 | - prefix, rlimit_to_string(i), c->rlimit[i]->rlim_max); | ||
79 | - fprintf(f, "Limit%s%sSoft: " RLIM_FMT "\n", | ||
80 | - prefix, rlimit_to_string(i), c->rlimit[i]->rlim_cur); | ||
81 | + fprintf(f, "Limit%s%s: %ju\n", | ||
82 | + prefix, rlimit_to_string(i), (uintmax_t)c->rlimit[i]->rlim_max); | ||
83 | + fprintf(f, "Limit%s%sSoft: %ju\n", | ||
84 | + prefix, rlimit_to_string(i), (uintmax_t)c->rlimit[i]->rlim_cur); | ||
85 | } | ||
86 | |||
87 | if (c->ioprio_set) { | ||
88 | -- | ||
89 | 2.11.0 | ||
90 | |||