netlink,network: drop "const" from opaque object parameters in supposed-to-be-public...
authorLennart Poettering <lennart@poettering.net>
Tue, 11 May 2021 15:08:00 +0000 (17:08 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 12 May 2021 07:19:58 +0000 (16:19 +0900)
commit041ea9f9bb2f20e6e3479cdd94f4c6d4109b6f0e
treefcdc4507a5c9d9ee1bd37b2daf0dc2bc5a330ae7
parent5c2e5957678462d871c5c2ea5261becec5f8f80f
netlink,network: drop "const" from opaque object parameters in supposed-to-be-public APIs

This drops the "const" specifier from the opaque object parameters to
various functions in our API.

This effectively reverts #19292 and more.

Why drop this? Our public APIs should not leak too much information
about how stuff is implemented internally. In our public APIs we
shouldn't give too many guarantees we don#t want to necessarily keep.
Specifically: in many cases it makes sense that getters actually
generate/parse/allocate data on the fly, storing/caching the result
internally, to speed things up, do things lazily or to track memory
allocations so that they can be freed later. Doing this means we need to
change the objects, even though the getters are semantically a read
operation.

We want to retain the freedom that we can change things around
internally. By exposing the objects as "const" we remove a good chunk of
that, for little gain.

See sd_bus_creds_get_description() for a real example of a getter that
implicitly caches and thus modifies the relevant object.

This removes the "const" decorators from sd-dhcp and sd-netlink, two
APIs that we intend to make public eventually even though they still are
not, leaving us the chance to still fix this before it becomes set in
stone.
src/libsystemd-network/network-internal.h
src/libsystemd-network/sd-dhcp-client.c
src/libsystemd-network/sd-dhcp-lease.c
src/libsystemd/sd-netlink/generic-netlink.c
src/libsystemd/sd-netlink/netlink-message.c
src/libsystemd/sd-netlink/netlink-slot.c
src/libsystemd/sd-netlink/rtnl-message.c
src/libsystemd/sd-netlink/sd-netlink.c
src/systemd/sd-dhcp-client.h
src/systemd/sd-dhcp-lease.h
src/systemd/sd-netlink.h