Linux Audio

Check our new training course

Loading...
v4.6
 
 1#include "util.h"
 2#include "../debug.h"
 3
 4
 5/*
 6 * Default error logging functions
 7 */
 8static int perf_stdio__error(const char *format, va_list args)
 9{
10	fprintf(stderr, "Error:\n");
11	vfprintf(stderr, format, args);
12	return 0;
13}
14
15static int perf_stdio__warning(const char *format, va_list args)
16{
 
 
 
17	fprintf(stderr, "Warning:\n");
18	vfprintf(stderr, format, args);
19	return 0;
20}
21
22static struct perf_error_ops default_eops =
23{
24	.error		= perf_stdio__error,
25	.warning	= perf_stdio__warning,
26};
27
28static struct perf_error_ops *perf_eops = &default_eops;
29
30
31int ui__error(const char *format, ...)
32{
33	int ret;
34	va_list args;
35
36	va_start(args, format);
37	ret = perf_eops->error(format, args);
38	va_end(args);
39
40	return ret;
41}
42
43int ui__warning(const char *format, ...)
44{
45	int ret;
46	va_list args;
 
 
47
48	va_start(args, format);
49	ret = perf_eops->warning(format, args);
50	va_end(args);
51
52	return ret;
53}
54
55/**
56 * perf_error__register - Register error logging functions
57 * @eops: The pointer to error logging function struct
58 *
59 * Register UI-specific error logging functions. Before calling this,
60 * other logging functions should be unregistered, if any.
61 */
62int perf_error__register(struct perf_error_ops *eops)
63{
64	if (perf_eops != &default_eops)
65		return -1;
66
67	perf_eops = eops;
68	return 0;
69}
70
71/**
72 * perf_error__unregister - Unregister error logging functions
73 * @eops: The pointer to error logging function struct
74 *
75 * Unregister already registered error logging functions.
76 */
77int perf_error__unregister(struct perf_error_ops *eops)
78{
79	if (perf_eops != eops)
80		return -1;
81
82	perf_eops = &default_eops;
83	return 0;
84}
v6.8
 1// SPDX-License-Identifier: GPL-2.0
 2#include "util.h"
 3#include "../util/debug.h"
 4#include <stdio.h>
 5
 6/*
 7 * Default error logging functions
 8 */
 9static int perf_stdio__error(const char *format, va_list args)
10{
11	fprintf(stderr, "Error:\n");
12	vfprintf(stderr, format, args);
13	return 0;
14}
15
16static int perf_stdio__warning(const char *format, va_list args)
17{
18	if (quiet)
19		return 0;
20
21	fprintf(stderr, "Warning:\n");
22	vfprintf(stderr, format, args);
23	return 0;
24}
25
26static struct perf_error_ops default_eops =
27{
28	.error		= perf_stdio__error,
29	.warning	= perf_stdio__warning,
30};
31
32static struct perf_error_ops *perf_eops = &default_eops;
33
34
35int ui__error(const char *format, ...)
36{
37	int ret;
38	va_list args;
39
40	va_start(args, format);
41	ret = perf_eops->error(format, args);
42	va_end(args);
43
44	return ret;
45}
46
47int ui__warning(const char *format, ...)
48{
49	int ret;
50	va_list args;
51	if (quiet)
52		return 0;
53
54	va_start(args, format);
55	ret = perf_eops->warning(format, args);
56	va_end(args);
57
58	return ret;
59}
60
61/**
62 * perf_error__register - Register error logging functions
63 * @eops: The pointer to error logging function struct
64 *
65 * Register UI-specific error logging functions. Before calling this,
66 * other logging functions should be unregistered, if any.
67 */
68int perf_error__register(struct perf_error_ops *eops)
69{
70	if (perf_eops != &default_eops)
71		return -1;
72
73	perf_eops = eops;
74	return 0;
75}
76
77/**
78 * perf_error__unregister - Unregister error logging functions
79 * @eops: The pointer to error logging function struct
80 *
81 * Unregister already registered error logging functions.
82 */
83int perf_error__unregister(struct perf_error_ops *eops)
84{
85	if (perf_eops != eops)
86		return -1;
87
88	perf_eops = &default_eops;
89	return 0;
90}