dte test coverage


Directory: ./
File: src/util/progname.h
Date: 2024-12-21 16:03:22
Exec Total Coverage
Lines: 3 3 100.0%
Functions: 1 1 100.0%
Branches: 8 8 100.0%

Line Branch Exec Source
1 #ifndef UTIL_PROGNAME_H
2 #define UTIL_PROGNAME_H
3
4 #include "macros.h"
5
6 // Get the program name from argv[0] (as passed to main()), or fall back to a
7 // pre-defined string if it's missing
8 RETURNS_NONNULL
9 7 static inline const char *progname(int argc, char *argv[], const char *fallback)
10 {
11 // Setting argv[0] properly is under the control of the parent process,
12 // so it's safest to make as few assumptions about it as possible
13
6/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 2 times.
7 if (likely(argc >= 1 && argv && argv[0] && argv[0][0])) {
14 return argv[0];
15 }
16
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 return fallback ? fallback : "_PROG_";
17 }
18
19 #endif
20