GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/util/exception.cc
Date: 2024-04-28 02:33:07
Exec Total Coverage
Lines: 15 18 83.3%
Branches: 5 14 35.7%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #include "cvmfs_config.h"
6 #include "exception.h"
7
8 #include <cassert>
9 #include <cstdarg>
10 #include <cstdio>
11 #include <cstdlib>
12
13 #include "util/logging.h"
14
15 #ifdef CVMFS_NAMESPACE_GUARD
16 namespace CVMFS_NAMESPACE_GUARD {
17 #endif
18
19 17 void Panic(const char* coordinates, const LogSource source, const int mask,
20 const char* format, ...) {
21 17 char* msg = NULL;
22 va_list variadic_list;
23
24 // Format the message string
25 17 va_start(variadic_list, format);
26 17 int retval = vasprintf(&msg, format, variadic_list);
27
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 assert(retval != -1); // else: out of memory
28 17 va_end(variadic_list);
29
30 // Add the coordinates
31 17 char* msg_with_coordinates = NULL;
32 17 retval = asprintf(&msg_with_coordinates, "%s\n%s", coordinates, msg);
33
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if (retval == -1) {
34 free(msg_with_coordinates);
35 } else {
36 17 free(msg);
37 17 msg = msg_with_coordinates;
38 }
39 // From now on we deal only with `msg`
40
41 // Either throw the exception or log + abort
42 #ifdef CVMFS_RAISE_EXCEPTIONS
43 (void) source;
44 (void) mask;
45
2/4
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 17 times.
✗ Branch 7 not taken.
17 throw ECvmfsException(msg);
46 #else
47 LogCvmfs(source, mask, "%s", msg);
48 abort();
49 #endif
50 }
51
52 2 void Panic(const char* coordinates, const LogSource _source, const char *nul) {
53
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 assert(nul == NULL);
54 2 Panic(coordinates, _source, kLogDebug | kLogStderr | kLogSyslogErr, "");
55 }
56
57 #ifdef CVMFS_NAMESPACE_GUARD
58 } // namespace CVMFS_NAMESPACE_GUARD
59 #endif
60