syntax-check: Forbid use of qsort()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Michal Privoznik 2023-11-23 10:54:57 +01:00
parent cfcbba4c2b
commit 5dff94115c
2 changed files with 9 additions and 1 deletions

View 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\>' \

View 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);
}