~sircmpwn/scdoc

1923fb61cd71182f05d029f280d056b21f66e8a0 — Dimitry Andric 3 months ago 4af1e1e
Fix clang 15 -Wstrict-prototypes warnings

As of https://github.com/llvm/llvm-project/commit/11da1b53d8c, clang 15
has started warning about functions which take no arguments, but are
declared or defined using "()" instead of "(void)". See also [1].

At first this was even an error by default, but before clang 15 was
released, it was again downgraded to a warning. Since scdoc builds
with both "-std=c99 -pedantic" and "-Wall -Wextra -Werror", this leads
to two compile errors:

    include/str.h:10:23: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    struct str *str_create();
                          ^
                           void
    src/string.c:15:23: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    struct str *str_create() {
                          ^
                           void

To fix this, use "(void)" for both the declaration and definition of the
str_create function.

[1] https://discourse.llvm.org/t/rfc-enabling-wstrict-prototypes-by-default-in-c/60521
2 files changed, 2 insertions(+), 2 deletions(-)

M include/str.h
M src/string.c
M include/str.h => include/str.h +1 -1
@@ 7,7 7,7 @@ struct str {
	size_t len, size;
};

struct str *str_create();
struct str *str_create(void);
void str_free(struct str *str);
void str_reset(struct str *str);
int str_append_ch(struct str *str, uint32_t ch);

M src/string.c => src/string.c +1 -1
@@ 12,7 12,7 @@ static void ensure_capacity(struct str *str, size_t len) {
	}
}

struct str *str_create() {
struct str *str_create(void) {
	struct str *str = xcalloc(1, sizeof(struct str));
	str->str = xcalloc(16, 1);
	str->size = 16;