sfinx

sphincs+ inspired signing utility
git clone git://git.finwo.net/app/sfinx
Log | Files | Refs | README

commit 3fd6d6059ae69c79b63d2bc8c3c46563cce88441
parent 4842126114294e2014be013021164b3d8f95e109
Author: finwo <finwo@pm.me>
Date:   Fri,  9 Oct 2026 15:48:23 +0200

Auto-formatting

Diffstat:
M.clang-format | 2+-
MMakefile | 1+
Msrc/cli/help.c | 3+--
Msrc/cli/registry.c | 19++++++++++---------
Msrc/cli/registry.h | 6+++---
Msrc/sfinx.c | 2+-
Mtest/00-e4m4.c | 14+++++++-------
7 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/.clang-format b/.clang-format @@ -75,7 +75,7 @@ AllowAllParametersOfDeclarationOnNextLine: true AllowBreakBeforeNoexceptSpecifier: Never AllowShortBlocksOnASingleLine: Never AllowShortCaseExpressionOnASingleLine: true -AllowShortCaseLabelsOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: true AllowShortCompoundRequirementOnASingleLine: true AllowShortEnumsOnASingleLine: true AllowShortFunctionsOnASingleLine: None diff --git a/Makefile b/Makefile @@ -39,6 +39,7 @@ Makefile: ; .PHONY: format format: $(FIND) src/ -type f \( -name '*.c' -o -name '*.h' \) -exec clang-format -i {} + + $(FIND) test/ -type f \( -name '*.c' -o -name '*.h' \) -exec clang-format -i {} + # Forward any other goal verbatim into the assembled target tree .PHONY: FORCE diff --git a/src/cli/help.c b/src/cli/help.c @@ -9,7 +9,6 @@ int main_help(int argc, char *argv[]) { return 0; } -__attribute__((constructor)) -static void register_help(void) { +__attribute__((constructor)) static void register_help(void) { cli_register("help", main_help); } diff --git a/src/cli/registry.c b/src/cli/registry.c @@ -1,17 +1,18 @@ +#include "registry.h" + #include <stdlib.h> #include <string.h> -#include "registry.h" #define CLI_MAX 32 static const char *cli_names[CLI_MAX]; static cli_main_fn cli_fns[CLI_MAX]; -static int cli_count = 0; +static int cli_count = 0; void cli_register(const char *name, cli_main_fn fn) { if (cli_count >= CLI_MAX) return; cli_names[cli_count] = name; - cli_fns[cli_count] = fn; + cli_fns[cli_count] = fn; cli_count++; } @@ -22,15 +23,15 @@ cli_main_fn cli_find(const char *name) { return NULL; } -char * cli_registered() { +char *cli_registered() { char *out; - int len=1; - for(int i=0; i<cli_count; i++) { - if (i) len+=2; - len+=strlen(cli_names[i]); + int len = 1; + for (int i = 0; i < cli_count; i++) { + if (i) len += 2; + len += strlen(cli_names[i]); } out = calloc(1, len); - for(int i=0; i<cli_count; i++) { + for (int i = 0; i < cli_count; i++) { if (i) strcat(out, ", "); strcat(out, cli_names[i]); } diff --git a/src/cli/registry.h b/src/cli/registry.h @@ -3,8 +3,8 @@ typedef int (*cli_main_fn)(int argc, char **argv); -void cli_register(const char *name, cli_main_fn fn); +void cli_register(const char *name, cli_main_fn fn); cli_main_fn cli_find(const char *name); -char * cli_registered(); +char *cli_registered(); -#endif // __SFINX_CLI_REGISTRY_H__ +#endif // __SFINX_CLI_REGISTRY_H__ diff --git a/src/sfinx.c b/src/sfinx.c @@ -21,7 +21,7 @@ static inline uint32_t _sfinx_e4m4_encode(uint32_t value, uint8_t *out) { return 1; } - uint32_t base = value; + uint32_t base = value; uint32_t shift = 0; while (base > 31) { base >>= 1; diff --git a/test/00-e4m4.c b/test/00-e4m4.c @@ -1,9 +1,9 @@ -#include "src/sfinx.c" -#include "_tap.c" - #include <inttypes.h> #include <limits.h> +#include "_tap.c" +#include "src/sfinx.c" + static void check_u32(uint32_t got, uint32_t want, const char *what) { tap(got == want, what, "got %" PRIu32 ", want %" PRIu32, got, want); } @@ -18,9 +18,9 @@ static void check_encode(uint32_t value, uint8_t want, const char *what) { } int main(void) { - uint8_t scratch = 0; + uint8_t scratch = 0; uint32_t round_ok = 1; - int bad = -1; + int bad = -1; tap_begin("sfinx E4M4"); @@ -55,11 +55,11 @@ int main(void) { check_u32(_sfinx_e4m4_encode(UINT32_MAX, &scratch), 0, "reject UINT32_MAX"); for (int i = 0; i < 256; i++) { - uint8_t round = 0; + uint8_t round = 0; uint32_t value = _sfinx_e4m4_decode((uint8_t)i); if (!_sfinx_e4m4_encode(value, &round) || round != (uint8_t)i) { round_ok = 0; - bad = i; + bad = i; break; } }