summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-05-28 16:08:46 +0100
committerVincent Sanders <vince@kyllikki.org>2015-05-28 16:08:46 +0100
commitc105738fa36bb2400adc47399c5b878d252d1c86 (patch)
tree138eeb449e1bf51ee1726b5f820740aada0ccd0b /monkey
parent20f2c86a511f7913cf858e7bd3668b0b59663ba0 (diff)
downloadnetsurf-c105738fa36bb2400adc47399c5b878d252d1c86.tar.gz
netsurf-c105738fa36bb2400adc47399c5b878d252d1c86.tar.bz2
Change LOG() macro to be varadic
This changes the LOG macro to be varadic removing the need for all callsites to have double bracketing and allows for future improvement on how we use the logging macros. The callsites were changed with coccinelle and the changes checked by hand. Compile tested for several frontends but not all. A formatting annotation has also been added which allows the compiler to check the parameters and types passed to the logging.
Diffstat (limited to 'monkey')
-rw-r--r--monkey/browser.c2
-rw-r--r--monkey/dispatch.c2
-rw-r--r--monkey/filetype.c2
-rw-r--r--monkey/poll.c10
-rw-r--r--monkey/schedule.c17
5 files changed, 16 insertions, 17 deletions
diff --git a/monkey/browser.c b/monkey/browser.c
index 2b78537db..a13262170 100644
--- a/monkey/browser.c
+++ b/monkey/browser.c
@@ -437,7 +437,7 @@ monkey_window_handle_redraw(int argc, char **argv)
clip.y1 = atoi(argv[6]);
}
- LOG(("Issue redraw"));
+ LOG("Issue redraw");
fprintf(stdout, "WINDOW REDRAW WIN %d START\n", atoi(argv[2]));
browser_window_redraw(gw->bw, gw->scrollx, gw->scrolly, &clip, &ctx);
fprintf(stdout, "WINDOW REDRAW WIN %d STOP\n", atoi(argv[2]));
diff --git a/monkey/dispatch.c b/monkey/dispatch.c
index c70070d4e..563534d64 100644
--- a/monkey/dispatch.c
+++ b/monkey/dispatch.c
@@ -40,7 +40,7 @@ monkey_register_handler(const char *cmd, handle_command_fn fn)
{
monkey_cmdhandler_t *ret = calloc(sizeof(*ret), 1);
if (ret == NULL) {
- LOG(("Unable to allocate handler"));
+ LOG("Unable to allocate handler");
return NSERROR_NOMEM;
}
ret->cmd = strdup(cmd);
diff --git a/monkey/filetype.c b/monkey/filetype.c
index 8c5037781..891dcd30b 100644
--- a/monkey/filetype.c
+++ b/monkey/filetype.c
@@ -70,7 +70,7 @@ void monkey_fetch_filetype_init(const char *mimefile)
hash_add(mime_hash, "spr", "image/x-riscos-sprite");
if (fh == NULL) {
- LOG(("Unable to open a mime.types file, so using a minimal one for you."));
+ LOG("Unable to open a mime.types file, so using a minimal one for you.");
return;
}
diff --git a/monkey/poll.c b/monkey/poll.c
index 6e96919a1..3ec31af86 100644
--- a/monkey/poll.c
+++ b/monkey/poll.c
@@ -29,7 +29,7 @@
#ifdef DEBUG_POLL_LOOP
#include "utils/log.h"
#else
-#define LOG(X)
+#define LOG(fmt, args...) ((void) 0)
#endif
@@ -103,7 +103,7 @@ void monkey_poll(void)
fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR;
g_main_context_add_poll(0, fd, 0);
fd_list[fd_count++] = fd;
- LOG(("Want to read %d", i));
+ LOG("Want to read %d", i);
}
if (FD_ISSET(i, &write_fd_set)) {
GPollFD *fd = malloc(sizeof *fd);
@@ -111,7 +111,7 @@ void monkey_poll(void)
fd->events = G_IO_OUT | G_IO_ERR;
g_main_context_add_poll(0, fd, 0);
fd_list[fd_count++] = fd;
- LOG(("Want to write %d", i));
+ LOG("Want to write %d", i);
}
if (FD_ISSET(i, &exc_fd_set)) {
GPollFD *fd = malloc(sizeof *fd);
@@ -119,13 +119,13 @@ void monkey_poll(void)
fd->events = G_IO_ERR;
g_main_context_add_poll(0, fd, 0);
fd_list[fd_count++] = fd;
- LOG(("Want to check %d", i));
+ LOG("Want to check %d", i);
}
}
schedule_run();
- LOG(("Iterate %sblocking", block?"":"non-"));
+ LOG("Iterate %sblocking", block ? "" : "non-");
if (block) {
fprintf(stdout, "GENERIC POLL BLOCKING\n");
}
diff --git a/monkey/schedule.c b/monkey/schedule.c
index e8ec1c6fa..d6f8e65dc 100644
--- a/monkey/schedule.c
+++ b/monkey/schedule.c
@@ -29,7 +29,7 @@
#ifdef DEBUG_MONKEY_SCHEDULE
#include "utils/log.h"
#else
-#define LOG(X)
+#define LOG(fmt, args...) ((void) 0)
#endif
/** Killable callback closure embodiment. */
@@ -52,10 +52,10 @@ nsgtk_schedule_generic_callback(gpointer data)
_nsgtk_callback_t *cb = (_nsgtk_callback_t *)(data);
if (cb->callback_killed) {
/* This callback instance has been killed. */
- LOG(("CB at %p already dead.", cb));
+ LOG("CB at %p already dead.", cb);
}
queued_callbacks = g_list_remove(queued_callbacks, cb);
- LOG(("CB %p(%p) now pending run", cb->callback, cb->context));
+ LOG("CB %p(%p) now pending run", cb->callback, cb->context);
pending_callbacks = g_list_append(pending_callbacks, cb);
return FALSE;
}
@@ -67,8 +67,7 @@ nsgtk_schedule_kill_callback(void *_target, void *_match)
_nsgtk_callback_t *match = (_nsgtk_callback_t *)_match;
if ((target->callback == match->callback) &&
(target->context == match->context)) {
- LOG(("Found match for %p(%p), killing.",
- target->callback, target->context));
+ LOG("Found match for %p(%p), killing.", target->callback, target->context);
target->callback = NULL;
target->context = NULL;
target->callback_killed = true;
@@ -106,7 +105,7 @@ nserror monkey_schedule(int t, void (*callback)(void *p), void *p)
cb->context = p;
cb->callback_killed = false;
/* Prepend is faster right now. */
- LOG(("queued a callback to %p(%p) for %d msecs time", callback, p, t));
+ LOG("queued a callback to %p(%p) for %d msecs time", callback, p, t);
queued_callbacks = g_list_prepend(queued_callbacks, cb);
g_timeout_add(t, nsgtk_schedule_generic_callback, cb);
@@ -126,17 +125,17 @@ schedule_run(void)
/* Clear the pending list. */
pending_callbacks = NULL;
- LOG(("Captured a run of %d callbacks to fire.", g_list_length(this_run)));
+ LOG("Captured a run of %d callbacks to fire.", g_list_length(this_run));
/* Run all the callbacks which made it this far. */
while (this_run != NULL) {
_nsgtk_callback_t *cb = (_nsgtk_callback_t *)(this_run->data);
this_run = g_list_remove(this_run, this_run->data);
if (!cb->callback_killed) {
- LOG(("CB DO %p(%p)", cb->callback, cb->context));
+ LOG("CB DO %p(%p)", cb->callback, cb->context);
cb->callback(cb->context);
} else {
- LOG(("CB %p(%p) already dead, dropping", cb->callback, cb->context));
+ LOG("CB %p(%p) already dead, dropping", cb->callback, cb->context);
}
free(cb);
}