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
Found by Coverity:
Error: RESOURCE_LEAK (CWE-772): [#def274] [important]
NetworkManager-1.31.3/src/libnmt-newt/nmt-newt-button.c:118: alloc_fn: Storage is returned from allocation function "g_strdup_printf".
NetworkManager-1.31.3/src/libnmt-newt/nmt-newt-button.c:118: var_assign: Assigning: "label" = storage returned from "g_strdup_printf(" <%s>", priv->label)".
NetworkManager-1.31.3/src/libnmt-newt/nmt-newt-button.c:119: noescape: Resource "label" is not freed or pointed-to in "nmt_newt_locale_from_utf8".
NetworkManager-1.31.3/src/libnmt-newt/nmt-newt-button.c:125: leaked_storage: Variable "label" going out of scope leaks the storage it points to.
# 123| }
# 124|
# 125|-> return co;
# 126| }
# 127|
Fixes: 3bda3fb60c ('nmtui: initial import of nmtui')
Previously, nmtui would set the newt color "checkbox" to a hard coded
value. This made it impossible to override the color via "$NEWT_COLORS".
With this change, nmtui also parses "$NEWT_COLORS" to allow setting
newt colors:
$ NEWT_COLORS='
window=white,red
border=white,red
checkbox=white,red
actcheckbox=white,green
' nmtui
Custom nmtui colors can now also be set via "$NMT_NEWT_COLORS":
"badLabel"
"plainLabel"
"disabledButton"
"textboxWithBackground"
For example:
$ NMT_NEWT_COLORS='plainLabel=green,lightgray' nmtui
The environment variables "$NEWT_COLORS_FILE" and "NMT_NEWT_COLORS_FILE"
are honored too.
The code is based on libnewt code ([1]), authored by Miroslav Lichvar.
That patch is originally LGPL-2.0-only licensed, but for inclusion in
NetworkManager we require it to be LGPL-2.1-or-later. Miroslav kindly
agreed to use his original contribution in NetworkManager.
[1] https://pagure.io/newt/c/34e56d12931a25222d7debb22f95bb2f9fa696a0
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/653https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/793