commit 1f5e482b8a62445879daa102a958a916f8e094cf
parent f2f5a3742f05eee246e82b56463fd52851664486
Author: Joris Vink <joris@coders.se>
Date: Mon, 1 Feb 2016 15:33:40 +0100
Build option changes.
- Build with -O2 unless NOOPT is set to 1.
- Hide -g behind DEBUG instead of always building with it.
- Explicitely set the standard used to c99, use pedantic.
Diffstat:
6 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
@@ -11,14 +11,20 @@ S_SRC= src/kore.c src/buf.c src/cli.c src/config.c src/connection.c \
src/pool.c src/timer.c src/utils.c src/worker.c
S_OBJS= $(S_SRC:.c=.o)
-CFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS+=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
CFLAGS+=-Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual
-CFLAGS+=-Wsign-compare -Iincludes -g
+CFLAGS+=-Wsign-compare -Iincludes -std=c99 -pedantic
CFLAGS+=-DPREFIX='"$(PREFIX)"'
LDFLAGS=-rdynamic -lssl -lcrypto
ifneq ("$(DEBUG)", "")
- CFLAGS+=-DKORE_DEBUG
+ CFLAGS+=-DKORE_DEBUG -g
+endif
+
+ifneq ("$(NOOPT)", "")
+ CFLAGS+=-O0
+else
+ CFLAGS+=-O2
endif
ifneq ("$(NOHTTP)", "")
diff --git a/src/cli.c b/src/cli.c
@@ -45,7 +45,7 @@
#define PRI_TIME_T "d"
#endif
-#if defined(linux)
+#if defined(__linux__)
#if defined(__x86_64__)
#define PRI_TIME_T PRIu64
#else
diff --git a/src/http.c b/src/http.c
@@ -297,7 +297,7 @@ http_process_request(struct http_request *req)
switch (r) {
case KORE_RESULT_OK:
- cb = req->hdlr->addr;
+ *(void **)&(cb) = req->hdlr->addr;
worker->active_hdlr = req->hdlr;
r = cb(req);
worker->active_hdlr = NULL;
diff --git a/src/kore.c b/src/kore.c
@@ -313,7 +313,7 @@ kore_server_bind(const char *ip, const char *port, const char *ccb)
}
if (ccb != NULL) {
- l->connect = kore_module_getsym(ccb);
+ *(void **)&(l->connect) = kore_module_getsym(ccb);
if (l->connect == NULL) {
printf("no such callback: '%s'\n", ccb);
close(l->fd);
diff --git a/src/module.c b/src/module.c
@@ -51,7 +51,7 @@ kore_module_load(const char *path, const char *onload)
if (onload != NULL) {
module->onload = kore_strdup(onload);
- module->ocb = dlsym(module->handle, onload);
+ *(void **)&(module->ocb) = dlsym(module->handle, onload);
if (module->ocb == NULL)
fatal("%s: onload '%s' not present", path, onload);
}
@@ -107,7 +107,8 @@ kore_module_reload(int cbs)
fatal("kore_module_reload(): %s", dlerror());
if (module->onload != NULL) {
- module->ocb = dlsym(module->handle, module->onload);
+ *(void **)&(module->ocb) =
+ dlsym(module->handle, module->onload);
if (module->ocb == NULL) {
fatal("%s: onload '%s' not present",
module->path, module->onload);
diff --git a/src/validator.c b/src/validator.c
@@ -42,7 +42,8 @@ kore_validator_add(const char *name, u_int8_t type, const char *arg)
}
break;
case KORE_VALIDATOR_TYPE_FUNCTION:
- if ((val->func = kore_module_getsym(arg)) == NULL) {
+ *(void **)(&val->func) = kore_module_getsym(arg);
+ if (val->func == NULL) {
kore_mem_free(val);
kore_log(LOG_NOTICE,
"validator %s has undefined callback %s",
@@ -112,7 +113,8 @@ kore_validator_reload(void)
if (val->type != KORE_VALIDATOR_TYPE_FUNCTION)
continue;
- if ((val->func = kore_module_getsym(val->arg)) == NULL)
+ *(void **)&(val->func) = kore_module_getsym(val->arg);
+ if (val->func == NULL)
fatal("no function for validator %s found", val->name);
}
}