[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Avoid double-parens in log_fn() messages on clang.
commit 7bed9dc73a6b95b2de741195ce54d073e0bd4a37
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Sat Mar 14 14:12:03 2015 -0400
Avoid double-parens in log_fn() messages on clang.
On clang (and elsewhere?) __PRETTY_FUNCTION__ includes parenthesized
argument lists. This is clever, but it makes our old "%s(): " format
look funny.
This is a fix on 0957ffeb, aka svn:r288. Fixes bug 15269.
---
changes/bug15269 | 7 +++++++
src/common/log.c | 12 +++++++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/changes/bug15269 b/changes/bug15269
new file mode 100644
index 0000000..e6b2b24
--- /dev/null
+++ b/changes/bug15269
@@ -0,0 +1,7 @@
+ o Minor bugfixes (logs):
+ - When building Tor under Clang, do not include an extra set of
+ parentheses in log messages that include function names.
+ Fixes bug 15053; bugfix on every released version of Tor when
+ compiled with recent enough Clang.
+
+
diff --git a/src/common/log.c b/src/common/log.c
index e8cc30c..5278dbd 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -140,6 +140,9 @@ static size_t pending_startup_messages_len;
* configured. */
static int queue_startup_messages = 1;
+/** True iff __PRETTY_FUNCTION__ includes parenthesized arguments. */
+static int pretty_fn_has_parens = 0;
+
/** Don't store more than this many bytes of messages while waiting for the
* logs to get configured. */
#define MAX_STARTUP_MSG_LEN (1<<16)
@@ -306,7 +309,9 @@ format_msg(char *buf, size_t buf_len,
}
if (funcname && should_log_function_name(domain, severity)) {
- r = tor_snprintf(buf+n, buf_len-n, "%s(): ", funcname);
+ r = tor_snprintf(buf+n, buf_len-n,
+ pretty_fn_has_parens ? "%s: " : "%s(): ",
+ funcname);
if (r<0)
n = strlen(buf);
else
@@ -925,6 +930,11 @@ init_logging(int disable_startup_queue)
tor_mutex_init(&log_mutex);
log_mutex_initialized = 1;
}
+#ifdef __GNUC__
+ if (strchr(__PRETTY_FUNCTION__, '(')) {
+ pretty_fn_has_parens = 1;
+ }
+#endif
if (pending_cb_messages == NULL)
pending_cb_messages = smartlist_new();
if (disable_startup_queue)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits