return memdup_suffix0(p, size * need);
}
+static inline size_t GREEDY_ALLOC_ROUND_UP(size_t l) {
+ size_t m;
+
+ /* Round up allocation sizes a bit to some reasonable, likely larger value. This is supposed to be
+ * used for cases which are likely called in an allocation loop of some form, i.e. that repetitively
+ * grow stuff, for example strv_extend() and suchlike.
+ *
+ * Note the difference to GREEDY_REALLOC() here, as this helper operates on a single size value only,
+ * and rounds up to next multiple of 2, needing no further counter.
+ *
+ * Note the benefits of direct ALIGN_POWER2() usage: type-safety for size_t, sane handling for very
+ * small (i.e. <= 2) and safe handling for very large (i.e. > SSIZE_MAX) values. */
+
+ if (l <= 2)
+ return 2; /* Never allocate less than 2 of something. */
+
+ m = ALIGN_POWER2(l);
+ if (m == 0) /* overflow? */
+ return l;
+
+ return m;
+}
+
void* greedy_realloc(void **p, size_t need, size_t size);
void* greedy_realloc0(void **p, size_t need, size_t size);
void* greedy_realloc_append(void **p, size_t *n_p, const void *from, size_t n_from, size_t size);
#pragma once
#include <endian.h>
+#include <errno.h>
#include "macro.h"
#include <string.h>
#include "arphrd-util.h"
+#include "assert-util.h"
#include "macro.h"
static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <limits.h>
#include <stdio.h>
#include "assert-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <errno.h>
+
#include "alloc-util.h"
#include "capsule-util.h"
#include "path-util.h"
#pragma once
#include <dirent.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdint.h>
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
#include <stdbool.h>
#include "errno-list.h"
#include <string.h>
#include <sys/stat.h>
+#include <sys/sysmacros.h>
#include "alloc-util.h"
#include "chase.h"
#include <inttypes.h>
#include <stdbool.h>
#include <sys/types.h>
+#include <sys/sysmacros.h>
#include "stdio-util.h"
#include <errno.h>
#include <stdbool.h>
+#include "assert-util.h"
#include "macro.h"
#include "path-util.h"
#include <stdio.h>
#include <unistd.h>
+#include "assert-util.h"
#include "macro.h"
#include "string.h"
#include <errno.h>
#include <string.h>
+#include "assert-util.h"
#include "errno-list.h"
#include "macro.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
#include <inttypes.h>
#include <string.h>
PROTECT_ERRNO; \
errno = ABS(value)
+#define return_with_errno(r, err) \
+ do { \
+ errno = ABS(err); \
+ return r; \
+ } while (false)
+
static inline int negative_errno(void) {
/* This helper should be used to shut up gcc if you know 'errno' is
* negative. Instead of "return -errno;", use "return negative_errno();"
return ERRNO_IS_NEG_##name(-ABS(r)); \
}
-assert_cc(INT_MAX <= INTMAX_MAX);
-
/* For send()/recv() or read()/write(). */
static inline bool ERRNO_IS_NEG_TRANSIENT(intmax_t r) {
return IN_SET(r,
#pragma once
#include <dirent.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <string.h>
+#include <sys/sysmacros.h>
#include "hash-funcs.h"
#include "path-util.h"
#include <ctype.h>
#include <errno.h>
+#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <errno.h>
+
+#include "assert-util.h"
#include "ioprio-util.h"
#include "parse-util.h"
#include "string-table.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <errno.h>
+#include <limits.h>
+
#include "alloc-util.h"
#include "iovec-util.h"
#include "iovec-wrapper.h"
#include <errno.h>
#include <stddef.h>
+#include "assert-util.h"
#include "label.h"
#include "macro.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
#include <libintl.h>
#include <locale.h>
#include <stdbool.h>
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
+#include "assert-util.h"
#include "macro.h"
/* Some structures we reference but don't want to pull in headers for */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <assert.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <stdbool.h>
-#include <sys/sysmacros.h>
-#include <sys/types.h>
-
#include "constants.h"
#include "macro-fundamental.h"
/* test harness */
#define EXIT_TEST_SKIP 77
-/* builtins */
-#if __SIZEOF_INT__ == 4
-#define BUILTIN_FFS_U32(x) __builtin_ffs(x);
-#elif __SIZEOF_LONG__ == 4
-#define BUILTIN_FFS_U32(x) __builtin_ffsl(x);
-#else
-#error "neither int nor long are four bytes long?!?"
-#endif
-
static inline uint64_t u64_multiply_safe(uint64_t a, uint64_t b) {
if (_unlikely_(a != 0 && b > (UINT64_MAX / a)))
return 0; /* overflow */
return 1UL << (sizeof(u) * 8 - __builtin_clzl(u - 1UL));
}
-static inline size_t GREEDY_ALLOC_ROUND_UP(size_t l) {
- size_t m;
-
- /* Round up allocation sizes a bit to some reasonable, likely larger value. This is supposed to be
- * used for cases which are likely called in an allocation loop of some form, i.e. that repetitively
- * grow stuff, for example strv_extend() and suchlike.
- *
- * Note the difference to GREEDY_REALLOC() here, as this helper operates on a single size value only,
- * and rounds up to next multiple of 2, needing no further counter.
- *
- * Note the benefits of direct ALIGN_POWER2() usage: type-safety for size_t, sane handling for very
- * small (i.e. <= 2) and safe handling for very large (i.e. > SSIZE_MAX) values. */
-
- if (l <= 2)
- return 2; /* Never allocate less than 2 of something. */
-
- m = ALIGN_POWER2(l);
- if (m == 0) /* overflow? */
- return l;
-
- return m;
-}
-
/*
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
(type*)( (char *)UNIQ_T(A, uniq) - offsetof(type, member) ); \
})
-#define return_with_errno(r, err) \
- do { \
- errno = ABS(err); \
- return r; \
- } while (false)
-
#define PTR_TO_INT(p) ((int) ((intptr_t) (p)))
#define INT_TO_PTR(u) ((void *) ((intptr_t) (u)))
#define PTR_TO_UINT(p) ((unsigned) ((uintptr_t) (p)))
#pragma once
#include <inttypes.h>
+#include <limits.h>
#include <malloc.h>
#include <stdbool.h>
#include <string.h>
#include <stdbool.h>
#include <string.h>
+#include "assert-util.h"
#include "set.h"
#define NULSTR_FOREACH(i, l) \
#include <errno.h>
#include <inttypes.h>
+#include <limits.h>
#include "macro.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
#include <signal.h>
#include "macro.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <limits.h>
#include <sys/time.h>
+#include "assert-util.h"
#include "macro.h"
#include "ratelimit.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <errno.h>
#include <unistd.h>
#include "alloc-util.h"
#include <stdlib.h>
+#include "assert-util.h"
#include "macro.h"
/* This is the same as glibc's internal __compar_d_fn_t type. glibc exports a public comparison_fn_t, for the
#pragma once
+#include <errno.h>
+
#include "macro.h"
#include "memory-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <errno.h>
+
#include "parse-util.h"
#include "string-table.h"
#include "string-util.h"
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
+#include <sys/types.h>
#include "alloc-util.h"
#include "macro.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <limits.h>
#include <syslog.h>
#include "sd-id128.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stddef.h>
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <limits.h>
+
#include "bcd.h"
#include "bootspec-fundamental.h"
#include "console.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <limits.h>
+
#include "efi-string.h"
#if SD_BOOT
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <limits.h>
+
#include "chid.h"
#include "devicetree.h"
#include "efi-firmware.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <limits.h>
+
#include "cpio.h"
#include "device-path-util.h"
#include "devicetree.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include "assert-util.h"
#include "unit-dependency-atom.h"
static const UnitDependencyAtom atom_map[_UNIT_DEPENDENCY_MAX] = {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <limits.h>
#include <stdalign.h>
#include <stdbool.h>
#include <stddef.h>
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
+
#if HAVE_BZIP2
#include <bzlib.h>
#endif
#include <zlib.h>
#include "alloc-util.h"
+#include "assert-util.h"
#include "btrfs-util.h"
#include "qcow2-util.h"
#include "sparse-endian.h"
#include "sd-bus.h"
+#include "assert-util.h"
#include "bus-signature.h"
#include "bus-type.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
+
#include "sd-id128.h"
#include "macro.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <sys/sysmacros.h>
+
#include "alloc-util.h"
#include "devnum-util.h"
#include "env-util.h"
#include "alloc-util.h"
#include "device-private.h"
#include "device-util.h"
+#include "errno-util.h"
#include "libudev-device-internal.h"
#include "libudev-list-internal.h"
#include "parse-util.h"
#include "alloc-util.h"
#include "device-enumerator-private.h"
#include "device-util.h"
+#include "errno-util.h"
#include "libudev-device-internal.h"
#include "libudev-list-internal.h"
#include "sd-hwdb.h"
#include "alloc-util.h"
+#include "assert-util.h"
+#include "errno-util.h"
#include "hwdb-util.h"
#include "libudev-list-internal.h"
#include "log.h"
#include "libudev.h"
#include "alloc-util.h"
+#include "errno-util.h"
#include "fd-util.h"
#include "io-util.h"
#include "udev-util.h"
#include "libudev.h"
#include "alloc-util.h"
+#include "errno-util.h"
#include "fd-util.h"
#include "log.h"
#include "string-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
+
#include "in-addr-util.h"
#include "macro.h"
* Copyright © 2019 VMware, Inc. */
#include "alloc-util.h"
+#include "assert-util.h"
#include "extract-word.h"
#include "fileio.h"
#include "parse-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
+
#include "macro.h"
/* DNS record types, taken from
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
#include <stdbool.h>
#include "dlfcn-util.h"
#if HAVE_BLKID
+#include <errno.h>
+
#include "blkid-util.h"
#include "string-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
#include <linux/if_bonding.h>
#include <netinet/in.h>
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include "assert-util.h"
#include "bus-locator.h"
#include "macro.h"
#include <math.h>
+#include "assert-util.h"
#include "color-util.h"
#include "macro.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/sendfile.h>
+#include <sys/sysmacros.h>
#include <sys/xattr.h>
#include <unistd.h>
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
+#include <pwd.h>
+
#include "macro.h"
typedef enum CoredumpFilter {
#include <errno.h>
#include <stdlib.h>
+#include <sys/sysmacros.h>
#include <unistd.h>
#include "alloc-util.h"
# include <stringprep.h>
#endif
+#include <errno.h>
#include <inttypes.h>
#if HAVE_LIBIDN2 || HAVE_LIBIDN
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
#include <stdbool.h>
#include "macro.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
#include <linux/if_link.h>
#include <netinet/in.h>
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
+
#include "dlfcn-util.h"
#if HAVE_LIBARCHIVE
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
+
#include "iovec-util.h"
#include "macro.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include <errno.h>
+
#include "list.h"
#include "macro.h"
#include "memory-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <errno.h>
+
#include "alloc-util.h"
#include "memory-util.h"
#include "random-util.h"
#include <sys/socket.h>
#include <sys/types.h>
+#include "assert-util.h"
#include "label-util.h"
#include "macro.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
+#include "assert-util.h"
#include "fileio.h"
#include "macro.h"
#include "smbios11.h"
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
+#include <sys/sysmacros.h>
#include "alloc-util.h"
#include "dirent-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sys/file.h>
+#include <sys/sysmacros.h>
#include <unistd.h>
#include "alloc-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <float.h>
+#include <sys/sysmacros.h>
#include "sd-json.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <limits.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>