Commit Graph

17 Commits

Author SHA1 Message Date
Thomas Haller
532f3e34a8 glib-aux: drop nm_str_buf_init() for NM_STR_BUF_INIT()
NM_STR_BUF_INIT() and nm_str_buf_init() were pretty much redundant. Drop one of
them.

Usually our pattern is that we don't have functions that return structs.
But NM_STR_BUF_INIT() returns a struct, because it's convenient to use
with

  nm_auto_str_buf NMStrBuf strbuf = NM_STR_BUF_INIT(...);

So use that variant instead.
2022-05-09 19:18:30 +02:00
Thomas Haller
615221a99c format: reformat source tree with clang-format 13.0
We use clang-format for automatic formatting of our source files.
Since clang-format is actively maintained software, the actual
formatting depends on the used version of clang-format. That is
unfortunate and painful, but really unavoidable unless clang-format
would be strictly bug-compatible.

So the version that we must use is from the current Fedora release, which
is also tested by our gitlab-ci. Previously, we were using Fedora 34 with
clang-tools-extra-12.0.1-1.fc34.x86_64.

As Fedora 35 comes along, we need to update our formatting as Fedora 35
comes with version "13.0.0~rc1-1.fc35".
An alternative would be to freeze on version 12, but that has different
problems (like, it's cumbersome to rebuild clang 12 on Fedora 35 and it
would be cumbersome for our developers which are on Fedora 35 to use a
clang that they cannot easily install).

The (differently painful) solution is to reformat from time to time, as we
switch to a new Fedora (and thus clang) version.
Usually we would expect that such a reformatting brings minor changes.
But this time, the changes are huge. That is mentioned in the release
notes [1] as

  Makes PointerAligment: Right working with AlignConsecutiveDeclarations. (Fixes https://llvm.org/PR27353)

[1] https://releases.llvm.org/13.0.0/tools/clang/docs/ReleaseNotes.html#clang-format
2021-11-29 09:31:09 +00:00
Thomas Haller
ea49b50651 all: add some README.md files describing the purpose of our sources 2021-08-19 17:51:11 +02:00
Thomas Haller
3587cbd827 all: rename nm_utils_strsplit_set*() to nm_strsplit_set*() 2021-08-02 09:26:47 +02:00
Thomas Haller
d0ba87a1ad all: rename nm_utils_strbuf_*() API to nm_strbuf_*()
The "utils" part does not seem useful in the name.

Note that we also have NMStrBuf, which is named nm_str_buf_*().
There is an unfortunate similarity between the two, but it's still
distinct enough (in particular, because one takes an NMStrBuf and
the other not).
2021-08-02 09:26:42 +02:00
Thomas Haller
4e109bacab clang-format: use "IndentPPDirectives:None" instead of "BeforeHash"
Subjectively, I think this looks better.
2021-07-09 08:49:06 +02:00
Thomas Haller
1353a0e8da logging: add _nm_log_full() macro
_nm_log_impl() is the underlying implementation. As we have
multiple implementations, it's a bit confusing how it all works
together.

We thus should not call this directly, so that there are few (literal)
uses of this symbol.

Still, we may need to call this version of the logging statement,
because it's the only one that allows to provide the file location.

Add a wrapper macro for this, that callers can use.
2021-04-12 16:46:01 +02:00
Thomas Haller
3c0ae1b5da platform: make global logging cache for NMPlatform's sysctl values thread-safe
We have a cache for sysctl values, so that we can log changes and
previous values.

When resetting the log level, we prune that cache, which is done by
_nm_logging_clear_platform_logging_cache(). That function is called
by nm_logging_setup(), which is guaranteed to only happen on the main
thread.

NMPlatform in general is not thread safe (meaning, that the same NMPlatform
instance cannot be used by multiple threads at the same time). There is however
a reasonable aim that you could use different NMPlatform instances on their
own threads.

That currently doesn't work, mainly due to nm-logging which always must
be done from the main thread -- unless we would set NM_THREAD_SAFE_ON_MAIN_THREAD
in all of NMPlatform (which would be too expensive for something we
don't actually need). That means also the sysctl getter must only be
called on the main thread an all was good already.

Still, we could have NMPlatform usable from multiple thread by setting
NM_THREAD_SAFE_ON_MAIN_THREAD. As we are almost there to have the code
thread-safe, make accessing the sysctl value cache thread-safe (even if
we currently don't actually access it from multiple thread).
2021-03-08 22:29:01 +01:00
Thomas Haller
597ad6aa8a logging: use NMStrBuf in _domains_to_string() 2021-03-08 22:29:01 +01:00
Thomas Haller
29e93b1738 logging: prefer stack buffer for logging message 2021-03-08 22:29:01 +01:00
Thomas Haller
62727b62e0 logging: fix syslog identifier for NetworkManager
We no longer define G_LOG_DOMAIN differently for the libraries and
applications. Instead, the use now all "nm".

However, that also changes the syslog identifier for NetworkManager
core. That is undesirable. Change it back to "NetworkManager".

Fixes: 341b6e0704 ('all: change G_LOG_DOMAIN to "nm"')
2021-03-03 11:15:16 +01:00
Thomas Haller
a9540fb927 build/meson: drop libnm_log_core_dep dependency 2021-02-28 10:42:04 +01:00
Thomas Haller
309dccf5f9 build/meson: cleanup libnm-glib-aux dependencies
Avoid dependencies but explicitly link the static library where it is
used.

This also fixes that we linked libnm-log-core into
libnm-settings-plugin-ifcfg-rh.so, which duplicated the symbols
while it should used them from NetworkManager.
2021-02-28 10:42:04 +01:00
Thomas Haller
2665b91288 core: rename level_desc global variable
Symbols in header files should almost always have an "nm" prefix.

That is not purely cosmetic, because core modules (like libnm-device-plugin*.so
and libnm-settings-plugin*so) should re-use the symbols of the NetworkManager
binary. For NetworkManager we generate a linker version script to only expose
the symbols that are needed. It thereby excludes symbols that don't have an "nm"
prefix.

Hence, the plugins otherwise cannot reuse the global symbol.

The only reason that we currently don't have a linker error is because
we also link the logging static library into the plugin modules. That is
wrong, because we should not duplicate these symbols.
2021-02-28 10:42:03 +01:00
Thomas Haller
7b48d6bd31 build: remove shared/ directory 2021-02-24 12:49:13 +01:00
Thomas Haller
635d84b896 build: remove "shared/" from include search path
There is nothing left there.
2021-02-24 12:49:06 +01:00
Thomas Haller
9dc84b32b0 build: move "shared/nm-{glib-aux,log-null,log-core}" to "src/libnm-{glib-aux,log-null,log-core}" 2021-02-24 12:48:20 +01:00