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 use `uintmax_t` instead.

Unfortunately, this patch is larger than that because the field's name
was tied to its data type.

Signed-off-by: Johannes Schindelin <johannes.schinde...@gmx.de>
---
 ref-filter.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/ref-filter.c b/ref-filter.c
index 07c1f372351..b8b34d4dd9e 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -236,7 +236,7 @@ struct atom_value {
                struct align align;
        } u;
        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 */
 };
 
 /*
@@ -492,7 +492,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)
@@ -539,8 +539,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);
                }
                else if (!strcmp(name, "parent")) {
                        struct commit_list *parents;
@@ -644,11 +644,11 @@ static void grab_date(const char *buf, struct atom_value 
*v, const char *atomnam
        if ((tz == LONG_MIN || tz == LONG_MAX) && errno == ERANGE)
                goto bad;
        v->s = xstrdup(show_date(timestamp, tz, &date_mode));
-       v->ul = timestamp;
+       v->value = timestamp;
        return;
  bad:
        v->s = "";
-       v->ul = 0;
+       v->value = 0;
 }
 
 /* See grab_values */
@@ -1583,9 +1583,9 @@ static int cmp_ref_sorting(struct ref_sorting *s, struct 
ref_array_item *a, stru
        else if (cmp_type == FIELD_STR)
                cmp = cmp_fn(va->s, vb->s);
        else {
-               if (va->ul < vb->ul)
+               if (va->value < vb->value)
                        cmp = -1;
-               else if (va->ul == vb->ul)
+               else if (va->value == vb->value)
                        cmp = cmp_fn(a->refname, b->refname);
                else
                        cmp = 1;
-- 
2.11.1.windows.1.379.g44ae0bc


Reply via email to