Fixed pedantic warnings for C99 + POSIX 2008 compatibility
This commit is contained in:
parent
e7faf8aaed
commit
10e933d758
10 changed files with 41 additions and 33 deletions
|
@ -41,7 +41,7 @@ set(GettextTranslate_GMO_BINARY 1)
|
|||
add_definitions(-DCRITERION_BUILDING_DLL=1)
|
||||
|
||||
if (NOT MSVC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -g -std=gnu99")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -pedantic -pedantic-errors -Wno-format -std=c99")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -g -std=c++11")
|
||||
endif ()
|
||||
|
||||
|
@ -53,6 +53,10 @@ if (WIN32 AND NOT MSVC)
|
|||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-no-undefined")
|
||||
endif()
|
||||
|
||||
# Enable standard extensions
|
||||
|
||||
add_definitions(-D_XOPEN_SOURCE=700)
|
||||
|
||||
# Compilation options
|
||||
|
||||
option(MINGW_DEFINE_OFF_T "Define off_t and off64_t ourselves before including io.h" OFF)
|
||||
|
|
|
@ -37,7 +37,6 @@ struct criterion_ordered_set {
|
|||
|
||||
struct criterion_ordered_set_node {
|
||||
struct criterion_ordered_set_node *next;
|
||||
char data[0];
|
||||
};
|
||||
|
||||
CR_BEGIN_C_API
|
||||
|
@ -54,6 +53,6 @@ CR_END_C_API
|
|||
# define FOREACH_SET(Elt, Set) \
|
||||
for (struct criterion_ordered_set_node *n = Set->first; n; n = n->next) \
|
||||
for (int cond = 1; cond;) \
|
||||
for (Elt = (void*) n->data; cond && (cond = 0, 1);)
|
||||
for (Elt = (void*) (n + 1); cond && (cond = 0, 1);)
|
||||
|
||||
#endif /* !CRITERION_ORDERED_SET_H_ */
|
||||
|
|
|
@ -36,7 +36,7 @@ static INLINE void nothing(CR_UNUSED void *ptr, CR_UNUSED void *meta) {}
|
|||
static void destroy_ordered_set_node(void *ptr, void *meta) {
|
||||
struct criterion_ordered_set *set = *(void **) meta;
|
||||
struct criterion_ordered_set_node *n = ptr;
|
||||
DEF(set->dtor, nothing)(n->data, NULL);
|
||||
DEF(set->dtor, nothing)(n + 1, NULL);
|
||||
sfree(((struct criterion_ordered_set_node *) ptr)->next);
|
||||
}
|
||||
|
||||
|
@ -58,11 +58,11 @@ void *insert_ordered_set(struct criterion_ordered_set *l,
|
|||
size_t size) {
|
||||
int cmp;
|
||||
struct criterion_ordered_set_node *n, *prev = NULL;
|
||||
for (n = l->first; n && (cmp = l->cmp(ptr, n->data)) > 0; n = n->next)
|
||||
for (n = l->first; n && (cmp = l->cmp(ptr, n + 1)) > 0; n = n->next)
|
||||
prev = n;
|
||||
|
||||
if (n && !cmp) // element already exists
|
||||
return n->data;
|
||||
return n + 1;
|
||||
|
||||
struct criterion_ordered_set_node *new = smalloc(
|
||||
.size = sizeof(struct criterion_ordered_set_node) + size,
|
||||
|
@ -72,7 +72,7 @@ void *insert_ordered_set(struct criterion_ordered_set *l,
|
|||
if (!new)
|
||||
return NULL;
|
||||
|
||||
memcpy(new->data, ptr, size);
|
||||
memcpy(new + 1, ptr, size);
|
||||
new->next = n;
|
||||
if (prev) {
|
||||
prev->next = new;
|
||||
|
@ -81,5 +81,5 @@ void *insert_ordered_set(struct criterion_ordered_set *l,
|
|||
}
|
||||
|
||||
++l->size;
|
||||
return new->data;
|
||||
return new + 1;
|
||||
}
|
||||
|
|
|
@ -71,17 +71,17 @@ f_report_hook CR_SECTION_END_(CR_HOOK_SECTION(POST_SUITE));
|
|||
f_report_hook CR_SECTION_END_(CR_HOOK_SECTION(POST_ALL));
|
||||
#endif
|
||||
|
||||
IMPL_CALL_REPORT_HOOKS(PRE_ALL);
|
||||
IMPL_CALL_REPORT_HOOKS(PRE_SUITE);
|
||||
IMPL_CALL_REPORT_HOOKS(PRE_INIT);
|
||||
IMPL_CALL_REPORT_HOOKS(PRE_TEST);
|
||||
IMPL_CALL_REPORT_HOOKS(ASSERT);
|
||||
IMPL_CALL_REPORT_HOOKS(THEORY_FAIL);
|
||||
IMPL_CALL_REPORT_HOOKS(TEST_CRASH);
|
||||
IMPL_CALL_REPORT_HOOKS(POST_TEST);
|
||||
IMPL_CALL_REPORT_HOOKS(POST_FINI);
|
||||
IMPL_CALL_REPORT_HOOKS(POST_SUITE);
|
||||
IMPL_CALL_REPORT_HOOKS(POST_ALL);
|
||||
IMPL_CALL_REPORT_HOOKS(PRE_ALL)
|
||||
IMPL_CALL_REPORT_HOOKS(PRE_SUITE)
|
||||
IMPL_CALL_REPORT_HOOKS(PRE_INIT)
|
||||
IMPL_CALL_REPORT_HOOKS(PRE_TEST)
|
||||
IMPL_CALL_REPORT_HOOKS(ASSERT)
|
||||
IMPL_CALL_REPORT_HOOKS(THEORY_FAIL)
|
||||
IMPL_CALL_REPORT_HOOKS(TEST_CRASH)
|
||||
IMPL_CALL_REPORT_HOOKS(POST_TEST)
|
||||
IMPL_CALL_REPORT_HOOKS(POST_FINI)
|
||||
IMPL_CALL_REPORT_HOOKS(POST_SUITE)
|
||||
IMPL_CALL_REPORT_HOOKS(POST_ALL)
|
||||
|
||||
ReportHook(PRE_ALL)(CR_UNUSED struct criterion_test_set *arg) {}
|
||||
ReportHook(PRE_SUITE)(CR_UNUSED struct criterion_suite_set *arg) {}
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
# include "criterion/hooks.h"
|
||||
# include "criterion/options.h"
|
||||
|
||||
# define report(Kind, Data) call_report_hooks_##Kind(Data)
|
||||
# define report(Kind, Data) report_(Kind, Data)
|
||||
# define report_(Kind, Data) call_report_hooks_##Kind(Data)
|
||||
|
||||
# define DECL_CALL_REPORT_HOOKS(Kind) \
|
||||
CR_DECL_SECTION_LIMITS(f_report_hook, CR_HOOK_SECTION(Kind)); \
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "criterion/options.h"
|
||||
#include "criterion/ordered-set.h"
|
||||
#include "criterion/logging.h"
|
||||
#include "criterion/preprocess.h"
|
||||
#include "compat/time.h"
|
||||
#include "compat/posix.h"
|
||||
#include "compat/processor.h"
|
||||
|
@ -84,7 +85,7 @@ CR_IMPL_SECTION_LIMITS(struct criterion_suite*, cr_sts);
|
|||
|
||||
// This is here to make the test suite & test sections non-empty
|
||||
TestSuite();
|
||||
Test(,) {};
|
||||
Test(,) {}
|
||||
|
||||
static INLINE void nothing(void) {}
|
||||
|
||||
|
@ -178,13 +179,16 @@ void run_test_child(struct criterion_test *test,
|
|||
g_wrappers[test->data->lang_](test, suite);
|
||||
}
|
||||
|
||||
#define push_event(Kind, ...) \
|
||||
#define push_event(...) \
|
||||
do { \
|
||||
stat_push_event(ctx->stats, \
|
||||
ctx->suite_stats, \
|
||||
ctx->test_stats, \
|
||||
&(struct event) { .kind = Kind, __VA_ARGS__ }); \
|
||||
report(Kind, ctx->test_stats); \
|
||||
&(struct event) { \
|
||||
.kind = CR_VA_HEAD(__VA_ARGS__), \
|
||||
CR_VA_TAIL(__VA_ARGS__) \
|
||||
}); \
|
||||
report(CR_VA_HEAD(__VA_ARGS__), ctx->test_stats); \
|
||||
} while (0)
|
||||
|
||||
s_pipe_handle *g_worker_pipe;
|
||||
|
|
|
@ -112,7 +112,7 @@ struct worker *run_next_test(struct criterion_test_set *p_set,
|
|||
ccrReturn(NULL);
|
||||
|
||||
for (ctx->ns = ctx->set->suites->first; ctx->ns; ctx->ns = ctx->ns->next) {
|
||||
ctx->suite_set = (void*) ctx->ns->data;
|
||||
ctx->suite_set = (void*) (ctx->ns + 1);
|
||||
|
||||
if (!ctx->suite_set->tests)
|
||||
continue;
|
||||
|
@ -126,7 +126,7 @@ struct worker *run_next_test(struct criterion_test_set *p_set,
|
|||
stat_push_event(ctx->stats, ctx->suite_stats, NULL, &ev);
|
||||
|
||||
for (ctx->nt = ctx->suite_set->tests->first; ctx->nt; ctx->nt = ctx->nt->next) {
|
||||
ctx->test = (void*) ctx->nt->data;
|
||||
ctx->test = (void*) (ctx->nt + 1);
|
||||
|
||||
if (ctx->test->data->kind_ == CR_TEST_PARAMETERIZED
|
||||
&& ctx->test->data->param_) {
|
||||
|
|
|
@ -59,7 +59,7 @@ static void nothing(CR_UNUSED s_glob_stats *stats,
|
|||
CR_UNUSED s_suite_stats *sstats,
|
||||
CR_UNUSED s_test_stats *tstats,
|
||||
CR_UNUSED void *data) {
|
||||
};
|
||||
}
|
||||
|
||||
static void destroy_stats(void *ptr, CR_UNUSED void *meta) {
|
||||
s_glob_stats *stats = ptr;
|
||||
|
|
|
@ -91,7 +91,7 @@ void cr_theory_reset(struct criterion_theory_context *ctx) {
|
|||
}
|
||||
|
||||
void cr_theory_call(struct criterion_theory_context *ctx, void (*fnptr)(void)) {
|
||||
dcCallVoid(ctx->vm, (DCpointer) fnptr);
|
||||
dcCallVoid(ctx->vm, (DCpointer) (unsigned long long) fnptr);
|
||||
}
|
||||
|
||||
static bool contains_word(const char *str, const char *pattern, size_t sz) {
|
||||
|
|
|
@ -134,16 +134,16 @@ static inline void handle_special(struct context *ctx, handler_arg strs[5]) {
|
|||
}
|
||||
|
||||
# define _ active
|
||||
Handler(handle_plus, [POSTSUFFIX] = {_, "+"}, [ELSESTR] = {_, "+" });
|
||||
Handler(handle_star, [POSTSUFFIX] = {_, "*"}, [ELSESTR] = {_, ".*"});
|
||||
Handler(handle_wild, [POSTSUFFIX] = {_, "?"}, [ELSESTR] = {_, "." });
|
||||
Handler(handle_plus, [POSTSUFFIX] = {_, "+"}, [ELSESTR] = {_, "+" })
|
||||
Handler(handle_star, [POSTSUFFIX] = {_, "*"}, [ELSESTR] = {_, ".*"})
|
||||
Handler(handle_wild, [POSTSUFFIX] = {_, "?"}, [ELSESTR] = {_, "." })
|
||||
Handler(handle_excl,
|
||||
[POSTPREFIX] = {_, "?!"},
|
||||
[PRESUFFIX] = {is_eos, "$" },
|
||||
[POSTSUFFIX] = {_, ".*"},
|
||||
[ELSESTR] = {_, "!" }
|
||||
);
|
||||
Handler(handle_at, [ELSESTR] = {_, "@"});
|
||||
)
|
||||
Handler(handle_at, [ELSESTR] = {_, "@"})
|
||||
# undef _
|
||||
|
||||
static void handle_rbra(struct context *ctx, CR_UNUSED char c) {
|
||||
|
|
Loading…
Add table
Reference in a new issue