From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 6D6DB20966 for ; Mon, 3 Apr 2017 04:21:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751161AbdDCEV3 (ORCPT ); Mon, 3 Apr 2017 00:21:29 -0400 Received: from mout.web.de ([212.227.15.4]:55541 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750951AbdDCEV2 (ORCPT ); Mon, 3 Apr 2017 00:21:28 -0400 Received: from [192.168.88.106] ([194.47.243.242]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0McWno-1cdE5C0EbI-00HcA0; Mon, 03 Apr 2017 06:21:22 +0200 Subject: Re: [PATCH v2 1/8] ref-filter: avoid using `unsigned long` for catch-all data type To: Johannes Schindelin , git@vger.kernel.org References: Cc: Junio C Hamano From: =?UTF-8?Q?Torsten_B=c3=b6gershausen?= Message-ID: <342cae56-ef58-3542-202d-6dd04d5777e8@web.de> Date: Mon, 3 Apr 2017 06:22:24 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:S5es0NpjjRBF8QRfi6iHFUMfXVG982IASisE5iM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bulk List-ID: X-Mailing-List: git@vger.kernel.org On 02/04/17 21:06, Johannes Schindelin wrote: > In its `atom_value` struct, the ref-filter source code wants to store > different values in a field called `ul` (for `unsigned long`), e.g. > timestamps. > > However, as we are about to switch the data type of timestamps away from > `unsigned long` (because it may be 32-bit even when `time_t` is 64-bit), > that data type is not large enough. > > Simply change that field to use `uintmax_t` instead. > > This patch is a bit larger than the mere change of the data type > because the field's name was tied to its data type, which has been fixed > at the same time. > > Signed-off-by: Johannes Schindelin > --- > ref-filter.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/ref-filter.c b/ref-filter.c > index 9c82b5b9d63..8538328fc7f 100644 > --- a/ref-filter.c > +++ b/ref-filter.c > @@ -351,7 +351,7 @@ struct ref_formatting_state { > struct atom_value { > const char *s; > void (*handler)(struct atom_value *atomv, struct ref_formatting_state *state); > - unsigned long ul; /* used for sorting when not FIELD_STR */ > + uintmax_t value; /* used for sorting when not FIELD_STR */ > struct used_atom *atom; > }; > > @@ -723,7 +723,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct object > if (!strcmp(name, "objecttype")) > v->s = typename(obj->type); > else if (!strcmp(name, "objectsize")) { > - v->ul = sz; > + v->value = sz; > v->s = xstrfmt("%lu", sz); > } > else if (deref) > @@ -770,8 +770,8 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object > v->s = xstrdup(oid_to_hex(&commit->tree->object.oid)); > } > else if (!strcmp(name, "numparent")) { > - v->ul = commit_list_count(commit->parents); > - v->s = xstrfmt("%lu", v->ul); > + v->value = commit_list_count(commit->parents); > + v->s = xstrfmt("%lu", (unsigned long)v->value); If we want to get rid of "%lu" at some day, we can do like this: v->s = xstrfmt("%" PRIuMAX, v->value); Or, to make clear that under all circumstances an unsigned long is big enough to hold the counter, for readers in the future, use something like this: v->s = xstrfmt("%lu", (xulong_t)v->value); (this is more a reminder to myself, to send such a patch )