diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:42 +0000 |
commit | 78e9bb837c258ac0ec7712b3d612cc2f407e731e (patch) | |
tree | f515d16b6efd858a9aeb5b0ef5d6f90bf288283d /coccinelle | |
parent | Adding debian version 255.5-1. (diff) | |
download | systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.tar.xz systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.zip |
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'coccinelle')
-rw-r--r-- | coccinelle/isempty.cocci | 101 | ||||
-rw-r--r-- | coccinelle/log-json.cocci | 3 | ||||
-rw-r--r-- | coccinelle/macros.h | 231 | ||||
-rw-r--r-- | coccinelle/mfree.cocci | 29 | ||||
-rw-r--r-- | coccinelle/mfree_return.cocci | 9 | ||||
-rw-r--r-- | coccinelle/parsing_hacks.h | 83 | ||||
-rwxr-xr-x | coccinelle/run-coccinelle.sh | 45 | ||||
-rw-r--r-- | coccinelle/siphash24.cocci | 13 | ||||
-rw-r--r-- | coccinelle/zz-drop-braces.cocci | 25 |
9 files changed, 273 insertions, 266 deletions
diff --git a/coccinelle/isempty.cocci b/coccinelle/isempty.cocci index b1b9277..2089970 100644 --- a/coccinelle/isempty.cocci +++ b/coccinelle/isempty.cocci @@ -41,3 +41,104 @@ expression s; - strlen_ptr@p(s) != 0 + !isempty(s) ) +@@ +/* Disable this transformation for the hashmap.h, set.h, test-hashmap.c, test-hashmap-plain.c */ +position p : script:python() { + p[0].file != "src/basic/hashmap.h" and + p[0].file != "src/basic/set.h" and + p[0].file != "src/test/test-hashmap.c" and + p[0].file != "src/test/test-hashmap-plain.c" + }; +expression s; +@@ +( +- hashmap_size@p(s) == 0 ++ hashmap_isempty(s) +| +- hashmap_size@p(s) <= 0 ++ hashmap_isempty(s) +| +- hashmap_size@p(s) > 0 ++ !hashmap_isempty(s) +| +- hashmap_size@p(s) != 0 ++ !hashmap_isempty(s) +| +- ordered_hashmap_size@p(s) == 0 ++ ordered_hashmap_isempty(s) +| +- ordered_hashmap_size@p(s) <= 0 ++ ordered_hashmap_isempty(s) +| +- ordered_hashmap_size@p(s) > 0 ++ !ordered_hashmap_isempty(s) +| +- ordered_hashmap_size@p(s) != 0 ++ !ordered_hashmap_isempty(s) +| +- set_size@p(s) == 0 ++ set_isempty(s) +| +- set_size@p(s) <= 0 ++ set_isempty(s) +| +- set_size@p(s) > 0 ++ !set_isempty(s) +| +- set_size@p(s) != 0 ++ !set_isempty(s) +| +- ordered_set_size@p(s) == 0 ++ ordered_set_isempty(s) +| +- ordered_set_size@p(s) <= 0 ++ ordered_set_isempty(s) +| +- ordered_set_size@p(s) > 0 ++ !ordered_set_isempty(s) +| +- ordered_set_size@p(s) != 0 ++ !ordered_set_isempty(s) +) +@@ +expression s; +@@ +( +- fdset_size(s) == 0 ++ fdset_isempty(s) +| +- fdset_size(s) <= 0 ++ fdset_isempty(s) +| +- fdset_size(s) > 0 ++ !fdset_isempty(s) +| +- fdset_size(s) != 0 ++ !fdset_isempty(s) +) +@@ +expression s; +@@ +( +- prioq_size(s) == 0 ++ prioq_isempty(s) +| +- prioq_size(s) <= 0 ++ prioq_isempty(s) +| +- prioq_size(s) > 0 ++ !prioq_isempty(s) +| +- prioq_size(s) != 0 ++ !prioq_isempty(s) +) +@@ +expression s; +@@ +( +- table_get_rows(s) <= 1 ++ table_isempty(s) +| +- table_get_rows(s) > 1 ++ !table_isempty(s) +) diff --git a/coccinelle/log-json.cocci b/coccinelle/log-json.cocci index d184e56..c941706 100644 --- a/coccinelle/log-json.cocci +++ b/coccinelle/log-json.cocci @@ -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 index adfea5f..0000000 --- a/coccinelle/macros.h +++ /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/mfree.cocci b/coccinelle/mfree.cocci index 191cd62..1062d0c 100644 --- a/coccinelle/mfree.cocci +++ b/coccinelle/mfree.cocci @@ -1,7 +1,36 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ @@ +/* Avoid running this transformation on the mfree function itself */ +position p : script:python() { p[0].current_element != "mfree" }; +expression e; +@@ +- free@p(e); +- return NULL; ++ return mfree(e); + +@@ expression p; @@ - free(p); - p = NULL; + p = mfree(p); + +@@ +expression p; +@@ +- if (p) +- free(p); ++ free(p); + +@@ +expression p; +@@ +- if (p) +- mfree(p); ++ free(p); + +@@ +expression p; +@@ +- mfree(p); ++ free(p); diff --git a/coccinelle/mfree_return.cocci b/coccinelle/mfree_return.cocci deleted file mode 100644 index c2c4cb3..0000000 --- a/coccinelle/mfree_return.cocci +++ /dev/null @@ -1,9 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -@@ -/* Avoid running this transformation on the mfree function itself */ -position p : script:python() { p[0].current_element != "mfree" }; -expression e; -@@ -- free@p(e); -- return NULL; -+ return mfree(e); diff --git a/coccinelle/parsing_hacks.h b/coccinelle/parsing_hacks.h new file mode 100644 index 0000000..f88dae0 --- /dev/null +++ b/coccinelle/parsing_hacks.h @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +/* FIXME + * - issues with parsing stuff like + * - validchars = UPPERCASE_LETTERS DIGITS; + * - see: https://github.com/coccinelle/coccinelle/issues/341 + * - keywords in macro invocations like FOREACH_DIRENT_ALL(de, d, return -errno) + * - see: https://github.com/coccinelle/coccinelle/issues/340 + * - also see the 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 builtin 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 parse these from the included headers, so let's just drop them. */ +#define PAM_EXTERN +#define STACK_OF(x) + +/* 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_ELEMENT(i, array) 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 +#define STRV_FOREACH_BACKWARDS 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]; } +#define SD_ID128_MAKE(...) ((const sd_id128) {}) diff --git a/coccinelle/run-coccinelle.sh b/coccinelle/run-coccinelle.sh index cd95179..d4bccdc 100755 --- a/coccinelle/run-coccinelle.sh +++ b/coccinelle/run-coccinelle.sh @@ -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,45 @@ 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 \ + --undefined ENABLE_DEBUG_HASHMAP \ + --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 diff --git a/coccinelle/siphash24.cocci b/coccinelle/siphash24.cocci new file mode 100644 index 0000000..c577120 --- /dev/null +++ b/coccinelle/siphash24.cocci @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +@@ +expression p, s; +@@ +- siphash24_compress(&p, sizeof(p), s); ++ siphash24_compress_typesafe(p, s); + +@@ +union in_addr_union p; +expression f, s; +@@ +- siphash24_compress(&p, FAMILY_ADDRESS_SIZE(f), s); ++ in_addr_hash_func(&p, f, s); diff --git a/coccinelle/zz-drop-braces.cocci b/coccinelle/zz-drop-braces.cocci index 8c3be01..7a3382c 100644 --- a/coccinelle/zz-drop-braces.cocci +++ b/coccinelle/zz-drop-braces.cocci @@ -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; ) - } |