From: Lennart Poettering Date: Sat, 24 Oct 2015 21:42:56 +0000 (+0200) Subject: sd-*.h: clean up exported (or to-be-exported) header files X-Git-Tag: v228~153^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=04c0136989b7eb896bfb0fb176e11233d69e1453;p=thirdparty%2Fsystemd.git sd-*.h: clean up exported (or to-be-exported) header files Exported header files should not include internal headers. Fix that. Exported header files should not use the bool type. So far we opted to stick to C89 for exported headers, and hence use "int" for bools in them. Continue to do so. Exported header files should have #include lines for everything they use including inttypes.h and sys/types.h, so that they may be included in any order. Exported header files should have C++ guards, hence add them. Exported header files should not use gcc extensions like #pragma once, get rid of it. --- diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index 39afffc72c1..52f7579c5e7 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -94,7 +94,7 @@ int sd_dhcp_server_configure_pool(sd_dhcp_server *server, struct in_addr *addres return 0; } -bool sd_dhcp_server_is_running(sd_dhcp_server *server) { +int sd_dhcp_server_is_running(sd_dhcp_server *server) { assert_return(server, false); return !!server->receive_message; diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index cb8b0713f4e..d4d4b771d94 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -206,9 +206,8 @@ int sd_dhcp6_client_set_duid( return 0; } -int sd_dhcp6_client_set_information_request(sd_dhcp6_client *client, bool enabled) { +int sd_dhcp6_client_set_information_request(sd_dhcp6_client *client, int enabled) { assert_return(client, -EINVAL); - assert_return(IN_SET(client->state, DHCP6_STATE_STOPPED), -EBUSY); client->information_request = enabled; @@ -216,7 +215,7 @@ int sd_dhcp6_client_set_information_request(sd_dhcp6_client *client, bool enable return 0; } -int sd_dhcp6_client_get_information_request(sd_dhcp6_client *client, bool *enabled) { +int sd_dhcp6_client_get_information_request(sd_dhcp6_client *client, int *enabled) { assert_return(client, -EINVAL); assert_return(enabled, -EINVAL); diff --git a/src/libsystemd-network/sd-ipv4acd.c b/src/libsystemd-network/sd-ipv4acd.c index ae9805bfaa4..d2ad5f75a42 100644 --- a/src/libsystemd-network/sd-ipv4acd.c +++ b/src/libsystemd-network/sd-ipv4acd.c @@ -468,7 +468,7 @@ int sd_ipv4acd_set_address(sd_ipv4acd *ll, const struct in_addr *address){ return 0; } -bool sd_ipv4acd_is_running(sd_ipv4acd *ll) { +int sd_ipv4acd_is_running(sd_ipv4acd *ll) { assert_return(ll, false); return ll->state != IPV4ACD_STATE_INIT; diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c index 0d025768a91..68ec58da901 100644 --- a/src/libsystemd-network/sd-ipv4ll.c +++ b/src/libsystemd-network/sd-ipv4ll.c @@ -227,7 +227,7 @@ int sd_ipv4ll_set_address_seed(sd_ipv4ll *ll, unsigned seed) { return 0; } -bool sd_ipv4ll_is_running(sd_ipv4ll *ll) { +int sd_ipv4ll_is_running(sd_ipv4ll *ll) { assert_return(ll, false); return sd_ipv4acd_is_running(ll->acd); diff --git a/src/libsystemd-network/sd-pppoe.c b/src/libsystemd-network/sd-pppoe.c index 87e3ce4b1da..7456b3218a6 100644 --- a/src/libsystemd-network/sd-pppoe.c +++ b/src/libsystemd-network/sd-pppoe.c @@ -34,6 +34,7 @@ #include "event-util.h" #include "random-util.h" #include "socket-util.h" +#include "sparse-endian.h" #include "string-util.h" #include "utf8.h" #include "util.h" diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c index fdf8d2ef898..4872567894e 100644 --- a/src/libsystemd-network/test-dhcp6-client.c +++ b/src/libsystemd-network/test-dhcp6-client.c @@ -700,7 +700,7 @@ int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) { static int test_client_solicit(sd_event *e) { sd_dhcp6_client *client; usec_t time_now = now(clock_boottime_or_monotonic()); - bool val = true; + int val = true; if (verbose) printf("* %s\n", __FUNCTION__); diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c index 623359def62..c3332bb1ac4 100644 --- a/src/network/networkd-dhcp6.c +++ b/src/network/networkd-dhcp6.c @@ -166,8 +166,7 @@ static void dhcp6_handler(sd_dhcp6_client *client, int event, void *userdata) { } int dhcp6_configure(Link *link, bool inf_req) { - int r; - bool information_request; + int r, information_request; assert_return(link, -EINVAL); diff --git a/src/systemd/sd-device.h b/src/systemd/sd-device.h index 38cb2a11028..fc117258213 100644 --- a/src/systemd/sd-device.h +++ b/src/systemd/sd-device.h @@ -24,7 +24,7 @@ ***/ #include -#include +#include #include "_sd-common.h" diff --git a/src/systemd/sd-dhcp-client.h b/src/systemd/sd-dhcp-client.h index 4291fb7ebcb..c0146158f37 100644 --- a/src/systemd/sd-dhcp-client.h +++ b/src/systemd/sd-dhcp-client.h @@ -22,12 +22,18 @@ along with systemd; If not, see . ***/ -#include +#include #include +#include +#include #include "sd-event.h" #include "sd-dhcp-lease.h" +#include "_sd-common.h" + +_SD_BEGIN_DECLARATIONS; + enum { SD_DHCP_CLIENT_EVENT_STOP = 0, SD_DHCP_CLIENT_EVENT_IP_ACQUIRE = 1, @@ -72,4 +78,6 @@ int sd_dhcp_client_attach_event(sd_dhcp_client *client, sd_event *event, int pri int sd_dhcp_client_detach_event(sd_dhcp_client *client); sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client); +_SD_END_DECLARATIONS; + #endif diff --git a/src/systemd/sd-dhcp-lease.h b/src/systemd/sd-dhcp-lease.h index ed5bceecdd8..38222594e7b 100644 --- a/src/systemd/sd-dhcp-lease.h +++ b/src/systemd/sd-dhcp-lease.h @@ -23,8 +23,14 @@ along with systemd; If not, see . ***/ -#include +#include #include +#include +#include + +#include "_sd-common.h" + +_SD_BEGIN_DECLARATIONS; typedef struct sd_dhcp_lease sd_dhcp_lease; struct sd_dhcp_route; @@ -52,4 +58,6 @@ int sd_dhcp_lease_get_vendor_specific(sd_dhcp_lease *lease, const void **data, s int sd_dhcp_lease_get_client_id(sd_dhcp_lease *lease, const void **client_id, size_t *client_id_len); int sd_dhcp_lease_get_timezone(sd_dhcp_lease *lease, const char **timezone); +_SD_END_DECLARATIONS; + #endif diff --git a/src/systemd/sd-dhcp-server.h b/src/systemd/sd-dhcp-server.h index 4b0c7a18526..55bceb1ea59 100644 --- a/src/systemd/sd-dhcp-server.h +++ b/src/systemd/sd-dhcp-server.h @@ -23,10 +23,13 @@ along with systemd; If not, see . ***/ -#include +#include #include #include "sd-event.h" +#include "_sd-common.h" + +_SD_BEGIN_DECLARATIONS; typedef struct sd_dhcp_server sd_dhcp_server; @@ -39,7 +42,7 @@ int sd_dhcp_server_attach_event(sd_dhcp_server *client, sd_event *event, int pri int sd_dhcp_server_detach_event(sd_dhcp_server *client); sd_event *sd_dhcp_server_get_event(sd_dhcp_server *client); -bool sd_dhcp_server_is_running(sd_dhcp_server *server); +int sd_dhcp_server_is_running(sd_dhcp_server *server); int sd_dhcp_server_start(sd_dhcp_server *server); int sd_dhcp_server_stop(sd_dhcp_server *server); @@ -55,4 +58,6 @@ int sd_dhcp_server_set_default_lease_time(sd_dhcp_server *server, uint32_t t); int sd_dhcp_server_forcerenew(sd_dhcp_server *server); +_SD_END_DECLARATIONS; + #endif diff --git a/src/systemd/sd-dhcp6-client.h b/src/systemd/sd-dhcp6-client.h index e95d7588153..13182a481d9 100644 --- a/src/systemd/sd-dhcp6-client.h +++ b/src/systemd/sd-dhcp6-client.h @@ -22,13 +22,17 @@ along with systemd; If not, see . ***/ +#include #include -#include +#include #include "sd-event.h" - #include "sd-dhcp6-lease.h" +#include "_sd-common.h" + +_SD_BEGIN_DECLARATIONS; + enum { SD_DHCP6_CLIENT_EVENT_STOP = 0, SD_DHCP6_CLIENT_EVENT_RESEND_EXPIRE = 10, @@ -49,10 +53,8 @@ int sd_dhcp6_client_set_mac(sd_dhcp6_client *client, const uint8_t *addr, size_t addr_len, uint16_t arp_type); int sd_dhcp6_client_set_duid(sd_dhcp6_client *client, uint16_t type, uint8_t *duid, size_t duid_len); -int sd_dhcp6_client_set_information_request(sd_dhcp6_client *client, - bool enabled); -int sd_dhcp6_client_get_information_request(sd_dhcp6_client *client, - bool *enabled); +int sd_dhcp6_client_set_information_request(sd_dhcp6_client *client, int enabled); +int sd_dhcp6_client_get_information_request(sd_dhcp6_client *client, int *enabled); int sd_dhcp6_client_set_request_option(sd_dhcp6_client *client, uint16_t option); @@ -68,4 +70,6 @@ sd_dhcp6_client *sd_dhcp6_client_ref(sd_dhcp6_client *client); sd_dhcp6_client *sd_dhcp6_client_unref(sd_dhcp6_client *client); int sd_dhcp6_client_new(sd_dhcp6_client **ret); +_SD_END_DECLARATIONS; + #endif diff --git a/src/systemd/sd-dhcp6-lease.h b/src/systemd/sd-dhcp6-lease.h index dc3df3bbf7b..3fc0ee4bed3 100644 --- a/src/systemd/sd-dhcp6-lease.h +++ b/src/systemd/sd-dhcp6-lease.h @@ -23,8 +23,13 @@ along with systemd; If not, see . ***/ +#include #include +#include "_sd-common.h" + +_SD_BEGIN_DECLARATIONS; + typedef struct sd_dhcp6_lease sd_dhcp6_lease; void sd_dhcp6_lease_reset_address_iter(sd_dhcp6_lease *lease); @@ -42,4 +47,6 @@ int sd_dhcp6_lease_get_ntp_fqdn(sd_dhcp6_lease *lease, char ***ntp_fqdn); sd_dhcp6_lease *sd_dhcp6_lease_ref(sd_dhcp6_lease *lease); sd_dhcp6_lease *sd_dhcp6_lease_unref(sd_dhcp6_lease *lease); +_SD_END_DECLARATIONS; + #endif diff --git a/src/systemd/sd-hwdb.h b/src/systemd/sd-hwdb.h index 3c44b981d68..49269a073ae 100644 --- a/src/systemd/sd-hwdb.h +++ b/src/systemd/sd-hwdb.h @@ -39,9 +39,11 @@ int sd_hwdb_get(sd_hwdb *hwdb, const char *modalias, const char *key, const char int sd_hwdb_seek(sd_hwdb *hwdb, const char *modalias); int sd_hwdb_enumerate(sd_hwdb *hwdb, const char **key, const char **value); -/* the inverse condition avoids ambiguity of danling 'else' after the macro */ +/* the inverse condition avoids ambiguity of dangling 'else' after the macro */ #define SD_HWDB_FOREACH_PROPERTY(hwdb, modalias, key, value) \ if (sd_hwdb_seek(hwdb, modalias) < 0) { } \ else while (sd_hwdb_enumerate(hwdb, &(key), &(value)) > 0) +_SD_END_DECLARATIONS; + #endif diff --git a/src/systemd/sd-ipv4acd.h b/src/systemd/sd-ipv4acd.h index adcb2c7b920..6337d614525 100644 --- a/src/systemd/sd-ipv4acd.h +++ b/src/systemd/sd-ipv4acd.h @@ -23,11 +23,13 @@ along with systemd; If not, see . ***/ -#include #include #include #include "sd-event.h" +#include "_sd-common.h" + +_SD_BEGIN_DECLARATIONS; enum { SD_IPV4ACD_EVENT_STOP = 0, @@ -45,11 +47,13 @@ int sd_ipv4acd_set_callback(sd_ipv4acd *ll, sd_ipv4acd_cb_t cb, void *userdata); int sd_ipv4acd_set_mac(sd_ipv4acd *ll, const struct ether_addr *addr); int sd_ipv4acd_set_index(sd_ipv4acd *ll, int interface_index); int sd_ipv4acd_set_address(sd_ipv4acd *ll, const struct in_addr *address); -bool sd_ipv4acd_is_running(sd_ipv4acd *ll); +int sd_ipv4acd_is_running(sd_ipv4acd *ll); int sd_ipv4acd_start(sd_ipv4acd *ll); int sd_ipv4acd_stop(sd_ipv4acd *ll); sd_ipv4acd *sd_ipv4acd_ref(sd_ipv4acd *ll); sd_ipv4acd *sd_ipv4acd_unref(sd_ipv4acd *ll); int sd_ipv4acd_new (sd_ipv4acd **ret); +_SD_END_DECLARATIONS; + #endif diff --git a/src/systemd/sd-ipv4ll.h b/src/systemd/sd-ipv4ll.h index cc85140acdd..2949f1dfb28 100644 --- a/src/systemd/sd-ipv4ll.h +++ b/src/systemd/sd-ipv4ll.h @@ -22,11 +22,13 @@ along with systemd; If not, see . ***/ -#include #include #include #include "sd-event.h" +#include "_sd-common.h" + +_SD_BEGIN_DECLARATIONS; enum { SD_IPV4LL_EVENT_STOP = 0, @@ -45,11 +47,13 @@ int sd_ipv4ll_set_mac(sd_ipv4ll *ll, const struct ether_addr *addr); int sd_ipv4ll_set_index(sd_ipv4ll *ll, int interface_index); int sd_ipv4ll_set_address(sd_ipv4ll *ll, const struct in_addr *address); int sd_ipv4ll_set_address_seed(sd_ipv4ll *ll, unsigned seed); -bool sd_ipv4ll_is_running(sd_ipv4ll *ll); +int sd_ipv4ll_is_running(sd_ipv4ll *ll); int sd_ipv4ll_start(sd_ipv4ll *ll); int sd_ipv4ll_stop(sd_ipv4ll *ll); sd_ipv4ll *sd_ipv4ll_ref(sd_ipv4ll *ll); sd_ipv4ll *sd_ipv4ll_unref(sd_ipv4ll *ll); int sd_ipv4ll_new (sd_ipv4ll **ret); +_SD_END_DECLARATIONS; + #endif diff --git a/src/systemd/sd-lldp.h b/src/systemd/sd-lldp.h index e9abdf349f0..31651ce132f 100644 --- a/src/systemd/sd-lldp.h +++ b/src/systemd/sd-lldp.h @@ -1,5 +1,8 @@ /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ +#ifndef foosdlldphfoo +#define foosdlldphfoo + /*** This file is part of systemd. @@ -20,11 +23,13 @@ along with systemd; If not, see . ***/ -#pragma once - #include +#include #include "sd-event.h" +#include "_sd-common.h" + +_SD_BEGIN_DECLARATIONS; enum { SD_LLDP_EVENT_UPDATE_INFO = 0, @@ -74,3 +79,7 @@ sd_lldp_packet *sd_lldp_packet_unref(sd_lldp_packet *tlv); int sd_lldp_packet_get_destination_type(sd_lldp_packet *tlv, int *dest); int sd_lldp_get_packets(sd_lldp *lldp, sd_lldp_packet ***tlvs); + +_SD_END_DECLARATIONS; + +#endif diff --git a/src/systemd/sd-ndisc.h b/src/systemd/sd-ndisc.h index 83575c69084..570e1741d68 100644 --- a/src/systemd/sd-ndisc.h +++ b/src/systemd/sd-ndisc.h @@ -22,9 +22,13 @@ along with systemd; If not, see . ***/ +#include #include #include "sd-event.h" +#include "_sd-common.h" + +_SD_BEGIN_DECLARATIONS; enum { SD_NDISC_EVENT_ROUTER_ADVERTISMENT_NONE = 0, @@ -68,4 +72,6 @@ int sd_ndisc_router_discovery_start(sd_ndisc *nd); be16toh((address).s6_addr16[6]), \ be16toh((address).s6_addr16[7]) +_SD_END_DECLARATIONS; + #endif diff --git a/src/systemd/sd-path.h b/src/systemd/sd-path.h index e238c0ce203..32803036332 100644 --- a/src/systemd/sd-path.h +++ b/src/systemd/sd-path.h @@ -24,6 +24,10 @@ #include +#include "_sd-common.h" + +_SD_BEGIN_DECLARATIONS; + enum { /* Temporary files */ SD_PATH_TEMPORARY = 0x0ULL, @@ -84,4 +88,6 @@ enum { int sd_path_home(uint64_t type, const char *suffix, char **path); int sd_path_search(uint64_t type, const char *suffix, char ***paths); +_SD_END_DECLARATIONS; + #endif diff --git a/src/systemd/sd-pppoe.h b/src/systemd/sd-pppoe.h index 90878ffa27b..80d9fc2862c 100644 --- a/src/systemd/sd-pppoe.h +++ b/src/systemd/sd-pppoe.h @@ -22,12 +22,12 @@ along with systemd; If not, see . ***/ -#include #include #include "sd-event.h" +#include "_sd-common.h" -#include "sparse-endian.h" +_SD_BEGIN_DECLARATIONS; enum { SD_PPPOE_EVENT_RUNNING = 0, @@ -50,4 +50,6 @@ sd_pppoe *sd_pppoe_ref(sd_pppoe *ppp); sd_pppoe *sd_pppoe_unref(sd_pppoe *ppp); int sd_pppoe_new (sd_pppoe **ret); +_SD_END_DECLARATIONS; + #endif diff --git a/src/systemd/sd-resolve.h b/src/systemd/sd-resolve.h index 80c5852e455..82c4b39efe1 100644 --- a/src/systemd/sd-resolve.h +++ b/src/systemd/sd-resolve.h @@ -22,12 +22,13 @@ along with systemd; If not, see . ***/ -#include -#include +#include #include +#include +#include -#include "_sd-common.h" #include "sd-event.h" +#include "_sd-common.h" _SD_BEGIN_DECLARATIONS;