summaryrefslogtreecommitdiff
path: root/image
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 /image
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 'image')
-rw-r--r--image/ico.c8
-rw-r--r--image/image_cache.c93
-rw-r--r--image/jpeg.c4
-rw-r--r--image/png.c11
-rw-r--r--image/rsvg.c12
5 files changed, 60 insertions, 68 deletions
diff --git a/image/ico.c b/image/ico.c
index b6743cb7c..9cb650bfe 100644
--- a/image/ico.c
+++ b/image/ico.c
@@ -162,7 +162,7 @@ static bool nsico_convert(struct content *c)
bmp = ico_find(ico->ico, 255, 255);
if (bmp == NULL) {
/* return error */
- LOG(("Failed to select icon"));
+ LOG("Failed to select icon");
return false;
}
@@ -185,7 +185,7 @@ static bool nsico_redraw(struct content *c, struct content_redraw_data *data,
bmp = ico_find(ico->ico, data->width, data->height);
if (bmp == NULL) {
/* return error */
- LOG(("Failed to select icon"));
+ LOG("Failed to select icon");
return false;
}
@@ -194,7 +194,7 @@ static bool nsico_redraw(struct content *c, struct content_redraw_data *data,
if (bmp_decode(bmp) != BMP_OK) {
return false;
} else {
- LOG(("Decoding bitmap"));
+ LOG("Decoding bitmap");
guit->bitmap->modified(bmp->bitmap);
}
@@ -257,7 +257,7 @@ static void *nsico_get_internal(const struct content *c, void *context)
bmp = ico_find(ico->ico, 16, 16);
if (bmp == NULL) {
/* return error */
- LOG(("Failed to select icon"));
+ LOG("Failed to select icon");
return NULL;
}
diff --git a/image/image_cache.c b/image/image_cache.c
index cf15bf75d..49285635f 100644
--- a/image/image_cache.c
+++ b/image/image_cache.c
@@ -224,11 +224,7 @@ static void image_cache__free_bitmap(struct image_cache_entry_s *centry)
{
if (centry->bitmap != NULL) {
#ifdef IMAGE_CACHE_VERBOSE
- LOG(("Freeing bitmap %p size %d age %d redraw count %d",
- centry->bitmap,
- centry->bitmap_size,
- image_cache->current_age - centry->bitmap_age,
- centry->redraw_count));
+ LOG("Freeing bitmap %p size %d age %d redraw count %d", centry->bitmap, centry->bitmap_size, image_cache->current_age - centry->bitmap_age, centry->redraw_count);
#endif
guit->bitmap->destroy(centry->bitmap);
centry->bitmap = NULL;
@@ -245,7 +241,7 @@ static void image_cache__free_bitmap(struct image_cache_entry_s *centry)
static void image_cache__free_entry(struct image_cache_entry_s *centry)
{
#ifdef IMAGE_CACHE_VERBOSE
- LOG(("freeing %p ", centry));
+ LOG("freeing %p ", centry);
#endif
if (centry->redraw_count == 0) {
@@ -287,7 +283,7 @@ static void image_cache__background_update(void *p)
icache->current_age += icache->params.bg_clean_time;
#ifdef IMAGE_CACHE_VERBOSE
- LOG(("Cache age %ds", icache->current_age / 1000));
+ LOG("Cache age %ds", icache->current_age / 1000);
#endif
image_cache__clean(icache);
@@ -339,13 +335,13 @@ bool image_cache_speculate(struct content *c)
if ((image_cache->total_bitmap_size < image_cache->params.limit) &&
(c->size <= image_cache->params.speculative_small)) {
#ifdef IMAGE_CACHE_VERBOSE
- LOG(("content size (%d) is smaller than minimum (%d)", c->size, SPECULATE_SMALL));
+ LOG("content size (%d) is smaller than minimum (%d)", c->size, SPECULATE_SMALL);
#endif
decision = true;
}
#ifdef IMAGE_CACHE_VERBOSE
- LOG(("returning %d", decision));
+ LOG("returning %d", decision);
#endif
return decision;
}
@@ -378,8 +374,8 @@ image_cache_init(const struct image_cache_parameters *image_cache_parameters)
image_cache__background_update,
image_cache);
- LOG(("Image cache initilised with a limit of %d hysteresis of %d",
- image_cache->params.limit, image_cache->params.hysteresis));
+ LOG("Image cache initilised with a limit of %zd hysteresis of %zd",
+ image_cache->params.limit, image_cache->params.hysteresis);
return NSERROR_OK;
}
@@ -391,9 +387,8 @@ nserror image_cache_fini(void)
guit->browser->schedule(-1, image_cache__background_update, image_cache);
- LOG(("Size at finish %d (in %d)",
- image_cache->total_bitmap_size,
- image_cache->bitmap_count));
+ LOG("Size at finish %zd (in %d)",
+ image_cache->total_bitmap_size, image_cache->bitmap_count);
while (image_cache->entries != NULL) {
image_cache__free_entry(image_cache->entries);
@@ -403,13 +398,11 @@ nserror image_cache_fini(void)
image_cache->miss_count +
image_cache->fail_count;
- LOG(("Age %ds", image_cache->current_age / 1000));
- LOG(("Peak size %d (in %d)",
- image_cache->max_bitmap_size,
- image_cache->max_bitmap_size_count ));
- LOG(("Peak image count %d (size %d)",
- image_cache->max_bitmap_count,
- image_cache->max_bitmap_count_size));
+ LOG("Age %ds", image_cache->current_age / 1000);
+ LOG("Peak size %zd (in %d)",
+ image_cache->max_bitmap_size, image_cache->max_bitmap_size_count);
+ LOG("Peak image count %d (size %zd)",
+ image_cache->max_bitmap_count, image_cache->max_bitmap_count_size);
if (op_count > 0) {
uint64_t op_size;
@@ -418,35 +411,35 @@ nserror image_cache_fini(void)
image_cache->miss_size +
image_cache->fail_size;
- LOG(("Cache total/hit/miss/fail (counts) %d/%d/%d/%d (100%%/%d%%/%d%%/%d%%)",
- op_count,
- image_cache->hit_count,
- image_cache->miss_count,
- image_cache->fail_count,
- (image_cache->hit_count * 100) / op_count,
- (image_cache->miss_count * 100) / op_count,
- (image_cache->fail_count * 100) / op_count));
- LOG(("Cache total/hit/miss/fail (size) %d/%d/%d/%d (100%%/%d%%/%d%%/%d%%)",
- op_size,
- image_cache->hit_size,
- image_cache->miss_size,
- image_cache->fail_size,
- (image_cache->hit_size * 100) / op_size,
- (image_cache->miss_size * 100) / op_size,
- (image_cache->fail_size * 100) / op_size));
+ LOG("Cache total/hit/miss/fail (counts) %d/%d/%d/%d (100%%/%d%%/%d%%/%d%%)",
+ op_count,
+ image_cache->hit_count,
+ image_cache->miss_count,
+ image_cache->fail_count,
+ (image_cache->hit_count * 100) / op_count,
+ (image_cache->miss_count * 100) / op_count,
+ (image_cache->fail_count * 100) / op_count);
+ LOG("Cache total/hit/miss/fail (size) %zd/%zd/%zd/%zd (100%%/%"PRId64"%%/%"PRId64"%%/%"PRId64"%%)",
+ op_size,
+ image_cache->hit_size,
+ image_cache->miss_size,
+ image_cache->fail_size,
+ (image_cache->hit_size * 100) / op_size,
+ (image_cache->miss_size * 100) / op_size,
+ (image_cache->fail_size * 100) / op_size);
}
- LOG(("Total images never rendered: %d (includes %d that were converted)",
- image_cache->total_unrendered,
- image_cache->specultive_miss_count));
+ LOG("Total images never rendered: %d (includes %d that were converted)",
+ image_cache->total_unrendered,
+ image_cache->specultive_miss_count);
- LOG(("Total number of excessive conversions: %d (from %d images converted more than once)",
- image_cache->total_extra_conversions,
- image_cache->total_extra_conversions_count));
+ LOG("Total number of excessive conversions: %d (from %d images converted more than once)",
+ image_cache->total_extra_conversions,
+ image_cache->total_extra_conversions_count);
- LOG(("Bitmap of size %d had most (%d) conversions",
- image_cache->peak_conversions_size,
- image_cache->peak_conversions));
+ LOG("Bitmap of size %d had most (%d) conversions",
+ image_cache->peak_conversions_size,
+ image_cache->peak_conversions);
free(image_cache);
@@ -478,7 +471,7 @@ nserror image_cache_add(struct content *content,
centry->bitmap_size = content->width * content->height * 4;
}
- LOG(("centry %p, content %p, bitmap %p", centry, content, bitmap));
+ LOG("centry %p, content %p, bitmap %p", centry, content, bitmap);
centry->convert = convert;
@@ -517,7 +510,7 @@ nserror image_cache_remove(struct content *content)
/* get the cache entry */
centry = image_cache__find(content);
if (centry == NULL) {
- LOG(("Could not find cache entry for content (%p)", content));
+ LOG("Could not find cache entry for content (%p)", content);
return NSERROR_NOT_FOUND;
}
@@ -747,7 +740,7 @@ bool image_cache_redraw(struct content *c,
/* get the cache entry */
centry = image_cache__find(c);
if (centry == NULL) {
- LOG(("Could not find cache entry for content (%p)", c));
+ LOG("Could not find cache entry for content (%p)", c);
return false;
}
@@ -785,7 +778,7 @@ void image_cache_destroy(struct content *content)
/* get the cache entry */
centry = image_cache__find(content);
if (centry == NULL) {
- LOG(("Could not find cache entry for content (%p)", content));
+ LOG("Could not find cache entry for content (%p)", content);
} else {
image_cache__free_entry(centry);
}
diff --git a/image/jpeg.c b/image/jpeg.c
index 309dec0a1..8e6ac8528 100644
--- a/image/jpeg.c
+++ b/image/jpeg.c
@@ -140,7 +140,7 @@ static void nsjpeg_term_source(j_decompress_ptr cinfo)
static void nsjpeg_error_log(j_common_ptr cinfo)
{
cinfo->err->format_message(cinfo, nsjpeg_error_buffer);
- LOG(("%s", nsjpeg_error_buffer));
+ LOG("%s", nsjpeg_error_buffer);
}
@@ -154,7 +154,7 @@ static void nsjpeg_error_exit(j_common_ptr cinfo)
jmp_buf *setjmp_buffer = (jmp_buf *) cinfo->client_data;
cinfo->err->format_message(cinfo, nsjpeg_error_buffer);
- LOG(("%s", nsjpeg_error_buffer));
+ LOG("%s", nsjpeg_error_buffer);
longjmp(*setjmp_buffer, 1);
}
diff --git a/image/png.c b/image/png.c
index ecb7e3c65..5d68d2f8a 100644
--- a/image/png.c
+++ b/image/png.c
@@ -71,7 +71,7 @@ enum nspng_cberr {
*/
static void nspng_warning(png_structp png_ptr, png_const_charp warning_message)
{
- LOG(("%s", warning_message));
+ LOG("%s", warning_message);
}
/**
@@ -79,7 +79,7 @@ static void nspng_warning(png_structp png_ptr, png_const_charp warning_message)
*/
static void nspng_error(png_structp png_ptr, png_const_charp error_message)
{
- LOG(("%s", error_message));
+ LOG("%s", error_message);
longjmp(png_jmpbuf(png_ptr), CBERR_LIBPNG);
}
@@ -172,8 +172,7 @@ static void info_callback(png_structp png_s, png_infop info)
png_c->rowbytes = png_get_rowbytes(png_s, info);
png_c->interlace = (interlace == PNG_INTERLACE_ADAM7);
- LOG(("size %li * %li, rowbytes %zu", (unsigned long)width,
- (unsigned long)height, png_c->rowbytes));
+ LOG("size %li * %li, rowbytes %zu", (unsigned long)width, (unsigned long)height, png_c->rowbytes);
}
static void row_callback(png_structp png_s, png_bytep new_row,
@@ -261,7 +260,7 @@ static nserror nspng_create_png_data(nspng_content *png_c)
if (setjmp(png_jmpbuf(png_c->png))) {
png_destroy_read_struct(&png_c->png, &png_c->info, 0);
- LOG(("Failed to set callbacks"));
+ LOG("Failed to set callbacks");
png_c->png = NULL;
png_c->info = NULL;
@@ -349,7 +348,7 @@ static bool nspng_process_data(struct content *c, const char *data,
* up png conversion and signal the content
* error
*/
- LOG(("Fatal PNG error during header, error content"));
+ LOG("Fatal PNG error during header, error content");
png_destroy_read_struct(&png_c->png, &png_c->info, 0);
png_c->png = NULL;
diff --git a/image/rsvg.c b/image/rsvg.c
index 3dd27fed6..4ffb43aa8 100644
--- a/image/rsvg.c
+++ b/image/rsvg.c
@@ -66,7 +66,7 @@ static nserror rsvg_create_svg_data(rsvg_content *c)
c->bitmap = NULL;
if ((c->rsvgh = rsvg_handle_new()) == NULL) {
- LOG(("rsvg_handle_new() returned NULL."));
+ LOG("rsvg_handle_new() returned NULL.");
msg_data.error = messages_get("NoMemory");
content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
return NSERROR_NOMEM;
@@ -116,7 +116,7 @@ static bool rsvg_process_data(struct content *c, const char *data,
if (rsvg_handle_write(d->rsvgh, (const guchar *)data, (gsize)size,
&err) == FALSE) {
- LOG(("rsvg_handle_write returned an error: %s", err->message));
+ LOG("rsvg_handle_write returned an error: %s", err->message);
msg_data.error = err->message;
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return false;
@@ -162,7 +162,7 @@ static bool rsvg_convert(struct content *c)
GError *err = NULL;
if (rsvg_handle_close(d->rsvgh, &err) == FALSE) {
- LOG(("rsvg_handle_close returned an error: %s", err->message));
+ LOG("rsvg_handle_close returned an error: %s", err->message);
msg_data.error = err->message;
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return false;
@@ -180,7 +180,7 @@ static bool rsvg_convert(struct content *c)
if ((d->bitmap = guit->bitmap->create(c->width, c->height,
BITMAP_NEW)) == NULL) {
- LOG(("Failed to create bitmap for rsvg render."));
+ LOG("Failed to create bitmap for rsvg render.");
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return false;
@@ -191,14 +191,14 @@ static bool rsvg_convert(struct content *c)
CAIRO_FORMAT_ARGB32,
c->width, c->height,
guit->bitmap->get_rowstride(d->bitmap))) == NULL) {
- LOG(("Failed to create Cairo image surface for rsvg render."));
+ LOG("Failed to create Cairo image surface for rsvg render.");
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return false;
}
if ((d->ct = cairo_create(d->cs)) == NULL) {
- LOG(("Failed to create Cairo drawing context for rsvg render."));
+ LOG("Failed to create Cairo drawing context for rsvg render.");
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return false;