diff --git a/src/basic/macro.h b/src/basic/macro.h index 6d5840a832..c05339832d 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -25,7 +25,7 @@ #define _public_ __attribute__((__visibility__("default"))) #define _hidden_ __attribute__((__visibility__("hidden"))) #define _weakref_(x) __attribute__((__weakref__(#x))) -#define _alignas_(x) __attribute__((__aligned__(__alignof(x)))) +#define _alignas_(x) __attribute__((__aligned__(__alignof__(x)))) #define _alignptr_ __attribute__((__aligned__(sizeof(void*)))) #define _warn_unused_result_ __attribute__((__warn_unused_result__)) diff --git a/src/basic/signal-util.c b/src/basic/signal-util.c index 34b2b27918..f945a96f0d 100644 --- a/src/basic/signal-util.c +++ b/src/basic/signal-util.c @@ -119,7 +119,7 @@ int sigprocmask_many(int how, sigset_t *old, ...) { return 0; } -static const char *const __signal_table[] = { +static const char *const static_signal_table[] = { [SIGHUP] = "HUP", [SIGINT] = "INT", [SIGQUIT] = "QUIT", @@ -155,13 +155,13 @@ static const char *const __signal_table[] = { [SIGSYS] = "SYS" }; -DEFINE_PRIVATE_STRING_TABLE_LOOKUP(__signal, int); +DEFINE_PRIVATE_STRING_TABLE_LOOKUP(static_signal, int); const char *signal_to_string(int signo) { static thread_local char buf[STRLEN("RTMIN+") + DECIMAL_STR_MAX(int)]; const char *name; - name = __signal_to_string(signo); + name = static_signal_to_string(signo); if (name) return name; @@ -190,7 +190,7 @@ int signal_from_string(const char *s) { s += 3; /* Check that the input is a signal name. */ - signo = __signal_from_string(s); + signo = static_signal_from_string(s); if (signo > 0) return signo; diff --git a/src/basic/sort-util.c b/src/basic/sort-util.c index a9c68b7e3e..e0fb9cf4a8 100644 --- a/src/basic/sort-util.c +++ b/src/basic/sort-util.c @@ -5,7 +5,7 @@ /* hey glibc, APIs with callbacks without a user pointer are so useless */ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size, - __compar_d_fn_t compar, void *arg) { + comparison_userdata_fn_t compar, void *arg) { size_t l, u, idx; const void *p; int comparison; diff --git a/src/basic/sort-util.h b/src/basic/sort-util.h index 49586a4a24..02a6784d99 100644 --- a/src/basic/sort-util.h +++ b/src/basic/sort-util.h @@ -5,14 +5,20 @@ #include "macro.h" +/* This is the same as glibc's internal __compar_d_fn_t type. glibc exports a public comparison_fn_t, for the + * external type __compar_fn_t, but doesn't do anything similar for __compar_d_fn_t. Let's hence do that + * ourselves, picking a name that is obvious, but likely enough to not clash with glibc's choice of naming if + * they should ever add one. */ +typedef int (*comparison_userdata_fn_t)(const void *, const void *, void *); + void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size, - __compar_d_fn_t compar, void *arg); + comparison_userdata_fn_t compar, void *arg); #define typesafe_bsearch_r(k, b, n, func, userdata) \ ({ \ const typeof(b[0]) *_k = k; \ int (*_func_)(const typeof(b[0])*, const typeof(b[0])*, typeof(userdata)) = func; \ - xbsearch_r((const void*) _k, (b), (n), sizeof((b)[0]), (__compar_d_fn_t) _func_, userdata); \ + xbsearch_r((const void*) _k, (b), (n), sizeof((b)[0]), (comparison_userdata_fn_t) _func_, userdata); \ }) /** @@ -20,7 +26,7 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size, * that only if nmemb > 0. */ static inline void* bsearch_safe(const void *key, const void *base, - size_t nmemb, size_t size, __compar_fn_t compar) { + size_t nmemb, size_t size, comparison_fn_t compar) { if (nmemb <= 0) return NULL; @@ -32,14 +38,14 @@ static inline void* bsearch_safe(const void *key, const void *base, ({ \ const typeof(b[0]) *_k = k; \ int (*_func_)(const typeof(b[0])*, const typeof(b[0])*) = func; \ - bsearch_safe((const void*) _k, (b), (n), sizeof((b)[0]), (__compar_fn_t) _func_); \ + bsearch_safe((const void*) _k, (b), (n), sizeof((b)[0]), (comparison_fn_t) _func_); \ }) /** * Normal qsort requires base to be nonnull. Here were require * that only if nmemb > 0. */ -static inline void _qsort_safe(void *base, size_t nmemb, size_t size, __compar_fn_t compar) { +static inline void _qsort_safe(void *base, size_t nmemb, size_t size, comparison_fn_t compar) { if (nmemb <= 1) return; @@ -52,10 +58,10 @@ static inline void _qsort_safe(void *base, size_t nmemb, size_t size, __compar_f #define typesafe_qsort(p, n, func) \ ({ \ int (*_func_)(const typeof(p[0])*, const typeof(p[0])*) = func; \ - _qsort_safe((p), (n), sizeof((p)[0]), (__compar_fn_t) _func_); \ + _qsort_safe((p), (n), sizeof((p)[0]), (comparison_fn_t) _func_); \ }) -static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, __compar_d_fn_t compar, void *userdata) { +static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, comparison_userdata_fn_t compar, void *userdata) { if (nmemb <= 1) return; @@ -66,7 +72,7 @@ static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, __compar_ #define typesafe_qsort_r(p, n, func, userdata) \ ({ \ int (*_func_)(const typeof(p[0])*, const typeof(p[0])*, typeof(userdata)) = func; \ - qsort_r_safe((p), (n), sizeof((p)[0]), (__compar_d_fn_t) _func_, userdata); \ + qsort_r_safe((p), (n), sizeof((p)[0]), (comparison_userdata_fn_t) _func_, userdata); \ }) int cmp_int(const int *a, const int *b); diff --git a/src/basic/sparse-endian.h b/src/basic/sparse-endian.h index 9583dda9e5..c795d3da8f 100644 --- a/src/basic/sparse-endian.h +++ b/src/basic/sparse-endian.h @@ -55,9 +55,9 @@ typedef uint64_t __sd_bitwise be64_t; #undef le64toh #if __BYTE_ORDER == __LITTLE_ENDIAN -#define bswap_16_on_le(x) __bswap_16(x) -#define bswap_32_on_le(x) __bswap_32(x) -#define bswap_64_on_le(x) __bswap_64(x) +#define bswap_16_on_le(x) bswap_16(x) +#define bswap_32_on_le(x) bswap_32(x) +#define bswap_64_on_le(x) bswap_64(x) #define bswap_16_on_be(x) (x) #define bswap_32_on_be(x) (x) #define bswap_64_on_be(x) (x) @@ -65,9 +65,9 @@ typedef uint64_t __sd_bitwise be64_t; #define bswap_16_on_le(x) (x) #define bswap_32_on_le(x) (x) #define bswap_64_on_le(x) (x) -#define bswap_16_on_be(x) __bswap_16(x) -#define bswap_32_on_be(x) __bswap_32(x) -#define bswap_64_on_be(x) __bswap_64(x) +#define bswap_16_on_be(x) bswap_16(x) +#define bswap_32_on_be(x) bswap_32(x) +#define bswap_64_on_be(x) bswap_64(x) #endif static inline le16_t htole16(uint16_t value) { return (le16_t __sd_force) bswap_16_on_be(value); } diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index d82d679a47..eb07bf6898 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -25,7 +25,7 @@ #define TEXT_ATTR_SWAP(c) EFI_TEXT_ATTR(((c) & 0b11110000) >> 4, (c) & 0b1111) /* magic string to find in the binary image */ -static const char _used_ _section_(".sdmagic") magic[] = "#### LoaderInfo: systemd-boot " GIT_VERSION " ####"; +_used_ _section_(".sdmagic") static const char magic[] = "#### LoaderInfo: systemd-boot " GIT_VERSION " ####"; enum loader_type { LOADER_UNDEFINED, diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c index 00876337d2..aa8ca9666b 100644 --- a/src/boot/efi/stub.c +++ b/src/boot/efi/stub.c @@ -14,7 +14,7 @@ #include "util.h" /* magic string to find in the binary image */ -static const char __attribute__((used)) magic[] = "#### LoaderInfo: systemd-stub " GIT_VERSION " ####"; +_used_ _section_(".sdmagic") static const char magic[] = "#### LoaderInfo: systemd-stub " GIT_VERSION " ####"; static EFI_STATUS combine_initrd( EFI_PHYSICAL_ADDRESS initrd_base, UINTN initrd_size, diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c index 984e324d74..513a4fb00e 100644 --- a/src/core/selinux-access.c +++ b/src/core/selinux-access.c @@ -126,7 +126,7 @@ _printf_(2, 3) static int log_callback(int type, const char *fmt, ...) { DISABLE_WARNING_FORMAT_NONLITERAL; log_internalv(LOG_AUTH | callback_type_to_priority(type), - 0, PROJECT_FILE, __LINE__, __FUNCTION__, + 0, PROJECT_FILE, __LINE__, __func__, fmt2, ap); REENABLE_WARNING; va_end(ap); diff --git a/src/libsystemd-network/dhcp-identifier.c b/src/libsystemd-network/dhcp-identifier.c index 3313e53f74..23021f7bad 100644 --- a/src/libsystemd-network/dhcp-identifier.c +++ b/src/libsystemd-network/dhcp-identifier.c @@ -207,7 +207,7 @@ int dhcp_identifier_set_iaid( if (legacy_unstable_byteorder) /* for historical reasons (a bug), the bits were swapped and thus * the result was endianness dependent. Preserve that behavior. */ - id32 = __bswap_32(id32); + id32 = bswap_32(id32); else /* the fixed behavior returns a stable byte order. Since LE is expected * to be more common, swap the bytes on LE to give the same as legacy diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c index 10db7f6c4b..4b11cdbc16 100644 --- a/src/libsystemd-network/test-dhcp-client.c +++ b/src/libsystemd-network/test-dhcp-client.c @@ -45,7 +45,7 @@ static void test_request_basic(sd_event *e) { sd_dhcp_client *client; if (verbose) - printf("* %s\n", __FUNCTION__); + printf("* %s\n", __func__); /* Initialize client without Anonymize settings. */ r = sd_dhcp_client_new(&client, false); @@ -105,7 +105,7 @@ static void test_request_anonymize(sd_event *e) { sd_dhcp_client *client; if (verbose) - printf("* %s\n", __FUNCTION__); + printf("* %s\n", __func__); /* Initialize client with Anonymize settings. */ r = sd_dhcp_client_new(&client, true); @@ -137,7 +137,7 @@ static void test_checksum(void) { }; if (verbose) - printf("* %s\n", __FUNCTION__); + printf("* %s\n", __func__); assert_se(dhcp_packet_checksum((uint8_t*)&buf, 20) == be16toh(0x78ae)); } @@ -158,7 +158,7 @@ static void test_dhcp_identifier_set_iaid(void) { #if __BYTE_ORDER == __LITTLE_ENDIAN assert_se(iaid == iaid_legacy); #else - assert_se(iaid == __bswap_32(iaid_legacy)); + assert_se(iaid == bswap_32(iaid_legacy)); #endif } @@ -279,7 +279,7 @@ static void test_discover_message(sd_event *e) { int res, r; if (verbose) - printf("* %s\n", __FUNCTION__); + printf("* %s\n", __func__); r = sd_dhcp_client_new(&client, false); assert_se(r >= 0); @@ -497,7 +497,7 @@ static void test_addr_acq(sd_event *e) { int res, r; if (verbose) - printf("* %s\n", __FUNCTION__); + printf("* %s\n", __func__); r = sd_dhcp_client_new(&client, false); assert_se(r >= 0); diff --git a/src/libsystemd-network/test-ipv4ll.c b/src/libsystemd-network/test-ipv4ll.c index 7985185b33..e90e73459d 100644 --- a/src/libsystemd-network/test-ipv4ll.c +++ b/src/libsystemd-network/test-ipv4ll.c @@ -81,7 +81,7 @@ static void test_public_api_setters(sd_event *e) { .ether_addr_octet = {'A', 'B', 'C', '1', '2', '3'}}; if (verbose) - printf("* %s\n", __FUNCTION__); + printf("* %s\n", __func__); assert_se(sd_ipv4ll_new(&ll) == 0); assert_se(ll); @@ -130,7 +130,7 @@ static void test_basic_request(sd_event *e) { .ether_addr_octet = {'A', 'B', 'C', '1', '2', '3'}}; if (verbose) - printf("* %s\n", __FUNCTION__); + printf("* %s\n", __func__); assert_se(sd_ipv4ll_new(&ll) == 0); assert_se(sd_ipv4ll_start(ll) == -EINVAL); diff --git a/src/libsystemd-network/test-ndisc-ra.c b/src/libsystemd-network/test-ndisc-ra.c index 927e21b3cd..4713bc99b5 100644 --- a/src/libsystemd-network/test-ndisc-ra.c +++ b/src/libsystemd-network/test-ndisc-ra.c @@ -111,7 +111,7 @@ static int test_rs_hangcheck(sd_event_source *s, uint64_t usec, static void test_radv_prefix(void) { sd_radv_prefix *p; - printf("* %s\n", __FUNCTION__); + printf("* %s\n", __func__); assert_se(sd_radv_prefix_new(&p) >= 0); @@ -153,7 +153,7 @@ static void test_radv_prefix(void) { static void test_radv(void) { sd_radv *ra; - printf("* %s\n", __FUNCTION__); + printf("* %s\n", __func__); assert_se(sd_radv_new(&ra) >= 0); assert_se(ra); @@ -295,7 +295,7 @@ static void test_ra(void) { sd_radv *ra; unsigned i; - printf("* %s\n", __FUNCTION__); + printf("* %s\n", __func__); assert_se(socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) >= 0); diff --git a/src/libsystemd-network/test-ndisc-rs.c b/src/libsystemd-network/test-ndisc-rs.c index 5e50453c35..ae26ee7e74 100644 --- a/src/libsystemd-network/test-ndisc-rs.c +++ b/src/libsystemd-network/test-ndisc-rs.c @@ -273,7 +273,7 @@ static void test_rs(void) { sd_ndisc *nd; if (verbose) - printf("* %s\n", __FUNCTION__); + printf("* %s\n", __func__); send_ra_function = send_ra; @@ -366,7 +366,7 @@ static void test_timeout(void) { sd_ndisc *nd; if (verbose) - printf("* %s\n", __FUNCTION__); + printf("* %s\n", __func__); send_ra_function = test_timeout_value; diff --git a/src/locale/localed.c b/src/locale/localed.c index df0eb030d4..c228385d0e 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -560,7 +560,7 @@ static void log_xkb(struct xkb_context *ctx, enum xkb_log_level lvl, const char fmt = strjoina("libxkbcommon: ", format); DISABLE_WARNING_FORMAT_NONLITERAL; - log_internalv(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, fmt, args); + log_internalv(LOG_DEBUG, 0, PROJECT_FILE, __LINE__, __func__, fmt, args); REENABLE_WARNING; } diff --git a/src/shared/ethtool-util.c b/src/shared/ethtool-util.c index ee7be4635f..333e5a4879 100644 --- a/src/shared/ethtool-util.c +++ b/src/shared/ethtool-util.c @@ -756,7 +756,7 @@ int ethtool_set_features(int *ethtool_fd, const char *ifname, const int features static int get_glinksettings(int fd, struct ifreq *ifr, struct ethtool_link_usettings **ret) { struct ecmd { struct ethtool_link_settings req; - __u32 link_mode_data[3 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32]; + uint32_t link_mode_data[3 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32]; } ecmd = { .req.cmd = ETHTOOL_GLINKSETTINGS, }; @@ -857,7 +857,7 @@ static int get_gset(int fd, struct ifreq *ifr, struct ethtool_link_usettings **r static int set_slinksettings(int fd, struct ifreq *ifr, const struct ethtool_link_usettings *u) { struct { struct ethtool_link_settings req; - __u32 link_mode_data[3 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32]; + uint32_t link_mode_data[3 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32]; } ecmd = {}; unsigned offset; diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c index 489f5ad16a..bde2811dd7 100644 --- a/src/udev/scsi_id/scsi_serial.c +++ b/src/udev/scsi_id/scsi_serial.c @@ -237,7 +237,7 @@ static int scsi_dump(struct scsi_id_device *dev_scsi, struct sg_io_hdr *io) { */ return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "%s: called with no error", - __FUNCTION__); + __func__); log_debug("%s: sg_io failed status 0x%x 0x%x 0x%x 0x%x", dev_scsi->kernel, io->driver_status, io->host_status, io->msg_status, io->status); @@ -255,7 +255,7 @@ static int scsi_dump_v4(struct scsi_id_device *dev_scsi, struct sg_io_v4 *io) { */ return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "%s: called with no error", - __FUNCTION__); + __func__); log_debug("%s: sg_io failed status 0x%x 0x%x 0x%x", dev_scsi->kernel, io->driver_status, io->transport_status, io->device_status);