[Rpm-maint] [patch] warnings for rpmExpand(), rpmlog(), rpmGetPath()

Michal Marek mmarek at suse.cz
Wed Feb 13 15:19:41 UTC 2008


gcc allows to mark variadic functions that expect a terminating NULL as
such and issues a warning if the caller doesn't pass the NULL. A similar
mechanism is available for printf-like functions. What about using this
for the few variadic functions in the rpmlib API? It would help to catch
some mistakes at compile-time rather than at run-time, e.g:

  char *test1 = rpmExpand("%_sourcedir");
  char *test2 = rpmExpand("%_topdir", " ");

$ gcc -Wall -I ./include -c test.c
test.c: In function 'main':
test.c:9: warning: not enough variable arguments to fit a sentinel
test.c:10: warning: missing sentinel in function call

Attached are two patches, the first one marks rpmExpand() and
rpmGetPath() with __attribute__((sentinel)) for gcc 4.0+ and rpmlog()
with __attribute__((format (printf, 2, 3))). The second patch silences
warnings in rpmlog() calls that now show up.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: variadic-checks.patch
Type: text/x-patch
Size: 1860 bytes
Desc: not available
Url : http://lists.rpm.org/pipermail/rpm-maint/attachments/20080213/e804b511/attachment-0002.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: warnings.patch
Type: text/x-patch
Size: 7881 bytes
Desc: not available
Url : http://lists.rpm.org/pipermail/rpm-maint/attachments/20080213/e804b511/attachment-0003.bin 

More information about the Rpm-maint mailing list