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 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 46 | --- a/meson.build |
| 47 | +++ b/meson.build |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 48 | @@ -572,6 +572,7 @@ foreach ident : [ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 49 | #include <unistd.h>'''], |
| 50 | ['explicit_bzero' , '''#include <string.h>'''], |
| 51 | ['reallocarray', '''#include <malloc.h>'''], |
| 52 | + ['strndupa' , '''#include <string.h>'''], |
| 53 | ] |
| 54 | |
| 55 | 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] | 56 | --- a/src/backlight/backlight.c |
| 57 | +++ b/src/backlight/backlight.c |
| 58 | @@ -17,6 +17,7 @@ |
| 59 | #include "string-util.h" |
| 60 | #include "strv.h" |
| 61 | #include "util.h" |
| 62 | +#include "missing.h" |
| 63 | |
| 64 | static int find_pci_or_platform_parent(sd_device *device, sd_device **ret) { |
| 65 | const char *subsystem, *sysname, *value; |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 66 | --- a/src/basic/env-util.c |
| 67 | +++ b/src/basic/env-util.c |
| 68 | @@ -16,6 +16,7 @@ |
| 69 | #include "string-util.h" |
| 70 | #include "strv.h" |
| 71 | #include "utf8.h" |
| 72 | +#include "missing.h" |
| 73 | |
| 74 | #define VALID_CHARS_ENV_NAME \ |
| 75 | DIGITS LETTERS \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 76 | --- a/src/basic/missing_stdlib.h |
| 77 | +++ b/src/basic/missing_stdlib.h |
| 78 | @@ -11,3 +11,15 @@ |
Brad Bishop | c68388fc | 2019-08-26 01:33:31 -0400 | [diff] [blame] | 79 | # error "neither secure_getenv nor __secure_getenv are available" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 80 | # endif |
| 81 | #endif |
| 82 | + |
| 83 | +/* string.h */ |
| 84 | +#if ! HAVE_STRNDUPA |
| 85 | +#define strndupa(s, n) \ |
| 86 | + ({ \ |
| 87 | + const char *__old = (s); \ |
| 88 | + size_t __len = strnlen(__old, (n)); \ |
| 89 | + char *__new = (char *)alloca(__len + 1); \ |
| 90 | + __new[__len] = '\0'; \ |
| 91 | + (char *)memcpy(__new, __old, __len); \ |
| 92 | + }) |
| 93 | +#endif |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 94 | --- a/src/basic/mkdir.c |
| 95 | +++ b/src/basic/mkdir.c |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 96 | @@ -14,6 +14,7 @@ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 97 | #include "stat-util.h" |
| 98 | #include "stdio-util.h" |
| 99 | #include "user-util.h" |
| 100 | +#include "missing.h" |
| 101 | |
| 102 | int mkdir_safe_internal(const char *path, mode_t mode, uid_t uid, gid_t gid, MkdirFlags flags, mkdir_func_t _mkdir) { |
| 103 | struct stat st; |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 104 | --- a/src/basic/parse-util.c |
| 105 | +++ b/src/basic/parse-util.c |
| 106 | @@ -19,6 +19,7 @@ |
| 107 | #include "process-util.h" |
| 108 | #include "stat-util.h" |
| 109 | #include "string-util.h" |
| 110 | +#include "missing.h" |
| 111 | |
| 112 | int parse_boolean(const char *v) { |
| 113 | if (!v) |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 114 | --- a/src/basic/proc-cmdline.c |
| 115 | +++ b/src/basic/proc-cmdline.c |
| 116 | @@ -15,6 +15,7 @@ |
| 117 | #include "string-util.h" |
| 118 | #include "util.h" |
| 119 | #include "virt.h" |
| 120 | +#include "missing.h" |
| 121 | |
| 122 | int proc_cmdline(char **ret) { |
| 123 | const char *e; |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 124 | --- a/src/basic/procfs-util.c |
| 125 | +++ b/src/basic/procfs-util.c |
| 126 | @@ -11,6 +11,7 @@ |
| 127 | #include "procfs-util.h" |
| 128 | #include "stdio-util.h" |
| 129 | #include "string-util.h" |
| 130 | +#include "missing.h" |
| 131 | |
| 132 | int procfs_tasks_get_limit(uint64_t *ret) { |
| 133 | _cleanup_free_ char *value = NULL; |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 134 | --- a/src/basic/time-util.c |
| 135 | +++ b/src/basic/time-util.c |
| 136 | @@ -28,6 +28,7 @@ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 137 | #include "string-util.h" |
| 138 | #include "strv.h" |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 139 | #include "time-util.h" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 140 | +#include "missing.h" |
| 141 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 142 | static clockid_t map_clock_id(clockid_t c) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 143 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 144 | --- a/src/core/dbus-cgroup.c |
| 145 | +++ b/src/core/dbus-cgroup.c |
| 146 | @@ -15,6 +15,7 @@ |
| 147 | #include "fileio.h" |
| 148 | #include "limits-util.h" |
| 149 | #include "path-util.h" |
| 150 | +#include "missing.h" |
| 151 | |
| 152 | static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_cgroup_device_policy, cgroup_device_policy, CGroupDevicePolicy); |
| 153 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 154 | --- a/src/core/dbus-util.c |
| 155 | +++ b/src/core/dbus-util.c |
| 156 | @@ -7,6 +7,7 @@ |
| 157 | #include "unit-printf.h" |
| 158 | #include "user-util.h" |
| 159 | #include "unit.h" |
| 160 | +#include "missing.h" |
| 161 | |
| 162 | int bus_property_get_triggered_unit( |
| 163 | sd_bus *bus, |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 164 | --- a/src/core/kmod-setup.c |
| 165 | +++ b/src/core/kmod-setup.c |
| 166 | @@ -11,6 +11,7 @@ |
| 167 | #include "kmod-setup.h" |
| 168 | #include "macro.h" |
| 169 | #include "string-util.h" |
| 170 | +#include "missing.h" |
| 171 | |
| 172 | #if HAVE_KMOD |
| 173 | #include <libkmod.h> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 174 | --- a/src/core/service.c |
| 175 | +++ b/src/core/service.c |
| 176 | @@ -42,6 +42,7 @@ |
| 177 | #include "unit.h" |
| 178 | #include "utf8.h" |
| 179 | #include "util.h" |
| 180 | +#include "missing.h" |
| 181 | |
| 182 | static const UnitActiveState state_translation_table[_SERVICE_STATE_MAX] = { |
| 183 | [SERVICE_DEAD] = UNIT_INACTIVE, |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 184 | --- a/src/journal/journalctl.c |
| 185 | +++ b/src/journal/journalctl.c |
| 186 | @@ -67,6 +67,7 @@ |
| 187 | #include "tmpfile-util.h" |
| 188 | #include "unit-name.h" |
| 189 | #include "user-util.h" |
| 190 | +#include "missing.h" |
| 191 | |
| 192 | #define DEFAULT_FSS_INTERVAL_USEC (15*USEC_PER_MINUTE) |
| 193 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 194 | --- a/src/libsystemd/sd-bus/bus-message.c |
| 195 | +++ b/src/libsystemd/sd-bus/bus-message.c |
| 196 | @@ -21,6 +21,7 @@ |
| 197 | #include "strv.h" |
| 198 | #include "time-util.h" |
| 199 | #include "utf8.h" |
| 200 | +#include "missing.h" |
| 201 | |
| 202 | static int message_append_basic(sd_bus_message *m, char type, const void *p, const void **stored); |
| 203 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 204 | --- a/src/libsystemd/sd-bus/bus-objects.c |
| 205 | +++ b/src/libsystemd/sd-bus/bus-objects.c |
| 206 | @@ -13,6 +13,7 @@ |
| 207 | #include "set.h" |
| 208 | #include "string-util.h" |
| 209 | #include "strv.h" |
| 210 | +#include "missing.h" |
| 211 | |
| 212 | static int node_vtable_get_userdata( |
| 213 | sd_bus *bus, |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 214 | --- a/src/libsystemd/sd-bus/test-bus-benchmark.c |
| 215 | +++ b/src/libsystemd/sd-bus/test-bus-benchmark.c |
| 216 | @@ -14,6 +14,7 @@ |
| 217 | #include "missing_resource.h" |
| 218 | #include "time-util.h" |
| 219 | #include "util.h" |
| 220 | +#include "missing.h" |
| 221 | |
| 222 | #define MAX_SIZE (2*1024*1024) |
| 223 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 224 | --- a/src/locale/keymap-util.c |
| 225 | +++ b/src/locale/keymap-util.c |
| 226 | @@ -23,6 +23,7 @@ |
| 227 | #include "string-util.h" |
| 228 | #include "strv.h" |
| 229 | #include "tmpfile-util.h" |
| 230 | +#include "missing.h" |
| 231 | |
| 232 | static bool startswith_comma(const char *s, const char *prefix) { |
| 233 | s = startswith(s, prefix); |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 234 | --- a/src/nspawn/nspawn-settings.c |
| 235 | +++ b/src/nspawn/nspawn-settings.c |
| 236 | @@ -16,6 +16,7 @@ |
| 237 | #include "strv.h" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 238 | #include "user-util.h" |
| 239 | #include "util.h" |
| 240 | +#include "missing.h" |
| 241 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 242 | Settings *settings_new(void) { |
| 243 | Settings *s; |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 244 | --- a/src/shared/dns-domain.c |
| 245 | +++ b/src/shared/dns-domain.c |
| 246 | @@ -24,6 +24,7 @@ |
| 247 | #include "string-util.h" |
| 248 | #include "strv.h" |
| 249 | #include "utf8.h" |
| 250 | +#include "missing.h" |
| 251 | |
| 252 | int dns_label_unescape(const char **name, char *dest, size_t sz, DNSLabelFlags flags) { |
| 253 | const char *n; |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 254 | --- a/src/shared/journal-importer.c |
| 255 | +++ b/src/shared/journal-importer.c |
| 256 | @@ -13,6 +13,7 @@ |
| 257 | #include "parse-util.h" |
| 258 | #include "string-util.h" |
| 259 | #include "unaligned.h" |
| 260 | +#include "missing.h" |
| 261 | |
| 262 | enum { |
| 263 | IMPORTER_STATE_LINE = 0, /* waiting to read, or reading line */ |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 264 | --- a/src/shared/logs-show.c |
| 265 | +++ b/src/shared/logs-show.c |
| 266 | @@ -38,6 +38,7 @@ |
| 267 | #include "time-util.h" |
| 268 | #include "utf8.h" |
| 269 | #include "util.h" |
| 270 | +#include "missing.h" |
| 271 | |
| 272 | /* up to three lines (each up to 100 characters) or 300 characters, whichever is less */ |
| 273 | #define PRINT_LINE_THRESHOLD 3 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 274 | --- a/src/shared/pager.c |
| 275 | +++ b/src/shared/pager.c |
| 276 | @@ -25,6 +25,7 @@ |
| 277 | #include "strv.h" |
| 278 | #include "terminal-util.h" |
| 279 | #include "util.h" |
| 280 | +#include "missing.h" |
| 281 | |
| 282 | static pid_t pager_pid = 0; |
| 283 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 284 | --- a/src/shared/path-lookup.c |
| 285 | +++ b/src/shared/path-lookup.c |
| 286 | @@ -20,6 +20,7 @@ |
| 287 | #include "tmpfile-util.h" |
| 288 | #include "user-util.h" |
| 289 | #include "util.h" |
| 290 | +#include "missing.h" |
| 291 | |
| 292 | int xdg_user_runtime_dir(char **ret, const char *suffix) { |
| 293 | const char *e; |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 294 | --- a/src/shared/uid-range.c |
| 295 | +++ b/src/shared/uid-range.c |
| 296 | @@ -9,6 +9,7 @@ |
| 297 | #include "sort-util.h" |
| 298 | #include "uid-range.h" |
| 299 | #include "user-util.h" |
| 300 | +#include "missing.h" |
| 301 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 302 | static bool uid_range_intersect(UidRange *range, uid_t start, uid_t nr) { |
| 303 | assert(range); |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 304 | --- a/src/socket-proxy/socket-proxyd.c |
| 305 | +++ b/src/socket-proxy/socket-proxyd.c |
| 306 | @@ -28,6 +28,7 @@ |
| 307 | #include "socket-util.h" |
| 308 | #include "string-util.h" |
| 309 | #include "util.h" |
| 310 | +#include "missing.h" |
| 311 | |
| 312 | #define BUFFER_SIZE (256 * 1024) |
| 313 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 314 | --- a/src/test/test-hexdecoct.c |
| 315 | +++ b/src/test/test-hexdecoct.c |
| 316 | @@ -6,6 +6,7 @@ |
| 317 | #include "hexdecoct.h" |
| 318 | #include "macro.h" |
| 319 | #include "string-util.h" |
| 320 | +#include "missing.h" |
| 321 | |
| 322 | static void test_hexchar(void) { |
| 323 | assert_se(hexchar(0xa) == 'a'); |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 324 | --- a/src/udev/udev-builtin-path_id.c |
| 325 | +++ b/src/udev/udev-builtin-path_id.c |
| 326 | @@ -23,6 +23,7 @@ |
| 327 | #include "strv.h" |
| 328 | #include "sysexits.h" |
| 329 | #include "udev-builtin.h" |
| 330 | +#include "missing.h" |
| 331 | |
| 332 | _printf_(2,3) |
| 333 | static void path_prepend(char **path, const char *fmt, ...) { |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 334 | --- a/src/udev/udev-rules.c |
| 335 | +++ b/src/udev/udev-rules.c |
| 336 | @@ -40,6 +40,7 @@ |
| 337 | #include "udev.h" |
| 338 | #include "user-util.h" |
| 339 | #include "util.h" |
| 340 | +#include "missing.h" |
| 341 | |
| 342 | #define PREALLOC_TOKEN 2048 |
| 343 | #define RULES_DIRS (const char* const*) CONF_PATHS_STRV("udev/rules.d") |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 344 | --- a/src/login/pam_systemd.c |
| 345 | +++ b/src/login/pam_systemd.c |
| 346 | @@ -27,6 +27,7 @@ |
| 347 | #include "hostname-util.h" |
| 348 | #include "login-util.h" |
| 349 | #include "macro.h" |
| 350 | +#include "missing.h" |
| 351 | #include "parse-util.h" |
| 352 | #include "path-util.h" |
| 353 | #include "process-util.h" |