From 625f10960419d59bf9bd67d2d2d26f573b32da5a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 11 Oct 2024 14:03:05 +0200 Subject: [PATCH] sd-json: drop sd_json_dispatch_pid() again, as we prefer json_dispatch_pidref() now The calls are now unused, and we generally prefer if people send a PID triplet rather than a single PID, hence stop supporting a high-level dispacher for pid_t. --- src/basic/process-util.h | 5 ----- src/libsystemd/libsystemd.sym | 1 - src/libsystemd/sd-json/sd-json.c | 38 -------------------------------- src/systemd/sd-json.h | 1 - 4 files changed, 45 deletions(-) diff --git a/src/basic/process-util.h b/src/basic/process-util.h index c282df7701e..05b7a69fc60 100644 --- a/src/basic/process-util.h +++ b/src/basic/process-util.h @@ -150,7 +150,6 @@ static inline bool sched_priority_is_valid(int i) { } #define PID_AUTOMATIC ((pid_t) INT_MIN) /* special value indicating "acquire pid from connection peer" */ -#define PID_INVALID ((pid_t) 0) /* default value for "invalid pid" */ static inline bool pid_is_valid(pid_t p) { return p > 0; @@ -160,10 +159,6 @@ static inline bool pid_is_automatic(pid_t p) { return p == PID_AUTOMATIC; } -static inline bool pid_is_valid_or_automatic(pid_t p) { - return pid_is_valid(p) || pid_is_automatic(p); -} - pid_t getpid_cached(void); void reset_cached_pid(void); diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym index d642ef2581b..b3f46f90f19 100644 --- a/src/libsystemd/libsystemd.sym +++ b/src/libsystemd/libsystemd.sym @@ -864,7 +864,6 @@ global: sd_json_dispatch_strv; sd_json_dispatch_tristate; sd_json_dispatch_uid_gid; - sd_json_dispatch_pid; sd_json_dispatch_uint16; sd_json_dispatch_uint32; sd_json_dispatch_uint64; diff --git a/src/libsystemd/sd-json/sd-json.c b/src/libsystemd/sd-json/sd-json.c index 5ff1b584a65..2028f222cbc 100644 --- a/src/libsystemd/sd-json/sd-json.c +++ b/src/libsystemd/sd-json/sd-json.c @@ -5564,44 +5564,6 @@ _public_ int sd_json_dispatch_uid_gid(const char *name, sd_json_variant *variant return 0; } -_public_ int sd_json_dispatch_pid(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) { - /* pid_t is a signed type, but we don't consider negative values as valid. - * There is a special treatment for 0 if SD_JSON_RELAX flag present. */ - - pid_t *pid = userdata; - uint32_t k; - int r; - - assert_return(variant, -EINVAL); - assert_cc(sizeof(pid_t) == sizeof(uint32_t)); - - if (sd_json_variant_is_null(variant)) { - *pid = PID_INVALID; - return 0; - } - - r = sd_json_dispatch_uint32(name, variant, flags, &k); - if (r < 0) - return r; - - if (k == 0) { - if (!FLAGS_SET(flags, SD_JSON_RELAX)) - goto invalid_value; - - *pid = PID_AUTOMATIC; - return 0; - } - - if (!pid_is_valid(k)) - goto invalid_value; - - *pid = k; - return 0; - -invalid_value: - return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not a valid PID.", strna(name)); -} - _public_ int sd_json_dispatch_id128(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) { sd_id128_t *uuid = userdata; int r; diff --git a/src/systemd/sd-json.h b/src/systemd/sd-json.h index a73eeb8dd6f..f3c9a272572 100644 --- a/src/systemd/sd-json.h +++ b/src/systemd/sd-json.h @@ -328,7 +328,6 @@ int sd_json_dispatch_int8(const char *name, sd_json_variant *variant, sd_json_di int sd_json_dispatch_uint8(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata); int sd_json_dispatch_double(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata); int sd_json_dispatch_uid_gid(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata); -int sd_json_dispatch_pid(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata); int sd_json_dispatch_id128(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata); int sd_json_dispatch_signal(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata); int sd_json_dispatch_unsupported(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata); -- 2.47.3