serial: 8250_dw: Don't use UPF_FIXED_TYPE
[linux/fpc-iii.git] / tools / perf / ui / util.c
blob4f989774c8c674c535990dcf82ae2ba47d5971e3
1 #include "util.h"
2 #include "../debug.h"
5 /*
6 * Default error logging functions
7 */
8 static int perf_stdio__error(const char *format, va_list args)
10 fprintf(stderr, "Error:\n");
11 vfprintf(stderr, format, args);
12 return 0;
15 static int perf_stdio__warning(const char *format, va_list args)
17 fprintf(stderr, "Warning:\n");
18 vfprintf(stderr, format, args);
19 return 0;
22 static struct perf_error_ops default_eops =
24 .error = perf_stdio__error,
25 .warning = perf_stdio__warning,
28 static struct perf_error_ops *perf_eops = &default_eops;
31 int ui__error(const char *format, ...)
33 int ret;
34 va_list args;
36 va_start(args, format);
37 ret = perf_eops->error(format, args);
38 va_end(args);
40 return ret;
43 int ui__warning(const char *format, ...)
45 int ret;
46 va_list args;
48 va_start(args, format);
49 ret = perf_eops->warning(format, args);
50 va_end(args);
52 return ret;
56 /**
57 * perf_error__register - Register error logging functions
58 * @eops: The pointer to error logging function struct
60 * Register UI-specific error logging functions. Before calling this,
61 * other logging functions should be unregistered, if any.
63 int perf_error__register(struct perf_error_ops *eops)
65 if (perf_eops != &default_eops)
66 return -1;
68 perf_eops = eops;
69 return 0;
72 /**
73 * perf_error__unregister - Unregister error logging functions
74 * @eops: The pointer to error logging function struct
76 * Unregister already registered error logging functions.
78 int perf_error__unregister(struct perf_error_ops *eops)
80 if (perf_eops != eops)
81 return -1;
83 perf_eops = &default_eops;
84 return 0;