Re: fix compile warning for pg_backup_tar.c

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: fix compile warning for pg_backup_tar.c
Date: 2004-11-08 18:24:10
Message-ID: 418FB9CA.9090405@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Peter Eisentraut wrote:

>Andrew Dunstan wrote:
>
>
>>Yet another fix for a useless compile warning. This one is slightly
>>ugly ;-(
>>
>>
>
>First of all, ugly code needs to be documented in the code.
>
>

Ok. Perhaps code that is expected to generate warnings should be too ;-)

>Then, the diff
>
>+ #ifdef INT64_IS_BUSTED
> if (th->fileLen > MAX_TAR_MEMBER_FILELEN)
>+ #else
>+ if (((int64) th->fileLen -1) >= MAX_TAR_MEMBER_FILELEN)
>+ #endif
>
>seems to imply that the current code corresponds to INT64_IS_BUSTED,
>which obviously defies reason.
>
>I remember when I wrote that code I consciously let the compile warning
>stand for platforms with busted int64 because it became too confusing
>to fix. Maybe you can clear that up for us. :)
>
>

The error I saw was on Windows, for which I don't think int64 is busted,
as we have long long int:

pg_backup_tar.c:1022: warning: comparison is always false due to
limited range of data type

ISTM that what is happening here is that the compiler is smart enough to
know that what is in MAX_TAR_MEMBER_FILELEN can't be exceeded by any
possible value of type off_t.

cheers

andrew

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Peter Eisentraut 2004-11-08 18:48:35 Re: fix compile warning for pg_backup_tar.c
Previous Message Tom Lane 2004-11-08 18:12:50 Re: fix compile warning for pg_backup_tar.c