From c73aa60b0d0adb1732f5946188e5b161b7788e93 Mon Sep 17 00:00:00 2001 From: Andrei Alexeyev Date: Fri, 30 Aug 2024 11:08:41 +0200 Subject: [PATCH] util/stringops: constify hexdigest() --- src/util/stringops.c | 4 ++-- src/util/stringops.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/stringops.c b/src/util/stringops.c index a52255ac2..2f159d17d 100644 --- a/src/util/stringops.c +++ b/src/util/stringops.c @@ -364,11 +364,11 @@ void format_huge_num(uint digits, uint64_t num, size_t bufsize, char buf[bufsize assert(p == buf + len - 1); } -void hexdigest(uint8_t *input, size_t input_size, char *output, size_t output_size) { +void hexdigest(const uint8_t *input, size_t input_size, char *output, size_t output_size) { assert(output_size > input_size * 2); static char charmap[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; - uint8_t *end = input + input_size; + const uint8_t *end = input + input_size; while(input < end) { uint8_t byte = *input++; diff --git a/src/util/stringops.h b/src/util/stringops.h index 186087150..6bd04ebdb 100644 --- a/src/util/stringops.h +++ b/src/util/stringops.h @@ -78,7 +78,7 @@ char* ucs4_to_utf8_alloc(const uint32_t *ucs4) attr_nonnull(1) attr_returns_allo uint32_t utf8_getch(const char **src) attr_nonnull(1); void format_huge_num(uint digits, uint64_t num, size_t bufsize, char buf[bufsize]); -void hexdigest(uint8_t *input, size_t input_size, char *output, size_t output_size); +void hexdigest(const uint8_t *input, size_t input_size, char *output, size_t output_size); #define FILENAME_TIMESTAMP_MIN_BUF_SIZE 23 size_t filename_timestamp(char *buf, size_t buf_size, const SystemTime time) attr_nonnull(1);