Various changes to prepare for running IWYU on the repository (#37319)
These are various commits that were required to get things compiling after running IWYU. I think all of them make sense on their own, hence this split PR to merge them ahead of time.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <linux/if_arp.h>
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_arp.h>
|
||||
#include <net/if.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/ip.h>
|
||||
@@ -1350,6 +1351,53 @@ void* cmsg_find_and_copy_data(struct msghdr *mh, int level, int type, void *buf,
|
||||
return memcpy_safe(buf, CMSG_DATA(cmsg), buf_len);
|
||||
}
|
||||
|
||||
size_t sockaddr_ll_len(const struct sockaddr_ll *sa) {
|
||||
/* Certain hardware address types (e.g Infiniband) do not fit into sll_addr
|
||||
* (8 bytes) and run over the structure. This function returns the correct size that
|
||||
* must be passed to kernel. */
|
||||
|
||||
assert(sa->sll_family == AF_PACKET);
|
||||
|
||||
size_t mac_len = sizeof(sa->sll_addr);
|
||||
|
||||
if (be16toh(sa->sll_hatype) == ARPHRD_ETHER)
|
||||
mac_len = MAX(mac_len, (size_t) ETH_ALEN);
|
||||
if (be16toh(sa->sll_hatype) == ARPHRD_INFINIBAND)
|
||||
mac_len = MAX(mac_len, (size_t) INFINIBAND_ALEN);
|
||||
|
||||
return offsetof(struct sockaddr_ll, sll_addr) + mac_len;
|
||||
}
|
||||
|
||||
size_t sockaddr_un_len(const struct sockaddr_un *sa) {
|
||||
/* Covers only file system and abstract AF_UNIX socket addresses, but not unnamed socket addresses. */
|
||||
|
||||
assert(sa->sun_family == AF_UNIX);
|
||||
|
||||
return offsetof(struct sockaddr_un, sun_path) +
|
||||
(sa->sun_path[0] == 0 ?
|
||||
1 + strnlen(sa->sun_path+1, sizeof(sa->sun_path)-1) :
|
||||
strnlen(sa->sun_path, sizeof(sa->sun_path))+1);
|
||||
}
|
||||
|
||||
size_t sockaddr_len(const union sockaddr_union *sa) {
|
||||
switch (sa->sa.sa_family) {
|
||||
case AF_INET:
|
||||
return sizeof(struct sockaddr_in);
|
||||
case AF_INET6:
|
||||
return sizeof(struct sockaddr_in6);
|
||||
case AF_UNIX:
|
||||
return sockaddr_un_len(&sa->un);
|
||||
case AF_PACKET:
|
||||
return sockaddr_ll_len(&sa->ll);
|
||||
case AF_NETLINK:
|
||||
return sizeof(struct sockaddr_nl);
|
||||
case AF_VSOCK:
|
||||
return sizeof(struct sockaddr_vm);
|
||||
default:
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
int socket_ioctl_fd(void) {
|
||||
int fd;
|
||||
|
||||
|
||||
+3
-54
@@ -238,62 +238,11 @@ void* cmsg_find_and_copy_data(struct msghdr *mh, int level, int type, void *buf,
|
||||
(size) == CMSG_ALIGN(size) ? 1 : -1]; \
|
||||
}
|
||||
|
||||
/*
|
||||
* Certain hardware address types (e.g Infiniband) do not fit into sll_addr
|
||||
* (8 bytes) and run over the structure. This macro returns the correct size that
|
||||
* must be passed to kernel.
|
||||
*/
|
||||
#define SOCKADDR_LL_LEN(sa) \
|
||||
({ \
|
||||
const struct sockaddr_ll *_sa = &(sa); \
|
||||
size_t _mac_len = sizeof(_sa->sll_addr); \
|
||||
assert(_sa->sll_family == AF_PACKET); \
|
||||
if (be16toh(_sa->sll_hatype) == ARPHRD_ETHER) \
|
||||
_mac_len = MAX(_mac_len, (size_t) ETH_ALEN); \
|
||||
if (be16toh(_sa->sll_hatype) == ARPHRD_INFINIBAND) \
|
||||
_mac_len = MAX(_mac_len, (size_t) INFINIBAND_ALEN); \
|
||||
offsetof(struct sockaddr_ll, sll_addr) + _mac_len; \
|
||||
})
|
||||
size_t sockaddr_ll_len(const struct sockaddr_ll *sa);
|
||||
|
||||
/* Covers only file system and abstract AF_UNIX socket addresses, but not unnamed socket addresses. */
|
||||
#define SOCKADDR_UN_LEN(sa) \
|
||||
({ \
|
||||
const struct sockaddr_un *_sa = &(sa); \
|
||||
assert(_sa->sun_family == AF_UNIX); \
|
||||
offsetof(struct sockaddr_un, sun_path) + \
|
||||
(_sa->sun_path[0] == 0 ? \
|
||||
1 + strnlen(_sa->sun_path+1, sizeof(_sa->sun_path)-1) : \
|
||||
strnlen(_sa->sun_path, sizeof(_sa->sun_path))+1); \
|
||||
})
|
||||
size_t sockaddr_un_len(const struct sockaddr_un *sa);
|
||||
|
||||
#define SOCKADDR_LEN(saddr) \
|
||||
({ \
|
||||
const union sockaddr_union *__sa = &(saddr); \
|
||||
size_t _len; \
|
||||
switch (__sa->sa.sa_family) { \
|
||||
case AF_INET: \
|
||||
_len = sizeof(struct sockaddr_in); \
|
||||
break; \
|
||||
case AF_INET6: \
|
||||
_len = sizeof(struct sockaddr_in6); \
|
||||
break; \
|
||||
case AF_UNIX: \
|
||||
_len = SOCKADDR_UN_LEN(__sa->un); \
|
||||
break; \
|
||||
case AF_PACKET: \
|
||||
_len = SOCKADDR_LL_LEN(__sa->ll); \
|
||||
break; \
|
||||
case AF_NETLINK: \
|
||||
_len = sizeof(struct sockaddr_nl); \
|
||||
break; \
|
||||
case AF_VSOCK: \
|
||||
_len = sizeof(struct sockaddr_vm); \
|
||||
break; \
|
||||
default: \
|
||||
assert_not_reached(); \
|
||||
} \
|
||||
_len; \
|
||||
})
|
||||
size_t sockaddr_len(const union sockaddr_union *sa);
|
||||
|
||||
int socket_ioctl_fd(void);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#if SD_BOOT
|
||||
# include "efi-string.h"
|
||||
# include "util.h"
|
||||
#else
|
||||
# include <byteswap.h>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#if SD_BOOT
|
||||
# include "efi-string.h"
|
||||
# include "efi.h"
|
||||
#else
|
||||
# include <uchar.h>
|
||||
#endif
|
||||
|
||||
@@ -76,6 +76,12 @@ Still 100% public domain
|
||||
modified for use with systemd
|
||||
*/
|
||||
|
||||
#if SD_BOOT
|
||||
# include "efi-string.h"
|
||||
#else
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#include "memory-util-fundamental.h"
|
||||
#include "sha1-fundamental.h"
|
||||
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
License along with the GNU C Library; if not, see
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#if SD_BOOT
|
||||
# include "efi-string.h"
|
||||
#else
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#include "assert-fundamental.h"
|
||||
#include "macro-fundamental.h"
|
||||
#include "memory-util-fundamental.h"
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to start up daemon: %m");
|
||||
|
||||
notify_stop = notify_start(NOTIFY_READY, NOTIFY_STOPPING);
|
||||
notify_stop = notify_start(NOTIFY_READY_MESSAGE, NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
r = sd_event_loop(m->event);
|
||||
if (r < 0)
|
||||
|
||||
@@ -1939,7 +1939,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_notify(false, NOTIFY_READY);
|
||||
r = sd_notify(false, NOTIFY_READY_MESSAGE);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
|
||||
|
||||
@@ -2044,7 +2044,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_notify(false, NOTIFY_READY);
|
||||
r = sd_notify(false, NOTIFY_READY_MESSAGE);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
notify_stop = notify_start(NOTIFY_READY, NOTIFY_STOPPING);
|
||||
notify_stop = notify_start(NOTIFY_READY_MESSAGE, NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
while (!server.quit) {
|
||||
struct epoll_event event;
|
||||
|
||||
@@ -1180,7 +1180,7 @@ static int run(int argc, char **argv) {
|
||||
log_debug("%s running as pid "PID_FMT,
|
||||
program_invocation_short_name, getpid_cached());
|
||||
|
||||
notify_message = notify_start(NOTIFY_READY, NOTIFY_STOPPING);
|
||||
notify_message = notify_start(NOTIFY_READY_MESSAGE, NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
while (s.active) {
|
||||
r = sd_event_get_state(s.event);
|
||||
|
||||
@@ -982,7 +982,7 @@ static int run(int argc, char **argv) {
|
||||
|
||||
notify_message = notify_start("READY=1\n"
|
||||
"STATUS=Processing input...",
|
||||
NOTIFY_STOPPING);
|
||||
NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
for (;;) {
|
||||
r = sd_event_get_state(u.event);
|
||||
|
||||
@@ -2057,7 +2057,7 @@ static int dispatch_notify_event(sd_event_source *es, int fd, uint32_t revents,
|
||||
* there's something to send it will be turned on again. */
|
||||
|
||||
if (!s->sent_notify_ready) {
|
||||
if (send(s->notify_fd, NOTIFY_READY, strlen(NOTIFY_READY), MSG_DONTWAIT) < 0) {
|
||||
if (send(s->notify_fd, NOTIFY_READY_MESSAGE, strlen(NOTIFY_READY_MESSAGE), MSG_DONTWAIT) < 0) {
|
||||
if (errno == EAGAIN)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ static int _bind_raw_socket(
|
||||
/* We may overflow link->ll. link->ll_buffer ensures we have enough space. */
|
||||
memcpy(link->ll.sll_addr, bcast_addr->bytes, bcast_addr->length);
|
||||
|
||||
r = bind(s, &link->sa, SOCKADDR_LL_LEN(link->ll));
|
||||
r = bind(s, &link->sa, sockaddr_ll_len(&link->ll));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
@@ -258,7 +258,7 @@ int dhcp_network_send_raw_socket(
|
||||
assert(packet);
|
||||
assert(len > 0);
|
||||
|
||||
if (sendto(s, packet, len, 0, &link->sa, SOCKADDR_LL_LEN(link->ll)) < 0)
|
||||
if (sendto(s, packet, len, 0, &link->sa, sockaddr_ll_len(&link->ll)) < 0)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -685,7 +685,7 @@ int sd_lldp_neighbor_tlv_is_type(sd_lldp_neighbor *n, uint8_t type) {
|
||||
return type == k;
|
||||
}
|
||||
|
||||
int sd_lldp_neighbor_tlv_get_oui(sd_lldp_neighbor *n, uint8_t oui[_SD_ARRAY_STATIC 3], uint8_t *subtype) {
|
||||
int sd_lldp_neighbor_tlv_get_oui(sd_lldp_neighbor *n, uint8_t oui[static 3], uint8_t *subtype) {
|
||||
const uint8_t *d;
|
||||
size_t length;
|
||||
int r;
|
||||
@@ -714,7 +714,7 @@ int sd_lldp_neighbor_tlv_get_oui(sd_lldp_neighbor *n, uint8_t oui[_SD_ARRAY_STAT
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_lldp_neighbor_tlv_is_oui(sd_lldp_neighbor *n, const uint8_t oui[_SD_ARRAY_STATIC 3], uint8_t subtype) {
|
||||
int sd_lldp_neighbor_tlv_is_oui(sd_lldp_neighbor *n, const uint8_t oui[static 3], uint8_t subtype) {
|
||||
uint8_t k[3], st;
|
||||
int r;
|
||||
|
||||
|
||||
@@ -1030,7 +1030,7 @@ static int parse_container_unix_address(sd_bus *b, const char **p, char **guid)
|
||||
/* Note that we use the old /var/run prefix here, to increase compatibility with really old containers */
|
||||
.sun_path = "/var/run/dbus/system_bus_socket",
|
||||
};
|
||||
b->sockaddr_size = SOCKADDR_UN_LEN(b->sockaddr.un);
|
||||
b->sockaddr_size = sockaddr_un_len(&b->sockaddr.un);
|
||||
b->is_local = false;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "stat-util.h"
|
||||
#include "user-util.h"
|
||||
|
||||
_public_ char *sd_id128_to_string(sd_id128_t id, char s[_SD_ARRAY_STATIC SD_ID128_STRING_MAX]) {
|
||||
_public_ char *sd_id128_to_string(sd_id128_t id, char s[static SD_ID128_STRING_MAX]) {
|
||||
size_t k = 0;
|
||||
|
||||
assert_return(s, NULL);
|
||||
@@ -39,7 +39,7 @@ _public_ char *sd_id128_to_string(sd_id128_t id, char s[_SD_ARRAY_STATIC SD_ID12
|
||||
return s;
|
||||
}
|
||||
|
||||
_public_ char *sd_id128_to_uuid_string(sd_id128_t id, char s[_SD_ARRAY_STATIC SD_ID128_UUID_STRING_MAX]) {
|
||||
_public_ char *sd_id128_to_uuid_string(sd_id128_t id, char s[static SD_ID128_UUID_STRING_MAX]) {
|
||||
size_t k = 0;
|
||||
|
||||
assert_return(s, NULL);
|
||||
|
||||
@@ -230,7 +230,7 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) {
|
||||
};
|
||||
struct msghdr mh = {
|
||||
.msg_name = (struct sockaddr*) &sa.sa,
|
||||
.msg_namelen = SOCKADDR_UN_LEN(sa.un),
|
||||
.msg_namelen = sockaddr_un_len(&sa.un),
|
||||
};
|
||||
ssize_t k;
|
||||
bool have_syslog_identifier = false;
|
||||
|
||||
@@ -84,7 +84,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
/* Make an address -> name query */
|
||||
sa.in.sin_addr.s_addr = inet_addr(argc >= 3 ? argv[2] : "193.99.144.71");
|
||||
r = sd_resolve_getnameinfo(resolve, &q2, &sa.sa, SOCKADDR_LEN(sa), 0, SD_RESOLVE_GET_BOTH, getnameinfo_handler, NULL);
|
||||
r = sd_resolve_getnameinfo(resolve, &q2, &sa.sa, sockaddr_len(&sa), 0, SD_RESOLVE_GET_BOTH, getnameinfo_handler, NULL);
|
||||
if (r < 0)
|
||||
log_error_errno(r, "sd_resolve_getnameinfo(): %m");
|
||||
|
||||
|
||||
@@ -664,7 +664,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_notify(false, NOTIFY_READY);
|
||||
r = sd_notify(false, NOTIFY_READY_MESSAGE);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
|
||||
|
||||
+2
-2
@@ -1088,7 +1088,7 @@ static int manager_dispatch_reload_signal(sd_event_source *s, const struct signa
|
||||
else
|
||||
log_info("Config file reloaded.");
|
||||
|
||||
(void) sd_notify(/* unset= */ false, NOTIFY_READY);
|
||||
(void) sd_notify(/* unset= */ false, NOTIFY_READY_MESSAGE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1268,7 +1268,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to fully start up daemon: %m");
|
||||
|
||||
notify_message = notify_start(NOTIFY_READY, NOTIFY_STOPPING);
|
||||
notify_message = notify_start(NOTIFY_READY_MESSAGE, NOTIFY_STOPPING_MESSAGE);
|
||||
return manager_run(m);
|
||||
}
|
||||
|
||||
|
||||
@@ -345,7 +345,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to fully start up daemon: %m");
|
||||
|
||||
r = sd_notify(false, NOTIFY_READY);
|
||||
r = sd_notify(false, NOTIFY_READY_MESSAGE);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ int manager_startup(Manager *m) {
|
||||
(void) sockaddr_un_unlink(&sockaddr.un);
|
||||
|
||||
WITH_UMASK(0000)
|
||||
if (bind(m->listen_fd, &sockaddr.sa, SOCKADDR_UN_LEN(sockaddr.un)) < 0)
|
||||
if (bind(m->listen_fd, &sockaddr.sa, sockaddr_un_len(&sockaddr.un)) < 0)
|
||||
return log_error_errno(errno, "Failed to bind socket: %m");
|
||||
|
||||
if (listen(m->listen_fd, SOMAXCONN) < 0)
|
||||
|
||||
@@ -31,7 +31,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to start up daemon: %m");
|
||||
|
||||
notify_stop = notify_start(NOTIFY_READY, NOTIFY_STOPPING);
|
||||
notify_stop = notify_start(NOTIFY_READY_MESSAGE, NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
r = sd_event_loop(m->event);
|
||||
if (r < 0)
|
||||
|
||||
@@ -1229,6 +1229,6 @@ int manager_reload(Manager *m, sd_bus_message *message) {
|
||||
log_debug("Reloaded.");
|
||||
r = 0;
|
||||
finish:
|
||||
(void) sd_notify(/* unset_environment= */ false, NOTIFY_READY);
|
||||
(void) sd_notify(/* unset_environment= */ false, NOTIFY_READY_MESSAGE);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#endif
|
||||
#include <linux/can/netlink.h>
|
||||
#include <netinet/icmp6.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "conf-parser.h"
|
||||
#include "in-addr-prefix-util.h"
|
||||
#include "net-condition.h"
|
||||
#include "netif-sriov.h"
|
||||
#include "networkd-address-generation.h"
|
||||
#include "networkd-address-label.h"
|
||||
#include "networkd-address.h"
|
||||
@@ -38,6 +40,7 @@ _Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#include "networkd-routing-policy-rule.h"
|
||||
#include "networkd-sriov.h"
|
||||
#include "qdisc.h"
|
||||
#include "socket-util.h"
|
||||
#include "tclass.h"
|
||||
#include "vlan-util.h"
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not start manager: %m");
|
||||
|
||||
notify_message = notify_start(NOTIFY_READY, NOTIFY_STOPPING);
|
||||
notify_message = notify_start(NOTIFY_READY_MESSAGE, NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
r = sd_event_loop(m->event);
|
||||
if (r < 0)
|
||||
|
||||
+1
-1
@@ -3660,7 +3660,7 @@ static int setup_notify_child(const void *directory) {
|
||||
(void) sockaddr_un_unlink(&sa.un);
|
||||
|
||||
WITH_UMASK(0577) { /* only set "w" bit, which is all that's necessary for connecting from the container */
|
||||
r = bind(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un));
|
||||
r = bind(fd, &sa.sa, sockaddr_un_len(&sa.un));
|
||||
if (r < 0)
|
||||
return log_error_errno(errno, "bind(" NSPAWN_NOTIFY_SOCKET_PATH ") failed: %m");
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ static int manager_make_listen_socket(Manager *m) {
|
||||
(void) sockaddr_un_unlink(&sockaddr.un);
|
||||
|
||||
WITH_UMASK(0000)
|
||||
if (bind(m->listen_fd, &sockaddr.sa, SOCKADDR_UN_LEN(sockaddr.un)) < 0)
|
||||
if (bind(m->listen_fd, &sockaddr.sa, sockaddr_un_len(&sockaddr.un)) < 0)
|
||||
return log_error_errno(errno, "Failed to bind socket: %m");
|
||||
|
||||
r = mkdir_p("/run/systemd/userdb", 0755);
|
||||
|
||||
@@ -34,7 +34,7 @@ static int run(int argc, char *argv[]) {
|
||||
return log_error_errno(r, "Failed to start up daemon: %m");
|
||||
|
||||
_unused_ _cleanup_(notify_on_cleanup) const char *notify_stop = NULL;
|
||||
notify_stop = notify_start(NOTIFY_READY, NOTIFY_STOPPING);
|
||||
notify_stop = notify_start(NOTIFY_READY_MESSAGE, NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
r = sd_event_loop(m->event);
|
||||
if (r < 0)
|
||||
|
||||
@@ -660,7 +660,7 @@ static int manager_dispatch_reload_signal(sd_event_source *s, const struct signa
|
||||
manager_set_defaults(m);
|
||||
manager_parse_config_file(m);
|
||||
|
||||
(void) sd_notify(/* unset= */ false, NOTIFY_READY);
|
||||
(void) sd_notify(/* unset= */ false, NOTIFY_READY_MESSAGE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to start up daemon: %m");
|
||||
|
||||
notify_msg = notify_start(NOTIFY_READY, NOTIFY_STOPPING);
|
||||
notify_msg = notify_start(NOTIFY_READY_MESSAGE, NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
log_debug("systemd-oomd started%s.", arg_dry_run ? " in dry run mode" : "");
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to fully start up daemon: %m");
|
||||
|
||||
r = sd_notify(false, NOTIFY_READY);
|
||||
r = sd_notify(false, NOTIFY_READY_MESSAGE);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
|
||||
|
||||
@@ -1274,7 +1274,7 @@ int dns_server_is_accessible(DnsServer *s) {
|
||||
return r;
|
||||
}
|
||||
|
||||
r = RET_NERRNO(connect(fd, &sa.sa, SOCKADDR_LEN(sa)));
|
||||
r = RET_NERRNO(connect(fd, &sa.sa, sockaddr_len(&sa)));
|
||||
if (!IN_SET(r,
|
||||
0,
|
||||
-ENETUNREACH,
|
||||
|
||||
@@ -572,7 +572,7 @@ int dns_stream_new(
|
||||
|
||||
if (tfo_address) {
|
||||
s->tfo_address = *tfo_address;
|
||||
s->tfo_salen = SOCKADDR_LEN(*tfo_address);
|
||||
s->tfo_salen = sockaddr_len(tfo_address);
|
||||
}
|
||||
|
||||
*ret = TAKE_PTR(s);
|
||||
|
||||
@@ -1322,7 +1322,7 @@ static int manager_dns_stub_fd_extra(Manager *m, DnsStubListenerExtra *l, int ty
|
||||
log_debug_errno(r, "Failed to enable fragment size reception, ignoring: %m");
|
||||
}
|
||||
|
||||
r = RET_NERRNO(bind(fd, &sa.sa, SOCKADDR_LEN(sa)));
|
||||
r = RET_NERRNO(bind(fd, &sa.sa, sockaddr_len(&sa)));
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
|
||||
@@ -690,7 +690,7 @@ static int manager_dispatch_reload_signal(sd_event_source *s, const struct signa
|
||||
manager_flush_caches(m, LOG_INFO);
|
||||
manager_verify_all(m);
|
||||
|
||||
(void) sd_notify(/* unset= */ false, NOTIFY_READY);
|
||||
(void) sd_notify(/* unset= */ false, NOTIFY_READY_MESSAGE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to drop remaining caps: %m");
|
||||
|
||||
notify_stop = notify_start(NOTIFY_READY, NOTIFY_STOPPING);
|
||||
notify_stop = notify_start(NOTIFY_READY_MESSAGE, NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
r = sd_event_loop(m->event);
|
||||
if (r < 0)
|
||||
|
||||
@@ -111,7 +111,7 @@ static void *tcp_dns_server(void *p) {
|
||||
|
||||
assert_se((bindfd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0)) >= 0);
|
||||
assert_se(setsockopt(bindfd, SOL_SOCKET, SO_REUSEADDR, &(int){1}, sizeof(int)) >= 0);
|
||||
assert_se(bind(bindfd, &server_address.sa, SOCKADDR_LEN(server_address)) >= 0);
|
||||
assert_se(bind(bindfd, &server_address.sa, sockaddr_len(&server_address)) >= 0);
|
||||
assert_se(listen(bindfd, 1) >= 0);
|
||||
assert_se((acceptfd = accept(bindfd, NULL, NULL)) >= 0);
|
||||
server_handle(acceptfd);
|
||||
@@ -246,7 +246,7 @@ static void test_dns_stream(bool tls) {
|
||||
assert_se((clientfd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0)) >= 0);
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
r = connect(clientfd, &server_address.sa, SOCKADDR_LEN(server_address));
|
||||
r = connect(clientfd, &server_address.sa, sockaddr_len(&server_address));
|
||||
if (r >= 0)
|
||||
break;
|
||||
usleep_safe(EVENT_TIMEOUT_USEC / 100);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#if HAVE_BLKID
|
||||
|
||||
#include "blkid-util.h"
|
||||
#include "string-util.h"
|
||||
|
||||
int blkid_partition_get_uuid_id128(blkid_partition p, sd_id128_t *ret) {
|
||||
const char *s;
|
||||
|
||||
assert(p);
|
||||
|
||||
s = blkid_partition_get_uuid(p);
|
||||
if (isempty(s))
|
||||
return -ENXIO;
|
||||
|
||||
return sd_id128_from_string(s, ret);
|
||||
}
|
||||
|
||||
int blkid_partition_get_type_id128(blkid_partition p, sd_id128_t *ret) {
|
||||
const char *s;
|
||||
|
||||
assert(p);
|
||||
|
||||
s = blkid_partition_get_type_string(p);
|
||||
if (isempty(s))
|
||||
return -ENXIO;
|
||||
|
||||
return sd_id128_from_string(s, ret);
|
||||
}
|
||||
|
||||
#endif
|
||||
+6
-26
@@ -2,38 +2,18 @@
|
||||
#pragma once
|
||||
|
||||
#if HAVE_BLKID
|
||||
# include <blkid.h>
|
||||
|
||||
# include "sd-id128.h"
|
||||
#include <blkid.h>
|
||||
|
||||
# include "macro.h"
|
||||
# include "string-util.h"
|
||||
#include "sd-id128.h"
|
||||
|
||||
#include "memory-util.h"
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(blkid_probe, blkid_free_probe, NULL);
|
||||
|
||||
static inline int blkid_partition_get_uuid_id128(blkid_partition p, sd_id128_t *ret) {
|
||||
const char *s;
|
||||
int blkid_partition_get_uuid_id128(blkid_partition p, sd_id128_t *ret);
|
||||
|
||||
assert(p);
|
||||
|
||||
s = blkid_partition_get_uuid(p);
|
||||
if (isempty(s))
|
||||
return -ENXIO;
|
||||
|
||||
return sd_id128_from_string(s, ret);
|
||||
}
|
||||
|
||||
static inline int blkid_partition_get_type_id128(blkid_partition p, sd_id128_t *ret) {
|
||||
const char *s;
|
||||
|
||||
assert(p);
|
||||
|
||||
s = blkid_partition_get_type_string(p);
|
||||
if (isempty(s))
|
||||
return -ENXIO;
|
||||
|
||||
return sd_id128_from_string(s, ret);
|
||||
}
|
||||
int blkid_partition_get_type_id128(blkid_partition p, sd_id128_t *ret);
|
||||
|
||||
/* Define symbolic names for blkid_do_safeprobe() return values, since blkid only uses literal numbers. We
|
||||
* prefix these symbolic definitions with underscores, to not invade libblkid's namespace needlessly. */
|
||||
|
||||
@@ -154,7 +154,7 @@ int bus_event_loop_with_idle(
|
||||
|
||||
/* Inform the service manager that we are going down, so that it will queue all
|
||||
* further start requests, instead of assuming we are still running. */
|
||||
(void) sd_notify(false, NOTIFY_STOPPING);
|
||||
(void) sd_notify(false, NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
r = bus_async_unregister_and_exit(e, bus, name);
|
||||
if (r < 0)
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
#define NOTIFY_READY "READY=1\n" "STATUS=Processing requests..."
|
||||
#define NOTIFY_STOPPING "STOPPING=1\n" "STATUS=Shutting down..."
|
||||
#define NOTIFY_READY_MESSAGE "READY=1\n" "STATUS=Processing requests..."
|
||||
#define NOTIFY_STOPPING_MESSAGE "STOPPING=1\n" "STATUS=Shutting down..."
|
||||
|
||||
static inline const char* notify_start(const char *start, const char *stop) {
|
||||
if (start)
|
||||
|
||||
@@ -680,16 +680,16 @@ int local_outbounds(
|
||||
* make use of the binding and return it. Hence, let's not unnecessarily fail early here: we
|
||||
* can still easily detect if the auto-binding worked or not, by comparing the bound IP
|
||||
* address with zero — which we do below. */
|
||||
if (connect(fd, &sa.sa, SOCKADDR_LEN(sa)) < 0)
|
||||
if (connect(fd, &sa.sa, sockaddr_len(&sa)) < 0)
|
||||
log_debug_errno(errno, "Failed to connect SOCK_DGRAM socket to gateway, ignoring: %m");
|
||||
|
||||
/* Let's now read the socket address of the socket. A routing decision should have been
|
||||
* made. Let's verify that and use the data. */
|
||||
salen = SOCKADDR_LEN(sa);
|
||||
salen = sockaddr_len(&sa);
|
||||
if (getsockname(fd, &sa.sa, &salen) < 0)
|
||||
return -errno;
|
||||
assert(sa.sa.sa_family == i->family);
|
||||
assert(salen == SOCKADDR_LEN(sa));
|
||||
assert(salen == sockaddr_len(&sa));
|
||||
|
||||
switch (i->family) {
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ shared_sources = files(
|
||||
'battery-util.c',
|
||||
'binfmt-util.c',
|
||||
'bitmap.c',
|
||||
'blkid-util.c',
|
||||
'blockdev-list.c',
|
||||
'blockdev-util.c',
|
||||
'bond-util.c',
|
||||
@@ -278,7 +279,7 @@ gperf_file = custom_target(
|
||||
fname,
|
||||
input : ip_protocol_list_txt,
|
||||
output : fname,
|
||||
command : [generate_gperfs, 'ip_protocol', 'IPPROTO_', '@INPUT@'],
|
||||
command : [generate_gperfs, 'ip_protocol', 'IPPROTO_', '@INPUT@', '<netinet/in.h>'],
|
||||
capture : true)
|
||||
|
||||
fname = 'ip-protocol-from-name.h'
|
||||
@@ -303,9 +304,8 @@ target2 = custom_target(
|
||||
command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
|
||||
capture : true)
|
||||
|
||||
shared_generated_gperf_headers = [target1, target2]
|
||||
generated_sources += shared_generated_gperf_headers
|
||||
shared_sources += shared_generated_gperf_headers
|
||||
generated_sources += [target1, target2]
|
||||
shared_sources += [target1, target2]
|
||||
|
||||
fname = 'ethtool-link-mode.h'
|
||||
ethtool_link_mode_h = custom_target(
|
||||
|
||||
@@ -17,7 +17,7 @@ int plymouth_connect(int flags) {
|
||||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
if (connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0)
|
||||
if (connect(fd, &sa.sa, sockaddr_un_len(&sa.un)) < 0)
|
||||
return -errno;
|
||||
|
||||
return TAKE_FD(fd);
|
||||
|
||||
@@ -478,7 +478,7 @@ static int run(int argc, char **argv) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
notify = notify_start(NOTIFY_READY, NOTIFY_STOPPING);
|
||||
notify = notify_start(NOTIFY_READY_MESSAGE, NOTIFY_STOPPING_MESSAGE);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
||||
@@ -688,7 +688,7 @@ static int run(int argc, char *argv[]) {
|
||||
return r;
|
||||
}
|
||||
|
||||
notify_stop = notify_start(NOTIFY_READY, NOTIFY_STOPPING);
|
||||
notify_stop = notify_start(NOTIFY_READY_MESSAGE, NOTIFY_STOPPING_MESSAGE);
|
||||
r = sd_event_loop(context.event);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to run event loop: %m");
|
||||
|
||||
@@ -37,7 +37,7 @@ static int process_vsock_cid(unsigned cid, const char *port) {
|
||||
if (fd < 0)
|
||||
return log_error_errno(errno, "Failed to allocate AF_VSOCK socket: %m");
|
||||
|
||||
if (connect(fd, &sa.sa, SOCKADDR_LEN(sa)) < 0)
|
||||
if (connect(fd, &sa.sa, sockaddr_len(&sa)) < 0)
|
||||
return log_error_errno(errno, "Failed to connect to vsock:%u:%u: %m", sa.vm.svm_cid, sa.vm.svm_port);
|
||||
|
||||
/* OpenSSH wants us to send a single byte along with the file descriptor, hence do so */
|
||||
|
||||
@@ -1240,7 +1240,7 @@ static int run(int argc, char* argv[]) {
|
||||
_unused_ _cleanup_(notify_on_cleanup) const char *notify_message =
|
||||
notify_start("READY=1\n"
|
||||
"STATUS=Exposing disks in target mode...",
|
||||
NOTIFY_STOPPING);
|
||||
NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
r = sd_event_loop(event);
|
||||
if (r < 0)
|
||||
|
||||
@@ -225,8 +225,7 @@ executables += [
|
||||
generated_gperf_headers,
|
||||
},
|
||||
test_template + {
|
||||
'sources' : files('test-arphrd-util.c') +
|
||||
generated_gperf_headers,
|
||||
'sources' : files('test-arphrd-util.c')
|
||||
},
|
||||
test_template + {
|
||||
'sources' : files('test-ask-password-api.c'),
|
||||
@@ -249,8 +248,7 @@ executables += [
|
||||
'type' : 'manual',
|
||||
},
|
||||
test_template + {
|
||||
'sources' : files('test-cap-list.c') +
|
||||
generated_gperf_headers,
|
||||
'sources' : files('test-cap-list.c'),
|
||||
'dependencies' : libcap,
|
||||
},
|
||||
test_template + {
|
||||
@@ -313,8 +311,7 @@ executables += [
|
||||
'timeout' : 180,
|
||||
},
|
||||
test_template + {
|
||||
'sources' : files('test-ip-protocol-list.c') +
|
||||
shared_generated_gperf_headers,
|
||||
'sources' : files('test-ip-protocol-list.c'),
|
||||
},
|
||||
test_template + {
|
||||
'sources' : files('test-ipcrm.c'),
|
||||
|
||||
@@ -928,7 +928,7 @@ TEST(read_full_file_socket) {
|
||||
|
||||
assert_se(sockaddr_un_set_path(&sa.un, j) >= 0);
|
||||
|
||||
assert_se(bind(listener, &sa.sa, SOCKADDR_UN_LEN(sa.un)) >= 0);
|
||||
assert_se(bind(listener, &sa.sa, sockaddr_un_len(&sa.un)) >= 0);
|
||||
assert_se(listen(listener, 1) >= 0);
|
||||
|
||||
/* Make sure the socket doesn't fit into a struct sockaddr_un, but we can still access it */
|
||||
|
||||
@@ -86,7 +86,7 @@ TEST(fake_pressure) {
|
||||
socket_fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0);
|
||||
assert_se(socket_fd >= 0);
|
||||
assert_se(sockaddr_un_set_path(&sa.un, k) >= 0);
|
||||
assert_se(bind(socket_fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) >= 0);
|
||||
assert_se(bind(socket_fd, &sa.sa, sockaddr_un_len(&sa.un)) >= 0);
|
||||
assert_se(listen(socket_fd, 1) >= 0);
|
||||
|
||||
/* Ideally we'd just allocate this on the stack, but AddressSanitizer doesn't like it if threads
|
||||
|
||||
@@ -134,8 +134,8 @@ TEST(sockaddr_un_len) {
|
||||
.sun_path = "\0foobar",
|
||||
};
|
||||
|
||||
assert_se(SOCKADDR_UN_LEN(fs) == offsetof(struct sockaddr_un, sun_path) + strlen(fs.sun_path) + 1);
|
||||
assert_se(SOCKADDR_UN_LEN(abstract) == offsetof(struct sockaddr_un, sun_path) + 1 + strlen(abstract.sun_path + 1));
|
||||
assert_se(sockaddr_un_len(&fs) == offsetof(struct sockaddr_un, sun_path) + strlen(fs.sun_path) + 1);
|
||||
assert_se(sockaddr_un_len(&abstract) == offsetof(struct sockaddr_un, sun_path) + 1 + strlen(abstract.sun_path + 1));
|
||||
}
|
||||
|
||||
TEST(in_addr_is_multicast) {
|
||||
@@ -564,14 +564,14 @@ TEST(sockaddr_un_set_path) {
|
||||
|
||||
fd1 = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0);
|
||||
assert_se(fd1 >= 0);
|
||||
assert_se(bind(fd1, &sa.sa, SOCKADDR_LEN(sa)) >= 0);
|
||||
assert_se(bind(fd1, &sa.sa, sockaddr_len(&sa)) >= 0);
|
||||
assert_se(listen(fd1, 1) >= 0);
|
||||
|
||||
sh = unlink_and_free(sh); /* remove temporary symlink */
|
||||
|
||||
fd2 = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0);
|
||||
assert_se(fd2 >= 0);
|
||||
assert_se(connect(fd2, &sa.sa, SOCKADDR_LEN(sa)) < 0);
|
||||
assert_se(connect(fd2, &sa.sa, sockaddr_len(&sa)) < 0);
|
||||
assert_se(errno == ENOENT); /* we removed the symlink, must fail */
|
||||
|
||||
free(j);
|
||||
@@ -581,7 +581,7 @@ TEST(sockaddr_un_set_path) {
|
||||
assert_se(fd3 > 0);
|
||||
assert_se(sockaddr_un_set_path(&sa.un, FORMAT_PROC_FD_PATH(fd3)) >= 0); /* connect via O_PATH instead, circumventing 108ch limit */
|
||||
|
||||
assert_se(connect(fd2, &sa.sa, SOCKADDR_LEN(sa)) >= 0);
|
||||
assert_se(connect(fd2, &sa.sa, sockaddr_len(&sa)) >= 0);
|
||||
}
|
||||
|
||||
TEST(getpeerpidref) {
|
||||
|
||||
@@ -1182,7 +1182,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_notify(false, NOTIFY_READY);
|
||||
r = sd_notify(false, NOTIFY_READY_MESSAGE);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ static int run(int argc, char *argv[]) {
|
||||
|
||||
notify_message = notify_start("READY=1\n"
|
||||
"STATUS=Daemon is running",
|
||||
NOTIFY_STOPPING);
|
||||
NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
r = manager_setup_save_time_event(m);
|
||||
if (r < 0)
|
||||
|
||||
@@ -406,7 +406,7 @@ static int process_and_watch_password_files(bool watch) {
|
||||
}
|
||||
|
||||
_unused_ _cleanup_(notify_on_cleanup) const char *notify_stop =
|
||||
notify_start(NOTIFY_READY, NOTIFY_STOPPING);
|
||||
notify_start(NOTIFY_READY_MESSAGE, NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
for (;;) {
|
||||
usec_t timeout = USEC_INFINITY;
|
||||
|
||||
@@ -73,7 +73,7 @@ int udev_ctrl_new_from_fd(UdevCtrl **ret, int fd) {
|
||||
.sun_path = "/run/udev/control",
|
||||
};
|
||||
|
||||
uctrl->addrlen = SOCKADDR_UN_LEN(uctrl->saddr.un);
|
||||
uctrl->addrlen = sockaddr_un_len(&uctrl->saddr.un);
|
||||
|
||||
*ret = TAKE_PTR(uctrl);
|
||||
return 0;
|
||||
|
||||
@@ -234,7 +234,7 @@ void manager_exit(Manager *manager) {
|
||||
|
||||
manager->exit = true;
|
||||
|
||||
(void) sd_notify(/* unset= */ false, NOTIFY_STOPPING);
|
||||
(void) sd_notify(/* unset= */ false, NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
/* close sources of new events and discard buffered events */
|
||||
manager->ctrl = udev_ctrl_unref(manager->ctrl);
|
||||
@@ -1407,7 +1407,7 @@ int manager_main(Manager *manager) {
|
||||
log_warning_errno(r, "Failed to apply permissions on static device nodes, ignoring: %m");
|
||||
|
||||
_unused_ _cleanup_(notify_on_cleanup) const char *notify_message =
|
||||
notify_start(NOTIFY_READY, NOTIFY_STOPPING);
|
||||
notify_start(NOTIFY_READY_MESSAGE, NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
/* We will start processing events in the loop below. Before starting processing, let's remove the
|
||||
* event serialization fd from the fdstore, to avoid retrieving the serialized events again in future
|
||||
|
||||
@@ -287,7 +287,7 @@ static int manager_make_listen_socket(Manager *m) {
|
||||
(void) sockaddr_un_unlink(&sockaddr.un);
|
||||
|
||||
WITH_UMASK(0000)
|
||||
if (bind(m->listen_fd, &sockaddr.sa, SOCKADDR_UN_LEN(sockaddr.un)) < 0)
|
||||
if (bind(m->listen_fd, &sockaddr.sa, sockaddr_un_len(&sockaddr.un)) < 0)
|
||||
return log_error_errno(errno, "Failed to bind socket: %m");
|
||||
|
||||
FOREACH_STRING(alias,
|
||||
|
||||
@@ -47,7 +47,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to start up daemon: %m");
|
||||
|
||||
notify_stop = notify_start(NOTIFY_READY, NOTIFY_STOPPING);
|
||||
notify_stop = notify_start(NOTIFY_READY_MESSAGE, NOTIFY_STOPPING_MESSAGE);
|
||||
|
||||
r = sd_event_loop(m->event);
|
||||
if (r < 0)
|
||||
|
||||
@@ -9,18 +9,23 @@ Generate %-from-name.gperf from %-list.txt
|
||||
import sys
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 4:
|
||||
sys.exit(f'Usage: {sys.argv[0]} name prefix file')
|
||||
if len(sys.argv) < 4:
|
||||
sys.exit(f'Usage: {sys.argv[0]} name prefix file [includes...]')
|
||||
|
||||
name, prefix, file = sys.argv[1:]
|
||||
name, prefix, file, *includes = sys.argv[1:]
|
||||
includes = [f"#include {i}" for i in includes]
|
||||
|
||||
print("""\
|
||||
%{
|
||||
_Pragma("GCC diagnostic ignored \\"-Wimplicit-fallthrough\\"")
|
||||
# Older versions of python don't allow backslashes
|
||||
# in f-strings so use chr(10) for newlines and chr(92)
|
||||
# for backslashes instead as a workaround.
|
||||
print(f"""\
|
||||
%{{
|
||||
_Pragma("GCC diagnostic ignored {chr(92)}"-Wimplicit-fallthrough{chr(92)}"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \\"-Wzero-as-null-pointer-constant\\"")
|
||||
_Pragma("GCC diagnostic ignored {chr(92)}"-Wzero-as-null-pointer-constant{chr(92)}"")
|
||||
#endif
|
||||
%}""")
|
||||
{chr(10).join(includes)}
|
||||
%}}""")
|
||||
print(f"""\
|
||||
struct {name}_name {{ const char* name; int id; }};
|
||||
%null-strings
|
||||
|
||||
Reference in New Issue
Block a user