From 75018632a9b953aafeae6f4e8aea607fd1d89dca Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 6 Sep 2017 18:28:12 +0100 Subject: Use coccinelle to change logging macro calls in c files for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done @@ expression E; @@ -LOG(E); +NSLOG(netsurf, INFO, E); @@ expression E, E1; @@ -LOG(E, E1); +NSLOG(netsurf, INFO, E, E1); @@ expression E, E1, E2; @@ -LOG(E, E1, E2); +NSLOG(netsurf, INFO, E, E1, E2); @@ expression E, E1, E2, E3; @@ -LOG(E, E1, E2, E3); +NSLOG(netsurf, INFO, E, E1, E2, E3); @@ expression E, E1, E2, E3, E4; @@ -LOG(E, E1, E2, E3, E4); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4); @@ expression E, E1, E2, E3, E4, E5; @@ -LOG(E, E1, E2, E3, E4, E5); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5); @@ expression E, E1, E2, E3, E4, E5, E6; @@ -LOG(E, E1, E2, E3, E4, E5, E6); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6); @@ expression E, E1, E2, E3, E4, E5, E6, E7; @@ -LOG(E, E1, E2, E3, E4, E5, E6, E7); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7); --- content/fetchers/curl.c | 80 +++++++++++++++++++++++++++------------------ content/fetchers/data.c | 17 ++++++---- content/fetchers/resource.c | 6 ++-- 3 files changed, 64 insertions(+), 39 deletions(-) (limited to 'content/fetchers') diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c index 7d0e40c24..a6146edb3 100644 --- a/content/fetchers/curl.c +++ b/content/fetchers/curl.c @@ -155,7 +155,8 @@ static void ns_X509_free(X509 *cert) */ static bool fetch_curl_initialise(lwc_string *scheme) { - LOG("Initialise cURL fetcher for %s", lwc_string_data(scheme)); + NSLOG(netsurf, INFO, "Initialise cURL fetcher for %s", + lwc_string_data(scheme)); curl_fetchers_registered++; return true; /* Always succeeds */ } @@ -171,17 +172,20 @@ static void fetch_curl_finalise(lwc_string *scheme) struct cache_handle *h; curl_fetchers_registered--; - LOG("Finalise cURL fetcher %s", lwc_string_data(scheme)); + NSLOG(netsurf, INFO, "Finalise cURL fetcher %s", + lwc_string_data(scheme)); if (curl_fetchers_registered == 0) { CURLMcode codem; /* All the fetchers have been finalised. */ - LOG("All cURL fetchers finalised, closing down cURL"); + NSLOG(netsurf, INFO, + "All cURL fetchers finalised, closing down cURL"); curl_easy_cleanup(fetch_blank_curl); codem = curl_multi_cleanup(fetch_curl_multi); if (codem != CURLM_OK) - LOG("curl_multi_cleanup failed: ignoring"); + NSLOG(netsurf, INFO, + "curl_multi_cleanup failed: ignoring"); curl_global_cleanup(); } @@ -251,7 +255,9 @@ fetch_curl_post_convert(const struct fetch_multipart_data *control) "application/octet-stream", CURLFORM_END); if (code != CURL_FORMADD_OK) - LOG("curl_formadd: %d (%s)", code, control->name); + NSLOG(netsurf, INFO, + "curl_formadd: %d (%s)", code, + control->name); } else { char *mimetype = guit->fetch->mimetype(control->value); code = curl_formadd(&post, &last, @@ -262,7 +268,11 @@ fetch_curl_post_convert(const struct fetch_multipart_data *control) (mimetype != 0 ? mimetype : "text/plain"), CURLFORM_END); if (code != CURL_FORMADD_OK) - LOG("curl_formadd: %d (%s=%s)", code, control->name, control->value); + NSLOG(netsurf, INFO, + "curl_formadd: %d (%s=%s)", + code, + control->name, + control->value); free(mimetype); } free(leafname); @@ -273,7 +283,9 @@ fetch_curl_post_convert(const struct fetch_multipart_data *control) CURLFORM_COPYCONTENTS, control->value, CURLFORM_END); if (code != CURL_FORMADD_OK) - LOG("curl_formadd: %d (%s=%s)", code, control->name, control->value); + NSLOG(netsurf, INFO, + "curl_formadd: %d (%s=%s)", code, + control->name, control->value); } } @@ -321,7 +333,7 @@ fetch_curl_setup(struct fetch *parent_fetch, fetch->fetch_handle = parent_fetch; - LOG("fetch %p, url '%s'", fetch, nsurl_access(url)); + NSLOG(netsurf, INFO, "fetch %p, url '%s'", fetch, nsurl_access(url)); /* construct a new fetch structure */ fetch->curl_handle = NULL; @@ -776,7 +788,7 @@ static void fetch_curl_abort(void *vf) { struct curl_fetch_info *f = (struct curl_fetch_info *)vf; assert(f); - LOG("fetch %p, url '%s'", f, nsurl_access(f->url)); + NSLOG(netsurf, INFO, "fetch %p, url '%s'", f, nsurl_access(f->url)); if (f->curl_handle) { f->abort = true; } else { @@ -796,7 +808,7 @@ static void fetch_curl_stop(struct curl_fetch_info *f) CURLMcode codem; assert(f); - LOG("fetch %p, url '%s'", f, nsurl_access(f->url)); + NSLOG(netsurf, INFO, "fetch %p, url '%s'", f, nsurl_access(f->url)); if (f->curl_handle) { /* remove from curl multi handle */ @@ -864,7 +876,7 @@ static bool fetch_curl_process_headers(struct curl_fetch_info *f) assert(code == CURLE_OK); } http_code = f->http_code; - LOG("HTTP status code %li", http_code); + NSLOG(netsurf, INFO, "HTTP status code %li", http_code); if (http_code == 304 && !f->post_urlenc && !f->post_multipart) { /* Not Modified && GET request */ @@ -875,7 +887,7 @@ static bool fetch_curl_process_headers(struct curl_fetch_info *f) /* handle HTTP redirects (3xx response codes) */ if (300 <= http_code && http_code < 400 && f->location != 0) { - LOG("FETCH_REDIRECT, '%s'", f->location); + NSLOG(netsurf, INFO, "FETCH_REDIRECT, '%s'", f->location); msg.type = FETCH_REDIRECT; msg.data.redirect = f->location; fetch_send_callback(&msg, f->fetch_handle); @@ -1037,7 +1049,7 @@ static void fetch_curl_done(CURL *curl_handle, CURLcode result) assert(code == CURLE_OK); abort_fetch = f->abort; - LOG("done %s", nsurl_access(f->url)); + NSLOG(netsurf, INFO, "done %s", nsurl_access(f->url)); if ((abort_fetch == false) && (result == CURLE_OK || @@ -1082,7 +1094,7 @@ static void fetch_curl_done(CURL *curl_handle, CURLcode result) memset(f->cert_data, 0, sizeof(f->cert_data)); cert = true; } else { - LOG("Unknown cURL response code %d", result); + NSLOG(netsurf, INFO, "Unknown cURL response code %d", result); error = true; } @@ -1146,7 +1158,8 @@ static void fetch_curl_poll(lwc_string *scheme_ignored) &exc_fd_set, &max_fd); assert(codem == CURLM_OK); - LOG("Curl file descriptor states (maxfd=%i):", max_fd); + NSLOG(netsurf, INFO, + "Curl file descriptor states (maxfd=%i):", max_fd); for (i = 0; i <= max_fd; i++) { bool read = false; bool write = false; @@ -1162,10 +1175,10 @@ static void fetch_curl_poll(lwc_string *scheme_ignored) error = true; } if (read || write || error) { - LOG(" fd %i: %s %s %s", i, - read ? "read" : " ", - write ? "write" : " ", - error ? "error" : " "); + NSLOG(netsurf, INFO, " fd %i: %s %s %s", i, + read ? "read" : " ", + write ? "write" : " ", + error ? "error" : " "); } } } @@ -1174,7 +1187,8 @@ static void fetch_curl_poll(lwc_string *scheme_ignored) do { codem = curl_multi_perform(fetch_curl_multi, &running); if (codem != CURLM_OK && codem != CURLM_CALL_MULTI_PERFORM) { - LOG("curl_multi_perform: %i %s", codem, curl_multi_strerror(codem)); + NSLOG(netsurf, INFO, "curl_multi_perform: %i %s", + codem, curl_multi_strerror(codem)); guit->misc->warning("MiscError", curl_multi_strerror(codem)); return; } @@ -1336,7 +1350,7 @@ fetch_curl_header(char *data, size_t size, size_t nmemb, void *_f) free(f->location); f->location = malloc(size); if (!f->location) { - LOG("malloc failed"); + NSLOG(netsurf, INFO, "malloc failed"); return size; } SKIP_ST(9); @@ -1427,17 +1441,17 @@ nserror fetch_curl_register(void) .finalise = fetch_curl_finalise }; - LOG("curl_version %s", curl_version()); + NSLOG(netsurf, INFO, "curl_version %s", curl_version()); code = curl_global_init(CURL_GLOBAL_ALL); if (code != CURLE_OK) { - LOG("curl_global_init failed."); + NSLOG(netsurf, INFO, "curl_global_init failed."); return NSERROR_INIT_FAILED; } fetch_curl_multi = curl_multi_init(); if (!fetch_curl_multi) { - LOG("curl_multi_init failed."); + NSLOG(netsurf, INFO, "curl_multi_init failed."); return NSERROR_INIT_FAILED; } @@ -1465,7 +1479,7 @@ nserror fetch_curl_register(void) */ fetch_blank_curl = curl_easy_init(); if (!fetch_blank_curl) { - LOG("curl_easy_init failed"); + NSLOG(netsurf, INFO, "curl_easy_init failed"); return NSERROR_INIT_FAILED; } @@ -1497,11 +1511,12 @@ nserror fetch_curl_register(void) if (nsoption_charp(ca_bundle) && strcmp(nsoption_charp(ca_bundle), "")) { - LOG("ca_bundle: '%s'", nsoption_charp(ca_bundle)); + NSLOG(netsurf, INFO, "ca_bundle: '%s'", + nsoption_charp(ca_bundle)); SETOPT(CURLOPT_CAINFO, nsoption_charp(ca_bundle)); } if (nsoption_charp(ca_path) && strcmp(nsoption_charp(ca_path), "")) { - LOG("ca_path: '%s'", nsoption_charp(ca_path)); + NSLOG(netsurf, INFO, "ca_path: '%s'", nsoption_charp(ca_path)); SETOPT(CURLOPT_CAPATH, nsoption_charp(ca_path)); } @@ -1513,7 +1528,8 @@ nserror fetch_curl_register(void) curl_with_openssl = false; } - LOG("cURL %slinked against openssl", curl_with_openssl ? "" : "not "); + NSLOG(netsurf, INFO, "cURL %slinked against openssl", + curl_with_openssl ? "" : "not "); /* cURL initialised okay, register the fetchers */ @@ -1532,19 +1548,21 @@ nserror fetch_curl_register(void) } if (fetcher_add(scheme, &fetcher_ops) != NSERROR_OK) { - LOG("Unable to register cURL fetcher for %s", data->protocols[i]); + NSLOG(netsurf, INFO, + "Unable to register cURL fetcher for %s", + data->protocols[i]); } } return NSERROR_OK; curl_easy_setopt_failed: - LOG("curl_easy_setopt failed."); + NSLOG(netsurf, INFO, "curl_easy_setopt failed."); return NSERROR_INIT_FAILED; #if LIBCURL_VERSION_NUM >= 0x071e00 curl_multi_setopt_failed: - LOG("curl_multi_setopt failed."); + NSLOG(netsurf, INFO, "curl_multi_setopt failed."); return NSERROR_INIT_FAILED; #endif } diff --git a/content/fetchers/data.c b/content/fetchers/data.c index cb99e6ff2..5ba021fd3 100644 --- a/content/fetchers/data.c +++ b/content/fetchers/data.c @@ -57,14 +57,16 @@ static struct fetch_data_context *ring = NULL; static bool fetch_data_initialise(lwc_string *scheme) { - LOG("fetch_data_initialise called for %s", lwc_string_data(scheme)); + NSLOG(netsurf, INFO, "fetch_data_initialise called for %s", + lwc_string_data(scheme)); return true; } static void fetch_data_finalise(lwc_string *scheme) { - LOG("fetch_data_finalise called for %s", lwc_string_data(scheme)); + NSLOG(netsurf, INFO, "fetch_data_finalise called for %s", + lwc_string_data(scheme)); } static bool fetch_data_can_fetch(const nsurl *url) @@ -147,7 +149,7 @@ static bool fetch_data_process(struct fetch_data_context *c) * data must still be there. */ - LOG("url: %.140s", c->url); + NSLOG(netsurf, INFO, "url: %.140s", c->url); if (strlen(c->url) < 6) { /* 6 is the minimum possible length (data:,) */ @@ -259,8 +261,10 @@ static void fetch_data_poll(lwc_string *scheme) char header[64]; fetch_set_http_code(c->parent_fetch, 200); - LOG("setting data: MIME type to %s, length to %" PRIsizet, - c->mimetype, c->datalen); + NSLOG(netsurf, INFO, + "setting data: MIME type to %s, length to %"PRIsizet, + c->mimetype, + c->datalen); /* Any callback can result in the fetch being aborted. * Therefore, we _must_ check for this after _every_ * call to fetch_data_send_callback(). @@ -296,7 +300,8 @@ static void fetch_data_poll(lwc_string *scheme) fetch_data_send_callback(&msg, c); } } else { - LOG("Processing of %s failed!", c->url); + NSLOG(netsurf, INFO, "Processing of %s failed!", + c->url); /* Ensure that we're unlocked here. If we aren't, * then fetch_data_process() is broken. diff --git a/content/fetchers/resource.c b/content/fetchers/resource.c index b8b4b191f..78757733e 100644 --- a/content/fetchers/resource.c +++ b/content/fetchers/resource.c @@ -276,14 +276,16 @@ static bool fetch_resource_initialise(lwc_string *scheme) &e->data, &e->data_len); if (res == NSERROR_OK) { - LOG("direct data for %s", fetch_resource_paths[i]); + NSLOG(netsurf, INFO, "direct data for %s", + fetch_resource_paths[i]); fetch_resource_path_count++; } else { e->redirect_url = guit->fetch->get_resource_url(fetch_resource_paths[i]); if (e->redirect_url == NULL) { lwc_string_unref(e->path); } else { - LOG("redirect url for %s", fetch_resource_paths[i]); + NSLOG(netsurf, INFO, "redirect url for %s", + fetch_resource_paths[i]); fetch_resource_path_count++; } } -- cgit v1.2.3