From 976cc5bfca3c360921bdb4cce38a225ce5a1bd46 Mon Sep 17 00:00:00 2001 From: hniksic Date: Tue, 21 Jun 2005 18:26:22 -0700 Subject: [PATCH] [svn] Define the IF_DEBUG macro. --- src/ChangeLog | 10 ++++++++++ src/connect.c | 7 +++---- src/cookies.c | 4 +--- src/host.c | 4 +--- src/main.c | 8 ++++---- src/openssl.c | 4 +--- src/wget.h | 13 ++++++++----- 7 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 927be724..326835a6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2005-06-22 Hrvoje Niksic + + * openssl.c, connect.c, host.c: Replace instances of #ifdef + ENABLE_DEBUG if (opt.debug) {...} #endif with IF_DEBUG {...}. + + * main.c: Rename the IF_DEBUG defined here to WHEN_DEBUG. + + * wget.h (IF_DEBUG): New macro. + (DEBUGP): Define in terms of IF_DEBUG. + 2005-06-22 Hrvoje Niksic * http.c (gethttp): Only handle --set-cookies (and assert that diff --git a/src/connect.c b/src/connect.c index 0b58ffad..69a2e5e6 100644 --- a/src/connect.c +++ b/src/connect.c @@ -278,10 +278,9 @@ connect_to_ip (const ip_address *ip, int port, const char *print) int on = 1; /* In case of error, we will go on anyway... */ int err = setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof (on)); -#ifdef ENABLE_DEBUG - if (err < 0) - DEBUGP (("Failed setting IPV6_V6ONLY: %s", strerror (errno))); -#endif + IF_DEBUG + if (err < 0) + DEBUGP (("Failed setting IPV6_V6ONLY: %s", strerror (errno))); } #endif diff --git a/src/cookies.c b/src/cookies.c index a75799e5..0b690c66 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -258,8 +258,7 @@ store_cookie (struct cookie_jar *jar, struct cookie *cookie) hash_table_put (jar->chains, chain_key, cookie); ++jar->cookie_count; -#ifdef ENABLE_DEBUG - if (opt.debug) + IF_DEBUG { time_t exptime = cookie->expiry_time; DEBUGP (("\nStored cookie %s %d%s %s <%s> <%s> [expiry %s] %s %s\n", @@ -271,7 +270,6 @@ store_cookie (struct cookie_jar *jar, struct cookie *cookie) cookie->expiry_time ? datetime_str (&exptime) : "none", cookie->attr, cookie->value)); } -#endif } /* Discard a cookie matching COOKIE's domain, port, path, and diff --git a/src/host.c b/src/host.c index d9753ab6..fccc0d6d 100644 --- a/src/host.c +++ b/src/host.c @@ -622,8 +622,7 @@ cache_store (const char *host, struct address_list *al) ++al->refcount; hash_table_put (host_name_addresses_map, xstrdup_lower (host), al); -#ifdef ENABLE_DEBUG - if (opt.debug) + IF_DEBUG { int i; debug_logprintf ("Caching %s =>", host); @@ -631,7 +630,6 @@ cache_store (const char *host, struct address_list *al) debug_logprintf (" %s", pretty_print_address (al->addresses + i)); debug_logprintf ("\n"); } -#endif } /* Remove HOST from the DNS cache. Does nothing is HOST is not in diff --git a/src/main.c b/src/main.c index 997a2de7..5cb383a1 100644 --- a/src/main.c +++ b/src/main.c @@ -112,9 +112,9 @@ static void print_version (void); #endif #ifdef ENABLE_DEBUG -# define IF_DEBUG(x) x +# define WHEN_DEBUG(x) x #else -# define IF_DEBUG(x) NULL +# define WHEN_DEBUG(x) NULL #endif struct cmdline_option { @@ -158,7 +158,7 @@ struct cmdline_option option_data[] = { "convert-links", 'k', OPT_BOOLEAN, "convertlinks", -1 }, { "cookies", 0, OPT_BOOLEAN, "cookies", -1 }, { "cut-dirs", 0, OPT_VALUE, "cutdirs", -1 }, - { IF_DEBUG ("debug"), 'd', OPT_BOOLEAN, "debug", -1 }, + { WHEN_DEBUG ("debug"), 'd', OPT_BOOLEAN, "debug", -1 }, { "delete-after", 0, OPT_BOOLEAN, "deleteafter", -1 }, { "directories", 0, OPT_BOOLEAN, "dirstruct", -1 }, { "directory-prefix", 'P', OPT_VALUE, "dirprefix", -1 }, @@ -254,7 +254,7 @@ struct cmdline_option option_data[] = { "waitretry", 0, OPT_VALUE, "waitretry", -1 }, }; -#undef IF_DEBUG +#undef WHEN_DEBUG #undef IF_SSL /* Return a string that contains S with "no-" prepended. The string diff --git a/src/openssl.c b/src/openssl.c index 5850b96f..6fd9d656 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -422,8 +422,7 @@ ssl_check_certificate (int fd, const char *host) goto no_cert; /* must bail out since CERT is NULL */ } -#ifdef ENABLE_DEBUG - if (opt.debug) + IF_DEBUG { char *subject = X509_NAME_oneline (X509_get_subject_name (cert), 0, 0); char *issuer = X509_NAME_oneline (X509_get_issuer_name (cert), 0, 0); @@ -432,7 +431,6 @@ ssl_check_certificate (int fd, const char *host) OPENSSL_free (subject); OPENSSL_free (issuer); } -#endif vresult = SSL_get_verify_result (ssl); if (vresult != X509_V_OK) diff --git a/src/wget.h b/src/wget.h index d382d3da..7b76f8d8 100644 --- a/src/wget.h +++ b/src/wget.h @@ -98,13 +98,16 @@ so, delete this exception statement from your version. */ # define UNLIKELY(exp) (exp) #endif -/* Print X if debugging is enabled; a no-op otherwise. */ +/* Execute the following statement if debugging is both enabled at + compile-time and requested at run-time; a no-op otherwise. */ #ifdef ENABLE_DEBUG -# define DEBUGP(x) do if (UNLIKELY (opt.debug)) {debug_logprintf x;} while (0) -#else /* not ENABLE_DEBUG */ -# define DEBUGP(x) do {} while (0) -#endif /* not ENABLE_DEBUG */ +# define IF_DEBUG if (UNLIKELY (opt.debug)) +#else +# define IF_DEBUG if (0) +#endif + +#define DEBUGP(x) do { IF_DEBUG { debug_logprintf x; } } while (0) /* Define an integer type that works for file sizes, content lengths, and such. Normally we could just use off_t, but off_t is always -- 2.39.2