From 3a9c8dcdff2d56b8ac663703f2027d8521e6cf4b Mon Sep 17 00:00:00 2001 From: Soumik15630m Date: Mon, 9 Feb 2026 00:07:31 +0530 Subject: [PATCH] NFC: linting fixes --- include/fmt/fmt-c.h | 5 ++--- src/fmt-c.cc | 13 ++++++------- test/test_c.c | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/include/fmt/fmt-c.h b/include/fmt/fmt-c.h index 50720c5f..a3ca0fcf 100644 --- a/include/fmt/fmt-c.h +++ b/include/fmt/fmt-c.h @@ -1,9 +1,9 @@ #ifndef FMT_C_API_H #define FMT_C_API_H +#include #include #include -#include #include #define FMT_C_ABI_VERSION 1 @@ -252,13 +252,12 @@ static inline FmtArg fmt_identity(FmtArg x) { return x; } # define FMT_MAP(f, ...) \ FMT_CAT(FMT_MAP_, FMT_NARG(__VA_ARGS__))(f, ##__VA_ARGS__) -# define fmt_format(buf, cap, fmt, ...) \ +# define fmt_format(buf, cap, fmt, ...) \ fmt_c_format( \ buf, cap, fmt, \ (FmtArg[]){{FMT_INT}, FMT_MAP(FMT_MAKE_ARG, ##__VA_ARGS__)} + 1, \ FMT_NARG(__VA_ARGS__)) - #endif // !__cplusplus #endif // FMT_C_API_H \ No newline at end of file diff --git a/src/fmt-c.cc b/src/fmt-c.cc index 4b7dd031..87c6a156 100644 --- a/src/fmt-c.cc +++ b/src/fmt-c.cc @@ -9,7 +9,6 @@ #include #include - extern "C" { int fmt_c_get_version(void) { return FMT_C_ABI_VERSION; } @@ -62,7 +61,8 @@ static bool populate_store(const FmtArg* c_args, size_t arg_count, case FMT_CUSTOM: { if (!c_args[i].custom_fn || !c_args[i].value.ptr) { - g_fixed_store[i] = fmt::basic_format_arg(fmt::string_view("")); + g_fixed_store[i] = + fmt::basic_format_arg(fmt::string_view("")); return false; } @@ -90,14 +90,13 @@ static bool populate_store(const FmtArg* c_args, size_t arg_count, break; } - default: - return false; + default: return false; } } return true; } int fmt_c_format(char* buffer, size_t capacity, const char* format_str, - const FmtArg* args, size_t arg_count) { + const FmtArg* args, size_t arg_count) { if (!format_str) return FMT_ERR_NULL_FORMAT; if (arg_count > FMT_C_MAX_ARGS) return FMT_ERR_INVALID_ARG; @@ -119,7 +118,8 @@ int fmt_c_format(char* buffer, size_t capacity, const char* format_str, return static_cast(result.size); } - auto result = fmt::vformat_to_n(buffer, capacity - 1, format_str, format_args_view); + auto result = + fmt::vformat_to_n(buffer, capacity - 1, format_str, format_args_view); *result.out = '\0'; return static_cast(result.size); @@ -130,5 +130,4 @@ int fmt_c_format(char* buffer, size_t capacity, const char* format_str, } } - } // extern "C" \ No newline at end of file diff --git a/test/test_c.c b/test/test_c.c index 51f8fd32..726206c1 100644 --- a/test/test_c.c +++ b/test/test_c.c @@ -297,7 +297,7 @@ TEST(all_integer_types) { unsigned long long ull = 800ULL; fmt_format(buf, sizeof(buf), "{} {} {} {} {} {} {} {}", s, i, l, ll, us, ui, - ul, ull); + ul, ull); ASSERT_TRUE(strstr(buf, "100") != NULL); ASSERT_TRUE(strstr(buf, "800") != NULL); }