GCC Code Coverage Report


Directory: ./
File: include/erec.h
Date: 2026-01-20 23:48:36
Exec Total Coverage
Lines: 3 3 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 #ifndef NFTABLES_EREC_H
2 #define NFTABLES_EREC_H
3
4 #include <nftables.h>
5 #include <utils.h>
6
7 /**
8 * enum error_record_types
9 *
10 * @EREC_INFORMATIONAL: informational message
11 * @EREC_WARNING: warning message
12 * @EREC_ERROR: error message
13 */
14 enum error_record_types {
15 EREC_INFORMATIONAL,
16 EREC_WARNING,
17 EREC_ERROR,
18 };
19
20 #define EREC_MSGBUFSIZE 1024
21 #define EREC_LOCATIONS_MAX 3
22
23 /**
24 * struct error_record
25 *
26 * @list: message queue node
27 * @type: error record type
28 * @num_locations: number of locations
29 * @locations: location(s) of error
30 * @msg: message
31 */
32 struct error_record {
33 struct list_head list;
34 enum error_record_types type;
35 unsigned int num_locations;
36 struct location locations[EREC_LOCATIONS_MAX];
37 char *msg;
38 };
39
40 extern struct error_record *erec_vcreate(enum error_record_types type,
41 const struct location *loc,
42 const char *fmt, va_list ap)
43 __fmtstring(3, 0);
44 extern struct error_record *erec_create(enum error_record_types type,
45 const struct location *loc,
46 const char *fmt, ...) __fmtstring(3, 4);
47 extern void erec_add_location(struct error_record *erec,
48 const struct location *loc);
49 extern void erec_destroy(struct error_record *erec);
50
51 #define error(loc, fmt, args...) \
52 erec_create(EREC_ERROR, (loc), (fmt), ## args)
53 #define warning(loc, fmt, args...) \
54 erec_create(EREC_WARNING, (loc), (fmt), ## args)
55
56 3191 static inline void erec_queue(struct error_record *erec,
57 struct list_head *queue)
58 {
59 3191 list_add_tail(&erec->list, queue);
60 3191 }
61
62 extern void erec_print(struct output_ctx *octx, const struct error_record *erec,
63 unsigned int debug_mask);
64 extern void erec_print_list(struct output_ctx *octx, struct list_head *list,
65 unsigned int debug_mask);
66
67 struct eval_ctx;
68
69 extern int __fmtstring(4, 5) __stmt_binary_error(struct eval_ctx *ctx,
70 const struct location *l1,
71 const struct location *l2,
72 const char *fmt, ...);
73
74 #define stmt_error(ctx, s1, fmt, args...) \
75 __stmt_binary_error(ctx, &(s1)->location, NULL, fmt, ## args)
76 #define stmt_binary_error(ctx, s1, s2, fmt, args...) \
77 __stmt_binary_error(ctx, &(s1)->location, &(s2)->location, fmt, ## args)
78
79 void print_location(FILE *f, const struct input_descriptor *indesc,
80 const struct location *loc);
81 const char *line_location(const struct input_descriptor *indesc,
82 const struct location *loc, char *buf, size_t bufsiz);
83
84 #endif /* NFTABLES_EREC_H */
85