Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1 | From 399fd3eda3045636a70da438a0fd1406cc332ed1 Mon Sep 17 00:00:00 2001 |
| 2 | From: Chen Qi <Qi.Chen@windriver.com> |
| 3 | Date: Mon, 25 Feb 2019 14:18:21 +0800 |
| 4 | Subject: [PATCH 05/24] src/basic/missing.h: check for missing strndupa |
| 5 | |
| 6 | include missing.h for definition of strndupa |
| 7 | |
| 8 | Upstream-Status: Inappropriate [musl specific] |
| 9 | |
| 10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 11 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 12 | [Rebased for v242] |
| 13 | Signed-off-by: Andrej Valek <andrej.valek@siemens.com> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 14 | --- |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 15 | meson.build | 1 + |
| 16 | src/backlight/backlight.c | 1 + |
| 17 | src/basic/env-util.c | 1 + |
| 18 | src/basic/missing_stdlib.h | 12 ++++++++++++ |
| 19 | src/basic/mkdir.c | 1 + |
| 20 | src/basic/parse-util.c | 1 + |
| 21 | src/basic/proc-cmdline.c | 1 + |
| 22 | src/basic/procfs-util.c | 1 + |
| 23 | src/basic/time-util.c | 1 + |
| 24 | src/core/dbus-cgroup.c | 1 + |
| 25 | src/core/dbus-util.c | 1 + |
| 26 | src/core/kmod-setup.c | 1 + |
| 27 | src/core/service.c | 1 + |
| 28 | src/journal/journalctl.c | 1 + |
| 29 | src/libsystemd/sd-bus/bus-message.c | 1 + |
| 30 | src/libsystemd/sd-bus/bus-objects.c | 1 + |
| 31 | src/libsystemd/sd-bus/test-bus-benchmark.c | 1 + |
| 32 | src/locale/keymap-util.c | 1 + |
| 33 | src/nspawn/nspawn-settings.c | 1 + |
| 34 | src/shared/dns-domain.c | 1 + |
| 35 | src/shared/journal-importer.c | 1 + |
| 36 | src/shared/logs-show.c | 1 + |
| 37 | src/shared/pager.c | 1 + |
| 38 | src/shared/path-lookup.c | 1 + |
| 39 | src/shared/uid-range.c | 1 + |
| 40 | src/socket-proxy/socket-proxyd.c | 1 + |
| 41 | src/test/test-hexdecoct.c | 1 + |
| 42 | src/udev/udev-builtin-path_id.c | 1 + |
| 43 | src/udev/udev-rules.c | 1 + |
| 44 | 29 files changed, 40 insertions(+) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 45 | |
| 46 | diff --git a/meson.build b/meson.build |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 47 | index 79195c9..80d9564 100644 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 48 | --- a/meson.build |
| 49 | +++ b/meson.build |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 50 | @@ -572,6 +572,7 @@ foreach ident : [ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 51 | #include <unistd.h>'''], |
| 52 | ['explicit_bzero' , '''#include <string.h>'''], |
| 53 | ['reallocarray', '''#include <malloc.h>'''], |
| 54 | + ['strndupa' , '''#include <string.h>'''], |
| 55 | ] |
| 56 | |
| 57 | have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE') |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 58 | diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c |
| 59 | index dfd6805..c2b2ace 100644 |
| 60 | --- a/src/backlight/backlight.c |
| 61 | +++ b/src/backlight/backlight.c |
| 62 | @@ -17,6 +17,7 @@ |
| 63 | #include "string-util.h" |
| 64 | #include "strv.h" |
| 65 | #include "util.h" |
| 66 | +#include "missing.h" |
| 67 | |
| 68 | static int find_pci_or_platform_parent(sd_device *device, sd_device **ret) { |
| 69 | const char *subsystem, *sysname, *value; |
| 70 | diff --git a/src/basic/env-util.c b/src/basic/env-util.c |
| 71 | index fd449dc..e2b0722 100644 |
| 72 | --- a/src/basic/env-util.c |
| 73 | +++ b/src/basic/env-util.c |
| 74 | @@ -16,6 +16,7 @@ |
| 75 | #include "string-util.h" |
| 76 | #include "strv.h" |
| 77 | #include "utf8.h" |
| 78 | +#include "missing.h" |
| 79 | |
| 80 | #define VALID_CHARS_ENV_NAME \ |
| 81 | DIGITS LETTERS \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 82 | diff --git a/src/basic/missing_stdlib.h b/src/basic/missing_stdlib.h |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 83 | index 188a8d4..1e16ec2 100644 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 84 | --- a/src/basic/missing_stdlib.h |
| 85 | +++ b/src/basic/missing_stdlib.h |
| 86 | @@ -11,3 +11,15 @@ |
| 87 | # define secure_getenv getenv |
| 88 | # endif |
| 89 | #endif |
| 90 | + |
| 91 | +/* string.h */ |
| 92 | +#if ! HAVE_STRNDUPA |
| 93 | +#define strndupa(s, n) \ |
| 94 | + ({ \ |
| 95 | + const char *__old = (s); \ |
| 96 | + size_t __len = strnlen(__old, (n)); \ |
| 97 | + char *__new = (char *)alloca(__len + 1); \ |
| 98 | + __new[__len] = '\0'; \ |
| 99 | + (char *)memcpy(__new, __old, __len); \ |
| 100 | + }) |
| 101 | +#endif |
| 102 | diff --git a/src/basic/mkdir.c b/src/basic/mkdir.c |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 103 | index 6b82eab..51c6b78 100644 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 104 | --- a/src/basic/mkdir.c |
| 105 | +++ b/src/basic/mkdir.c |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 106 | @@ -14,6 +14,7 @@ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 107 | #include "stat-util.h" |
| 108 | #include "stdio-util.h" |
| 109 | #include "user-util.h" |
| 110 | +#include "missing.h" |
| 111 | |
| 112 | int mkdir_safe_internal(const char *path, mode_t mode, uid_t uid, gid_t gid, MkdirFlags flags, mkdir_func_t _mkdir) { |
| 113 | struct stat st; |
| 114 | diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c |
| 115 | index 87724af..d9c53bc 100644 |
| 116 | --- a/src/basic/parse-util.c |
| 117 | +++ b/src/basic/parse-util.c |
| 118 | @@ -19,6 +19,7 @@ |
| 119 | #include "process-util.h" |
| 120 | #include "stat-util.h" |
| 121 | #include "string-util.h" |
| 122 | +#include "missing.h" |
| 123 | |
| 124 | int parse_boolean(const char *v) { |
| 125 | if (!v) |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 126 | diff --git a/src/basic/proc-cmdline.c b/src/basic/proc-cmdline.c |
| 127 | index 1670001..b51feaa 100644 |
| 128 | --- a/src/basic/proc-cmdline.c |
| 129 | +++ b/src/basic/proc-cmdline.c |
| 130 | @@ -15,6 +15,7 @@ |
| 131 | #include "string-util.h" |
| 132 | #include "util.h" |
| 133 | #include "virt.h" |
| 134 | +#include "missing.h" |
| 135 | |
| 136 | int proc_cmdline(char **ret) { |
| 137 | const char *e; |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 138 | diff --git a/src/basic/procfs-util.c b/src/basic/procfs-util.c |
| 139 | index 7aaf95b..42ce53d 100644 |
| 140 | --- a/src/basic/procfs-util.c |
| 141 | +++ b/src/basic/procfs-util.c |
| 142 | @@ -11,6 +11,7 @@ |
| 143 | #include "procfs-util.h" |
| 144 | #include "stdio-util.h" |
| 145 | #include "string-util.h" |
| 146 | +#include "missing.h" |
| 147 | |
| 148 | int procfs_tasks_get_limit(uint64_t *ret) { |
| 149 | _cleanup_free_ char *value = NULL; |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 150 | diff --git a/src/basic/time-util.c b/src/basic/time-util.c |
| 151 | index daf952b..374b97f 100644 |
| 152 | --- a/src/basic/time-util.c |
| 153 | +++ b/src/basic/time-util.c |
| 154 | @@ -28,6 +28,7 @@ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 155 | #include "string-util.h" |
| 156 | #include "strv.h" |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 157 | #include "time-util.h" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 158 | +#include "missing.h" |
| 159 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 160 | static clockid_t map_clock_id(clockid_t c) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 161 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 162 | diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c |
| 163 | index 4615aea..bc1364f 100644 |
| 164 | --- a/src/core/dbus-cgroup.c |
| 165 | +++ b/src/core/dbus-cgroup.c |
| 166 | @@ -15,6 +15,7 @@ |
| 167 | #include "fileio.h" |
| 168 | #include "limits-util.h" |
| 169 | #include "path-util.h" |
| 170 | +#include "missing.h" |
| 171 | |
| 172 | static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_cgroup_device_policy, cgroup_device_policy, CGroupDevicePolicy); |
| 173 | |
| 174 | diff --git a/src/core/dbus-util.c b/src/core/dbus-util.c |
| 175 | index f4fbb72..0a1e3b5 100644 |
| 176 | --- a/src/core/dbus-util.c |
| 177 | +++ b/src/core/dbus-util.c |
| 178 | @@ -7,6 +7,7 @@ |
| 179 | #include "unit-printf.h" |
| 180 | #include "user-util.h" |
| 181 | #include "unit.h" |
| 182 | +#include "missing.h" |
| 183 | |
| 184 | int bus_property_get_triggered_unit( |
| 185 | sd_bus *bus, |
| 186 | diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c |
| 187 | index a91cfeb..a459610 100644 |
| 188 | --- a/src/core/kmod-setup.c |
| 189 | +++ b/src/core/kmod-setup.c |
| 190 | @@ -11,6 +11,7 @@ |
| 191 | #include "kmod-setup.h" |
| 192 | #include "macro.h" |
| 193 | #include "string-util.h" |
| 194 | +#include "missing.h" |
| 195 | |
| 196 | #if HAVE_KMOD |
| 197 | #include <libkmod.h> |
| 198 | diff --git a/src/core/service.c b/src/core/service.c |
| 199 | index 0289990..0e725b5 100644 |
| 200 | --- a/src/core/service.c |
| 201 | +++ b/src/core/service.c |
| 202 | @@ -42,6 +42,7 @@ |
| 203 | #include "unit.h" |
| 204 | #include "utf8.h" |
| 205 | #include "util.h" |
| 206 | +#include "missing.h" |
| 207 | |
| 208 | static const UnitActiveState state_translation_table[_SERVICE_STATE_MAX] = { |
| 209 | [SERVICE_DEAD] = UNIT_INACTIVE, |
| 210 | diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c |
| 211 | index 0048909..0e85eb7 100644 |
| 212 | --- a/src/journal/journalctl.c |
| 213 | +++ b/src/journal/journalctl.c |
| 214 | @@ -67,6 +67,7 @@ |
| 215 | #include "tmpfile-util.h" |
| 216 | #include "unit-name.h" |
| 217 | #include "user-util.h" |
| 218 | +#include "missing.h" |
| 219 | |
| 220 | #define DEFAULT_FSS_INTERVAL_USEC (15*USEC_PER_MINUTE) |
| 221 | |
| 222 | diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c |
| 223 | index 427d42f..b050568 100644 |
| 224 | --- a/src/libsystemd/sd-bus/bus-message.c |
| 225 | +++ b/src/libsystemd/sd-bus/bus-message.c |
| 226 | @@ -21,6 +21,7 @@ |
| 227 | #include "strv.h" |
| 228 | #include "time-util.h" |
| 229 | #include "utf8.h" |
| 230 | +#include "missing.h" |
| 231 | |
| 232 | static int message_append_basic(sd_bus_message *m, char type, const void *p, const void **stored); |
| 233 | |
| 234 | diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c |
| 235 | index d9fc256..e9c6932 100644 |
| 236 | --- a/src/libsystemd/sd-bus/bus-objects.c |
| 237 | +++ b/src/libsystemd/sd-bus/bus-objects.c |
| 238 | @@ -13,6 +13,7 @@ |
| 239 | #include "set.h" |
| 240 | #include "string-util.h" |
| 241 | #include "strv.h" |
| 242 | +#include "missing.h" |
| 243 | |
| 244 | static int node_vtable_get_userdata( |
| 245 | sd_bus *bus, |
| 246 | diff --git a/src/libsystemd/sd-bus/test-bus-benchmark.c b/src/libsystemd/sd-bus/test-bus-benchmark.c |
| 247 | index 8de0a85..4fd0a2e 100644 |
| 248 | --- a/src/libsystemd/sd-bus/test-bus-benchmark.c |
| 249 | +++ b/src/libsystemd/sd-bus/test-bus-benchmark.c |
| 250 | @@ -14,6 +14,7 @@ |
| 251 | #include "missing_resource.h" |
| 252 | #include "time-util.h" |
| 253 | #include "util.h" |
| 254 | +#include "missing.h" |
| 255 | |
| 256 | #define MAX_SIZE (2*1024*1024) |
| 257 | |
| 258 | diff --git a/src/locale/keymap-util.c b/src/locale/keymap-util.c |
| 259 | index b8bd181..fe0cae0 100644 |
| 260 | --- a/src/locale/keymap-util.c |
| 261 | +++ b/src/locale/keymap-util.c |
| 262 | @@ -23,6 +23,7 @@ |
| 263 | #include "string-util.h" |
| 264 | #include "strv.h" |
| 265 | #include "tmpfile-util.h" |
| 266 | +#include "missing.h" |
| 267 | |
| 268 | static bool startswith_comma(const char *s, const char *prefix) { |
| 269 | s = startswith(s, prefix); |
| 270 | diff --git a/src/nspawn/nspawn-settings.c b/src/nspawn/nspawn-settings.c |
| 271 | index 476cb07..91e28de 100644 |
| 272 | --- a/src/nspawn/nspawn-settings.c |
| 273 | +++ b/src/nspawn/nspawn-settings.c |
| 274 | @@ -16,6 +16,7 @@ |
| 275 | #include "strv.h" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 276 | #include "user-util.h" |
| 277 | #include "util.h" |
| 278 | +#include "missing.h" |
| 279 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 280 | Settings *settings_new(void) { |
| 281 | Settings *s; |
| 282 | diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c |
| 283 | index 4b31cb3..989ebf3 100644 |
| 284 | --- a/src/shared/dns-domain.c |
| 285 | +++ b/src/shared/dns-domain.c |
| 286 | @@ -24,6 +24,7 @@ |
| 287 | #include "string-util.h" |
| 288 | #include "strv.h" |
| 289 | #include "utf8.h" |
| 290 | +#include "missing.h" |
| 291 | |
| 292 | int dns_label_unescape(const char **name, char *dest, size_t sz, DNSLabelFlags flags) { |
| 293 | const char *n; |
| 294 | diff --git a/src/shared/journal-importer.c b/src/shared/journal-importer.c |
| 295 | index 8638cd3..d03774a 100644 |
| 296 | --- a/src/shared/journal-importer.c |
| 297 | +++ b/src/shared/journal-importer.c |
| 298 | @@ -13,6 +13,7 @@ |
| 299 | #include "parse-util.h" |
| 300 | #include "string-util.h" |
| 301 | #include "unaligned.h" |
| 302 | +#include "missing.h" |
| 303 | |
| 304 | enum { |
| 305 | IMPORTER_STATE_LINE = 0, /* waiting to read, or reading line */ |
| 306 | diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c |
| 307 | index 5fb736f..19cb165 100644 |
| 308 | --- a/src/shared/logs-show.c |
| 309 | +++ b/src/shared/logs-show.c |
| 310 | @@ -38,6 +38,7 @@ |
| 311 | #include "time-util.h" |
| 312 | #include "utf8.h" |
| 313 | #include "util.h" |
| 314 | +#include "missing.h" |
| 315 | |
| 316 | /* up to three lines (each up to 100 characters) or 300 characters, whichever is less */ |
| 317 | #define PRINT_LINE_THRESHOLD 3 |
| 318 | diff --git a/src/shared/pager.c b/src/shared/pager.c |
| 319 | index 2abb0f6..a00c95f 100644 |
| 320 | --- a/src/shared/pager.c |
| 321 | +++ b/src/shared/pager.c |
| 322 | @@ -25,6 +25,7 @@ |
| 323 | #include "strv.h" |
| 324 | #include "terminal-util.h" |
| 325 | #include "util.h" |
| 326 | +#include "missing.h" |
| 327 | |
| 328 | static pid_t pager_pid = 0; |
| 329 | |
| 330 | diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c |
| 331 | index 442fde7..0eb1188 100644 |
| 332 | --- a/src/shared/path-lookup.c |
| 333 | +++ b/src/shared/path-lookup.c |
| 334 | @@ -20,6 +20,7 @@ |
| 335 | #include "tmpfile-util.h" |
| 336 | #include "user-util.h" |
| 337 | #include "util.h" |
| 338 | +#include "missing.h" |
| 339 | |
| 340 | int xdg_user_runtime_dir(char **ret, const char *suffix) { |
| 341 | const char *e; |
| 342 | diff --git a/src/shared/uid-range.c b/src/shared/uid-range.c |
| 343 | index 7cb7d8a..8b12b91 100644 |
| 344 | --- a/src/shared/uid-range.c |
| 345 | +++ b/src/shared/uid-range.c |
| 346 | @@ -9,6 +9,7 @@ |
| 347 | #include "sort-util.h" |
| 348 | #include "uid-range.h" |
| 349 | #include "user-util.h" |
| 350 | +#include "missing.h" |
| 351 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 352 | static bool uid_range_intersect(UidRange *range, uid_t start, uid_t nr) { |
| 353 | assert(range); |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 354 | diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c |
| 355 | index abbbc9f..6179b58 100644 |
| 356 | --- a/src/socket-proxy/socket-proxyd.c |
| 357 | +++ b/src/socket-proxy/socket-proxyd.c |
| 358 | @@ -28,6 +28,7 @@ |
| 359 | #include "socket-util.h" |
| 360 | #include "string-util.h" |
| 361 | #include "util.h" |
| 362 | +#include "missing.h" |
| 363 | |
| 364 | #define BUFFER_SIZE (256 * 1024) |
| 365 | |
| 366 | diff --git a/src/test/test-hexdecoct.c b/src/test/test-hexdecoct.c |
| 367 | index 5221742..a05e778 100644 |
| 368 | --- a/src/test/test-hexdecoct.c |
| 369 | +++ b/src/test/test-hexdecoct.c |
| 370 | @@ -6,6 +6,7 @@ |
| 371 | #include "hexdecoct.h" |
| 372 | #include "macro.h" |
| 373 | #include "string-util.h" |
| 374 | +#include "missing.h" |
| 375 | |
| 376 | static void test_hexchar(void) { |
| 377 | assert_se(hexchar(0xa) == 'a'); |
| 378 | diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c |
| 379 | index 7ce1c56..cc19b8e 100644 |
| 380 | --- a/src/udev/udev-builtin-path_id.c |
| 381 | +++ b/src/udev/udev-builtin-path_id.c |
| 382 | @@ -23,6 +23,7 @@ |
| 383 | #include "strv.h" |
| 384 | #include "sysexits.h" |
| 385 | #include "udev-builtin.h" |
| 386 | +#include "missing.h" |
| 387 | |
| 388 | _printf_(2,3) |
| 389 | static void path_prepend(char **path, const char *fmt, ...) { |
| 390 | diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c |
| 391 | index ee87d7c..9aced10 100644 |
| 392 | --- a/src/udev/udev-rules.c |
| 393 | +++ b/src/udev/udev-rules.c |
| 394 | @@ -40,6 +40,7 @@ |
| 395 | #include "udev.h" |
| 396 | #include "user-util.h" |
| 397 | #include "util.h" |
| 398 | +#include "missing.h" |
| 399 | |
| 400 | #define PREALLOC_TOKEN 2048 |
| 401 | #define RULES_DIRS (const char* const*) CONF_PATHS_STRV("udev/rules.d") |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 402 | -- |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 403 | 2.11.0 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 404 | |