RPM Community Forums

Mailing List Message of <rpm-devel>

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

From: Mark Hatle <mark.hatle@windriver.com>
Date: Wed 13 Feb 2008 - 17:05:06 CET
Message-ID: <47B31532.9000109@windriver.com>
This is a fairly interesting patch that was sent to the rpm.org list. 
Is this something we're interested in?  It may point out some issues 
with rpm5, or future development.. (At the expense of gcc 4...)

--Mark

-------- Original Message --------
Subject: [Rpm-maint] 	[patch] warnings for rpmExpand(), rpmlog(), 
rpmGetPath()
Date: Wed, 13 Feb 2008 16:19:41 +0100
From: Michal Marek <mmarek@suse.cz>
To: rpm-maint@lists.rpm.org

Hi,

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.

Comments?

Michal


_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
https://lists.rpm.org/mailman/listinfo/rpm-maint



Received on Wed Feb 13 17:05:09 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.