Coverage Report

Created: 2026-07-12 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/wsutil/cmdarg_err.c
Line
Count
Source
1
/* cmdarg_err.c
2
 * Routines to report command-line argument errors.
3
 *
4
 * Wireshark - Network traffic analyzer
5
 * By Gerald Combs <gerald@wireshark.org>
6
 * Copyright 1998 Gerald Combs
7
 *
8
 * SPDX-License-Identifier: GPL-2.0-or-later
9
 */
10
11
#include "config.h"
12
13
#include "cmdarg_err.h"
14
15
static void (*print_err)(const char *, va_list ap);
16
static void (*print_err_cont)(const char *, va_list ap);
17
18
/*
19
 * Set the reporting functions for error messages.
20
 */
21
void
22
cmdarg_err_init(void (*err)(const char *, va_list),
23
                void (*err_cont)(const char *, va_list))
24
15
{
25
15
    print_err = err;
26
15
    print_err_cont = err_cont;
27
15
}
28
29
/*
30
 * Report an error in command-line arguments.
31
 */
32
void
33
vcmdarg_err(const char *fmt, va_list ap)
34
2
{
35
2
    print_err(fmt, ap);
36
2
}
37
38
void
39
cmdarg_err(const char *fmt, ...)
40
0
{
41
0
    va_list ap;
42
43
0
    va_start(ap, fmt);
44
0
    print_err(fmt, ap);
45
0
    va_end(ap);
46
0
}
47
48
/*
49
 * Report additional information for an error in command-line arguments.
50
 */
51
void
52
cmdarg_err_cont(const char *fmt, ...)
53
0
{
54
0
    va_list ap;
55
56
0
    va_start(ap, fmt);
57
0
    print_err_cont(fmt, ap);
58
0
    va_end(ap);
59
0
}
60
61
/*
62
 * Error printing routines that report to the standard error.
63
 */
64
void
65
stderr_cmdarg_err(const char *msg_format, va_list ap)
66
2
{
67
2
    fprintf(stderr, "%s: ", g_get_prgname());
68
2
    vfprintf(stderr, msg_format, ap);
69
2
    fprintf(stderr, "\n");
70
2
}
71
72
void
73
stderr_cmdarg_err_cont(const char *msg_format, va_list ap)
74
0
{
75
0
    vfprintf(stderr, msg_format, ap);
76
    fprintf(stderr, "\n");
77
0
}