You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Stefan Sperling <st...@elego.de> on 2008/04/04 09:15:55 UTC

"null format string" warnings on trunk - what to do?

Hi,

I'm getting these warnings compiling current trunk:

subversion/svn/util.c: In function 'svn_cl__merge_file_externally':
subversion/svn/util.c:245: warning: null format string

subversion/svnadmin/main.c: In function 'subcommand_setuuid':
subversion/svnadmin/main.c:1059: warning: null format string

subversion/libsvn_ra_svn/cyrus_auth.c: In function 'svn_ra_svn__get_addresses':
subversion/libsvn_ra_svn/cyrus_auth.c:694: warning: null format string
subversion/libsvn_ra_svn/cyrus_auth.c:698: warning: null format string
subversion/libsvn_ra_svn/cyrus_auth.c:702: warning: null format string
subversion/libsvn_ra_svn/cyrus_auth.c:706: warning: null format string

In all these cases, the argument supplied to the functions in
question is indeed simply NULL.

I don't know whether we should ignore these warnings or not.

I'm using the following gcc version (this is on FreeBSD-7.0):

gcc (GCC) 4.2.1 20070719  [FreeBSD]
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Thanks,
-- 
Stefan Sperling <st...@elego.de>                 Software Developer
elego Software Solutions GmbH                            HRB 77719
Gustav-Meyer-Allee 25, Gebaeude 12        Tel:  +49 30 23 45 86 96 
13355 Berlin                              Fax:  +49 30 23 45 86 95
http://www.elego.de                 Geschaeftsfuehrer: Olaf Wagner

Re: "null format string" warnings on trunk - what to do?

Posted by Julian Foad <ju...@btopenworld.com>.
Stefan Sperling wrote:
> Hi,
> 
> I'm getting these warnings compiling current trunk:
> 
> subversion/svn/util.c: In function 'svn_cl__merge_file_externally':
> subversion/svn/util.c:245: warning: null format string
> 
> subversion/svnadmin/main.c: In function 'subcommand_setuuid':
> subversion/svnadmin/main.c:1059: warning: null format string
> 
> subversion/libsvn_ra_svn/cyrus_auth.c: In function 'svn_ra_svn__get_addresses':
> subversion/libsvn_ra_svn/cyrus_auth.c:694: warning: null format string
> subversion/libsvn_ra_svn/cyrus_auth.c:698: warning: null format string
> subversion/libsvn_ra_svn/cyrus_auth.c:702: warning: null format string
> subversion/libsvn_ra_svn/cyrus_auth.c:706: warning: null format string
> 
> In all these cases, the argument supplied to the functions in
> question is indeed simply NULL.
> 
> I don't know whether we should ignore these warnings or not.

The second one is wrong because svn_error_createf() isn't specified as allowing 
NULL for its format argument. In fact it's demonstrably wrong:

[[[
$ svnadmin setuuid a b c
Segmentation fault
]]]

(It's not a big deal because the bug is in the "svnadmin" program in an 
erroneous usage situation (too many arguments), and not in a library function.)

Fixed in r30256.

The rest are harmless but could be improved. svn_error_wrap_apr() is defined as 
accepting a null format string:

/** Wrap a @a status from an APR function.  If @a fmt is NULL, this is
  * equivalent to svn_error_create(status,NULL,NULL).  Otherwise,
  * [...]
  */
svn_error_t *svn_error_wrap_apr(apr_status_t status, const char *fmt, ...)
        __attribute__((format(printf, 2, 3)));

The "__attribute__" tells the compiler otherwise. We could change something 
here... and/or just stop calling it with NULL and use 
svn_error_create(status,NULL,NULL) instead.

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org