]> git.ipfire.org Git - thirdparty/systemd.git/commit
basic/fs-util: change CHASE_OPEN flag into a separate output parameter
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 24 Oct 2019 08:33:20 +0000 (10:33 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 24 Oct 2019 13:44:24 +0000 (22:44 +0900)
commita5648b809457d120500b2acb18b31e2168a4817a
tree59846b7791dce151e858a889f1281bad28c55ffe
parent58ce85f6a17b6db03265e6a974120b18d1c0855a
basic/fs-util: change CHASE_OPEN flag into a separate output parameter

chase_symlinks() would return negative on error, and either a non-negative status
or a non-negative fd when CHASE_OPEN was given. This made the interface quite
complicated, because dependning on the flags used, we would get two different
"types" of return object. Coverity was always confused by this, and flagged
every use of chase_symlinks() without CHASE_OPEN as a resource leak (because it
would this that an fd is returned). This patch uses a saparate output parameter,
so there is no confusion.

(I think it is OK to have functions which return either an error or an fd. It's
only returning *either* an fd or a non-fd that is confusing.)
33 files changed:
src/basic/fs-util.c
src/basic/fs-util.h
src/basic/mkdir.c
src/basic/mountpoint-util.c
src/basic/path-util.c
src/basic/stat-util.c
src/core/dbus-manager.c
src/core/namespace.c
src/core/service.c
src/core/socket.c
src/core/unit.c
src/delta/delta.c
src/fstab-generator/fstab-generator.c
src/journal/journalctl.c
src/libsystemd/sd-device/sd-device.c
src/machine/machine-dbus.c
src/mount/mount-tool.c
src/nspawn/nspawn-mount.c
src/nspawn/nspawn.c
src/portable/portablectl.c
src/shared/dissect-image.c
src/shared/dropin.c
src/shared/machine-image.c
src/shared/os-util.c
src/shared/switch-root.c
src/shared/unit-file.c
src/systemctl/systemctl.c
src/test/test-chase-symlinks.c
src/test/test-copy.c
src/test/test-fs-util.c
src/tmpfiles/tmpfiles.c
src/udev/udev-builtin-net_id.c
src/volatile-root/volatile-root.c