You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Philip Martin <ph...@codematters.co.uk> on 2005/02/13 20:24:39 UTC

compose_delta.c compiler warning

compose_delta.c:copy_source_ops:

              /* This is an overlapping target copy.
                 The idea here is to transpose the pattern, then generate
                 another overlapping copy. */
              const apr_size_t ptn_length = off[0] - op->offset;
              const apr_size_t ptn_overlap = fix_offset % ptn_length;
              apr_size_t fix_off = fix_offset;
              apr_size_t tgt_off = target_offset;
              assert(ptn_length > ptn_overlap);

              if (ptn_overlap >= 0)

The line above causes the warning:

../svn/subversion/libsvn_delta/compose_delta.c:676: warning: comparison of unsigned expression >= 0 is always true

I'm not sure what was intended, possibly it's to catch % returning a
negative value, but fix_offset, ptn_length are unsigned so that should
not happen, and since ptn_overlap is unsigned the test won't catch it
anyway.

                {
                  /* Issue second subrange in the pattern. */
                  const apr_size_t length =
                    MIN(op->length - fix_off - fix_limit,
                        ptn_length - ptn_overlap);
                  copy_source_ops(op->offset + ptn_overlap,
                                  op->offset + ptn_overlap + length,
                                  tgt_off,
                                  build_baton, window, ndx, pool);
                  fix_off += length;
                  tgt_off += length;
                }

-- 
Philip Martin

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

Re: compose_delta.c compiler warning

Posted by Philip Martin <ph...@codematters.co.uk>.
Branko Čibej <br...@xbc.nu> writes:

> Philip Martin wrote:
>
>>              if (ptn_overlap >= 0)
>>
>>The line above causes the warning:
>>
>>../svn/subversion/libsvn_delta/compose_delta.c:676: warning: comparison of unsigned expression >= 0 is always true
>>
>>
> It's not impossible that the test should be >0, not >=0; but my brain
> isn't working very well right now, so I won't venture to guess...

It used to be '>' but r2288, over two years ago, changed it to '>='.

-- 
Philip Martin

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

Re: compose_delta.c compiler warning

Posted by Philip Martin <ph...@codematters.co.uk>.
Branko Čibej <br...@xbc.nu> writes:

> Philip Martin wrote:
>>
>>../svn/subversion/libsvn_delta/compose_delta.c:676: warning: comparison of unsigned expression >= 0 is always true
>>
> Hm, how long has this warning been around? I'm not aware of any
> changes here lately.

I don't think it's new.  You need -Wextra with gcc to see it and that,
as documented, produces lots of unwanted warnings.

-- 
Philip Martin

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

Re: compose_delta.c compiler warning

Posted by Branko Čibej <br...@xbc.nu>.
Philip Martin wrote:

>compose_delta.c:copy_source_ops:
>
>              /* This is an overlapping target copy.
>                 The idea here is to transpose the pattern, then generate
>                 another overlapping copy. */
>              const apr_size_t ptn_length = off[0] - op->offset;
>              const apr_size_t ptn_overlap = fix_offset % ptn_length;
>              apr_size_t fix_off = fix_offset;
>              apr_size_t tgt_off = target_offset;
>              assert(ptn_length > ptn_overlap);
>
>              if (ptn_overlap >= 0)
>
>The line above causes the warning:
>
>../svn/subversion/libsvn_delta/compose_delta.c:676: warning: comparison of unsigned expression >= 0 is always true
>  
>
Hm, how long has this warning been around? I'm not aware of any changes 
here lately.

>I'm not sure what was intended, possibly it's to catch % returning a
>negative value, but fix_offset, ptn_length are unsigned so that should
>not happen, and since ptn_overlap is unsigned the test won't catch it
>anyway.
>
>                {
>                  /* Issue second subrange in the pattern. */
>                  const apr_size_t length =
>                    MIN(op->length - fix_off - fix_limit,
>                        ptn_length - ptn_overlap);
>                  copy_source_ops(op->offset + ptn_overlap,
>                                  op->offset + ptn_overlap + length,
>                                  tgt_off,
>                                  build_baton, window, ndx, pool);
>                  fix_off += length;
>                  tgt_off += length;
>                }
>  
>
It's not impossible that the test should be >0, not >=0; but my brain 
isn't working very well right now, so I won't venture to guess...

-- Brane


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