btrfs-progs: reorder extent buffer members for better packing
[platform/upstream/btrfs-progs.git] / messages.c
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public
4  * License v2 as published by the Free Software Foundation.
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9  * General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the
13  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
14  * Boston, MA 021110-1307, USA.
15  */
16
17 #include <stdio.h>
18 #include <stdarg.h>
19 #include "messages.h"
20
21 __attribute__ ((format (printf, 1, 2)))
22 void __btrfs_warning(const char *fmt, ...)
23 {
24         va_list args;
25
26         fputs("WARNING: ", stderr);
27         va_start(args, fmt);
28         vfprintf(stderr, fmt, args);
29         va_end(args);
30         fputc('\n', stderr);
31 }
32
33 __attribute__ ((format (printf, 1, 2)))
34 void __btrfs_error(const char *fmt, ...)
35 {
36         va_list args;
37
38         fputs("ERROR: ", stderr);
39         va_start(args, fmt);
40         vfprintf(stderr, fmt, args);
41         va_end(args);
42         fputc('\n', stderr);
43 }
44
45 __attribute__ ((format (printf, 2, 3)))
46 int __btrfs_warning_on(int condition, const char *fmt, ...)
47 {
48         va_list args;
49
50         if (!condition)
51                 return 0;
52
53         fputs("WARNING: ", stderr);
54         va_start(args, fmt);
55         vfprintf(stderr, fmt, args);
56         va_end(args);
57         fputc('\n', stderr);
58
59         return 1;
60 }
61
62 __attribute__ ((format (printf, 2, 3)))
63 int __btrfs_error_on(int condition, const char *fmt, ...)
64 {
65         va_list args;
66
67         if (!condition)
68                 return 0;
69
70         fputs("ERROR: ", stderr);
71         va_start(args, fmt);
72         vfprintf(stderr, fmt, args);
73         va_end(args);
74         fputc('\n', stderr);
75
76         return 1;
77 }