]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
build: prohibit realpath() by syntax-check
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 4 Jul 2025 07:50:33 +0000 (09:50 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 15 Jul 2025 08:13:23 +0000 (10:13 +0200)
We have virFileCanonicalizePath() which calls realpath() but
also is present in our mocks (in contrast to realpath()).
Introduce a syntax-check rule to enforce use of our wrapper.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
build-aux/syntax-check.mk

index 1303a0ce7eeede078c7cc72b6ad360285af8ae90..27eabe65659e6de046947d75f2e080707a885ba3 100644 (file)
@@ -247,6 +247,12 @@ sc_prohibit_canonicalize_file_name:
        halt='use virFileCanonicalizePath() instead of canonicalize_file_name()' \
          $(_sc_search_regexp)
 
+sc_prohibit_realpath:
+       @prohibit='\<realpath\(' \
+       exclude='exempt from syntax-check' \
+       halt='use virFileCanonicalizePath() instead of realpath()' \
+         $(_sc_search_regexp)
+
 # qsort from glibc has unstable sort ordering for "equal" members
 sc_prohibit_qsort:
        @prohibit='\<(qsort|qsort_r) *\(' \
@@ -1420,6 +1426,9 @@ exclude_file_name_regexp--sc_prohibit_nonreentrant = \
 exclude_file_name_regexp--sc_prohibit_canonicalize_file_name = \
   ^(build-aux/syntax-check\.mk|tests/virfilemock\.c)$$
 
+exclude_file_name_regexp--sc_prohibit_realpath = \
+  ^(build-aux/syntax-check\.mk|src/cpu_map/sync_qemu_features_i386\.py|tests/virfilemock\.c)$$
+
 exclude_file_name_regexp--sc_prohibit_raw_allocation = \
   ^(docs/advanced-tests\.rst|src/util/viralloc\.[ch]|examples/.*|tests/(securityselinuxhelper|(vircgroup|nss)mock|commandhelper)\.c|tools/wireshark/src/packet-libvirt\.c|tools/nss/libvirt_nss(_leases|_macs)?\.[ch])$$