perf tools: Use __maybe_used for unused variables
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / tools / perf / ui / helpline.c
CommitLineData
5575536f
ACM
1#include <stdio.h>
2#include <stdlib.h>
4610e413 3#include <string.h>
5575536f 4
1e6dd077 5#include "../debug.h"
5575536f 6#include "helpline.h"
5c35d69f 7#include "ui.h"
5575536f 8
e6e90468
NK
9char ui_helpline__current[512];
10
11static void nop_helpline__pop(void)
5575536f 12{
5575536f
ACM
13}
14
1d037ca1 15static void nop_helpline__push(const char *msg __maybe_unused)
e6e90468
NK
16{
17}
4610e413 18
e6e90468
NK
19static struct ui_helpline default_helpline_fns = {
20 .pop = nop_helpline__pop,
21 .push = nop_helpline__push,
22};
23
24struct ui_helpline *helpline_fns = &default_helpline_fns;
25
26void ui_helpline__pop(void)
5575536f 27{
e6e90468
NK
28 helpline_fns->pop();
29}
4610e413 30
e6e90468
NK
31void ui_helpline__push(const char *msg)
32{
33 helpline_fns->push(msg);
5575536f
ACM
34}
35
59e8fe32 36void ui_helpline__vpush(const char *fmt, va_list ap)
5575536f
ACM
37{
38 char *s;
39
40 if (vasprintf(&s, fmt, ap) < 0)
41 vfprintf(stderr, fmt, ap);
42 else {
43 ui_helpline__push(s);
44 free(s);
45 }
46}
47
48void ui_helpline__fpush(const char *fmt, ...)
49{
50 va_list ap;
51
52 va_start(ap, fmt);
53 ui_helpline__vpush(fmt, ap);
54 va_end(ap);
55}
56
57void ui_helpline__puts(const char *msg)
58{
59 ui_helpline__pop();
60 ui_helpline__push(msg);
61}