Re: [PATCH 2/3] treewide: switch to khashl for memory savings
From: Junio C Hamano <hidden>
Date: 2024-03-27 21:54:27
Jeff King [off-list ref] writes:
quoted hunk
On Tue, Mar 26, 2024 at 10:48:40AM -0700, Junio C Hamano wrote:quoted
$ make builtin/fast-import.sp ;# part of make sparse SP builtin/fast-import.c builtin/fast-import.c: note: in included file (through oidset.h, packfile.h): khashl.h:516:1: error: Using plain integer as NULL pointer khashl.h:516:1: error: Using plain integer as NULL pointer make: *** [Makefile:3237: builtin/fast-import.sp] Error 1 I found IMPL_GET and IMPL_DEL's use of (h->keys == 0) were giving one of these two, and managed to reduce the error to just one with the attached patch, but I don't know what the other error is coming from.Probably:diff --git a/khashl.h b/khashl.h index 8fcebed237..1e724bbf88 100644 --- a/khashl.h +++ b/khashl.h@@ -116,7 +116,7 @@ static kh_inline khint_t __kh_h2b(khint_t hash, khint_t bits) { return hash * 26 #define __KHASHL_IMPL_RESIZE(SCOPE, HType, prefix, khkey_t, __hash_fn, __hash_eq) \ SCOPE void prefix##_resize(HType *h, khint_t new_n_buckets) { \ - khint32_t *new_used = 0; \ + khint32_t *new_used = NULL; \ khint_t j = 0, x = new_n_buckets, n_buckets, new_bits, new_mask; \ while ((x >>= 1) != 0) ++j; \ if (new_n_buckets & (new_n_buckets - 1)) ++j; \ -Peff
Spot on. With this (and the other two 0 -> NULL fixes), and with the SWAP() thing in brian's credential series fixed, the tip of 'seen' passes the static-analysis and sparse CI jobs again. Thanks.