coccinelle: ignore more attributes and macros
This also adds bus_assert_return() as an variant of assertion. With this change, more code blocks are checked by coccinelle, thus the test become slightly slower. So the timeout is extended. Also, as checking exec_invoke() takes so long, let's skip it. Note, previously the function was skipped due to parse error caused by unknown cleanup attributes. So, the coverage is not decreased by the skip.
This commit is contained in:
@@ -12,10 +12,14 @@
|
||||
* assert(param) at the top. If it can legitimately be NULL, add an if() guard.
|
||||
*/
|
||||
@@
|
||||
/* exec_invoke() is too large to be checked by this rule. */
|
||||
position p : script:python() {
|
||||
not (p[0].file.endswith("exec-invoke.c") and
|
||||
p[0].current_element == "exec_invoke")
|
||||
};
|
||||
identifier fn, param;
|
||||
identifier is_set =~ "_is_set$";
|
||||
type T;
|
||||
position p;
|
||||
@@
|
||||
|
||||
fn(..., T *param, ...) {
|
||||
@@ -24,6 +28,7 @@ fn(..., T *param, ...) {
|
||||
when != assert_se(param)
|
||||
when != assert_se(param != NULL)
|
||||
when != assert_return(param, ...)
|
||||
when != bus_assert_return(param, ...)
|
||||
when != ASSERT_PTR(param)
|
||||
when != POINTER_MAY_BE_NULL(param)
|
||||
/* Any foo_is_set(param) guard implies param != NULL, since all *_is_set()
|
||||
|
||||
+108
-4
@@ -58,27 +58,95 @@
|
||||
#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. */
|
||||
/* Coccinelle doesn't know these keywords, so just drop them, since they are not important for any of our rules. */
|
||||
#define thread_local
|
||||
#define _Noreturn
|
||||
|
||||
/* Coccinelle can't handle the __attribute__((__cleanup__(x))) GCC extension used by our _cleanup_*
|
||||
* macros. Without this, any variable declared with _cleanup_free_ or _cleanup_(foo) makes the whole
|
||||
* function unparsable. Drop the attribute since it's not relevant for semantic checks. */
|
||||
#define _cleanup_bitmap_free_
|
||||
#define _cleanup_close_
|
||||
#define _cleanup_close_pair_
|
||||
#define _cleanup_closedir_
|
||||
#define _cleanup_fclose_
|
||||
#define _cleanup_fdset_free_
|
||||
#define _cleanup_file_close_
|
||||
#define _cleanup_free_
|
||||
#define _cleanup_freecon_
|
||||
#define _cleanup_hashmap_free_
|
||||
#define _cleanup_iterated_cache_free_
|
||||
#define _cleanup_ordered_hashmap_free_
|
||||
#define _cleanup_ordered_set_free_
|
||||
#define _cleanup_pages_
|
||||
#define _cleanup_pclose_
|
||||
#define _cleanup_set_free_
|
||||
#define _cleanup_strv_free_
|
||||
#define _cleanup_strv_free_erase_
|
||||
#define _cleanup_umask_
|
||||
|
||||
/* Also drop other attributes. */
|
||||
/* fundmental/macro.h */
|
||||
#define _alias_(x)
|
||||
#define _align_(x)
|
||||
#define _alignas_(x)
|
||||
#define _alignptr_
|
||||
#define _cleanup_(x)
|
||||
#define _const_
|
||||
#define _deprecated_
|
||||
#define _destructor_
|
||||
#define _hidden_
|
||||
#define _likely_(x) x
|
||||
#define _malloc_
|
||||
#define _noclone_
|
||||
#define _noinline_
|
||||
#define _noreturn_
|
||||
#define _packed_
|
||||
#define _printf_(a, b)
|
||||
#define _public_
|
||||
#define _pure_
|
||||
#define _returns_nonnull_
|
||||
#define _section_(x)
|
||||
#define _sentinel_
|
||||
#define _unlikely_(x) x
|
||||
#define _unused_
|
||||
#define _used_
|
||||
#define _warn_unused_result_
|
||||
#define _weak_
|
||||
#define _weakref_(x)
|
||||
#define _alloc_(...)
|
||||
#define _fallthrough_
|
||||
#define _retain_
|
||||
#define _no_reorder_
|
||||
#define _nonnull_if_nonzero_(p, n)
|
||||
|
||||
/* basic/dlopen-note.h */
|
||||
#define _dlopen_loader_
|
||||
|
||||
/* basic/macro.h */
|
||||
#define _variable_no_sanitize_address_
|
||||
#define _function_no_sanitize_float_cast_overflow_
|
||||
|
||||
/* systemd/_sd-common.h */
|
||||
#define _sd_printf_(a, b)
|
||||
#define _sd_sentinel_
|
||||
#define _sd_packed_
|
||||
#define _sd_pure_
|
||||
#define _sd_deprecated_
|
||||
|
||||
/* 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_ARGUMENT(entry, ...) YACFE_ITERATOR
|
||||
#define FOREACH_ARRAY(i, array, num) YACFE_ITERATOR
|
||||
#define FOREACH_DIRENT(de, d, on_error) YACFE_ITERATOR
|
||||
#define FOREACH_DIRENT_ALL(de, d, on_error) YACFE_ITERATOR
|
||||
#define FOREACH_DIRENT(de, d, on_error) for (struct dirent *(de) = readdir_ensure_type(d); (de); (de) = readdir_ensure_type(d))
|
||||
#define FOREACH_DIRENT_ALL(de, d, on_error) FOREACH_DIRENT(de, d, on_error)
|
||||
#define FOREACH_DIRENT_IN_BUFFER(de, buf, sz) YACFE_ITERATOR
|
||||
#define FOREACH_ELEMENT(i, array) YACFE_ITERATOR
|
||||
#define FOREACH_INOTIFY_EVENT_WARN(e, buffer, sz) YACFE_ITERATOR
|
||||
#define FOREACH_PCR_IN_TPMS_PCR_SELECTION(pcr, tpms) YACFE_ITERATOR
|
||||
#define FOREACH_STRING(x, y, ...) YACFE_ITERATOR
|
||||
#define HASHMAP_FOREACH(e, h) YACFE_ITERATOR
|
||||
#define HASHMAP_FOREACH_KEY(e, k, h) YACFE_ITERATOR
|
||||
@@ -88,11 +156,13 @@
|
||||
#define NULSTR_FOREACH_PAIR(i, j, l) YACFE_ITERATOR
|
||||
#define ORDERED_HASHMAP_FOREACH(e, h) YACFE_ITERATOR
|
||||
#define ORDERED_HASHMAP_FOREACH_KEY(e, k, h) YACFE_ITERATOR
|
||||
#define SD_FIBER_WITH_TIMEOUT(timeout) YACFE_ITERATOR
|
||||
#define SET_FOREACH(e, s) YACFE_ITERATOR
|
||||
#define SET_FOREACH_MOVE(e, d, s) YACFE_ITERATOR
|
||||
#define STRV_FOREACH(s, l) YACFE_ITERATOR
|
||||
#define STRV_FOREACH_BACKWARDS(s, l) YACFE_ITERATOR
|
||||
#define STRV_FOREACH_PAIR(x, y, l) YACFE_ITERATOR
|
||||
#define WITH_UMASK(mask) 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. */
|
||||
@@ -108,3 +178,37 @@
|
||||
* See: https://github.com/coccinelle/coccinelle/issues/413 */
|
||||
#define Z_EXPORT
|
||||
#define Z_EXTERN
|
||||
|
||||
/* Ignore several more macros */
|
||||
#define BUS_ERROR_MAP_ELF_REGISTER
|
||||
#define UPPERCASE_LETTERS ""
|
||||
#define LOWERCASE_LETTERS ""
|
||||
#define DIGITS ""
|
||||
#define ANSI_DCS ""
|
||||
#define ANSI_ST ""
|
||||
#define TPM2_SHA256_DIGEST_SIZE 32
|
||||
#define ElfW(type) Elf__ELF_NATIVE_CLASS_##type
|
||||
#define STACK_OF(type) struct stack_st_##type
|
||||
|
||||
/* shared/options.h */
|
||||
#define _OPTION_COCCI_ case (0x100 + counter)
|
||||
#define OPTION_NAMESPACE(ns) _OPTION_COCCI_
|
||||
#define OPTION_GROUP(gr) _OPTION_COCCI_
|
||||
#define OPTION_FULL_DATA(fl, sc, lc, mv, d, h) _OPTION_COCCI_
|
||||
#define OPTION_FULL(fl, sc, lc, mv, h) _OPTION_COCCI_
|
||||
#define OPTION(sc, lc, mv, h) _OPTION_COCCI_
|
||||
#define OPTION_LONG(lc, mv, h) _OPTION_COCCI_
|
||||
#define OPTION_LONG_FLAGS(fl, lc, mv, h) _OPTION_COCCI_
|
||||
#define OPTION_LONG_DATA(lc, mv, d, h) _OPTION_COCCI_
|
||||
#define OPTION_SHORT(sc, mv, h) _OPTION_COCCI_
|
||||
#define OPTION_SHORT_FLAGS(fl, sc, mv, h) _OPTION_COCCI_
|
||||
#define OPTION_SHORT_DATA(sc, mv, d, h) _OPTION_COCCI_
|
||||
#define OPTION_POSITIONAL _OPTION_COCCI_
|
||||
#define OPTION_HELP_VERBATIM(lc, h) _OPTION_COCCI_
|
||||
#define OPTION_COMMON_PRIVATE_KEY(purpose) _OPTION_COCCI_
|
||||
#define OPTION_COMMON_CERTIFICATE(purpose) _OPTION_COCCI_
|
||||
|
||||
/* libbpf */
|
||||
#define SEC(x)
|
||||
#define __weak
|
||||
#define __ksym
|
||||
|
||||
Reference in New Issue
Block a user