From dbe2e97facd9e1b2dc2e62ce1a7291d8ff3d543c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81ris=20Narti=C5=A1s?= Date: Fri, 31 Jul 2026 09:24:17 +0300 Subject: [PATCH] r.stats: bump up counts storage to unsigned long long On Windows `log` is 32bit and only `long long` is 64bit. Fixes: #7769 Authored by Claude Sonnet 4.6 --- raster/r.stats/stats.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/raster/r.stats/stats.c b/raster/r.stats/stats.c index 66f67d49a28..6a27a12cf1f 100644 --- a/raster/r.stats/stats.c +++ b/raster/r.stats/stats.c @@ -23,14 +23,14 @@ struct Node { struct Node *left; struct Node *right; struct Node *list; - long count; + unsigned long long count; double area; }; static struct Node **hashtable; static struct Node *node_list = NULL; static int node_count = 0; -static long total_count = 0; +static unsigned long long total_count = 0; int initialize_cell_stats(int n) { @@ -200,7 +200,7 @@ static int node_compare(const void *pp, const void *qq) static int node_compare_count_asc(const void *pp, const void *qq) { struct Node *const *p = pp, *const *q = qq; - long a, b; + unsigned long long a, b; a = (*p)->count; b = (*q)->count; @@ -213,7 +213,7 @@ static int node_compare_count_asc(const void *pp, const void *qq) static int node_compare_count_desc(const void *pp, const void *qq) { struct Node *const *p = pp, *const *q = qq; - long a, b; + unsigned long long a, b; a = (*p)->count; b = (*q)->count; @@ -550,7 +550,8 @@ int print_cell_stats(char *fmt, int with_percents, int with_counts, break; case CSV: case PLAIN: - fprintf(stdout, "%s%ld", fs, (long)node->count); + fprintf(stdout, "%s%llu", fs, + (unsigned long long)node->count); break; } }