The aim of this rule is to capture the following pattern:
g_autofree const char *var = ...;
The pattern is problematic, because it frees a const pointer. If
written the old way, we'd get a compiler warning:
warning: passing argument 1 of ‘free’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
halt='use signed type for pid values' \
$(_sc_search_regexp)
+sc_prohibit_g_autofree_const:
+ @prohibit='\<g_auto(free|ptr)\>.* const.* \*[^*]' \
+ halt='‘g_autofree’ discards ‘const’ qualifier from pointer target type' \
+ $(_sc_search_regexp)
+
+
# Many of the function names below came from this filter:
# git grep -B2 '\<_('|grep -E '\.c- *[[:alpha:]_][[:alnum:]_]* ?\(.*[,;]$' \
# |sed 's/.*\.c- *//'|perl -pe 's/ ?\(.*//'|sort -u \