Re: svn commit: r1804618 - /subversion/trunk/build/generator/gen_base.py

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: svn commit: r1804618 - /subversion/trunk/build/generator/gen_base.py

Daniel Shahaf-2
[hidden email] wrote on Thu, 10 Aug 2017 00:09 +0000:
> +++ subversion/trunk/build/generator/gen_base.py Thu Aug 10 00:09:21 2017
> @@ -288,15 +288,21 @@ class GeneratorBase:
> +    # errno names can vary depending on the Python, and possibly the
> +    # OS, version and they are not even used by normal release builds
> +    # so omit them from the tarball. We always want the struct itself
> +    # so that SVN_DEBUG builds still compile.
> +    write_struct('svn__errno',
> +                 [] if self.release_mode else errno.errorcode.items())

Passing an empty list to write_struct() will define svn__errno as:

    static struct {…} svn__errno[] = {};

svn__errno is iterated on with:

    for (i = 0; i < sizeof(svn__errno)/sizeof(svn__errno[0]); i++)

Is this loop iteration style valid for empty arrays?  Looking at C89, it's not
clear to me that sizeof(x[0]) is well-defined for empty arrays.

IIRC, this question affects Windows debug builds since they define SVN_DEBUG.

Cheers,

Daniel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: svn commit: r1804618 - /subversion/trunk/build/generator/gen_base.py

Philip Martin
Daniel Shahaf <[hidden email]> writes:

> Is this loop iteration style valid for empty arrays?  Looking at C89, it's not
> clear to me that sizeof(x[0]) is well-defined for empty arrays.

It builds without warnings using 'gcc -std=c89' but fails if I add
'-pedantic':

../src/subversion/libsvn_subr/errorcode.inc:6:18: warning: ISO C forbids empty initializer braces [-Wpedantic]
 } svn__errno[] = {
                  ^
../src/subversion/libsvn_subr/errorcode.inc:6:3: error: zero or negative size array ‘svn__errno’
 } svn__errno[] = {
   ^~~~~~~~~~

I suppose I could insert a dummy entry for zero.  The code that uses the
array will never look for zero since there is an earlier return.

--
Philip
Loading...