[PATCH] build: prohibit realpath() by syntax-check

Michal Privoznik via Devel posted 1 patch 5 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/d78736142fe387e879752c13c9b74c0b533e240a.1751616764.git.mprivozn@redhat.com
build-aux/syntax-check.mk | 9 +++++++++
1 file changed, 9 insertions(+)
[PATCH] build: prohibit realpath() by syntax-check
Posted by Michal Privoznik via Devel 5 months, 2 weeks ago
From: Michal Privoznik <mprivozn@redhat.com>

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>
---
 build-aux/syntax-check.mk | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk
index 1303a0ce7e..27eabe6565 100644
--- a/build-aux/syntax-check.mk
+++ b/build-aux/syntax-check.mk
@@ -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])$$
 
-- 
2.49.0
Re: [PATCH] build: prohibit realpath() by syntax-check
Posted by Ján Tomko via Devel 5 months, 1 week ago
On a Friday in 2025, Michal Privoznik via Devel wrote:
>From: Michal Privoznik <mprivozn@redhat.com>
>
>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>
>---
> build-aux/syntax-check.mk | 9 +++++++++
> 1 file changed, 9 insertions(+)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano