[libvirt] [PATCH v3 5/9] syntax-check: Prohibit canonicalize_file_name()

Andrea Bolognani posted 9 patches 7 years ago
[libvirt] [PATCH v3 5/9] syntax-check: Prohibit canonicalize_file_name()
Posted by Andrea Bolognani 7 years ago
We want to make sure our wrapper is used instead in order
to keep the test suite working.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 cfg.mk             | 10 ++++++++++
 src/util/virfile.c |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/cfg.mk b/cfg.mk
index c3d18279ce..6bebd0ad9f 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -462,6 +462,13 @@ sc_prohibit_ctype_h:
 	halt='use c-ctype.h instead of ctype.h' \
 	  $(_sc_search_regexp)
 
+# We have our own wrapper for mocking purposes
+sc_prohibit_canonicalize_file_name:
+	@prohibit='\<canonicalize_file_name\(' \
+	exclude='exempt from syntax-check' \
+	halt='use virFileCanonicalizePath() instead of canonicalize_file_name()' \
+	  $(_sc_search_regexp)
+
 # Insist on correct types for [pug]id.
 sc_correct_id_types:
 	@prohibit='\<(int|long) *[pug]id\>' \
@@ -1208,6 +1215,9 @@ exclude_file_name_regexp--sc_prohibit_nonreentrant = \
 exclude_file_name_regexp--sc_prohibit_select = \
 	^cfg\.mk$$
 
+exclude_file_name_regexp--sc_prohibit_canonicalize_file_name = \
+  ^cfg\.mk$$
+
 exclude_file_name_regexp--sc_prohibit_raw_allocation = \
   ^(docs/hacking\.html\.in|src/util/viralloc\.[ch]|examples/.*|tests/(securityselinuxhelper|(vircgroup|nss)mock|commandhelper)\.c|tools/wireshark/src/packet-libvirt\.c)$$
 
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 41dda410cb..40f106d01d 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -3309,7 +3309,7 @@ virFileSanitizePath(const char *path)
 char *
 virFileCanonicalizePath(const char *path)
 {
-    return canonicalize_file_name(path);
+    return canonicalize_file_name(path); /* exempt from syntax-check */
 }
 
 /**
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 5/9] syntax-check: Prohibit canonicalize_file_name()
Posted by Daniel P. Berrangé 7 years ago
On Thu, May 03, 2018 at 12:54:19PM +0200, Andrea Bolognani wrote:
> We want to make sure our wrapper is used instead in order
> to keep the test suite working.
> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>  cfg.mk             | 10 ++++++++++
>  src/util/virfile.c |  2 +-
>  2 files changed, 11 insertions(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list