{"thread":{"id":"45864","subject":"[PATCH] archive-tar: fix a sparse 'constant too large' warning","startedAt":"2017-05-03T23:41:29Z","lastAt":"2017-05-08T00:19:24Z","messageCount":4,"participants":["Ramsay Jones","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"318710","messageId":"252ddd6a-3516-6619-8ea6-d3897f13d93d@ramsayjones.plus.com","threadId":"45864","inReplyTo":null,"subject":"[PATCH] archive-tar: fix a sparse 'constant too large' warning","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2017-05-03T23:41:05Z","receivedAt":"2017-05-03T23:41:29Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nCommit dddbad728c (\"timestamp_t: a new data type for timestamps\",\n26-04-2017) introduced a new typedef 'timestamp_t', as a synonym for an\nunsigned long, which was used at the time to represent timestamps in\ngit. A later commit 28f4aee3fb (\"use uintmax_t for timestamps\",\n26-04-2017) changed the typedef to use an 'uintmax_t' for the timestamp\nrepresentation type.\n\nWhen building on a 32-bit Linux system, sparse complains that a constant\n(USTAR_MAX_MTIME) used to detect a 'far-future mtime' timestamp, is too\nlarge; 'warning: constant 077777777777UL is so big it is unsigned long\nlong' on lines 335 and 338 of archive-tar.c. Note that both gcc and\nclang only issue a warning if this constant is used in a context that\nrequires an 'unsigned long' (rather than an uintmax_t). (Since TIME_MAX\nis no longer equal to 0xFFFFFFFF, even on a 32-bit system, the macro\nUSTAR_MAX_MTIME is set to 077777777777UL, which cannot be represented as\nan 'unsigned long' constant).\n\nIn order to suppress the warning, change the definition of the macro\nconstant to use an 'ULL' type suffix.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n\nHi Junio,\n\nI try to build git on 32-bit Linux about once a week (but it can\nsometimes be less often than that!). During tonight's build sparse\nchirped at me while building the 'next' branch.\n\nThis patch was built on top of next.\n\nATB,\nRamsay Jones\n\n archive-tar.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 319a5b1c7..6dddc0cff 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -33,7 +33,7 @@ static int write_tar_filter_archive(const struct archiver *ar,\n #if TIME_MAX == 0xFFFFFFFF\n #define USTAR_MAX_MTIME TIME_MAX\n #else\n-#define USTAR_MAX_MTIME 077777777777UL\n+#define USTAR_MAX_MTIME 077777777777ULL\n #endif\n \n /* writes out the whole block, but only if it is full */\n-- \n2.12.0\n"},{"id":"318737","messageId":"alpine.DEB.2.21.1.1705041121520.4905@virtualbox","threadId":"45864","inReplyTo":"252ddd6a-3516-6619-8ea6-d3897f13d93d@ramsayjones.plus.com","subject":"Re: [PATCH] archive-tar: fix a sparse 'constant too large' warning","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-05-04T09:26:40Z","receivedAt":"2017-05-04T09:28:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Ramsay,\n\nOn Thu, 4 May 2017, Ramsay Jones wrote:\n\n> diff --git a/archive-tar.c b/archive-tar.c\n> index 319a5b1c7..6dddc0cff 100644\n> --- a/archive-tar.c\n> +++ b/archive-tar.c\n> @@ -33,7 +33,7 @@ static int write_tar_filter_archive(const struct archiver *ar,\n>  #if TIME_MAX == 0xFFFFFFFF\n>  #define USTAR_MAX_MTIME TIME_MAX\n>  #else\n> -#define USTAR_MAX_MTIME 077777777777UL\n> +#define USTAR_MAX_MTIME 077777777777ULL\n>  #endif\n>  \n\nFunny. This problem was pointed out by Hannes Sixt (IIRC) and I fixed this\nvery thing in v6.\n\nExcept I did not. I changed the wrong constant! Instead of\nUSTAR_MAX_MTIME, I adjusted USTAR_MAX_SIZE. D'oh.\n\nI just saw that my patch series already hit `next`, so I fear you are\nright that we need a follow-up patch. Maybe we want this diff, though?\n\n-- snipsnap --\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 319a5b1c7cd..073e60ebd3c 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -28,12 +28,12 @@ static int write_tar_filter_archive(const struct archiver *ar,\n #if ULONG_MAX == 0xFFFFFFFF\n #define USTAR_MAX_SIZE ULONG_MAX\n #else\n-#define USTAR_MAX_SIZE 077777777777ULL\n+#define USTAR_MAX_SIZE 077777777777UL\n #endif\n #if TIME_MAX == 0xFFFFFFFF\n #define USTAR_MAX_MTIME TIME_MAX\n #else\n-#define USTAR_MAX_MTIME 077777777777UL\n+#define USTAR_MAX_MTIME 077777777777ULL\n #endif\n \n /* writes out the whole block, but only if it is full */\n"},{"id":"318816","messageId":"70b431dc-c5cc-e376-b63e-6a58ee1385f1@ramsayjones.plus.com","threadId":"45864","inReplyTo":"alpine.DEB.2.21.1.1705041121520.4905@virtualbox","subject":"Re: [PATCH] archive-tar: fix a sparse 'constant too large' warning","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2017-05-05T01:21:50Z","receivedAt":"2017-05-05T01:21:57Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 04/05/17 10:26, Johannes Schindelin wrote:\n> Hi Ramsay,\n> \n> On Thu, 4 May 2017, Ramsay Jones wrote:\n> \n>> diff --git a/archive-tar.c b/archive-tar.c\n>> index 319a5b1c7..6dddc0cff 100644\n>> --- a/archive-tar.c\n>> +++ b/archive-tar.c\n>> @@ -33,7 +33,7 @@ static int write_tar_filter_archive(const struct archiver *ar,\n>>  #if TIME_MAX == 0xFFFFFFFF\n>>  #define USTAR_MAX_MTIME TIME_MAX\n>>  #else\n>> -#define USTAR_MAX_MTIME 077777777777UL\n>> +#define USTAR_MAX_MTIME 077777777777ULL\n>>  #endif\n>>  \n> \n> Funny. This problem was pointed out by Hannes Sixt (IIRC) and I fixed this\n> very thing in v6.\n> \n> Except I did not. I changed the wrong constant! Instead of\n> USTAR_MAX_MTIME, I adjusted USTAR_MAX_SIZE. D'oh.\n\nAh, I did wonder about that.\n\n> I just saw that my patch series already hit `next`, so I fear you are\n> right that we need a follow-up patch. Maybe we want this diff, though?\n> \n> -- snipsnap --\n> diff --git a/archive-tar.c b/archive-tar.c\n> index 319a5b1c7cd..073e60ebd3c 100644\n> --- a/archive-tar.c\n> +++ b/archive-tar.c\n> @@ -28,12 +28,12 @@ static int write_tar_filter_archive(const struct archiver *ar,\n>  #if ULONG_MAX == 0xFFFFFFFF\n>  #define USTAR_MAX_SIZE ULONG_MAX\n>  #else\n> -#define USTAR_MAX_SIZE 077777777777ULL\n> +#define USTAR_MAX_SIZE 077777777777UL\n\nSure, I can add this. (Although, I don't think it actually\nmatters).\n\nHmm, unless somebody objects in the meantime, I will re-roll\nthe patch (tomorrow, it's late!).\n\n>  #endif\n>  #if TIME_MAX == 0xFFFFFFFF\n>  #define USTAR_MAX_MTIME TIME_MAX\n>  #else\n> -#define USTAR_MAX_MTIME 077777777777UL\n> +#define USTAR_MAX_MTIME 077777777777ULL\n>  #endif\n>  \n>  /* writes out the whole block, but only if it is full */\n> \n\nATB,\nRamsay Jones\n\n\n"},{"id":"319026","messageId":"xmqqshkgci9o.fsf@gitster.mtv.corp.google.com","threadId":"45864","inReplyTo":"70b431dc-c5cc-e376-b63e-6a58ee1385f1@ramsayjones.plus.com","subject":"Re: [PATCH] archive-tar: fix a sparse 'constant too large' warning","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-08T00:19:15Z","receivedAt":"2017-05-08T00:19:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n\n> Sure, I can add this. (Although, I don't think it actually\n> matters).\n>\n> Hmm, unless somebody objects in the meantime, I will re-roll\n> the patch (tomorrow, it's late!).\n\nThanks.\n"}]}