]> git.ipfire.org Git - thirdparty/systemd.git/commit
networkctl: open the bus just once
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 11 Jan 2022 14:12:42 +0000 (15:12 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 14 Jan 2022 07:24:04 +0000 (16:24 +0900)
commitd821e40ca96d2b14216f7a18e4512364bfb83628
tree5ec2c26ff1f3152afe6115ae21dbd00ad7eb27f4
parent048d46999995847095e3b7a513ba0627e0179dec
networkctl: open the bus just once

We'd connect to the bus twice: the first time to check networkd namespace,
and then the second time to do the deed we were asked to do. It's nicer
to open the bus just once, for efficience and also to avoid the open call
in all functions.

An ASSERT_PTR helper is added:
- sd_bus *bus = userdata;
  ...
- assert(bus);
+ sd_bus *bus = ASSERT_PTR(userdata);
  ...

It can be used in other place too, but I'm leaving that for a later
refactoring.
src/fundamental/macro-fundamental.h
src/network/networkctl.c