#define __printf(a, b) __attribute__((format(printf, a, b)))
-__printf(2, 3)
-static int __base_pr(enum libbpf_print_level level, const char *format, ...)
+static int __base_pr(enum libbpf_print_level level, const char *format,
+ va_list args)
{
- va_list args;
- int err;
-
if (level == LIBBPF_DEBUG)
return 0;
- va_start(args, format);
- err = vfprintf(stderr, format, args);
- va_end(args);
- return err;
+ return vfprintf(stderr, format, args);
}
-static __printf(2, 3) libbpf_print_fn_t __libbpf_pr = __base_pr;
+static libbpf_print_fn_t __libbpf_pr = __base_pr;
void libbpf_set_print(libbpf_print_fn_t fn)
{
};
typedef int (*libbpf_print_fn_t)(enum libbpf_print_level level,
- const char *, ...)
- __attribute__((format(printf, 2, 3)));
+ const char *, va_list ap);
LIBBPF_API void libbpf_set_print(libbpf_print_fn_t fn);
#include "c++/clang-c.h"
static int libbpf_perf_print(enum libbpf_print_level level __attribute__((unused)),
- const char *fmt, ...)
+ const char *fmt, va_list args)
{
- va_list args;
- int ret;
-
- va_start(args, fmt);
- ret = veprintf(1, verbose, pr_fmt(fmt), args);
- va_end(args);
- return ret;
+ return veprintf(1, verbose, pr_fmt(fmt), args);
}
struct bpf_prog_priv {
return err;
}
-#define __printf(a, b) __attribute__((format(printf, a, b)))
-
-__printf(2, 3)
static int __base_pr(enum libbpf_print_level level __attribute__((unused)),
- const char *format, ...)
+ const char *format, va_list args)
{
- va_list args;
- int err;
-
- va_start(args, format);
- err = vfprintf(stderr, format, args);
- va_end(args);
- return err;
+ return vfprintf(stderr, format, args);
}
#define BTF_INFO_ENC(kind, kind_flag, vlen) \
static bool debug = 0;
static int libbpf_debug_print(enum libbpf_print_level level,
- const char *fmt, ...)
+ const char *fmt, va_list args)
{
- va_list args;
- int ret;
-
if (level == LIBBPF_DEBUG && !debug)
return 0;
- va_start(args, fmt);
fprintf(stderr, "[%d] ", level);
- ret = vfprintf(stderr, fmt, args);
- va_end(args);
- return ret;
+ return vfprintf(stderr, fmt, args);
}
#define EXIT_FAIL_LIBBPF EXIT_FAILURE
}
static int libbpf_debug_print(enum libbpf_print_level level,
- const char *format, ...)
+ const char *format, va_list args)
{
- va_list args;
- int ret;
-
if (level == LIBBPF_DEBUG)
return 0;
- va_start(args, format);
- ret = vfprintf(stderr, format, args);
- va_end(args);
- return ret;
+ return vfprintf(stderr, format, args);
}
static void test_reference_tracking()