diff options
Diffstat (limited to 'trace.c')
-rw-r--r-- | trace.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -122,9 +122,7 @@ static int prepare_trace_line(const char *file, int line, static void print_trace_line(struct trace_key *key, struct strbuf *buf) { - /* append newline if missing */ - if (buf->len && buf->buf[buf->len - 1] != '\n') - strbuf_addch(buf, '\n'); + strbuf_complete_line(buf); write_or_whine_pipe(get_trace_fd(key), buf->buf, buf->len, err_msg); strbuf_release(buf); @@ -216,7 +214,7 @@ void trace_argv_printf(const char **argv, const char *format, ...) va_end(ap); } -void trace_strbuf(const char *key, const struct strbuf *data) +void trace_strbuf(struct trace_key *key, const struct strbuf *data) { trace_strbuf_fl(NULL, 0, key, data); } @@ -298,13 +296,12 @@ void trace_repo_setup(const char *prefix) { static struct trace_key key = TRACE_KEY_INIT(SETUP); const char *git_work_tree; - char cwd[PATH_MAX]; + char *cwd; if (!trace_want(&key)) return; - if (!getcwd(cwd, PATH_MAX)) - die("Unable to get current working directory"); + cwd = xgetcwd(); if (!(git_work_tree = get_git_work_tree())) git_work_tree = "(null)"; @@ -316,6 +313,8 @@ void trace_repo_setup(const char *prefix) trace_printf_key(&key, "setup: worktree: %s\n", quote_crnl(git_work_tree)); trace_printf_key(&key, "setup: cwd: %s\n", quote_crnl(cwd)); trace_printf_key(&key, "setup: prefix: %s\n", quote_crnl(prefix)); + + free(cwd); } int trace_want(struct trace_key *key) @@ -323,7 +322,7 @@ int trace_want(struct trace_key *key) return !!get_trace_fd(key); } -#ifdef HAVE_CLOCK_GETTIME +#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_CLOCK_MONOTONIC) static inline uint64_t highres_nanos(void) { @@ -384,7 +383,7 @@ static inline uint64_t gettimeofday_nanos(void) * Returns nanoseconds since the epoch (01/01/1970), for performance tracing * (i.e. favoring high precision over wall clock time accuracy). */ -inline uint64_t getnanotime(void) +uint64_t getnanotime(void) { static uint64_t offset; if (offset > 1) { |