diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/rt/rust_builtin.cpp | 4 | ||||
| -rw-r--r-- | src/rt/rust_dom.cpp | 4 | ||||
| -rw-r--r-- | src/rt/rust_internal.h | 4 | ||||
| -rw-r--r-- | src/rt/rust_log.cpp | 4 | ||||
| -rw-r--r-- | src/rt/rust_srv.cpp | 10 |
5 files changed, 15 insertions, 11 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 84111d82..a859c7b9 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -22,14 +22,14 @@ last_os_error(rust_task *task) { return NULL; } #elif defined(_GNU_SOURCE) - char cbuf[1024]; + char cbuf[BUF_BYTES]; char *buf = strerror_r(errno, cbuf, sizeof(cbuf)); if (!buf) { task->fail(1); return NULL; } #else - char buf[1024]; + char buf[BUF_BYTES]; int err = strerror_r(errno, buf, sizeof(buf)); if (err) { task->fail(1); diff --git a/src/rt/rust_dom.cpp b/src/rt/rust_dom.cpp index 45279551..356e9fe4 100644 --- a/src/rt/rust_dom.cpp +++ b/src/rt/rust_dom.cpp @@ -57,7 +57,7 @@ rust_dom::activate(rust_task *task) { void rust_dom::log(rust_task *task, uint32_t type_bits, char const *fmt, ...) { - char buf[256]; + char buf[BUF_BYTES]; if (_log.is_tracing(type_bits)) { va_list args; va_start(args, fmt); @@ -69,7 +69,7 @@ rust_dom::log(rust_task *task, uint32_t type_bits, char const *fmt, ...) { void rust_dom::log(uint32_t type_bits, char const *fmt, ...) { - char buf[256]; + char buf[BUF_BYTES]; if (_log.is_tracing(type_bits)) { va_list args; va_start(args, fmt); diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h index f008d9f6..9a1b2ec0 100644 --- a/src/rt/rust_internal.h +++ b/src/rt/rust_internal.h @@ -88,6 +88,10 @@ static size_t const TIME_SLICE_IN_MS = 10; static intptr_t const CONST_REFCOUNT = 0x7badface; +// This accounts for logging buffers. + +static size_t const BUF_BYTES = 1024; + // Every reference counted object should derive from this base class. template <typename T> struct rc_base { diff --git a/src/rt/rust_log.cpp b/src/rt/rust_log.cpp index 20f3f146..d0ba85de 100644 --- a/src/rt/rust_log.cpp +++ b/src/rt/rust_log.cpp @@ -136,7 +136,7 @@ append_string(char *buffer, rust_log::ansi_color color, void rust_log::trace_ln(uint32_t thread_id, char *prefix, char *message) { - char buffer[1024] = ""; + char buffer[BUF_BYTES] = ""; _log_lock.lock(); append_string(buffer, "%-34s", prefix); for (uint32_t i = 0; i < _indent; i++) { @@ -158,7 +158,7 @@ rust_log::trace_ln(rust_task *task, char *message) { #else uint32_t thread_id = hash((uint32_t) pthread_self()); #endif - char prefix[1024] = ""; + char prefix[BUF_BYTES] = ""; if (_dom && _dom->name) { append_string(prefix, "%04" PRIxPTR ":%.10s:", thread_id, _dom->name); diff --git a/src/rt/rust_srv.cpp b/src/rt/rust_srv.cpp index a5fcde9b..0453abce 100644 --- a/src/rt/rust_srv.cpp +++ b/src/rt/rust_srv.cpp @@ -12,7 +12,7 @@ rust_srv::rust_srv() : } rust_srv::~rust_srv() { -// char msg[1024]; +// char msg[BUF_BYTES]; // snprintf(msg, sizeof(msg), "~rust_srv %" PRIxPTR, (uintptr_t) this); // log(msg); } @@ -43,13 +43,13 @@ rust_srv::fatal(const char *expression, size_t line, const char *format, ...) { - char buf[1024]; + char buf[BUF_BYTES]; va_list args; va_start(args, format); vsnprintf(buf, sizeof(buf), format, args); va_end(args); - char msg[1024]; + char msg[BUF_BYTES]; snprintf(msg, sizeof(msg), "fatal, '%s' failed, %s:%d %s", expression, file, (int)line, buf); @@ -63,13 +63,13 @@ rust_srv::warning(char const *expression, size_t line, const char *format, ...) { - char buf[1024]; + char buf[BUF_BYTES]; va_list args; va_start(args, format); vsnprintf(buf, sizeof(buf), format, args); va_end(args); - char msg[1024]; + char msg[BUF_BYTES]; snprintf(msg, sizeof(msg), "warning: '%s', at: %s:%d %s", expression, file, (int)line, buf); |