]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #30634 from dtardon/docbook-valid-3
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 27 Dec 2023 19:06:57 +0000 (04:06 +0900)
committerGitHub <noreply@github.com>
Wed, 27 Dec 2023 19:06:57 +0000 (04:06 +0900)
DocBook validation fixes (part 3)

34 files changed:
coccinelle/log-json.cocci
coccinelle/macros.h [deleted file]
coccinelle/parsing_hacks.h [new file with mode: 0644]
coccinelle/run-coccinelle.sh
coccinelle/zz-drop-braces.cocci
hwdb.d/70-sound-card.hwdb
src/basic/locale-util.c
src/boot/bootctl-install.c
src/core/dbus-execute.c
src/journal-remote/journal-gatewayd.c
src/libsystemd/sd-bus/bus-message.c
src/libsystemd/sd-bus/bus-socket.c
src/libsystemd/sd-bus/sd-bus.c
src/libsystemd/sd-bus/test-bus-objects.c
src/libsystemd/sd-event/sd-event.c
src/modules-load/modules-load.c
src/network/networkd-address.c
src/network/networkd-ndisc.c
src/network/networkd-route.c
src/nspawn/nspawn-oci.c
src/partition/repart.c
src/shared/elf-util.c
src/shared/killall.c
src/shared/pkcs11-util.c
src/shared/tpm2-util.c
src/sleep/sleep.c
src/systemctl/systemctl-edit.c
src/test/test-acl-util.c
src/test/test-mountpoint-util.c
src/test/test-set.c
src/test/test-time-util.c
src/test/test-uid-range.c
src/test/test-xattr-util.c
src/udev/udev-builtin-path_id.c

index d184e5658454efc01597d55d18ec26ea61aa6a6d..c941706c6417133e7e155a711614d175d61056a9 100644 (file)
@@ -3,7 +3,6 @@
 expression e, v, flags;
 expression list args;
 @@
-+ return
 - json_log(v, flags, 0, args);
-+ json_log(v, flags, SYNTHETIC_ERRNO(e), args);
 - return -e;
++ return json_log(v, flags, SYNTHETIC_ERRNO(e), args);
diff --git a/coccinelle/macros.h b/coccinelle/macros.h
deleted file mode 100644 (file)
index adfea5f..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-/*
- * Collected macros from our systemd codebase to make the cocci semantic
- * parser happy. Inspired by the original cocci macros file
- * /usr/lib64/coccinelle/standard.h (including the YACFE_* symbols)
- */
-
-// General
-#define PTR_TO_PID(x)
-
-// src/basic/macro.h
-#define _printf_(a, b) __attribute__((__format__(printf, a, b)))
-#define _alloc_(...) __attribute__((__alloc_size__(__VA_ARGS__)))
-#define _sentinel_ __attribute__((__sentinel__))
-#define _section_(x) __attribute__((__section__(x)))
-#define _used_ __attribute__((__used__))
-#define _unused_ __attribute__((__unused__))
-#define _destructor_ __attribute__((__destructor__))
-#define _pure_ __attribute__((__pure__))
-#define _const_ __attribute__((__const__))
-#define _deprecated_ __attribute__((__deprecated__))
-#define _packed_ __attribute__((__packed__))
-#define _malloc_ __attribute__((__malloc__))
-#define _weak_ __attribute__((__weak__))
-#define _likely_(x) (__builtin_expect(!!(x), 1))
-#define _unlikely_(x) (__builtin_expect(!!(x), 0))
-#define _public_ __attribute__((__visibility__("default")))
-#define _hidden_ __attribute__((__visibility__("hidden")))
-#define _weakref_(x) __attribute__((__weakref__(#x)))
-#define _align_(x) __attribute__((__aligned__(x)))
-#define _alignas_(x) __attribute__((__aligned__(__alignof(x))))
-#define _alignptr_ __attribute__((__aligned__(sizeof(void*))))
-#define _cleanup_(x) __attribute__((__cleanup__(x)))
-#define _fallthrough_
-#define _noreturn_ __attribute__((__noreturn__))
-#define thread_local __thread
-
-#define ELEMENTSOF(x)                                                   \
-        (__builtin_choose_expr(                                         \
-                !__builtin_types_compatible_p(typeof(x), typeof(&*(x))), \
-                sizeof(x)/sizeof((x)[0]),                               \
-                VOID_0))
-
-// src/basic/umask-util.h
-#define _cleanup_umask_
-#define WITH_UMASK(mask)                                            \
-        for (_cleanup_umask_ mode_t _saved_umask_ = umask(mask) | S_IFMT; \
-             FLAGS_SET(_saved_umask_, S_IFMT);                          \
-             _saved_umask_ &= 0777)
-
-// src/basic/hashmap.h
-#define _IDX_ITERATOR_FIRST (UINT_MAX - 1)
-#define HASHMAP_FOREACH(e, h) YACFE_ITERATOR
-#define ORDERED_HASHMAP_FOREACH(e, h) YACFE_ITERATOR
-#define HASHMAP_FOREACH_KEY(e, k, h) YACFE_ITERATOR
-#define ORDERED_HASHMAP_FOREACH_KEY(e, k, h) YACFE_ITERATOR
-
-// src/basic/list.h
-#define LIST_HEAD(t,name)                                               \
-        t *name
-#define LIST_FIELDS(t,name)                                             \
-        t *name##_next, *name##_prev
-#define LIST_HEAD_INIT(head)                                            \
-        do {                                                            \
-                (head) = NULL;                                          \
-        } while (false)
-#define LIST_INIT(name,item)                                            \
-        do {                                                            \
-                typeof(*(item)) *_item = (item);                        \
-                assert(_item);                                          \
-                _item->name##_prev = _item->name##_next = NULL;         \
-        } while (false)
-#define LIST_PREPEND(name,head,item)                                    \
-        do {                                                            \
-                typeof(*(head)) **_head = &(head), *_item = (item);     \
-                assert(_item);                                          \
-                if ((_item->name##_next = *_head))                      \
-                        _item->name##_next->name##_prev = _item;        \
-                _item->name##_prev = NULL;                              \
-                *_head = _item;                                         \
-        } while (false)
-#define LIST_APPEND(name,head,item)                                     \
-        do {                                                            \
-                typeof(*(head)) **_hhead = &(head), *_tail;             \
-                LIST_FIND_TAIL(name, *_hhead, _tail);                   \
-                LIST_INSERT_AFTER(name, *_hhead, _tail, item);          \
-        } while (false)
-#define LIST_REMOVE(name,head,item)                                     \
-        do {                                                            \
-                typeof(*(head)) **_head = &(head), *_item = (item);     \
-                assert(_item);                                          \
-                if (_item->name##_next)                                 \
-                        _item->name##_next->name##_prev = _item->name##_prev; \
-                if (_item->name##_prev)                                 \
-                        _item->name##_prev->name##_next = _item->name##_next; \
-                else {                                                  \
-                        assert(*_head == _item);                        \
-                        *_head = _item->name##_next;                    \
-                }                                                       \
-                _item->name##_next = _item->name##_prev = NULL;         \
-        } while (false)
-#define LIST_FIND_HEAD(name,item,head)                                  \
-        do {                                                            \
-                typeof(*(item)) *_item = (item);                        \
-                if (!_item)                                             \
-                        (head) = NULL;                                  \
-                else {                                                  \
-                        while (_item->name##_prev)                      \
-                                _item = _item->name##_prev;             \
-                        (head) = _item;                                 \
-                }                                                       \
-        } while (false)
-#define LIST_FIND_TAIL(name,item,tail)                                  \
-        do {                                                            \
-                typeof(*(item)) *_item = (item);                        \
-                if (!_item)                                             \
-                        (tail) = NULL;                                  \
-                else {                                                  \
-                        while (_item->name##_next)                      \
-                                _item = _item->name##_next;             \
-                        (tail) = _item;                                 \
-                }                                                       \
-        } while (false)
-#define LIST_INSERT_AFTER(name,head,a,b)                                \
-        do {                                                            \
-                typeof(*(head)) **_head = &(head), *_a = (a), *_b = (b); \
-                assert(_b);                                             \
-                if (!_a) {                                              \
-                        if ((_b->name##_next = *_head))                 \
-                                _b->name##_next->name##_prev = _b;      \
-                        _b->name##_prev = NULL;                         \
-                        *_head = _b;                                    \
-                } else {                                                \
-                        if ((_b->name##_next = _a->name##_next))        \
-                                _b->name##_next->name##_prev = _b;      \
-                        _b->name##_prev = _a;                           \
-                        _a->name##_next = _b;                           \
-                }                                                       \
-        } while (false)
-#define LIST_INSERT_BEFORE(name,head,a,b)                               \
-        do {                                                            \
-                typeof(*(head)) **_head = &(head), *_a = (a), *_b = (b); \
-                assert(_b);                                             \
-                if (!_a) {                                              \
-                        if (!*_head) {                                  \
-                                _b->name##_next = NULL;                 \
-                                _b->name##_prev = NULL;                 \
-                                *_head = _b;                            \
-                        } else {                                        \
-                                typeof(*(head)) *_tail = (head);        \
-                                while (_tail->name##_next)              \
-                                        _tail = _tail->name##_next;     \
-                                _b->name##_next = NULL;                 \
-                                _b->name##_prev = _tail;                \
-                                _tail->name##_next = _b;                \
-                        }                                               \
-                } else {                                                \
-                        if ((_b->name##_prev = _a->name##_prev))        \
-                                _b->name##_prev->name##_next = _b;      \
-                        else                                            \
-                                *_head = _b;                            \
-                        _b->name##_next = _a;                           \
-                        _a->name##_prev = _b;                           \
-                }                                                       \
-        } while (false)
-
-#define LIST_JUST_US(name,item)                                         \
-        (!(item)->name##_prev && !(item)->name##_next)
-#define LIST_FOREACH(name,i,head)                                       \
-        for ((i) = (head); (i); (i) = (i)->name##_next)
-#define LIST_FOREACH_SAFE(name,i,n,head)                                \
-        for ((i) = (head); (i) && (((n) = (i)->name##_next), 1); (i) = (n))
-#define LIST_FOREACH_BEFORE(name,i,p)                                   \
-        for ((i) = (p)->name##_prev; (i); (i) = (i)->name##_prev)
-#define LIST_FOREACH_AFTER(name,i,p)                                    \
-        for ((i) = (p)->name##_next; (i); (i) = (i)->name##_next)
-#define LIST_FOREACH_OTHERS(name,i,p)                                   \
-        for (({                                                         \
-                (i) = (p);                                              \
-                while ((i) && (i)->name##_prev)                         \
-                        (i) = (i)->name##_prev;                         \
-                if ((i) == (p))                                         \
-                        (i) = (p)->name##_next;                         \
-             });                                                        \
-             (i);                                                       \
-             (i) = (i)->name##_next == (p) ? (p)->name##_next : (i)->name##_next)
-#define LIST_LOOP_BUT_ONE(name,i,head,p)                                \
-        for ((i) = (p)->name##_next ? (p)->name##_next : (head);        \
-             (i) != (p);                                                \
-             (i) = (i)->name##_next ? (i)->name##_next : (head))
-
-#define LIST_JOIN(name,a,b)                                             \
-        do {                                                            \
-                assert(b);                                              \
-                if (!(a))                                               \
-                        (a) = (b);                                      \
-                else {                                                  \
-                        typeof(*(a)) *_head = (b), *_tail;              \
-                        LIST_FIND_TAIL(name, (a), _tail);               \
-                        _tail->name##_next = _head;                     \
-                        _head->name##_prev = _tail;                     \
-                }                                                       \
-                (b) = NULL;                                             \
-        } while (false)
-
-// src/basic/strv.h
-#define STRV_FOREACH(s, l) YACFE_ITERATOR
-#define STRV_FOREACH_BACKWARDS(s, l) YACFE_ITERATOR
-#define STRV_FOREACH_PAIR(x, y, l) YACFE_ITERATOR
-
-// src/basic/socket-util.h
-#define CMSG_BUFFER_TYPE(size)                                          \
-        union {                                                         \
-                struct cmsghdr cmsghdr;                                 \
-                uint8_t buf[size];                                      \
-                uint8_t align_check[(size) >= CMSG_SPACE(0) &&          \
-                                    (size) == CMSG_ALIGN(size) ? 1 : -1]; \
-        }
-
-// src/libsystemd/sd-device/device-util.h
-#define FOREACH_DEVICE_PROPERTY(device, key, value) YACFE_ITERATOR
-#define FOREACH_DEVICE_TAG(device, tag) YACFE_ITERATOR
-#define FOREACH_DEVICE_CURRENT_TAG(device, tag) YACFE_ITERATOR
-#define FOREACH_DEVICE_SYSATTR(device, attr) YACFE_ITERATOR
-#define FOREACH_DEVICE_DEVLINK(device, devlink) YACFE_ITERATOR
-#define FOREACH_DEVICE(enumerator, device) YACFE_ITERATOR
-#define FOREACH_SUBSYSTEM(enumerator, device) YACFE_ITERATOR
-
-// src/basic/dirent-util.h
-#define FOREACH_DIRENT(de, d, on_error) YACFE_ITERATOR
-#define FOREACH_DIRENT_ALL(de, d, on_error) YACFE_ITERATOR
diff --git a/coccinelle/parsing_hacks.h b/coccinelle/parsing_hacks.h
new file mode 100644 (file)
index 0000000..e16aa9f
--- /dev/null
@@ -0,0 +1,80 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+/* FIXME
+ *  - issues with parsing stuff like
+ *      * int foo[ELEMENTSOF(bar)] = {};
+ *      * validchars = UPPERCASE_LETTERS DIGITS;
+ *      * multiline compound literals (some instances)
+ *      * compound literals in function calls (some instances)
+ *      * keywords in macro invocations like FOREACH_DIRENT_ALL(de, d, return -errno)
+ *        (also, see FIXME in the TEST stuff below)
+ */
+
+/* This file contains parsing hacks for Coccinelle (spatch), to make it happy with some of our more complex
+ * macros - it is intended to be used with the --macro-file-builtins option for spatch.
+ *
+ * Coccinelle's macro support is somewhat limited and the parser trips over some of our more complex macros.
+ * In most cases this doesn't really matter, as the parsing errors are silently ignored, but there are
+ * special cases in which the parser incorrectly infers information that then causes issues in valid code
+ * later down the line.
+ *
+ * Inspired by a similarly named file [0] from the Coccinelle sources, and the original bultin macros [1].
+ *
+ * [0] https://github.com/coccinelle/coccinelle/blob/master/parsing_c/parsing_hacks.ml
+ * [1] https://github.com/coccinelle/coccinelle/blob/master/standard.h
+ *
+ */
+
+/* Coccinelle really doesn't like our way of registering unit test cases, and incorrectly assumes that "id"
+ * from TEST(id) is the actual function identifier. This then causes name conflicts, since the unit tests
+ * are usually named after the functions they test.
+ *
+ * For example, a unit test for xsetxattr() is defined using TEST(xsetxattr), which eventually yields a
+ * procedure with following declaration:
+ *
+ *      static const void test_xsetxattr(void);
+ *
+ * However, Coccinelle fails to parse the chain of macros behind TEST(x) and assumes the test function is
+ * named "xsetxattr", which then causes a name conflict when the actual "xsetxattr" function is called:
+ *
+ * (ONCE) SEMANTIC:parameter name omitted, but I continue
+ * Warning: PARSING: src/test/test-xattr-util.c:57: type defaults to 'int'; ...
+ * ERROR-RECOV: found sync '}' at line 127
+ * Parsing pass2: try again
+ * ERROR-RECOV: found sync '}' at line 127
+ * Parsing pass3: try again
+ * ERROR-RECOV: found sync '}' at line 127
+ * Parse error
+ *  = File "src/test/test-xattr-util.c", line 101, column 12, charpos = 3152
+ *   around = 'xsetxattr',
+ *   whole content =         r = xsetxattr(AT_FDCWD, x, "user.foo", "fullpath", SIZE_MAX, 0);
+ * Badcount: 40
+ *
+ * The easy way out here is to just provide a simplified version of the TEST(x) macro that pinpoints the most
+ * important detail - that the actual function name is prefixed with test_.
+ *
+ * FIXME: even with this Coccinelle still fails to process TEST(x) instances where x is a keyword, e.g.
+ *        TEST(float), TEST(default), ...
+ */
+#define TEST(x, ...) static void test_##x(void)
+#define TEST_RET(x, ...) static int test_##x(void)
+
+/* Coccinelle doesn't know this keyword, so just drop it, since it's not important for any of our rules. */
+#define thread_local
+
+/* Coccinelle fails to get this one from the included headers, so let's just drop it. */
+#define PAM_EXTERN
+
+/* Mark a couple of iterator explicitly as iterators, otherwise Coccinelle gets a bit confused. Coccinelle
+ * can usually infer this information automagically, but in these specific cases it needs a bit of help. */
+#define FOREACH_ARRAY(i, array, num) YACFE_ITERATOR
+#define FOREACH_DIRENT_ALL(de, d, on_error) YACFE_ITERATOR
+#define FOREACH_STRING(x, y, ...) YACFE_ITERATOR
+#define HASHMAP_FOREACH(e, h) YACFE_ITERATOR
+#define LIST_FOREACH(name, i, head) YACFE_ITERATOR
+#define ORDERED_HASHMAP_FOREACH(e, h) YACFE_ITERATOR
+#define SET_FOREACH(e, s) YACFE_ITERATOR
+
+/* Coccinelle really doesn't like multiline macros that are not in the "usual" do { ... } while(0) format, so
+ * let's help it a little here by providing simplified one-line versions. */
+#define CMSG_BUFFER_TYPE(x) union { uint8_t align_check[(size) >= CMSG_SPACE(0) && (size) == CMSG_ALIGN(size) ? 1 : -1]; }
index cd951790b9ddc649b861e24b612714f06150efd9..af5dd359884d4ad6c09f500a09e01ce039f9a289 100755 (executable)
@@ -10,13 +10,17 @@ EXCLUDED_PATHS=(
     # Symlinked to test-bus-vtable-cc.cc, which causes issues with the IN_SET macro
     "src/libsystemd/sd-bus/test-bus-vtable.c"
     "src/libsystemd/sd-journal/lookup3.c"
+    # Ignore man examples, as they redefine some macros we use internally, which makes Coccinelle complain
+    # and ignore code that tries to use the redefined stuff
+    "man/*"
 )
 
 TOP_DIR="$(git rev-parse --show-toplevel)"
+CACHE_DIR="$(dirname "$0")/.coccinelle-cache"
 ARGS=()
 
 # Create an array from files tracked by git...
-mapfile -t FILES < <(git ls-files ':/*.[ch]')
+mapfile -t FILES < <(git ls-files ':/*.c')
 # ...and filter everything that matches patterns from EXCLUDED_PATHS
 for excl in "${EXCLUDED_PATHS[@]}"; do
     # shellcheck disable=SC2206
@@ -37,12 +41,44 @@ fi
 
 [[ ${#@} -ne 0 ]] && SCRIPTS=("$@") || SCRIPTS=("$TOP_DIR"/coccinelle/*.cocci)
 
+mkdir -p "$CACHE_DIR"
+echo "--x-- Using Coccinelle cache directory: $CACHE_DIR"
+echo
+
 for script in "${SCRIPTS[@]}"; do
     echo "--x-- Processing $script --x--"
     TMPFILE="$(mktemp)"
     echo "+ spatch --sp-file $script ${ARGS[*]} ..."
-    parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \
-             spatch --macro-file="$TOP_DIR/coccinelle/macros.h" --smpl-spacing --sp-file "$script" "${ARGS[@]}" ::: "${FILES[@]}" \
-             2>"$TMPFILE" || cat "$TMPFILE"
+    # A couple of notes:
+    #
+    # 1) Limit this to 10 files at once, as processing the ASTs is _very_ memory hungry - e.g. with 20 files
+    # at once one spatch process can take around 2.5 GiB of RAM, which can easily eat up all available RAM
+    # when paired together with parallel
+    #
+    # 2) Make sure spatch can find our includes via -I <dir>, similarly as we do when compiling stuff.
+    #    Also, include the system include path as well, since we're not kernel and we make use of the stdlib
+    #    (and other libraries).
+    #
+    # 3) Make sure to include includes from includes (--recursive-includes), but use them only to get type
+    # definitions (--include-headers-for-types) - otherwise we'd start formatting them as well, which might
+    # be unwanted, especially for includes we fetch verbatim from third-parties
+    #
+    # 4) Explicitly undefine the SD_BOOT symbol, so Coccinelle ignores includes guarded by #if SD_BOOT
+    #
+    # 5) Use cache, since generating the full AST is expensive. With cache we can do that only once and then
+    #    reuse the cached ASTs for other rules. This cuts down the time needed to run each rule by ~60%.
+    parallel --halt now,fail=1 --keep-order --noswap --max-args=10 \
+        spatch --cache-prefix "$CACHE_DIR" \
+               -I src \
+               -I /usr/include \
+               --recursive-includes \
+               --include-headers-for-types \
+               --undefined SD_BOOT \
+               --macro-file-builtins "coccinelle/parsing_hacks.h" \
+               --smpl-spacing \
+               --sp-file "$script" \
+               "${ARGS[@]}" ::: "${FILES[@]}" \
+               2>"$TMPFILE" || cat "$TMPFILE"
+    rm -f "$TMPFILE"
     echo -e "--x-- Processed $script --x--\n"
 done
index 8c3be01c1f78617e3a655b0c1acd5046cc241794..7a3382c9a7b9e2f13f54d64b7bbad7bb9b95cdf1 100644 (file)
@@ -1,28 +1,13 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 @@
 position p : script:python() { p[0].file != "src/journal/lookup3.c" };
-identifier id;
-expression e;
+expression e,e1;
 @@
-if (...)
-- {
+- if (e) {
++ if (e)
 (
-    id@p(...);
+  e1@p;
 |
-    e@p;
-)
-- }
-
-@@
-position p : script:python() { p[0].file != "src/journal/lookup3.c" };
-identifier id;
-expression e;
-@@
-if (...)
-- {
-(
-    return id@p(...);
-|
-    return e@p;
+  return e1@p;
 )
 - }
index 51b235d94d06816d6f941c8b80f409da1ab30312..dd5ef0558354b2737ede98f2a65d8d2ece54c6e0 100644 (file)
@@ -8,6 +8,13 @@
 #   systemd-hwdb update
 #   udevadm trigger
 
+###########################################################
+# Corsair
+###########################################################
+# Void Headsets
+usb:v1B1Cp0A51*
+ SOUND_FORM_FACTOR=headset
+
 ###########################################################
 # Steelseries
 ###########################################################
index d3fef01febfc581c9af382cb84a8a2ef17eda27c..9e70c3f01fb2990adc5f72128d4f92f9aa166a2f 100644 (file)
@@ -221,7 +221,7 @@ int get_locales(char ***ret) {
         locales = set_free(locales);
 
         r = getenv_bool("SYSTEMD_LIST_NON_UTF8_LOCALES");
-        if (r == -ENXIO || r == 0) {
+        if (IN_SET(r, -ENXIO, 0)) {
                 char **a, **b;
 
                 /* Filter out non-UTF-8 locales, because it's 2019, by default */
index d1bd3c681c7c1ec5db5ed10281ecb38388f55c5a..58470385df27025fa3ff51a005ae3f8819e1617e 100644 (file)
@@ -1018,7 +1018,7 @@ static int remove_loader_variables(void) {
                        EFI_LOADER_VARIABLE(LoaderEntryDefault),
                        EFI_LOADER_VARIABLE(LoaderEntryLastBooted),
                        EFI_LOADER_VARIABLE(LoaderEntryOneShot),
-                       EFI_LOADER_VARIABLE(LoaderSystemToken)){
+                       EFI_LOADER_VARIABLE(LoaderSystemToken)) {
 
                 int q;
 
index 2c6dce0a0882b1c0a30706ed812be46b11ac495b..1830d697848bbc5e9da3e1c0932bbb4b1cb8aa11 100644 (file)
@@ -1311,7 +1311,7 @@ int bus_set_transient_exec_command(
         int r;
 
         /* Drop Ex from the written setting. E.g. ExecStart=, not ExecStartEx=. */
-        const char *written_name = is_ex_prop ? strndupa(name, strlen(name) - 2) : name;
+        const char *written_name = is_ex_prop ? strndupa_safe(name, strlen(name) - 2) : name;
 
         r = sd_bus_message_enter_container(message, 'a', is_ex_prop ? "(sasas)" : "(sasb)");
         if (r < 0)
index ad1c46ac6ca27b488e5ad914f72e590d77043223..d88436018c7b076be36f5015546859886231e93b 100644 (file)
@@ -879,7 +879,7 @@ static int request_handler_machine(
                      SD_ID128_FORMAT_VAL(bid),
                      hostname_cleanup(hostname),
                      os_release_pretty_name(pretty_name, os_name),
-                     v ? v : "bare",
+                     v ?: "bare",
                      usage,
                      cutoff_from,
                      cutoff_to);
index ff0228081fedbb4ca1034077b26fc8eb9d203a31..5ac90223ffd88874e2fe1f8da42ef0e71f381758 100644 (file)
@@ -627,7 +627,7 @@ static int message_new_reply(
                         return r;
         }
 
-        t->dont_send = !!(call->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED);
+        t->dont_send = FLAGS_SET(call->header->flags, BUS_MESSAGE_NO_REPLY_EXPECTED);
         t->enforced_reply_signature = call->enforced_reply_signature;
 
         /* let's copy the sensitive flag over. Let's do that as a safety precaution to keep a transaction
index 3c59d0d615287f81c1ca3b7df29eb6e3c49f4a89..718709f0b24bd9bd7bc91406ff5ea90ea3481290 100644 (file)
@@ -217,7 +217,7 @@ static int bus_socket_auth_verify_client(sd_bus *b) {
         /* And possibly check the third line, too */
         if (b->accept_fd) {
                 l = lines[i++];
-                b->can_fds = !!memory_startswith(l, lines[i] - l, "AGREE_UNIX_FD");
+                b->can_fds = memory_startswith(l, lines[i] - l, "AGREE_UNIX_FD");
         }
 
         assert(i == n);
index 4a0259f8bbd27fc3326e39c0b39dc9c78e4aa41f..f036a49c644b50d1ea482c953c53f00e1c168523 100644 (file)
@@ -321,7 +321,7 @@ _public_ int sd_bus_set_bus_client(sd_bus *bus, int b) {
         assert_return(!bus->patch_sender, -EPERM);
         assert_return(!bus_origin_changed(bus), -ECHILD);
 
-        bus->bus_client = !!b;
+        bus->bus_client = b;
         return 0;
 }
 
@@ -331,7 +331,7 @@ _public_ int sd_bus_set_monitor(sd_bus *bus, int b) {
         assert_return(bus->state == BUS_UNSET, -EPERM);
         assert_return(!bus_origin_changed(bus), -ECHILD);
 
-        bus->is_monitor = !!b;
+        bus->is_monitor = b;
         return 0;
 }
 
@@ -341,7 +341,7 @@ _public_ int sd_bus_negotiate_fds(sd_bus *bus, int b) {
         assert_return(bus->state == BUS_UNSET, -EPERM);
         assert_return(!bus_origin_changed(bus), -ECHILD);
 
-        bus->accept_fd = !!b;
+        bus->accept_fd = b;
         return 0;
 }
 
@@ -353,7 +353,7 @@ _public_ int sd_bus_negotiate_timestamp(sd_bus *bus, int b) {
 
         /* This is not actually supported by any of our transports these days, but we do honour it for synthetic
          * replies, and maybe one day classic D-Bus learns this too */
-        bus->attach_timestamp = !!b;
+        bus->attach_timestamp = b;
 
         return 0;
 }
@@ -380,7 +380,7 @@ _public_ int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id) {
         assert_return(bus->state == BUS_UNSET, -EPERM);
         assert_return(!bus_origin_changed(bus), -ECHILD);
 
-        bus->is_server = !!b;
+        bus->is_server = b;
         bus->server_id = server_id;
         return 0;
 }
@@ -391,7 +391,7 @@ _public_ int sd_bus_set_anonymous(sd_bus *bus, int b) {
         assert_return(bus->state == BUS_UNSET, -EPERM);
         assert_return(!bus_origin_changed(bus), -ECHILD);
 
-        bus->anonymous_auth = !!b;
+        bus->anonymous_auth = b;
         return 0;
 }
 
@@ -401,7 +401,7 @@ _public_ int sd_bus_set_trusted(sd_bus *bus, int b) {
         assert_return(bus->state == BUS_UNSET, -EPERM);
         assert_return(!bus_origin_changed(bus), -ECHILD);
 
-        bus->trusted = !!b;
+        bus->trusted = b;
         return 0;
 }
 
@@ -419,7 +419,7 @@ _public_ int sd_bus_set_allow_interactive_authorization(sd_bus *bus, int b) {
         assert_return(bus = bus_resolve(bus), -ENOPKG);
         assert_return(!bus_origin_changed(bus), -ECHILD);
 
-        bus->allow_interactive_authorization = !!b;
+        bus->allow_interactive_authorization = b;
         return 0;
 }
 
@@ -437,7 +437,7 @@ _public_ int sd_bus_set_watch_bind(sd_bus *bus, int b) {
         assert_return(bus->state == BUS_UNSET, -EPERM);
         assert_return(!bus_origin_changed(bus), -ECHILD);
 
-        bus->watch_bind = !!b;
+        bus->watch_bind = b;
         return 0;
 }
 
@@ -455,7 +455,7 @@ _public_ int sd_bus_set_connected_signal(sd_bus *bus, int b) {
         assert_return(bus->state == BUS_UNSET, -EPERM);
         assert_return(!bus_origin_changed(bus), -ECHILD);
 
-        bus->connected_signal = !!b;
+        bus->connected_signal = b;
         return 0;
 }
 
index ccdd0d50b7c03f3742c26c540a84190c613dfc83..2847ba84f5b13381573236a5d0897beb3c04b434 100644 (file)
@@ -494,10 +494,9 @@ static int client(struct context *c) {
                         }
                         assert_se(sd_bus_message_exit_container(reply) >= 0);
 
-                        if (streq(path, "/value/a")) {
+                        if (streq(path, "/value/a"))
                                 /* ObjectManager must be here */
                                 assert_se(found_object_manager_interface);
-                        }
 
                 } else
                         assert_se(sd_bus_message_skip(reply, "a{sa{sv}}") >= 0);
index 896ea4deca840c203873e37fbb33a13d7f5eb630..56f9ac7fc1d989e3a4331a810aa3c8e040a385e5 100644 (file)
@@ -5038,7 +5038,7 @@ _public_ int sd_event_set_watchdog(sd_event *e, int b) {
                 }
         }
 
-        e->watchdog = !!b;
+        e->watchdog = b;
         return e->watchdog;
 
 fail:
index efca2379eac71e5850cfaa897e6fd166e55048c8..da7e3d890055550b370dfea691852d356a02457b 100644 (file)
@@ -172,10 +172,8 @@ static int run(int argc, char *argv[]) {
                 log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
 
         ctx = kmod_new(NULL, NULL);
-        if (!ctx) {
-                log_error("Failed to allocate memory for kmod.");
-                return -ENOMEM;
-        }
+        if (!ctx)
+                return log_oom();
 
         kmod_load_resources(ctx);
         kmod_set_log_fn(ctx, systemd_kmod_log, NULL);
index bcd3ae66213ff1ef663c1fece1faf0566f1ca9b3..f95a138a2e3e3ba2be2498e2dd11cfdb016f3120 100644 (file)
@@ -201,18 +201,14 @@ Address *address_free(Address *address) {
         if (address->network) {
                 assert(address->section);
                 ordered_hashmap_remove(address->network->addresses_by_section, address->section);
+
+                if (address->network->dhcp_server_address == address)
+                        address->network->dhcp_server_address = NULL;
         }
 
-        if (address->link) {
+        if (address->link)
                 set_remove(address->link->addresses, address);
 
-                if (address->family == AF_INET6 &&
-                    in6_addr_equal(&address->in_addr.in6, &address->link->ipv6ll_address))
-                        memzero(&address->link->ipv6ll_address, sizeof(struct in6_addr));
-
-                ipv4acd_detach(address->link, address);
-        }
-
         config_section_free(address->section);
         free(address->label);
         free(address->netlabel);
@@ -778,6 +774,13 @@ static int address_drop(Address *address) {
 
         address_del_netlabel(address);
 
+        /* FIXME: if the IPv6LL address is dropped, stop DHCPv6, NDISC, RADV. */
+        if (address->family == AF_INET6 &&
+            in6_addr_equal(&address->in_addr.in6, &link->ipv6ll_address))
+                link->ipv6ll_address = (const struct in6_addr) {};
+
+        ipv4acd_detach(link, address);
+
         address_free(address);
 
         link_update_operstate(link, /* also_update_master = */ true);
index fde5e2c3c1e6b07310d5f162f8d2b8c4efc5016a..ddd60a1e574914d027e333fa8120458b2ec6df7d 100644 (file)
@@ -608,7 +608,7 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) {
         }
 
         r = sd_ndisc_router_route_get_preference(rt, &preference);
-        if (r == -ENOTSUP) {
+        if (r == -EOPNOTSUPP) {
                 log_link_debug_errno(link, r, "Received route prefix with unsupported preference, ignoring: %m");
                 return 0;
         }
index ac7cd43491768baef8287cbda34278b81167a14e..0743a3427e7f08005569af57eaa06702873d8e3a 100644 (file)
@@ -2869,7 +2869,7 @@ int config_parse_route_tcp_rto(
                 return 0;
         }
 
-        if (IN_SET(usec, 0, USEC_INFINITY) ||
+        if (!timestamp_is_set(usec) ||
             DIV_ROUND_UP(usec, USEC_PER_MSEC) > UINT32_MAX) {
                 log_syntax(unit, LOG_WARNING, filename, line, 0,
                            "Route TCP retransmission timeout (RTO) must be in the range 0…%"PRIu32"ms, ignoring assignment: %s", UINT32_MAX, rvalue);
index e3b6f895d171dcef7e4d3429fd4441440d8838fb..62cf331a4a9c1e521cb0705b7540e63c1ec56152 100644 (file)
@@ -1837,10 +1837,8 @@ static int oci_seccomp_syscalls(const char *name, JsonVariant *v, JsonDispatchFl
                 if (r < 0)
                         return r;
 
-                if (strv_isempty(rule.names)) {
-                        json_log(e, flags, 0, "System call name list is empty.");
-                        return -EINVAL;
-                }
+                if (strv_isempty(rule.names))
+                        return json_log(e, flags, SYNTHETIC_ERRNO(EINVAL), "System call name list is empty.");
 
                 STRV_FOREACH(i, rule.names) {
                         int nr;
index 1e9284e2e2e855ad71c59e91b7192e6dfae24c9b..95cae94a8e069af60d0a5bfaf0a0833e8cff4abe 100644 (file)
@@ -4172,8 +4172,7 @@ static int sign_verity_roothash(
                 return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to convert PKCS7 signature to DER: %s",
                                        ERR_error_string(ERR_get_error(), NULL));
 
-        ret_signature->iov_base = TAKE_PTR(sig);
-        ret_signature->iov_len = sigsz;
+        *ret_signature = IOVEC_MAKE(TAKE_PTR(sig), sigsz);
 
         return 0;
 #else
index 24ed16e56b5a9d93de506d0f018000d8c88b4c9e..b3b5037a7c6fc712f9c6b5b4fbf96b50c75f350d 100644 (file)
@@ -348,7 +348,7 @@ static int parse_package_metadata(const char *name, JsonVariant *id_json, Elf *e
 
                 /* Package metadata is in PT_NOTE headers. */
                 program_header = sym_gelf_getphdr(elf, i, &mem);
-                if (!program_header || (program_header->p_type != PT_NOTE && program_header->p_type != PT_INTERP))
+                if (!program_header || !IN_SET(program_header->p_type, PT_NOTE, PT_INTERP))
                         continue;
 
                 if (program_header->p_type == PT_INTERP) {
index 330b4c3272d779a7da498ed85c8a175998a712fb..917b7732665ff0635040ffd8ea230304ba9ebefa 100644 (file)
@@ -257,7 +257,7 @@ static int killall(int sig, Set *pids, bool send_sighup) {
 
                 r = pidref_kill(&pidref, sig);
                 if (r < 0) {
-                        if (errno != -ESRCH)
+                        if (r != -ESRCH)
                                 log_warning_errno(errno, "Could not kill " PID_FMT ", ignoring: %m", pidref.pid);
                 } else {
                         n_killed++;
index edf4fb01b925e13652ded04273a425093ce8bc31..9792f70d42202624eca85fc1eee1abe0afa339f0 100644 (file)
@@ -665,7 +665,7 @@ int pkcs11_token_find_private_key(
                 optional_attributes[1].ulValueLen = sizeof(derive_value);
 
                 rv = m->C_GetAttributeValue(session, candidate, optional_attributes, ELEMENTSOF(optional_attributes));
-                if (rv != CKR_OK && rv != CKR_ATTRIBUTE_TYPE_INVALID)
+                if (!IN_SET(rv, CKR_OK, CKR_ATTRIBUTE_TYPE_INVALID))
                         return log_error_errno(SYNTHETIC_ERRNO(EIO),
                                 "Failed to get attributes of a selected private key: %s", sym_p11_kit_strerror(rv));
 
@@ -737,7 +737,7 @@ int pkcs11_token_find_related_object(
         CK_RV rv;
 
         rv = m->C_GetAttributeValue(session, prototype, attributes, ELEMENTSOF(attributes));
-        if (rv != CKR_OK && rv != CKR_ATTRIBUTE_TYPE_INVALID)
+        if (!IN_SET(rv, CKR_OK, CKR_ATTRIBUTE_TYPE_INVALID))
                 return log_debug_errno(SYNTHETIC_ERRNO(EIO), "Failed to retrieve length of attributes: %s", sym_p11_kit_strerror(rv));
 
         if (attributes[0].ulValueLen != CK_UNAVAILABLE_INFORMATION) {
@@ -812,7 +812,7 @@ static int ecc_convert_to_compressed(
         int r;
 
         rv = m->C_GetAttributeValue(session, object, &ec_params_attr, 1);
-        if (rv != CKR_OK && rv != CKR_ATTRIBUTE_TYPE_INVALID)
+        if (!IN_SET(rv, CKR_OK, CKR_ATTRIBUTE_TYPE_INVALID))
                 return log_error_errno(SYNTHETIC_ERRNO(EIO),
                         "Failed to retrieve length of CKA_EC_PARAMS: %s", sym_p11_kit_strerror(rv));
 
@@ -834,7 +834,7 @@ static int ecc_convert_to_compressed(
 
                 ec_params_attr.ulValueLen = 0;
                 rv = m->C_GetAttributeValue(session, public_key, &ec_params_attr, 1);
-                if (rv != CKR_OK && rv != CKR_ATTRIBUTE_TYPE_INVALID)
+                if (!IN_SET(rv, CKR_OK, CKR_ATTRIBUTE_TYPE_INVALID))
                         return log_error_errno(SYNTHETIC_ERRNO(EIO),
                                 "Failed to retrieve length of CKA_EC_PARAMS: %s", sym_p11_kit_strerror(rv));
 
index f2bdae2becac1fb9c3dae0374183f62066e49698..80a0d5f2dc60838c7765113723177e1e870051df 100644 (file)
@@ -2059,7 +2059,7 @@ int tpm2_create_primary(
                         session ? session->esys_handle : ESYS_TR_PASSWORD,
                         ESYS_TR_NONE,
                         ESYS_TR_NONE,
-                        sensitive ? sensitive : &(TPM2B_SENSITIVE_CREATE) {},
+                        sensitive ?: &(TPM2B_SENSITIVE_CREATE) {},
                         template,
                         /* outsideInfo= */ NULL,
                         &(TPML_PCR_SELECTION) {},
@@ -5891,10 +5891,7 @@ int tpm2_unseal_data(
                                        "Failed to unseal data: %s", sym_Tss2_RC_Decode(rc));
 
         _cleanup_(iovec_done) struct iovec d = {};
-        d = (struct iovec) {
-                .iov_base = memdup(unsealed->buffer, unsealed->size),
-                .iov_len = unsealed->size,
-        };
+        d = IOVEC_MAKE(memdup(unsealed->buffer, unsealed->size), unsealed->size);
 
         explicit_bzero_safe(unsealed->buffer, unsealed->size);
 
@@ -7572,7 +7569,7 @@ int tpm2_util_pbkdf2_hmac_sha256(const void *pass,
                     size_t saltlen,
                     uint8_t ret_key[static SHA256_DIGEST_SIZE]) {
 
-        uint8_t _cleanup_(erase_and_freep) *buffer = NULL;
+        _cleanup_(erase_and_freep) uint8_t *buffer = NULL;
         uint8_t u[SHA256_DIGEST_SIZE];
 
         /* To keep this simple, since derived KeyLen (dkLen in docs)
index 3784796487a42bb2eddf851688b7bc6ab52b674d..deb165ead89b0994541f98aad49afcb909c70f44 100644 (file)
@@ -176,7 +176,7 @@ static int lock_all_homes(void) {
         /* Let's synchronously lock all home directories managed by homed that have been marked for it. This
          * way the key material required to access these volumes is hopefully removed from memory. */
 
-        r = bus_connect_system_systemd(&bus);
+        r = sd_bus_open_system(&bus);
         if (r < 0)
                 return log_error_errno(r, "Failed to connect to system bus: %m");
 
index a6bb5e52892252b28fb561b7e2cbb7d18ef5cfbc..c851c8546ef55c51caba46780ace0ff5bce9d6d9 100644 (file)
@@ -247,13 +247,12 @@ static int find_paths_to_edit(
                         return r; /* Already logged by unit_find_paths() */
 
                 if (!path) {
-                        if (!arg_force) {
-                                log_info("Run 'systemctl edit%s --force --full %s' to create a new unit.",
-                                         arg_runtime_scope == RUNTIME_SCOPE_GLOBAL ? " --global" :
-                                         arg_runtime_scope == RUNTIME_SCOPE_USER ? " --user" : "",
-                                         *name);
-                                return -ENOENT;
-                        }
+                        if (!arg_force)
+                                return log_info_errno(SYNTHETIC_ERRNO(ENOENT),
+                                                      "Run 'systemctl edit%s --force --full %s' to create a new unit.",
+                                                      arg_runtime_scope == RUNTIME_SCOPE_GLOBAL ? " --global" :
+                                                      arg_runtime_scope == RUNTIME_SCOPE_USER ? " --user" : "",
+                                                      *name);
 
                         /* Create a new unit from scratch */
                         r = unit_file_create_new(
index eb9678a7d9478828a5d4235f44e84531c9044e59..331faf1e4b304fbb2cd9420d7ef4b9aaa67c8006 100644 (file)
@@ -82,7 +82,7 @@ TEST(fd_acl_make_read_only) {
         (void) fd_add_uid_acl_permission(fd, 1, ACL_READ|ACL_WRITE|ACL_EXECUTE);
 
         assert_se(fstat(fd, &st) >= 0);
-        assert_se((st.st_mode & 0200) == 0200);
+        assert_se(FLAGS_SET(st.st_mode, 0200));
 
         cmd = strjoina("getfacl -p ", fn);
         assert_se(system(cmd) == 0);
index 0c1b849c89763f4944800ca201d6875e648ad1f8..1f71a258598c02472620e859ec84026f644642b2 100644 (file)
@@ -328,23 +328,23 @@ TEST(mount_option_supported) {
 
         r = mount_option_supported("tmpfs", "size", "64M");
         log_info("tmpfs supports size=64M: %s (%i)", r < 0 ? "don't know" : yes_no(r), r);
-        assert_se(r > 0 || r == -EAGAIN || (r < 0 && ERRNO_IS_PRIVILEGE(r)));
+        assert_se(r > 0 || r == -EAGAIN || ERRNO_IS_NEG_PRIVILEGE(r));
 
         r = mount_option_supported("ext4", "discard", NULL);
         log_info("ext4 supports discard: %s (%i)", r < 0 ? "don't know" : yes_no(r), r);
-        assert_se(r > 0 || r == -EAGAIN || (r < 0 && ERRNO_IS_PRIVILEGE(r)));
+        assert_se(r > 0 || r == -EAGAIN || ERRNO_IS_NEG_PRIVILEGE(r));
 
         r = mount_option_supported("tmpfs", "idontexist", "64M");
         log_info("tmpfs supports idontexist: %s (%i)", r < 0 ? "don't know" : yes_no(r), r);
-        assert_se(r == 0 || r == -EAGAIN || (r < 0 && ERRNO_IS_PRIVILEGE(r)));
+        assert_se(IN_SET(r, 0, -EAGAIN) || ERRNO_IS_NEG_PRIVILEGE(r));
 
         r = mount_option_supported("tmpfs", "ialsodontexist", NULL);
         log_info("tmpfs supports ialsodontexist: %s (%i)", r < 0 ? "don't know" : yes_no(r), r);
-        assert_se(r == 0 || r == -EAGAIN || (r < 0 && ERRNO_IS_PRIVILEGE(r)));
+        assert_se(IN_SET(r, 0, -EAGAIN) || ERRNO_IS_NEG_PRIVILEGE(r));
 
         r = mount_option_supported("proc", "hidepid", "1");
         log_info("proc supports hidepid=1: %s (%i)", r < 0 ? "don't know" : yes_no(r), r);
-        assert_se(r >= 0 || r == -EAGAIN || (r < 0 && ERRNO_IS_PRIVILEGE(r)));
+        assert_se(r >= 0 || r == -EAGAIN || ERRNO_IS_NEG_PRIVILEGE(r));
 }
 
 TEST(fstype_can_discard) {
index 0d5a6a185608902a5c844984f3e101e7f70422f7..af5b5553e069b4b4ce73c00a55304ca65e1be191 100644 (file)
@@ -141,7 +141,7 @@ TEST(set_ensure_allocated) {
         assert_se(set_ensure_allocated(&m, &string_hash_ops) == 1);
         assert_se(set_ensure_allocated(&m, &string_hash_ops) == 0);
         assert_se(set_ensure_allocated(&m, NULL) == 0);
-        assert_se(set_size(m) == 0);
+        assert_se(set_isempty(m));
 }
 
 TEST(set_copy) {
index 76931ce0ab30d733b003b4b8fe0708d3ecc84010..d29afa38dd29a2dcea5dae4a48273081087e2f1b 100644 (file)
@@ -1089,9 +1089,9 @@ TEST(map_clock_usec) {
         assert_se(nowr < USEC_INFINITY - USEC_PER_DAY*7); /* overflow check */
         x = nowr + USEC_PER_DAY*7; /* 1 week from now */
         y = map_clock_usec(x, CLOCK_REALTIME, CLOCK_MONOTONIC);
-        assert_se(y > 0 && y < USEC_INFINITY);
+        assert_se(timestamp_is_set(y));
         z = map_clock_usec(y, CLOCK_MONOTONIC, CLOCK_REALTIME);
-        assert_se(z > 0 && z < USEC_INFINITY);
+        assert_se(timestamp_is_set(z));
         assert_se((z > x ? z - x : x - z) < USEC_PER_HOUR);
 
         assert_se(nowr > USEC_PER_DAY * 7); /* underflow check */
@@ -1100,7 +1100,7 @@ TEST(map_clock_usec) {
         if (y != 0) { /* might underflow if machine is not up long enough for the monotonic clock to be beyond 1w */
                 assert_se(y < USEC_INFINITY);
                 z = map_clock_usec(y, CLOCK_MONOTONIC, CLOCK_REALTIME);
-                assert_se(z > 0 && z < USEC_INFINITY);
+                assert_se(timestamp_is_set(z));
                 assert_se((z > x ? z - x : x - z) < USEC_PER_HOUR);
         }
 }
index 186f6ee29c8d8e7b78efec123c1b0139754fba2b..aabbd2425ccb4a464a1237d9daceea4c52c1c27c 100644 (file)
@@ -99,7 +99,7 @@ TEST(load_userns) {
         int r;
 
         r = uid_range_load_userns(&p, NULL);
-        if (r < 0 && ERRNO_IS_NOT_SUPPORTED(r))
+        if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
                 return;
 
         assert_se(r >= 0);
index 85901c9a49b45ecae56cff62e7c3089f1be6e949..b473165a3e0058748d0a6643cbb30d211850064d 100644 (file)
@@ -45,7 +45,7 @@ TEST(getxattr_at_malloc) {
         fd = open("/", O_RDONLY|O_DIRECTORY|O_CLOEXEC|O_NOCTTY);
         assert_se(fd >= 0);
         r = getxattr_at_malloc(fd, "usr", "user.idontexist", 0, &value);
-        assert_se(r < 0 && ERRNO_IS_XATTR_ABSENT(r));
+        assert_se(ERRNO_IS_NEG_XATTR_ABSENT(r));
 
         safe_close(fd);
         fd = open(x, O_PATH|O_CLOEXEC);
@@ -99,7 +99,7 @@ TEST(xsetxattr) {
 
         /* by full path */
         r = xsetxattr(AT_FDCWD, x, "user.foo", "fullpath", SIZE_MAX, 0);
-        if (r < 0 && ERRNO_IS_NOT_SUPPORTED(r))
+        if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
                 return (void) log_tests_skipped_errno(r, "no xattrs supported on /var/tmp");
         assert_se(r >= 0);
         verify_xattr(dfd, "fullpath");
index 467c9a6ad3981ece6d1d8c4ae09ddd1362d18cec..f1370e60608ceff37b35aa574a6be0c480e2f52a 100644 (file)
@@ -632,7 +632,7 @@ static int find_real_nvme_parent(sd_device *dev, sd_device **ret) {
                 return -ENXIO;
 
         end += strspn(end, DIGITS);
-        sysname = strndupa(sysname, end - sysname);
+        sysname = strndupa_safe(sysname, end - sysname);
 
         r = sd_device_new_from_subsystem_sysname(&nvme, "nvme", sysname);
         if (r < 0)