Skip to content

Commit 3a9c8dc

Browse files
committed
NFC: linting fixes
1 parent 181ef32 commit 3a9c8dc

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

include/fmt/fmt-c.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef FMT_C_API_H
22
#define FMT_C_API_H
33

4+
#include <stdbool.h>
45
#include <stddef.h>
56
#include <stdint.h>
6-
#include <stdbool.h>
77
#include <stdio.h>
88

99
#define FMT_C_ABI_VERSION 1
@@ -252,13 +252,12 @@ static inline FmtArg fmt_identity(FmtArg x) { return x; }
252252
# define FMT_MAP(f, ...) \
253253
FMT_CAT(FMT_MAP_, FMT_NARG(__VA_ARGS__))(f, ##__VA_ARGS__)
254254

255-
# define fmt_format(buf, cap, fmt, ...) \
255+
# define fmt_format(buf, cap, fmt, ...) \
256256
fmt_c_format( \
257257
buf, cap, fmt, \
258258
(FmtArg[]){{FMT_INT}, FMT_MAP(FMT_MAKE_ARG, ##__VA_ARGS__)} + 1, \
259259
FMT_NARG(__VA_ARGS__))
260260

261-
262261
#endif // !__cplusplus
263262

264263
#endif // FMT_C_API_H

src/fmt-c.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <string>
1010
#include <vector>
1111

12-
1312
extern "C" {
1413

1514
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,
6261

6362
case FMT_CUSTOM: {
6463
if (!c_args[i].custom_fn || !c_args[i].value.ptr) {
65-
g_fixed_store[i] = fmt::basic_format_arg<Context>(fmt::string_view("<error>"));
64+
g_fixed_store[i] =
65+
fmt::basic_format_arg<Context>(fmt::string_view("<error>"));
6666
return false;
6767
}
6868

@@ -90,14 +90,13 @@ static bool populate_store(const FmtArg* c_args, size_t arg_count,
9090
break;
9191
}
9292

93-
default:
94-
return false;
93+
default: return false;
9594
}
9695
}
9796
return true;
9897
}
9998
int fmt_c_format(char* buffer, size_t capacity, const char* format_str,
100-
const FmtArg* args, size_t arg_count) {
99+
const FmtArg* args, size_t arg_count) {
101100
if (!format_str) return FMT_ERR_NULL_FORMAT;
102101
if (arg_count > FMT_C_MAX_ARGS) return FMT_ERR_INVALID_ARG;
103102

@@ -119,7 +118,8 @@ int fmt_c_format(char* buffer, size_t capacity, const char* format_str,
119118
return static_cast<int>(result.size);
120119
}
121120

122-
auto result = fmt::vformat_to_n(buffer, capacity - 1, format_str, format_args_view);
121+
auto result =
122+
fmt::vformat_to_n(buffer, capacity - 1, format_str, format_args_view);
123123
*result.out = '\0';
124124
return static_cast<int>(result.size);
125125

@@ -130,5 +130,4 @@ int fmt_c_format(char* buffer, size_t capacity, const char* format_str,
130130
}
131131
}
132132

133-
134133
} // extern "C"

test/test_c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ TEST(all_integer_types) {
297297
unsigned long long ull = 800ULL;
298298

299299
fmt_format(buf, sizeof(buf), "{} {} {} {} {} {} {} {}", s, i, l, ll, us, ui,
300-
ul, ull);
300+
ul, ull);
301301
ASSERT_TRUE(strstr(buf, "100") != NULL);
302302
ASSERT_TRUE(strstr(buf, "800") != NULL);
303303
}

0 commit comments

Comments
 (0)