mirror of
https://github.com/systemd/systemd.git
synced 2026-08-12 22:17:19 +00:00
The fix in 8f1751a111 made me wonder if we could automatically detect
when pointers are accessed but when this might not be safe. Systemd
is already using a lot of `assert(dst)` and this change now forces
us to use them.
So this commit (ab)uses coccinelle to flag any pointer parameter
dereference not preceded by assert(param), ASSERT_PTR(param), or an
explicit NULL check. It adds integration into meson as a new "coccinelle"
test suite (just like clang-tidy) and is run in CI. The check is not
perfect but seems a reasonable heuristic.
For this RFC commit it is scoped to a subset, it excludes 25 dirs right
now and includes around 100. About 300 warnings left. Busywork that I am
happy to do if there is agreement that it is worth it.
With this in place we would have caught the bug from 8f1751a111 in CI:
```
FAIL: check-pointer-deref.cocci found issues in systemd/src/boot:
diff -u -p systemd/src/boot/measure.c /tmp/nothing/measure.c
--- systemd/src/boot/measure.c
+++ /tmp/nothing/measure.c
@@ -312,7 +312,6 @@ EFI_STATUS tpm_log_tagged_event(
if (err != EFI_SUCCESS)
return err;
- *ret_measured = true;
return EFI_SUCCESS;
}
```
This also adds a new POINTER_MAY_BE_NULL() for the cases when the
called function will do the NULL check (like `iovec_is_set()`).
39 lines
1.9 KiB
Meson
39 lines
1.9 KiB
Meson
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
check_api_docs_sh = files('check-api-docs.sh')
|
|
check_coccinelle_sh = files('check-coccinelle.sh')
|
|
check_efi_alignment_py = files('check-efi-alignment.py')
|
|
check_help_sh = files('check-help.sh')
|
|
check_version_history_py = files('check-version-history.py')
|
|
check_version_sh = files('check-version.sh')
|
|
elf2efi_py = files('elf2efi.py')
|
|
dbus_exporter_py = files('dbus_exporter.py')
|
|
find_unused_library_symbols_py = files('find-unused-library-symbols.py')
|
|
generate_gperfs = files('generate-gperfs.py')
|
|
git_contrib_sh = files('git-contrib.sh')
|
|
make_autosuspend_rules_py = files('make-autosuspend-rules.py')
|
|
make_directive_index_py = files('make-directive-index.py')
|
|
make_man_index_py = files('make-man-index.py')
|
|
meson_build_sh = files('meson-build.sh')
|
|
meson_extract_unit_files_py = files('meson-extract-unit-files.py')
|
|
meson_render_jinja2_py = files('meson-render-jinja2.py')
|
|
sync_docs_py = files('sync-docs.py')
|
|
update_dbus_docs_py = files('update-dbus-docs.py')
|
|
update_hwdb_autosuspend_sh = files('update-hwdb-autosuspend.sh')
|
|
update_hwdb_sh = files('update-hwdb.sh')
|
|
update_man_rules_py = files('update-man-rules.py')
|
|
update_syscall_tables_sh = files('update-syscall-tables.sh')
|
|
vcs_tag_sh = files('vcs-tag.sh')
|
|
xml_helper_py = files('xml_helper.py')
|
|
|
|
#####################################################################
|
|
|
|
# Try to install the git pre-commit hook
|
|
git_setup_sh = find_program('./git-setup.sh', required : false)
|
|
if git_setup_sh.found()
|
|
git_hook = run_command(git_setup_sh, check : false)
|
|
if git_hook.returncode() == 0
|
|
message(git_hook.stdout().strip())
|
|
endif
|
|
endif
|