• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemd / systemd / 14554080340

19 Apr 2025 11:46AM UTC coverage: 72.101% (-0.03%) from 72.13%
14554080340

push

github

web-flow
Add two new paragraphs to coding style about header files (#37188)

296880 of 411754 relevant lines covered (72.1%)

687547.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.88
/src/basic/dlfcn-util.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include "dlfcn-util.h"
4
#include "log.h"
5

6
static int dlsym_many_or_warnv(void *dl, int log_level, va_list ap) {
4,390✔
7
        void (**fn)(void);
4,390✔
8

9
        /* Tries to resolve a bunch of function symbols, and logs an error about if it cannot resolve one of
10
         * them. Note that this function possibly modifies the supplied function pointers if the whole
11
         * operation fails. */
12

13
        while ((fn = va_arg(ap, typeof(fn)))) {
76,603✔
14
                void (*tfn)(void);
72,213✔
15
                const char *symbol;
72,213✔
16

17
                symbol = va_arg(ap, typeof(symbol));
72,213✔
18

19
                tfn = (typeof(tfn)) dlsym(dl, symbol);
72,213✔
20
                if (!tfn)
72,213✔
21
                        return log_full_errno(log_level,
×
22
                                              SYNTHETIC_ERRNO(ELIBBAD),
23
                                              "Can't find symbol %s: %s", symbol, dlerror());
24
                *fn = tfn;
72,213✔
25
        }
26

27
        return 0;
28
}
29

30
int dlsym_many_or_warn_sentinel(void *dl, int log_level, ...) {
2,233✔
31
        va_list ap;
2,233✔
32
        int r;
2,233✔
33

34
        va_start(ap, log_level);
2,233✔
35
        r = dlsym_many_or_warnv(dl, log_level, ap);
2,233✔
36
        va_end(ap);
2,233✔
37

38
        return r;
2,233✔
39
}
40

41
int dlopen_many_sym_or_warn_sentinel(void **dlp, const char *filename, int log_level, ...) {
259,488✔
42
        _cleanup_(dlclosep) void *dl = NULL;
259,488✔
43
        int r;
259,488✔
44

45
        if (*dlp)
259,488✔
46
                return 0; /* Already loaded */
47

48
        dl = dlopen(filename, RTLD_NOW|RTLD_NODELETE);
2,226✔
49
        if (!dl)
2,226✔
50
                return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
69✔
51
                                       "%s is not installed: %s", filename, dlerror());
52

53
        log_debug("Loaded '%s' via dlopen()", filename);
2,157✔
54

55
        va_list ap;
2,157✔
56
        va_start(ap, log_level);
2,157✔
57
        r = dlsym_many_or_warnv(dl, log_level, ap);
2,157✔
58
        va_end(ap);
2,157✔
59

60
        if (r < 0)
2,157✔
61
                return r;
62

63
        /* Note that we never release the reference here, because there's no real reason to. After all this
64
         * was traditionally a regular shared library dependency which lives forever too. */
65
        *dlp = TAKE_PTR(dl);
2,157✔
66
        return 1;
2,157✔
67
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc