Yu Watanabe [Wed, 7 Apr 2021 16:47:52 +0000 (01:47 +0900)]
test: move check of nat table existence
As test_v4() with iptables backend will be called after nftables tests.
Follow-up for
afbcd905526111e3a1bd55b0d6d5ee4413734735.
Zbigniew Jędrzejewski-Szmek [Thu, 8 Apr 2021 12:37:02 +0000 (14:37 +0200)]
Merge pull request #19237 from yuwata/udev-builtin-net-id-follow-ups-for-19017
udev: fix several issues around hotplug slot detection
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 14:18:53 +0000 (16:18 +0200)]
core: fix memleak of ipc_namespace_path
Fixup for
a70581ffb5c13c91c76ff73ba6f5f3ff59c5a915.
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32991
Luca Boccassi [Wed, 7 Apr 2021 21:06:26 +0000 (22:06 +0100)]
Merge pull request #19231 from bluca/coredump_decode
coredump: follow-ups for #19135
Yu Watanabe [Wed, 7 Apr 2021 13:22:22 +0000 (22:22 +0900)]
udev: use snprintf_ok()
Yu Watanabe [Wed, 7 Apr 2021 13:36:12 +0000 (22:36 +0900)]
udev: fix potential infinite loop
Yu Watanabe [Wed, 7 Apr 2021 13:26:41 +0000 (22:26 +0900)]
udev: make dev_pci_slot() return earlier when PCI bridge is found
Yu Watanabe [Wed, 7 Apr 2021 10:17:23 +0000 (19:17 +0900)]
udev: use uint32_t for hotplug_slot
This also makes function id is parsed as uint64_t. Kernel internally
uses uint32_t for function id (see the definition of 'struct zpci_dev),
but it maybe extended in the future.
Yu Watanabe [Wed, 7 Apr 2021 13:11:00 +0000 (22:11 +0900)]
udev: split out logic of parsing s390 PCI slots
This also adds several debugging logs.
Yu Watanabe [Wed, 7 Apr 2021 10:19:45 +0000 (19:19 +0900)]
udev: it is not necessary that the path is readable
Yu Watanabe [Wed, 7 Apr 2021 10:09:50 +0000 (19:09 +0900)]
udev: add missing initialization to fix freeing invalid address
Lennart Poettering [Thu, 1 Apr 2021 15:58:54 +0000 (17:58 +0200)]
mkosi: work-around to make systemd build in Fedora images that lack populated /etc
On Fedora /usr/bin/ld is a symlink managed via the "alternatives"
system. This unfortunately means the binary is not usable in
environments where /var or /etc are unpopulated. Let's address this by
redirecting "ld" to "ld.bfd" manually if such an environment is
detected, via $PATH.
This is useful for building systemd in mkosi with UsrOnly=1 set.
Lennart Poettering [Tue, 6 Apr 2021 09:45:47 +0000 (11:45 +0200)]
proc-cmdline: allow backslash escapes when parsing /proc/cmdline
So far when parsing /proc/cmdline we'd consider backslashes as
mechanisms for escaping whitepace or quotes. This changes things so that
they are retained as they are instead. The kernel itself doesn't allow such
escaping, and hence we shouldn't do so either (see lib/cmdline.c in the
kernel sources; it does support "" quotes btw).
This fix is useful to allow specifying backslash escapes in the "root="
cmdline option to be passed through to systemd-fstab-generator. Example:
root=/dev/disk/by-partlabel/Root\x20Partition
Previously we'd eat up the "\" so that we'd then look for a device
/dev/disk/by-partlabel/Rootx20Partition which never shows up.
Luca Boccassi [Wed, 7 Apr 2021 09:56:14 +0000 (10:56 +0100)]
coredump: update and shorten package metadata keys
Follow-up for
a7ea0a460bb3
Luca Boccassi [Wed, 7 Apr 2021 09:47:14 +0000 (10:47 +0100)]
coredump: use path_equal_filename helper
Luca Boccassi [Wed, 7 Apr 2021 09:45:33 +0000 (10:45 +0100)]
basic: add path_equal_filename helper
Luca Boccassi [Wed, 7 Apr 2021 09:38:56 +0000 (10:38 +0100)]
coredumpctl: fetch JSON object by key instead of iterating
Follow-up for
d1b5a0c691
Luca Boccassi [Wed, 7 Apr 2021 09:35:34 +0000 (10:35 +0100)]
coredump: fetch JSON object by key instead of iterating
Follow-up for
c546154a4448ddf9
Luca Boccassi [Wed, 7 Apr 2021 09:31:31 +0000 (10:31 +0100)]
coredump: rename COREDUMP_PKGMETA_ fields to COREDUMP_PACKAGE_
Follow-up for
c546154a4448ddf9
Luca Boccassi [Wed, 7 Apr 2021 09:21:48 +0000 (10:21 +0100)]
coredump: use JSON helpers instead of creating objects manually
Follow-up for
95f71807733
Luca Boccassi [Wed, 7 Apr 2021 09:16:54 +0000 (10:16 +0100)]
coredump: fix style nits
Follow-up for
95f71807733
Luca Boccassi [Wed, 7 Apr 2021 09:15:20 +0000 (10:15 +0100)]
coredump: use set_put_strdup()
Follow-up for
95f71807733
Luca Boccassi [Wed, 7 Apr 2021 09:15:01 +0000 (10:15 +0100)]
coredump: fix typo
Follow-up for
95f71807733
Morten Linderud [Wed, 7 Apr 2021 10:10:10 +0000 (12:10 +0200)]
man/systemd-cryptenroll: Fix sd-boot manvolnum from 8 to 7
Off-by-one error in the documentation index. The volume number for
systemd-boot/sd-boot is 7.
Signed-off-by: Morten Linderud <morten@linderud.pw>
Luca Boccassi [Tue, 6 Apr 2021 19:24:17 +0000 (20:24 +0100)]
Bump test-random-util timeout
It is using log_trace, which we enabled in the CI, so now it's
slower and it is timing out. Bump the timeout from 30s to 120s.
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 05:41:16 +0000 (07:41 +0200)]
Merge pull request #19135 from bluca/coredump_decode
coredump: parse build-id and .note.package
Luca Boccassi [Tue, 6 Apr 2021 14:48:52 +0000 (15:48 +0100)]
Add markdown doc about coredump package metadata
Luca Boccassi [Tue, 6 Apr 2021 17:02:41 +0000 (18:02 +0100)]
coredumpctl: parse and print package metadata
Luca Boccassi [Tue, 6 Apr 2021 17:24:01 +0000 (18:24 +0100)]
coredump: parse and append package metadata to journal message
Append 'package' and 'packageVersion' to the journal as discrete fields
COREDUMP_PKGMETA_PACKAGE and COREDUMP_PKGMETA_PACKAGEVERSION respectively,
and the full json blurb as COREDUMP_PKGMETA_JSON.
Luca Boccassi [Tue, 6 Apr 2021 17:21:48 +0000 (18:21 +0100)]
coredump: parse .note.package ELF section
Parse the .note.package ELF section for each ELF object
contained in a core file, if present.
Luca Boccassi [Thu, 18 Mar 2021 11:19:09 +0000 (11:19 +0000)]
coredump: parse build-id out of core file
Parse the build-id of each ELF object contained in the core file
using the elfutils' libdwfl interface.
Add it to the journal.
Luca Boccassi [Tue, 6 Apr 2021 17:52:11 +0000 (18:52 +0100)]
Merge pull request #19215 from braewoods/main
hwdb: 60-keyboard:: Add quirks for 2 new HP laptops
Lennart Poettering [Tue, 6 Apr 2021 09:46:19 +0000 (11:46 +0200)]
tpm2-util: properly load tpm2 libraries befre unsealing
We forgot a call to dlopen_tpm2() in the unseal codepaths. As long as
automatic TPM2 device discovery was used that didn't matter, since in
that codepaths we'd have another call dlopen_tpm2(). But with an
explicitly configured TPM2 device things should work too, hence add the
missing call.
Fixes: #19206
Lennart Poettering [Tue, 6 Apr 2021 09:45:54 +0000 (11:45 +0200)]
recovery-key: add some extra asserts
Let's ensure our key sizes calculations are correct.
This doesn't actually change anything, just adds more safety checks.
Inspired by #19203, but not a fix.
KoyamaSohei [Sat, 3 Apr 2021 16:13:37 +0000 (01:13 +0900)]
resolve: copy rd flag from the query to response
Sibo Dong [Sat, 3 Apr 2021 03:33:59 +0000 (23:33 -0400)]
bash-completion: localize words and cword variables
The words and cword variables are not localized in all Bash completion
scripts that call _init_completion.
cur, prev, words, and cword (and split if using the -s flag) are all
variables that should be localized in Bash completion scripts before
calling _init_completion (even if they don't otherwise appear in the
calling script). This is done for cur and prev, but not for words and
cword. Letting words and cword remain unlocalized may clobber variables
the user is using for other purposes, which is bad.
This issue can be resolved by declaring words and cword as local
variables.
Resolves #19188.
Luca Boccassi [Fri, 2 Apr 2021 15:30:43 +0000 (16:30 +0100)]
sysusers/firstboot: temporarily disable LoadCredential
Single-param LoadCredential= in units causes systemd v247/v248 to
assert when parsing. Disable it for now, until the fix is merged
in the stable trees, released and available (eg: in Debian
for the CI)
See: https://github.com/systemd/systemd/issues/19178
Lennart Poettering [Tue, 6 Apr 2021 09:45:27 +0000 (11:45 +0200)]
update
James Buren [Tue, 6 Apr 2021 07:18:26 +0000 (02:18 -0500)]
hwdb: 60-keyboard:: Add HP ProBook 455 G5 hotkey quirks
This enables all of the known hotkeys that were not working out of the
box on my test unit.
James Buren [Tue, 6 Apr 2021 06:32:37 +0000 (01:32 -0500)]
hwdb: 60-keyboard:: Add HP mt44 Mobile Thin Client hotkey quirks
This enables all of the known hotkeys that were not working out of the
box on my test unit.
Gibeom Gwon [Mon, 5 Apr 2021 14:11:23 +0000 (23:11 +0900)]
qrcode-util: set case-sensitive for generating QR codes
Until now, string treated case-insensitive, always converted to
uppercase. This can cause confusion such as user enter uppercased
recovery key.
Anita Zhang [Fri, 2 Apr 2021 09:49:37 +0000 (02:49 -0700)]
test-firewall-util: skip if iptables nat table does not exist
Zbigniew Jędrzejewski-Szmek [Tue, 6 Apr 2021 05:59:59 +0000 (07:59 +0200)]
Merge pull request #19126 from anitazha/oomdimprovements
systemd-oomd post-test week improvements
Frantisek Sumsal [Fri, 2 Apr 2021 17:51:44 +0000 (19:51 +0200)]
test: check if the unit file fuzzer corpora is up to date
This follows a similar pattern we already have in place for
networkd-related directives.
Anita Zhang [Fri, 26 Mar 2021 09:37:01 +0000 (02:37 -0700)]
oomd: threshold swap kill candidates to usages of more than 5%
In some instances, particularly with swap on zram, swap used will be high
while there is still a lot of memory available. FB OOMD handles this by
thresholding kills to X% of total swap usage. Let's do the same thing here.
Anecdotally with these thresholds and my laptop which is exclusively swap
on zram I can sit at 0K / 4G swap free with most of memory free and
systemd-oomd doesn't kill anything.
Partially addresses aggressive kill behavior from
https://bugzilla.redhat.com/show_bug.cgi?id=
1941170
Anita Zhang [Fri, 26 Mar 2021 08:53:15 +0000 (01:53 -0700)]
oomd: don't get pressure candidates on every interval
Only start collecting candidates for a memory pressure kill when we're
hitting the limit (but before the duration hitting that limit is
exceeded). This brings CPU util from ~1% to 0.3%.
Addresses CPU util from
https://bugzilla.redhat.com/show_bug.cgi?id=
1941340
and
https://bugzilla.redhat.com/show_bug.cgi?id=
1944646
Frantisek Sumsal [Fri, 2 Apr 2021 16:07:26 +0000 (18:07 +0200)]
fuzzer: add a test case for #19178
Luca Boccassi [Fri, 2 Apr 2021 16:56:13 +0000 (17:56 +0100)]
Merge pull request #19179 from anitazha/buildandtest
test-oomd-util: fix running in mkosi
Viktor Mihajlovski [Thu, 18 Mar 2021 10:03:34 +0000 (11:03 +0100)]
udev: fix slot based network names on s390
The s390 PCI driver assigns the hotplug slot name from the
function_id attribute of the PCI device using a 8 char hexadecimal
format to match the underlying firmware/hypervisor notation.
Further, there's always a one-to-one mapping between a PCI
function and a hotplug slot, as individual functions can
hot plugged even for multi-function devices.
As the generic matching code will always try to parse the slot
name in /sys/bus/pci/slots as a positive decimal number, either
a wrong value might be produced for ID_NET_NAME_SLOT if
the slot name consists of decimal numbers only, or none at all
if a character in the range from 'a' to 'f' is encountered.
Additionally, the generic code assumes that two interfaces
share a hotplug slot, if they differ only in the function part
of the PCI address. E.g., for an interface with the PCI address
dddd:bb:aa.f, it will match the device to the first slot with
an address dddd:bb:aa. As more than one slot may have this address
for the s390 PCI driver, the wrong slot may be selected.
To resolve this we're adding a new naming schema version with the
flag NAMING_SLOT_FUNCTION_ID, which enables the correct matching
of hotplug slots if the device has an attribute named function_id.
The ID_NET_NAME_SLOT property will only be produced if there's
a file /sys/bus/pci/slots/<slotname> where <slotname> matches
the value of /sys/bus/pci/devices/.../function_id in 8 char
hex notation.
Fixes #19016
See also #19078
Zbigniew Jędrzejewski-Szmek [Fri, 2 Apr 2021 13:53:16 +0000 (15:53 +0200)]
Merge pull request #18717 from yuwata/sd-device-monitor-introduce-more-filters
sd-device-monitor: introduce two new filters and use them in dissect-image.c
Carlo Teubner [Fri, 2 Apr 2021 08:03:02 +0000 (09:03 +0100)]
docs: use current spelling "macOS" not "OS X" etc.
Yu Watanabe [Sun, 21 Feb 2021 02:11:28 +0000 (11:11 +0900)]
dissect-image: move parent device check into device_is_partition()
Checking parent for enumerated devices is mostly redundant. Just for
safety.
Yu Watanabe [Sun, 21 Feb 2021 02:16:18 +0000 (11:16 +0900)]
dissect-image: also check devtype in device_is_partition()
This should be mostly redundant. Just for safety.
Yu Watanabe [Sun, 21 Feb 2021 02:00:19 +0000 (11:00 +0900)]
dissect-image: filter out enumerated or triggered devices without "partition" sysattr
This also adds more filters for device enumerator and monitor.
These newly added filters should be mostly redundant. But this hides
spurious error in sd_device_get_sysattr_value(). See,
https://github.com/systemd/systemd/pull/18684#discussion_r579700977
Yu Watanabe [Wed, 24 Feb 2021 05:05:03 +0000 (14:05 +0900)]
test: add tests for filters of sd-device-monitor
Yu Watanabe [Sun, 21 Feb 2021 00:54:55 +0000 (09:54 +0900)]
sd-device-monitor: introduce sd_device_monitor_filter_add_match_parent()
Yu Watanabe [Sun, 21 Feb 2021 00:53:50 +0000 (09:53 +0900)]
sd-device-enumerator: also move match_parent() to device-util.[ch]
Yu Watanabe [Sun, 21 Feb 2021 00:33:04 +0000 (09:33 +0900)]
sd-device-monitor: introduce sd_device_monitor_filter_add_match_sysattr()
Yu Watanabe [Sun, 21 Feb 2021 00:32:39 +0000 (09:32 +0900)]
sd-device-enumerator: move match_sysattr() to device-util.[ch]
It will be used by sd-device-monitor in later commits.
Yu Watanabe [Sat, 20 Feb 2021 22:53:31 +0000 (07:53 +0900)]
sd-device-monitor: split passes_filter() into two parts
Anita Zhang [Fri, 2 Apr 2021 02:06:26 +0000 (19:06 -0700)]
test-oomd-util: fix running in mkosi
When this test is run in mkosi, the previously tested cgroup that we write
xattrs into and the root cgroup are the same.
Since the root cgroup is a live cgroup anyways (vs. the test cgroups which are
remade each time) let's generate the expected preference values from reading
the xattrs instead of assuming it will be NONE.
Anita Zhang [Fri, 26 Mar 2021 08:19:10 +0000 (01:19 -0700)]
oomd: force DefaultMemoryPressureDurationSec= to be greater than or equal 1 sec
Anita Zhang [Fri, 26 Mar 2021 07:54:46 +0000 (00:54 -0700)]
oomd: delete unused variables
Anita Zhang [Sat, 27 Mar 2021 09:02:00 +0000 (02:02 -0700)]
oomd: rename last_hit_mem_pressure_limit -> mem_pressure_limit_hit_start
Since this is only changed the first time the limit is hit (and remains
set as long as the pressure remains over), I changed the name to better
reflect that.
Keeps consistent with "last_had_mem_reclaim" which is actually updated
every time there is reclaim activity.
Anita Zhang [Fri, 26 Mar 2021 07:39:25 +0000 (00:39 -0700)]
oomd: rework memory reclaim detection logic
systemd-oomd only monitors and kills within a selected cgroup subtree
For memory pressure kills, this means it's unnecessary to get the
pgscan rate across all the monitored memory pressure cgroups.
The increase will show up whether we do a total sum or not, but since
we only care about the increase in the subtree we're about to target
for a kill, we can simplify the code a bit by not doing this total sum.
Anita Zhang [Fri, 26 Mar 2021 06:54:22 +0000 (23:54 -0700)]
oomd: refactor pgscan_rate calculation into helper
Anita Zhang [Wed, 24 Mar 2021 09:17:04 +0000 (02:17 -0700)]
oomd: split swap and mem pressure event timers
One thing that came out of the test week is that systoomd needs to poll
more frequently so as not to race with the kernel oom killer in
situations where memory is eaten quickly. Memory pressure counters are
lagging so it isn't worthwhile to change the current read rate; however swap
is not lagging and can be checked more frequently.
So let's split these into 2 different timer events. As a result, swap
now also doesn't have to be subject to the post-action (post-kill) delay
that we need for memory pressure events.
Addresses some of slowness to kill discussed in
https://bugzilla.redhat.com/show_bug.cgi?id=
1941340
Anita Zhang [Fri, 2 Apr 2021 01:44:26 +0000 (18:44 -0700)]
meson: link with libm for math functions
Fixes this error I got building on F33:
/usr/bin/ld: test-random-util.p/src_test_test-random-util.c.o: undefined
reference to symbol 'sqrt@@GLIBC_2.2.5'
/usr/bin/ld: /usr/lib64/libm.so.6: error adding symbols: DSO missing
from command line
Joerg Behrmann [Tue, 30 Mar 2021 14:29:59 +0000 (16:29 +0200)]
systemd-notify: Fix return value of --booted
Luca Boccassi [Thu, 1 Apr 2021 18:45:08 +0000 (19:45 +0100)]
Merge pull request #19175 from keszybz/maybe-unitialized-warning-2
Third batch of fixes and suppressions for maybe-unitialized warnings
Luca Boccassi [Thu, 1 Apr 2021 08:48:36 +0000 (09:48 +0100)]
resolved: use _cleanup_(gcry_md_closep) in one more place
Documentation says gcry_md_close will ignore a NULL input so should be safe:
https://gnupg.org/documentation/manuals/gcrypt/Working-with-hash-algorithms.html
Makes Coverity happy, follow-up for
248b1e0aa4
CID #
1451555
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 19:28:11 +0000 (21:28 +0200)]
libudev: fix return of udev_monitor_filter_add_match_subsystem_devtype()
Follow-up for
7117842657c0fc5a3446b6fe158615279cf2d650.
sd_device_monitor_filter_add_match_subsystem_devtype() now returns 1 to signify
that something was done, and 0 to signify that nothing was done, but
udev_monitor_filter_add_match_subsystem_devtype() needs to return 0 as documented.
udev_monitor_filter_add_match_tag() is adjusted to match.
This makes gdm start successfully here again.
Before, it would just not boot, with nothing very obvious in the logs:
gdm[1756]: Gdm: GdmDisplay: Session never registered, failing
Replaces #19171.
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 09:12:57 +0000 (11:12 +0200)]
resolved: avoid passing unitialized variable
The issue was introduced in the refactoring in
775ae35403f8f3c01b7ac13387fe8aac1759993f.
We would pass an initialized value to a helper function. We would only *use*
it if it was initialized. But the mere passing of an unitialized variable is
UB, so let's not do that. This silences a gcc warning.
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:37:11 +0000 (10:37 +0200)]
various: silence gcc warnings
AFAICT, gcc is just being stupid in all those cases.
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:53:42 +0000 (10:53 +0200)]
shared/dissect-image: silence gcc warning
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:22:50 +0000 (10:22 +0200)]
sd-netlink: drop unnecessary forward declaration
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:19:07 +0000 (10:19 +0200)]
backlight: refactor get_max_brightness() to appease gcc
The old code was just fine, but gcc doesn't understand that max_brightness is
initialized. Let's rework it a bit to move some logic to the main function. Now
get_max_brightness() just retrieves and parses the attribute, and the main
function decides what to do with it.
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:11:30 +0000 (10:11 +0200)]
test-device-util: let's verify that we return proper error from log_device_*
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:09:11 +0000 (10:09 +0200)]
sd-device: header needs an include because it uses sd_device type
Luca Boccassi [Thu, 1 Apr 2021 09:07:46 +0000 (10:07 +0100)]
Merge pull request #19168 from keszybz/nss-resolve-unfoobar
Fix nss-resolve reverse alias lookups
Luca Boccassi [Thu, 1 Apr 2021 08:36:46 +0000 (09:36 +0100)]
Merge pull request #19169 from keszybz/reenable-maybe-unitialized-warning
Fix a bunch of maybe-unitialized warnings but don't enable the warning yet
Deepak Rawat [Wed, 31 Mar 2021 16:44:07 +0000 (09:44 -0700)]
logind: Rename kexec reboot flag
Also change error message to be more meanigful. No change in
functionality.
Fixes:
0d96caa5c0
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 16:13:00 +0000 (18:13 +0200)]
basic/env-util: silence two gcc warnings
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 16:07:57 +0000 (18:07 +0200)]
cryptsetup: silence gcc maybe-unused warning
Simplify one debug stmt while at it.
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 16:07:25 +0000 (18:07 +0200)]
systemctl: silence gcc maybe-unused warning
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 15:46:04 +0000 (17:46 +0200)]
shared/pretty-print: silence gcc warning
gcc was very unhappy for some reason:
[988/1664] Compiling C object systemd-oomd.p/src_oom_oomd.c.o
In file included from ../src/basic/path-util.h:10,
from ../src/shared/pretty-print.c:14,
from ../src/oom/oomd.c:15:
../src/shared/pretty-print.c: In function ‘conf_files_cat’:
../src/basic/strv.h:123:32: warning: ‘prefixes’ may be used uninitialized [-Wmaybe-uninitialized]
123 | for ((s) = (l); (s) && *(s); (s)++)
| ^
In file included from ../src/oom/oomd.c:15:
../src/shared/pretty-print.c:283:16: note: ‘prefixes’ was declared here
283 | char **prefixes, **prefix;
| ^~~~~~~~
../src/shared/pretty-print.c:305:12: warning: ‘is_collection’ may be used uninitialized in this function [-Wmaybe-uninitialized]
305 | if (!is_collection) {
| ^
../src/shared/pretty-print.c:301:13: warning: ‘extension’ may be used uninitialized in this function [-Wmaybe-uninitialized]
301 | r = conf_files_list_strv(&files, extension, root, 0, (const char* const*) dirs);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Maybe this is caused by the statis char** variables?
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 15:37:25 +0000 (17:37 +0200)]
core: silence gcc warning
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 15:32:04 +0000 (17:32 +0200)]
shared/bus-message-util: silence gcc warning
[1/429] Compiling C object src/shared/libsystemd-shared-248.a.p/bus-message-util.c.o
../src/shared/bus-message-util.c: In function ‘bus_message_read_dns_servers’:
../src/shared/bus-message-util.c:165:21: warning: ‘family’ may be used uninitialized in this function [-Wmaybe-uninitialized]
165 | r = in_addr_full_new(family, &a, port, 0, server_name, dns + n);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/shared/bus-message-util.c:165:21: warning: ‘port’ may be used uninitialized in this function [-Wmaybe-uninitialized]
../src/shared/bus-message-util.c:165:21: warning: ‘server_name’ may be used uninitialized in this function [-Wmaybe-uninitialized]
The warning would be there despite all the asserts in bus_error_setfv() and
sd_bus_error_set(). So let's add an explicit assert.
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 15:24:26 +0000 (17:24 +0200)]
shared/conf-parser: fix unitialized variable
Introduced in
4f9ff96a55187927a4164a19df580329f4c6522b.
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 15:13:24 +0000 (17:13 +0200)]
test-capability: silence gcc warning
[2/3] Compiling C object test-capability.p/src_test_test-capability.c.o
../src/test/test-capability.c: In function ‘main’:
../src/test/test-capability.c:270:12: warning: ‘run_ambient’ may be used uninitialized in this function [-Wmaybe-uninitialized]
270 | if (run_ambient)
| ^
gcc-11.0.1-0.3.fc34.x86_64
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 12:21:21 +0000 (14:21 +0200)]
basic/cgroup-util: silence gcc warning about unitialized variable
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 12:06:39 +0000 (14:06 +0200)]
sd-event: silence gcc's maybe-unitialized warning
[91/180] Compiling C object libsystemd.a.p/src_libsystemd_sd-event_sd-event.c.o
In file included from ../src/basic/macro.h:12,
from ../src/basic/alloc-util.h:9,
from ../src/libsystemd/sd-event/sd-event.c:11:
../src/libsystemd/sd-event/sd-event.c: In function ‘sd_event_wait’:
../src/fundamental/macro-fundamental.h:86:63: warning: ‘child_min_priority’ may be used uninitialized in this function [-Wmaybe-uninitialized]
86 | UNIQ_T(A, aq) < UNIQ_T(B, bq) ? UNIQ_T(A, aq) : UNIQ_T(B, bq); \
| ^
../src/libsystemd/sd-event/sd-event.c:3983:45: note: ‘child_min_priority’ was declared here
3983 | int64_t epoll_min_priority, child_min_priority;
| ^~~~~~~~~~~~~~~~~~
Alternative to #19159.
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 10:43:00 +0000 (12:43 +0200)]
varlink: use two local flag variables to silence gcc warning
[59/655] Compiling C object src/shared/libsystemd-shared-248.a.p/varlink.c.o
../src/shared/varlink.c: In function ‘varlink_write’:
../src/shared/varlink.c:459:12: warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
459 | if (n < 0) {
| ^
../src/shared/varlink.c: In function ‘varlink_process’:
../src/shared/varlink.c:541:12: warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
541 | if (n < 0) {
| ^
../src/shared/varlink.c:486:17: note: ‘n’ was declared here
486 | ssize_t n;
| ^
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 09:46:31 +0000 (11:46 +0200)]
man: split the description of sd_bus_error_set()
It was one giant all of text in pseudo-random order. Let's split it into
paragraphs talk about one subject each.
And unfortunately, the description of what happens when the error is not
set was not correct. In general, various functions treat 0/NULL as
not-an-error, and return 0.
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 09:45:15 +0000 (11:45 +0200)]
sd-bus: add asserts showing that sd_bus_error_setf() returns negative
(when name is specified).
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 09:27:15 +0000 (11:27 +0200)]
sd-bus: add assert to tell the compiler that the error code is positive
I was hoping it would help with the following gcc warning:
[35/657] Compiling C object src/shared/libsystemd-shared-248.a.p/bus-message-util.c.o
../src/shared/bus-message-util.c: In function ‘bus_message_read_dns_servers’:
../src/shared/bus-message-util.c:165:21: warning: ‘family’ may be used uninitialized in this function [-Wmaybe-uninitialized]
165 | r = in_addr_full_new(family, &a, port, 0, server_name, dns + n);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/shared/bus-message-util.c:165:21: warning: ‘port’ may be used uninitialized in this function [-Wmaybe-uninitialized]
../src/shared/bus-message-util.c:165:21: warning: ‘server_name’ may be used uninitialized in this function [-Wmaybe-uninitialized]
It actually doesn't, but the compiler has a point here: the code is specified
in sd_bus_error_map[], and it has no way of knowning that we want it to be a
positive value.
I think this should be an assert, because if this assumption fails, a
programming error has occured, something that'd want to catch.
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 09:09:39 +0000 (11:09 +0200)]
basic/fileio: silence gcc's maybe-unitialized warning
[11/657] Compiling C object src/basic/libbasic.a.p/fileio.c.o
../src/basic/fileio.c: In function ‘write_string_stream_ts’:
../src/basic/fileio.c:167:21: warning: ‘fd’ may be used uninitialized in this function [-Wmaybe-uninitialized]
167 | if (futimens(fd, twice) < 0)
| ^~~~~~~~~~~~~~~~~~~
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 09:06:41 +0000 (11:06 +0200)]
basic/socket-util: add hint to silence gcc's maybe-unitialized warning
[59/1551] Compiling C object src/basic/libbasic.a.p/socket-util.c.o
../src/basic/socket-util.c: In function ‘socket_get_mtu’:
../src/basic/socket-util.c:1393:16: warning: ‘mtu’ may be used uninitialized in this function [-Wmaybe-uninitialized]
1393 | *ret = (size_t) mtu;
| ^~~~~~~~~~~~
Zbigniew Jędrzejewski-Szmek [Mon, 29 Mar 2021 18:58:44 +0000 (20:58 +0200)]
resolved: drop unnecessary {}
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 14:48:04 +0000 (16:48 +0200)]
nss-resolve: define variables in the body
Same motivation as in the parent commit: let's define variables later, ideally
right when they are first initialized, so it's easier to figure out that they
are properly initialized.
error_id and r_tuple* were previously initialized, but I don't see why they
would need to be.
No functional change intended.