summaryrefslogtreecommitdiff
path: root/reftable/stack.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-02-18 10:20:47 +0100
committerJunio C Hamano <gitster@pobox.com>2025-02-18 10:55:38 -0800
commit712f6cfe5411fdbbf46688c22a40fac7e0a8839b (patch)
treefb0447412882a7180e60f71a8f617cb7d3b980df /reftable/stack.c
parent01a587da8cf89f9d6c8c5b19ea3e109efb7c9b7c (diff)
reftable/system: introduce `reftable_rand()`
Introduce a new system-level `reftable_rand()` function that generates a single unsigned integer for us. The implementation of this function is to be provided by the calling codebase, which allows us to more easily hook into pre-seeded random number generators. Adapt the two callsites where we generated random data. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/stack.c')
-rw-r--r--reftable/stack.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/reftable/stack.c b/reftable/stack.c
index c33f0c3333..08893fd454 100644
--- a/reftable/stack.c
+++ b/reftable/stack.c
@@ -523,7 +523,7 @@ static int reftable_stack_reload_maybe_reuse(struct reftable_stack *st,
close(fd);
fd = -1;
- delay = delay + (delay * git_rand(CSPRNG_BYTES_INSECURE)) / UINT32_MAX + 1;
+ delay = delay + (delay * reftable_rand()) / UINT32_MAX + 1;
sleep_millisec(delay);
}
@@ -688,7 +688,7 @@ int reftable_stack_add(struct reftable_stack *st,
static int format_name(struct reftable_buf *dest, uint64_t min, uint64_t max)
{
char buf[100];
- uint32_t rnd = git_rand(CSPRNG_BYTES_INSECURE);
+ uint32_t rnd = reftable_rand();
snprintf(buf, sizeof(buf), "0x%012" PRIx64 "-0x%012" PRIx64 "-%08x",
min, max, rnd);
reftable_buf_reset(dest);