Skip to content

Commit e9bd21c

Browse files
committed
Merge branch 'tb/trace2-va-list-fix'
Fix some code that passed a NULL when a va_list was expected. * tb/trace2-va-list-fix: trace2: NULL is not allowed for va_list
2 parents 2850232 + ad006fe commit e9bd21c

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

trace2.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,14 @@ void trace2_region_enter_printf_va_fl(const char *file, int line,
548548
}
549549

550550
void trace2_region_enter_fl(const char *file, int line, const char *category,
551-
const char *label, const struct repository *repo)
551+
const char *label, const struct repository *repo, ...)
552552
{
553+
va_list ap;
554+
va_start(ap, repo);
553555
trace2_region_enter_printf_va_fl(file, line, category, label, repo,
554-
NULL, NULL);
556+
NULL, ap);
557+
va_end(ap);
558+
555559
}
556560

557561
void trace2_region_enter_printf_fl(const char *file, int line,
@@ -621,10 +625,13 @@ void trace2_region_leave_printf_va_fl(const char *file, int line,
621625
}
622626

623627
void trace2_region_leave_fl(const char *file, int line, const char *category,
624-
const char *label, const struct repository *repo)
628+
const char *label, const struct repository *repo, ...)
625629
{
630+
va_list ap;
631+
va_start(ap, repo);
626632
trace2_region_leave_printf_va_fl(file, line, category, label, repo,
627-
NULL, NULL);
633+
NULL, ap);
634+
va_end(ap);
628635
}
629636

630637
void trace2_region_leave_printf_fl(const char *file, int line,

trace2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ void trace2_def_repo_fl(const char *file, int line, struct repository *repo);
238238
* on this thread.
239239
*/
240240
void trace2_region_enter_fl(const char *file, int line, const char *category,
241-
const char *label, const struct repository *repo);
241+
const char *label, const struct repository *repo, ...);
242242

243243
#define trace2_region_enter(category, label, repo) \
244244
trace2_region_enter_fl(__FILE__, __LINE__, (category), (label), (repo))
@@ -278,7 +278,7 @@ void trace2_region_enter_printf(const char *category, const char *label,
278278
* in this nesting level.
279279
*/
280280
void trace2_region_leave_fl(const char *file, int line, const char *category,
281-
const char *label, const struct repository *repo);
281+
const char *label, const struct repository *repo, ...);
282282

283283
#define trace2_region_leave(category, label, repo) \
284284
trace2_region_leave_fl(__FILE__, __LINE__, (category), (label), (repo))

trace2/tr2_tgt_event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static void fn_atexit(uint64_t us_elapsed_absolute, int code)
190190
static void maybe_add_string_va(struct json_writer *jw, const char *field_name,
191191
const char *fmt, va_list ap)
192192
{
193-
if (fmt && *fmt && ap) {
193+
if (fmt && *fmt) {
194194
va_list copy_ap;
195195
struct strbuf buf = STRBUF_INIT;
196196

trace2/tr2_tgt_normal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static void fn_atexit(uint64_t us_elapsed_absolute, int code)
126126
static void maybe_append_string_va(struct strbuf *buf, const char *fmt,
127127
va_list ap)
128128
{
129-
if (fmt && *fmt && ap) {
129+
if (fmt && *fmt) {
130130
va_list copy_ap;
131131

132132
va_copy(copy_ap, ap);

trace2/tr2_tgt_perf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static void fn_atexit(uint64_t us_elapsed_absolute, int code)
211211
static void maybe_append_string_va(struct strbuf *buf, const char *fmt,
212212
va_list ap)
213213
{
214-
if (fmt && *fmt && ap) {
214+
if (fmt && *fmt) {
215215
va_list copy_ap;
216216

217217
va_copy(copy_ap, ap);

0 commit comments

Comments
 (0)