Re: [PATCH v5 6/8] Introduce a new data type for timestamps
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Apr 26, 2017, 16:43 UTC
- Message-ID
- <c6bcc382-f526-cf0c-8181-3985216e6c2b@kdbg.org>
- In-Reply-To
- <fea2df0e1ff5869572cf756d75fd3468d184457f.1493042239.git.johannes.schindelin@gmx.de>
Am 24.04.2017 um 15:58 schrieb Johannes Schindelin:
Show 12 quoted lines
> diff --git a/archive-tar.c b/archive-tar.c > index 380e3aedd23..695339a2369 100644 > --- a/archive-tar.c > +++ b/archive-tar.c > @@ -27,9 +27,12 @@ static int write_tar_filter_archive(const struct archiver *ar, > */ > #if ULONG_MAX == 0xFFFFFFFF > #define USTAR_MAX_SIZE ULONG_MAX > -#define USTAR_MAX_MTIME ULONG_MAX > #else > #define USTAR_MAX_SIZE 077777777777UL > +#endif
This part of the hunk is fine: if ULONG_MAX is not 2^32-1, then 2^33-1 will fit in a long.
Show 5 quoted lines
> +#if TIME_MAX == 0xFFFFFFFF > +#define USTAR_MAX_MTIME TIME_MAX > +#else > #define USTAR_MAX_MTIME 077777777777UL > #endif
But this is not: just because TIME_MAX is not 32 bits, does not mean that long is also more than 32 bits. We need this:
diff --git a/archive-tar.c b/archive-tar.c index aadd5865f6..b5d6ce27d3 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -33,7 +33,7 @@ static int write_tar_filter_archive(const struct archiver *ar, #if TIME_MAX == 0xFFFFFFFF #define USTAR_MAX_MTIME TIME_MAX #else -#define USTAR_MAX_MTIME 077777777777UL +#define USTAR_MAX_MTIME 077777777777ULL #endif /* writes out the whole block, but only if it is full */