]> xenbits.xensource.com Git - libvirt.git/commitdiff
syntax-check: Forbid use of qsort()
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 23 Nov 2023 09:54:57 +0000 (10:54 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 24 Nov 2023 08:53:14 +0000 (09:53 +0100)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
build-aux/syntax-check.mk
tools/nss/libvirt_nss.c

index 309ca0c29a9be4c2a1bda1ef615e3c47c0c5698f..eaeb6d4f23fdf0277a1f1d387cb0cf0bbc123c4d 100644 (file)
@@ -248,6 +248,13 @@ sc_prohibit_canonicalize_file_name:
        halt='use virFileCanonicalizePath() instead of canonicalize_file_name()' \
          $(_sc_search_regexp)
 
+# qsort from glibc has unstable sort ordering for "equal" members
+sc_prohibit_qsort:
+       @prohibit='\<(qsort|qsort_r) *\(' \
+       exclude='exempt from syntax-check' \
+       halt='use g_qsort_with_data instead of qsort' \
+         $(_sc_search_regexp)
+
 # Insist on correct types for [pug]id.
 sc_correct_id_types:
        @prohibit='\<(int|long) *[pug]id\>' \
index ff6ea1d3732ae713cbfdc346f71a24dc99fdd512..d79a00a1b0b0e1735dc0248497c499388efeab1f 100644 (file)
@@ -71,7 +71,8 @@ sortAddr(leaseAddress *tmpAddress,
          size_t ntmpAddress)
 {
     if (tmpAddress)
-        qsort(tmpAddress, ntmpAddress, sizeof(*tmpAddress), leaseAddressSorter);
+        qsort(tmpAddress, ntmpAddress, /* exempt from syntax-check */
+              sizeof(*tmpAddress), leaseAddressSorter);
 }