[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1663760 - svn_hash_sets() type checking

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Wed, 4 Mar 2015 01:22:47 +0000

julianfoad_at_apache.org wrote on Tue, Mar 03, 2015 at 18:09:32 -0000:
> Author: julianfoad
> Date: Tue Mar 3 18:09:32 2015
> New Revision: 1663760
>
> URL: http://svn.apache.org/r1663760
> Log:
> Redefine the svn_hash_gets and svn_hash_sets macros in a way that allows for
> parameter type checking, at least in debug builds.
>
> /** Shortcut for apr_hash_set() with a const char * key.
> *
> * @since New in 1.8.
> */
> -#define svn_hash_sets(ht, key, val) \
> - apr_hash_set(ht, key, APR_HASH_KEY_STRING, val)
> +#define svn_hash_sets(ht, key, val) \
> + do { \
> + const char *svn_hash__key = (key); \
> + apr_hash_set(ht, svn_hash__key, APR_HASH_KEY_STRING, val); \
> + } while (0)

Strictly speaking, that's a backwards-incompatible change. Since the
new definition is no longer an rvalue, API consumers' code would break
if they used svn_hash_sets() as part of a statement. Example:

    /* This works with svn 1.8. */
    #include <subversion-1/svn_hash.h>
    #define my_foo() (svn_hash_sets(h, s), 42)

I think we have to either errata this, or restore svn_hash_gets()'
previous definition and name the do-while version svn_hash_gets2().

Makes sense?

Cheers,

Daniel
Received on 2015-03-04 02:23:24 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.