fix: add format attribute to relevant functions (-Wsuggest-attribute=format)
[lttng-ust.git] / liblttng-ust / tracef.c
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (C) 2013-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 */
6
7 #define _LGPL_SOURCE
8 #include <stdio.h>
9 #include <ust-helper.h>
10
11 #define TRACEPOINT_CREATE_PROBES
12 #define TRACEPOINT_DEFINE
13 #include "lttng-ust-tracef-provider.h"
14
15 static inline __attribute__((always_inline, format(printf, 1, 0)))
16 void __lttng_ust_vtracef(const char *fmt, va_list ap)
17 {
18 char *msg;
19 const int len = vasprintf(&msg, fmt, ap);
20
21 /* len does not include the final \0 */
22 if (len < 0)
23 goto end;
24 __tracepoint_cb_lttng_ust_tracef___event(msg, len,
25 LTTNG_UST_CALLER_IP());
26 free(msg);
27 end:
28 return;
29 }
30
31 __attribute__((format(printf, 1, 0)))
32 void _lttng_ust_vtracef(const char *fmt, va_list ap);
33 void _lttng_ust_vtracef(const char *fmt, va_list ap)
34 {
35 __lttng_ust_vtracef(fmt, ap);
36 }
37
38 __attribute__((format(printf, 1, 2)))
39 void _lttng_ust_tracef(const char *fmt, ...);
40 void _lttng_ust_tracef(const char *fmt, ...)
41 {
42 va_list ap;
43
44 va_start(ap, fmt);
45 __lttng_ust_vtracef(fmt, ap);
46 va_end(ap);
47 }
This page took 0.032887 seconds and 5 git commands to generate.