]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
libsystemd: drop "const" decorators on public inline functions
authorLennart Poettering <lennart@poettering.net>
Tue, 14 Oct 2025 09:17:27 +0000 (11:17 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 14 Oct 2025 11:08:57 +0000 (13:08 +0200)
The point of the "const" attribute is to give the compiler hints about
behaviour of functions if it only has the function prototype but no body
around. But inline functions are the ones where the compiler *always*
has the body around, hence the "const" decorator is really just noise:
the compuler can determine the constness on its own, just by looking at
the code.

Hence, drop the decorators, it's just noise. And a source of errors, as
675fa49f69943b0f009c973ed3d1e90afc1d88b1 has shown.

Follow-up for: #39289

src/systemd/_sd-common.h
src/systemd/sd-id128.h
src/systemd/sd-json.h

index 1b855bfdd235f1603be9c1ff7baef248761987dc..36410c9e34663d3e5ff068c44bd6f0a770517030 100644 (file)
@@ -52,10 +52,6 @@ typedef void (*_sd_destroy_t)(void *userdata);
 #  define _sd_pure_ __attribute__((__pure__))
 #endif
 
-#ifndef _sd_const_
-#  define _sd_const_ __attribute__((__const__))
-#endif
-
 /* Note that strictly speaking __deprecated__ has been available before GCC 6. However, starting with GCC 6
  * it also works on enum values, which we are interested in. Since this is a developer-facing feature anyway
  * (as opposed to build engineer-facing), let's hence conditionalize this to gcc 6, given that the developers
index 915d2ab2f226b8c8bcde55251b153bc2da4d4090..b579d72440afa789cb79f1066a16aaf437c51179 100644 (file)
@@ -115,17 +115,17 @@ int sd_id128_get_invocation_app_specific(sd_id128_t app_id, sd_id128_t *ret);
 #define SD_ID128_MAKE_UUID_STR(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \
         #a #b #c #d "-" #e #f "-" #g #h "-" #i #j "-" #k #l #m #n #o #p
 
-_sd_const_ static __inline__ int sd_id128_equal(sd_id128_t a, sd_id128_t b) {
+static __inline__ int sd_id128_equal(sd_id128_t a, sd_id128_t b) {
         return a.qwords[0] == b.qwords[0] && a.qwords[1] == b.qwords[1];
 }
 
 int sd_id128_string_equal(const char *s, sd_id128_t id);
 
-_sd_const_ static __inline__ int sd_id128_is_null(sd_id128_t a) {
+static __inline__ int sd_id128_is_null(sd_id128_t a) {
         return a.qwords[0] == 0 && a.qwords[1] == 0;
 }
 
-_sd_const_ static __inline__ int sd_id128_is_allf(sd_id128_t a) {
+static __inline__ int sd_id128_is_allf(sd_id128_t a) {
         return a.qwords[0] == UINT64_C(0xFFFFFFFFFFFFFFFF) && a.qwords[1] == UINT64_C(0xFFFFFFFFFFFFFFFF);
 }
 
@@ -144,7 +144,7 @@ static __inline__ int sd_id128_in_setv(sd_id128_t a, va_list ap) {
         }
 }
 
-_sd_const_ static __inline__ int sd_id128_in_set_sentinel(sd_id128_t a, ...) {
+static __inline__ int sd_id128_in_set_sentinel(sd_id128_t a, ...) {
         va_list ap;
         int r;
 
index fabec8a7a404d48cf7354ff805eecc220f1f5971..9328e4700fe573c3dc15a9441ebf68da606ee726 100644 (file)
@@ -338,7 +338,7 @@ int sd_json_variant_unhex(sd_json_variant *v, void **ret, size_t *ret_size);
 const char* sd_json_variant_type_to_string(sd_json_variant_type_t t);
 sd_json_variant_type_t sd_json_variant_type_from_string(const char *s);
 
-_sd_const_ static __inline__ int sd_json_format_enabled(sd_json_format_flags_t flags) {
+static __inline__ int sd_json_format_enabled(sd_json_format_flags_t flags) {
         return !(flags & SD_JSON_FORMAT_OFF);
 }