From 32a847a61f031813865199366318d047ca38c2f1 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 31 Jan 2019 12:49:28 +0100 Subject: [PATCH 01/13] systemd/trivial: adjust naming of include guard define --- shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h b/shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h index fd5adeb09e..a4f9ecd2e6 100644 --- a/shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h +++ b/shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h @@ -16,8 +16,8 @@ * Copyright (C) 2014 - 2018 Red Hat, Inc. */ -#ifndef __NM_SD_ADAPT_BASIC_H__ -#define __NM_SD_ADAPT_BASIC_H__ +#ifndef __NM_SD_ADAPT_SHARED_H__ +#define __NM_SD_ADAPT_SHARED_H__ #include "nm-default.h" @@ -130,4 +130,4 @@ static inline pid_t gettid(void) { /*****************************************************************************/ -#endif /* __NM_SD_ADAPT_BASIC_H__ */ +#endif /* __NM_SD_ADAPT_SHARED_H__ */ From a3370af3a8a965e41950c5022182730d79614df2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 31 Jan 2019 13:44:13 +0100 Subject: [PATCH 02/13] all: drop unnecessary includes of and "nm-macros-interal.h" already includes and . No need to include it everywhere else too. --- clients/cli/agent.c | 1 - clients/cli/common.c | 1 - clients/cli/connections.c | 2 -- clients/cli/devices.c | 2 -- clients/cli/general.c | 1 - clients/cli/nmcli.c | 1 - clients/cli/polkit-agent.c | 1 - clients/cli/utils.c | 2 -- clients/common/nm-polkit-listener.c | 1 - clients/common/nm-secret-agent-simple.c | 1 - clients/common/nm-vpn-helpers.c | 2 -- clients/tui/newt/nmt-newt-button-box.c | 3 +-- clients/tui/newt/nmt-newt-container.c | 3 +-- clients/tui/newt/nmt-newt-entry.c | 2 -- clients/tui/newt/nmt-newt-form.c | 1 - clients/tui/newt/nmt-newt-grid.c | 2 -- clients/tui/newt/nmt-newt-label.c | 3 +-- clients/tui/newt/nmt-newt-section.c | 3 +-- clients/tui/newt/nmt-newt-stack.c | 2 -- clients/tui/newt/nmt-newt-textbox.c | 3 +-- clients/tui/newt/nmt-newt-utils.c | 1 - clients/tui/nm-editor-bindings.c | 5 ++--- clients/tui/nmt-address-list.c | 4 ++-- clients/tui/nmt-device-entry.c | 4 ++-- clients/tui/nmt-editor-grid.c | 2 -- clients/tui/nmt-mac-entry.c | 2 -- clients/tui/nmt-utils.c | 2 -- clients/tui/nmt-widget-list.c | 4 ++-- clients/tui/nmtui.c | 4 ++-- dispatcher/nm-dispatcher-utils.c | 4 +--- dispatcher/nm-dispatcher.c | 2 -- dispatcher/tests/test-dispatcher-envp.c | 1 - libnm-core/nm-connection.c | 1 - libnm-core/nm-crypto.c | 1 - libnm-core/nm-dbus-utils.c | 2 -- libnm-core/nm-errors.c | 3 +-- libnm-core/nm-keyfile-utils.c | 6 +++--- libnm-core/nm-keyfile.c | 2 -- libnm-core/nm-property-compare.c | 5 ++--- libnm-core/nm-setting-8021x.c | 2 -- libnm-core/nm-setting-adsl.c | 2 -- libnm-core/nm-setting-bluetooth.c | 1 - libnm-core/nm-setting-bond.c | 2 -- libnm-core/nm-setting-bridge-port.c | 1 - libnm-core/nm-setting-bridge.c | 1 - libnm-core/nm-setting-cdma.c | 2 -- libnm-core/nm-setting-connection.c | 2 -- libnm-core/nm-setting-dcb.c | 2 -- libnm-core/nm-setting-gsm.c | 2 -- libnm-core/nm-setting-ip-config.c | 1 - libnm-core/nm-setting-ip4-config.c | 2 -- libnm-core/nm-setting-ip6-config.c | 1 - libnm-core/nm-setting-macsec.c | 1 - libnm-core/nm-setting-macvlan.c | 1 - libnm-core/nm-setting-olpc-mesh.c | 2 -- libnm-core/nm-setting-pppoe.c | 2 -- libnm-core/nm-setting-serial.c | 2 -- libnm-core/nm-setting-team-port.c | 1 - libnm-core/nm-setting-team.c | 1 - libnm-core/nm-setting-tun.c | 1 - libnm-core/nm-setting-vlan.c | 1 - libnm-core/nm-setting-vpn.c | 2 -- libnm-core/nm-setting-vxlan.c | 1 - libnm-core/nm-setting-wifi-p2p.c | 1 - libnm-core/nm-setting-wimax.c | 1 - libnm-core/nm-setting-wired.c | 1 - libnm-core/nm-setting-wireless-security.c | 2 -- libnm-core/nm-setting-wireless.c | 1 - libnm-core/nm-setting.c | 2 -- libnm-core/nm-utils.c | 2 -- libnm-core/nm-vpn-plugin-info.c | 2 -- libnm-core/tests/test-crypto.c | 1 - libnm-core/tests/test-general.c | 2 -- libnm-core/tests/test-secrets.c | 2 -- libnm-core/tests/test-setting.c | 1 - libnm-core/tests/test-settings-defaults.c | 2 -- libnm-glib/nm-vpn-plugin-utils.c | 1 - libnm-util/nm-setting-bond.c | 1 - libnm-util/nm-setting-vpn.c | 1 - libnm/nm-access-point.c | 2 -- libnm/nm-active-connection.c | 3 +-- libnm/nm-client.c | 4 ++-- libnm/nm-dbus-helpers.c | 2 -- libnm/nm-device-adsl.c | 3 --- libnm/nm-device-bond.c | 4 +--- libnm/nm-device-bridge.c | 4 +--- libnm/nm-device-bt.c | 4 +--- libnm/nm-device-dummy.c | 3 +-- libnm/nm-device-ethernet.c | 4 +--- libnm/nm-device-generic.c | 3 +-- libnm/nm-device-infiniband.c | 4 +--- libnm/nm-device-ip-tunnel.c | 4 +--- libnm/nm-device-macsec.c | 3 +-- libnm/nm-device-macvlan.c | 4 +--- libnm/nm-device-modem.c | 4 +--- libnm/nm-device-olpc-mesh.c | 4 +--- libnm/nm-device-ovs-bridge.c | 3 +-- libnm/nm-device-ovs-interface.c | 3 +-- libnm/nm-device-ovs-port.c | 3 +-- libnm/nm-device-team.c | 4 +--- libnm/nm-device-tun.c | 5 ++--- libnm/nm-device-vlan.c | 4 +--- libnm/nm-device-vxlan.c | 4 +--- libnm/nm-device-wifi-p2p.c | 3 --- libnm/nm-device-wifi.c | 3 --- libnm/nm-device-wimax.c | 4 +--- libnm/nm-device-wpan.c | 3 +-- libnm/nm-device.c | 1 - libnm/nm-dhcp-config.c | 3 +-- libnm/nm-dhcp4-config.c | 1 + libnm/nm-dhcp6-config.c | 1 + libnm/nm-dns-manager.c | 3 --- libnm/nm-ip-config.c | 3 +-- libnm/nm-ip4-config.c | 1 + libnm/nm-ip6-config.c | 1 + libnm/nm-manager.c | 2 -- libnm/nm-object.c | 1 - libnm/nm-remote-connection.c | 4 +--- libnm/nm-remote-settings.c | 3 --- libnm/nm-secret-agent-old.c | 2 -- libnm/nm-vpn-connection.c | 3 +-- libnm/nm-vpn-plugin-old.c | 1 - libnm/nm-vpn-service-plugin.c | 1 - libnm/nm-wifi-p2p-peer.c | 3 --- libnm/nm-wimax-nsp.c | 4 +--- libnm/tests/test-nm-client.c | 1 - libnm/tests/test-remote-settings-client.c | 1 - libnm/tests/test-secret-agent.c | 1 - shared/nm-test-utils-impl.c | 1 - shared/nm-utils/nm-shared-utils.c | 1 - src/devices/adsl/nm-atm-manager.c | 1 - src/devices/adsl/nm-device-adsl.c | 2 -- src/devices/bluetooth/nm-bluez-device.c | 2 -- src/devices/bluetooth/nm-bluez-manager.c | 1 - src/devices/bluetooth/nm-bluez4-adapter.c | 2 -- src/devices/bluetooth/nm-bluez4-manager.c | 1 - src/devices/bluetooth/nm-bluez5-dun.c | 1 - src/devices/bluetooth/nm-bluez5-manager.c | 1 - src/devices/bluetooth/nm-device-bt.c | 1 - src/devices/nm-device-bond.c | 1 - src/devices/nm-device-dummy.c | 1 - src/devices/nm-device-ethernet.c | 2 -- src/devices/nm-device-factory.c | 2 -- src/devices/nm-device-ip-tunnel.c | 1 - src/devices/nm-device-macvlan.c | 1 - src/devices/nm-device-tun.c | 1 - src/devices/nm-device-veth.c | 2 -- src/devices/nm-device-vxlan.c | 2 -- src/devices/nm-device-wpan.c | 1 - src/devices/nm-device.c | 2 -- src/devices/nm-lldp-listener.c | 1 - src/devices/ovs/nm-ovsdb.c | 1 - src/devices/team/nm-team-factory.c | 1 - src/devices/wifi/nm-device-iwd.c | 2 -- src/devices/wifi/nm-device-olpc-mesh.c | 2 -- src/devices/wifi/nm-device-wifi.c | 2 -- src/devices/wifi/nm-iwd-manager.c | 1 - src/devices/wifi/nm-wifi-ap.c | 1 - src/devices/wifi/nm-wifi-p2p-peer.c | 1 - src/devices/wifi/nm-wifi-utils.c | 1 - src/devices/wifi/tests/test-general.c | 3 --- src/devices/wwan/nm-device-modem.c | 2 -- src/devices/wwan/nm-modem-broadband.c | 1 - src/devices/wwan/nm-modem-manager.c | 1 - src/devices/wwan/nm-modem-ofono.c | 2 -- src/devices/wwan/nm-modem.c | 1 - src/devices/wwan/nm-wwan-factory.c | 1 - src/dhcp/nm-dhcp-client.c | 2 -- src/dhcp/nm-dhcp-dhclient-utils.c | 1 - src/dhcp/nm-dhcp-dhclient.c | 2 -- src/dhcp/nm-dhcp-dhcpcanon.c | 2 -- src/dhcp/nm-dhcp-dhcpcd.c | 2 -- src/dhcp/nm-dhcp-helper.c | 1 - src/dhcp/nm-dhcp-listener.c | 2 -- src/dhcp/nm-dhcp-manager.c | 2 -- src/dhcp/nm-dhcp-systemd.c | 2 -- src/dhcp/nm-dhcp-utils.c | 2 -- src/dhcp/tests/test-dhcp-dhclient.c | 1 - src/dhcp/tests/test-dhcp-utils.c | 1 - src/dns/nm-dns-manager.c | 1 - src/dns/nm-dns-plugin.c | 1 - src/dnsmasq/nm-dnsmasq-manager.c | 1 - src/dnsmasq/nm-dnsmasq-utils.c | 1 - src/initrd/nmi-cmdline-reader.c | 4 +--- src/initrd/nmi-ibft-reader.c | 2 -- src/initrd/tests/test-cmdline-reader.c | 1 - src/initrd/tests/test-ibft-reader.c | 1 - src/main-utils.c | 1 - src/main.c | 2 -- src/ndisc/nm-fake-ndisc.c | 1 - src/ndisc/nm-lndp-ndisc.c | 1 - src/ndisc/nm-ndisc.c | 1 - src/ndisc/tests/test-ndisc-fake.c | 1 - src/ndisc/tests/test-ndisc-linux.c | 1 - src/nm-act-request.c | 1 - src/nm-audit-manager.c | 2 -- src/nm-auth-subject.c | 1 - src/nm-auth-utils.c | 3 --- src/nm-checkpoint.c | 2 -- src/nm-config-data.c | 2 -- src/nm-config.c | 1 - src/nm-connectivity.c | 2 -- src/nm-core-utils.c | 2 -- src/nm-dbus-manager.c | 2 -- src/nm-dcb.c | 1 - src/nm-dhcp4-config.c | 2 -- src/nm-dhcp6-config.c | 2 -- src/nm-dispatcher.c | 3 --- src/nm-firewall-manager.c | 2 -- src/nm-hostname-manager.c | 2 -- src/nm-iface-helper.c | 2 -- src/nm-ip4-config.c | 1 - src/nm-ip6-config.c | 1 - src/nm-keep-alive.c | 2 -- src/nm-logging.c | 2 -- src/nm-manager.c | 2 -- src/nm-policy.c | 2 -- src/nm-rfkill-manager.c | 1 - src/nm-session-monitor.c | 2 -- src/nm-sleep-monitor.c | 2 -- src/platform/nm-fake-platform.c | 1 - src/platform/nm-linux-platform.c | 1 - src/platform/nm-platform-utils.c | 2 -- src/platform/nm-platform.c | 2 -- src/platform/nmp-netns.c | 1 - src/platform/tests/test-common.h | 1 - src/platform/wifi/nm-wifi-utils-nl80211.c | 2 -- src/platform/wifi/nm-wifi-utils-wext.c | 2 -- src/platform/wifi/nm-wifi-utils.c | 1 - src/ppp/nm-ppp-manager-call.c | 1 - src/ppp/nm-ppp-manager.c | 2 -- src/ppp/nm-pppd-plugin.c | 1 - src/settings/nm-agent-manager.c | 1 - src/settings/nm-settings-connection.c | 2 -- src/settings/nm-settings.c | 2 -- src/settings/plugins/ibft/nms-ibft-connection.c | 1 - src/settings/plugins/ibft/nms-ibft-plugin.c | 2 -- src/settings/plugins/ibft/nms-ibft-reader.c | 2 -- src/settings/plugins/ibft/tests/test-ibft.c | 1 - src/settings/plugins/ifcfg-rh/nm-inotify-helper.c | 2 -- src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c | 1 - src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c | 2 -- src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c | 2 -- src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c | 1 - src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c | 2 -- src/settings/plugins/ifcfg-rh/shvar.c | 2 -- src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 1 - src/settings/plugins/ifupdown/nms-ifupdown-connection.c | 1 - .../plugins/ifupdown/nms-ifupdown-interface-parser.c | 1 - src/settings/plugins/ifupdown/nms-ifupdown-parser.c | 2 -- src/settings/plugins/ifupdown/nms-ifupdown-plugin.c | 1 - src/settings/plugins/ifupdown/tests/test-ifupdown.c | 2 -- src/settings/plugins/keyfile/nms-keyfile-connection.c | 1 - src/settings/plugins/keyfile/nms-keyfile-plugin.c | 2 -- src/settings/plugins/keyfile/nms-keyfile-reader.c | 1 - src/settings/plugins/keyfile/nms-keyfile-utils.c | 1 - src/settings/plugins/keyfile/nms-keyfile-writer.c | 2 -- src/settings/plugins/keyfile/tests/test-keyfile.c | 1 - src/supplicant/nm-supplicant-config.c | 1 - src/supplicant/nm-supplicant-interface.c | 1 - src/supplicant/nm-supplicant-manager.c | 2 -- src/supplicant/nm-supplicant-settings-verify.c | 2 -- src/supplicant/tests/test-supplicant-config.c | 1 - src/systemd/src/libsystemd-network/dhcp-network.c | 1 - src/systemd/src/libsystemd-network/dhcp-option.c | 1 - src/systemd/src/libsystemd-network/dhcp-packet.c | 1 - src/systemd/src/libsystemd-network/dhcp6-network.c | 1 - src/systemd/src/libsystemd-network/dhcp6-option.c | 1 - src/systemd/src/libsystemd-network/sd-dhcp-client.c | 1 - src/systemd/src/libsystemd-network/sd-dhcp-lease.c | 1 - src/systemd/src/libsystemd-network/sd-dhcp6-client.c | 1 - src/systemd/src/libsystemd-network/sd-dhcp6-lease.c | 1 - src/systemd/src/libsystemd-network/sd-ipv4acd.c | 1 - src/systemd/src/libsystemd-network/sd-ipv4ll.c | 1 - src/systemd/src/libsystemd/sd-event/event-util.c | 1 - src/systemd/src/libsystemd/sd-id128/id128-util.c | 1 - src/systemd/src/libsystemd/sd-id128/sd-id128.c | 1 - src/systemd/src/shared/dns-domain.h | 1 - src/tests/config/nm-test-device.c | 2 -- src/tests/test-dcb.c | 2 -- src/tests/test-general-with-expect.c | 2 -- src/tests/test-general.c | 2 -- src/tests/test-ip4-config.c | 1 - src/tests/test-ip6-config.c | 1 - src/tests/test-utils.c | 2 -- src/vpn/nm-vpn-connection.c | 2 -- src/vpn/nm-vpn-manager.c | 2 -- 287 files changed, 57 insertions(+), 468 deletions(-) diff --git a/clients/cli/agent.c b/clients/cli/agent.c index 55a5ba6b85..a18eecc52d 100644 --- a/clients/cli/agent.c +++ b/clients/cli/agent.c @@ -25,7 +25,6 @@ #include #include -#include #include #include diff --git a/clients/cli/common.c b/clients/cli/common.c index 56e5062f52..b3342c1935 100644 --- a/clients/cli/common.c +++ b/clients/cli/common.c @@ -25,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 0e6201dd9e..ff7d020303 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -22,10 +22,8 @@ #include "connections.h" #include -#include #include #include -#include #include #include #include diff --git a/clients/cli/devices.c b/clients/cli/devices.c index c9906d3b0c..04a8c98891 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -22,9 +22,7 @@ #include "devices.h" #include -#include #include -#include #include #include "nm-secret-agent-simple.h" diff --git a/clients/cli/general.c b/clients/cli/general.c index d9128c7670..d0cfc844aa 100644 --- a/clients/cli/general.c +++ b/clients/cli/general.c @@ -21,7 +21,6 @@ #include "general.h" -#include #include #include "nm-common-macros.h" diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index c8253fff9a..d7bc2a4629 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -24,7 +24,6 @@ #include "nmcli.h" #include -#include #include #include #include diff --git a/clients/cli/polkit-agent.c b/clients/cli/polkit-agent.c index b895599be4..accb567fe3 100644 --- a/clients/cli/polkit-agent.c +++ b/clients/cli/polkit-agent.c @@ -22,7 +22,6 @@ #include "polkit-agent.h" #include -#include #include #include diff --git a/clients/cli/utils.c b/clients/cli/utils.c index 1b940467ce..f23e079c96 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -23,9 +23,7 @@ #include "utils.h" #include -#include #include -#include #include #include #include diff --git a/clients/common/nm-polkit-listener.c b/clients/common/nm-polkit-listener.c index dccf1d38bb..7367459d7d 100644 --- a/clients/common/nm-polkit-listener.c +++ b/clients/common/nm-polkit-listener.c @@ -35,7 +35,6 @@ #include "nm-polkit-listener.h" -#include #include #include diff --git a/clients/common/nm-secret-agent-simple.c b/clients/common/nm-secret-agent-simple.c index 43b1155487..1393793e4c 100644 --- a/clients/common/nm-secret-agent-simple.c +++ b/clients/common/nm-secret-agent-simple.c @@ -35,7 +35,6 @@ #include #include -#include #include "nm-vpn-service-plugin.h" #include "nm-vpn-helpers.h" diff --git a/clients/common/nm-vpn-helpers.c b/clients/common/nm-vpn-helpers.c index a840d97f97..a2e7dc0374 100644 --- a/clients/common/nm-vpn-helpers.c +++ b/clients/common/nm-vpn-helpers.c @@ -25,8 +25,6 @@ #include "nm-vpn-helpers.h" -#include - #include "nm-utils.h" /*****************************************************************************/ diff --git a/clients/tui/newt/nmt-newt-button-box.c b/clients/tui/newt/nmt-newt-button-box.c index 5341c76a54..02d8f5cbb2 100644 --- a/clients/tui/newt/nmt-newt-button-box.c +++ b/clients/tui/newt/nmt-newt-button-box.c @@ -31,9 +31,8 @@ #include "nm-default.h" -#include - #include "nmt-newt-button-box.h" + #include "nmt-newt-button.h" G_DEFINE_TYPE (NmtNewtButtonBox, nmt_newt_button_box, NMT_TYPE_NEWT_CONTAINER) diff --git a/clients/tui/newt/nmt-newt-container.c b/clients/tui/newt/nmt-newt-container.c index 927f187e86..402590258a 100644 --- a/clients/tui/newt/nmt-newt-container.c +++ b/clients/tui/newt/nmt-newt-container.c @@ -28,9 +28,8 @@ #include "nm-default.h" -#include - #include "nmt-newt-container.h" + #include "nmt-newt-component.h" G_DEFINE_ABSTRACT_TYPE (NmtNewtContainer, nmt_newt_container, NMT_TYPE_NEWT_WIDGET) diff --git a/clients/tui/newt/nmt-newt-entry.c b/clients/tui/newt/nmt-newt-entry.c index 2715a7389f..90c2e467b5 100644 --- a/clients/tui/newt/nmt-newt-entry.c +++ b/clients/tui/newt/nmt-newt-entry.c @@ -28,8 +28,6 @@ #include "nm-default.h" -#include - #include "nmt-newt-entry.h" #include "nmt-newt-form.h" #include "nmt-newt-hacks.h" diff --git a/clients/tui/newt/nmt-newt-form.c b/clients/tui/newt/nmt-newt-form.c index ccf447eada..cd87a2160a 100644 --- a/clients/tui/newt/nmt-newt-form.c +++ b/clients/tui/newt/nmt-newt-form.c @@ -27,7 +27,6 @@ #include "nm-default.h" #include -#include #include #include "nmt-newt-form.h" diff --git a/clients/tui/newt/nmt-newt-grid.c b/clients/tui/newt/nmt-newt-grid.c index 4333e0dc6f..e6c487f5f7 100644 --- a/clients/tui/newt/nmt-newt-grid.c +++ b/clients/tui/newt/nmt-newt-grid.c @@ -42,8 +42,6 @@ #include "nm-default.h" -#include - #include "nmt-newt-grid.h" G_DEFINE_TYPE (NmtNewtGrid, nmt_newt_grid, NMT_TYPE_NEWT_CONTAINER) diff --git a/clients/tui/newt/nmt-newt-label.c b/clients/tui/newt/nmt-newt-label.c index f9aed8a3dd..63bd28da9d 100644 --- a/clients/tui/newt/nmt-newt-label.c +++ b/clients/tui/newt/nmt-newt-label.c @@ -27,9 +27,8 @@ #include "nm-default.h" -#include - #include "nmt-newt-label.h" + #include "nmt-newt-utils.h" G_DEFINE_TYPE (NmtNewtLabel, nmt_newt_label, NMT_TYPE_NEWT_COMPONENT) diff --git a/clients/tui/newt/nmt-newt-section.c b/clients/tui/newt/nmt-newt-section.c index 34073454ce..9b7e44e4b5 100644 --- a/clients/tui/newt/nmt-newt-section.c +++ b/clients/tui/newt/nmt-newt-section.c @@ -37,9 +37,8 @@ #include "nm-default.h" -#include - #include "nmt-newt-section.h" + #include "nmt-newt-grid.h" #include "nmt-newt-label.h" #include "nmt-newt-utils.h" diff --git a/clients/tui/newt/nmt-newt-stack.c b/clients/tui/newt/nmt-newt-stack.c index 3abf00b199..da4beb8b70 100644 --- a/clients/tui/newt/nmt-newt-stack.c +++ b/clients/tui/newt/nmt-newt-stack.c @@ -31,8 +31,6 @@ #include "nm-default.h" -#include - #include "nmt-newt-stack.h" G_DEFINE_TYPE (NmtNewtStack, nmt_newt_stack, NMT_TYPE_NEWT_CONTAINER) diff --git a/clients/tui/newt/nmt-newt-textbox.c b/clients/tui/newt/nmt-newt-textbox.c index 73794f5eb3..0850e60c50 100644 --- a/clients/tui/newt/nmt-newt-textbox.c +++ b/clients/tui/newt/nmt-newt-textbox.c @@ -26,9 +26,8 @@ #include "nm-default.h" -#include - #include "nmt-newt-textbox.h" + #include "nmt-newt-utils.h" G_DEFINE_TYPE (NmtNewtTextbox, nmt_newt_textbox, NMT_TYPE_NEWT_COMPONENT) diff --git a/clients/tui/newt/nmt-newt-utils.c b/clients/tui/newt/nmt-newt-utils.c index e886650036..475faf7ee8 100644 --- a/clients/tui/newt/nmt-newt-utils.c +++ b/clients/tui/newt/nmt-newt-utils.c @@ -23,7 +23,6 @@ #include "nm-default.h" -#include #include #include #include diff --git a/clients/tui/nm-editor-bindings.c b/clients/tui/nm-editor-bindings.c index 16ea60d31d..df6387c329 100644 --- a/clients/tui/nm-editor-bindings.c +++ b/clients/tui/nm-editor-bindings.c @@ -27,12 +27,11 @@ #include "nm-default.h" +#include "nm-editor-bindings.h" + #include #include #include -#include - -#include "nm-editor-bindings.h" static void value_transform_string_int (const GValue *src_value, diff --git a/clients/tui/nmt-address-list.c b/clients/tui/nmt-address-list.c index 53990d6a53..ae1a6b2fcc 100644 --- a/clients/tui/nmt-address-list.c +++ b/clients/tui/nmt-address-list.c @@ -30,12 +30,12 @@ #include "nm-default.h" +#include "nmt-address-list.h" + #include #include #include -#include -#include "nmt-address-list.h" #include "nmt-ip-entry.h" G_DEFINE_TYPE (NmtAddressList, nmt_address_list, NMT_TYPE_WIDGET_LIST) diff --git a/clients/tui/nmt-device-entry.c b/clients/tui/nmt-device-entry.c index a4d63e4f34..43fbbc1649 100644 --- a/clients/tui/nmt-device-entry.c +++ b/clients/tui/nmt-device-entry.c @@ -36,12 +36,12 @@ #include "nm-default.h" -#include +#include "nmt-device-entry.h" + #include #include #include "nmtui.h" -#include "nmt-device-entry.h" G_DEFINE_TYPE (NmtDeviceEntry, nmt_device_entry, NMT_TYPE_EDITOR_GRID) diff --git a/clients/tui/nmt-editor-grid.c b/clients/tui/nmt-editor-grid.c index bc8a784336..bb3e78b851 100644 --- a/clients/tui/nmt-editor-grid.c +++ b/clients/tui/nmt-editor-grid.c @@ -39,8 +39,6 @@ #include "nm-default.h" -#include - #include "nmt-editor-grid.h" G_DEFINE_TYPE (NmtEditorGrid, nmt_editor_grid, NMT_TYPE_NEWT_CONTAINER) diff --git a/clients/tui/nmt-mac-entry.c b/clients/tui/nmt-mac-entry.c index 23c2ab1cbe..70c8c30796 100644 --- a/clients/tui/nmt-mac-entry.c +++ b/clients/tui/nmt-mac-entry.c @@ -30,8 +30,6 @@ #include "nmt-mac-entry.h" -#include - #include "nm-common-macros.h" G_DEFINE_TYPE (NmtMacEntry, nmt_mac_entry, NMT_TYPE_NEWT_ENTRY) diff --git a/clients/tui/nmt-utils.c b/clients/tui/nmt-utils.c index 7cd71be2b4..96b97158e1 100644 --- a/clients/tui/nmt-utils.c +++ b/clients/tui/nmt-utils.c @@ -23,8 +23,6 @@ #include "nm-default.h" -#include - #include "nmt-utils.h" /** diff --git a/clients/tui/nmt-widget-list.c b/clients/tui/nmt-widget-list.c index 2fd5af02c7..ad35f3de1f 100644 --- a/clients/tui/nmt-widget-list.c +++ b/clients/tui/nmt-widget-list.c @@ -32,12 +32,12 @@ #include "nm-default.h" +#include "nmt-widget-list.h" + #include #include #include -#include -#include "nmt-widget-list.h" #include "nmt-newt.h" G_DEFINE_TYPE (NmtWidgetList, nmt_widget_list, NMT_TYPE_NEWT_GRID) diff --git a/clients/tui/nmtui.c b/clients/tui/nmtui.c index 97c528e705..aacc07cb15 100644 --- a/clients/tui/nmtui.c +++ b/clients/tui/nmtui.c @@ -26,14 +26,14 @@ #include "nm-default.h" +#include "nmtui.h" + #include #include -#include #include "nmt-newt.h" #include "nm-editor-bindings.h" -#include "nmtui.h" #include "nmtui-edit.h" #include "nmtui-connect.h" #include "nmtui-hostname.h" diff --git a/dispatcher/nm-dispatcher-utils.c b/dispatcher/nm-dispatcher-utils.c index 4d04eeca97..dee00612d7 100644 --- a/dispatcher/nm-dispatcher-utils.c +++ b/dispatcher/nm-dispatcher-utils.c @@ -20,7 +20,7 @@ #include "nm-default.h" -#include +#include "nm-dispatcher-utils.h" #include "nm-dbus-interface.h" #include "nm-connection.h" @@ -31,8 +31,6 @@ #include "nm-dispatcher-api.h" #include "nm-utils.h" -#include "nm-dispatcher-utils.h" - /*****************************************************************************/ static gboolean diff --git a/dispatcher/nm-dispatcher.c b/dispatcher/nm-dispatcher.c index 9139ffe5c7..d395942a38 100644 --- a/dispatcher/nm-dispatcher.c +++ b/dispatcher/nm-dispatcher.c @@ -24,12 +24,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include diff --git a/dispatcher/tests/test-dispatcher-envp.c b/dispatcher/tests/test-dispatcher-envp.c index 78bcd233ef..89ddadbbaa 100644 --- a/dispatcher/tests/test-dispatcher-envp.c +++ b/dispatcher/tests/test-dispatcher-envp.c @@ -22,7 +22,6 @@ #include #include -#include #include "nm-dispatcher-utils.h" #include "nm-dispatcher-api.h" diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index 5bafe2d7c0..5e84cf45b6 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -24,7 +24,6 @@ #include "nm-connection.h" -#include #include #include "nm-connection-private.h" diff --git a/libnm-core/nm-crypto.c b/libnm-core/nm-crypto.c index 1af2ea2840..67f206c46d 100644 --- a/libnm-core/nm-crypto.c +++ b/libnm-core/nm-crypto.c @@ -25,7 +25,6 @@ #include "nm-crypto.h" -#include #include #include #include diff --git a/libnm-core/nm-dbus-utils.c b/libnm-core/nm-dbus-utils.c index 69f4bb2f8a..8c455971bc 100644 --- a/libnm-core/nm-dbus-utils.c +++ b/libnm-core/nm-dbus-utils.c @@ -20,8 +20,6 @@ #include "nm-default.h" -#include - #include "nm-core-internal.h" typedef struct { diff --git a/libnm-core/nm-errors.c b/libnm-core/nm-errors.c index 351bc1d096..beef95c7fb 100644 --- a/libnm-core/nm-errors.c +++ b/libnm-core/nm-errors.c @@ -20,9 +20,8 @@ #include "nm-default.h" -#include - #include "nm-errors.h" + #include "nm-vpn-dbus-interface.h" #include "nm-core-internal.h" diff --git a/libnm-core/nm-keyfile-utils.c b/libnm-core/nm-keyfile-utils.c index 9543ebde6e..e243150d02 100644 --- a/libnm-core/nm-keyfile-utils.c +++ b/libnm-core/nm-keyfile-utils.c @@ -20,10 +20,10 @@ #include "nm-default.h" -#include -#include - #include "nm-keyfile-utils.h" + +#include + #include "nm-keyfile-internal.h" #include "nm-setting-wired.h" #include "nm-setting-wireless.h" diff --git a/libnm-core/nm-keyfile.c b/libnm-core/nm-keyfile.c index e20681300b..b81020a3bc 100644 --- a/libnm-core/nm-keyfile.c +++ b/libnm-core/nm-keyfile.c @@ -23,14 +23,12 @@ #include "nm-keyfile-internal.h" -#include #include #include #include #include #include #include -#include #include #include "nm-utils/nm-secret-utils.h" diff --git a/libnm-core/nm-property-compare.c b/libnm-core/nm-property-compare.c index 2a3ee39732..d3a19ec748 100644 --- a/libnm-core/nm-property-compare.c +++ b/libnm-core/nm-property-compare.c @@ -22,11 +22,10 @@ #include "nm-default.h" -#include -#include - #include "nm-property-compare.h" +#include + static int _nm_property_compare_collection (GVariant *value1, GVariant *value2) { diff --git a/libnm-core/nm-setting-8021x.c b/libnm-core/nm-setting-8021x.c index 19741fdf9b..45fb711c5e 100644 --- a/libnm-core/nm-setting-8021x.c +++ b/libnm-core/nm-setting-8021x.c @@ -24,8 +24,6 @@ #include "nm-setting-8021x.h" -#include - #include "nm-utils/nm-secret-utils.h" #include "nm-utils.h" #include "nm-crypto.h" diff --git a/libnm-core/nm-setting-adsl.c b/libnm-core/nm-setting-adsl.c index b7f7d746a6..b2de702728 100644 --- a/libnm-core/nm-setting-adsl.c +++ b/libnm-core/nm-setting-adsl.c @@ -23,8 +23,6 @@ #include "nm-setting-adsl.h" -#include - #include "nm-setting-ppp.h" #include "nm-setting-private.h" #include "nm-utils.h" diff --git a/libnm-core/nm-setting-bluetooth.c b/libnm-core/nm-setting-bluetooth.c index a31928403a..bc4f8bd069 100644 --- a/libnm-core/nm-setting-bluetooth.c +++ b/libnm-core/nm-setting-bluetooth.c @@ -24,7 +24,6 @@ #include "nm-setting-bluetooth.h" -#include #include #include "nm-connection-private.h" diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c index fa55c06f28..b36ed20851 100644 --- a/libnm-core/nm-setting-bond.c +++ b/libnm-core/nm-setting-bond.c @@ -23,9 +23,7 @@ #include "nm-setting-bond.h" -#include #include -#include #include #include diff --git a/libnm-core/nm-setting-bridge-port.c b/libnm-core/nm-setting-bridge-port.c index b8670afded..614c883cbd 100644 --- a/libnm-core/nm-setting-bridge-port.c +++ b/libnm-core/nm-setting-bridge-port.c @@ -23,7 +23,6 @@ #include "nm-setting-bridge-port.h" -#include #include #include diff --git a/libnm-core/nm-setting-bridge.c b/libnm-core/nm-setting-bridge.c index 2544b19c1f..e418013cb6 100644 --- a/libnm-core/nm-setting-bridge.c +++ b/libnm-core/nm-setting-bridge.c @@ -23,7 +23,6 @@ #include "nm-setting-bridge.h" -#include #include #include diff --git a/libnm-core/nm-setting-cdma.c b/libnm-core/nm-setting-cdma.c index 1e5cd81ec6..b05daaffd9 100644 --- a/libnm-core/nm-setting-cdma.c +++ b/libnm-core/nm-setting-cdma.c @@ -23,8 +23,6 @@ #include "nm-setting-cdma.h" -#include - #include "nm-utils.h" #include "nm-setting-private.h" #include "nm-core-enum-types.h" diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index ee91ed5d96..e8d008e33d 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -24,8 +24,6 @@ #include "nm-setting-connection.h" -#include - #include "nm-utils.h" #include "nm-utils-private.h" #include "nm-core-enum-types.h" diff --git a/libnm-core/nm-setting-dcb.c b/libnm-core/nm-setting-dcb.c index c8026c696d..419d9825e8 100644 --- a/libnm-core/nm-setting-dcb.c +++ b/libnm-core/nm-setting-dcb.c @@ -23,8 +23,6 @@ #include "nm-setting-dcb.h" -#include - #include "nm-utils.h" #include "nm-utils-private.h" #include "nm-setting-private.h" diff --git a/libnm-core/nm-setting-gsm.c b/libnm-core/nm-setting-gsm.c index 68d2903240..e6784e4265 100644 --- a/libnm-core/nm-setting-gsm.c +++ b/libnm-core/nm-setting-gsm.c @@ -24,8 +24,6 @@ #include "nm-setting-gsm.h" -#include - #include "nm-utils.h" #include "nm-setting-private.h" #include "nm-core-enum-types.h" diff --git a/libnm-core/nm-setting-ip-config.c b/libnm-core/nm-setting-ip-config.c index 8fff030ea9..a10fcbe4c0 100644 --- a/libnm-core/nm-setting-ip-config.c +++ b/libnm-core/nm-setting-ip-config.c @@ -24,7 +24,6 @@ #include "nm-setting-ip-config.h" -#include #include #include "nm-setting-ip4-config.h" diff --git a/libnm-core/nm-setting-ip4-config.c b/libnm-core/nm-setting-ip4-config.c index 59529bc270..dd3b79b752 100644 --- a/libnm-core/nm-setting-ip4-config.c +++ b/libnm-core/nm-setting-ip4-config.c @@ -23,8 +23,6 @@ #include "nm-setting-ip4-config.h" -#include - #include "nm-setting-private.h" /** diff --git a/libnm-core/nm-setting-ip6-config.c b/libnm-core/nm-setting-ip6-config.c index bf3acf96b0..d6c085ac8c 100644 --- a/libnm-core/nm-setting-ip6-config.c +++ b/libnm-core/nm-setting-ip6-config.c @@ -23,7 +23,6 @@ #include "nm-setting-ip6-config.h" -#include #include #include "nm-setting-private.h" diff --git a/libnm-core/nm-setting-macsec.c b/libnm-core/nm-setting-macsec.c index 3d93ac5ae6..040aa17df7 100644 --- a/libnm-core/nm-setting-macsec.c +++ b/libnm-core/nm-setting-macsec.c @@ -23,7 +23,6 @@ #include "nm-setting-macsec.h" #include -#include #include "nm-utils/nm-secret-utils.h" diff --git a/libnm-core/nm-setting-macvlan.c b/libnm-core/nm-setting-macvlan.c index a25e105598..332dc00774 100644 --- a/libnm-core/nm-setting-macvlan.c +++ b/libnm-core/nm-setting-macvlan.c @@ -24,7 +24,6 @@ #include "nm-setting-macvlan.h" #include -#include #include "nm-utils.h" #include "nm-setting-connection.h" diff --git a/libnm-core/nm-setting-olpc-mesh.c b/libnm-core/nm-setting-olpc-mesh.c index eb87e1ff21..f6a32dbb0b 100644 --- a/libnm-core/nm-setting-olpc-mesh.c +++ b/libnm-core/nm-setting-olpc-mesh.c @@ -24,8 +24,6 @@ #include "nm-setting-olpc-mesh.h" -#include - #include "nm-utils.h" #include "nm-utils-private.h" #include "nm-setting-private.h" diff --git a/libnm-core/nm-setting-pppoe.c b/libnm-core/nm-setting-pppoe.c index e316688856..e2d516c5d4 100644 --- a/libnm-core/nm-setting-pppoe.c +++ b/libnm-core/nm-setting-pppoe.c @@ -24,8 +24,6 @@ #include "nm-setting-pppoe.h" -#include - #include "nm-setting-ppp.h" #include "nm-setting-private.h" #include "nm-core-enum-types.h" diff --git a/libnm-core/nm-setting-serial.c b/libnm-core/nm-setting-serial.c index 8b8bb76d64..36bc4f69ba 100644 --- a/libnm-core/nm-setting-serial.c +++ b/libnm-core/nm-setting-serial.c @@ -24,8 +24,6 @@ #include "nm-setting-serial.h" -#include - #include "nm-setting-private.h" /** diff --git a/libnm-core/nm-setting-team-port.c b/libnm-core/nm-setting-team-port.c index be88eb8350..1db8f22a66 100644 --- a/libnm-core/nm-setting-team-port.c +++ b/libnm-core/nm-setting-team-port.c @@ -23,7 +23,6 @@ #include "nm-setting-team-port.h" -#include #include #include diff --git a/libnm-core/nm-setting-team.c b/libnm-core/nm-setting-team.c index 96fdd10dcb..42ee3eec89 100644 --- a/libnm-core/nm-setting-team.c +++ b/libnm-core/nm-setting-team.c @@ -23,7 +23,6 @@ #include "nm-setting-team.h" -#include #include #include "nm-utils.h" diff --git a/libnm-core/nm-setting-tun.c b/libnm-core/nm-setting-tun.c index 348c9fc1ba..9801f5cfa1 100644 --- a/libnm-core/nm-setting-tun.c +++ b/libnm-core/nm-setting-tun.c @@ -24,7 +24,6 @@ #include "nm-setting-tun.h" #include -#include #include "nm-utils.h" #include "nm-setting-connection.h" diff --git a/libnm-core/nm-setting-vlan.c b/libnm-core/nm-setting-vlan.c index 4eba1626fe..5b8a49d48b 100644 --- a/libnm-core/nm-setting-vlan.c +++ b/libnm-core/nm-setting-vlan.c @@ -24,7 +24,6 @@ #include "nm-setting-vlan.h" #include -#include #include "nm-utils.h" #include "nm-core-types-internal.h" diff --git a/libnm-core/nm-setting-vpn.c b/libnm-core/nm-setting-vpn.c index e3612c13bd..e9501ab1f7 100644 --- a/libnm-core/nm-setting-vpn.c +++ b/libnm-core/nm-setting-vpn.c @@ -23,8 +23,6 @@ #include "nm-setting-vpn.h" -#include -#include #include #include "nm-utils/nm-secret-utils.h" diff --git a/libnm-core/nm-setting-vxlan.c b/libnm-core/nm-setting-vxlan.c index 0c21be27db..0c116f0611 100644 --- a/libnm-core/nm-setting-vxlan.c +++ b/libnm-core/nm-setting-vxlan.c @@ -24,7 +24,6 @@ #include "nm-setting-vxlan.h" #include -#include #include "nm-utils.h" #include "nm-setting-private.h" diff --git a/libnm-core/nm-setting-wifi-p2p.c b/libnm-core/nm-setting-wifi-p2p.c index 893170fc28..f215f47d5a 100644 --- a/libnm-core/nm-setting-wifi-p2p.c +++ b/libnm-core/nm-setting-wifi-p2p.c @@ -21,7 +21,6 @@ #include "nm-setting-wifi-p2p.h" -#include #include #include "nm-utils.h" diff --git a/libnm-core/nm-setting-wimax.c b/libnm-core/nm-setting-wimax.c index aa574a56de..a700f7fe77 100644 --- a/libnm-core/nm-setting-wimax.c +++ b/libnm-core/nm-setting-wimax.c @@ -24,7 +24,6 @@ #include "nm-setting-wimax.h" -#include #include #include "nm-setting-private.h" diff --git a/libnm-core/nm-setting-wired.c b/libnm-core/nm-setting-wired.c index ef99425511..471c65f653 100644 --- a/libnm-core/nm-setting-wired.c +++ b/libnm-core/nm-setting-wired.c @@ -24,7 +24,6 @@ #include "nm-setting-wired.h" -#include #include #include "nm-utils.h" diff --git a/libnm-core/nm-setting-wireless-security.c b/libnm-core/nm-setting-wireless-security.c index 65b55db351..f689751e4d 100644 --- a/libnm-core/nm-setting-wireless-security.c +++ b/libnm-core/nm-setting-wireless-security.c @@ -24,8 +24,6 @@ #include "nm-setting-wireless-security.h" -#include - #include "nm-setting-8021x.h" #include "nm-utils.h" #include "nm-utils-private.h" diff --git a/libnm-core/nm-setting-wireless.c b/libnm-core/nm-setting-wireless.c index 5d3f8fe817..b4cb105607 100644 --- a/libnm-core/nm-setting-wireless.c +++ b/libnm-core/nm-setting-wireless.c @@ -24,7 +24,6 @@ #include "nm-setting-wireless.h" -#include #include #include "nm-utils.h" diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index fe6808bcdc..269f83175c 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -24,8 +24,6 @@ #include "nm-setting.h" -#include - #include "nm-setting-private.h" #include "nm-utils.h" #include "nm-core-internal.h" diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index b0f84aab22..b1d5761ff3 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -23,8 +23,6 @@ #include "nm-utils.h" -#include -#include #include #include #include diff --git a/libnm-core/nm-vpn-plugin-info.c b/libnm-core/nm-vpn-plugin-info.c index 275a9dd5eb..627d5f8963 100644 --- a/libnm-core/nm-vpn-plugin-info.c +++ b/libnm-core/nm-vpn-plugin-info.c @@ -22,8 +22,6 @@ #include "nm-vpn-plugin-info.h" -#include -#include #include #include "nm-errors.h" diff --git a/libnm-core/tests/test-crypto.c b/libnm-core/tests/test-crypto.c index 6b63e6fdd4..4ac9679b05 100644 --- a/libnm-core/tests/test-crypto.c +++ b/libnm-core/tests/test-crypto.c @@ -26,7 +26,6 @@ #include #include #include -#include #include "nm-crypto-impl.h" #include "nm-utils.h" diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index efbcf6274e..96eafa3a68 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -23,8 +23,6 @@ #include "nm-default.h" -#include - #include "nm-utils/c-list-util.h" #include "nm-utils/nm-enum-utils.h" diff --git a/libnm-core/tests/test-secrets.c b/libnm-core/tests/test-secrets.c index d31c43d2ce..5debe5cfb0 100644 --- a/libnm-core/tests/test-secrets.c +++ b/libnm-core/tests/test-secrets.c @@ -21,8 +21,6 @@ #include "nm-default.h" -#include - #include "nm-setting-8021x.h" #include "nm-setting-cdma.h" #include "nm-setting-connection.h" diff --git a/libnm-core/tests/test-setting.c b/libnm-core/tests/test-setting.c index d8784d31ef..4518c55e5d 100644 --- a/libnm-core/tests/test-setting.c +++ b/libnm-core/tests/test-setting.c @@ -20,7 +20,6 @@ #include "nm-default.h" #include -#include #include "nm-utils.h" #include "nm-utils-private.h" diff --git a/libnm-core/tests/test-settings-defaults.c b/libnm-core/tests/test-settings-defaults.c index 95570b0380..9e6405434f 100644 --- a/libnm-core/tests/test-settings-defaults.c +++ b/libnm-core/tests/test-settings-defaults.c @@ -21,8 +21,6 @@ #include "nm-default.h" -#include - #include "nm-utils.h" #include "nm-setting-8021x.h" #include "nm-setting-cdma.h" diff --git a/libnm-glib/nm-vpn-plugin-utils.c b/libnm-glib/nm-vpn-plugin-utils.c index ca652d1be9..e2bc42896c 100644 --- a/libnm-glib/nm-vpn-plugin-utils.c +++ b/libnm-glib/nm-vpn-plugin-utils.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include #include diff --git a/libnm-util/nm-setting-bond.c b/libnm-util/nm-setting-bond.c index a54e93c3a5..9a1c5c7391 100644 --- a/libnm-util/nm-setting-bond.c +++ b/libnm-util/nm-setting-bond.c @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/libnm-util/nm-setting-vpn.c b/libnm-util/nm-setting-vpn.c index 1fed9eca38..626ba4ca84 100644 --- a/libnm-util/nm-setting-vpn.c +++ b/libnm-util/nm-setting-vpn.c @@ -22,7 +22,6 @@ #include "nm-default.h" #include -#include #include #include diff --git a/libnm/nm-access-point.c b/libnm/nm-access-point.c index 25281c9282..ac00d6e1bb 100644 --- a/libnm/nm-access-point.c +++ b/libnm/nm-access-point.c @@ -23,8 +23,6 @@ #include "nm-access-point.h" -#include - #include "nm-connection.h" #include "nm-setting-connection.h" #include "nm-setting-wireless.h" diff --git a/libnm/nm-active-connection.c b/libnm/nm-active-connection.c index 5b238b3bcc..fdade4bc24 100644 --- a/libnm/nm-active-connection.c +++ b/libnm/nm-active-connection.c @@ -21,10 +21,9 @@ #include "nm-default.h" -#include +#include "nm-active-connection.h" #include "nm-dbus-interface.h" -#include "nm-active-connection.h" #include "nm-object-private.h" #include "nm-core-internal.h" #include "nm-device.h" diff --git a/libnm/nm-client.c b/libnm/nm-client.c index 870adfc750..b2f76ee60a 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -21,11 +21,11 @@ #include "nm-default.h" -#include +#include "nm-client.h" + #include #include "nm-utils.h" -#include "nm-client.h" #include "nm-manager.h" #include "nm-dns-manager.h" #include "nm-remote-settings.h" diff --git a/libnm/nm-dbus-helpers.c b/libnm/nm-dbus-helpers.c index 44eed0c83c..a507c65834 100644 --- a/libnm/nm-dbus-helpers.c +++ b/libnm/nm-dbus-helpers.c @@ -22,8 +22,6 @@ #include "nm-dbus-helpers.h" -#include - #include "nm-dbus-interface.h" static GBusType nm_bus = G_BUS_TYPE_SYSTEM; diff --git a/libnm/nm-device-adsl.c b/libnm/nm-device-adsl.c index a82aa8d061..f63468aa89 100644 --- a/libnm/nm-device-adsl.c +++ b/libnm/nm-device-adsl.c @@ -23,10 +23,7 @@ #include "nm-device-adsl.h" -#include - #include "nm-object-private.h" - #include "nm-setting-adsl.h" #include "nm-setting-connection.h" diff --git a/libnm/nm-device-bond.c b/libnm/nm-device-bond.c index 83b7c3b418..4cc47b5c4b 100644 --- a/libnm/nm-device-bond.c +++ b/libnm/nm-device-bond.c @@ -20,12 +20,10 @@ #include "nm-default.h" -#include +#include "nm-setting-bond.h" #include "nm-setting-connection.h" -#include "nm-setting-bond.h" #include "nm-utils.h" - #include "nm-device-bond.h" #include "nm-object-private.h" #include "nm-core-internal.h" diff --git a/libnm/nm-device-bridge.c b/libnm/nm-device-bridge.c index 39c48d2ac8..2db3a2384d 100644 --- a/libnm/nm-device-bridge.c +++ b/libnm/nm-device-bridge.c @@ -20,12 +20,10 @@ #include "nm-default.h" -#include +#include "nm-setting-bridge.h" #include "nm-setting-connection.h" -#include "nm-setting-bridge.h" #include "nm-utils.h" - #include "nm-device-bridge.h" #include "nm-object-private.h" #include "nm-core-internal.h" diff --git a/libnm/nm-device-bt.c b/libnm/nm-device-bt.c index a47e39580f..d0af0ff623 100644 --- a/libnm/nm-device-bt.c +++ b/libnm/nm-device-bt.c @@ -21,13 +21,11 @@ #include "nm-default.h" -#include +#include "nm-device-bt.h" #include "nm-setting-connection.h" #include "nm-setting-bluetooth.h" #include "nm-utils.h" - -#include "nm-device-bt.h" #include "nm-object-private.h" #include "nm-enum-types.h" diff --git a/libnm/nm-device-dummy.c b/libnm/nm-device-dummy.c index 4c20202595..8a37214330 100644 --- a/libnm/nm-device-dummy.c +++ b/libnm/nm-device-dummy.c @@ -20,9 +20,8 @@ #include "nm-default.h" -#include - #include "nm-device-dummy.h" + #include "nm-object-private.h" #include "nm-setting-dummy.h" #include "nm-setting-connection.h" diff --git a/libnm/nm-device-ethernet.c b/libnm/nm-device-ethernet.c index ebb019dcf3..5d2acdb265 100644 --- a/libnm/nm-device-ethernet.c +++ b/libnm/nm-device-ethernet.c @@ -21,14 +21,12 @@ #include "nm-default.h" -#include +#include "nm-device-ethernet.h" #include "nm-setting-connection.h" #include "nm-setting-wired.h" #include "nm-setting-pppoe.h" #include "nm-utils.h" - -#include "nm-device-ethernet.h" #include "nm-object-private.h" G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE) diff --git a/libnm/nm-device-generic.c b/libnm/nm-device-generic.c index 62cb89ebf7..c0bf4d7077 100644 --- a/libnm/nm-device-generic.c +++ b/libnm/nm-device-generic.c @@ -20,9 +20,8 @@ #include "nm-default.h" -#include - #include "nm-device-generic.h" + #include "nm-object-private.h" #include "nm-setting-generic.h" #include "nm-setting-connection.h" diff --git a/libnm/nm-device-infiniband.c b/libnm/nm-device-infiniband.c index 1ed942b5be..aaf5ff8623 100644 --- a/libnm/nm-device-infiniband.c +++ b/libnm/nm-device-infiniband.c @@ -20,13 +20,11 @@ #include "nm-default.h" -#include +#include "nm-device-infiniband.h" #include "nm-setting-connection.h" #include "nm-setting-infiniband.h" #include "nm-utils.h" - -#include "nm-device-infiniband.h" #include "nm-object-private.h" G_DEFINE_TYPE (NMDeviceInfiniband, nm_device_infiniband, NM_TYPE_DEVICE) diff --git a/libnm/nm-device-ip-tunnel.c b/libnm/nm-device-ip-tunnel.c index 2f7efe9d8d..150dc9891c 100644 --- a/libnm/nm-device-ip-tunnel.c +++ b/libnm/nm-device-ip-tunnel.c @@ -20,13 +20,11 @@ #include "nm-default.h" -#include +#include "nm-device-ip-tunnel.h" #include "nm-setting-connection.h" #include "nm-setting-ip-tunnel.h" #include "nm-utils.h" - -#include "nm-device-ip-tunnel.h" #include "nm-object-private.h" #include "nm-core-internal.h" diff --git a/libnm/nm-device-macsec.c b/libnm/nm-device-macsec.c index 16bbbebb2e..493bff874c 100644 --- a/libnm/nm-device-macsec.c +++ b/libnm/nm-device-macsec.c @@ -20,9 +20,8 @@ #include "nm-default.h" -#include - #include "nm-device-macsec.h" + #include "nm-device-private.h" #include "nm-object-private.h" #include "nm-utils.h" diff --git a/libnm/nm-device-macvlan.c b/libnm/nm-device-macvlan.c index 23c649cc24..37484770b6 100644 --- a/libnm/nm-device-macvlan.c +++ b/libnm/nm-device-macvlan.c @@ -20,13 +20,11 @@ #include "nm-default.h" -#include +#include "nm-setting-macvlan.h" #include "nm-setting-connection.h" -#include "nm-setting-macvlan.h" #include "nm-setting-wired.h" #include "nm-utils.h" - #include "nm-device-macvlan.h" #include "nm-object-private.h" diff --git a/libnm/nm-device-modem.c b/libnm/nm-device-modem.c index 7fc843f6df..0373b3c08a 100644 --- a/libnm/nm-device-modem.c +++ b/libnm/nm-device-modem.c @@ -21,13 +21,11 @@ #include "nm-default.h" -#include +#include "nm-device-modem.h" #include "nm-setting-connection.h" #include "nm-setting-gsm.h" #include "nm-setting-cdma.h" - -#include "nm-device-modem.h" #include "nm-object-private.h" #include "nm-enum-types.h" diff --git a/libnm/nm-device-olpc-mesh.c b/libnm/nm-device-olpc-mesh.c index 875f11a99c..6258916421 100644 --- a/libnm/nm-device-olpc-mesh.c +++ b/libnm/nm-device-olpc-mesh.c @@ -20,12 +20,10 @@ #include "nm-default.h" -#include +#include "nm-device-olpc-mesh.h" #include "nm-setting-connection.h" #include "nm-setting-olpc-mesh.h" - -#include "nm-device-olpc-mesh.h" #include "nm-object-private.h" #include "nm-device-wifi.h" diff --git a/libnm/nm-device-ovs-bridge.c b/libnm/nm-device-ovs-bridge.c index 27ee97cf35..4671c8a9f2 100644 --- a/libnm/nm-device-ovs-bridge.c +++ b/libnm/nm-device-ovs-bridge.c @@ -19,9 +19,8 @@ #include "nm-default.h" -#include - #include "nm-device-ovs-bridge.h" + #include "nm-object-private.h" #include "nm-setting-ovs-bridge.h" #include "nm-setting-ovs-port.h" diff --git a/libnm/nm-device-ovs-interface.c b/libnm/nm-device-ovs-interface.c index ed3dbd4ca4..b07373e130 100644 --- a/libnm/nm-device-ovs-interface.c +++ b/libnm/nm-device-ovs-interface.c @@ -19,9 +19,8 @@ #include "nm-default.h" -#include - #include "nm-device-ovs-interface.h" + #include "nm-object-private.h" #include "nm-setting-ovs-interface.h" #include "nm-setting-ovs-port.h" diff --git a/libnm/nm-device-ovs-port.c b/libnm/nm-device-ovs-port.c index 8be5549a7c..39ecaee599 100644 --- a/libnm/nm-device-ovs-port.c +++ b/libnm/nm-device-ovs-port.c @@ -19,9 +19,8 @@ #include "nm-default.h" -#include - #include "nm-device-ovs-port.h" + #include "nm-object-private.h" #include "nm-setting-ovs-port.h" #include "nm-setting-ovs-port.h" diff --git a/libnm/nm-device-team.c b/libnm/nm-device-team.c index 101e3160e7..749739ffcf 100644 --- a/libnm/nm-device-team.c +++ b/libnm/nm-device-team.c @@ -20,13 +20,11 @@ #include "nm-default.h" -#include +#include "nm-device-team.h" #include "nm-setting-connection.h" #include "nm-setting-team.h" #include "nm-utils.h" - -#include "nm-device-team.h" #include "nm-object-private.h" #include "nm-core-internal.h" diff --git a/libnm/nm-device-tun.c b/libnm/nm-device-tun.c index 2c88bf3393..166aa1dfb5 100644 --- a/libnm/nm-device-tun.c +++ b/libnm/nm-device-tun.c @@ -20,14 +20,13 @@ #include "nm-default.h" -#include +#include "nm-device-tun.h" + #include #include "nm-setting-connection.h" #include "nm-setting-tun.h" #include "nm-utils.h" - -#include "nm-device-tun.h" #include "nm-object-private.h" G_DEFINE_TYPE (NMDeviceTun, nm_device_tun, NM_TYPE_DEVICE) diff --git a/libnm/nm-device-vlan.c b/libnm/nm-device-vlan.c index 5728d404d6..e043724597 100644 --- a/libnm/nm-device-vlan.c +++ b/libnm/nm-device-vlan.c @@ -20,14 +20,12 @@ #include "nm-default.h" -#include +#include "nm-device-vlan.h" #include "nm-setting-connection.h" #include "nm-setting-vlan.h" #include "nm-setting-wired.h" #include "nm-utils.h" - -#include "nm-device-vlan.h" #include "nm-object-private.h" G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE) diff --git a/libnm/nm-device-vxlan.c b/libnm/nm-device-vxlan.c index 9a87ad137a..8dbf13365d 100644 --- a/libnm/nm-device-vxlan.c +++ b/libnm/nm-device-vxlan.c @@ -20,13 +20,11 @@ #include "nm-default.h" -#include +#include "nm-device-vxlan.h" #include "nm-setting-connection.h" #include "nm-setting-vxlan.h" #include "nm-utils.h" - -#include "nm-device-vxlan.h" #include "nm-object-private.h" G_DEFINE_TYPE (NMDeviceVxlan, nm_device_vxlan, NM_TYPE_DEVICE) diff --git a/libnm/nm-device-wifi-p2p.c b/libnm/nm-device-wifi-p2p.c index 039a8684cb..c368fe3f46 100644 --- a/libnm/nm-device-wifi-p2p.c +++ b/libnm/nm-device-wifi-p2p.c @@ -21,12 +21,9 @@ #include "nm-device-wifi-p2p.h" -#include - #include "nm-setting-connection.h" #include "nm-setting-wifi-p2p.h" #include "nm-utils.h" - #include "nm-wifi-p2p-peer.h" #include "nm-object-private.h" #include "nm-core-internal.h" diff --git a/libnm/nm-device-wifi.c b/libnm/nm-device-wifi.c index 9fb1eebfba..9af3639d70 100644 --- a/libnm/nm-device-wifi.c +++ b/libnm/nm-device-wifi.c @@ -23,13 +23,10 @@ #include "nm-device-wifi.h" -#include - #include "nm-setting-connection.h" #include "nm-setting-wireless.h" #include "nm-setting-wireless-security.h" #include "nm-utils.h" - #include "nm-access-point.h" #include "nm-object-private.h" #include "nm-core-internal.h" diff --git a/libnm/nm-device-wimax.c b/libnm/nm-device-wimax.c index 08624594a3..36cebcf270 100644 --- a/libnm/nm-device-wimax.c +++ b/libnm/nm-device-wimax.c @@ -21,13 +21,11 @@ #include "nm-default.h" -#include +#include "nm-device-wimax.h" #include "nm-setting-connection.h" #include "nm-setting-wimax.h" #include "nm-utils.h" - -#include "nm-device-wimax.h" #include "nm-wimax-nsp.h" #include "nm-object-private.h" #include "nm-core-internal.h" diff --git a/libnm/nm-device-wpan.c b/libnm/nm-device-wpan.c index 6118362316..d6acda6184 100644 --- a/libnm/nm-device-wpan.c +++ b/libnm/nm-device-wpan.c @@ -19,9 +19,8 @@ #include "nm-default.h" -#include - #include "nm-device-wpan.h" + #include "nm-object-private.h" #include "nm-setting-wpan.h" #include "nm-setting-connection.h" diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 4bcd7c6ca4..0834f6dfc6 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -23,7 +23,6 @@ #include "nm-device.h" -#include #include #include "nm-libnm-utils.h" diff --git a/libnm/nm-dhcp-config.c b/libnm/nm-dhcp-config.c index 3f835670dd..e13bbd3473 100644 --- a/libnm/nm-dhcp-config.c +++ b/libnm/nm-dhcp-config.c @@ -21,9 +21,8 @@ #include "nm-default.h" -#include - #include "nm-dhcp-config.h" + #include "nm-dhcp4-config.h" #include "nm-dhcp6-config.h" #include "nm-dbus-interface.h" diff --git a/libnm/nm-dhcp4-config.c b/libnm/nm-dhcp4-config.c index 0e783576b3..b01e1677b0 100644 --- a/libnm/nm-dhcp4-config.c +++ b/libnm/nm-dhcp4-config.c @@ -21,6 +21,7 @@ #include "nm-default.h" #include "nm-dhcp4-config.h" + #include "nm-object-private.h" G_DEFINE_TYPE (NMDhcp4Config, nm_dhcp4_config, NM_TYPE_DHCP_CONFIG) diff --git a/libnm/nm-dhcp6-config.c b/libnm/nm-dhcp6-config.c index 9252e734f8..03dbcc3062 100644 --- a/libnm/nm-dhcp6-config.c +++ b/libnm/nm-dhcp6-config.c @@ -21,6 +21,7 @@ #include "nm-default.h" #include "nm-dhcp6-config.h" + #include "nm-object-private.h" G_DEFINE_TYPE (NMDhcp6Config, nm_dhcp6_config, NM_TYPE_DHCP_CONFIG) diff --git a/libnm/nm-dns-manager.c b/libnm/nm-dns-manager.c index 37117b723e..a3c2bba3a8 100644 --- a/libnm/nm-dns-manager.c +++ b/libnm/nm-dns-manager.c @@ -22,11 +22,8 @@ #include "nm-dns-manager.h" -#include - #include "nm-dbus-interface.h" #include "nm-connection.h" - #include "nm-client.h" #include "nm-object-private.h" #include "nm-dbus-helpers.h" diff --git a/libnm/nm-ip-config.c b/libnm/nm-ip-config.c index c1e888be39..618b05f170 100644 --- a/libnm/nm-ip-config.c +++ b/libnm/nm-ip-config.c @@ -21,9 +21,8 @@ #include "nm-default.h" -#include - #include "nm-ip-config.h" + #include "nm-ip4-config.h" #include "nm-ip6-config.h" #include "nm-setting-ip-config.h" diff --git a/libnm/nm-ip4-config.c b/libnm/nm-ip4-config.c index 322ea4e808..ac16ef6a07 100644 --- a/libnm/nm-ip4-config.c +++ b/libnm/nm-ip4-config.c @@ -21,6 +21,7 @@ #include "nm-default.h" #include "nm-ip4-config.h" + #include "nm-object-private.h" G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_IP_CONFIG) diff --git a/libnm/nm-ip6-config.c b/libnm/nm-ip6-config.c index 93cdf332b6..773faf6ab8 100644 --- a/libnm/nm-ip6-config.c +++ b/libnm/nm-ip6-config.c @@ -21,6 +21,7 @@ #include "nm-default.h" #include "nm-ip6-config.h" + #include "nm-object-private.h" G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, NM_TYPE_IP_CONFIG) diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index 3254d4a094..4d8c223a48 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -23,8 +23,6 @@ #include "nm-manager.h" -#include - #include "nm-utils.h" #include "nm-checkpoint.h" #include "nm-common-macros.h" diff --git a/libnm/nm-object.c b/libnm/nm-object.c index d2ae25aab1..f54dac5df2 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -23,7 +23,6 @@ #include "nm-object.h" -#include #include #include diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c index 08faa77e3e..a011ca8745 100644 --- a/libnm/nm-remote-connection.c +++ b/libnm/nm-remote-connection.c @@ -21,14 +21,12 @@ #include "nm-default.h" -#include +#include "nm-remote-connection.h" #include "nm-dbus-interface.h" #include "nm-utils.h" #include "nm-setting-connection.h" #include "nm-core-internal.h" - -#include "nm-remote-connection.h" #include "nm-remote-connection-private.h" #include "nm-object-private.h" #include "nm-dbus-helpers.h" diff --git a/libnm/nm-remote-settings.c b/libnm/nm-remote-settings.c index f2b26215c9..6b2d6e9248 100644 --- a/libnm/nm-remote-settings.c +++ b/libnm/nm-remote-settings.c @@ -23,11 +23,8 @@ #include "nm-remote-settings.h" -#include - #include "nm-dbus-interface.h" #include "nm-connection.h" - #include "nm-client.h" #include "nm-remote-connection.h" #include "nm-remote-connection-private.h" diff --git a/libnm/nm-secret-agent-old.c b/libnm/nm-secret-agent-old.c index 5f4565c076..56a88b004f 100644 --- a/libnm/nm-secret-agent-old.c +++ b/libnm/nm-secret-agent-old.c @@ -22,8 +22,6 @@ #include "nm-secret-agent-old.h" -#include - #include "nm-dbus-interface.h" #include "nm-enum-types.h" #include "nm-dbus-helpers.h" diff --git a/libnm/nm-vpn-connection.c b/libnm/nm-vpn-connection.c index bc26d0b959..9fc32ed612 100644 --- a/libnm/nm-vpn-connection.c +++ b/libnm/nm-vpn-connection.c @@ -21,9 +21,8 @@ #include "nm-default.h" -#include - #include "nm-vpn-connection.h" + #include "nm-dbus-interface.h" #include "nm-utils.h" #include "nm-object-private.h" diff --git a/libnm/nm-vpn-plugin-old.c b/libnm/nm-vpn-plugin-old.c index bfafc7b775..80900cecb5 100644 --- a/libnm/nm-vpn-plugin-old.c +++ b/libnm/nm-vpn-plugin-old.c @@ -23,7 +23,6 @@ #include "nm-vpn-plugin-old.h" -#include #include #include diff --git a/libnm/nm-vpn-service-plugin.c b/libnm/nm-vpn-service-plugin.c index ed9da7f787..57b36e69b5 100644 --- a/libnm/nm-vpn-service-plugin.c +++ b/libnm/nm-vpn-service-plugin.c @@ -23,7 +23,6 @@ #include "nm-vpn-service-plugin.h" -#include #include #include diff --git a/libnm/nm-wifi-p2p-peer.c b/libnm/nm-wifi-p2p-peer.c index d17010ce0f..91bc29d016 100644 --- a/libnm/nm-wifi-p2p-peer.c +++ b/libnm/nm-wifi-p2p-peer.c @@ -21,13 +21,10 @@ #include "nm-wifi-p2p-peer.h" -#include - #include "nm-connection.h" #include "nm-setting-connection.h" #include "nm-setting-wifi-p2p.h" #include "nm-utils.h" - #include "nm-dbus-interface.h" #include "nm-object-private.h" diff --git a/libnm/nm-wimax-nsp.c b/libnm/nm-wimax-nsp.c index 90c2c2bba0..7baf7f0272 100644 --- a/libnm/nm-wimax-nsp.c +++ b/libnm/nm-wimax-nsp.c @@ -20,13 +20,11 @@ #include "nm-default.h" -#include +#include "nm-wimax-nsp.h" #include "nm-connection.h" #include "nm-setting-connection.h" #include "nm-setting-wimax.h" - -#include "nm-wimax-nsp.h" #include "nm-dbus-interface.h" #include "nm-object-private.h" #include "nm-enum-types.h" diff --git a/libnm/tests/test-nm-client.c b/libnm/tests/test-nm-client.c index 21272e4d4f..35ae33be26 100644 --- a/libnm/tests/test-nm-client.c +++ b/libnm/tests/test-nm-client.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include diff --git a/libnm/tests/test-remote-settings-client.c b/libnm/tests/test-remote-settings-client.c index 45d60c069a..1b2114942e 100644 --- a/libnm/tests/test-remote-settings-client.c +++ b/libnm/tests/test-remote-settings-client.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include diff --git a/libnm/tests/test-secret-agent.c b/libnm/tests/test-secret-agent.c index 53110be6cd..35a215ca33 100644 --- a/libnm/tests/test-secret-agent.c +++ b/libnm/tests/test-secret-agent.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include diff --git a/shared/nm-test-utils-impl.c b/shared/nm-test-utils-impl.c index 1da9014e19..509b235a0f 100644 --- a/shared/nm-test-utils-impl.c +++ b/shared/nm-test-utils-impl.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include "NetworkManager.h" diff --git a/shared/nm-utils/nm-shared-utils.c b/shared/nm-utils/nm-shared-utils.c index 288c96a4f8..db97111193 100644 --- a/shared/nm-utils/nm-shared-utils.c +++ b/shared/nm-utils/nm-shared-utils.c @@ -23,7 +23,6 @@ #include "nm-shared-utils.h" -#include #include #include #include diff --git a/src/devices/adsl/nm-atm-manager.c b/src/devices/adsl/nm-atm-manager.c index 0ff4603df5..dddb834249 100644 --- a/src/devices/adsl/nm-atm-manager.c +++ b/src/devices/adsl/nm-atm-manager.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include diff --git a/src/devices/adsl/nm-device-adsl.c b/src/devices/adsl/nm-device-adsl.c index ddc03ce3b1..e0501a74b3 100644 --- a/src/devices/adsl/nm-device-adsl.c +++ b/src/devices/adsl/nm-device-adsl.c @@ -25,12 +25,10 @@ #include #include #include -#include #include #include #include #include -#include #include "devices/nm-device-private.h" #include "platform/nm-platform.h" diff --git a/src/devices/bluetooth/nm-bluez-device.c b/src/devices/bluetooth/nm-bluez-device.c index 8e2a96b78f..377ee478a0 100644 --- a/src/devices/bluetooth/nm-bluez-device.c +++ b/src/devices/bluetooth/nm-bluez-device.c @@ -23,8 +23,6 @@ #include "nm-bluez-device.h" -#include - #include "nm-core-internal.h" #include "nm-bt-error.h" #include "nm-bluez-common.h" diff --git a/src/devices/bluetooth/nm-bluez-manager.c b/src/devices/bluetooth/nm-bluez-manager.c index 711f2e5786..dc85a8b287 100644 --- a/src/devices/bluetooth/nm-bluez-manager.c +++ b/src/devices/bluetooth/nm-bluez-manager.c @@ -21,7 +21,6 @@ #include "nm-default.h" #include -#include #include #include diff --git a/src/devices/bluetooth/nm-bluez4-adapter.c b/src/devices/bluetooth/nm-bluez4-adapter.c index c8ef7a2716..3a456debc5 100644 --- a/src/devices/bluetooth/nm-bluez4-adapter.c +++ b/src/devices/bluetooth/nm-bluez4-adapter.c @@ -22,8 +22,6 @@ #include "nm-bluez4-adapter.h" -#include - #include "nm-dbus-interface.h" #include "nm-bluez-device.h" #include "nm-bluez-common.h" diff --git a/src/devices/bluetooth/nm-bluez4-manager.c b/src/devices/bluetooth/nm-bluez4-manager.c index 1fe02f1860..82d995bed0 100644 --- a/src/devices/bluetooth/nm-bluez4-manager.c +++ b/src/devices/bluetooth/nm-bluez4-manager.c @@ -24,7 +24,6 @@ #include "nm-bluez4-manager.h" #include -#include #include #include "nm-bluez4-adapter.h" diff --git a/src/devices/bluetooth/nm-bluez5-dun.c b/src/devices/bluetooth/nm-bluez5-dun.c index 32f8da65eb..b85a410e8d 100644 --- a/src/devices/bluetooth/nm-bluez5-dun.c +++ b/src/devices/bluetooth/nm-bluez5-dun.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "nm-bluez5-dun.h" diff --git a/src/devices/bluetooth/nm-bluez5-manager.c b/src/devices/bluetooth/nm-bluez5-manager.c index e984212bb6..be15d8243b 100644 --- a/src/devices/bluetooth/nm-bluez5-manager.c +++ b/src/devices/bluetooth/nm-bluez5-manager.c @@ -25,7 +25,6 @@ #include "nm-bluez5-manager.h" #include -#include #include #include "nm-core-internal.h" diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index 68209d8ab9..5dcafee9ed 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -23,7 +23,6 @@ #include "nm-device-bt.h" #include -#include #include "nm-bluez-common.h" #include "nm-bluez-device.h" diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 78cba9bb1d..6dabdfe855 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -22,7 +22,6 @@ #include "nm-device-bond.h" -#include #include #include "NetworkManagerUtils.h" diff --git a/src/devices/nm-device-dummy.c b/src/devices/nm-device-dummy.c index eb90456a97..47a45342d8 100644 --- a/src/devices/nm-device-dummy.c +++ b/src/devices/nm-device-dummy.c @@ -17,7 +17,6 @@ #include "nm-device-dummy.h" #include -#include #include #include "nm-act-request.h" diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 3b6fb35b32..f93ff1a483 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -24,10 +24,8 @@ #include "nm-device-ethernet.h" #include -#include #include #include -#include #include #include "nm-device-private.h" diff --git a/src/devices/nm-device-factory.c b/src/devices/nm-device-factory.c index a11ead6e4c..30aca03850 100644 --- a/src/devices/nm-device-factory.c +++ b/src/devices/nm-device-factory.c @@ -24,8 +24,6 @@ #include #include -#include -#include #include #include "platform/nm-platform.h" diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c index 1dc2bc964b..9627594748 100644 --- a/src/devices/nm-device-ip-tunnel.c +++ b/src/devices/nm-device-ip-tunnel.c @@ -22,7 +22,6 @@ #include "nm-device-ip-tunnel.h" -#include #include #include #include diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index bb629713fc..aa2a0ac05f 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -22,7 +22,6 @@ #include "nm-device-macvlan.h" -#include #include #include "nm-device-private.h" diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index 3fe3dfd4a4..90360c9ea1 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -23,7 +23,6 @@ #include "nm-device-tun.h" #include -#include #include #include diff --git a/src/devices/nm-device-veth.c b/src/devices/nm-device-veth.c index 6f90758cd5..d7a59baec7 100644 --- a/src/devices/nm-device-veth.c +++ b/src/devices/nm-device-veth.c @@ -20,9 +20,7 @@ #include "nm-default.h" -#include #include -#include #include "nm-device-veth.h" #include "nm-device-private.h" diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index 50730320e0..fc73c09975 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -22,8 +22,6 @@ #include "nm-device-vxlan.h" -#include - #include "nm-device-private.h" #include "nm-manager.h" #include "platform/nm-platform.h" diff --git a/src/devices/nm-device-wpan.c b/src/devices/nm-device-wpan.c index c2fa7f4e8d..cdfd1f70aa 100644 --- a/src/devices/nm-device-wpan.c +++ b/src/devices/nm-device-wpan.c @@ -23,7 +23,6 @@ #include "nm-device-wpan.h" #include -#include #include #include diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index bff35ddd43..317be5b5bd 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -24,9 +24,7 @@ #include "nm-device.h" #include -#include #include -#include #include #include #include diff --git a/src/devices/nm-lldp-listener.c b/src/devices/nm-lldp-listener.c index ae18063709..f26a2d5cde 100644 --- a/src/devices/nm-lldp-listener.c +++ b/src/devices/nm-lldp-listener.c @@ -23,7 +23,6 @@ #include "nm-lldp-listener.h" #include -#include #include "platform/nm-platform.h" #include "nm-utils.h" diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c index 48f6b4f3f9..47cae7d990 100644 --- a/src/devices/ovs/nm-ovsdb.c +++ b/src/devices/ovs/nm-ovsdb.c @@ -21,7 +21,6 @@ #include "nm-ovsdb.h" -#include #include #include diff --git a/src/devices/team/nm-team-factory.c b/src/devices/team/nm-team-factory.c index d062429f26..f18b943db5 100644 --- a/src/devices/team/nm-team-factory.c +++ b/src/devices/team/nm-team-factory.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include "nm-manager.h" diff --git a/src/devices/wifi/nm-device-iwd.c b/src/devices/wifi/nm-device-iwd.c index 5b150e0ca4..68116ef65e 100644 --- a/src/devices/wifi/nm-device-iwd.c +++ b/src/devices/wifi/nm-device-iwd.c @@ -22,8 +22,6 @@ #include "nm-device-iwd.h" -#include - #include "nm-common-macros.h" #include "devices/nm-device.h" #include "devices/nm-device-private.h" diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c index 193779a7fc..1172a61337 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.c +++ b/src/devices/wifi/nm-device-olpc-mesh.c @@ -29,13 +29,11 @@ #include "nm-device-olpc-mesh.h" #include -#include #include #include #include #include #include -#include #include "devices/nm-device.h" #include "nm-device-wifi.h" diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index edc099493d..aaa101a67a 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -24,9 +24,7 @@ #include "nm-device-wifi.h" #include -#include #include -#include #include "nm-device-wifi-p2p.h" #include "nm-wifi-ap.h" diff --git a/src/devices/wifi/nm-iwd-manager.c b/src/devices/wifi/nm-iwd-manager.c index 736a1a2398..c6e2d644e7 100644 --- a/src/devices/wifi/nm-iwd-manager.c +++ b/src/devices/wifi/nm-iwd-manager.c @@ -22,7 +22,6 @@ #include "nm-iwd-manager.h" -#include #include #include "nm-logging.h" diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c index d6920bafb1..87daff596e 100644 --- a/src/devices/wifi/nm-wifi-ap.c +++ b/src/devices/wifi/nm-wifi-ap.c @@ -23,7 +23,6 @@ #include "nm-wifi-ap.h" -#include #include #include "nm-setting-wireless.h" diff --git a/src/devices/wifi/nm-wifi-p2p-peer.c b/src/devices/wifi/nm-wifi-p2p-peer.c index db114381b0..4b524623c4 100644 --- a/src/devices/wifi/nm-wifi-p2p-peer.c +++ b/src/devices/wifi/nm-wifi-p2p-peer.c @@ -22,7 +22,6 @@ #include "nm-wifi-p2p-peer.h" -#include #include #include "nm-setting-wireless.h" diff --git a/src/devices/wifi/nm-wifi-utils.c b/src/devices/wifi/nm-wifi-utils.c index 1eb13127a9..c6e8b3e0df 100644 --- a/src/devices/wifi/nm-wifi-utils.c +++ b/src/devices/wifi/nm-wifi-utils.c @@ -22,7 +22,6 @@ #include "nm-wifi-utils.h" -#include #include #include "nm-utils.h" diff --git a/src/devices/wifi/tests/test-general.c b/src/devices/wifi/tests/test-general.c index f752bbfcd9..e08998379e 100644 --- a/src/devices/wifi/tests/test-general.c +++ b/src/devices/wifi/tests/test-general.c @@ -20,10 +20,7 @@ #include "nm-default.h" -#include - #include "devices/wifi/nm-wifi-utils.h" - #include "nm-core-internal.h" #include "nm-test-utils-core.h" diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index bd9ee3bb8e..a98c0ce916 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -22,8 +22,6 @@ #include "nm-device-modem.h" -#include - #include "nm-modem.h" #include "devices/nm-device-private.h" #include "nm-rfkill-manager.h" diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index e8699c5b26..1cb549b017 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -22,7 +22,6 @@ #include "nm-modem-broadband.h" -#include #include #include diff --git a/src/devices/wwan/nm-modem-manager.c b/src/devices/wwan/nm-modem-manager.c index dfc102f3e5..fac14d69d6 100644 --- a/src/devices/wwan/nm-modem-manager.c +++ b/src/devices/wwan/nm-modem-manager.c @@ -24,7 +24,6 @@ #include "nm-modem-manager.h" -#include #include #if HAVE_LIBSYSTEMD diff --git a/src/devices/wwan/nm-modem-ofono.c b/src/devices/wwan/nm-modem-ofono.c index f3c4d7a304..8d0f0b0148 100644 --- a/src/devices/wwan/nm-modem-ofono.c +++ b/src/devices/wwan/nm-modem-ofono.c @@ -22,8 +22,6 @@ #include "nm-modem-ofono.h" -#include - #include "nm-core-internal.h" #include "devices/nm-device-private.h" #include "nm-modem.h" diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index 1ad12b9d8e..74c212ae29 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -24,7 +24,6 @@ #include "nm-modem.h" #include -#include #include #include diff --git a/src/devices/wwan/nm-wwan-factory.c b/src/devices/wwan/nm-wwan-factory.c index a561b58a62..c9ee27ff2f 100644 --- a/src/devices/wwan/nm-wwan-factory.c +++ b/src/devices/wwan/nm-wwan-factory.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include "devices/nm-device-factory.h" diff --git a/src/dhcp/nm-dhcp-client.c b/src/dhcp/nm-dhcp-client.c index 7ed7a68660..39175dab38 100644 --- a/src/dhcp/nm-dhcp-client.c +++ b/src/dhcp/nm-dhcp-client.c @@ -21,10 +21,8 @@ #include "nm-dhcp-client.h" -#include #include #include -#include #include #include #include diff --git a/src/dhcp/nm-dhcp-dhclient-utils.c b/src/dhcp/nm-dhcp-dhclient-utils.c index 99762ee18e..cbd706fa69 100644 --- a/src/dhcp/nm-dhcp-dhclient-utils.c +++ b/src/dhcp/nm-dhcp-dhclient-utils.c @@ -21,7 +21,6 @@ #include "nm-dhcp-dhclient-utils.h" -#include #include #include #include diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c index 0146c8b465..6673f9ae9a 100644 --- a/src/dhcp/nm-dhcp-dhclient.c +++ b/src/dhcp/nm-dhcp-dhclient.c @@ -29,9 +29,7 @@ #if WITH_DHCLIENT -#include #include -#include #include #include #include diff --git a/src/dhcp/nm-dhcp-dhcpcanon.c b/src/dhcp/nm-dhcp-dhcpcanon.c index 0f033e2250..e1495cc6cc 100644 --- a/src/dhcp/nm-dhcp-dhcpcanon.c +++ b/src/dhcp/nm-dhcp-dhcpcanon.c @@ -22,9 +22,7 @@ #if WITH_DHCPCANON -#include #include -#include #include #include "nm-utils.h" diff --git a/src/dhcp/nm-dhcp-dhcpcd.c b/src/dhcp/nm-dhcp-dhcpcd.c index e2a1354f2c..b3d87ee00a 100644 --- a/src/dhcp/nm-dhcp-dhcpcd.c +++ b/src/dhcp/nm-dhcp-dhcpcd.c @@ -24,9 +24,7 @@ #if WITH_DHCPCD -#include #include -#include #include #include #include diff --git a/src/dhcp/nm-dhcp-helper.c b/src/dhcp/nm-dhcp-helper.c index 83cc4600b8..8f753a6177 100644 --- a/src/dhcp/nm-dhcp-helper.c +++ b/src/dhcp/nm-dhcp-helper.c @@ -22,7 +22,6 @@ #include #include -#include #include #include "nm-utils/nm-vpn-plugin-macros.h" diff --git a/src/dhcp/nm-dhcp-listener.c b/src/dhcp/nm-dhcp-listener.c index 1770ead34f..049c4e552e 100644 --- a/src/dhcp/nm-dhcp-listener.c +++ b/src/dhcp/nm-dhcp-listener.c @@ -24,9 +24,7 @@ #include #include #include -#include #include -#include #include #include "nm-dhcp-helper-api.h" diff --git a/src/dhcp/nm-dhcp-manager.c b/src/dhcp/nm-dhcp-manager.c index c13c3043a5..7063c82cfa 100644 --- a/src/dhcp/nm-dhcp-manager.c +++ b/src/dhcp/nm-dhcp-manager.c @@ -27,9 +27,7 @@ #include #include #include -#include #include -#include #include #include #include diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c index 3d93d3ac03..ddba34f392 100644 --- a/src/dhcp/nm-dhcp-systemd.c +++ b/src/dhcp/nm-dhcp-systemd.c @@ -18,9 +18,7 @@ #include "nm-default.h" -#include #include -#include #include #include #include diff --git a/src/dhcp/nm-dhcp-utils.c b/src/dhcp/nm-dhcp-utils.c index 768f9fd790..efd8422b36 100644 --- a/src/dhcp/nm-dhcp-utils.c +++ b/src/dhcp/nm-dhcp-utils.c @@ -19,8 +19,6 @@ #include "nm-default.h" -#include -#include #include #include diff --git a/src/dhcp/tests/test-dhcp-dhclient.c b/src/dhcp/tests/test-dhcp-dhclient.c index a65cbc4ef0..55d712b0a5 100644 --- a/src/dhcp/tests/test-dhcp-dhclient.c +++ b/src/dhcp/tests/test-dhcp-dhclient.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include #include diff --git a/src/dhcp/tests/test-dhcp-utils.c b/src/dhcp/tests/test-dhcp-utils.c index 617a3c6c42..240d868c7f 100644 --- a/src/dhcp/tests/test-dhcp-utils.c +++ b/src/dhcp/tests/test-dhcp-utils.c @@ -21,7 +21,6 @@ #include #include -#include #include #include "nm-utils/nm-dedup-multi.h" diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c index 2a30a5407b..a6a10f59e4 100644 --- a/src/dns/nm-dns-manager.c +++ b/src/dns/nm-dns-manager.c @@ -23,7 +23,6 @@ #include "nm-default.h" -#include #include #include #include diff --git a/src/dns/nm-dns-plugin.c b/src/dns/nm-dns-plugin.c index 48f04b004d..ce81418690 100644 --- a/src/dns/nm-dns-plugin.c +++ b/src/dns/nm-dns-plugin.c @@ -21,7 +21,6 @@ #include "nm-dns-plugin.h" -#include #include #include #include diff --git a/src/dnsmasq/nm-dnsmasq-manager.c b/src/dnsmasq/nm-dnsmasq-manager.c index 1afc6e0d71..43bc66fcae 100644 --- a/src/dnsmasq/nm-dnsmasq-manager.c +++ b/src/dnsmasq/nm-dnsmasq-manager.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/src/dnsmasq/nm-dnsmasq-utils.c b/src/dnsmasq/nm-dnsmasq-utils.c index 382b3aeb49..ec5545d3ec 100644 --- a/src/dnsmasq/nm-dnsmasq-utils.c +++ b/src/dnsmasq/nm-dnsmasq-utils.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include "nm-dnsmasq-utils.h" diff --git a/src/initrd/nmi-cmdline-reader.c b/src/initrd/nmi-cmdline-reader.c index ffd460509b..b9c75c1ba2 100644 --- a/src/initrd/nmi-cmdline-reader.c +++ b/src/initrd/nmi-cmdline-reader.c @@ -19,12 +19,10 @@ */ #include "nm-default.h" + #include "nm-core-internal.h" - #include "nm-initrd-generator.h" -#include - /*****************************************************************************/ #define _NMLOG(level, domain, ...) \ diff --git a/src/initrd/nmi-ibft-reader.c b/src/initrd/nmi-ibft-reader.c index c927546746..03a129ef46 100644 --- a/src/initrd/nmi-ibft-reader.c +++ b/src/initrd/nmi-ibft-reader.c @@ -22,13 +22,11 @@ #include "nm-initrd-generator.h" #include -#include #include #include #include #include #include -#include #include #include diff --git a/src/initrd/tests/test-cmdline-reader.c b/src/initrd/tests/test-cmdline-reader.c index 95084e9213..1a87505aec 100644 --- a/src/initrd/tests/test-cmdline-reader.c +++ b/src/initrd/tests/test-cmdline-reader.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/src/initrd/tests/test-ibft-reader.c b/src/initrd/tests/test-ibft-reader.c index 340b3896c8..fd99b074d9 100644 --- a/src/initrd/tests/test-ibft-reader.c +++ b/src/initrd/tests/test-ibft-reader.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/src/main-utils.c b/src/main-utils.c index a597ede7c6..753f2c7de4 100644 --- a/src/main-utils.c +++ b/src/main-utils.c @@ -22,7 +22,6 @@ #include "nm-default.h" #include -#include #include #include #include diff --git a/src/main.c b/src/main.c index cf95a4ed67..b52b9347c4 100644 --- a/src/main.c +++ b/src/main.c @@ -23,14 +23,12 @@ #include #include -#include #include #include #include #include #include #include -#include #include #include "main-utils.h" diff --git a/src/ndisc/nm-fake-ndisc.c b/src/ndisc/nm-fake-ndisc.c index 6e9a72c6f4..f471923175 100644 --- a/src/ndisc/nm-fake-ndisc.c +++ b/src/ndisc/nm-fake-ndisc.c @@ -22,7 +22,6 @@ #include "nm-fake-ndisc.h" -#include #include #include "nm-ndisc-private.h" diff --git a/src/ndisc/nm-lndp-ndisc.c b/src/ndisc/nm-lndp-ndisc.c index a5bb017133..d608a2dc68 100644 --- a/src/ndisc/nm-lndp-ndisc.c +++ b/src/ndisc/nm-lndp-ndisc.c @@ -22,7 +22,6 @@ #include "nm-lndp-ndisc.h" -#include #include #include /* stdarg.h included because of a bug in ndp.h */ diff --git a/src/ndisc/nm-ndisc.c b/src/ndisc/nm-ndisc.c index 038ecb806b..dd535630b4 100644 --- a/src/ndisc/nm-ndisc.c +++ b/src/ndisc/nm-ndisc.c @@ -24,7 +24,6 @@ #include #include -#include #include "nm-setting-ip6-config.h" diff --git a/src/ndisc/tests/test-ndisc-fake.c b/src/ndisc/tests/test-ndisc-fake.c index 268f3b49b4..d2291d4495 100644 --- a/src/ndisc/tests/test-ndisc-fake.c +++ b/src/ndisc/tests/test-ndisc-fake.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include "ndisc/nm-ndisc.h" diff --git a/src/ndisc/tests/test-ndisc-linux.c b/src/ndisc/tests/test-ndisc-linux.c index 2764b6c040..d47c001852 100644 --- a/src/ndisc/tests/test-ndisc-linux.c +++ b/src/ndisc/tests/test-ndisc-linux.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include "ndisc/nm-ndisc.h" diff --git a/src/nm-act-request.c b/src/nm-act-request.c index 584eceab12..a79167f211 100644 --- a/src/nm-act-request.c +++ b/src/nm-act-request.c @@ -23,7 +23,6 @@ #include "nm-act-request.h" -#include #include #include #include diff --git a/src/nm-audit-manager.c b/src/nm-audit-manager.c index 64d9bf4a49..64b8b52513 100644 --- a/src/nm-audit-manager.c +++ b/src/nm-audit-manager.c @@ -22,8 +22,6 @@ #include "nm-audit-manager.h" -#include -#include #if HAVE_LIBAUDIT #include #endif diff --git a/src/nm-auth-subject.c b/src/nm-auth-subject.c index 9ed65e2dd2..dff331a8d8 100644 --- a/src/nm-auth-subject.c +++ b/src/nm-auth-subject.c @@ -30,7 +30,6 @@ #include "nm-auth-subject.h" -#include #include #include "nm-dbus-manager.h" diff --git a/src/nm-auth-utils.c b/src/nm-auth-utils.c index 0c4a4bac4d..146f6883f4 100644 --- a/src/nm-auth-utils.c +++ b/src/nm-auth-utils.c @@ -22,10 +22,7 @@ #include "nm-auth-utils.h" -#include - #include "nm-utils/nm-c-list.h" - #include "nm-setting-connection.h" #include "nm-auth-subject.h" #include "nm-auth-manager.h" diff --git a/src/nm-checkpoint.c b/src/nm-checkpoint.c index 5489ed4956..9b1622ec25 100644 --- a/src/nm-checkpoint.c +++ b/src/nm-checkpoint.c @@ -22,8 +22,6 @@ #include "nm-checkpoint.h" -#include - #include "nm-active-connection.h" #include "nm-act-request.h" #include "nm-auth-subject.h" diff --git a/src/nm-config-data.c b/src/nm-config-data.c index 8ef915163f..3e75e1aa71 100644 --- a/src/nm-config-data.c +++ b/src/nm-config-data.c @@ -23,8 +23,6 @@ #include "nm-config-data.h" -#include - #include "nm-config.h" #include "devices/nm-device.h" #include "nm-core-internal.h" diff --git a/src/nm-config.c b/src/nm-config.c index d028be6733..3e82bdec05 100644 --- a/src/nm-config.c +++ b/src/nm-config.c @@ -23,7 +23,6 @@ #include "nm-config.h" -#include #include #include "nm-utils.h" diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c index bc0e1d94cf..59fe042e1c 100644 --- a/src/nm-connectivity.c +++ b/src/nm-connectivity.c @@ -24,8 +24,6 @@ #include "nm-connectivity.h" -#include - #if WITH_CONCHECK #include #endif diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c index 911babd5d0..2798b07f21 100644 --- a/src/nm-core-utils.c +++ b/src/nm-core-utils.c @@ -23,10 +23,8 @@ #include "nm-core-utils.h" -#include #include #include -#include #include #include #include diff --git a/src/nm-dbus-manager.c b/src/nm-dbus-manager.c index 9c8d6570f7..00fa6617b5 100644 --- a/src/nm-dbus-manager.c +++ b/src/nm-dbus-manager.c @@ -26,8 +26,6 @@ #include #include #include -#include -#include #include "c-list/src/c-list.h" #include "nm-dbus-interface.h" diff --git a/src/nm-dcb.c b/src/nm-dcb.c index 5a46fa00c9..a63fdf3d96 100644 --- a/src/nm-dcb.c +++ b/src/nm-dcb.c @@ -21,7 +21,6 @@ #include "nm-default.h" #include -#include #include "nm-dcb.h" #include "platform/nm-platform.h" diff --git a/src/nm-dhcp4-config.c b/src/nm-dhcp4-config.c index ceafddf56e..fe0df3a755 100644 --- a/src/nm-dhcp4-config.c +++ b/src/nm-dhcp4-config.c @@ -22,8 +22,6 @@ #include "nm-dhcp4-config.h" -#include - #include "nm-dbus-interface.h" #include "nm-utils.h" #include "nm-dbus-object.h" diff --git a/src/nm-dhcp6-config.c b/src/nm-dhcp6-config.c index d477521afe..59266d55fa 100644 --- a/src/nm-dhcp6-config.c +++ b/src/nm-dhcp6-config.c @@ -22,8 +22,6 @@ #include "nm-dhcp6-config.h" -#include - #include "nm-dbus-interface.h" #include "nm-utils.h" #include "nm-dbus-object.h" diff --git a/src/nm-dispatcher.c b/src/nm-dispatcher.c index 368b781ad1..4d8d9f8a8e 100644 --- a/src/nm-dispatcher.c +++ b/src/nm-dispatcher.c @@ -23,9 +23,6 @@ #include "nm-dispatcher.h" -#include -#include - #include "nm-dispatcher-api.h" #include "NetworkManagerUtils.h" #include "nm-utils.h" diff --git a/src/nm-firewall-manager.c b/src/nm-firewall-manager.c index 5b5e7cfa20..a4b079b4de 100644 --- a/src/nm-firewall-manager.c +++ b/src/nm-firewall-manager.c @@ -22,8 +22,6 @@ #include "nm-firewall-manager.h" -#include - #include "NetworkManagerUtils.h" #include "c-list/src/c-list.h" diff --git a/src/nm-hostname-manager.c b/src/nm-hostname-manager.c index 88ff1604dd..d405a32016 100644 --- a/src/nm-hostname-manager.c +++ b/src/nm-hostname-manager.c @@ -23,8 +23,6 @@ #include "nm-hostname-manager.h" #include -#include -#include #if HAVE_SELINUX #include diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index 5b2f6726e9..2dd606a822 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -23,11 +23,9 @@ #include #include #include -#include #include #include #include -#include #include #include #include diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index 722144bab9..e362c20def 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -23,7 +23,6 @@ #include "nm-ip4-config.h" -#include #include #include #include diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index 703043886c..5247938986 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -23,7 +23,6 @@ #include "nm-ip6-config.h" -#include #include #include #include diff --git a/src/nm-keep-alive.c b/src/nm-keep-alive.c index d34c524cd1..cfec138a30 100644 --- a/src/nm-keep-alive.c +++ b/src/nm-keep-alive.c @@ -23,8 +23,6 @@ #include "nm-keep-alive.h" -#include - #include "settings/nm-settings-connection.h" /*****************************************************************************/ diff --git a/src/nm-logging.c b/src/nm-logging.c index 8388e603e2..d870732641 100644 --- a/src/nm-logging.c +++ b/src/nm-logging.c @@ -28,11 +28,9 @@ #include #include #include -#include #include #include #include -#include #if SYSTEMD_JOURNAL #define SD_JOURNAL_SUPPRESS_LOCATION diff --git a/src/nm-manager.c b/src/nm-manager.c index 67d94fdecc..5f490c83a7 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -25,8 +25,6 @@ #include #include -#include -#include #include #include "nm-utils/nm-c-list.h" diff --git a/src/nm-policy.c b/src/nm-policy.c index 77fc929c10..9372965f03 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -23,9 +23,7 @@ #include "nm-policy.h" -#include #include -#include #include #include "NetworkManagerUtils.h" diff --git a/src/nm-rfkill-manager.c b/src/nm-rfkill-manager.c index 557f4cd93e..534ad36939 100644 --- a/src/nm-rfkill-manager.c +++ b/src/nm-rfkill-manager.c @@ -22,7 +22,6 @@ #include "nm-rfkill-manager.h" -#include #include #include "nm-utils/nm-udev-utils.h" diff --git a/src/nm-session-monitor.c b/src/nm-session-monitor.c index b67c537c8b..aadfa6b91d 100644 --- a/src/nm-session-monitor.c +++ b/src/nm-session-monitor.c @@ -24,8 +24,6 @@ #include "nm-session-monitor.h" #include -#include -#include #include #if SESSION_TRACKING_SYSTEMD && SESSION_TRACKING_ELOGIND diff --git a/src/nm-sleep-monitor.c b/src/nm-sleep-monitor.c index 54d757730f..7e0ebe6c1c 100644 --- a/src/nm-sleep-monitor.c +++ b/src/nm-sleep-monitor.c @@ -21,8 +21,6 @@ #include "nm-sleep-monitor.h" -#include -#include #include #include diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c index 814d9cea24..3046615954 100644 --- a/src/platform/nm-fake-platform.c +++ b/src/platform/nm-fake-platform.c @@ -22,7 +22,6 @@ #include "nm-fake-platform.h" -#include #include #include #include diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index f1508d5502..748d2c572d 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c index d4a598f08c..75eba0ba08 100644 --- a/src/platform/nm-platform-utils.c +++ b/src/platform/nm-platform-utils.c @@ -22,9 +22,7 @@ #include "nm-platform-utils.h" -#include #include -#include #include #include #include diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 4bb31b1742..ba7357020f 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -23,13 +23,11 @@ #include "nm-platform.h" #include -#include #include #include #include #include #include -#include #include #include #include diff --git a/src/platform/nmp-netns.c b/src/platform/nmp-netns.c index 3e71cb9462..8a71ff61d5 100644 --- a/src/platform/nmp-netns.c +++ b/src/platform/nmp-netns.c @@ -23,7 +23,6 @@ #include "nmp-netns.h" #include -#include #include #include #include diff --git a/src/platform/tests/test-common.h b/src/platform/tests/test-common.h index 048fd9dd8d..aa1f54606b 100644 --- a/src/platform/tests/test-common.h +++ b/src/platform/tests/test-common.h @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/src/platform/wifi/nm-wifi-utils-nl80211.c b/src/platform/wifi/nm-wifi-utils-nl80211.c index 0df3d2d823..80f316f880 100644 --- a/src/platform/wifi/nm-wifi-utils-nl80211.c +++ b/src/platform/wifi/nm-wifi-utils-nl80211.c @@ -24,8 +24,6 @@ #include "nm-wifi-utils-nl80211.h" -#include -#include #include #include #include diff --git a/src/platform/wifi/nm-wifi-utils-wext.c b/src/platform/wifi/nm-wifi-utils-wext.c index 597f315249..9b8be8de6a 100644 --- a/src/platform/wifi/nm-wifi-utils-wext.c +++ b/src/platform/wifi/nm-wifi-utils-wext.c @@ -23,8 +23,6 @@ #include "nm-wifi-utils-wext.h" -#include -#include #include #include #include diff --git a/src/platform/wifi/nm-wifi-utils.c b/src/platform/wifi/nm-wifi-utils.c index 25d71c6a88..96071faa25 100644 --- a/src/platform/wifi/nm-wifi-utils.c +++ b/src/platform/wifi/nm-wifi-utils.c @@ -25,7 +25,6 @@ #include #include -#include #include #include "nm-wifi-utils-private.h" diff --git a/src/ppp/nm-ppp-manager-call.c b/src/ppp/nm-ppp-manager-call.c index 8f6584167a..d951e4fd1a 100644 --- a/src/ppp/nm-ppp-manager-call.c +++ b/src/ppp/nm-ppp-manager-call.c @@ -24,7 +24,6 @@ #include #include -#include #include "nm-manager.h" #include "nm-core-utils.h" diff --git a/src/ppp/nm-ppp-manager.c b/src/ppp/nm-ppp-manager.c index 548f46606f..2f6cb03294 100644 --- a/src/ppp/nm-ppp-manager.c +++ b/src/ppp/nm-ppp-manager.c @@ -26,11 +26,9 @@ #include #include #include -#include #include #include #include -#include #include #include #include diff --git a/src/ppp/nm-pppd-plugin.c b/src/ppp/nm-pppd-plugin.c index 5e99be4112..a8d6749a43 100644 --- a/src/ppp/nm-pppd-plugin.c +++ b/src/ppp/nm-pppd-plugin.c @@ -22,7 +22,6 @@ #include #define ___CONFIG_H__ -#include #include #include #include diff --git a/src/settings/nm-agent-manager.c b/src/settings/nm-agent-manager.c index edadee14bf..8924c39f42 100644 --- a/src/settings/nm-agent-manager.c +++ b/src/settings/nm-agent-manager.c @@ -22,7 +22,6 @@ #include "nm-agent-manager.h" -#include #include #include "nm-common-macros.h" diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index 04ad5bf9cd..8d1f95833f 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -23,8 +23,6 @@ #include "nm-settings-connection.h" -#include - #include "c-list/src/c-list.h" #include "nm-common-macros.h" diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index 74de6cc2ad..da910368cb 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -29,8 +29,6 @@ #include #include -#include -#include #include #include diff --git a/src/settings/plugins/ibft/nms-ibft-connection.c b/src/settings/plugins/ibft/nms-ibft-connection.c index fb7f18f8d3..a36d8a3101 100644 --- a/src/settings/plugins/ibft/nms-ibft-connection.c +++ b/src/settings/plugins/ibft/nms-ibft-connection.c @@ -22,7 +22,6 @@ #include "nms-ibft-connection.h" -#include #include #include #include diff --git a/src/settings/plugins/ibft/nms-ibft-plugin.c b/src/settings/plugins/ibft/nms-ibft-plugin.c index 69dd3733e9..00b25068fc 100644 --- a/src/settings/plugins/ibft/nms-ibft-plugin.c +++ b/src/settings/plugins/ibft/nms-ibft-plugin.c @@ -22,9 +22,7 @@ #include "nms-ibft-plugin.h" -#include #include -#include #include #include "nm-setting-connection.h" diff --git a/src/settings/plugins/ibft/nms-ibft-reader.c b/src/settings/plugins/ibft/nms-ibft-reader.c index ac5824a167..c6c1437651 100644 --- a/src/settings/plugins/ibft/nms-ibft-reader.c +++ b/src/settings/plugins/ibft/nms-ibft-reader.c @@ -23,13 +23,11 @@ #include "nms-ibft-reader.h" #include -#include #include #include #include #include #include -#include #include #include diff --git a/src/settings/plugins/ibft/tests/test-ibft.c b/src/settings/plugins/ibft/tests/test-ibft.c index 5e46be2eb5..4c45f574d2 100644 --- a/src/settings/plugins/ibft/tests/test-ibft.c +++ b/src/settings/plugins/ibft/tests/test-ibft.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/src/settings/plugins/ifcfg-rh/nm-inotify-helper.c b/src/settings/plugins/ifcfg-rh/nm-inotify-helper.c index e7a74a1aea..bed127fa43 100644 --- a/src/settings/plugins/ifcfg-rh/nm-inotify-helper.c +++ b/src/settings/plugins/ifcfg-rh/nm-inotify-helper.c @@ -23,9 +23,7 @@ #include "nm-inotify-helper.h" #include -#include #include -#include #include "NetworkManagerUtils.h" diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c index ca319ddc61..4f769c5f7a 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c @@ -22,7 +22,6 @@ #include "nms-ifcfg-rh-connection.h" -#include #include #include diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c index 05d4d7386b..89272edbb3 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c @@ -25,9 +25,7 @@ #include "nms-ifcfg-rh-plugin.h" -#include #include -#include #include #include #include diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c index eafb0af37c..d7fc5da1ba 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -23,13 +23,11 @@ #include "nms-ifcfg-rh-reader.h" #include -#include #include #include #include #include #include -#include #include #include diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c index 49096d262f..22c9061b8a 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c @@ -23,7 +23,6 @@ #include "nms-ifcfg-rh-utils.h" #include -#include #include "nm-core-internal.h" #include "NetworkManagerUtils.h" diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c index 90311e90c7..ee7fd16157 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -22,11 +22,9 @@ #include "nms-ifcfg-rh-writer.h" -#include #include #include #include -#include #include #include #include diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 1995d72474..ac150b74f1 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -27,11 +27,9 @@ #include "shvar.h" -#include #include #include #include -#include #include #include #include diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index e46ea0ee10..108e7f677e 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-connection.c b/src/settings/plugins/ifupdown/nms-ifupdown-connection.c index 1b81704420..d06078a97d 100644 --- a/src/settings/plugins/ifupdown/nms-ifupdown-connection.c +++ b/src/settings/plugins/ifupdown/nms-ifupdown-connection.c @@ -24,7 +24,6 @@ #include "nms-ifupdown-connection.h" -#include #include #include "nm-dbus-interface.h" diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c b/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c index 73ecc2f9c6..6587fc8491 100644 --- a/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c +++ b/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c @@ -26,7 +26,6 @@ #include #include -#include #include #include diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-parser.c b/src/settings/plugins/ifupdown/nms-ifupdown-parser.c index 2ee3f17532..fd5561ae7f 100644 --- a/src/settings/plugins/ifupdown/nms-ifupdown-parser.c +++ b/src/settings/plugins/ifupdown/nms-ifupdown-parser.c @@ -25,10 +25,8 @@ #include "nms-ifupdown-parser.h" -#include #include #include -#include #include #include "nm-core-internal.h" diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c b/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c index b66eedc70a..317de633a2 100644 --- a/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c +++ b/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c @@ -26,7 +26,6 @@ #include "nms-ifupdown-plugin.h" -#include #include #include diff --git a/src/settings/plugins/ifupdown/tests/test-ifupdown.c b/src/settings/plugins/ifupdown/tests/test-ifupdown.c index 82ee1c4acc..674cb19c49 100644 --- a/src/settings/plugins/ifupdown/tests/test-ifupdown.c +++ b/src/settings/plugins/ifupdown/tests/test-ifupdown.c @@ -20,8 +20,6 @@ #include "nm-default.h" -#include - #include "nm-core-internal.h" #include "settings/plugins/ifupdown/nms-ifupdown-interface-parser.h" diff --git a/src/settings/plugins/keyfile/nms-keyfile-connection.c b/src/settings/plugins/keyfile/nms-keyfile-connection.c index 7511f206ad..3b362978a2 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-connection.c +++ b/src/settings/plugins/keyfile/nms-keyfile-connection.c @@ -23,7 +23,6 @@ #include "nms-keyfile-connection.h" -#include #include #include "nm-dbus-interface.h" diff --git a/src/settings/plugins/keyfile/nms-keyfile-plugin.c b/src/settings/plugins/keyfile/nms-keyfile-plugin.c index ae9bea13f3..c13cc1ff95 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-plugin.c +++ b/src/settings/plugins/keyfile/nms-keyfile-plugin.c @@ -26,8 +26,6 @@ #include #include #include -#include - #include #include "nm-connection.h" diff --git a/src/settings/plugins/keyfile/nms-keyfile-reader.c b/src/settings/plugins/keyfile/nms-keyfile-reader.c index 314b103392..5778f13c15 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-reader.c +++ b/src/settings/plugins/keyfile/nms-keyfile-reader.c @@ -23,7 +23,6 @@ #include "nms-keyfile-reader.h" #include -#include #include "nm-keyfile-internal.h" diff --git a/src/settings/plugins/keyfile/nms-keyfile-utils.c b/src/settings/plugins/keyfile/nms-keyfile-utils.c index 8d4ec943c4..3e83e16be9 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-utils.c +++ b/src/settings/plugins/keyfile/nms-keyfile-utils.c @@ -23,7 +23,6 @@ #include "nms-keyfile-utils.h" #include -#include #include #include "nm-keyfile-internal.h" diff --git a/src/settings/plugins/keyfile/nms-keyfile-writer.c b/src/settings/plugins/keyfile/nms-keyfile-writer.c index 23a6a77c27..6e2f5b1909 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-writer.c +++ b/src/settings/plugins/keyfile/nms-keyfile-writer.c @@ -26,8 +26,6 @@ #include #include #include -#include -#include #include "nm-keyfile-internal.h" diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c index cdc9bfb0c6..15c7f5b3b1 100644 --- a/src/settings/plugins/keyfile/tests/test-keyfile.c +++ b/src/settings/plugins/keyfile/tests/test-keyfile.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/src/supplicant/nm-supplicant-config.c b/src/supplicant/nm-supplicant-config.c index f004968e70..0b269f11c9 100644 --- a/src/supplicant/nm-supplicant-config.c +++ b/src/supplicant/nm-supplicant-config.c @@ -23,7 +23,6 @@ #include "nm-supplicant-config.h" -#include #include #include "nm-core-internal.h" diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c index 8a362e947f..82354df01b 100644 --- a/src/supplicant/nm-supplicant-interface.c +++ b/src/supplicant/nm-supplicant-interface.c @@ -25,7 +25,6 @@ #include "nm-supplicant-manager.h" #include -#include #include "NetworkManagerUtils.h" #include "nm-supplicant-config.h" diff --git a/src/supplicant/nm-supplicant-manager.c b/src/supplicant/nm-supplicant-manager.c index 97b3f4cec8..2af825e43e 100644 --- a/src/supplicant/nm-supplicant-manager.c +++ b/src/supplicant/nm-supplicant-manager.c @@ -23,8 +23,6 @@ #include "nm-supplicant-manager.h" -#include - #include "nm-supplicant-interface.h" #include "nm-supplicant-types.h" #include "nm-core-internal.h" diff --git a/src/supplicant/nm-supplicant-settings-verify.c b/src/supplicant/nm-supplicant-settings-verify.c index 857a6b6b42..2ed918b602 100644 --- a/src/supplicant/nm-supplicant-settings-verify.c +++ b/src/supplicant/nm-supplicant-settings-verify.c @@ -24,8 +24,6 @@ #include #include -#include -#include struct Opt { const char * key; diff --git a/src/supplicant/tests/test-supplicant-config.c b/src/supplicant/tests/test-supplicant-config.c index a4d798ca85..2c7a71a3ea 100644 --- a/src/supplicant/tests/test-supplicant-config.c +++ b/src/supplicant/tests/test-supplicant-config.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/src/systemd/src/libsystemd-network/dhcp-network.c b/src/systemd/src/libsystemd-network/dhcp-network.c index ba59690817..2eedd4dd4b 100644 --- a/src/systemd/src/libsystemd-network/dhcp-network.c +++ b/src/systemd/src/libsystemd-network/dhcp-network.c @@ -5,7 +5,6 @@ #include "nm-sd-adapt-core.h" -#include #include #include #include diff --git a/src/systemd/src/libsystemd-network/dhcp-option.c b/src/systemd/src/libsystemd-network/dhcp-option.c index b065ae499e..c5fbe749de 100644 --- a/src/systemd/src/libsystemd-network/dhcp-option.c +++ b/src/systemd/src/libsystemd-network/dhcp-option.c @@ -5,7 +5,6 @@ #include "nm-sd-adapt-core.h" -#include #include #include #include diff --git a/src/systemd/src/libsystemd-network/dhcp-packet.c b/src/systemd/src/libsystemd-network/dhcp-packet.c index 9e565e2887..91e8a54eca 100644 --- a/src/systemd/src/libsystemd-network/dhcp-packet.c +++ b/src/systemd/src/libsystemd-network/dhcp-packet.c @@ -5,7 +5,6 @@ #include "nm-sd-adapt-core.h" -#include #include #include #include diff --git a/src/systemd/src/libsystemd-network/dhcp6-network.c b/src/systemd/src/libsystemd-network/dhcp6-network.c index 73c195a71a..d786756e85 100644 --- a/src/systemd/src/libsystemd-network/dhcp6-network.c +++ b/src/systemd/src/libsystemd-network/dhcp6-network.c @@ -5,7 +5,6 @@ #include "nm-sd-adapt-core.h" -#include #include #include #include diff --git a/src/systemd/src/libsystemd-network/dhcp6-option.c b/src/systemd/src/libsystemd-network/dhcp6-option.c index 5a83aaaa45..3d5abe64af 100644 --- a/src/systemd/src/libsystemd-network/dhcp6-option.c +++ b/src/systemd/src/libsystemd-network/dhcp6-option.c @@ -5,7 +5,6 @@ #include "nm-sd-adapt-core.h" -#include #include #include diff --git a/src/systemd/src/libsystemd-network/sd-dhcp-client.c b/src/systemd/src/libsystemd-network/sd-dhcp-client.c index 2f9244d871..20429306bd 100644 --- a/src/systemd/src/libsystemd-network/sd-dhcp-client.c +++ b/src/systemd/src/libsystemd-network/sd-dhcp-client.c @@ -5,7 +5,6 @@ #include "nm-sd-adapt-core.h" -#include #include #include #include diff --git a/src/systemd/src/libsystemd-network/sd-dhcp-lease.c b/src/systemd/src/libsystemd-network/sd-dhcp-lease.c index fc5077c2b2..8359d077ee 100644 --- a/src/systemd/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/systemd/src/libsystemd-network/sd-dhcp-lease.c @@ -6,7 +6,6 @@ #include "nm-sd-adapt-core.h" #include -#include #include #include #include diff --git a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c index 6b55083ec6..39dc881a41 100644 --- a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c @@ -5,7 +5,6 @@ #include "nm-sd-adapt-core.h" -#include #include #include #include diff --git a/src/systemd/src/libsystemd-network/sd-dhcp6-lease.c b/src/systemd/src/libsystemd-network/sd-dhcp6-lease.c index 48188bf3ec..7263c96f0d 100644 --- a/src/systemd/src/libsystemd-network/sd-dhcp6-lease.c +++ b/src/systemd/src/libsystemd-network/sd-dhcp6-lease.c @@ -5,7 +5,6 @@ #include "nm-sd-adapt-core.h" -#include #include "alloc-util.h" #include "dhcp6-lease-internal.h" diff --git a/src/systemd/src/libsystemd-network/sd-ipv4acd.c b/src/systemd/src/libsystemd-network/sd-ipv4acd.c index b43da6b496..6de4adb535 100644 --- a/src/systemd/src/libsystemd-network/sd-ipv4acd.c +++ b/src/systemd/src/libsystemd-network/sd-ipv4acd.c @@ -6,7 +6,6 @@ #include "nm-sd-adapt-core.h" #include -#include #include #include #include diff --git a/src/systemd/src/libsystemd-network/sd-ipv4ll.c b/src/systemd/src/libsystemd-network/sd-ipv4ll.c index f1b94829af..8b1e966589 100644 --- a/src/systemd/src/libsystemd-network/sd-ipv4ll.c +++ b/src/systemd/src/libsystemd-network/sd-ipv4ll.c @@ -6,7 +6,6 @@ #include "nm-sd-adapt-core.h" #include -#include #include #include #include diff --git a/src/systemd/src/libsystemd/sd-event/event-util.c b/src/systemd/src/libsystemd/sd-event/event-util.c index e8384cfd6b..2afacfe64a 100644 --- a/src/systemd/src/libsystemd/sd-event/event-util.c +++ b/src/systemd/src/libsystemd/sd-event/event-util.c @@ -2,7 +2,6 @@ #include "nm-sd-adapt-core.h" -#include #include "event-source.h" #include "event-util.h" diff --git a/src/systemd/src/libsystemd/sd-id128/id128-util.c b/src/systemd/src/libsystemd/sd-id128/id128-util.c index f8f0883caf..6245e9dfff 100644 --- a/src/systemd/src/libsystemd/sd-id128/id128-util.c +++ b/src/systemd/src/libsystemd/sd-id128/id128-util.c @@ -2,7 +2,6 @@ #include "nm-sd-adapt-core.h" -#include #include #include diff --git a/src/systemd/src/libsystemd/sd-id128/sd-id128.c b/src/systemd/src/libsystemd/sd-id128/sd-id128.c index a476017b35..13a2829112 100644 --- a/src/systemd/src/libsystemd/sd-id128/sd-id128.c +++ b/src/systemd/src/libsystemd/sd-id128/sd-id128.c @@ -2,7 +2,6 @@ #include "nm-sd-adapt-core.h" -#include #include #include diff --git a/src/systemd/src/shared/dns-domain.h b/src/systemd/src/shared/dns-domain.h index 88b3eb112c..17db7c5274 100644 --- a/src/systemd/src/shared/dns-domain.h +++ b/src/systemd/src/shared/dns-domain.h @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #pragma once -#include #include #include #include diff --git a/src/tests/config/nm-test-device.c b/src/tests/config/nm-test-device.c index 4963158340..c21317692a 100644 --- a/src/tests/config/nm-test-device.c +++ b/src/tests/config/nm-test-device.c @@ -22,8 +22,6 @@ #include "nm-test-device.h" -#include - #include "devices/nm-device-private.h" #include "nm-utils.h" diff --git a/src/tests/test-dcb.c b/src/tests/test-dcb.c index 2ab0f89056..6291f254c7 100644 --- a/src/tests/test-dcb.c +++ b/src/tests/test-dcb.c @@ -20,8 +20,6 @@ #include "nm-default.h" -#include - #include "nm-dcb.h" #include "nm-test-utils-core.h" diff --git a/src/tests/test-general-with-expect.c b/src/tests/test-general-with-expect.c index ba8e3ce4cb..dd720ac712 100644 --- a/src/tests/test-general-with-expect.c +++ b/src/tests/test-general-with-expect.c @@ -20,8 +20,6 @@ #include "nm-default.h" -#include -#include #include #include #include diff --git a/src/tests/test-general.c b/src/tests/test-general.c index 79e73cdc55..f4bb820d9c 100644 --- a/src/tests/test-general.c +++ b/src/tests/test-general.c @@ -20,8 +20,6 @@ #include "nm-default.h" -#include -#include #include #include diff --git a/src/tests/test-ip4-config.c b/src/tests/test-ip4-config.c index 9fea6af5b1..f98c84c3ba 100644 --- a/src/tests/test-ip4-config.c +++ b/src/tests/test-ip4-config.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include "nm-ip4-config.h" diff --git a/src/tests/test-ip6-config.c b/src/tests/test-ip6-config.c index 51807dea6b..8f5f41d73f 100644 --- a/src/tests/test-ip6-config.c +++ b/src/tests/test-ip6-config.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include diff --git a/src/tests/test-utils.c b/src/tests/test-utils.c index 9572ec7a51..c326f790cb 100644 --- a/src/tests/test-utils.c +++ b/src/tests/test-utils.c @@ -20,8 +20,6 @@ #include "nm-default.h" -#include -#include #include #include "nm-test-utils-core.h" diff --git a/src/vpn/nm-vpn-connection.c b/src/vpn/nm-vpn-connection.c index c7cfcdcdfd..b2ed6999bd 100644 --- a/src/vpn/nm-vpn-connection.c +++ b/src/vpn/nm-vpn-connection.c @@ -23,11 +23,9 @@ #include "nm-vpn-connection.h" -#include #include #include #include -#include #include #include #include diff --git a/src/vpn/nm-vpn-manager.c b/src/vpn/nm-vpn-manager.c index d063916873..0b27b9de3b 100644 --- a/src/vpn/nm-vpn-manager.c +++ b/src/vpn/nm-vpn-manager.c @@ -23,8 +23,6 @@ #include "nm-vpn-manager.h" -#include - #include "nm-vpn-plugin-info.h" #include "nm-vpn-connection.h" #include "nm-setting-vpn.h" From b7bb7449738b8fd3eee545af7fa5efd004718431 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 31 Jan 2019 13:40:53 +0100 Subject: [PATCH 03/13] libnm,core: use _nm_utils_ascii_str_to_uint64() instead of strtol() Using strtol() correctly proves to be hard. Usually, we want to also check that the end pointer is points to the end of the string. Othewise, we silently accept trailing garbage. --- clients/tui/newt/nmt-newt-entry-numeric.c | 4 ++-- libnm-core/nm-setting-bond.c | 17 ++++++----------- src/supplicant/nm-supplicant-settings-verify.c | 16 +++------------- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/clients/tui/newt/nmt-newt-entry-numeric.c b/clients/tui/newt/nmt-newt-entry-numeric.c index a52fe8689f..92855fcb2c 100644 --- a/clients/tui/newt/nmt-newt-entry-numeric.c +++ b/clients/tui/newt/nmt-newt-entry-numeric.c @@ -127,8 +127,8 @@ newt_entry_numeric_validate (NmtNewtEntry *entry, if (!*text) return priv->optional ? TRUE : FALSE; - val = _nm_utils_ascii_str_to_int64 (text, 10, priv->min, priv->max, 0); - return val != 0 || errno == 0; + val = _nm_utils_ascii_str_to_int64 (text, 10, priv->min, priv->max, G_MAXINT64); + return val != G_MAXINT64 || errno == 0; } static void diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c index b36ed20851..51ce2debbc 100644 --- a/libnm-core/nm-setting-bond.c +++ b/libnm-core/nm-setting-bond.c @@ -175,19 +175,14 @@ nm_setting_bond_get_option (NMSettingBond *setting, static gboolean validate_int (const char *name, const char *value, const BondDefault *def) { - long num; - guint i; + guint64 num; - for (i = 0; i < strlen (value); i++) { - if (!g_ascii_isdigit (value[i]) && value[i] != '-') - return FALSE; - } - - errno = 0; - num = strtol (value, NULL, 10); - if (errno) + if (!NM_STRCHAR_ALL (value, ch, g_ascii_isdigit (ch))) return FALSE; - if (num < def->min || num > def->max) + + num = _nm_utils_ascii_str_to_uint64 (value, 10, def->min, def->max, G_MAXUINT64); + if ( num == G_MAXUINT64 + && errno != 0) return FALSE; return TRUE; diff --git a/src/supplicant/nm-supplicant-settings-verify.c b/src/supplicant/nm-supplicant-settings-verify.c index 2ed918b602..f10bbb0431 100644 --- a/src/supplicant/nm-supplicant-settings-verify.c +++ b/src/supplicant/nm-supplicant-settings-verify.c @@ -157,23 +157,13 @@ validate_type_int (const struct Opt * opt, const char * value, const guint32 len) { - long int intval; + gint64 v; g_return_val_if_fail (opt != NULL, FALSE); g_return_val_if_fail (value != NULL, FALSE); - errno = 0; - intval = strtol (value, NULL, 10); - if (errno != 0) - return FALSE; - - /* strtol returns a long, but we are dealing with ints */ - if (intval > INT_MAX || intval < INT_MIN) - return FALSE; - if (intval > opt->int_high || intval < opt->int_low) - return FALSE; - - return TRUE; + v = _nm_utils_ascii_str_to_int64 (value, 10, opt->int_low, opt->int_high, G_MININT64); + return v != G_MININT64 || errno == 0; } static gboolean From 047998f80a8686f5200cd48d31349c977f9a50b7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 31 Jan 2019 13:29:21 +0100 Subject: [PATCH 04/13] all: cache errno in local variable before using it --- clients/cli/utils.c | 32 +++++++----- libnm-glib/nm-vpn-plugin-utils.c | 1 - libnm/nm-vpn-service-plugin.c | 1 - shared/nm-utils/nm-io-utils.c | 51 +++++++++++-------- shared/nm-utils/nm-shared-utils.c | 8 +-- src/devices/adsl/nm-device-adsl.c | 4 +- src/devices/bluetooth/nm-bluez5-dun.c | 18 ++++--- src/devices/wifi/nm-iwd-manager.c | 8 ++- src/dhcp/nm-dhcp-dhclient.c | 10 ++-- src/dhcp/nm-dhcp-dhcpcanon.c | 7 ++- src/dhcp/nm-dhcp-dhcpcd.c | 7 ++- src/dhcp/nm-dhcp-utils.c | 2 +- src/dns/nm-dns-manager.c | 18 ++++--- src/initrd/nm-initrd-generator.c | 4 +- src/main-utils.c | 17 ++++--- src/main.c | 9 ++-- src/nm-audit-manager.c | 8 +-- src/nm-config-data.c | 1 - src/nm-iface-helper.c | 12 ++--- src/nm-logging.c | 6 +-- src/nm-manager.c | 5 +- src/nm-policy.c | 8 +-- src/nm-session-monitor.c | 4 +- src/platform/nm-linux-platform.c | 24 +++++---- src/platform/nm-netlink.c | 7 +-- src/platform/nm-platform-utils.c | 7 ++- src/platform/wifi/nm-wifi-utils-wext.c | 24 +++++---- src/ppp/nm-ppp-manager.c | 24 +++++---- .../plugins/ifcfg-rh/nm-inotify-helper.c | 4 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-reader.c | 3 +- src/settings/plugins/ifcfg-rh/shvar.c | 10 ++-- .../plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 8 ++- .../plugins/keyfile/tests/test-keyfile.c | 9 +++- src/tests/test-general-with-expect.c | 3 +- 34 files changed, 217 insertions(+), 147 deletions(-) diff --git a/clients/cli/utils.c b/clients/cli/utils.c index f23e079c96..b3190b085c 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -1426,19 +1426,20 @@ pager_fallback (void) { char buf[64]; int rb; + int errsv; do { rb = read (STDIN_FILENO, buf, sizeof (buf)); if (rb == -1) { - if (errno == EINTR) { + errsv = errno; + if (errsv == EINTR) continue; - } else { - g_printerr (_("Error reading nmcli output: %s\n"), strerror (errno)); - _exit(EXIT_FAILURE); - } + g_printerr (_("Error reading nmcli output: %s\n"), strerror (errsv)); + _exit(EXIT_FAILURE); } if (write (STDOUT_FILENO, buf, rb) == -1) { - g_printerr (_("Error writing nmcli output: %s\n"), strerror (errno)); + errsv = errno; + g_printerr (_("Error writing nmcli output: %s\n"), strerror (errsv)); _exit(EXIT_FAILURE); } } while (rb > 0); @@ -1453,6 +1454,7 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config) pid_t pager_pid; pid_t parent_pid; int fd[2]; + int errsv; if ( nmc_config->in_editor || nmc_config->print_output == NMC_PRINT_TERSE @@ -1462,7 +1464,8 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config) return 0; if (pipe (fd) == -1) { - g_printerr (_("Failed to create pager pipe: %s\n"), strerror (errno)); + errsv = errno; + g_printerr (_("Failed to create pager pipe: %s\n"), strerror (errsv)); return 0; } @@ -1470,7 +1473,8 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config) pager_pid = fork (); if (pager_pid == -1) { - g_printerr (_("Failed to fork pager: %s\n"), strerror (errno)); + errsv = errno; + g_printerr (_("Failed to fork pager: %s\n"), strerror (errsv)); nm_close (fd[0]); nm_close (fd[1]); return 0; @@ -1515,10 +1519,14 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config) } /* Return in the parent */ - if (dup2 (fd[1], STDOUT_FILENO) < 0) - g_printerr (_("Failed to duplicate pager pipe: %s\n"), strerror (errno)); - if (dup2 (fd[1], STDERR_FILENO) < 0) - g_printerr (_("Failed to duplicate pager pipe: %s\n"), strerror (errno)); + if (dup2 (fd[1], STDOUT_FILENO) < 0) { + errsv = errno; + g_printerr (_("Failed to duplicate pager pipe: %s\n"), strerror (errsv)); + } + if (dup2 (fd[1], STDERR_FILENO) < 0) { + errsv = errno; + g_printerr (_("Failed to duplicate pager pipe: %s\n"), strerror (errsv)); + } nm_close (fd[0]); nm_close (fd[1]); diff --git a/libnm-glib/nm-vpn-plugin-utils.c b/libnm-glib/nm-vpn-plugin-utils.c index e2bc42896c..30949d1973 100644 --- a/libnm-glib/nm-vpn-plugin-utils.c +++ b/libnm-glib/nm-vpn-plugin-utils.c @@ -82,7 +82,6 @@ nm_vpn_plugin_utils_read_vpn_details (int fd, ssize_t nr; GHashTable *hash = NULL; - errno = 0; nr = read (fd, &c, 1); if (nr == -1) { if (errno == EAGAIN) { diff --git a/libnm/nm-vpn-service-plugin.c b/libnm/nm-vpn-service-plugin.c index 57b36e69b5..5e3c0641f3 100644 --- a/libnm/nm-vpn-service-plugin.c +++ b/libnm/nm-vpn-service-plugin.c @@ -807,7 +807,6 @@ nm_vpn_service_plugin_read_vpn_details (int fd, while (1) { ssize_t nr; - errno = 0; nr = read (fd, &c, 1); if (nr < 0) { if (errno == EAGAIN) { diff --git a/shared/nm-utils/nm-io-utils.c b/shared/nm-utils/nm-io-utils.c index 06f756c412..ac16ff97f2 100644 --- a/shared/nm-utils/nm-io-utils.c +++ b/shared/nm-utils/nm-io-utils.c @@ -36,10 +36,11 @@ _nm_printf (3, 4) static int _get_contents_error (GError **error, int errsv, const char *format, ...) { - if (errsv < 0) - errsv = -errsv; - else if (!errsv) - errsv = errno; + if (errsv < 0) { + errsv = errsv == G_MININT + ? G_MAXINT + : -errsv; + } if (error) { char *msg; @@ -57,6 +58,12 @@ _get_contents_error (GError **error, int errsv, const char *format, ...) } return -errsv; } +#define _get_contents_error_errno(error, ...) \ + ({ \ + int _errsv = (errno); \ + \ + _get_contents_error (error, _errsv, __VA_ARGS__); \ + }) static char * _mem_realloc (char *old, gboolean do_bzero_mem, gsize cur_len, gsize new_len) @@ -127,13 +134,14 @@ nm_utils_fd_get_contents (int fd, struct stat stat_buf; gs_free char *str = NULL; const bool do_bzero_mem = NM_FLAGS_HAS (flags, NM_UTILS_FILE_GET_CONTENTS_FLAG_SECRET); + int errsv; g_return_val_if_fail (fd >= 0, -EINVAL); g_return_val_if_fail (contents, -EINVAL); g_return_val_if_fail (!error || !*error, -EINVAL); if (fstat (fd, &stat_buf) < 0) - return _get_contents_error (error, 0, "failure during fstat"); + return _get_contents_error_errno (error, "failure during fstat"); if (!max_length) { /* default to a very large size, but not extreme */ @@ -156,7 +164,7 @@ nm_utils_fd_get_contents (int fd, if (n_read < 0) { if (do_bzero_mem) nm_explicit_bzero (str, n_stat); - return _get_contents_error (error, n_read, "error reading %zu bytes from file descriptor", n_stat); + return _get_contents_error (error, -n_read, "error reading %zu bytes from file descriptor", n_stat); } str[n_read] = '\0'; @@ -176,19 +184,19 @@ nm_utils_fd_get_contents (int fd, else { fd2 = fcntl (fd, F_DUPFD_CLOEXEC, 0); if (fd2 < 0) - return _get_contents_error (error, 0, "error during dup"); + return _get_contents_error_errno (error, "error during dup"); } if (!(f = fdopen (fd2, "r"))) { + errsv = errno; nm_close (fd2); - return _get_contents_error (error, 0, "failure during fdopen"); + return _get_contents_error (error, errsv, "failure during fdopen"); } n_have = 0; n_alloc = 0; while (!feof (f)) { - int errsv; gsize n_read; n_read = fread (buf, 1, sizeof (buf), f); @@ -395,20 +403,21 @@ nm_utils_file_set_contents (const char *filename, * guarantee the data is written to the disk before the metadata.) */ if ( lstat (filename, &statbuf) == 0 - && statbuf.st_size > 0 - && fsync (fd) != 0) { - errsv = errno; + && statbuf.st_size > 0) { + if (fsync (fd) != 0) { + errsv = errno; - nm_close (fd); - unlink (tmp_name); + nm_close (fd); + unlink (tmp_name); - g_set_error (error, - G_FILE_ERROR, - g_file_error_from_errno (errsv), - "failed to fsync %s: %s", - tmp_name, - g_strerror (errsv)); - return FALSE; + g_set_error (error, + G_FILE_ERROR, + g_file_error_from_errno (errsv), + "failed to fsync %s: %s", + tmp_name, + g_strerror (errsv)); + return FALSE; + } } nm_close (fd); diff --git a/shared/nm-utils/nm-shared-utils.c b/shared/nm-utils/nm-shared-utils.c index db97111193..860d4c18a6 100644 --- a/shared/nm-utils/nm-shared-utils.c +++ b/shared/nm-utils/nm-shared-utils.c @@ -1769,10 +1769,12 @@ nm_utils_fd_read_loop (int fd, void *buf, size_t nbytes, bool do_poll) k = read (fd, p, nbytes); if (k < 0) { - if (errno == EINTR) + int errsv = errno; + + if (errsv == EINTR) continue; - if (errno == EAGAIN && do_poll) { + if (errsv == EAGAIN && do_poll) { /* We knowingly ignore any return value here, * and expect that any error/EOF is reported @@ -1782,7 +1784,7 @@ nm_utils_fd_read_loop (int fd, void *buf, size_t nbytes, bool do_poll) continue; } - return n > 0 ? n : -errno; + return n > 0 ? n : -errsv; } if (k == 0) diff --git a/src/devices/adsl/nm-device-adsl.c b/src/devices/adsl/nm-device-adsl.c index e0501a74b3..89de6e76ca 100644 --- a/src/devices/adsl/nm-device-adsl.c +++ b/src/devices/adsl/nm-device-adsl.c @@ -369,8 +369,8 @@ br2684_create_iface (NMDeviceAdsl *self, priv->nas_update_id = g_timeout_add (100, nas_update_cb, self); return NM_ACT_STAGE_RETURN_POSTPONE; } - if (errno != EEXIST) { - errsv = errno; + errsv = errno; + if (errsv != EEXIST) { _LOGW (LOGD_ADSL, "failed to create br2684 interface (%d)", errsv); break; } diff --git a/src/devices/bluetooth/nm-bluez5-dun.c b/src/devices/bluetooth/nm-bluez5-dun.c index b85a410e8d..ae5efcedfc 100644 --- a/src/devices/bluetooth/nm-bluez5-dun.c +++ b/src/devices/bluetooth/nm-bluez5-dun.c @@ -56,6 +56,7 @@ dun_connect (NMBluez5DunContext *context) char tty[100]; const int ttylen = sizeof (tty) - 1; GError *error = NULL; + int errsv; struct rfcomm_dev_req req = { .flags = (1 << RFCOMM_REUSE_DLC) | (1 << RFCOMM_RELEASE_ONHUP), @@ -65,7 +66,7 @@ dun_connect (NMBluez5DunContext *context) context->rfcomm_fd = socket (AF_BLUETOOTH, SOCK_STREAM | SOCK_CLOEXEC, BTPROTO_RFCOMM); if (context->rfcomm_fd < 0) { - int errsv = errno; + errsv = errno; error = g_error_new (NM_BT_ERROR, NM_BT_ERROR_DUN_CONNECT_FAILED, "Failed to create RFCOMM socket: (%d) %s", errsv, strerror (errsv)); @@ -77,7 +78,7 @@ dun_connect (NMBluez5DunContext *context) sa.rc_channel = 0; memcpy (&sa.rc_bdaddr, &context->src, ETH_ALEN); if (bind (context->rfcomm_fd, (struct sockaddr *) &sa, sizeof(sa))) { - int errsv = errno; + errsv = errno; error = g_error_new (NM_BT_ERROR, NM_BT_ERROR_DUN_CONNECT_FAILED, "Failed to bind socket: (%d) %s", errsv, strerror (errsv)); @@ -87,7 +88,7 @@ dun_connect (NMBluez5DunContext *context) sa.rc_channel = context->rfcomm_channel; memcpy (&sa.rc_bdaddr, &context->dst, ETH_ALEN); if (connect (context->rfcomm_fd, (struct sockaddr *) &sa, sizeof (sa)) ) { - int errsv = errno; + errsv = errno; error = g_error_new (NM_BT_ERROR, NM_BT_ERROR_DUN_CONNECT_FAILED, "Failed to connect to remote device: (%d) %s", errsv, strerror (errsv)); @@ -102,7 +103,7 @@ dun_connect (NMBluez5DunContext *context) memcpy (&req.dst, &context->dst, ETH_ALEN); devid = ioctl (context->rfcomm_fd, RFCOMMCREATEDEV, &req); if (devid < 0) { - int errsv = errno; + errsv = errno; error = g_error_new (NM_BT_ERROR, NM_BT_ERROR_DUN_CONNECT_FAILED, "Failed to create rfcomm device: (%d) %s", errsv, strerror (errsv)); @@ -249,7 +250,8 @@ sdp_connect_watch (GIOChannel *channel, GIOCondition condition, gpointer user_da sdp_list_t *search, *attrs; uuid_t svclass; uint16_t attr; - int fd, err, fd_err = 0; + int fd, fd_err = 0; + int err; socklen_t len = sizeof (fd_err); GError *error = NULL; @@ -257,13 +259,13 @@ sdp_connect_watch (GIOChannel *channel, GIOCondition condition, gpointer user_da fd = g_io_channel_unix_get_fd (channel); if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &fd_err, &len) < 0) { - nm_log_dbg (LOGD_BT, "(%s -> %s): getsockopt error=%d", - context->src_str, context->dst_str, errno); err = errno; + nm_log_dbg (LOGD_BT, "(%s -> %s): getsockopt error=%d", + context->src_str, context->dst_str, err); } else { + err = fd_err; nm_log_dbg (LOGD_BT, "(%s -> %s): SO_ERROR error=%d", context->src_str, context->dst_str, fd_err); - err = fd_err; } if (err != 0) { diff --git a/src/devices/wifi/nm-iwd-manager.c b/src/devices/wifi/nm-iwd-manager.c index c6e2d644e7..d668f0d889 100644 --- a/src/devices/wifi/nm-iwd-manager.c +++ b/src/devices/wifi/nm-iwd-manager.c @@ -136,6 +136,7 @@ agent_dbus_method_cb (GDBusConnection *connection, int ifindex; NMDevice *device; gs_free char *name_owner = NULL; + int errsv; /* Be paranoid and check the sender address */ name_owner = g_dbus_object_manager_client_get_name_owner (G_DBUS_OBJECT_MANAGER_CLIENT (priv->object_manager)); @@ -171,8 +172,9 @@ agent_dbus_method_cb (GDBusConnection *connection, ifindex = if_nametoindex (ifname); if (!ifindex) { + errsv = errno; _LOGD ("agent-request: if_nametoindex failed for Name %s for Device at %s: %i", - ifname, device_path, errno); + ifname, device_path, errsv); goto return_error; } @@ -338,6 +340,7 @@ set_device_dbus_object (NMIwdManager *self, GDBusProxy *proxy, const char *ifname; int ifindex; NMDevice *device; + int errsv; ifname = get_property_string_or_null (proxy, "Name"); if (!ifname) { @@ -349,8 +352,9 @@ set_device_dbus_object (NMIwdManager *self, GDBusProxy *proxy, ifindex = if_nametoindex (ifname); if (!ifindex) { + errsv = errno; _LOGE ("if_nametoindex failed for Name %s for Device at %s: %i", - ifname, g_dbus_proxy_get_object_path (proxy), errno); + ifname, g_dbus_proxy_get_object_path (proxy), errsv); return; } diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c index 6673f9ae9a..3a3f1feae5 100644 --- a/src/dhcp/nm-dhcp-dhclient.c +++ b/src/dhcp/nm-dhcp-dhclient.c @@ -591,16 +591,18 @@ stop (NMDhcpClient *client, gboolean release) { NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client); NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self); + int errsv; NM_DHCP_CLIENT_CLASS (nm_dhcp_dhclient_parent_class)->stop (client, release); if (priv->conf_file) - if (remove (priv->conf_file) == -1) - _LOGD ("could not remove dhcp config file \"%s\": %d (%s)", priv->conf_file, errno, g_strerror (errno)); + if (remove (priv->conf_file) == -1) { + errsv = errno; + _LOGD ("could not remove dhcp config file \"%s\": %d (%s)", priv->conf_file, errsv, g_strerror (errsv)); + } if (priv->pid_file) { if (remove (priv->pid_file) == -1) { - int errsv = errno; - + errsv = errno; _LOGD ("could not remove dhcp pid file \"%s\": %s (%d)", priv->pid_file, g_strerror (errsv), errsv); } nm_clear_g_free (&priv->pid_file); diff --git a/src/dhcp/nm-dhcp-dhcpcanon.c b/src/dhcp/nm-dhcp-dhcpcanon.c index e1495cc6cc..e6bd14e055 100644 --- a/src/dhcp/nm-dhcp-dhcpcanon.c +++ b/src/dhcp/nm-dhcp-dhcpcanon.c @@ -203,12 +203,15 @@ stop (NMDhcpClient *client, gboolean release) { NMDhcpDhcpcanon *self = NM_DHCP_DHCPCANON (client); NMDhcpDhcpcanonPrivate *priv = NM_DHCP_DHCPCANON_GET_PRIVATE (self); + int errsv; NM_DHCP_CLIENT_CLASS (nm_dhcp_dhcpcanon_parent_class)->stop (client, release); if (priv->pid_file) { - if (remove (priv->pid_file) == -1) - _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errno, g_strerror (errno)); + if (remove (priv->pid_file) == -1) { + errsv = errno; + _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errsv, g_strerror (errsv)); + } g_free (priv->pid_file); priv->pid_file = NULL; } diff --git a/src/dhcp/nm-dhcp-dhcpcd.c b/src/dhcp/nm-dhcp-dhcpcd.c index b3d87ee00a..59ffe44132 100644 --- a/src/dhcp/nm-dhcp-dhcpcd.c +++ b/src/dhcp/nm-dhcp-dhcpcd.c @@ -197,12 +197,15 @@ stop (NMDhcpClient *client, gboolean release) { NMDhcpDhcpcd *self = NM_DHCP_DHCPCD (client); NMDhcpDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE (self); + int errsv; NM_DHCP_CLIENT_CLASS (nm_dhcp_dhcpcd_parent_class)->stop (client, release); if (priv->pid_file) { - if (remove (priv->pid_file) == -1) - _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errno, g_strerror (errno)); + if (remove (priv->pid_file) == -1) { + errsv = errno; + _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errsv, g_strerror (errsv)); + } } /* FIXME: implement release... */ diff --git a/src/dhcp/nm-dhcp-utils.c b/src/dhcp/nm-dhcp-utils.c index efd8422b36..3d347427ca 100644 --- a/src/dhcp/nm-dhcp-utils.c +++ b/src/dhcp/nm-dhcp-utils.c @@ -544,7 +544,7 @@ nm_dhcp_utils_ip4_config_from_options (NMDedupMultiIndex *multi_idx, errno = 0; int_mtu = strtol (str, NULL, 10); - if ((errno == EINVAL) || (errno == ERANGE)) + if (NM_IN_SET (errno, EINVAL, ERANGE)) goto error; if (int_mtu > 576) diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c index a6a10f59e4..93426efda6 100644 --- a/src/dns/nm-dns-manager.c +++ b/src/dns/nm-dns-manager.c @@ -535,6 +535,7 @@ dispatch_netconfig (NMDnsManager *self, { GPid pid; int fd; + int errsv; int status; gssize l; nm_auto_free_gstring GString *str = NULL; @@ -565,8 +566,7 @@ again: /* Wait until the process exits */ if (!nm_utils_kill_child_sync (pid, 0, LOGD_DNS, "netconfig", &status, 1000, 0)) { - int errsv = errno; - + errsv = errno; g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, "Error waiting for netconfig to exit: %s", strerror (errsv)); @@ -708,7 +708,8 @@ dispatch_resolvconf (NMDnsManager *self, gs_free char *cmd = NULL; FILE *f; gboolean success = FALSE; - int errnosv, err; + int errsv; + int err; char *argv[] = { RESOLVCONF_PATH, "-d", "NetworkManager", NULL }; int status; @@ -742,12 +743,13 @@ dispatch_resolvconf (NMDnsManager *self, cmd = g_strconcat (RESOLVCONF_PATH, " -a ", "NetworkManager", NULL); if ((f = popen (cmd, "w")) == NULL) { + errsv = errno; g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, "Could not write to %s: %s", RESOLVCONF_PATH, - g_strerror (errno)); + g_strerror (errsv)); return SR_ERROR; } @@ -758,10 +760,10 @@ dispatch_resolvconf (NMDnsManager *self, error); err = pclose (f); if (err < 0) { - errnosv = errno; + errsv = errno; g_clear_error (error); - g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errnosv), - "Failed to close pipe to resolvconf: %d", errnosv); + g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv), + "Failed to close pipe to resolvconf: %d", errsv); return SR_ERROR; } else if (err > 0) { _LOGW ("resolvconf failed with status %d", err); @@ -924,7 +926,7 @@ update_resolv_conf (NMDnsManager *self, NM_MANAGER_ERROR_FAILED, "Could not replace %s: %s", MY_RESOLV_CONF, - g_strerror (errno)); + g_strerror (errsv)); _LOGT ("update-resolv-conf: failed to rename temporary file %s to %s (%s)", MY_RESOLV_CONF_TMP, MY_RESOLV_CONF, g_strerror (errsv)); return SR_ERROR; diff --git a/src/initrd/nm-initrd-generator.c b/src/initrd/nm-initrd-generator.c index 70f23e1774..9946be7df8 100644 --- a/src/initrd/nm-initrd-generator.c +++ b/src/initrd/nm-initrd-generator.c @@ -92,6 +92,7 @@ main (int argc, char *argv[]) }; GOptionContext *option_context; GError *error = NULL; + int errsv; option_context = g_option_context_new ("-- [ip=...] [rd.route=...] [bridge=...] [bond=...] [team=...] [vlan=...] " "[bootdev=...] [nameserver=...] [rd.peerdns=...] [rd.bootif=...] [BOOTIF=...] ... "); @@ -121,7 +122,8 @@ main (int argc, char *argv[]) g_clear_pointer (&connections_dir, g_free); if (connections_dir && g_mkdir_with_parents (connections_dir, 0755) != 0) { - _LOGW (LOGD_CORE, "%s: %s", connections_dir, strerror (errno)); + errsv = errno; + _LOGW (LOGD_CORE, "%s: %s", connections_dir, strerror (errsv)); return 1; } diff --git a/src/main-utils.c b/src/main-utils.c index 753f2c7de4..5799f09559 100644 --- a/src/main-utils.c +++ b/src/main-utils.c @@ -92,21 +92,26 @@ nm_main_utils_write_pidfile (const char *pidfile) { char pid[16]; int fd; + int errsv; gboolean success = FALSE; if ((fd = open (pidfile, O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC, 00644)) < 0) { - fprintf (stderr, _("Opening %s failed: %s\n"), pidfile, strerror (errno)); + errsv = errno; + fprintf (stderr, _("Opening %s failed: %s\n"), pidfile, strerror (errsv)); return FALSE; } g_snprintf (pid, sizeof (pid), "%d", getpid ()); - if (write (fd, pid, strlen (pid)) < 0) - fprintf (stderr, _("Writing to %s failed: %s\n"), pidfile, strerror (errno)); - else + if (write (fd, pid, strlen (pid)) < 0) { + errsv = errno; + fprintf (stderr, _("Writing to %s failed: %s\n"), pidfile, strerror (errsv)); + } else success = TRUE; - if (nm_close (fd)) - fprintf (stderr, _("Closing %s failed: %s\n"), pidfile, strerror (errno)); + if (nm_close (fd)) { + errsv = errno; + fprintf (stderr, _("Closing %s failed: %s\n"), pidfile, strerror (errsv)); + } return success; } diff --git a/src/main.c b/src/main.c index b52b9347c4..b9cbdc44ab 100644 --- a/src/main.c +++ b/src/main.c @@ -230,6 +230,7 @@ main (int argc, char *argv[]) guint sd_id = 0; GError *error_invalid_logging_config = NULL; const char *const *warnings; + int errsv; /* Known to cause a possible deadlock upon GDBus initialization: * https://bugzilla.gnome.org/show_bug.cgi?id=674885 */ @@ -331,12 +332,10 @@ main (int argc, char *argv[]) if (global_opt.become_daemon && !nm_config_get_is_debug (config)) { if (daemon (0, 0) < 0) { - int saved_errno; - - saved_errno = errno; + errsv = errno; fprintf (stderr, _("Could not daemonize: %s [error %u]\n"), - g_strerror (saved_errno), - saved_errno); + g_strerror (errsv), + errsv); exit (1); } wrote_pidfile = nm_main_utils_write_pidfile (global_opt.pidfile); diff --git a/src/nm-audit-manager.c b/src/nm-audit-manager.c index 64b8b52513..05fc88cc25 100644 --- a/src/nm-audit-manager.c +++ b/src/nm-audit-manager.c @@ -335,15 +335,17 @@ init_auditd (NMAuditManager *self) { NMAuditManagerPrivate *priv = NM_AUDIT_MANAGER_GET_PRIVATE (self); NMConfigData *data = nm_config_get_data (priv->config); + int errsv; if (nm_config_data_get_value_boolean (data, NM_CONFIG_KEYFILE_GROUP_LOGGING, NM_CONFIG_KEYFILE_KEY_LOGGING_AUDIT, NM_CONFIG_DEFAULT_LOGGING_AUDIT_BOOL)) { if (priv->auditd_fd < 0) { priv->auditd_fd = audit_open (); - if (priv->auditd_fd < 0) - _LOGE (LOGD_CORE, "failed to open auditd socket: %s", strerror (errno)); - else + if (priv->auditd_fd < 0) { + errsv = errno; + _LOGE (LOGD_CORE, "failed to open auditd socket: %s", strerror (errsv)); + } else _LOGD (LOGD_CORE, "socket created"); } } else { diff --git a/src/nm-config-data.c b/src/nm-config-data.c index 3e75e1aa71..608b7e5890 100644 --- a/src/nm-config-data.c +++ b/src/nm-config-data.c @@ -216,7 +216,6 @@ nm_config_data_get_value_int64 (const NMConfigData *self, const char *group, con str = nm_config_keyfile_get_value (NM_CONFIG_DATA_GET_PRIVATE (self)->keyfile, group, key, NM_CONFIG_GET_VALUE_NONE); val = _nm_utils_ascii_str_to_int64 (str, base, min, max, fallback); if (str) { - /* preserve errno from the parsing. */ errsv = errno; g_free (str); errno = errsv; diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index 2dd606a822..a038e79e5b 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -387,6 +387,7 @@ main (int argc, char *argv[]) gs_unref_bytes GBytes *client_id = NULL; gs_free NMUtilsIPv6IfaceId *iid = NULL; guint sd_id; + int errsv; c_list_init (&gl.dad_failed_lst_head); @@ -423,7 +424,8 @@ main (int argc, char *argv[]) gl.ifindex = nmp_utils_if_nametoindex (global_opt.ifname); if (gl.ifindex <= 0) { - fprintf (stderr, _("Failed to find interface index for %s (%s)\n"), global_opt.ifname, strerror (errno)); + errsv = errno; + fprintf (stderr, _("Failed to find interface index for %s (%s)\n"), global_opt.ifname, strerror (errsv)); return 1; } pidfile = g_strdup_printf (NMIH_PID_FILE_FMT, gl.ifindex); @@ -448,12 +450,10 @@ main (int argc, char *argv[]) if (global_opt.become_daemon && !global_opt.debug) { if (daemon (0, 0) < 0) { - int saved_errno; - - saved_errno = errno; + errsv = errno; fprintf (stderr, _("Could not daemonize: %s [error %u]\n"), - g_strerror (saved_errno), - saved_errno); + g_strerror (errsv), + errsv); return 1; } if (nm_main_utils_write_pidfile (pidfile)) diff --git a/src/nm-logging.c b/src/nm-logging.c index d870732641..fed57966a4 100644 --- a/src/nm-logging.c +++ b/src/nm-logging.c @@ -680,7 +680,7 @@ _nm_log_impl (const char *file, va_list args; char *msg; GTimeVal tv; - int errno_saved; + int errsv; const NMLogDomain *cur_log_state; NMLogDomain cur_log_state_copy[_LOGL_N_REAL]; Global g_copy; @@ -710,7 +710,7 @@ _nm_log_impl (const char *file, (void) cur_log_state; - errno_saved = errno; + errsv = errno; /* Make sure that %m maps to the specified error */ if (error != 0) { @@ -833,7 +833,7 @@ _nm_log_impl (const char *file, g_free (msg); - errno = errno_saved; + errno = errsv; } /*****************************************************************************/ diff --git a/src/nm-manager.c b/src/nm-manager.c index 5f490c83a7..138cfb35fc 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -7184,10 +7184,10 @@ rfkill_change (NMManager *self, const char *desc, RfKillType rtype, gboolean ena int fd; struct rfkill_event event; ssize_t len; + int errsv; g_return_if_fail (rtype == RFKILL_TYPE_WLAN || rtype == RFKILL_TYPE_WWAN); - errno = 0; fd = open ("/dev/rfkill", O_RDWR | O_CLOEXEC); if (fd < 0) { if (errno == EACCES) @@ -7218,8 +7218,9 @@ rfkill_change (NMManager *self, const char *desc, RfKillType rtype, gboolean ena len = write (fd, &event, sizeof (event)); if (len < 0) { + errsv = errno; _LOGW (LOGD_RFKILL, "rfkill: (%s): failed to change Wi-Fi killswitch state: (%d) %s", - desc, errno, g_strerror (errno)); + desc, errsv, g_strerror (errsv)); } else if (len == sizeof (event)) { _LOGI (LOGD_RFKILL, "rfkill: %s hardware radio set %s", desc, enabled ? "enabled" : "disabled"); diff --git a/src/nm-policy.c b/src/nm-policy.c index 9372965f03..9cdddde008 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -506,13 +506,13 @@ settings_set_hostname_cb (const char *hostname, NMPolicy *self = NM_POLICY (user_data); NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); int ret = 0; + int errsv; if (!result) { _LOGT (LOGD_DNS, "set-hostname: hostname set via dbus failed, fallback to \"sethostname\""); ret = sethostname (hostname, strlen (hostname)); if (ret != 0) { - int errsv = errno; - + errsv = errno; _LOGW (LOGD_DNS, "set-hostname: couldn't set the system hostname to '%s': (%d) %s", hostname, errsv, strerror (errsv)); if (errsv == EPERM) @@ -533,6 +533,7 @@ _get_hostname (NMPolicy *self) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); char *hostname = NULL; + int errsv; /* If there is an in-progress hostname change, return * the last hostname set as would be set soon... @@ -551,8 +552,7 @@ _get_hostname (NMPolicy *self) /* ...or retrieve it by yourself */ hostname = g_malloc (HOST_NAME_BUFSIZE); if (gethostname (hostname, HOST_NAME_BUFSIZE -1) != 0) { - int errsv = errno; - + errsv = errno; _LOGT (LOGD_DNS, "get-hostname: couldn't get the system hostname: (%d) %s", errsv, g_strerror (errsv)); g_free (hostname); diff --git a/src/nm-session-monitor.c b/src/nm-session-monitor.c index aadfa6b91d..31810b8dc7 100644 --- a/src/nm-session-monitor.c +++ b/src/nm-session-monitor.c @@ -204,13 +204,15 @@ static gboolean ck_update_cache (NMSessionMonitor *monitor) { struct stat statbuf; + int errsv; if (!monitor->ck.cache) return FALSE; /* Check the database file */ if (stat (CKDB_PATH, &statbuf) != 0) { - _LOGE ("failed to check ConsoleKit timestamp: %s", strerror (errno)); + errsv = errno; + _LOGE ("failed to check ConsoleKit timestamp: %s", strerror (errsv)); return FALSE; } if (statbuf.st_mtime == monitor->ck.timestamp) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 748d2c572d..5343e2a5a2 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -5022,7 +5022,7 @@ _nl_send_nlmsghdr (NMPlatform *platform, { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform); guint32 seq; - int nle; + int errsv; nm_assert (nlhdr); @@ -5051,13 +5051,13 @@ _nl_send_nlmsghdr (NMPlatform *platform, try_count = 0; again: - nle = sendmsg (nl_socket_get_fd (priv->nlh), &msg, 0); - if (nle < 0) { - nle = errno; - if (nle == EINTR && try_count++ < 100) + errsv = sendmsg (nl_socket_get_fd (priv->nlh), &msg, 0); + if (errsv < 0) { + errsv = errno; + if (errsv == EINTR && try_count++ < 100) goto again; - _LOGD ("netlink: nl-send-nlmsghdr: failed sending message: %s (%d)", g_strerror (nle), nle); - return -nle; + _LOGD ("netlink: nl-send-nlmsghdr: failed sending message: %s (%d)", g_strerror (errsv), errsv); + return -nm_errno_from_native (errsv); } } @@ -6096,6 +6096,7 @@ link_set_sriov_params (NMPlatform *platform, gint64 current_num; char ifname[IFNAMSIZ]; char buf[64]; + int errsv; if (!nm_platform_netns_push (platform, &netns)) return FALSE; @@ -6143,7 +6144,8 @@ link_set_sriov_params (NMPlatform *platform, ifname, "device/sriov_numvfs"), "0")) { - _LOGW ("link: couldn't reset SR-IOV num_vfs: %s", strerror (errno)); + errsv = errno; + _LOGW ("link: couldn't reset SR-IOV num_vfs: %s", strerror (errsv)); return FALSE; } } @@ -6158,7 +6160,8 @@ link_set_sriov_params (NMPlatform *platform, ifname, "device/sriov_drivers_autoprobe"), nm_sprintf_buf (buf, "%d", (int) autoprobe))) { - _LOGW ("link: couldn't set SR-IOV drivers-autoprobe to %d: %s", (int) autoprobe, strerror (errno)); + errsv = errno; + _LOGW ("link: couldn't set SR-IOV drivers-autoprobe to %d: %s", (int) autoprobe, strerror (errsv)); return FALSE; } @@ -6167,7 +6170,8 @@ link_set_sriov_params (NMPlatform *platform, ifname, "device/sriov_numvfs"), nm_sprintf_buf (buf, "%u", num_vfs))) { - _LOGW ("link: couldn't set SR-IOV num_vfs to %d: %s", num_vfs, strerror (errno)); + errsv = errno; + _LOGW ("link: couldn't set SR-IOV num_vfs to %d: %s", num_vfs, strerror (errsv)); return FALSE; } diff --git a/src/platform/nm-netlink.c b/src/platform/nm-netlink.c index 6abc1c3a34..80d8b9eeb0 100644 --- a/src/platform/nm-netlink.c +++ b/src/platform/nm-netlink.c @@ -1333,6 +1333,7 @@ nl_recv (struct nl_sock *sk, struct ucred tmpcreds; gboolean tmpcreds_has = FALSE; int retval; + int errsv; nm_assert (nla); nm_assert (buf && !*buf); @@ -1361,10 +1362,10 @@ retry: } if (n < 0) { - if (errno == EINTR) + errsv = errno; + if (errsv == EINTR) goto retry; - - retval = -nm_errno_from_native (errno); + retval = -nm_errno_from_native (errsv); goto abort; } diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c index 75eba0ba08..b7305faa41 100644 --- a/src/platform/nm-platform-utils.c +++ b/src/platform/nm-platform-utils.c @@ -1043,6 +1043,7 @@ nmp_utils_mii_supports_carrier_detect (int ifindex) int r; struct ifreq ifr; struct mii_ioctl_data *mii; + int errsv; g_return_val_if_fail (ifindex > 0, FALSE); @@ -1057,7 +1058,8 @@ nmp_utils_mii_supports_carrier_detect (int ifindex) memcpy (ifr.ifr_name, shandle.ifname, IFNAMSIZ); if (ioctl (shandle.fd, SIOCGMIIPHY, &ifr) < 0) { - nm_log_trace (LOGD_PLATFORM, "mii[%d,%s]: carrier-detect no: SIOCGMIIPHY failed: %s", ifindex, shandle.ifname, strerror (errno)); + errsv = errno; + nm_log_trace (LOGD_PLATFORM, "mii[%d,%s]: carrier-detect no: SIOCGMIIPHY failed: %s", ifindex, shandle.ifname, strerror (errsv)); return FALSE; } @@ -1066,7 +1068,8 @@ nmp_utils_mii_supports_carrier_detect (int ifindex) mii->reg_num = MII_BMSR; if (ioctl (shandle.fd, SIOCGMIIREG, &ifr) != 0) { - nm_log_trace (LOGD_PLATFORM, "mii[%d,%s]: carrier-detect no: SIOCGMIIREG failed: %s", ifindex, shandle.ifname, strerror (errno)); + errsv = errno; + nm_log_trace (LOGD_PLATFORM, "mii[%d,%s]: carrier-detect no: SIOCGMIIREG failed: %s", ifindex, shandle.ifname, strerror (errsv)); return FALSE; } diff --git a/src/platform/wifi/nm-wifi-utils-wext.c b/src/platform/wifi/nm-wifi-utils-wext.c index 9b8be8de6a..80680f56be 100644 --- a/src/platform/wifi/nm-wifi-utils-wext.c +++ b/src/platform/wifi/nm-wifi-utils-wext.c @@ -127,15 +127,17 @@ wifi_wext_get_mode_ifname (NMWifiUtils *data, const char *ifname) { NMWifiUtilsWext *wext = (NMWifiUtilsWext *) data; struct iwreq wrq; + int errsv; memset (&wrq, 0, sizeof (struct iwreq)); nm_utils_ifname_cpy (wrq.ifr_name, ifname); if (ioctl (wext->fd, SIOCGIWMODE, &wrq) < 0) { - if (errno != ENODEV) { + errsv = errno; + if (errsv != ENODEV) { _LOGW (LOGD_PLATFORM | LOGD_WIFI, "(%s): error %d getting card mode", - ifname, errno); + ifname, errsv); } return NM_802_11_MODE_UNKNOWN; } @@ -504,10 +506,10 @@ wifi_wext_set_mesh_ssid (NMWifiUtils *data, const guint8 *ssid, gsize len) if (ioctl (wext->fd, SIOCSIWESSID, &wrq) == 0) return TRUE; - if (errno != ENODEV) { + errsv = errno; + if (errsv != ENODEV) { gs_free char *ssid_str = NULL; - errsv = errno; _LOGE (LOGD_PLATFORM | LOGD_WIFI | LOGD_OLPC, "(%s): error setting SSID to %s: %s", ifname, @@ -543,6 +545,7 @@ wext_get_range_ifname (NMWifiUtilsWext *wext, int i = 26; gboolean success = FALSE; struct iwreq wrq; + int errsv; memset (&wrq, 0, sizeof (struct iwreq)); nm_utils_ifname_cpy (wrq.ifr_name, ifname); @@ -559,11 +562,14 @@ wext_get_range_ifname (NMWifiUtilsWext *wext, *response_len = wrq.u.data.length; success = TRUE; break; - } else if (errno != EAGAIN) { - _LOGE (LOGD_PLATFORM | LOGD_WIFI, - "(%s): couldn't get driver range information (%d).", - ifname, errno); - break; + } else { + errsv = errno; + if (errsv != EAGAIN) { + _LOGE (LOGD_PLATFORM | LOGD_WIFI, + "(%s): couldn't get driver range information (%d).", + ifname, errsv); + break; + } } g_usleep (G_USEC_PER_SEC / 4); diff --git a/src/ppp/nm-ppp-manager.c b/src/ppp/nm-ppp-manager.c index 2f6cb03294..86551fc035 100644 --- a/src/ppp/nm-ppp-manager.c +++ b/src/ppp/nm-ppp-manager.c @@ -180,6 +180,7 @@ monitor_cb (gpointer user_data) NMPPPManager *self = NM_PPP_MANAGER (user_data); NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self); const char *ifname; + int errsv; ifname = nm_platform_link_get_name (NM_PLATFORM_GET, priv->ifindex); @@ -191,8 +192,9 @@ monitor_cb (gpointer user_data) nm_utils_ifname_cpy (req.ifr_name, ifname); if (ioctl (priv->monitor_fd, SIOCGPPPSTATS, &req) < 0) { - if (errno != ENODEV) - _LOGW ("could not read ppp stats: %s", strerror (errno)); + errsv = errno; + if (errsv != ENODEV) + _LOGW ("could not read ppp stats: %s", strerror (errsv)); } else { g_signal_emit (self, signals[STATS], 0, (guint) stats.p.ppp_ibytes, @@ -207,19 +209,23 @@ static void monitor_stats (NMPPPManager *self) { NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self); + int errsv; /* already monitoring */ if (priv->monitor_fd >= 0) return; priv->monitor_fd = socket (AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); - if (priv->monitor_fd >= 0) { - g_warn_if_fail (priv->monitor_id == 0); - if (priv->monitor_id) - g_source_remove (priv->monitor_id); - priv->monitor_id = g_timeout_add_seconds (5, monitor_cb, self); - } else - _LOGW ("could not monitor PPP stats: %s", strerror (errno)); + if (priv->monitor_fd < 0) { + errsv = errno; + _LOGW ("could not monitor PPP stats: %s", strerror (errsv)); + return; + } + + g_warn_if_fail (priv->monitor_id == 0); + if (priv->monitor_id) + g_source_remove (priv->monitor_id); + priv->monitor_id = g_timeout_add_seconds (5, monitor_cb, self); } /*****************************************************************************/ diff --git a/src/settings/plugins/ifcfg-rh/nm-inotify-helper.c b/src/settings/plugins/ifcfg-rh/nm-inotify-helper.c index bed127fa43..5a16c01d51 100644 --- a/src/settings/plugins/ifcfg-rh/nm-inotify-helper.c +++ b/src/settings/plugins/ifcfg-rh/nm-inotify-helper.c @@ -141,11 +141,11 @@ init_inotify (NMInotifyHelper *self) { NMInotifyHelperPrivate *priv = NM_INOTIFY_HELPER_GET_PRIVATE (self); GIOChannel *channel; + int errsv; priv->ifd = inotify_init1 (IN_CLOEXEC); if (priv->ifd == -1) { - int errsv = errno; - + errsv = errno; nm_log_warn (LOGD_SETTINGS, "couldn't initialize inotify: %s (%d)", strerror (errsv), errsv); return FALSE; } diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c index d7fc5da1ba..2ae94e38e3 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -3949,9 +3949,8 @@ make_wireless_setting (shvarFile *ifcfg, value = svGetValueStr_cp (ifcfg, "CHANNEL"); if (value) { - errno = 0; chan = _nm_utils_ascii_str_to_int64 (value, 10, 1, 196, 0); - if (errno || (chan == 0)) { + if (chan == 0) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid wireless channel '%s'", value); g_free (value); diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index ac150b74f1..6df75acc66 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -1315,21 +1315,20 @@ svWriteFile (shvarFile *s, int mode, GError **error) FILE *f; int tmpfd; CList *current; + int errsv; if (s->modified) { if (s->fd == -1) s->fd = open (s->fileName, O_WRONLY | O_CREAT | O_CLOEXEC, mode); if (s->fd == -1) { - int errsv = errno; - + errsv = errno; g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errsv), "Could not open file '%s' for writing: %s", s->fileName, strerror (errsv)); return FALSE; } if (ftruncate (s->fd, 0) < 0) { - int errsv = errno; - + errsv = errno; g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errsv), "Could not overwrite file '%s': %s", s->fileName, strerror (errsv)); @@ -1338,8 +1337,7 @@ svWriteFile (shvarFile *s, int mode, GError **error) tmpfd = fcntl (s->fd, F_DUPFD_CLOEXEC, 0); if (tmpfd == -1) { - int errsv = errno; - + errsv = errno; g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errsv), "Internal error writing file '%s': %s", s->fileName, strerror (errsv)); diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 108e7f677e..6c30e12937 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -10019,10 +10019,14 @@ NMTST_DEFINE (); int main (int argc, char **argv) { + int errsv; + nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); - if (g_mkdir_with_parents (TEST_SCRATCH_DIR_TMP, 0755) != 0) - g_error ("failure to create test directory \"%s\": %s", TEST_SCRATCH_DIR_TMP, g_strerror (errno)); + if (g_mkdir_with_parents (TEST_SCRATCH_DIR_TMP, 0755) != 0) { + errsv = errno; + g_error ("failure to create test directory \"%s\": %s", TEST_SCRATCH_DIR_TMP, g_strerror (errsv)); + } g_test_add_func (TPATH "svUnescape", test_svUnescape); diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c index 15c7f5b3b1..3655563d24 100644 --- a/src/settings/plugins/keyfile/tests/test-keyfile.c +++ b/src/settings/plugins/keyfile/tests/test-keyfile.c @@ -2614,11 +2614,16 @@ NMTST_DEFINE (); int main (int argc, char **argv) { + int errsv; + _nm_utils_set_testing (NM_UTILS_TEST_NO_KEYFILE_OWNER_CHECK); + nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); - if (g_mkdir_with_parents (TEST_SCRATCH_DIR, 0755) != 0) - g_error ("failure to create test directory \"%s\": %s", TEST_SCRATCH_DIR, g_strerror (errno)); + if (g_mkdir_with_parents (TEST_SCRATCH_DIR, 0755) != 0) { + errsv = errno; + g_error ("failure to create test directory \"%s\": %s", TEST_SCRATCH_DIR, g_strerror (errsv)); + } /* The tests */ g_test_add_func ("/keyfile/test_read_valid_wired_connection", test_read_valid_wired_connection); diff --git a/src/tests/test-general-with-expect.c b/src/tests/test-general-with-expect.c index dd720ac712..8339fa5d43 100644 --- a/src/tests/test-general-with-expect.c +++ b/src/tests/test-general-with-expect.c @@ -40,7 +40,8 @@ test_nm_utils_monotonic_timestamp_as_boottime (void) clockid_t clockid; guint i; - if (clock_gettime (CLOCK_BOOTTIME, &tp) != 0 && errno == EINVAL) + if ( clock_gettime (CLOCK_BOOTTIME, &tp) != 0 + && errno == EINVAL) clockid = CLOCK_MONOTONIC; else clockid = CLOCK_BOOTTIME; From 89d3c5242ba0ba9488224b0a0be3b62bcc854695 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 31 Jan 2019 16:11:06 +0100 Subject: [PATCH 05/13] shared: fix nm_errno_from_native() for negative values We first need to map negative values to their positive form, and then do the check for the reserved range. Fixes: 18732c349310fa84f2b565b7d4efa347b5f172d5 --- shared/nm-utils/nm-errno.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/nm-utils/nm-errno.h b/shared/nm-utils/nm-errno.h index c3008f1fed..3bbf879327 100644 --- a/shared/nm-utils/nm-errno.h +++ b/shared/nm-utils/nm-errno.h @@ -118,9 +118,9 @@ nm_errno_from_native (int errsv) * are coerced to the special value NME_NATIVE_ERRNO, as they cannot * otherwise be represented in nm-error number domain. */ if (errsv < 0) { - return G_UNLIKELY (errsv == G_MININT) - ? NME_NATIVE_ERRNO - : -errsv; + if (G_UNLIKELY (errsv == G_MININT)) + return NME_NATIVE_ERRNO; + errsv = -errsv; } return G_UNLIKELY ( errsv >= _NM_ERRNO_RESERVED_FIRST && errsv <= _NM_ERRNO_RESERVED_LAST) From 67130e67060b2bf28ce68c7714ea021227ece751 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 31 Jan 2019 16:37:53 +0100 Subject: [PATCH 06/13] shared: cleanup separation and transition between errno and nmerr numbers The native error numbers (from ) and our nmerr extention on top of them are almost the same. But there are peculiarities. Both errno and nmerr must be positive values. That is because some API (systemd) like to return negative error codes. So, a positive errno and its negative counter part indicate the same error. We need normalization functions that make an error number positive (these are nm_errno() and nm_errno_native()). This means, G_MININT needs special treatment, because it cannot be represented as a positive integer. Also, zero needs special treatment, because we want to encode an error, and zero already encodes no-error. Take care of these special cases. On top of that, nmerr reserves a range within native error numbers for NetworkManager specific failure codes. So we need to transition from native numbers to nmerr numbers via nm_errno_from_native(). Take better care of some special cases and clean them up. Also add NM_ERRNO_NATIVE() macro. While nm_errno_native() coerces a value in the suitable range, NM_ERRNO_NATIVE() asserts that the number is already positive (and returns it as-is). It's use is only for asserting and implicitly documenting the requirements we have on the number passed to it. --- shared/nm-utils/nm-errno.c | 50 +++++++----- shared/nm-utils/nm-errno.h | 131 ++++++++++++++++++++---------- shared/nm-utils/nm-shared-utils.h | 2 +- 3 files changed, 118 insertions(+), 65 deletions(-) diff --git a/shared/nm-utils/nm-errno.c b/shared/nm-utils/nm-errno.c index c87f0b48d6..ddf280766c 100644 --- a/shared/nm-utils/nm-errno.c +++ b/shared/nm-utils/nm-errno.c @@ -24,29 +24,41 @@ /*****************************************************************************/ -NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_geterror, int, +NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_geterror, +#if 0 + enum _NMErrno, +#else + int, +#endif NM_UTILS_LOOKUP_DEFAULT (NULL), - NM_UTILS_LOOKUP_STR_ITEM (NME_UNSPEC, "NME_UNSPEC"), - NM_UTILS_LOOKUP_STR_ITEM (NME_BUG, "NME_BUG"), - NM_UTILS_LOOKUP_STR_ITEM (NME_NATIVE_ERRNO, "NME_NATIVE_ERRNO"), + NM_UTILS_LOOKUP_STR_ITEM (NME_ERRNO_SUCCESS, "NME_ERRNO_SUCCESS"), + NM_UTILS_LOOKUP_STR_ITEM (NME_ERRNO_OUT_OF_RANGE, "NME_ERRNO_OUT_OF_RANGE"), - NM_UTILS_LOOKUP_STR_ITEM (NME_NL_ATTRSIZE, "NME_NL_ATTRSIZE"), - NM_UTILS_LOOKUP_STR_ITEM (NME_NL_BAD_SOCK, "NME_NL_BAD_SOCK"), - NM_UTILS_LOOKUP_STR_ITEM (NME_NL_DUMP_INTR, "NME_NL_DUMP_INTR"), - NM_UTILS_LOOKUP_STR_ITEM (NME_NL_MSG_OVERFLOW, "NME_NL_MSG_OVERFLOW"), - NM_UTILS_LOOKUP_STR_ITEM (NME_NL_MSG_TOOSHORT, "NME_NL_MSG_TOOSHORT"), - NM_UTILS_LOOKUP_STR_ITEM (NME_NL_MSG_TRUNC, "NME_NL_MSG_TRUNC"), - NM_UTILS_LOOKUP_STR_ITEM (NME_NL_SEQ_MISMATCH, "NME_NL_SEQ_MISMATCH"), + NM_UTILS_LOOKUP_STR_ITEM (NME_UNSPEC, "NME_UNSPEC"), + NM_UTILS_LOOKUP_STR_ITEM (NME_BUG, "NME_BUG"), + NM_UTILS_LOOKUP_STR_ITEM (NME_NATIVE_ERRNO, "NME_NATIVE_ERRNO"), - NM_UTILS_LOOKUP_STR_ITEM (NME_PL_NOT_FOUND, "not-found"), - NM_UTILS_LOOKUP_STR_ITEM (NME_PL_EXISTS, "exists"), - NM_UTILS_LOOKUP_STR_ITEM (NME_PL_WRONG_TYPE, "wrong-type"), - NM_UTILS_LOOKUP_STR_ITEM (NME_PL_NOT_SLAVE, "not-slave"), - NM_UTILS_LOOKUP_STR_ITEM (NME_PL_NO_FIRMWARE, "no-firmware"), - NM_UTILS_LOOKUP_STR_ITEM (NME_PL_OPNOTSUPP, "not-supported"), - NM_UTILS_LOOKUP_STR_ITEM (NME_PL_NETLINK, "netlink"), - NM_UTILS_LOOKUP_STR_ITEM (NME_PL_CANT_SET_MTU, "cant-set-mtu"), + NM_UTILS_LOOKUP_STR_ITEM (NME_NL_ATTRSIZE, "NME_NL_ATTRSIZE"), + NM_UTILS_LOOKUP_STR_ITEM (NME_NL_BAD_SOCK, "NME_NL_BAD_SOCK"), + NM_UTILS_LOOKUP_STR_ITEM (NME_NL_DUMP_INTR, "NME_NL_DUMP_INTR"), + NM_UTILS_LOOKUP_STR_ITEM (NME_NL_MSG_OVERFLOW, "NME_NL_MSG_OVERFLOW"), + NM_UTILS_LOOKUP_STR_ITEM (NME_NL_MSG_TOOSHORT, "NME_NL_MSG_TOOSHORT"), + NM_UTILS_LOOKUP_STR_ITEM (NME_NL_MSG_TRUNC, "NME_NL_MSG_TRUNC"), + NM_UTILS_LOOKUP_STR_ITEM (NME_NL_SEQ_MISMATCH, "NME_NL_SEQ_MISMATCH"), + NM_UTILS_LOOKUP_STR_ITEM (NME_NL_NOADDR, "NME_NL_NOADDR"), + + NM_UTILS_LOOKUP_STR_ITEM (NME_PL_NOT_FOUND, "not-found"), + NM_UTILS_LOOKUP_STR_ITEM (NME_PL_EXISTS, "exists"), + NM_UTILS_LOOKUP_STR_ITEM (NME_PL_WRONG_TYPE, "wrong-type"), + NM_UTILS_LOOKUP_STR_ITEM (NME_PL_NOT_SLAVE, "not-slave"), + NM_UTILS_LOOKUP_STR_ITEM (NME_PL_NO_FIRMWARE, "no-firmware"), + NM_UTILS_LOOKUP_STR_ITEM (NME_PL_OPNOTSUPP, "not-supported"), + NM_UTILS_LOOKUP_STR_ITEM (NME_PL_NETLINK, "netlink"), + NM_UTILS_LOOKUP_STR_ITEM (NME_PL_CANT_SET_MTU, "cant-set-mtu"), + + NM_UTILS_LOOKUP_ITEM_IGNORE (_NM_ERRNO_MININT), + NM_UTILS_LOOKUP_ITEM_IGNORE (_NM_ERRNO_RESERVED_LAST_PLUS_1), ); const char * diff --git a/shared/nm-utils/nm-errno.h b/shared/nm-utils/nm-errno.h index 3bbf879327..68cf49a0c1 100644 --- a/shared/nm-utils/nm-errno.h +++ b/shared/nm-utils/nm-errno.h @@ -25,11 +25,23 @@ /*****************************************************************************/ -enum { +enum _NMErrno { _NM_ERRNO_MININT = G_MININT, _NM_ERRNO_MAXINT = G_MAXINT, _NM_ERRNO_RESERVED_FIRST = 100000, + + /* when we cannot represent a number as positive number, we resort to this + * number. Basically, the values G_MININT, -NME_ERRNO_SUCCESS, NME_ERRNO_SUCCESS + * and G_MAXINT all map to the same value. */ + NME_ERRNO_OUT_OF_RANGE = G_MAXINT, + + /* Indicate that the original errno was zero. Zero denotes *no error*, but we know something + * went wrong and we want to report some error. This is a placeholder to mean, something + * was wrong, but errno was zero. */ + NME_ERRNO_SUCCESS = G_MAXINT - 1, + + /* an unspecified error. */ NME_UNSPEC = _NM_ERRNO_RESERVED_FIRST, @@ -68,64 +80,93 @@ enum { /*****************************************************************************/ +/* When we receive an errno from a system function, we can safely assume + * that the error number is not negative. We rely on that, and possibly just + * "return -errsv;" to signal an error. We also rely on that, because libc + * is our trusted base: meaning, if it cannot even succeed at setting errno + * according to specification, all bets are off. + * + * This macro returns the input argument, and asserts that the error variable + * is positive. + * + * In a sense, the macro is related to nm_errno_native() function, but the difference + * is that this macro asserts that @errsv is positive, while nm_errno_native() coerces + * negative values to be non-negative. */ +#define NM_ERRNO_NATIVE(errsv) \ + ({ \ + const int _errsv_x = (errsv); \ + \ + nm_assert (_errsv_x > 0); \ + _errsv_x; \ + }) + +/* Normalize native errno. + * + * Our API may return native error codes () as negative values. This function + * takes such an errno, and normalizes it to their positive value. + * + * The special values G_MININT and zero are coerced to NME_ERRNO_OUT_OF_RANGE and NME_ERRNO_SUCCESS + * respectively. + * Other values are coerced to their inverse. + * Other positive values are returned unchanged. + * + * Basically, this normalizes errsv to be positive (taking care of two pathological cases). + */ static inline int nm_errno_native (int errsv) { - /* several API returns negative errno values as errors. Normalize - * negative values to positive values. - * - * As a special case, map G_MININT to G_MAXINT. If you care about the - * distinction, then check for G_MININT before. - * - * Basically, this normalizes a plain errno to be non-negative. */ - return errsv >= 0 - ? errsv - : ((errsv == G_MININT) ? G_MAXINT : -errsv); + switch (errsv) { + case 0: return NME_ERRNO_SUCCESS; + case G_MININT: return NME_ERRNO_OUT_OF_RANGE; + default: + return errsv >= 0 ? errsv : -errsv; + } } +/* Normalizes an nm-error to be positive. + * + * Various API returns negative error codes, and this function converts the negative + * value to its positive. + * + * Note that @nmerr is on the domain of NetworkManager specific error numbers, + * which is not the same as the native error numbers (errsv from ). But + * as far as normalizing goes, nm_errno() does exactly the same remapping as + * nm_errno_native(). */ static inline int nm_errno (int nmerr) { - /* Normalizes an nm-error to be positive. Various API returns negative - * error codes, and this function converts the negative value to its - * positive. - * - * It's very similar to nm_errno_native(), but not exactly. The difference is that - * nm_errno_native() is for plain errno, while nm_errno() is for nm-error numbers. - * Yes, nm-error number are ~almost~ the same as errno, except that a particular - * range (_NM_ERRNO_RESERVED_FIRST, _NM_ERRNO_RESERVED_LAST) is reserved. The difference - * between the two functions is only how G_MININT is mapped. - * - * See also nm_errno_from_native() below. */ - return nmerr >= 0 - ? nmerr - : ((nmerr == G_MININT) ? NME_BUG : -nmerr); + return nm_errno_native (nmerr); } +/* this maps a native errno to a (always non-negative) nm-error number. + * + * Note that nm-error numbers are embedded into the range of regular + * errno. The only difference is, that nm-error numbers reserve a + * range (_NM_ERRNO_RESERVED_FIRST, _NM_ERRNO_RESERVED_LAST) for their + * own purpose. + * + * That means, converting an errno to nm-error number means in + * most cases just returning itself. + * Only pathological cases need special handling: + * + * - 0 is mapped to NME_ERRNO_SUCCESS; + * - G_MININT is mapped to NME_ERRNO_OUT_OF_RANGE; + * - values in the range of (+/-) [_NM_ERRNO_RESERVED_FIRST, _NM_ERRNO_RESERVED_LAST] + * are mapped to NME_NATIVE_ERRNO + * - all other values are their (positive) absolute value. + */ static inline int nm_errno_from_native (int errsv) { - /* this maps a native errno to a (always non-negative) nm-error number. - * - * Note that nm-error numbers are embedded into the range of regular - * errno. The only difference is, that nm-error numbers reserve a - * range (_NM_ERRNO_RESERVED_FIRST, _NM_ERRNO_RESERVED_LAST) for their - * own purpose. - * - * That means, converting an errno to nm-error number means in - * most cases just returning itself (negative values are normalized - * to be positive). Only values G_MININT and [_NM_ERRNO_RESERVED_FIRST, _NM_ERRNO_RESERVED_LAST] - * are coerced to the special value NME_NATIVE_ERRNO, as they cannot - * otherwise be represented in nm-error number domain. */ - if (errsv < 0) { - if (G_UNLIKELY (errsv == G_MININT)) - return NME_NATIVE_ERRNO; - errsv = -errsv; + switch (errsv) { + case 0: return NME_ERRNO_SUCCESS; + case G_MININT: return NME_ERRNO_OUT_OF_RANGE; + default: + return G_UNLIKELY ( errsv >= _NM_ERRNO_RESERVED_FIRST + && errsv <= _NM_ERRNO_RESERVED_LAST) + ? NME_NATIVE_ERRNO + : errsv; } - return G_UNLIKELY ( errsv >= _NM_ERRNO_RESERVED_FIRST - && errsv <= _NM_ERRNO_RESERVED_LAST) - ? NME_NATIVE_ERRNO - : errsv; } const char *nm_strerror (int nmerr); diff --git a/shared/nm-utils/nm-shared-utils.h b/shared/nm-utils/nm-shared-utils.h index d9e409f0e6..a8082d4cd0 100644 --- a/shared/nm-utils/nm-shared-utils.h +++ b/shared/nm-utils/nm-shared-utils.h @@ -710,7 +710,7 @@ nm_utils_error_set_literal (GError **error, int error_code, const char *literal) \ ( _errsv >= 0 \ ? _errsv \ - : ( (_errsv == G_MININT) \ + : ( G_UNLIKELY (_errsv == G_MININT) \ ? G_MAXINT \ : -errsv)); \ }))) From 4d9918aac2144b45d17d10ce72672e98c860bf37 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 31 Jan 2019 16:53:45 +0100 Subject: [PATCH 07/13] all: assert that native errno numbers are positive Use the NM_ERRNO_NATIVE() macro that asserts that these errno numbers are indeed positive. Using the macro also serves as a documentation of what the meaning of these numbers is. That is often not obvious, whether we have an nm_errno(), an nm_errno_native() (from ), or another error number (e.g. WaitForNlResponseResult). This situation already improved by merging netlink error codes (nle), NMPlatformError enum and as nm_errno(). But we still must always be careful about not to mix error codes from different domains or transform them appropriately (like nm_errno_from_native()). --- shared/nm-utils/nm-io-utils.c | 11 ++++------- shared/nm-utils/nm-shared-utils.c | 6 ++++-- src/ndisc/nm-lndp-ndisc.c | 9 ++++----- src/platform/nm-linux-platform.c | 6 +++--- src/platform/nm-platform-utils.c | 4 ++-- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/shared/nm-utils/nm-io-utils.c b/shared/nm-utils/nm-io-utils.c index ac16ff97f2..091110e0a7 100644 --- a/shared/nm-utils/nm-io-utils.c +++ b/shared/nm-utils/nm-io-utils.c @@ -29,6 +29,7 @@ #include "nm-shared-utils.h" #include "nm-secret-utils.h" +#include "nm-errno.h" /*****************************************************************************/ @@ -36,11 +37,7 @@ _nm_printf (3, 4) static int _get_contents_error (GError **error, int errsv, const char *format, ...) { - if (errsv < 0) { - errsv = errsv == G_MININT - ? G_MAXINT - : -errsv; - } + nm_assert (NM_ERRNO_NATIVE (errsv)); if (error) { char *msg; @@ -306,7 +303,7 @@ nm_utils_file_get_contents (int dirfd, "Failed to open file \"%s\" with openat: %s", filename, g_strerror (errsv)); - return -errsv; + return -NM_ERRNO_NATIVE (errsv); } } else { fd = open (filename, O_RDONLY | O_CLOEXEC); @@ -319,7 +316,7 @@ nm_utils_file_get_contents (int dirfd, "Failed to open file \"%s\": %s", filename, g_strerror (errsv)); - return -errsv; + return -NM_ERRNO_NATIVE (errsv); } } return nm_utils_fd_get_contents (fd, diff --git a/shared/nm-utils/nm-shared-utils.c b/shared/nm-utils/nm-shared-utils.c index 860d4c18a6..f5b0d0f773 100644 --- a/shared/nm-utils/nm-shared-utils.c +++ b/shared/nm-utils/nm-shared-utils.c @@ -28,6 +28,8 @@ #include #include +#include "nm-errno.h" + /*****************************************************************************/ const void *const _NM_PTRARRAY_EMPTY[1] = { NULL }; @@ -1742,7 +1744,7 @@ nm_utils_fd_wait_for_event (int fd, int event, gint64 timeout_ns) r = ppoll (&pollfd, 1, pts, NULL); if (r < 0) - return -errno; + return -NM_ERRNO_NATIVE (errno); if (r == 0) return 0; return pollfd.revents; @@ -1784,7 +1786,7 @@ nm_utils_fd_read_loop (int fd, void *buf, size_t nbytes, bool do_poll) continue; } - return n > 0 ? n : -errsv; + return n > 0 ? n : -NM_ERRNO_NATIVE (errsv); } if (k == 0) diff --git a/src/ndisc/nm-lndp-ndisc.c b/src/ndisc/nm-lndp-ndisc.c index d608a2dc68..1ba35b0e94 100644 --- a/src/ndisc/nm-lndp-ndisc.c +++ b/src/ndisc/nm-lndp-ndisc.c @@ -32,6 +32,7 @@ #include "NetworkManagerUtils.h" #include "platform/nm-platform.h" #include "platform/nmp-netns.h" +#include "nm-utils/nm-errno.h" #define _NMLOG_PREFIX_NAME "ndisc-lndp" @@ -72,7 +73,6 @@ send_rs (NMNDisc *ndisc, GError **error) errsv = ndp_msg_new (&msg, NDP_MSG_RS); if (errsv) { - errsv = errsv > 0 ? errsv : -errsv; g_set_error_literal (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, "cannot create router solicitation"); return FALSE; @@ -82,7 +82,7 @@ send_rs (NMNDisc *ndisc, GError **error) errsv = ndp_msg_send (priv->ndp, msg); ndp_msg_destroy (msg); if (errsv) { - errsv = errsv > 0 ? errsv : -errsv; + errsv = nm_errno_native (errsv); g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, "%s (%d)", g_strerror (errsv), errsv); @@ -360,7 +360,6 @@ send_ra (NMNDisc *ndisc, GError **error) errsv = ndp_msg_new (&msg, NDP_MSG_RA); if (errsv) { - errsv = errsv > 0 ? errsv : -errsv; g_set_error_literal (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, "cannot create a router advertisement"); return FALSE; @@ -468,7 +467,7 @@ send_ra (NMNDisc *ndisc, GError **error) ndp_msg_destroy (msg); if (errsv) { - errsv = errsv > 0 ? errsv : -errsv; + errsv = nm_errno_native (errsv); g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, "%s (%d)", g_strerror (errsv), errsv); @@ -599,7 +598,7 @@ nm_lndp_ndisc_new (NMPlatform *platform, errsv = ndp_open (&priv->ndp); if (errsv != 0) { - errsv = errsv > 0 ? errsv : -errsv; + errsv = nm_errno_native (errsv); g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, "failure creating libndp socket: %s (%d)", g_strerror (errsv), errsv); diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 5343e2a5a2..cfa1b8bc6a 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -327,7 +327,7 @@ typedef enum { typedef enum { /* Negative values are errors from kernel. Add dummy member to * make enum signed. */ - _WAIT_FOR_NL_RESPONSE_RESULT_SYSTEM_ERROR = -1, + _WAIT_FOR_NL_RESPONSE_RESULT_SYSTEM_ERROR = G_MININT, WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN = 0, WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK, @@ -7825,7 +7825,7 @@ continue_reading: err = -NME_NL_MSG_TRUNC; abort_parsing = TRUE; } else if (e->error) { - int errsv = e->error > 0 ? e->error : -e->error; + int errsv = nm_errno_native (e->error); if ( NM_FLAGS_HAS (hdr->nlmsg_flags, NLM_F_ACK_TLVS) && hdr->nlmsg_len >= sizeof (*e) + e->msg.nlmsg_len) { @@ -7850,7 +7850,7 @@ continue_reading: errsv, NM_PRINT_FMT_QUOTED (extack_msg, " \"", extack_msg, "\"", ""), nlmsg_hdr (msg)->nlmsg_seq); - seq_result = -errsv; + seq_result = -NM_ERRNO_NATIVE (errsv); } else seq_result = WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK; } else diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c index b7305faa41..69ce4d88a1 100644 --- a/src/platform/nm-platform-utils.c +++ b/src/platform/nm-platform-utils.c @@ -84,7 +84,7 @@ socket_handle_init (SocketHandle *shandle, int ifindex) shandle->fd = socket (PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (shandle->fd < 0) { shandle->ifindex = 0; - return -errno; + return -NM_ERRNO_NATIVE (errno); } shandle->ifindex = ifindex; @@ -158,7 +158,7 @@ ethtool_call_handle (SocketHandle *shandle, gpointer edata) _ethtool_data_to_string (edata, sbuf, sizeof (sbuf)), shandle->ifname, strerror (errsv)); - return -errsv; + return -NM_ERRNO_NATIVE (errsv); } nm_log_trace (LOGD_PLATFORM, "ethtool[%d]: %s, %s: success", From e1ca3bf7ed4068ba3522398d20a1acc04256f43c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 31 Jan 2019 13:17:26 +0100 Subject: [PATCH 08/13] shared: add nm_strerror_native() to replace strerror() and g_strerror() We have various options for strerror(), with ups and downsides: - strerror() - returns pointer that is overwritten on next call. It's convenient to use, but dangerous. - not thread-safe. - not guaranteed to be UTF-8. - strerror_r() - takes input buffer and is less convenient to use. At least, we are in control of when the buffer gets overwritten. - there is a Posix/XSI and a glibc variant, making it sligthly inconvenient to used. This could be solved by a wrapper we implement. - thread-safe. - not guaranteed to be UTF-8. - g_strerror() - convenient and safe to use. Also the buffer is never released for the remainder of the program. - passing untrusted error numbers to g_strerror() can result in a denial of service, as the internal buffer grows until out-of-memory. - thread-safe. - guaranteed to be UTF-8 (depending on locale). Add our own wrapper nm_strerror_native(). It is: - convenient to use (returning a buffer that does not require management). - slightly dangerous as the buffer gets overwritten on the next call (like strerror()). - thread-safe. - guaranteed to be UTF-8 (depending on locale). - doesn't keep an unlimited cache of strings, unlike g_strerror(). You can't have it all. g_strerror() is leaking all generated error messages. I think that is unacceptable, because it would mean we need to keep track where our error numbers come from (and trust libraries we use to only set a restricted set of known error numbers). --- shared/nm-utils/nm-errno.c | 123 ++++++++++++++++++++++++++++++++++++- shared/nm-utils/nm-errno.h | 7 +++ 2 files changed, 129 insertions(+), 1 deletion(-) diff --git a/shared/nm-utils/nm-errno.c b/shared/nm-utils/nm-errno.c index ddf280766c..30eb9a8e78 100644 --- a/shared/nm-utils/nm-errno.c +++ b/shared/nm-utils/nm-errno.c @@ -22,6 +22,8 @@ #include "nm-errno.h" +#include + /*****************************************************************************/ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_geterror, @@ -61,6 +63,20 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_geterror, NM_UTILS_LOOKUP_ITEM_IGNORE (_NM_ERRNO_RESERVED_LAST_PLUS_1), ); +/** + * nm_strerror(): + * @nmerr: the NetworkManager specific errno to be converted + * to string. + * + * NetworkManager specific error numbers reserve a range in "errno.h" with + * our own defines. For numbers that don't fall into this range, the numbers + * are identical to the common error numbers. + * + * Idential to strerror(), g_strerror(), nm_strerror_native() for error numbers + * that are not in the reserved range of NetworkManager specific errors. + * + * Returns: (transfer none): the string representation of the error number. + */ const char * nm_strerror (int nmerr) { @@ -73,5 +89,110 @@ nm_strerror (int nmerr) if (s) return s; } - return g_strerror (nmerr); + return nm_strerror_native (nmerr); +} + +/*****************************************************************************/ + +/** + * nm_strerror_native_r: + * @errsv: the errno to convert to string. + * @buf: the output buffer where to write the string to. + * @buf_size: the length of buffer. + * + * This is like strerror_r(), with one difference: depending on the + * locale, the returned string is guaranteed to be valid UTF-8. + * Also, there is some confusion as to whether to use glibc's + * strerror_r() or the POXIX/XSI variant. This is abstracted + * by the function. + * + * Note that the returned buffer may also be a statically allocated + * buffer, and not the input buffer @buf. Consequently, the returned + * string may be longer than @buf_size. + * + * Returns: (transfer none): a NUL terminated error message. This is either a static + * string (that is never freed), or the provided @buf argumnt. + */ +const char * +nm_strerror_native_r (int errsv, char *buf, gsize buf_size) +{ + char *buf2; + + nm_assert (buf); + nm_assert (buf_size > 0); + +#if (_POSIX_C_SOURCE >= 200112L) && ! _GNU_SOURCE + /* XSI-compliant */ + { + int errno_saved = errno; + + if (strerror_r (errsv, buf, buf_size) != 0) { + g_snprintf (buf, buf_size, "Unspecified errno %d", errsv); + errno = errno_saved; + } + buf2 = buf; + } +#else + /* GNU-specific */ + buf2 = strerror_r (errsv, buf, buf_size); +#endif + + /* like g_strerror(), ensure that the error message is UTF-8. */ + if ( !g_get_charset (NULL) + && !g_utf8_validate (buf2, -1, NULL)) { + gs_free char *msg = NULL; + + msg = g_locale_to_utf8 (buf2, -1, NULL, NULL, NULL); + if (msg) { + g_strlcpy (buf, msg, buf_size); + buf2 = buf; + } + } + + return buf2; +} + +/** + * nm_strerror_native: + * @errsv: the errno integer from + * + * Like strerror(), but strerror() is not thread-safe and not guaranteed + * to be UTF-8. + * + * g_strerror() is a thread-safe variant of strerror(), however it caches + * all returned strings in a dictionary. That means, using this on untrusted + * error numbers can result in this cache to grow without limits. + * + * Instead, return a tread-local buffer. This way, it's thread-safe. + * + * There is a downside to this: subsequent calls of nm_strerror_native() + * overwrite the error message. + * + * Returns: (transfer none): the text representation of the error number. + */ +const char * +nm_strerror_native (int errsv) +{ + static _nm_thread_local char *buf_static = NULL; + char *buf; + + buf = buf_static; + if (G_UNLIKELY (!buf)) { + int errno_saved = errno; + pthread_key_t key; + + buf = g_malloc (NM_STRERROR_BUFSIZE); + buf_static = buf; + + if ( pthread_key_create (&key, g_free) != 0 + || pthread_setspecific (key, buf) != 0) { + /* Failure. We will leak the buffer when the thread exits. + * + * Nothing we can do about it really. For Debug builds we fail with an assertion. */ + nm_assert_not_reached (); + } + errno = errno_saved; + } + + return nm_strerror_native_r (errsv, buf, NM_STRERROR_BUFSIZE); } diff --git a/shared/nm-utils/nm-errno.h b/shared/nm-utils/nm-errno.h index 68cf49a0c1..4b16b216ec 100644 --- a/shared/nm-utils/nm-errno.h +++ b/shared/nm-utils/nm-errno.h @@ -173,4 +173,11 @@ const char *nm_strerror (int nmerr); /*****************************************************************************/ +#define NM_STRERROR_BUFSIZE 1024 + +const char *nm_strerror_native_r (int errsv, char *buf, gsize buf_size); +const char *nm_strerror_native (int errsv); + +/*****************************************************************************/ + #endif /* __NM_ERRNO_H__ */ From 737ab51472a95df32d5f47633c0f01e22ff43950 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 31 Jan 2019 17:17:10 +0100 Subject: [PATCH 09/13] all: include "nm-utils/nm-errno.h" via "nm-default.h" --- shared/nm-default.h | 1 + src/ndisc/nm-lndp-ndisc.c | 1 - src/platform/nm-linux-platform.c | 1 - src/platform/nm-netlink.c | 2 -- src/platform/nm-platform.c | 1 - src/platform/nm-platform.h | 1 - src/platform/wifi/nm-wifi-utils-nl80211.c | 1 - src/platform/wpan/nm-wpan-utils.c | 1 - 8 files changed, 1 insertion(+), 8 deletions(-) diff --git a/shared/nm-default.h b/shared/nm-default.h index c006f33d35..26d6476a95 100644 --- a/shared/nm-default.h +++ b/shared/nm-default.h @@ -292,6 +292,7 @@ _nm_g_return_if_fail_warning (const char *log_domain, #include "nm-utils/nm-macros-internal.h" #include "nm-utils/nm-shared-utils.h" +#include "nm-utils/nm-errno.h" #if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_UTIL /* no hash-utils in legacy code. */ diff --git a/src/ndisc/nm-lndp-ndisc.c b/src/ndisc/nm-lndp-ndisc.c index 1ba35b0e94..4c125d4c77 100644 --- a/src/ndisc/nm-lndp-ndisc.c +++ b/src/ndisc/nm-lndp-ndisc.c @@ -32,7 +32,6 @@ #include "NetworkManagerUtils.h" #include "platform/nm-platform.h" #include "platform/nmp-netns.h" -#include "nm-utils/nm-errno.h" #define _NMLOG_PREFIX_NAME "ndisc-lndp" diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index cfa1b8bc6a..1da9611003 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -43,7 +43,6 @@ #include "nm-core-internal.h" #include "nm-setting-vlan.h" -#include "nm-utils/nm-errno.h" #include "nm-utils/nm-secret-utils.h" #include "nm-netlink.h" #include "nm-core-utils.h" diff --git a/src/platform/nm-netlink.c b/src/platform/nm-netlink.c index 80d8b9eeb0..ec41d2308c 100644 --- a/src/platform/nm-netlink.c +++ b/src/platform/nm-netlink.c @@ -25,8 +25,6 @@ #include #include -#include "nm-utils/nm-errno.h" - /*****************************************************************************/ #ifndef SOL_NETLINK diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index ba7357020f..021b45d73e 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -39,7 +39,6 @@ #include "nm-core-internal.h" #include "nm-utils/nm-dedup-multi.h" #include "nm-utils/nm-udev-utils.h" -#include "nm-utils/nm-errno.h" #include "nm-core-utils.h" #include "nm-platform-utils.h" diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 412ac597ab..568b1f4b46 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -29,7 +29,6 @@ #include "nm-setting-wired.h" #include "nm-setting-wireless.h" #include "nm-setting-ip-tunnel.h" -#include "nm-utils/nm-errno.h" #define NM_TYPE_PLATFORM (nm_platform_get_type ()) #define NM_PLATFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PLATFORM, NMPlatform)) diff --git a/src/platform/wifi/nm-wifi-utils-nl80211.c b/src/platform/wifi/nm-wifi-utils-nl80211.c index 80f316f880..f03ae9c1f7 100644 --- a/src/platform/wifi/nm-wifi-utils-nl80211.c +++ b/src/platform/wifi/nm-wifi-utils-nl80211.c @@ -30,7 +30,6 @@ #include #include -#include "nm-utils/nm-errno.h" #include "platform/nm-netlink.h" #include "nm-wifi-utils-private.h" #include "platform/nm-platform.h" diff --git a/src/platform/wpan/nm-wpan-utils.c b/src/platform/wpan/nm-wpan-utils.c index f8708bc6aa..4ae1770ffe 100644 --- a/src/platform/wpan/nm-wpan-utils.c +++ b/src/platform/wpan/nm-wpan-utils.c @@ -23,7 +23,6 @@ #include -#include "nm-utils/nm-errno.h" #include "platform/linux/nl802154.h" #include "platform/nm-netlink.h" #include "platform/nm-platform-utils.h" From a4fb6ddfca60c50cdf140d3f388209ace06e24ff Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 31 Jan 2019 17:08:03 +0100 Subject: [PATCH 10/13] all: replace g_strerror() calls with nm_strerror_native() --- shared/nm-utils/nm-io-utils.c | 14 ++++---- shared/nm-utils/nm-shared-utils.h | 2 +- src/devices/nm-acd-manager.c | 2 +- src/devices/nm-device.c | 4 +-- src/devices/nm-lldp-listener.c | 10 +++--- src/dhcp/nm-dhcp-client.c | 2 +- src/dhcp/nm-dhcp-dhclient.c | 4 +-- src/dhcp/nm-dhcp-dhcpcanon.c | 2 +- src/dhcp/nm-dhcp-dhcpcd.c | 2 +- src/dns/nm-dns-manager.c | 30 ++++++++-------- src/main-utils.c | 8 ++--- src/main.c | 2 +- src/ndisc/nm-lndp-ndisc.c | 6 ++-- src/nm-iface-helper.c | 2 +- src/nm-manager.c | 2 +- src/nm-policy.c | 2 +- src/platform/nm-linux-platform.c | 8 ++--- src/platform/nm-platform-utils.c | 14 ++++---- src/platform/nmp-netns.c | 34 +++++++++---------- src/platform/tests/test-link.c | 2 +- src/platform/wifi/nm-wifi-utils-wext.c | 2 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-reader.c | 4 +-- .../plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 2 +- .../plugins/keyfile/nms-keyfile-utils.c | 4 +-- .../plugins/keyfile/nms-keyfile-writer.c | 2 +- .../plugins/keyfile/tests/test-keyfile.c | 2 +- 26 files changed, 84 insertions(+), 84 deletions(-) diff --git a/shared/nm-utils/nm-io-utils.c b/shared/nm-utils/nm-io-utils.c index 091110e0a7..7a9b8b7752 100644 --- a/shared/nm-utils/nm-io-utils.c +++ b/shared/nm-utils/nm-io-utils.c @@ -50,7 +50,7 @@ _get_contents_error (GError **error, int errsv, const char *format, ...) G_FILE_ERROR, g_file_error_from_errno (errsv), "%s: %s", - msg, g_strerror (errsv)); + msg, nm_strerror_native (errsv)); g_free (msg); } return -errsv; @@ -302,7 +302,7 @@ nm_utils_file_get_contents (int dirfd, g_file_error_from_errno (errsv), "Failed to open file \"%s\" with openat: %s", filename, - g_strerror (errsv)); + nm_strerror_native (errsv)); return -NM_ERRNO_NATIVE (errsv); } } else { @@ -315,7 +315,7 @@ nm_utils_file_get_contents (int dirfd, g_file_error_from_errno (errsv), "Failed to open file \"%s\": %s", filename, - g_strerror (errsv)); + nm_strerror_native (errsv)); return -NM_ERRNO_NATIVE (errsv); } } @@ -364,7 +364,7 @@ nm_utils_file_set_contents (const char *filename, g_file_error_from_errno (errsv), "failed to create file %s: %s", tmp_name, - g_strerror (errsv)); + nm_strerror_native (errsv)); return FALSE; } @@ -383,7 +383,7 @@ nm_utils_file_set_contents (const char *filename, g_file_error_from_errno (errsv), "failed to write to file %s: %s", tmp_name, - g_strerror (errsv)); + nm_strerror_native (errsv)); return FALSE; } @@ -412,7 +412,7 @@ nm_utils_file_set_contents (const char *filename, g_file_error_from_errno (errsv), "failed to fsync %s: %s", tmp_name, - g_strerror (errsv)); + nm_strerror_native (errsv)); return FALSE; } } @@ -428,7 +428,7 @@ nm_utils_file_set_contents (const char *filename, "failed to rename %s to %s: %s", tmp_name, filename, - g_strerror (errsv)); + nm_strerror_native (errsv)); return FALSE; } diff --git a/shared/nm-utils/nm-shared-utils.h b/shared/nm-utils/nm-shared-utils.h index a8082d4cd0..fd2019349a 100644 --- a/shared/nm-utils/nm-shared-utils.h +++ b/shared/nm-utils/nm-shared-utils.h @@ -705,7 +705,7 @@ nm_utils_error_set_literal (GError **error, int error_code, const char *literal) NM_UTILS_ERROR_UNKNOWN, \ fmt, \ ##__VA_ARGS__, \ - g_strerror (({ \ + nm_strerror_native (({ \ const int _errsv = (errsv); \ \ ( _errsv >= 0 \ diff --git a/src/devices/nm-acd-manager.c b/src/devices/nm-acd-manager.c index a0a175bec7..a8f7a63a14 100644 --- a/src/devices/nm-acd-manager.c +++ b/src/devices/nm-acd-manager.c @@ -99,7 +99,7 @@ static const char * acd_error_to_string (int error) { if (error < 0) - return g_strerror (-error); + return nm_strerror_native (-error); switch (error) { case _N_ACD_E_SUCCESS: diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 317be5b5bd..2426bb4d8a 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -10172,9 +10172,9 @@ share_init (NMDevice *self, GError **error) } else if (!nm_platform_sysctl_set (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv4/ip_forward"), "1")) { errsv = errno; _LOGD (LOGD_SHARING, "share: error enabling IPv4 forwarding: (%d) %s", - errsv, g_strerror (errsv)); + errsv, nm_strerror_native (errsv)); g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, - "cannot set ipv4/ip_forward: %s", g_strerror (errsv)); + "cannot set ipv4/ip_forward: %s", nm_strerror_native (errsv)); return FALSE; } diff --git a/src/devices/nm-lldp-listener.c b/src/devices/nm-lldp-listener.c index f26a2d5cde..cb3b5907da 100644 --- a/src/devices/nm-lldp-listener.c +++ b/src/devices/nm-lldp-listener.c @@ -383,7 +383,7 @@ lldp_neighbor_new (sd_lldp_neighbor *neighbor_sd, GError **error) &chassis_id, &chassis_id_len); if (r < 0) { g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, - "failed reading chassis-id: %s", g_strerror (-r)); + "failed reading chassis-id: %s", nm_strerror_native (-r)); return NULL; } if (chassis_id_len < 1) { @@ -396,7 +396,7 @@ lldp_neighbor_new (sd_lldp_neighbor *neighbor_sd, GError **error) &port_id, &port_id_len); if (r < 0) { g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, - "failed reading port-id: %s", g_strerror (-r)); + "failed reading port-id: %s", nm_strerror_native (-r)); return NULL; } if (port_id_len < 1) { @@ -412,7 +412,7 @@ lldp_neighbor_new (sd_lldp_neighbor *neighbor_sd, GError **error) r = sd_lldp_neighbor_get_destination_address (neighbor_sd, &neigh->destination_address); if (r < 0) { g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, - "failed getting destination address: %s", g_strerror (-r)); + "failed getting destination address: %s", nm_strerror_native (-r)); goto out; } @@ -463,7 +463,7 @@ lldp_neighbor_new (sd_lldp_neighbor *neighbor_sd, GError **error) r = sd_lldp_neighbor_tlv_rewind (neighbor_sd); if (r < 0) { g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, - "failed reading tlv (rewind): %s", g_strerror (-r)); + "failed reading tlv (rewind): %s", nm_strerror_native (-r)); goto out; } do { @@ -475,7 +475,7 @@ lldp_neighbor_new (sd_lldp_neighbor *neighbor_sd, GError **error) if (r == -ENXIO) continue; g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, - "failed reading tlv: %s", g_strerror (-r)); + "failed reading tlv: %s", nm_strerror_native (-r)); goto out; } diff --git a/src/dhcp/nm-dhcp-client.c b/src/dhcp/nm-dhcp-client.c index 39175dab38..a4fccce0b0 100644 --- a/src/dhcp/nm-dhcp-client.c +++ b/src/dhcp/nm-dhcp-client.c @@ -625,7 +625,7 @@ out: int errsv = errno; nm_log_dbg (LOGD_DHCP, "dhcp: could not remove pid file \"%s\": %s (%d)", - pid_file, g_strerror (errsv), errsv); + pid_file, nm_strerror_native (errsv), errsv); } } diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c index 3a3f1feae5..af702cb44c 100644 --- a/src/dhcp/nm-dhcp-dhclient.c +++ b/src/dhcp/nm-dhcp-dhclient.c @@ -598,12 +598,12 @@ stop (NMDhcpClient *client, gboolean release) if (priv->conf_file) if (remove (priv->conf_file) == -1) { errsv = errno; - _LOGD ("could not remove dhcp config file \"%s\": %d (%s)", priv->conf_file, errsv, g_strerror (errsv)); + _LOGD ("could not remove dhcp config file \"%s\": %d (%s)", priv->conf_file, errsv, nm_strerror_native (errsv)); } if (priv->pid_file) { if (remove (priv->pid_file) == -1) { errsv = errno; - _LOGD ("could not remove dhcp pid file \"%s\": %s (%d)", priv->pid_file, g_strerror (errsv), errsv); + _LOGD ("could not remove dhcp pid file \"%s\": %s (%d)", priv->pid_file, nm_strerror_native (errsv), errsv); } nm_clear_g_free (&priv->pid_file); } diff --git a/src/dhcp/nm-dhcp-dhcpcanon.c b/src/dhcp/nm-dhcp-dhcpcanon.c index e6bd14e055..868cc9dd5c 100644 --- a/src/dhcp/nm-dhcp-dhcpcanon.c +++ b/src/dhcp/nm-dhcp-dhcpcanon.c @@ -210,7 +210,7 @@ stop (NMDhcpClient *client, gboolean release) if (priv->pid_file) { if (remove (priv->pid_file) == -1) { errsv = errno; - _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errsv, g_strerror (errsv)); + _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errsv, nm_strerror_native (errsv)); } g_free (priv->pid_file); priv->pid_file = NULL; diff --git a/src/dhcp/nm-dhcp-dhcpcd.c b/src/dhcp/nm-dhcp-dhcpcd.c index 59ffe44132..2a7482b1fe 100644 --- a/src/dhcp/nm-dhcp-dhcpcd.c +++ b/src/dhcp/nm-dhcp-dhcpcd.c @@ -204,7 +204,7 @@ stop (NMDhcpClient *client, gboolean release) if (priv->pid_file) { if (remove (priv->pid_file) == -1) { errsv = errno; - _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errsv, g_strerror (errsv)); + _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errsv, nm_strerror_native (errsv)); } } diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c index 93426efda6..e506a890a9 100644 --- a/src/dns/nm-dns-manager.c +++ b/src/dns/nm-dns-manager.c @@ -677,7 +677,7 @@ write_resolv_conf_contents (FILE *f, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, "Could not write " _PATH_RESCONF ": %s", - g_strerror (errsv)); + nm_strerror_native (errsv)); errno = errsv; return FALSE; } @@ -749,7 +749,7 @@ dispatch_resolvconf (NMDnsManager *self, NM_MANAGER_ERROR_FAILED, "Could not write to %s: %s", RESOLVCONF_PATH, - g_strerror (errsv)); + nm_strerror_native (errsv)); return SR_ERROR; } @@ -887,9 +887,9 @@ update_resolv_conf (NMDnsManager *self, NM_MANAGER_ERROR_FAILED, "Could not open %s: %s", MY_RESOLV_CONF_TMP, - g_strerror (errsv)); + nm_strerror_native (errsv)); _LOGT ("update-resolv-conf: open temporary file %s failed (%s)", - MY_RESOLV_CONF_TMP, g_strerror (errsv)); + MY_RESOLV_CONF_TMP, nm_strerror_native (errsv)); return SR_ERROR; } @@ -897,7 +897,7 @@ update_resolv_conf (NMDnsManager *self, if (!success) { errsv = errno; _LOGT ("update-resolv-conf: write temporary file %s failed (%s)", - MY_RESOLV_CONF_TMP, g_strerror (errsv)); + MY_RESOLV_CONF_TMP, nm_strerror_native (errsv)); } if (fclose (f) < 0) { @@ -911,9 +911,9 @@ update_resolv_conf (NMDnsManager *self, NM_MANAGER_ERROR_FAILED, "Could not close %s: %s", MY_RESOLV_CONF_TMP, - g_strerror (errsv)); + nm_strerror_native (errsv)); _LOGT ("update-resolv-conf: close temporary file %s failed (%s)", - MY_RESOLV_CONF_TMP, g_strerror (errsv)); + MY_RESOLV_CONF_TMP, nm_strerror_native (errsv)); } return SR_ERROR; } else if (!success) @@ -926,9 +926,9 @@ update_resolv_conf (NMDnsManager *self, NM_MANAGER_ERROR_FAILED, "Could not replace %s: %s", MY_RESOLV_CONF, - g_strerror (errsv)); + nm_strerror_native (errsv)); _LOGT ("update-resolv-conf: failed to rename temporary file %s to %s (%s)", - MY_RESOLV_CONF_TMP, MY_RESOLV_CONF, g_strerror (errsv)); + MY_RESOLV_CONF_TMP, MY_RESOLV_CONF, nm_strerror_native (errsv)); return SR_ERROR; } @@ -963,10 +963,10 @@ update_resolv_conf (NMDnsManager *self, NM_MANAGER_ERROR_FAILED, "Could not unlink %s: %s", RESOLV_CONF_TMP, - g_strerror (errsv)); + nm_strerror_native (errsv)); _LOGT ("update-resolv-conf: write internal file %s succeeded " "but canot delete temporary file %s: %s", - MY_RESOLV_CONF, RESOLV_CONF_TMP, g_strerror (errsv)); + MY_RESOLV_CONF, RESOLV_CONF_TMP, nm_strerror_native (errsv)); return SR_ERROR; } @@ -978,10 +978,10 @@ update_resolv_conf (NMDnsManager *self, "Could not create symlink %s pointing to %s: %s", RESOLV_CONF_TMP, MY_RESOLV_CONF, - g_strerror (errsv)); + nm_strerror_native (errsv)); _LOGT ("update-resolv-conf: write internal file %s succeeded " "but failed to symlink %s: %s", - MY_RESOLV_CONF, RESOLV_CONF_TMP, g_strerror (errsv)); + MY_RESOLV_CONF, RESOLV_CONF_TMP, nm_strerror_native (errsv)); return SR_ERROR; } @@ -993,10 +993,10 @@ update_resolv_conf (NMDnsManager *self, "Could not rename %s to %s: %s", RESOLV_CONF_TMP, _PATH_RESCONF, - g_strerror (errsv)); + nm_strerror_native (errsv)); _LOGT ("update-resolv-conf: write internal file %s succeeded " "but failed to rename temporary symlink %s to %s: %s", - MY_RESOLV_CONF, RESOLV_CONF_TMP, _PATH_RESCONF, g_strerror (errsv)); + MY_RESOLV_CONF, RESOLV_CONF_TMP, _PATH_RESCONF, nm_strerror_native (errsv)); return SR_ERROR; } diff --git a/src/main-utils.c b/src/main-utils.c index 5799f09559..199945014c 100644 --- a/src/main-utils.c +++ b/src/main-utils.c @@ -130,13 +130,13 @@ nm_main_utils_ensure_statedir () && parent[1] != '\0' && g_mkdir_with_parents (parent, 0755) != 0) { errsv = errno; - fprintf (stderr, "Cannot create parents for '%s': %s", NMSTATEDIR, g_strerror (errsv)); + fprintf (stderr, "Cannot create parents for '%s': %s", NMSTATEDIR, nm_strerror_native (errsv)); exit (1); } /* Ensure state directory exists */ if (g_mkdir_with_parents (NMSTATEDIR, 0700) != 0) { errsv = errno; - fprintf (stderr, "Cannot create '%s': %s", NMSTATEDIR, g_strerror (errsv)); + fprintf (stderr, "Cannot create '%s': %s", NMSTATEDIR, nm_strerror_native (errsv)); exit (1); } } @@ -149,7 +149,7 @@ nm_main_utils_ensure_rundir () /* Setup runtime directory */ if (g_mkdir_with_parents (NMRUNDIR, 0755) != 0) { errsv = errno; - fprintf (stderr, _("Cannot create '%s': %s"), NMRUNDIR, g_strerror (errsv)); + fprintf (stderr, _("Cannot create '%s': %s"), NMRUNDIR, nm_strerror_native (errsv)); exit (1); } @@ -160,7 +160,7 @@ nm_main_utils_ensure_rundir () if (g_mkdir (NM_CONFIG_DEVICE_STATE_DIR, 0755) != 0) { errsv = errno; if (errsv != EEXIST) { - fprintf (stderr, _("Cannot create '%s': %s"), NM_CONFIG_DEVICE_STATE_DIR, g_strerror (errsv)); + fprintf (stderr, _("Cannot create '%s': %s"), NM_CONFIG_DEVICE_STATE_DIR, nm_strerror_native (errsv)); exit (1); } } diff --git a/src/main.c b/src/main.c index b9cbdc44ab..9f979cf4dc 100644 --- a/src/main.c +++ b/src/main.c @@ -334,7 +334,7 @@ main (int argc, char *argv[]) if (daemon (0, 0) < 0) { errsv = errno; fprintf (stderr, _("Could not daemonize: %s [error %u]\n"), - g_strerror (errsv), + nm_strerror_native (errsv), errsv); exit (1); } diff --git a/src/ndisc/nm-lndp-ndisc.c b/src/ndisc/nm-lndp-ndisc.c index 4c125d4c77..2dd7e7d8d2 100644 --- a/src/ndisc/nm-lndp-ndisc.c +++ b/src/ndisc/nm-lndp-ndisc.c @@ -84,7 +84,7 @@ send_rs (NMNDisc *ndisc, GError **error) errsv = nm_errno_native (errsv); g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, "%s (%d)", - g_strerror (errsv), errsv); + nm_strerror_native (errsv), errsv); return FALSE; } @@ -469,7 +469,7 @@ send_ra (NMNDisc *ndisc, GError **error) errsv = nm_errno_native (errsv); g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, "%s (%d)", - g_strerror (errsv), errsv); + nm_strerror_native (errsv), errsv); return FALSE; } @@ -600,7 +600,7 @@ nm_lndp_ndisc_new (NMPlatform *platform, errsv = nm_errno_native (errsv); g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, "failure creating libndp socket: %s (%d)", - g_strerror (errsv), errsv); + nm_strerror_native (errsv), errsv); g_object_unref (ndisc); return NULL; } diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index a038e79e5b..4d931ddd01 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -452,7 +452,7 @@ main (int argc, char *argv[]) if (daemon (0, 0) < 0) { errsv = errno; fprintf (stderr, _("Could not daemonize: %s [error %u]\n"), - g_strerror (errsv), + nm_strerror_native (errsv), errsv); return 1; } diff --git a/src/nm-manager.c b/src/nm-manager.c index 138cfb35fc..ce0d7c482f 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -7220,7 +7220,7 @@ rfkill_change (NMManager *self, const char *desc, RfKillType rtype, gboolean ena if (len < 0) { errsv = errno; _LOGW (LOGD_RFKILL, "rfkill: (%s): failed to change Wi-Fi killswitch state: (%d) %s", - desc, errsv, g_strerror (errsv)); + desc, errsv, nm_strerror_native (errsv)); } else if (len == sizeof (event)) { _LOGI (LOGD_RFKILL, "rfkill: %s hardware radio set %s", desc, enabled ? "enabled" : "disabled"); diff --git a/src/nm-policy.c b/src/nm-policy.c index 9cdddde008..a22b63326d 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -554,7 +554,7 @@ _get_hostname (NMPolicy *self) if (gethostname (hostname, HOST_NAME_BUFSIZE -1) != 0) { errsv = errno; _LOGT (LOGD_DNS, "get-hostname: couldn't get the system hostname: (%d) %s", - errsv, g_strerror (errsv)); + errsv, nm_strerror_native (errsv)); g_free (hostname); return NULL; } diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 1da9611003..78ccac8b69 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -459,7 +459,7 @@ G_DEFINE_TYPE (NMLinuxPlatform, nm_linux_platform, NM_TYPE_PLATFORM) _LOG_print (__level, __domain, __errsv, self, \ _NM_UTILS_MACRO_FIRST (__VA_ARGS__) ": %s (%d)" \ _NM_UTILS_MACRO_REST (__VA_ARGS__), \ - g_strerror (__errsv), __errsv); \ + nm_strerror_native (__errsv), __errsv); \ } \ } G_STMT_END @@ -510,7 +510,7 @@ wait_for_nl_response_to_string (WaitForNlResponseResult seq_result, if (seq_result < 0) { nm_utils_strbuf_append (&buf, &buf_size, "failure %d (%s%s%s)", -((int) seq_result), - g_strerror (-((int) seq_result)), + nm_strerror_native (-((int) seq_result)), errmsg ? " - " : "", errmsg ?: ""); } @@ -5055,7 +5055,7 @@ again: errsv = errno; if (errsv == EINTR && try_count++ < 100) goto again; - _LOGD ("netlink: nl-send-nlmsghdr: failed sending message: %s (%d)", g_strerror (errsv), errsv); + _LOGD ("netlink: nl-send-nlmsghdr: failed sending message: %s (%d)", nm_strerror_native (errsv), errsv); return -nm_errno_from_native (errsv); } } @@ -7580,7 +7580,7 @@ ip_route_get (NMPlatform *platform, nle = _nl_send_nlmsghdr (platform, &req.n, &seq_result, NULL, DELAYED_ACTION_RESPONSE_TYPE_ROUTE_GET, &route); if (nle < 0) { _LOGE ("get-route: failure sending netlink request \"%s\" (%d)", - g_strerror (-nle), -nle); + nm_strerror_native (-nle), -nle); return -NME_UNSPEC; } diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c index 69ce4d88a1..0116e887bd 100644 --- a/src/platform/nm-platform-utils.c +++ b/src/platform/nm-platform-utils.c @@ -181,7 +181,7 @@ ethtool_call_ifindex (int ifindex, gpointer edata) nm_log_trace (LOGD_PLATFORM, "ethtool[%d]: %s: failed creating ethtool socket: %s", ifindex, _ethtool_data_to_string (edata, sbuf, sizeof (sbuf)), - g_strerror (-r)); + nm_strerror_native (-r)); return r; } @@ -487,7 +487,7 @@ nmp_utils_ethtool_get_features (int ifindex) nm_log_trace (LOGD_PLATFORM, "ethtool[%d]: %s: failed creating ethtool socket: %s", ifindex, "get-features", - g_strerror (-r)); + nm_strerror_native (-r)); return FALSE; } @@ -618,7 +618,7 @@ nmp_utils_ethtool_set_features (int ifindex, nm_log_trace (LOGD_PLATFORM, "ethtool[%d]: %s: failed creating ethtool socket: %s", ifindex, "set-features", - g_strerror (-r)); + nm_strerror_native (-r)); return FALSE; } @@ -654,7 +654,7 @@ nmp_utils_ethtool_set_features (int ifindex, nm_log_trace (LOGD_PLATFORM, "ethtool[%d]: %s: failure setting features (%s)", ifindex, "set-features", - g_strerror (-r)); + nm_strerror_native (-r)); return FALSE; } @@ -764,7 +764,7 @@ nmp_utils_ethtool_supports_vlans (int ifindex) nm_log_trace (LOGD_PLATFORM, "ethtool[%d]: %s: failed creating ethtool socket: %s", ifindex, "support-vlans", - g_strerror (-r)); + nm_strerror_native (-r)); return FALSE; } @@ -803,7 +803,7 @@ nmp_utils_ethtool_get_peer_ifindex (int ifindex) nm_log_trace (LOGD_PLATFORM, "ethtool[%d]: %s: failed creating ethtool socket: %s", ifindex, "get-peer-ifindex", - g_strerror (-r)); + nm_strerror_native (-r)); return FALSE; } @@ -1050,7 +1050,7 @@ nmp_utils_mii_supports_carrier_detect (int ifindex) if ((r = socket_handle_init (&shandle, ifindex)) < 0) { nm_log_trace (LOGD_PLATFORM, "mii[%d]: carrier-detect no: failed creating ethtool socket: %s", ifindex, - g_strerror (-r)); + nm_strerror_native (-r)); return FALSE; } diff --git a/src/platform/nmp-netns.c b/src/platform/nmp-netns.c index 8a71ff61d5..f34dc83dd6 100644 --- a/src/platform/nmp-netns.c +++ b/src/platform/nmp-netns.c @@ -332,7 +332,7 @@ _netns_new (GError **error) errsv = errno; g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, "Failed opening netns: %s", - g_strerror (errsv)); + nm_strerror_native (errsv)); errno = errsv; return NULL; } @@ -342,7 +342,7 @@ _netns_new (GError **error) errsv = errno; g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, "Failed opening mntns: %s", - g_strerror (errsv)); + nm_strerror_native (errsv)); nm_close (fd_net); errno = errsv; return NULL; @@ -385,14 +385,14 @@ _netns_switch_push (GArray *netns_stack, && !_stack_current_ns_types (netns_stack, self, CLONE_NEWNET) && _setns (self, CLONE_NEWNET) != 0) { errsv = errno; - _LOGE (self, "failed to switch netns: %s", g_strerror (errsv)); + _LOGE (self, "failed to switch netns: %s", nm_strerror_native (errsv)); return FALSE; } if ( NM_FLAGS_HAS (ns_types, CLONE_NEWNS) && !_stack_current_ns_types (netns_stack, self, CLONE_NEWNS) && _setns (self, CLONE_NEWNS) != 0) { errsv = errno; - _LOGE (self, "failed to switch mntns: %s", g_strerror (errsv)); + _LOGE (self, "failed to switch mntns: %s", nm_strerror_native (errsv)); /* try to fix the mess by returning to the previous netns. */ if ( NM_FLAGS_HAS (ns_types, CLONE_NEWNET) @@ -401,7 +401,7 @@ _netns_switch_push (GArray *netns_stack, if ( self && _setns (self, CLONE_NEWNET) != 0) { errsv = errno; - _LOGE (self, "failed to restore netns: %s", g_strerror (errsv)); + _LOGE (self, "failed to restore netns: %s", nm_strerror_native (errsv)); } } return FALSE; @@ -428,7 +428,7 @@ _netns_switch_pop (GArray *netns_stack, success = FALSE; } else if (_setns (current, CLONE_NEWNET) != 0) { errsv = errno; - _LOGE (self, "failed to switch netns: %s", g_strerror (errsv)); + _LOGE (self, "failed to switch netns: %s", nm_strerror_native (errsv)); success = FALSE; } } @@ -440,7 +440,7 @@ _netns_switch_pop (GArray *netns_stack, success = FALSE; } else if (_setns (current, CLONE_NEWNS) != 0) { errsv = errno; - _LOGE (self, "failed to switch mntns: %s", g_strerror (errsv)); + _LOGE (self, "failed to switch mntns: %s", nm_strerror_native (errsv)); success = FALSE; } } @@ -534,19 +534,19 @@ nmp_netns_new (void) if (unshare (_CLONE_NS_ALL) != 0) { errsv = errno; - _LOGE (NULL, "failed to create new net and mnt namespace: %s", g_strerror (errsv)); + _LOGE (NULL, "failed to create new net and mnt namespace: %s", nm_strerror_native (errsv)); return NULL; } if (mount ("", "/", "none", MS_SLAVE | MS_REC, NULL) != 0) { errsv = errno; - _LOGE (NULL, "failed mount --make-rslave: %s", g_strerror (errsv)); + _LOGE (NULL, "failed mount --make-rslave: %s", nm_strerror_native (errsv)); goto err_out; } if (umount2 ("/sys", MNT_DETACH) != 0) { errsv = errno; - _LOGE (NULL, "failed umount /sys: %s", g_strerror (errsv)); + _LOGE (NULL, "failed umount /sys: %s", nm_strerror_native (errsv)); goto err_out; } @@ -555,7 +555,7 @@ nmp_netns_new (void) if (mount ("sysfs", "/sys", "sysfs", mountflags, NULL) != 0) { errsv = errno; - _LOGE (NULL, "failed mount /sys: %s", g_strerror (errsv)); + _LOGE (NULL, "failed mount /sys: %s", nm_strerror_native (errsv)); goto err_out; } @@ -653,7 +653,7 @@ nmp_netns_bind_to_path (NMPNetns *self, const char *filename, int *out_fd) errsv = errno; if (errsv != EEXIST) { _LOGE (self, "bind: failed to create directory %s: %s", - dirname, g_strerror (errsv)); + dirname, nm_strerror_native (errsv)); return FALSE; } } @@ -661,7 +661,7 @@ nmp_netns_bind_to_path (NMPNetns *self, const char *filename, int *out_fd) if ((fd = creat (filename, S_IRUSR | S_IRGRP | S_IROTH)) == -1) { errsv = errno; _LOGE (self, "bind: failed to create %s: %s", - filename, g_strerror (errsv)); + filename, nm_strerror_native (errsv)); return FALSE; } nm_close (fd); @@ -669,7 +669,7 @@ nmp_netns_bind_to_path (NMPNetns *self, const char *filename, int *out_fd) if (mount (PROC_SELF_NS_NET, filename, "none", MS_BIND, NULL) != 0) { errsv = errno; _LOGE (self, "bind: failed to mount %s to %s: %s", - PROC_SELF_NS_NET, filename, g_strerror (errsv)); + PROC_SELF_NS_NET, filename, nm_strerror_native (errsv)); unlink (filename); return FALSE; } @@ -677,7 +677,7 @@ nmp_netns_bind_to_path (NMPNetns *self, const char *filename, int *out_fd) if (out_fd) { if ((fd = open (filename, O_RDONLY | O_CLOEXEC)) == -1) { errsv = errno; - _LOGE (self, "bind: failed to open %s: %s", filename, g_strerror (errsv)); + _LOGE (self, "bind: failed to open %s: %s", filename, nm_strerror_native (errsv)); umount2 (filename, MNT_DETACH); unlink (filename); return FALSE; @@ -698,12 +698,12 @@ nmp_netns_bind_to_path_destroy (NMPNetns *self, const char *filename) if (umount2 (filename, MNT_DETACH) != 0) { errsv = errno; - _LOGE (self, "bind: failed to unmount2 %s: %s", filename, g_strerror (errsv)); + _LOGE (self, "bind: failed to unmount2 %s: %s", filename, nm_strerror_native (errsv)); return FALSE; } if (unlink (filename) != 0) { errsv = errno; - _LOGE (self, "bind: failed to unlink %s: %s", filename, g_strerror (errsv)); + _LOGE (self, "bind: failed to unlink %s: %s", filename, nm_strerror_native (errsv)); return FALSE; } return TRUE; diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c index 549b9276ff..e11858d634 100644 --- a/src/platform/tests/test-link.c +++ b/src/platform/tests/test-link.c @@ -2393,7 +2393,7 @@ _test_netns_check_skip (void) support_errsv = errno; } if (!support) { - _LOGD ("setns() failed with \"%s\". This indicates missing support (valgrind?)", g_strerror (support_errsv)); + _LOGD ("setns() failed with \"%s\". This indicates missing support (valgrind?)", nm_strerror_native (support_errsv)); g_test_skip ("No netns support (setns failed)"); return TRUE; } diff --git a/src/platform/wifi/nm-wifi-utils-wext.c b/src/platform/wifi/nm-wifi-utils-wext.c index 80680f56be..888575778b 100644 --- a/src/platform/wifi/nm-wifi-utils-wext.c +++ b/src/platform/wifi/nm-wifi-utils-wext.c @@ -115,7 +115,7 @@ get_ifname (int ifindex, char *buffer, const char *op) errsv = errno; _LOGW (LOGD_PLATFORM | LOGD_WIFI, "error getting interface name for ifindex %d, operation '%s': %s (%d)", - ifindex, op, g_strerror (errsv), errsv); + ifindex, op, nm_strerror_native (errsv), errsv); return FALSE; } diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c index 2ae94e38e3..e18041de9b 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -4994,7 +4994,7 @@ handle_bridge_option (NMSetting *setting, } else { v = _nm_utils_ascii_str_to_int64 (value, 10, 0, 1, -1); if (v == -1) { - error_message = g_strerror (errno); + error_message = nm_strerror_native (errno); goto warn; } } @@ -5006,7 +5006,7 @@ handle_bridge_option (NMSetting *setting, case G_TYPE_UINT: v = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT, -1); if (v == -1) { - error_message = g_strerror (errno); + error_message = nm_strerror_native (errno); goto warn; } if (!nm_g_object_set_property_uint (G_OBJECT (setting), m[i].property_name, v, NULL)) { diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 6c30e12937..b352fbfc7c 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -10025,7 +10025,7 @@ int main (int argc, char **argv) if (g_mkdir_with_parents (TEST_SCRATCH_DIR_TMP, 0755) != 0) { errsv = errno; - g_error ("failure to create test directory \"%s\": %s", TEST_SCRATCH_DIR_TMP, g_strerror (errsv)); + g_error ("failure to create test directory \"%s\": %s", TEST_SCRATCH_DIR_TMP, nm_strerror_native (errsv)); } g_test_add_func (TPATH "svUnescape", test_svUnescape); diff --git a/src/settings/plugins/keyfile/nms-keyfile-utils.c b/src/settings/plugins/keyfile/nms-keyfile-utils.c index 3e83e16be9..3c4b02885f 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-utils.c +++ b/src/settings/plugins/keyfile/nms-keyfile-utils.c @@ -276,14 +276,14 @@ nms_keyfile_utils_check_file_permissions (NMSKeyfileFiletype filetype, if (stat (filename, &st) != 0) { errsv = errno; g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "cannot access file: %s", g_strerror (errsv)); + "cannot access file: %s", nm_strerror_native (errsv)); return FALSE; } } else if (filetype == NMS_KEYFILE_FILETYPE_NMLOADED) { if (lstat (filename, &st) != 0) { errsv = errno; g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "cannot access file: %s", g_strerror (errsv)); + "cannot access file: %s", nm_strerror_native (errsv)); return FALSE; } } else diff --git a/src/settings/plugins/keyfile/nms-keyfile-writer.c b/src/settings/plugins/keyfile/nms-keyfile-writer.c index 6e2f5b1909..401c8d59e2 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-writer.c +++ b/src/settings/plugins/keyfile/nms-keyfile-writer.c @@ -298,7 +298,7 @@ _internal_write_connection (NMConnection *connection, errsv = errno; g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "error chowning '%s': %s (%d)", - path, g_strerror (errsv), errsv); + path, nm_strerror_native (errsv), errsv); unlink (path); return FALSE; } diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c index 3655563d24..baecac13bc 100644 --- a/src/settings/plugins/keyfile/tests/test-keyfile.c +++ b/src/settings/plugins/keyfile/tests/test-keyfile.c @@ -2622,7 +2622,7 @@ int main (int argc, char **argv) if (g_mkdir_with_parents (TEST_SCRATCH_DIR, 0755) != 0) { errsv = errno; - g_error ("failure to create test directory \"%s\": %s", TEST_SCRATCH_DIR, g_strerror (errsv)); + g_error ("failure to create test directory \"%s\": %s", TEST_SCRATCH_DIR, nm_strerror_native (errsv)); } /* The tests */ From 9beed4f661d0b8e02c16a616e7491baa42af0843 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 31 Jan 2019 17:22:18 +0100 Subject: [PATCH 11/13] all: replace strerror() calls with nm_strerror_native() --- clients/cli/utils.c | 12 ++++---- libnm-core/nm-utils.c | 2 +- shared/nm-utils/nm-test-utils.h | 6 ++-- src/devices/bluetooth/nm-bluez5-dun.c | 14 +++++----- src/devices/nm-device.c | 4 +-- src/dns/nm-dns-manager.c | 2 +- src/initrd/nm-initrd-generator.c | 2 +- src/main-utils.c | 6 ++-- src/nm-audit-manager.c | 2 +- src/nm-core-utils.c | 28 +++++++++---------- src/nm-dispatcher.c | 2 +- src/nm-iface-helper.c | 2 +- src/nm-policy.c | 2 +- src/nm-session-monitor.c | 2 +- src/platform/nm-linux-platform.c | 20 ++++++------- src/platform/nm-platform-utils.c | 6 ++-- src/platform/tests/test-common.c | 12 ++++---- src/platform/wifi/nm-wifi-utils-wext.c | 10 +++---- src/ppp/nm-ppp-manager.c | 4 +-- src/settings/nm-settings.c | 2 +- .../plugins/ifcfg-rh/nm-inotify-helper.c | 2 +- src/settings/plugins/ifcfg-rh/shvar.c | 8 +++--- 22 files changed, 75 insertions(+), 75 deletions(-) diff --git a/clients/cli/utils.c b/clients/cli/utils.c index b3190b085c..0e74ba8867 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -1434,12 +1434,12 @@ pager_fallback (void) errsv = errno; if (errsv == EINTR) continue; - g_printerr (_("Error reading nmcli output: %s\n"), strerror (errsv)); + g_printerr (_("Error reading nmcli output: %s\n"), nm_strerror_native (errsv)); _exit(EXIT_FAILURE); } if (write (STDOUT_FILENO, buf, rb) == -1) { errsv = errno; - g_printerr (_("Error writing nmcli output: %s\n"), strerror (errsv)); + g_printerr (_("Error writing nmcli output: %s\n"), nm_strerror_native (errsv)); _exit(EXIT_FAILURE); } } while (rb > 0); @@ -1465,7 +1465,7 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config) if (pipe (fd) == -1) { errsv = errno; - g_printerr (_("Failed to create pager pipe: %s\n"), strerror (errsv)); + g_printerr (_("Failed to create pager pipe: %s\n"), nm_strerror_native (errsv)); return 0; } @@ -1474,7 +1474,7 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config) pager_pid = fork (); if (pager_pid == -1) { errsv = errno; - g_printerr (_("Failed to fork pager: %s\n"), strerror (errsv)); + g_printerr (_("Failed to fork pager: %s\n"), nm_strerror_native (errsv)); nm_close (fd[0]); nm_close (fd[1]); return 0; @@ -1521,11 +1521,11 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config) /* Return in the parent */ if (dup2 (fd[1], STDOUT_FILENO) < 0) { errsv = errno; - g_printerr (_("Failed to duplicate pager pipe: %s\n"), strerror (errsv)); + g_printerr (_("Failed to duplicate pager pipe: %s\n"), nm_strerror_native (errsv)); } if (dup2 (fd[1], STDERR_FILENO) < 0) { errsv = errno; - g_printerr (_("Failed to duplicate pager pipe: %s\n"), strerror (errsv)); + g_printerr (_("Failed to duplicate pager pipe: %s\n"), nm_strerror_native (errsv)); } nm_close (fd[0]); diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index b1d5761ff3..506f434497 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -3105,7 +3105,7 @@ _nm_utils_check_file (const char *filename, g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_FAILED, - _("failed stat file %s: %s"), filename, strerror (errsv)); + _("failed stat file %s: %s"), filename, nm_strerror_native (errsv)); return FALSE; } diff --git a/shared/nm-utils/nm-test-utils.h b/shared/nm-utils/nm-test-utils.h index 5424d22247..c5ea5e3f2d 100644 --- a/shared/nm-utils/nm-test-utils.h +++ b/shared/nm-utils/nm-test-utils.h @@ -1060,7 +1060,7 @@ nmtst_reexec_sudo (void) execvp (__nmtst_internal.sudo_cmd, argv); errsv = errno; - g_error (">> exec %s failed: %d - %s", __nmtst_internal.sudo_cmd, errsv, strerror (errsv)); + g_error (">> exec %s failed: %d - %s", __nmtst_internal.sudo_cmd, errsv, nm_strerror_native (errsv)); } /*****************************************************************************/ @@ -1370,7 +1370,7 @@ nmtst_file_unlink_if_exists (const char *name) if (unlink (name) != 0) { errsv = errno; if (errsv != ENOENT) - g_error ("nmtst_file_unlink_if_exists(%s): failed with %s", name, strerror (errsv)); + g_error ("nmtst_file_unlink_if_exists(%s): failed with %s", name, nm_strerror_native (errsv)); } } @@ -1383,7 +1383,7 @@ nmtst_file_unlink (const char *name) if (unlink (name) != 0) { errsv = errno; - g_error ("nmtst_file_unlink(%s): failed with %s", name, strerror (errsv)); + g_error ("nmtst_file_unlink(%s): failed with %s", name, nm_strerror_native (errsv)); } } diff --git a/src/devices/bluetooth/nm-bluez5-dun.c b/src/devices/bluetooth/nm-bluez5-dun.c index ae5efcedfc..ff3a0da99e 100644 --- a/src/devices/bluetooth/nm-bluez5-dun.c +++ b/src/devices/bluetooth/nm-bluez5-dun.c @@ -69,7 +69,7 @@ dun_connect (NMBluez5DunContext *context) errsv = errno; error = g_error_new (NM_BT_ERROR, NM_BT_ERROR_DUN_CONNECT_FAILED, "Failed to create RFCOMM socket: (%d) %s", - errsv, strerror (errsv)); + errsv, nm_strerror_native (errsv)); goto done; } @@ -81,7 +81,7 @@ dun_connect (NMBluez5DunContext *context) errsv = errno; error = g_error_new (NM_BT_ERROR, NM_BT_ERROR_DUN_CONNECT_FAILED, "Failed to bind socket: (%d) %s", - errsv, strerror (errsv)); + errsv, nm_strerror_native (errsv)); goto done; } @@ -91,7 +91,7 @@ dun_connect (NMBluez5DunContext *context) errsv = errno; error = g_error_new (NM_BT_ERROR, NM_BT_ERROR_DUN_CONNECT_FAILED, "Failed to connect to remote device: (%d) %s", - errsv, strerror (errsv)); + errsv, nm_strerror_native (errsv)); goto done; } @@ -106,7 +106,7 @@ dun_connect (NMBluez5DunContext *context) errsv = errno; error = g_error_new (NM_BT_ERROR, NM_BT_ERROR_DUN_CONNECT_FAILED, "Failed to create rfcomm device: (%d) %s", - errsv, strerror (errsv)); + errsv, nm_strerror_native (errsv)); goto done; } context->rfcomm_id = devid; @@ -271,7 +271,7 @@ sdp_connect_watch (GIOChannel *channel, GIOCondition condition, gpointer user_da if (err != 0) { error = g_error_new (NM_BT_ERROR, NM_BT_ERROR_DUN_CONNECT_FAILED, "Error on Service Discovery socket: (%d) %s", - err, strerror (err)); + err, nm_strerror_native (err)); goto done; } @@ -298,7 +298,7 @@ sdp_connect_watch (GIOChannel *channel, GIOCondition condition, gpointer user_da error = g_error_new (NM_BT_ERROR, NM_BT_ERROR_DUN_CONNECT_FAILED, "Error starting Service Discovery: (%d) %s", - err, strerror (err)); + err, nm_strerror_native (err)); } sdp_list_free (attrs, NULL); @@ -359,7 +359,7 @@ nm_bluez5_dun_connect (NMBluez5DunContext *context, error = g_error_new (NM_BT_ERROR, NM_BT_ERROR_DUN_CONNECT_FAILED, "Failed to connect to the SDP server: (%d) %s", - err, strerror (err)); + err, nm_strerror_native (err)); /* FIXME: don't invoke the callback synchronously. */ context->callback (context, NULL, error, context->user_data); return; diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 2426bb4d8a..8b68469cd9 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -10183,7 +10183,7 @@ share_init (NMDevice *self, GError **error) } else if (!nm_platform_sysctl_set (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv4/ip_dynaddr"), "1")) { errsv = errno; _LOGD (LOGD_SHARING, "share: error enabling dynamic addresses: (%d) %s", - errsv, strerror (errsv)); + errsv, nm_strerror_native (errsv)); } for (iter = modules; *iter; iter++) @@ -10569,7 +10569,7 @@ activate_stage5_ip6_config_commit (NMDevice *self) if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) { if (!nm_platform_sysctl_set (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv6/conf/all/forwarding"), "1")) { errsv = errno; - _LOGE (LOGD_SHARING, "share: error enabling IPv6 forwarding: (%d) %s", errsv, strerror (errsv)); + _LOGE (LOGD_SHARING, "share: error enabling IPv6 forwarding: (%d) %s", errsv, nm_strerror_native (errsv)); nm_device_ip_method_failed (self, AF_INET6, NM_DEVICE_STATE_REASON_SHARED_START_FAILED); } } diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c index e506a890a9..c7c561c459 100644 --- a/src/dns/nm-dns-manager.c +++ b/src/dns/nm-dns-manager.c @@ -569,7 +569,7 @@ again: errsv = errno; g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, "Error waiting for netconfig to exit: %s", - strerror (errsv)); + nm_strerror_native (errsv)); return SR_ERROR; } if (!WIFEXITED (status) || WEXITSTATUS (status) != EXIT_SUCCESS) { diff --git a/src/initrd/nm-initrd-generator.c b/src/initrd/nm-initrd-generator.c index 9946be7df8..b84543c42e 100644 --- a/src/initrd/nm-initrd-generator.c +++ b/src/initrd/nm-initrd-generator.c @@ -123,7 +123,7 @@ main (int argc, char *argv[]) if (connections_dir && g_mkdir_with_parents (connections_dir, 0755) != 0) { errsv = errno; - _LOGW (LOGD_CORE, "%s: %s", connections_dir, strerror (errsv)); + _LOGW (LOGD_CORE, "%s: %s", connections_dir, nm_strerror_native (errsv)); return 1; } diff --git a/src/main-utils.c b/src/main-utils.c index 199945014c..f3a2edf5e1 100644 --- a/src/main-utils.c +++ b/src/main-utils.c @@ -97,20 +97,20 @@ nm_main_utils_write_pidfile (const char *pidfile) if ((fd = open (pidfile, O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC, 00644)) < 0) { errsv = errno; - fprintf (stderr, _("Opening %s failed: %s\n"), pidfile, strerror (errsv)); + fprintf (stderr, _("Opening %s failed: %s\n"), pidfile, nm_strerror_native (errsv)); return FALSE; } g_snprintf (pid, sizeof (pid), "%d", getpid ()); if (write (fd, pid, strlen (pid)) < 0) { errsv = errno; - fprintf (stderr, _("Writing to %s failed: %s\n"), pidfile, strerror (errsv)); + fprintf (stderr, _("Writing to %s failed: %s\n"), pidfile, nm_strerror_native (errsv)); } else success = TRUE; if (nm_close (fd)) { errsv = errno; - fprintf (stderr, _("Closing %s failed: %s\n"), pidfile, strerror (errsv)); + fprintf (stderr, _("Closing %s failed: %s\n"), pidfile, nm_strerror_native (errsv)); } return success; diff --git a/src/nm-audit-manager.c b/src/nm-audit-manager.c index 05fc88cc25..9f868508be 100644 --- a/src/nm-audit-manager.c +++ b/src/nm-audit-manager.c @@ -344,7 +344,7 @@ init_auditd (NMAuditManager *self) priv->auditd_fd = audit_open (); if (priv->auditd_fd < 0) { errsv = errno; - _LOGE (LOGD_CORE, "failed to open auditd socket: %s", strerror (errsv)); + _LOGE (LOGD_CORE, "failed to open auditd socket: %s", nm_strerror_native (errsv)); } else _LOGD (LOGD_CORE, "socket created"); } diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c index 2798b07f21..6141c5f1cf 100644 --- a/src/nm-core-utils.c +++ b/src/nm-core-utils.c @@ -573,7 +573,7 @@ _kc_cb_timeout_grace_period (void *user_data) /* ESRCH means, process does not exist or is already a zombie. */ if (errsv != ESRCH) { nm_log_err (LOGD_CORE | data->log_domain, "%s: kill(SIGKILL) returned unexpected return value %d: (%s, %d)", - data->log_name, ret, strerror (errsv), errsv); + data->log_name, ret, nm_strerror_native (errsv), errsv); } } else { nm_log_dbg (data->log_domain, "%s: process not terminated after %ld usec. Sending SIGKILL signal", @@ -659,7 +659,7 @@ nm_utils_kill_child_async (pid_t pid, int sig, NMLogDomain log_domain, /* ECHILD means, the process is not a child/does not exist or it has SIGCHILD blocked. */ if (errsv != ECHILD) { nm_log_err (LOGD_CORE | log_domain, LOG_NAME_FMT ": unexpected error while waitpid: %s (%d)", - LOG_NAME_ARGS, strerror (errsv), errsv); + LOG_NAME_ARGS, nm_strerror_native (errsv), errsv); _kc_invoke_callback (pid, log_domain, log_name, callback, user_data, FALSE, -1); return; } @@ -671,7 +671,7 @@ nm_utils_kill_child_async (pid_t pid, int sig, NMLogDomain log_domain, /* ESRCH means, process does not exist or is already a zombie. */ if (errsv != ESRCH) { nm_log_err (LOGD_CORE | log_domain, LOG_NAME_FMT ": unexpected error sending %s: %s (%d)", - LOG_NAME_ARGS, _kc_signal_to_string (sig), strerror (errsv), errsv); + LOG_NAME_ARGS, _kc_signal_to_string (sig), nm_strerror_native (errsv), errsv); _kc_invoke_callback (pid, log_domain, log_name, callback, user_data, FALSE, -1); return; } @@ -685,7 +685,7 @@ nm_utils_kill_child_async (pid_t pid, int sig, NMLogDomain log_domain, } else { errsv = errno; nm_log_err (LOGD_CORE | log_domain, LOG_NAME_FMT ": failed due to unexpected return value %ld by waitpid (%s, %d) after sending %s", - LOG_NAME_ARGS, (long) ret, strerror (errsv), errsv, _kc_signal_to_string (sig)); + LOG_NAME_ARGS, (long) ret, nm_strerror_native (errsv), errsv, _kc_signal_to_string (sig)); _kc_invoke_callback (pid, log_domain, log_name, callback, user_data, FALSE, -1); } return; @@ -767,7 +767,7 @@ nm_utils_kill_child_sync (pid_t pid, int sig, NMLogDomain log_domain, const char /* ECHILD means, the process is not a child/does not exist or it has SIGCHILD blocked. */ if (errsv != ECHILD) { nm_log_err (LOGD_CORE | log_domain, LOG_NAME_FMT ": unexpected error while waitpid: %s (%d)", - LOG_NAME_ARGS, strerror (errsv), errsv); + LOG_NAME_ARGS, nm_strerror_native (errsv), errsv); goto out; } } @@ -778,7 +778,7 @@ nm_utils_kill_child_sync (pid_t pid, int sig, NMLogDomain log_domain, const char /* ESRCH means, process does not exist or is already a zombie. */ if (errsv != ESRCH) { nm_log_err (LOGD_CORE | log_domain, LOG_NAME_FMT ": failed to send %s: %s (%d)", - LOG_NAME_ARGS, _kc_signal_to_string (sig), strerror (errsv), errsv); + LOG_NAME_ARGS, _kc_signal_to_string (sig), nm_strerror_native (errsv), errsv); } else { /* let's try again with waitpid, probably there was a race... */ ret = waitpid (pid, &status, 0); @@ -789,7 +789,7 @@ nm_utils_kill_child_sync (pid_t pid, int sig, NMLogDomain log_domain, const char } else { errsv = errno; nm_log_err (LOGD_CORE | log_domain, LOG_NAME_FMT ": failed due to unexpected return value %ld by waitpid (%s, %d) after sending %s", - LOG_NAME_ARGS, (long) ret, strerror (errsv), errsv, _kc_signal_to_string (sig)); + LOG_NAME_ARGS, (long) ret, nm_strerror_native (errsv), errsv, _kc_signal_to_string (sig)); } } goto out; @@ -820,7 +820,7 @@ nm_utils_kill_child_sync (pid_t pid, int sig, NMLogDomain log_domain, const char /* ECHILD means, the process is not a child/does not exist or it has SIGCHILD blocked. */ if (errsv != ECHILD) { nm_log_err (LOGD_CORE | log_domain, LOG_NAME_FMT ": after sending %s, waitpid failed with %s (%d)%s", - LOG_NAME_ARGS, _kc_signal_to_string (sig), strerror (errsv), errsv, + LOG_NAME_ARGS, _kc_signal_to_string (sig), nm_strerror_native (errsv), errsv, was_waiting ? _kc_waited_to_string (buf_wait, wait_start_us) : ""); goto out; } @@ -859,7 +859,7 @@ nm_utils_kill_child_sync (pid_t pid, int sig, NMLogDomain log_domain, const char /* ESRCH means, process does not exist or is already a zombie. */ if (errsv != ESRCH) { nm_log_err (LOGD_CORE | log_domain, LOG_NAME_FMT ": failed to send SIGKILL (after sending %s), %s (%d)", - LOG_NAME_ARGS, _kc_signal_to_string (sig), strerror (errsv), errsv); + LOG_NAME_ARGS, _kc_signal_to_string (sig), nm_strerror_native (errsv), errsv); goto out; } } @@ -877,7 +877,7 @@ nm_utils_kill_child_sync (pid_t pid, int sig, NMLogDomain log_domain, const char if (errsv != EINTR) { nm_log_err (LOGD_CORE | log_domain, LOG_NAME_FMT ": after sending %s%s, waitpid failed with %s (%d)%s", - LOG_NAME_ARGS, _kc_signal_to_string (sig), send_kill ? " and SIGKILL" : "", strerror (errsv), errsv, + LOG_NAME_ARGS, _kc_signal_to_string (sig), send_kill ? " and SIGKILL" : "", nm_strerror_native (errsv), errsv, _kc_waited_to_string (buf_wait, wait_start_us)); goto out; } @@ -965,7 +965,7 @@ nm_utils_kill_process_sync (pid_t pid, guint64 start_time, int sig, NMLogDomain LOG_NAME_ARGS, _kc_signal_to_string (sig)); } else { nm_log_warn (LOGD_CORE | log_domain, LOG_NAME_PROCESS_FMT ": failed to send %s: %s (%d)", - LOG_NAME_ARGS, _kc_signal_to_string (sig), strerror (errsv), errsv); + LOG_NAME_ARGS, _kc_signal_to_string (sig), nm_strerror_native (errsv), errsv); } return; } @@ -1016,7 +1016,7 @@ nm_utils_kill_process_sync (pid_t pid, guint64 start_time, int sig, NMLogDomain was_waiting ? _kc_waited_to_string (buf_wait, wait_start_us) : ""); } else { nm_log_warn (LOGD_CORE | log_domain, LOG_NAME_PROCESS_FMT ": failed to kill(%ld, 0): %s (%d)%s", - LOG_NAME_ARGS, (long int) pid, strerror (errsv), errsv, + LOG_NAME_ARGS, (long int) pid, nm_strerror_native (errsv), errsv, was_waiting ? _kc_waited_to_string (buf_wait, wait_start_us) : ""); } return; @@ -1052,7 +1052,7 @@ nm_utils_kill_process_sync (pid_t pid, guint64 start_time, int sig, NMLogDomain LOG_NAME_ARGS, _kc_waited_to_string (buf_wait, wait_start_us)); } else { nm_log_warn (LOGD_CORE | log_domain, LOG_NAME_PROCESS_FMT ": failed to send SIGKILL (after sending %s), %s (%d)%s", - LOG_NAME_ARGS, _kc_signal_to_string (sig), strerror (errsv), errsv, + LOG_NAME_ARGS, _kc_signal_to_string (sig), nm_strerror_native (errsv), errsv, _kc_waited_to_string (buf_wait, wait_start_us)); } return; @@ -4141,7 +4141,7 @@ nm_utils_read_plugin_paths (const char *dirname, const char *prefix) errsv = errno; nm_log_warn (LOGD_CORE, "plugin: skip invalid file %s (error during stat: %s)", - data.path, strerror (errsv)); + data.path, nm_strerror_native (errsv)); goto skip; } diff --git a/src/nm-dispatcher.c b/src/nm-dispatcher.c index 4d8d9f8a8e..c0ef1bb6b0 100644 --- a/src/nm-dispatcher.c +++ b/src/nm-dispatcher.c @@ -962,7 +962,7 @@ dispatcher_dir_changed (GFileMonitor *monitor, else if (errsv == 0) _LOGD ("%s script directory '%s' has no scripts", item->description, item->dir); else { - _LOGD ("%s script directory '%s' error reading (%s)", item->description, item->dir, strerror (errsv)); + _LOGD ("%s script directory '%s' error reading (%s)", item->description, item->dir, nm_strerror_native (errsv)); item->has_scripts = TRUE; } } else { diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index 4d931ddd01..1ef9f5aea6 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -425,7 +425,7 @@ main (int argc, char *argv[]) gl.ifindex = nmp_utils_if_nametoindex (global_opt.ifname); if (gl.ifindex <= 0) { errsv = errno; - fprintf (stderr, _("Failed to find interface index for %s (%s)\n"), global_opt.ifname, strerror (errsv)); + fprintf (stderr, _("Failed to find interface index for %s (%s)\n"), global_opt.ifname, nm_strerror_native (errsv)); return 1; } pidfile = g_strdup_printf (NMIH_PID_FILE_FMT, gl.ifindex); diff --git a/src/nm-policy.c b/src/nm-policy.c index a22b63326d..cb0688f43b 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -514,7 +514,7 @@ settings_set_hostname_cb (const char *hostname, if (ret != 0) { errsv = errno; _LOGW (LOGD_DNS, "set-hostname: couldn't set the system hostname to '%s': (%d) %s", - hostname, errsv, strerror (errsv)); + hostname, errsv, nm_strerror_native (errsv)); if (errsv == EPERM) _LOGW (LOGD_DNS, "set-hostname: you should use hostnamed when systemd hardening is in effect!"); } diff --git a/src/nm-session-monitor.c b/src/nm-session-monitor.c index 31810b8dc7..e8c25fd648 100644 --- a/src/nm-session-monitor.c +++ b/src/nm-session-monitor.c @@ -212,7 +212,7 @@ ck_update_cache (NMSessionMonitor *monitor) /* Check the database file */ if (stat (CKDB_PATH, &statbuf) != 0) { errsv = errno; - _LOGE ("failed to check ConsoleKit timestamp: %s", strerror (errsv)); + _LOGE ("failed to check ConsoleKit timestamp: %s", nm_strerror_native (errsv)); return FALSE; } if (statbuf.st_mtime == monitor->ck.timestamp) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 78ccac8b69..ce96c18426 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -4050,10 +4050,10 @@ sysctl_set (NMPlatform *platform, const char *pathid, int dirfd, const char *pat errsv = errno; if (errsv == ENOENT) { _LOGD ("sysctl: failed to open '%s': (%d) %s", - pathid, errsv, strerror (errsv)); + pathid, errsv, nm_strerror_native (errsv)); } else { _LOGE ("sysctl: failed to open '%s': (%d) %s", - pathid, errsv, strerror (errsv)); + pathid, errsv, nm_strerror_native (errsv)); } errno = errsv; return FALSE; @@ -4064,10 +4064,10 @@ sysctl_set (NMPlatform *platform, const char *pathid, int dirfd, const char *pat errsv = errno; if (errsv == ENOENT) { _LOGD ("sysctl: failed to openat '%s': (%d) %s", - pathid, errsv, strerror (errsv)); + pathid, errsv, nm_strerror_native (errsv)); } else { _LOGE ("sysctl: failed to openat '%s': (%d) %s", - pathid, errsv, strerror (errsv)); + pathid, errsv, nm_strerror_native (errsv)); } errno = errsv; return FALSE; @@ -4117,7 +4117,7 @@ sysctl_set (NMPlatform *platform, const char *pathid, int dirfd, const char *pat } _NMLOG (level, "sysctl: failed to set '%s' to '%s': (%d) %s", - path, value, errsv, strerror (errsv)); + path, value, errsv, nm_strerror_native (errsv)); } else if (nwrote < len - 1) { _LOGE ("sysctl: failed to set '%s' to '%s' after three attempts", path, value); @@ -6144,7 +6144,7 @@ link_set_sriov_params (NMPlatform *platform, "device/sriov_numvfs"), "0")) { errsv = errno; - _LOGW ("link: couldn't reset SR-IOV num_vfs: %s", strerror (errsv)); + _LOGW ("link: couldn't reset SR-IOV num_vfs: %s", nm_strerror_native (errsv)); return FALSE; } } @@ -6160,7 +6160,7 @@ link_set_sriov_params (NMPlatform *platform, "device/sriov_drivers_autoprobe"), nm_sprintf_buf (buf, "%d", (int) autoprobe))) { errsv = errno; - _LOGW ("link: couldn't set SR-IOV drivers-autoprobe to %d: %s", (int) autoprobe, strerror (errsv)); + _LOGW ("link: couldn't set SR-IOV drivers-autoprobe to %d: %s", (int) autoprobe, nm_strerror_native (errsv)); return FALSE; } @@ -6170,7 +6170,7 @@ link_set_sriov_params (NMPlatform *platform, "device/sriov_numvfs"), nm_sprintf_buf (buf, "%u", num_vfs))) { errsv = errno; - _LOGW ("link: couldn't set SR-IOV num_vfs to %d: %s", num_vfs, strerror (errsv)); + _LOGW ("link: couldn't set SR-IOV num_vfs to %d: %s", num_vfs, nm_strerror_native (errsv)); return FALSE; } @@ -7845,7 +7845,7 @@ continue_reading: /* Error message reported back from kernel. */ _LOGD ("netlink: recvmsg: error message from kernel: %s (%d)%s%s%s for request %d", - strerror (errsv), + nm_strerror_native (errsv), errsv, NM_PRINT_FMT_QUOTED (extack_msg, " \"", extack_msg, "\"", ""), nlmsg_hdr (msg)->nlmsg_seq); @@ -8008,7 +8008,7 @@ after_read: int errsv = errno; if (errsv != EINTR) { - _LOGE ("netlink: read: poll failed with %s", strerror (errsv)); + _LOGE ("netlink: read: poll failed with %s", nm_strerror_native (errsv)); delayed_action_wait_for_nl_response_complete_all (platform, WAIT_FOR_NL_RESPONSE_RESULT_FAILED_POLL); return any; } diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c index 0116e887bd..93cd0b3c8b 100644 --- a/src/platform/nm-platform-utils.c +++ b/src/platform/nm-platform-utils.c @@ -157,7 +157,7 @@ ethtool_call_handle (SocketHandle *shandle, gpointer edata) shandle->ifindex, _ethtool_data_to_string (edata, sbuf, sizeof (sbuf)), shandle->ifname, - strerror (errsv)); + nm_strerror_native (errsv)); return -NM_ERRNO_NATIVE (errsv); } @@ -1059,7 +1059,7 @@ nmp_utils_mii_supports_carrier_detect (int ifindex) if (ioctl (shandle.fd, SIOCGMIIPHY, &ifr) < 0) { errsv = errno; - nm_log_trace (LOGD_PLATFORM, "mii[%d,%s]: carrier-detect no: SIOCGMIIPHY failed: %s", ifindex, shandle.ifname, strerror (errsv)); + nm_log_trace (LOGD_PLATFORM, "mii[%d,%s]: carrier-detect no: SIOCGMIIPHY failed: %s", ifindex, shandle.ifname, nm_strerror_native (errsv)); return FALSE; } @@ -1069,7 +1069,7 @@ nmp_utils_mii_supports_carrier_detect (int ifindex) if (ioctl (shandle.fd, SIOCGMIIREG, &ifr) != 0) { errsv = errno; - nm_log_trace (LOGD_PLATFORM, "mii[%d,%s]: carrier-detect no: SIOCGMIIREG failed: %s", ifindex, shandle.ifname, strerror (errsv)); + nm_log_trace (LOGD_PLATFORM, "mii[%d,%s]: carrier-detect no: SIOCGMIIREG failed: %s", ifindex, shandle.ifname, nm_strerror_native (errsv)); return FALSE; } diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c index 8e29b5ce8d..c510710b17 100644 --- a/src/platform/tests/test-common.c +++ b/src/platform/tests/test-common.c @@ -1840,7 +1840,7 @@ nmtstp_namespace_create (int unshare_flags, GError **error) if (e != 0) { errsv = errno; g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, - "pipe() failed with %d (%s)", errsv, strerror (errsv)); + "pipe() failed with %d (%s)", errsv, nm_strerror_native (errsv)); return FALSE; } @@ -1848,7 +1848,7 @@ nmtstp_namespace_create (int unshare_flags, GError **error) if (e != 0) { errsv = errno; g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, - "pipe() failed with %d (%s)", errsv, strerror (errsv)); + "pipe() failed with %d (%s)", errsv, nm_strerror_native (errsv)); nm_close (pipefd_c2p[0]); nm_close (pipefd_c2p[1]); return FALSE; @@ -1858,7 +1858,7 @@ nmtstp_namespace_create (int unshare_flags, GError **error) if (pid < 0) { errsv = errno; g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, - "fork() failed with %d (%s)", errsv, strerror (errsv)); + "fork() failed with %d (%s)", errsv, nm_strerror_native (errsv)); nm_close (pipefd_c2p[0]); nm_close (pipefd_c2p[1]); nm_close (pipefd_p2c[0]); @@ -1919,7 +1919,7 @@ nmtstp_namespace_create (int unshare_flags, GError **error) "child process failed for unknown reason"); } else { g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, - "child process signaled failure %d (%s)", errsv, strerror (errsv)); + "child process signaled failure %d (%s)", errsv, nm_strerror_native (errsv)); } nm_close (pipefd_p2c[1]); kill (pid, SIGKILL); @@ -2074,14 +2074,14 @@ main (int argc, char **argv) if (unshare (CLONE_NEWNET | CLONE_NEWNS) != 0) { errsv = errno; - g_error ("unshare(CLONE_NEWNET|CLONE_NEWNS) failed with %s (%d)", strerror (errsv), errsv); + g_error ("unshare(CLONE_NEWNET|CLONE_NEWNS) failed with %s (%d)", nm_strerror_native (errsv), errsv); } /* We need a read-only /sys so that the platform knows there's no udev. */ mount (NULL, "/sys", "sysfs", MS_SLAVE, NULL); if (mount ("sys", "/sys", "sysfs", MS_RDONLY, NULL) != 0) { errsv = errno; - g_error ("mount(\"/sys\") failed with %s (%d)", strerror (errsv), errsv); + g_error ("mount(\"/sys\") failed with %s (%d)", nm_strerror_native (errsv), errsv); } } diff --git a/src/platform/wifi/nm-wifi-utils-wext.c b/src/platform/wifi/nm-wifi-utils-wext.c index 888575778b..3aa1720ae6 100644 --- a/src/platform/wifi/nm-wifi-utils-wext.c +++ b/src/platform/wifi/nm-wifi-utils-wext.c @@ -253,7 +253,7 @@ wifi_wext_get_freq (NMWifiUtils *data) if (ioctl (wext->fd, SIOCGIWFREQ, &wrq) < 0) { _LOGW (LOGD_PLATFORM | LOGD_WIFI, "(%s): error getting frequency: %s", - ifname, strerror (errno)); + ifname, nm_strerror_native (errno)); return 0; } @@ -291,7 +291,7 @@ wifi_wext_get_bssid (NMWifiUtils *data, guint8 *out_bssid) if (ioctl (wext->fd, SIOCGIWAP, &wrq) < 0) { _LOGW (LOGD_PLATFORM | LOGD_WIFI, "(%s): error getting associated BSSID: %s", - ifname, strerror (errno)); + ifname, nm_strerror_native (errno)); return FALSE; } memcpy (out_bssid, &(wrq.u.ap_addr.sa_data), ETH_ALEN); @@ -429,7 +429,7 @@ wifi_wext_get_qual (NMWifiUtils *data) if (ioctl (wext->fd, SIOCGIWSTATS, &wrq) < 0) { _LOGW (LOGD_PLATFORM | LOGD_WIFI, "(%s): error getting signal strength: %s", - ifname, strerror (errno)); + ifname, nm_strerror_native (errno)); return -1; } @@ -476,7 +476,7 @@ wifi_wext_set_mesh_channel (NMWifiUtils *data, guint32 channel) if (ioctl (wext->fd, SIOCSIWFREQ, &wrq) < 0) { _LOGE (LOGD_PLATFORM | LOGD_WIFI | LOGD_OLPC, "(%s): error setting channel to %d: %s", - ifname, channel, strerror (errno)); + ifname, channel, nm_strerror_native (errno)); return FALSE; } @@ -514,7 +514,7 @@ wifi_wext_set_mesh_ssid (NMWifiUtils *data, const guint8 *ssid, gsize len) "(%s): error setting SSID to %s: %s", ifname, (ssid_str = _nm_utils_ssid_to_string_arr (ssid, len)), - strerror (errsv)); + nm_strerror_native (errsv)); } return FALSE; diff --git a/src/ppp/nm-ppp-manager.c b/src/ppp/nm-ppp-manager.c index 86551fc035..04c14dfbd5 100644 --- a/src/ppp/nm-ppp-manager.c +++ b/src/ppp/nm-ppp-manager.c @@ -194,7 +194,7 @@ monitor_cb (gpointer user_data) if (ioctl (priv->monitor_fd, SIOCGPPPSTATS, &req) < 0) { errsv = errno; if (errsv != ENODEV) - _LOGW ("could not read ppp stats: %s", strerror (errsv)); + _LOGW ("could not read ppp stats: %s", nm_strerror_native (errsv)); } else { g_signal_emit (self, signals[STATS], 0, (guint) stats.p.ppp_ibytes, @@ -218,7 +218,7 @@ monitor_stats (NMPPPManager *self) priv->monitor_fd = socket (AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (priv->monitor_fd < 0) { errsv = errno; - _LOGW ("could not monitor PPP stats: %s", strerror (errsv)); + _LOGW ("could not monitor PPP stats: %s", nm_strerror_native (errsv)); return; } diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index da910368cb..86401ce1bf 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -636,7 +636,7 @@ add_plugin_load_file (NMSettings *self, const char *pname, GError **error) if (stat (path, &st) != 0) { errsv = errno; - _LOGW ("could not load plugin '%s' from file '%s': %s", pname, path, strerror (errsv)); + _LOGW ("could not load plugin '%s' from file '%s': %s", pname, path, nm_strerror_native (errsv)); return TRUE; } if (!S_ISREG (st.st_mode)) { diff --git a/src/settings/plugins/ifcfg-rh/nm-inotify-helper.c b/src/settings/plugins/ifcfg-rh/nm-inotify-helper.c index 5a16c01d51..04cbb5bc8c 100644 --- a/src/settings/plugins/ifcfg-rh/nm-inotify-helper.c +++ b/src/settings/plugins/ifcfg-rh/nm-inotify-helper.c @@ -146,7 +146,7 @@ init_inotify (NMInotifyHelper *self) priv->ifd = inotify_init1 (IN_CLOEXEC); if (priv->ifd == -1) { errsv = errno; - nm_log_warn (LOGD_SETTINGS, "couldn't initialize inotify: %s (%d)", strerror (errsv), errsv); + nm_log_warn (LOGD_SETTINGS, "couldn't initialize inotify: %s (%d)", nm_strerror_native (errsv), errsv); return FALSE; } diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 6df75acc66..f3d58e26c7 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -813,7 +813,7 @@ svOpenFileInternal (const char *name, gboolean create, GError **error) g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errsv), "Could not read file '%s': %s", - name, strerror (errsv)); + name, nm_strerror_native (errsv)); return NULL; } @@ -1324,14 +1324,14 @@ svWriteFile (shvarFile *s, int mode, GError **error) errsv = errno; g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errsv), "Could not open file '%s' for writing: %s", - s->fileName, strerror (errsv)); + s->fileName, nm_strerror_native (errsv)); return FALSE; } if (ftruncate (s->fd, 0) < 0) { errsv = errno; g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errsv), "Could not overwrite file '%s': %s", - s->fileName, strerror (errsv)); + s->fileName, nm_strerror_native (errsv)); return FALSE; } @@ -1340,7 +1340,7 @@ svWriteFile (shvarFile *s, int mode, GError **error) errsv = errno; g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errsv), "Internal error writing file '%s': %s", - s->fileName, strerror (errsv)); + s->fileName, nm_strerror_native (errsv)); return FALSE; } f = fdopen (tmpfd, "w"); From 2b630bc22e6bff22a19d99152e36eeb0f678026b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 31 Jan 2019 12:56:07 +0100 Subject: [PATCH 12/13] systemd: define strerror() in sd-adapt header to nm_strerror_native() Systemd uses strerror() extensively. Patch the function to use the thread-safe nm_strerror_native(). --- shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h | 5 +++++ src/tests/test-systemd.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h b/shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h index a4f9ecd2e6..06008ce860 100644 --- a/shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h +++ b/shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h @@ -27,6 +27,11 @@ /*****************************************************************************/ +/* strerror() is not thread-safe. Patch systemd-sources via a define. */ +#define strerror(errsv) nm_strerror_native (errsv) + +/*****************************************************************************/ + static inline NMLogLevel _slog_level_to_nm (int slevel) { diff --git a/src/tests/test-systemd.c b/src/tests/test-systemd.c index 0c2425255b..91edcab24a 100644 --- a/src/tests/test-systemd.c +++ b/src/tests/test-systemd.c @@ -80,6 +80,12 @@ nm_logging_setup (const char *level, return TRUE; } +const char * +nm_strerror_native (int errsv) +{ + return g_strerror (errsv); +} + /*****************************************************************************/ static void From d83d5f1da213b6f51b114e2081c48f6d4a9fc241 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 1 Feb 2019 08:35:14 +0100 Subject: [PATCH 13/13] shared: use nm_strerror_native_r() in lower layers Subsequent calls to nm_strerror_native() overwrite the previous buffer. That is potentially dangerious. At least functions in shared/nm-utils (which are lower-layer utilities) should not do that and instead use a stack-local buffer. That is because these functions should not make assumptions about the way they are called. On the other end, nmcli passing the return-value of nm_strerror_native() to g_print() is clearly OK because the higher layers are in control of when the call nm_strerror_native() -- by relying that lower layers don't interfere. --- shared/nm-utils/nm-io-utils.c | 21 +++++++++++-------- shared/nm-utils/nm-shared-utils.h | 34 ++++++++++++++++++------------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/shared/nm-utils/nm-io-utils.c b/shared/nm-utils/nm-io-utils.c index 7a9b8b7752..ce1fee6862 100644 --- a/shared/nm-utils/nm-io-utils.c +++ b/shared/nm-utils/nm-io-utils.c @@ -40,8 +40,9 @@ _get_contents_error (GError **error, int errsv, const char *format, ...) nm_assert (NM_ERRNO_NATIVE (errsv)); if (error) { - char *msg; + gs_free char *msg = NULL; va_list args; + char bstrerr[NM_STRERROR_BUFSIZE]; va_start (args, format); msg = g_strdup_vprintf (format, args); @@ -50,8 +51,8 @@ _get_contents_error (GError **error, int errsv, const char *format, ...) G_FILE_ERROR, g_file_error_from_errno (errsv), "%s: %s", - msg, nm_strerror_native (errsv)); - g_free (msg); + msg, + nm_strerror_native_r (errsv, bstrerr, sizeof (bstrerr))); } return -errsv; } @@ -289,6 +290,7 @@ nm_utils_file_get_contents (int dirfd, { int fd; int errsv; + char bstrerr[NM_STRERROR_BUFSIZE]; g_return_val_if_fail (filename && filename[0], -EINVAL); @@ -302,7 +304,7 @@ nm_utils_file_get_contents (int dirfd, g_file_error_from_errno (errsv), "Failed to open file \"%s\" with openat: %s", filename, - nm_strerror_native (errsv)); + nm_strerror_native_r (errsv, bstrerr, sizeof (bstrerr))); return -NM_ERRNO_NATIVE (errsv); } } else { @@ -315,7 +317,7 @@ nm_utils_file_get_contents (int dirfd, g_file_error_from_errno (errsv), "Failed to open file \"%s\": %s", filename, - nm_strerror_native (errsv)); + nm_strerror_native_r (errsv, bstrerr, sizeof (bstrerr))); return -NM_ERRNO_NATIVE (errsv); } } @@ -346,6 +348,7 @@ nm_utils_file_set_contents (const char *filename, int errsv; gssize s; int fd; + char bstrerr[NM_STRERROR_BUFSIZE]; g_return_val_if_fail (filename, FALSE); g_return_val_if_fail (contents || !length, FALSE); @@ -364,7 +367,7 @@ nm_utils_file_set_contents (const char *filename, g_file_error_from_errno (errsv), "failed to create file %s: %s", tmp_name, - nm_strerror_native (errsv)); + nm_strerror_native_r (errsv, bstrerr, sizeof (bstrerr))); return FALSE; } @@ -383,7 +386,7 @@ nm_utils_file_set_contents (const char *filename, g_file_error_from_errno (errsv), "failed to write to file %s: %s", tmp_name, - nm_strerror_native (errsv)); + nm_strerror_native_r (errsv, bstrerr, sizeof (bstrerr))); return FALSE; } @@ -412,7 +415,7 @@ nm_utils_file_set_contents (const char *filename, g_file_error_from_errno (errsv), "failed to fsync %s: %s", tmp_name, - nm_strerror_native (errsv)); + nm_strerror_native_r (errsv, bstrerr, sizeof (bstrerr))); return FALSE; } } @@ -428,7 +431,7 @@ nm_utils_file_set_contents (const char *filename, "failed to rename %s to %s: %s", tmp_name, filename, - nm_strerror_native (errsv)); + nm_strerror_native_r (errsv, bstrerr, sizeof (bstrerr))); return FALSE; } diff --git a/shared/nm-utils/nm-shared-utils.h b/shared/nm-utils/nm-shared-utils.h index fd2019349a..ce308ef67c 100644 --- a/shared/nm-utils/nm-shared-utils.h +++ b/shared/nm-utils/nm-shared-utils.h @@ -700,20 +700,26 @@ nm_utils_error_set_literal (GError **error, int error_code, const char *literal) g_set_error ((error), NM_UTILS_ERROR, error_code, __VA_ARGS__) #define nm_utils_error_set_errno(error, errsv, fmt, ...) \ - g_set_error ((error), \ - NM_UTILS_ERROR, \ - NM_UTILS_ERROR_UNKNOWN, \ - fmt, \ - ##__VA_ARGS__, \ - nm_strerror_native (({ \ - const int _errsv = (errsv); \ - \ - ( _errsv >= 0 \ - ? _errsv \ - : ( G_UNLIKELY (_errsv == G_MININT) \ - ? G_MAXINT \ - : -errsv)); \ - }))) + G_STMT_START { \ + char _bstrerr[NM_STRERROR_BUFSIZE]; \ + \ + g_set_error ((error), \ + NM_UTILS_ERROR, \ + NM_UTILS_ERROR_UNKNOWN, \ + fmt, \ + ##__VA_ARGS__, \ + nm_strerror_native_r (({ \ + const int _errsv = (errsv); \ + \ + ( _errsv >= 0 \ + ? _errsv \ + : ( G_UNLIKELY (_errsv == G_MININT) \ + ? G_MAXINT \ + : -errsv)); \ + }), \ + _bstrerr, \ + sizeof (_bstrerr))); \ + } G_STMT_END /*****************************************************************************/