summaryrefslogtreecommitdiff
path: root/image/image_cache.c
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/image_cache.c
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/image_cache.c')
-rw-r--r--image/image_cache.c93
1 files changed, 43 insertions, 50 deletions
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);
}