libdrgn: enable -Wmissing-prototypes

This requires workarounds for the Python module initialization function
and the test function exports.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
This commit is contained in:
Omar Sandoval 2023-10-02 15:52:32 -07:00
parent 154b77aa3a
commit e83d918c90
3 changed files with 18 additions and 2 deletions

View File

@ -111,6 +111,7 @@ AS_IF([test "x$enable_compiler_warnings" != xno],
-Wformat-overflow=2 dnl -Wformat-overflow=2 dnl
-Wformat-truncation=2 dnl -Wformat-truncation=2 dnl
-Wimplicit-fallthrough dnl -Wimplicit-fallthrough dnl
-Wmissing-prototypes dnl
-Wvla dnl -Wvla dnl
], [WARN_CFLAGS], [$compiler_flags_test])]) ], [WARN_CFLAGS], [$compiler_flags_test])])
AS_IF([test "x$enable_compiler_warnings" = xerror], AS_IF([test "x$enable_compiler_warnings" = xerror],

View File

@ -220,6 +220,7 @@ static int add_type_aliases(PyObject *m)
return 0; return 0;
} }
PyMODINIT_FUNC PyInit__drgn(void); // Silence -Wmissing-prototypes.
DRGNPY_PUBLIC PyMODINIT_FUNC PyInit__drgn(void) DRGNPY_PUBLIC PyMODINIT_FUNC PyInit__drgn(void)
{ {
PyObject *m = PyModule_Create(&drgnmodule); PyObject *m = PyModule_Create(&drgnmodule);

View File

@ -5,8 +5,10 @@
* Wrapper functions for testing. * Wrapper functions for testing.
* *
* In order to test a few internal interfaces that don't have Python bindings, * In order to test a few internal interfaces that don't have Python bindings,
* we export some wrappers for those interfaces and for some required * we export some wrappers for those interfaces. These wrappers are accessed via
* libelf/libdw helpers. These wrappers are accessed via ctypes. * ctypes.
*
* The extra declarations are needed to silence -Wmissing-prototypes.
*/ */
#include "drgnpy.h" #include "drgnpy.h"
@ -14,35 +16,42 @@
#include "../path.h" #include "../path.h"
#include "../serialize.h" #include "../serialize.h"
typeof(drgn_lexer_init) drgn_test_lexer_init;
DRGNPY_PUBLIC void drgn_test_lexer_init(struct drgn_lexer *lexer, DRGNPY_PUBLIC void drgn_test_lexer_init(struct drgn_lexer *lexer,
drgn_lexer_func func, const char *str) drgn_lexer_func func, const char *str)
{ {
return drgn_lexer_init(lexer, func, str); return drgn_lexer_init(lexer, func, str);
} }
typeof(drgn_lexer_deinit) drgn_test_lexer_deinit;
DRGNPY_PUBLIC void drgn_test_lexer_deinit(struct drgn_lexer *lexer) DRGNPY_PUBLIC void drgn_test_lexer_deinit(struct drgn_lexer *lexer)
{ {
return drgn_lexer_deinit(lexer); return drgn_lexer_deinit(lexer);
} }
typeof(drgn_lexer_pop) drgn_test_lexer_pop;
DRGNPY_PUBLIC struct drgn_error *drgn_test_lexer_pop(struct drgn_lexer *lexer, DRGNPY_PUBLIC struct drgn_error *drgn_test_lexer_pop(struct drgn_lexer *lexer,
struct drgn_token *token) struct drgn_token *token)
{ {
return drgn_lexer_pop(lexer, token); return drgn_lexer_pop(lexer, token);
} }
typeof(drgn_lexer_push) drgn_test_lexer_push;
DRGNPY_PUBLIC struct drgn_error * DRGNPY_PUBLIC struct drgn_error *
drgn_test_lexer_push(struct drgn_lexer *lexer, const struct drgn_token *token) drgn_test_lexer_push(struct drgn_lexer *lexer, const struct drgn_token *token)
{ {
return drgn_lexer_push(lexer, token); return drgn_lexer_push(lexer, token);
} }
typeof(drgn_lexer_peek) drgn_test_lexer_peek;
DRGNPY_PUBLIC struct drgn_error *drgn_test_lexer_peek(struct drgn_lexer *lexer, DRGNPY_PUBLIC struct drgn_error *drgn_test_lexer_peek(struct drgn_lexer *lexer,
struct drgn_token *token) struct drgn_token *token)
{ {
return drgn_lexer_peek(lexer, token); return drgn_lexer_peek(lexer, token);
} }
struct drgn_error *drgn_test_lexer_func(struct drgn_lexer *lexer,
struct drgn_token *token);
DRGNPY_PUBLIC struct drgn_error *drgn_test_lexer_func(struct drgn_lexer *lexer, DRGNPY_PUBLIC struct drgn_error *drgn_test_lexer_func(struct drgn_lexer *lexer,
struct drgn_token *token) struct drgn_token *token)
{ {
@ -57,12 +66,14 @@ DRGNPY_PUBLIC struct drgn_error *drgn_test_lexer_func(struct drgn_lexer *lexer,
return NULL; return NULL;
} }
typeof(drgn_c_family_lexer_func) drgn_test_lexer_c;
DRGNPY_PUBLIC struct drgn_error *drgn_test_lexer_c(struct drgn_lexer *lexer, DRGNPY_PUBLIC struct drgn_error *drgn_test_lexer_c(struct drgn_lexer *lexer,
struct drgn_token *token) struct drgn_token *token)
{ {
return drgn_c_family_lexer_func(lexer, token); return drgn_c_family_lexer_func(lexer, token);
} }
typeof(path_iterator_next) drgn_test_path_iterator_next;
DRGNPY_PUBLIC bool drgn_test_path_iterator_next(struct path_iterator *it, DRGNPY_PUBLIC bool drgn_test_path_iterator_next(struct path_iterator *it,
const char **component, const char **component,
size_t *component_len) size_t *component_len)
@ -70,12 +81,14 @@ DRGNPY_PUBLIC bool drgn_test_path_iterator_next(struct path_iterator *it,
return path_iterator_next(it, component, component_len); return path_iterator_next(it, component, component_len);
} }
typeof(path_ends_with) drgn_test_path_ends_with;
DRGNPY_PUBLIC bool drgn_test_path_ends_with(struct path_iterator *haystack, DRGNPY_PUBLIC bool drgn_test_path_ends_with(struct path_iterator *haystack,
struct path_iterator *needle) struct path_iterator *needle)
{ {
return path_ends_with(haystack, needle); return path_ends_with(haystack, needle);
} }
typeof(serialize_bits) drgn_test_serialize_bits;
DRGNPY_PUBLIC void drgn_test_serialize_bits(void *buf, uint64_t bit_offset, DRGNPY_PUBLIC void drgn_test_serialize_bits(void *buf, uint64_t bit_offset,
uint64_t uvalue, uint8_t bit_size, uint64_t uvalue, uint8_t bit_size,
bool little_endian) bool little_endian)
@ -83,6 +96,7 @@ DRGNPY_PUBLIC void drgn_test_serialize_bits(void *buf, uint64_t bit_offset,
return serialize_bits(buf, bit_offset, uvalue, bit_size, little_endian); return serialize_bits(buf, bit_offset, uvalue, bit_size, little_endian);
} }
typeof(deserialize_bits) drgn_test_deserialize_bits;
DRGNPY_PUBLIC uint64_t drgn_test_deserialize_bits(const void *buf, DRGNPY_PUBLIC uint64_t drgn_test_deserialize_bits(const void *buf,
uint64_t bit_offset, uint64_t bit_offset,
uint8_t bit_size, uint8_t bit_size,