]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: Small fixes for various clang-tidy warnings
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 21 Nov 2025 10:14:32 +0000 (11:14 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 26 Nov 2025 07:22:00 +0000 (16:22 +0900)
69 files changed:
src/analyze/analyze-image-policy.c
src/analyze/analyze-nvpcrs.c
src/analyze/analyze-pcrs.c
src/basic/fileio.c
src/basic/hashmap.h
src/basic/locale-util.c
src/basic/parse-util.c
src/basic/proc-cmdline.h
src/basic/user-util.c
src/boot/boot.c
src/boot/shim.c
src/boot/stub.c
src/boot/util.h
src/core/bpf-restrict-fs.c
src/core/bpf-socket-bind.c
src/core/device.c
src/core/exec-invoke.c
src/core/manager.c
src/core/socket.c
src/core/swap.c
src/core/varlink-dynamic-user.c
src/dissect/dissect.c
src/fundamental/sha256-fundamental.c
src/home/homed-home.c
src/home/homed-manager.c
src/home/homework-luks.c
src/import/pull-tar.c
src/journal-remote/journal-remote-main.c
src/journal/journald-manager.c
src/journal/journald-stream.c
src/libsystemd-network/dhcp-packet.c
src/libsystemd-network/test-dhcp-client.c
src/libsystemd/sd-bus/bus-creds.c
src/libsystemd/sd-bus/bus-message.c
src/libsystemd/sd-bus/bus-socket.c
src/libsystemd/sd-event/sd-event.c
src/libsystemd/sd-journal/journal-file.c
src/login/loginctl.c
src/machine/image-dbus.c
src/machine/machined-varlink.c
src/machine/operation.c
src/network/networkctl-link-info.c
src/network/networkd-link-bus.c
src/network/networkd-ndisc.c
src/nspawn/nspawn-oci.c
src/nsresourced/userns-restrict.c
src/pcrlock/pcrlock.c
src/portable/portabled-operation.c
src/resolve/resolved-dns-stream.c
src/resolve/resolved-dnssd.h
src/resolve/test-resolved-dummy-server.c
src/run/run.c
src/shared/bootspec.h
src/shared/dns-packet.c
src/shared/dns-packet.h
src/shared/dns-rr.c
src/shared/exec-util.c
src/shared/logs-show.c
src/shared/reread-partition-table.c
src/shared/tpm2-util.c
src/shared/user-record.c
src/systemd/sd-netlink.h
src/sysupdate/sysupdate.c
src/sysupdate/sysupdated.c
src/test/test-json.c
src/test/test-openssl.c
src/test/test-sigbus.c
src/test/test-tpm2.c
src/timesync/timesyncd-manager.c

index 9b95f35438fb26aa5c192ce9106b0e05e45a90c5..f7075c60a6602f5d47e269358985b477fbc7951b 100644 (file)
@@ -132,7 +132,7 @@ int verb_image_policy(int argc, char *argv[], void *userdata) {
                 if (!table)
                         return log_oom();
 
-                (void) table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
+                table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
 
                 for (PartitionDesignator d = 0; d < _PARTITION_DESIGNATOR_MAX; d++) {
                         PartitionPolicyFlags f = image_policy_get_exhaustively(p, d);
index 546523175c26836d19133a637959e419b1f83a56..4da24523935105cd3a414f00542f1dab25e0873d 100644 (file)
@@ -65,7 +65,7 @@ int verb_nvpcrs(int argc, char *argv[], void *userdata) {
                 return log_oom();
 
         (void) table_set_align_percent(table, table_get_cell(table, 0, 1), 100);
-        (void) table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
+        table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
         (void) table_set_sort(table, (size_t) 0);
 
         if (!have_tpm2)
index aa26af275d27f99ffa5a33781da2f5f35869b62d..ab5ef0e4de2feab1a8916371219287c3d8331722 100644 (file)
@@ -114,7 +114,7 @@ int verb_pcrs(int argc, char *argv[], void *userdata) {
                 return log_oom();
 
         (void) table_set_align_percent(table, table_get_cell(table, 0, 0), 100);
-        (void) table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
+        table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
 
         if (!alg) /* hide hash column if we couldn't acquire it */
                 (void) table_set_display(table, 0, 1);
index a3860abefbeccc1b3e6c54f4a45d1f7786ce2b38..2e6fffbd8503f4159161451431160a502ad8ed1c 100644 (file)
@@ -1228,7 +1228,7 @@ int search_and_open(
 
         assert(path);
 
-        copy = strv_copy((char**) search);
+        copy = strv_copy(search);
         if (!copy)
                 return -ENOMEM;
 
index 6ae9241760aa9b50c28bdbe148be33ed8edd2f69..ea39ffd6b09c70e8f807bd5e40b1fe73b1a59416 100644 (file)
@@ -89,10 +89,10 @@ int ordered_hashmap_ensure_replace(OrderedHashmap **h, const struct hash_ops *ha
 
 IteratedCache* _hashmap_iterated_cache_new(HashmapBase *h);
 static inline IteratedCache* hashmap_iterated_cache_new(Hashmap *h) {
-        return (IteratedCache*) _hashmap_iterated_cache_new(HASHMAP_BASE(h));
+        return _hashmap_iterated_cache_new(HASHMAP_BASE(h));
 }
 static inline IteratedCache* ordered_hashmap_iterated_cache_new(OrderedHashmap *h) {
-        return (IteratedCache*) _hashmap_iterated_cache_new(HASHMAP_BASE(h));
+        return _hashmap_iterated_cache_new(HASHMAP_BASE(h));
 }
 
 int hashmap_put(Hashmap *h, const void *key, void *value);
index ebccc6a8bd5ce712d603346025b1e604b7b793ae..6e752994185bfbe3eeb85cc3e7f5210c5e087e00 100644 (file)
@@ -151,7 +151,7 @@ static int add_locales_from_archive(Set *locales) {
 
 finish:
         if (p != MAP_FAILED)
-                munmap((void*) p, st.st_size);
+                munmap(p, st.st_size);
 
         return r;
 }
index c16b2ecdf688671419f3935c23642af02d8a27ba..d6eff8e81c3b057924389b3a6e95894cbc0f8dbe 100644 (file)
@@ -645,7 +645,7 @@ int safe_atod(const char *s, double *ret_d) {
                 return -EINVAL;
 
         if (ret_d)
-                *ret_d = (double) d;
+                *ret_d = d;
 
         return 0;
 }
@@ -710,7 +710,7 @@ int parse_ip_port(const char *s, uint16_t *ret) {
         if (l == 0)
                 return -EINVAL;
 
-        *ret = (uint16_t) l;
+        *ret = l;
 
         return 0;
 }
index eee2ce24aa13ccedc5cffc53502b8c120fe09a21..67f31793ad7d1229904b64f7bcad8341b0b23b99 100644 (file)
@@ -17,7 +17,7 @@ int proc_cmdline_filter_pid1_args(char **argv, char ***ret);
 int proc_cmdline(char **ret);
 int proc_cmdline_strv(char ***ret);
 
-int proc_cmdline_parse(const proc_cmdline_parse_t parse, void *userdata, ProcCmdlineFlags flags);
+int proc_cmdline_parse(proc_cmdline_parse_t parse, void *userdata, ProcCmdlineFlags flags);
 
 int proc_cmdline_get_key(const char *parameter, ProcCmdlineFlags flags, char **ret_value);
 int proc_cmdline_get_bool(const char *key, ProcCmdlineFlags flags, bool *ret);
index 5610abac94de0c54ea3c8ff7ee6ee6726ef96239..6f5b597694f9080cc6cf6c1cb949a0417b4d5d15 100644 (file)
@@ -1110,7 +1110,7 @@ int getpwnam_malloc(const char *name, struct passwd **ret) {
                         return -ENOMEM;
 
                 struct passwd *pw = NULL;
-                r = getpwnam_r(name, buf, (char*) buf + ALIGN(sizeof(struct passwd)), (size_t) bufsize, &pw);
+                r = getpwnam_r(name, buf, (char*) buf + ALIGN(sizeof(struct passwd)), bufsize, &pw);
                 if (r == 0) {
                         if (pw) {
                                 if (ret)
@@ -1151,7 +1151,7 @@ int getpwuid_malloc(uid_t uid, struct passwd **ret) {
                         return -ENOMEM;
 
                 struct passwd *pw = NULL;
-                r = getpwuid_r(uid, buf, (char*) buf + ALIGN(sizeof(struct passwd)), (size_t) bufsize, &pw);
+                r = getpwuid_r(uid, buf, (char*) buf + ALIGN(sizeof(struct passwd)), bufsize, &pw);
                 if (r == 0) {
                         if (pw) {
                                 if (ret)
@@ -1195,7 +1195,7 @@ int getgrnam_malloc(const char *name, struct group **ret) {
                         return -ENOMEM;
 
                 struct group *gr = NULL;
-                r = getgrnam_r(name, buf, (char*) buf + ALIGN(sizeof(struct group)), (size_t) bufsize, &gr);
+                r = getgrnam_r(name, buf, (char*) buf + ALIGN(sizeof(struct group)), bufsize, &gr);
                 if (r == 0) {
                         if (gr) {
                                 if (ret)
@@ -1234,7 +1234,7 @@ int getgrgid_malloc(gid_t gid, struct group **ret) {
                         return -ENOMEM;
 
                 struct group *gr = NULL;
-                r = getgrgid_r(gid, buf, (char*) buf + ALIGN(sizeof(struct group)), (size_t) bufsize, &gr);
+                r = getgrgid_r(gid, buf, (char*) buf + ALIGN(sizeof(struct group)), bufsize, &gr);
                 if (r == 0) {
                         if (gr) {
                                 if (ret)
index 0ff98709d5594fb7637afe2e3edd348f61c8617b..a167f736349740e750a8a35756439fc6f3948200 100644 (file)
@@ -2900,7 +2900,7 @@ static void export_loader_variables(
 
         assert(loaded_image);
 
-        (void) efivar_set_time_usec(MAKE_GUID_PTR(LOADER), u"LoaderTimeInitUSec", init_usec);
+        efivar_set_time_usec(MAKE_GUID_PTR(LOADER), u"LoaderTimeInitUSec", init_usec);
         (void) efivar_set_str16(MAKE_GUID_PTR(LOADER), u"LoaderInfo", u"systemd-boot " GIT_VERSION, 0);
         (void) efivar_set_uint64_le(MAKE_GUID_PTR(LOADER), u"LoaderFeatures", loader_features, 0);
 }
index e50cac233a46d760888dac3f287ec97878a2e4cd..97410d666965949117a2f1c7c4521bfb01777a3d 100644 (file)
@@ -43,7 +43,7 @@ bool shim_loaded(void) {
 bool shim_loader_available(void) {
         void *shim_image_loader;
 
-        return BS->LocateProtocol(MAKE_GUID_PTR(SHIM_IMAGE_LOADER), NULL, (void **) &shim_image_loader) == EFI_SUCCESS;
+        return BS->LocateProtocol(MAKE_GUID_PTR(SHIM_IMAGE_LOADER), NULL, &shim_image_loader) == EFI_SUCCESS;
 }
 
 static bool shim_validate(
index 654913c43d8858753c2ca3e4a33188fe578e50c0..d45eead2790801397d409b8d0fa6bbae36fda7bb 100644 (file)
@@ -1235,7 +1235,7 @@ static EFI_STATUS run(EFI_HANDLE image) {
 
         /* Pick up the arguments passed to us, split out the prefixing profile parameter, and return the rest
          * as potential command line to use. */
-        (void) process_arguments(image, loaded_image, &profile, &cmdline);
+        process_arguments(image, loaded_image, &profile, &cmdline);
 
         /* Find the sections we want to operate on, both the basic ones, and the one appropriate for the
          * selected profile. */
index ef017f45fa03ea193c0152fcf7cbaa20d3178569..2be8d463c35bf230246234dcdff1a2d431036f68 100644 (file)
@@ -12,7 +12,7 @@
 extern uint8_t __executable_start[];
 
 DISABLE_WARNING_REDUNDANT_DECLS;
-void free(void *p);
+void free(void *p); /* NOLINT (readability-redundant-declaration,readability-inconsistent-declaration-parameter-name) */
 REENABLE_WARNING;
 
 static inline void freep(void *p) {
index 859ba556a022203ed6282c6986c2126fb027e52d..916454bc6efc82fcb9ffa28c05f1a08b8dc7d536 100644 (file)
@@ -23,7 +23,7 @@
 
 static struct restrict_fs_bpf *restrict_fs_bpf_free(struct restrict_fs_bpf *obj) {
         /* restrict_fs_bpf__destroy handles object == NULL case */
-        (void) restrict_fs_bpf__destroy(obj);
+        restrict_fs_bpf__destroy(obj);
 
         return NULL;
 }
index 1cba47306d90ae82136d1e1eebabe45037d00d7b..eef9c01987a006398a1e973cc901602bd3c414be 100644 (file)
@@ -16,7 +16,7 @@
 
 static struct socket_bind_bpf *socket_bind_bpf_free(struct socket_bind_bpf *obj) {
         /* socket_bind_bpf__destroy handles object == NULL case */
-        (void) socket_bind_bpf__destroy(obj);
+        socket_bind_bpf__destroy(obj);
 
         return NULL;
 }
index 8afca1236e89fd8e3873a1a76115cd8400de7fa4..9f206cef3b55586ec1f668776d7413b287bc9edd 100644 (file)
@@ -1276,7 +1276,7 @@ void device_found_node(Manager *m, const char *node, DeviceFound found, DeviceFo
         }
 
         /* Update the device unit's state, should it exist */
-        (void) device_update_found_by_name(m, node, found, mask);
+        device_update_found_by_name(m, node, found, mask);
 }
 
 bool device_shall_be_bound_by(Unit *device, Unit *u) {
index 6aa01dceaf9327cfef280120149f0906aceae4a8..1f64378b72d227b44b8aeccf49ad383996db3352 100644 (file)
@@ -1443,7 +1443,7 @@ static int setup_pam(
 
                 /* Make sure we don't keep open the passed fds in this child. We assume that otherwise only
                  * those fds are open here that have been opened by PAM. */
-                (void) close_many(params->fds, params->n_socket_fds + params->n_stashed_fds);
+                close_many(params->fds, params->n_socket_fds + params->n_stashed_fds);
 
                 /* Also close the 'exec_fd' in the child, since the service manager waits for the EOF induced
                  * by the execve() to wait for completion, and if we'd keep the fd open here in the child
@@ -2024,8 +2024,6 @@ static void do_idle_pipe_dance(int idle_pipe[static 4]) {
         idle_pipe[3] = safe_close(idle_pipe[3]);
 }
 
-static const char *exec_directory_env_name_to_string(ExecDirectoryType t);
-
 /* And this table also maps ExecDirectoryType, to the environment variable we pass the selected directory to
  * the service payload in. */
 static const char* const exec_directory_env_name_table[_EXEC_DIRECTORY_TYPE_MAX] = {
index 38376a8d4af669b9b6ea173c12e0d146eb1f8c52..192004554b527940a3a55d06f9d17081472e75a9 100644 (file)
@@ -4320,10 +4320,10 @@ void manager_recheck_dbus(Manager *m) {
                 if (MANAGER_IS_SYSTEM(m))
                         (void) bus_init_system(m);
         } else {
-                (void) bus_done_api(m);
+                bus_done_api(m);
 
                 if (MANAGER_IS_SYSTEM(m))
-                        (void) bus_done_system(m);
+                        bus_done_system(m);
         }
 }
 
index 971d297beb87868d27a7f11c4d59897978f62e1c..897a3289159851208bfc39b2ad4fdddc5801b934 100644 (file)
@@ -2975,7 +2975,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
                         log_unit_debug(u, "No matching ffs socket found: %s", value);
 
         } else if (streq(key, "trigger-ratelimit"))
-                (void) deserialize_ratelimit(&s->trigger_limit, key, value);
+                deserialize_ratelimit(&s->trigger_limit, key, value);
         else
                 log_unit_debug(UNIT(s), "Unknown serialization key: %s", key);
 
index 9fb9cb641e36a6d6d8aea499fd557c2cf7e6949f..fa7846cd4654b80e6a0a265c58f87b0440778e77 100644 (file)
@@ -1134,7 +1134,7 @@ static int swap_load_proc_swaps(Manager *m, bool set_flags) {
 
                 device_found_node(m, d, DEVICE_FOUND_SWAP, DEVICE_FOUND_SWAP);
 
-                (void) swap_process_new(m, d, prio, set_flags);
+                swap_process_new(m, d, prio, set_flags);
         }
 
         return 0;
index 685ed8bac5cc4a785aeb5cc0d01fee75fb33e1e1..6be6091b3b0ff42e38c75d5ece7bad70b820a485 100644 (file)
@@ -186,7 +186,7 @@ int vl_method_get_group_record(sd_varlink *link, sd_json_variant *parameters, sd
         if (gid_is_valid(p.gid))
                 r = dynamic_user_lookup_uid(m, (uid_t) p.gid, &found_name);
         else if (p.group_name)
-                r = dynamic_user_lookup_name(m, p.group_name, (uid_t*) &found_gid);
+                r = dynamic_user_lookup_name(m, p.group_name, &found_gid);
         else {
                 DynamicUser *d;
 
index d244822c133de376776a77ff9909ef532e32f2b6..45e98855d37193441c00094dae21e4adc4718004 100644 (file)
@@ -1204,7 +1204,7 @@ static int action_dissect(
         }
 
         if (!sd_json_format_enabled(arg_json_format_flags)) {
-                (void) table_set_header(t, arg_legend);
+                table_set_header(t, arg_legend);
 
                 r = table_print(t, NULL);
                 if (r < 0)
index 463b4ccde7c3a25fd4c5b57e28ec12d9f3ee5294..76951ccfad2e06d2e916ea73c00f0ea6472de53c 100644 (file)
@@ -68,7 +68,7 @@ static const uint32_t K[64] = {
         0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
 };
 
-static void sha256_process_block(const void *, size_t, struct sha256_ctx *);
+static void sha256_process_block(const void *buffer, size_t len, struct sha256_ctx *ctx);
 
 /* Initialize structure containing state of computation.
    (FIPS 180-2:5.3.2)  */
index 3af3bd099567d66519d0d9a3e3863f4a79e66ad2..9c40a6179ee0d04199e6dccf7b0b56f23890f0a7 100644 (file)
@@ -740,7 +740,7 @@ static void home_fixate_finish(Home *h, int ret, UserRecord *hr) {
         secret = TAKE_PTR(h->secret); /* Take possession */
 
         if (ret < 0) {
-                (void) home_count_bad_authentication(h, ret, /* save= */ false);
+                home_count_bad_authentication(h, ret, /* save= */ false);
 
                 (void) convert_worker_errno(h, ret, &error);
                 r = log_error_errno(ret, "Fixation failed: %m");
@@ -831,7 +831,7 @@ static void home_activate_finish(Home *h, int ret, UserRecord *hr) {
         assert(IN_SET(h->state, HOME_ACTIVATING, HOME_ACTIVATING_FOR_ACQUIRE));
 
         if (ret < 0) {
-                (void) home_count_bad_authentication(h, ret, /* save= */ true);
+                home_count_bad_authentication(h, ret, /* save= */ true);
 
                 (void) convert_worker_errno(h, ret, &error);
                 r = log_full_errno(error_is_bad_password(ret) ? LOG_NOTICE : LOG_ERR,
@@ -994,7 +994,7 @@ static void home_change_finish(Home *h, int ret, UserRecord *hr) {
         flags = h->current_operation ? h->current_operation->call_flags : 0;
 
         if (ret < 0) {
-                (void) home_count_bad_authentication(h, ret, /* save= */ true);
+                home_count_bad_authentication(h, ret, /* save= */ true);
 
                 (void) convert_worker_errno(h, ret, &error);
                 r = log_full_errno(error_is_bad_password(ret) ? LOG_NOTICE : LOG_ERR,
@@ -1069,7 +1069,7 @@ static void home_unlocking_finish(Home *h, int ret, UserRecord *hr) {
         assert(IN_SET(h->state, HOME_UNLOCKING, HOME_UNLOCKING_FOR_ACQUIRE));
 
         if (ret < 0) {
-                (void) home_count_bad_authentication(h, ret, /* save= */ true);
+                home_count_bad_authentication(h, ret, /* save= */ true);
 
                 (void) convert_worker_errno(h, ret, &error);
                 r = log_full_errno(error_is_bad_password(ret) ? LOG_NOTICE : LOG_ERR,
@@ -1105,7 +1105,7 @@ static void home_authenticating_finish(Home *h, int ret, UserRecord *hr) {
         assert(IN_SET(h->state, HOME_AUTHENTICATING, HOME_AUTHENTICATING_WHILE_ACTIVE, HOME_AUTHENTICATING_FOR_ACQUIRE));
 
         if (ret < 0) {
-                (void) home_count_bad_authentication(h, ret, /* save= */ true);
+                home_count_bad_authentication(h, ret, /* save= */ true);
 
                 (void) convert_worker_errno(h, ret, &error);
                 r = log_full_errno(error_is_bad_password(ret) ? LOG_NOTICE : LOG_ERR,
index 3185cd6fecaf21145fa36c2dee75c880d48135ee..c54cc43fd348cbde6d8b003e556c12a84ff64c39 100644 (file)
@@ -1889,7 +1889,7 @@ static int manager_rebalance_calculate(Manager *m) {
                 assert(h->rebalance_usage <= usage_sum);
                 assert(h->rebalance_weight <= weight_sum);
 
-                d = ((double) (free_sum / 4096) * (double) h->rebalance_weight) / (double) weight_sum; /* Calculate new space for this home in units of 4K */
+                d = ((double) (free_sum / 4096.0) * (double) h->rebalance_weight) / (double) weight_sum; /* Calculate new space for this home in units of 4K */
 
                 /* Convert from units of 4K back to bytes */
                 if (d >= (double) (UINT64_MAX/4096))
index 4cecc9d264c35f126fb1be5dfe942e7038fb3ce7..489343cddcd3705f02a43f7a054cd5e6464e4006 100644 (file)
@@ -3342,7 +3342,7 @@ int home_resize_luks(
         crypto_offset = sym_crypt_get_data_offset(setup->crypt_device);
         if (crypto_offset > UINT64_MAX/512U)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "LUKS2 data offset out of range, refusing.");
-        crypto_offset_bytes = (uint64_t) crypto_offset * 512U;
+        crypto_offset_bytes = crypto_offset * 512U;
         if (setup->partition_size <= crypto_offset_bytes)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Weird, old crypto payload offset doesn't actually fit in partition size?");
 
index c01e5eafe2c4bc04af012f9952a1c2a072283e93..956fe7b993f8a0f34e9c0b81207241ccb43974be 100644 (file)
@@ -215,7 +215,7 @@ static void tar_pull_report_progress(TarPull *i, TarProgress p) {
         sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent);
 
         if (isatty_safe(STDERR_FILENO))
-                (void) draw_progress_bar("Total:", percent);
+                draw_progress_bar("Total:", percent);
 
         log_debug("Combined progress %u%%", percent);
 
index 247b3f2dc590ab0c157386a244b9c8dfabe260bf..d7bac7a6beaf36bf5750bdcf55e2e28175bd5302 100644 (file)
@@ -713,7 +713,7 @@ static int create_remoteserver(
                 if (fd < 0)
                         return fd;
 
-                r = journal_remote_add_source(s, fd, (char*) arg_output, false);
+                r = journal_remote_add_source(s, fd, arg_output, false);
                 if (r < 0)
                         return r;
         }
index 12748f6401c08f6f0e19ae9de66bfd86a0f08985..e1e9cba0ed6941c51e75f4e165feda7ed9d92507 100644 (file)
@@ -2529,7 +2529,7 @@ int manager_init(Manager *m) {
 
         (void) manager_connect_notify(m);
 
-        (void) client_context_acquire_default(m);
+        client_context_acquire_default(m);
 
         r = manager_system_journal_open(m, /* flush_requested= */ false, /* relinquish_requested= */ false);
         if (r < 0)
index 650b81da5f8f82fad3aad5f8bfc708d00ef6fc36..227b5cba8307d0594f124e60783146c719260913 100644 (file)
@@ -228,7 +228,7 @@ static int stdout_stream_log(
         assert(line_break < _LINE_BREAK_MAX);
 
         if (s->context)
-                (void) client_context_maybe_refresh(s->manager, s->context, NULL, NULL, 0, NULL, USEC_INFINITY);
+                client_context_maybe_refresh(s->manager, s->context, NULL, NULL, 0, NULL, USEC_INFINITY);
         else if (pid_is_valid(s->ucred.pid)) {
                 r = client_context_acquire(s->manager, s->ucred.pid, &s->ucred, s->label, strlen_ptr(s->label), s->unit_id, &s->context);
                 if (r < 0)
index 7732f25b8f70656e3b5f8063421eccb6d9c14885..90eae88379ad558837713e5f6d3223de26e6797c 100644 (file)
@@ -136,7 +136,7 @@ void dhcp_packet_append_ip_headers(DHCPPacket *packet, be32_t source_addr,
         packet->udp.len = htobe16(len - DHCP_IP_SIZE);
 
         packet->ip.check = packet->udp.len;
-        packet->udp.check = dhcp_packet_checksum((uint8_t*)&packet->ip.ttl, len - 8);
+        packet->udp.check = dhcp_packet_checksum(&packet->ip.ttl, len - 8);
 
         packet->ip.ttl = IPDEFTTL;
         packet->ip.check = 0;
@@ -201,7 +201,7 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, ui
                 packet->ip.check = packet->udp.len;
                 packet->ip.ttl = 0;
 
-                if (dhcp_packet_checksum((uint8_t*)&packet->ip.ttl,
+                if (dhcp_packet_checksum(&packet->ip.ttl,
                                   be16toh(packet->udp.len) + 12))
                         return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
                                                "ignoring packet: invalid UDP checksum");
index cc08c3fbd221119f59c16315ad58043c2121883a..a14a97c179428ee3798cd45e3255987e769a93cf 100644 (file)
@@ -219,7 +219,7 @@ int dhcp_network_send_raw_socket(int s, const union sockaddr_union *link, const
         discover->ip.ttl = 0;
         discover->ip.check = discover->udp.len;
 
-        udp_check = ~dhcp_packet_checksum((uint8_t*)&discover->ip.ttl, len - 8);
+        udp_check = ~dhcp_packet_checksum(&discover->ip.ttl, len - 8);
         assert_se(udp_check == 0xffff);
 
         discover->ip.ttl = IPDEFTTL;
index 2bbbd0f48440661cd8444cb07d119d1ff150f3d8..12eb6f2cf38aa2b57632d9510ac1fcc5505fb2ab 100644 (file)
@@ -435,7 +435,7 @@ _public_ int sd_bus_creds_get_unit(sd_bus_creds *c, const char **ret) {
                 if (r < 0)
                         return r;
 
-                r = cg_path_get_unit(shifted, (char**) &c->unit);
+                r = cg_path_get_unit(shifted, &c->unit);
                 if (r < 0)
                         return r;
         }
@@ -462,7 +462,7 @@ _public_ int sd_bus_creds_get_user_unit(sd_bus_creds *c, const char **ret) {
                 if (r < 0)
                         return r;
 
-                r = cg_path_get_user_unit(shifted, (char**) &c->user_unit);
+                r = cg_path_get_user_unit(shifted, &c->user_unit);
                 if (r < 0)
                         return r;
         }
@@ -489,7 +489,7 @@ _public_ int sd_bus_creds_get_slice(sd_bus_creds *c, const char **ret) {
                 if (r < 0)
                         return r;
 
-                r = cg_path_get_slice(shifted, (char**) &c->slice);
+                r = cg_path_get_slice(shifted, &c->slice);
                 if (r < 0)
                         return r;
         }
@@ -516,7 +516,7 @@ _public_ int sd_bus_creds_get_user_slice(sd_bus_creds *c, const char **ret) {
                 if (r < 0)
                         return r;
 
-                r = cg_path_get_user_slice(shifted, (char**) &c->user_slice);
+                r = cg_path_get_user_slice(shifted, &c->user_slice);
                 if (r < 0)
                         return r;
         }
@@ -543,7 +543,7 @@ _public_ int sd_bus_creds_get_session(sd_bus_creds *c, const char **ret) {
                 if (r < 0)
                         return r;
 
-                r = cg_path_get_session(shifted, (char**) &c->session);
+                r = cg_path_get_session(shifted, &c->session);
                 if (r < 0)
                         return r;
         }
index 64f4f0e22389fed40a1e2be5815ca1efb9d52334..601e0152de671b80ddc6af60b70d29db858c88f4 100644 (file)
@@ -4000,7 +4000,7 @@ static int message_skip_fields(
                         if (r < 0)
                                 return r;
 
-                        r = message_skip_fields(m, ri, UINT32_MAX, (const char**) &s);
+                        r = message_skip_fields(m, ri, UINT32_MAX, &s);
                         if (r < 0)
                                 return r;
 
@@ -4191,7 +4191,7 @@ static int message_parse_fields(sd_bus_message *m) {
                         break;
 
                 default:
-                        r = message_skip_fields(m, &ri, UINT32_MAX, (const char **) &signature);
+                        r = message_skip_fields(m, &ri, UINT32_MAX, &signature);
                 }
                 if (r < 0)
                         return r;
index cdda006306a2f10c1028fe5e7f478dc748e13d44..1ab014e8256eca0385a92f7f3fb8a8fa2465c15a 100644 (file)
@@ -170,7 +170,7 @@ static int bus_socket_auth_verify_client(sd_bus *b) {
         if (!b->anonymous_auth) {
                 l = lines[i++];
                 if (lines[i] - l == 4 + 2) {
-                        if (memcmp(l, "DATA", 4))
+                        if (memcmp(l, "DATA", 4) != 0)
                                 return -EPERM;
                 } else if (lines[i] - l == 3 + 32 + 2) {
                         /*
@@ -182,7 +182,7 @@ static int bus_socket_auth_verify_client(sd_bus *b) {
                          * wrong reply. We ignore the "<id>" parameter, though,
                          * since it has no real value.
                          */
-                        if (memcmp(l, "OK ", 3))
+                        if (memcmp(l, "OK ", 3) != 0)
                                 return -EPERM;
                 } else
                         return -EPERM;
@@ -193,7 +193,7 @@ static int bus_socket_auth_verify_client(sd_bus *b) {
 
         if (lines[i] - l != 3 + 32 + 2)
                 return -EPERM;
-        if (memcmp(l, "OK ", 3))
+        if (memcmp(l, "OK ", 3) != 0)
                 return -EPERM;
 
         b->auth = b->anonymous_auth ? BUS_AUTH_ANONYMOUS : BUS_AUTH_EXTERNAL;
index c9d14ebf17b760d4be3d980ac1d3f1c0022f444f..de8551593451a4add43f393cb9e2c582e9c0a1c5 100644 (file)
@@ -5311,7 +5311,7 @@ _public_ int sd_event_source_set_memory_pressure_type(sd_event_source *s, const
         if (!space)
                 return -EINVAL;
 
-        size_t l = (char*) space - (char*) s->memory_pressure.write_buffer;
+        size_t l = space - (char*) s->memory_pressure.write_buffer;
         b = memdup_suffix0(s->memory_pressure.write_buffer, l);
         if (!b)
                 return -ENOMEM;
@@ -5357,7 +5357,7 @@ _public_ int sd_event_source_set_memory_pressure_period(sd_event_source *s, uint
         if (!space)
                 return -EINVAL;
 
-        size_t l = (char*) space - (char*) s->memory_pressure.write_buffer;
+        size_t l = space - (char*) s->memory_pressure.write_buffer;
         b = memdup_suffix0(s->memory_pressure.write_buffer, l);
         if (!b)
                 return -ENOMEM;
index fa87c7d52e4262d0037fc39686d04a8b41225cf3..7792d8433f151ae92b4f6749b47b48c867b56f5d 100644 (file)
@@ -555,7 +555,7 @@ static int journal_file_verify_header(JournalFile *f) {
         assert(f);
         assert(f->header);
 
-        if (memcmp(f->header->signature, HEADER_SIGNATURE, 8))
+        if (memcmp(f->header->signature, HEADER_SIGNATURE, 8) != 0)
                 return -EBADMSG;
 
         /* In both read and write mode we refuse to open files with incompatible
@@ -3935,17 +3935,21 @@ void journal_file_print_header(JournalFile *f) {
                le64toh(f->header->n_objects),
                le64toh(f->header->n_entries));
 
-        if (JOURNAL_HEADER_CONTAINS(f->header, n_data))
+        if (JOURNAL_HEADER_CONTAINS(f->header, n_data)) {
+                size_t n_data_items = le64toh(f->header->data_hash_table_size) / sizeof(HashItem);
                 printf("Data objects: %"PRIu64"\n"
                        "Data hash table fill: %.1f%%\n",
                        le64toh(f->header->n_data),
-                       100.0 * (double) le64toh(f->header->n_data) / ((double) (le64toh(f->header->data_hash_table_size) / sizeof(HashItem))));
+                       100.0 * (double) le64toh(f->header->n_data) / (double) n_data_items);
+        }
 
-        if (JOURNAL_HEADER_CONTAINS(f->header, n_fields))
+        if (JOURNAL_HEADER_CONTAINS(f->header, n_fields)) {
+                size_t n_field_items = le64toh(f->header->field_hash_table_size) / sizeof(HashItem);
                 printf("Field objects: %"PRIu64"\n"
                        "Field hash table fill: %.1f%%\n",
                        le64toh(f->header->n_fields),
-                       100.0 * (double) le64toh(f->header->n_fields) / ((double) (le64toh(f->header->field_hash_table_size) / sizeof(HashItem))));
+                       100.0 * (double) le64toh(f->header->n_fields) / (double) n_field_items);
+        }
 
         if (JOURNAL_HEADER_CONTAINS(f->header, n_tags))
                 printf("Tag objects: %"PRIu64"\n",
@@ -4630,11 +4634,12 @@ bool journal_file_rotate_suggested(JournalFile *f, usec_t max_file_usec, int log
 
         if (JOURNAL_HEADER_CONTAINS(f->header, n_data))
                 if (le64toh(f->header->n_data) * 4ULL > (le64toh(f->header->data_hash_table_size) / sizeof(HashItem)) * 3ULL) {
+                        size_t n_data_items = le64toh(f->header->data_hash_table_size) / sizeof(HashItem);
                         log_ratelimit_full(
                                 log_level, JOURNAL_LOG_RATELIMIT,
                                 "Data hash table of %s has a fill level at %.1f (%"PRIu64" of %"PRIu64" items, %"PRIu64" file size, %"PRIu64" bytes per hash table item), suggesting rotation.",
                                 f->path,
-                                100.0 * (double) le64toh(f->header->n_data) / ((double) (le64toh(f->header->data_hash_table_size) / sizeof(HashItem))),
+                                100.0 * (double) le64toh(f->header->n_data) / (double) n_data_items,
                                 le64toh(f->header->n_data),
                                 le64toh(f->header->data_hash_table_size) / sizeof(HashItem),
                                 (uint64_t) f->last_stat.st_size,
@@ -4644,11 +4649,12 @@ bool journal_file_rotate_suggested(JournalFile *f, usec_t max_file_usec, int log
 
         if (JOURNAL_HEADER_CONTAINS(f->header, n_fields))
                 if (le64toh(f->header->n_fields) * 4ULL > (le64toh(f->header->field_hash_table_size) / sizeof(HashItem)) * 3ULL) {
+                        size_t n_field_items = le64toh(f->header->field_hash_table_size) / sizeof(HashItem);
                         log_ratelimit_full(
                                 log_level, JOURNAL_LOG_RATELIMIT,
                                 "Field hash table of %s has a fill level at %.1f (%"PRIu64" of %"PRIu64" items), suggesting rotation.",
                                 f->path,
-                                100.0 * (double) le64toh(f->header->n_fields) / ((double) (le64toh(f->header->field_hash_table_size) / sizeof(HashItem))),
+                                100.0 * (double) le64toh(f->header->n_fields) / (double) n_field_items,
                                 le64toh(f->header->n_fields),
                                 le64toh(f->header->field_hash_table_size) / sizeof(HashItem));
                         return true;
index fa406cfd74fafafc588ca4c1935e86c869720ccb..adb666aef93e52b653075f3c5a12e52f3735ffae 100644 (file)
@@ -296,7 +296,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
         (void) table_set_align_percent(table, TABLE_HEADER_CELL(0), 100);
         (void) table_set_align_percent(table, TABLE_HEADER_CELL(1), 100);
 
-        (void) table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
+        table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
 
         if (use_ex)
                 r = list_sessions_table_add(table, reply);
@@ -337,7 +337,7 @@ static int list_users(int argc, char *argv[], void *userdata) {
                 return log_oom();
 
         (void) table_set_align_percent(table, TABLE_HEADER_CELL(0), 100);
-        (void) table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
+        table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
 
         for (;;) {
                 _cleanup_(sd_bus_error_free) sd_bus_error error_property = SD_BUS_ERROR_NULL;
@@ -405,7 +405,7 @@ static int list_seats(int argc, char *argv[], void *userdata) {
         if (!table)
                 return log_oom();
 
-        (void) table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
+        table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
 
         for (;;) {
                 const char *seat;
@@ -579,7 +579,7 @@ static int print_session_status_info(sd_bus *bus, const char *path) {
         if (!table)
                 return log_oom();
 
-        (void) table_set_ersatz_string(table, TABLE_ERSATZ_NA);
+        table_set_ersatz_string(table, TABLE_ERSATZ_NA);
 
         if (dual_timestamp_is_set(&i.timestamp)) {
                 r = table_add_cell(table, NULL, TABLE_FIELD, "Since");
@@ -770,7 +770,7 @@ static int print_user_status_info(sd_bus *bus, const char *path) {
         if (!table)
                 return log_oom();
 
-        (void) table_set_ersatz_string(table, TABLE_ERSATZ_NA);
+        table_set_ersatz_string(table, TABLE_ERSATZ_NA);
 
         if (dual_timestamp_is_set(&i.timestamp)) {
                 r = table_add_cell(table, NULL, TABLE_FIELD, "Since");
@@ -869,7 +869,7 @@ static int print_seat_status_info(sd_bus *bus, const char *path) {
         if (!table)
                 return log_oom();
 
-        (void) table_set_ersatz_string(table, TABLE_ERSATZ_NA);
+        table_set_ersatz_string(table, TABLE_ERSATZ_NA);
 
         if (!strv_isempty(i.sessions)) {
                 _cleanup_strv_free_ char **sessions = TAKE_PTR(i.sessions);
index 0b6a1691302a1e08b1152d0a85d4367dcfad2dac..f7e3f7f93c52c9a382852121afd5943d08653b44 100644 (file)
@@ -75,7 +75,7 @@ int bus_image_method_remove(
 
         r = operation_new_with_bus_reply(m, /* machine= */ NULL, child, message, errno_pipe_fd[0], /* ret= */ NULL);
         if (r < 0) {
-                (void) sigkill_wait(child);
+                sigkill_wait(child);
                 return r;
         }
 
@@ -190,7 +190,7 @@ int bus_image_method_clone(
 
         r = operation_new_with_bus_reply(m, /* machine= */ NULL, child, message, errno_pipe_fd[0], /* ret= */ NULL);
         if (r < 0) {
-                (void) sigkill_wait(child);
+                sigkill_wait(child);
                 return r;
         }
 
index 8188aeb4b134c143424583e25a4f0db7a9bd2ec4..dd02bf9dd1bf017b8c5961d70f6c14c20713bec7 100644 (file)
@@ -358,7 +358,7 @@ static int vl_method_get_group_record(sd_varlink *link, sd_json_variant *paramet
         if (gid_is_valid(p.gid))
                 r = group_lookup_gid(m, p.gid, &found_name, &found_description);
         else if (p.group_name)
-                r = group_lookup_name(m, p.group_name, (uid_t*) &found_gid, &found_description);
+                r = group_lookup_name(m, p.group_name, &found_gid, &found_description);
         else
                 return sd_varlink_error(link, "io.systemd.UserDatabase.EnumerationNotSupported", NULL);
         if (r == -ESRCH)
index a624cb35fd72967f573450b9fa83258c2718e8e0..4e85006b855c05690afdeac527e8bfaff0590e56 100644 (file)
@@ -148,7 +148,7 @@ Operation *operation_free(Operation *o) {
         safe_close(o->extra_fd);
 
         if (o->pid > 1)
-                (void) sigkill_wait(o->pid);
+                sigkill_wait(o->pid);
 
         sd_bus_message_unref(o->message);
         sd_varlink_unref(o->link);
index 9db89be8a8c899912c53451f923d5542c4a85248..8f072f834ac707d25edb1b3f84ad3f21d920fcab 100644 (file)
@@ -109,9 +109,9 @@ static int decode_netdev(sd_netlink_message *m, LinkInfo *info) {
                 (void) sd_netlink_message_read_u8(m, IFLA_VXLAN_L2MISS, &info->vxlan_info.l2miss);
                 (void) sd_netlink_message_read_u8(m, IFLA_VXLAN_TOS, &info->vxlan_info.tos);
                 (void) sd_netlink_message_read_u8(m, IFLA_VXLAN_TTL, &info->vxlan_info.ttl);
-        } else if (streq(info->netdev_kind, "vlan"))
+        } else if (streq(info->netdev_kind, "vlan")) {
                 (void) sd_netlink_message_read_u16(m, IFLA_VLAN_ID, &info->vlan_id);
-        else if (STR_IN_SET(info->netdev_kind, "ipip", "sit")) {
+        else if (STR_IN_SET(info->netdev_kind, "ipip", "sit")) {
                 (void) sd_netlink_message_read_in_addr(m, IFLA_IPTUN_LOCAL, &info->local.in);
                 (void) sd_netlink_message_read_in_addr(m, IFLA_IPTUN_REMOTE, &info->remote.in);
         } else if (streq(info->netdev_kind, "geneve")) {
@@ -144,9 +144,9 @@ static int decode_netdev(sd_netlink_message *m, LinkInfo *info) {
         } else if (streq(info->netdev_kind, "vti6")) {
                 (void) sd_netlink_message_read_in6_addr(m, IFLA_VTI_LOCAL, &info->local.in6);
                 (void) sd_netlink_message_read_in6_addr(m, IFLA_VTI_REMOTE, &info->remote.in6);
-        } else if (STR_IN_SET(info->netdev_kind, "macvlan", "macvtap"))
+        } else if (STR_IN_SET(info->netdev_kind, "macvlan", "macvtap")) {
                 (void) sd_netlink_message_read_u32(m, IFLA_MACVLAN_MODE, &info->macvlan_mode);
-        else if (streq(info->netdev_kind, "ipvlan")) {
+        else if (streq(info->netdev_kind, "ipvlan")) {
                 (void) sd_netlink_message_read_u16(m, IFLA_IPVLAN_MODE, &info->ipvlan_mode);
                 (void) sd_netlink_message_read_u16(m, IFLA_IPVLAN_FLAGS, &info->ipvlan_flags);
         }
index 127a86281745633e8aac5d534b63da75fe9ad83d..91ad555f6c86582f8181e9467a8ea82f44e43e6c 100644 (file)
@@ -57,7 +57,7 @@ static int property_get_bit_rates(
                 return sd_bus_message_append(reply, "(tt)", UINT64_MAX, UINT64_MAX);
 
         assert(manager->speed_meter_usec_new > manager->speed_meter_usec_old);
-        interval_sec = (manager->speed_meter_usec_new - manager->speed_meter_usec_old) / USEC_PER_SEC;
+        interval_sec = (double) (manager->speed_meter_usec_new - manager->speed_meter_usec_old) / USEC_PER_SEC;
 
         if (link->stats_new.tx_bytes > link->stats_old.tx_bytes)
                 tx = (uint64_t) ((link->stats_new.tx_bytes - link->stats_old.tx_bytes) / interval_sec);
index b985dc29defe431a73e196222e258bcad87d52b5..6c6f823c0c75c4b8fb37a3507df0c8fbbb834058 100644 (file)
@@ -2198,7 +2198,7 @@ static int ndisc_dnr_compare_func(const NDiscDNR *a, const NDiscDNR *b) {
                 strcmp_ptr(a->resolver.dohpath, b->resolver.dohpath) ||
                 CMP(a->resolver.family, b->resolver.family) ||
                 CMP(a->resolver.n_addrs, b->resolver.n_addrs) ||
-                memcmp(a->resolver.addrs, b->resolver.addrs, sizeof(a->resolver.addrs[0]) * a->resolver.n_addrs);
+                memcmp(a->resolver.addrs, b->resolver.addrs, sizeof(a->resolver.addrs[0]) * a->resolver.n_addrs) != 0;
 }
 
 static void ndisc_dnr_hash_func(const NDiscDNR *x, struct siphash *state) {
index 70bea70c0be25f884c549791fe0d5ccf959553ea..b0cc7a58cf8e293276d1e5abbb0e731a3a406ed3 100644 (file)
@@ -1097,7 +1097,7 @@ static int oci_cgroup_memory_limit(const char *name, sd_json_variant *v, sd_json
                 return json_log(v, flags, SYNTHETIC_ERRNO(ERANGE),
                                 "Memory limit too large: %" PRIu64, k);
 
-        *m = (uint64_t) k;
+        *m = k;
         return 0;
 }
 
@@ -1404,7 +1404,7 @@ static int oci_cgroup_block_io_throttle(const char *name, sd_json_variant *v, sd
                 if (r < 0)
                         return r;
 
-                r = sd_bus_message_append(s->properties, "(sv)", pname, "a(st)", 1, path, (uint64_t) data.rate);
+                r = sd_bus_message_append(s->properties, "(sv)", pname, "a(st)", 1, path, data.rate);
                 if (r < 0)
                         return bus_log_create_error(r);
         }
@@ -1451,9 +1451,9 @@ static int oci_cgroup_pids(const char *name, sd_json_variant *v, sd_json_dispatc
                         return json_log(k, flags, SYNTHETIC_ERRNO(EINVAL),
                                         "pids limit not unsigned integer, refusing.");
 
-                m = (uint64_t) sd_json_variant_unsigned(k);
+                m = sd_json_variant_unsigned(k);
 
-                if ((uint64_t) m != sd_json_variant_unsigned(k))
+                if (m != sd_json_variant_unsigned(k))
                         return json_log(v, flags, SYNTHETIC_ERRNO(EINVAL),
                                         "pids limit out of range, refusing.");
         }
index c2119035bde2e7f6e8ec111b20cca96d474dc5b5..48b531677c61d631bae3f121cd011c03dcf5d1d1 100644 (file)
@@ -26,7 +26,7 @@
 
 struct userns_restrict_bpf *userns_restrict_bpf_free(struct userns_restrict_bpf *obj) {
 #if HAVE_VMLINUX_H
-        (void) userns_restrict_bpf__destroy(obj); /* this call is fine with NULL */
+        userns_restrict_bpf__destroy(obj); /* this call is fine with NULL */
 #endif
         return NULL;
 
index 8be8c9ac3d1c8a26a60753177e7287ff34e10ca6..525e9c5f4ba5f7f1c88082917c5071d7e80a6a24 100644 (file)
@@ -2126,7 +2126,7 @@ static int show_log_table(EventLog *el, sd_json_variant **ret_variant) {
         if (!table)
                 return log_oom();
 
-        (void) table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
+        table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
 
         r = table_add_many(table,
                            TABLE_HEADER, "pcr",
@@ -2272,7 +2272,7 @@ static int show_pcr_table(EventLog *el, sd_json_variant **ret_variant) {
         if (!table)
                 return log_oom();
 
-        (void) table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
+        table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
 
         r = table_add_many(table,
                            TABLE_HEADER, "pcr",
index 236904c728c09ae2493c8e374c45fece3778d4a5..c0039957dc2343161d70b80fad7e41c3d3394d2a 100644 (file)
@@ -123,7 +123,7 @@ Operation *operation_free(Operation *o) {
         safe_close(o->extra_fd);
 
         if (o->pid > 1)
-                (void) sigkill_wait(o->pid);
+                sigkill_wait(o->pid);
 
         sd_bus_message_unref(o->message);
 
index b4591365fdc8478013fc33131df1a3a5e39f06b7..e10605538a124bca378a7a373562892c084ab206 100644 (file)
@@ -427,7 +427,7 @@ static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *use
                                 }
 
                                 ss = dns_stream_read(s,
-                                          (uint8_t*) DNS_PACKET_DATA(s->read_packet) + s->n_read - sizeof(s->read_size),
+                                          DNS_PACKET_DATA(s->read_packet) + s->n_read - sizeof(s->read_size),
                                           sizeof(s->read_size) + be16toh(s->read_size) - s->n_read);
                                 if (ss < 0) {
                                         if (!ERRNO_IS_TRANSIENT(ss))
index 29c74791080a298e521a7f5eb2643837c8ba4766..98ac3dec7656ff99a70f29128a2b220883b436d2 100644 (file)
@@ -57,7 +57,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(DnssdTxtData*, dnssd_txtdata_free);
 int dnssd_render_instance_name(Manager *m, DnssdRegisteredService *s, char **ret);
 int dnssd_load(Manager *manager);
 int dnssd_txt_item_new_from_string(const char *key, const char *value, DnsTxtItem **ret_item);
-int dnssd_txt_item_new_from_data(const char *key, const void *value, const size_t size, DnsTxtItem **ret_item);
+int dnssd_txt_item_new_from_data(const char *key, const void *data, size_t size, DnsTxtItem **ret_item);
 int dnssd_update_rrs(DnssdRegisteredService *s);
 int dnssd_signal_conflict(Manager *manager, const char *name);
 
index 6ba03914908019d19f4f297bccf64a4fdf659f96..67bc8a9673452e25037fdff156bc2b4627214b0c 100644 (file)
@@ -385,7 +385,7 @@ static int on_dns_packet(sd_event_source *s, int fd, uint32_t revents, void *use
         name = dns_question_first_name(packet->question);
         log_info("Processing question for name '%s'", name);
 
-        (void) dns_question_dump(packet->question, stdout);
+        dns_question_dump(packet->question, stdout);
 
         r = make_reply_packet(packet, &reply);
         if (r < 0) {
index 088c30edcd292168b65aca026accb49c395f328a..f6bde7c0796b9515aba26edfeebb1367140f1b20 100644 (file)
@@ -753,7 +753,7 @@ static int parse_argv(int argc, char *argv[]) {
         with_trigger = !!arg_path_property || !!arg_socket_property || arg_with_timer;
 
         /* currently, only single trigger (path, socket, timer) unit can be created simultaneously */
-        if ((int) !!arg_path_property + (int) !!arg_socket_property + (int) arg_with_timer > 1)
+        if (!!arg_path_property + !!arg_socket_property + (int) arg_with_timer > 1)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                        "Only single trigger (path, socket, timer) unit can be created.");
 
index f1bb79f08f128b472e31caa8aec92b581db4930f..6b374c075f03bfea4a69855fc451171ceb5eeb47 100644 (file)
@@ -123,7 +123,7 @@ int boot_config_load_type1(
                 BootConfig *config,
                 FILE *f,
                 const char *root,
-                const BootEntrySource source,
+                BootEntrySource source,
                 const char *dir,
                 const char *id);
 
index 4dba0983ab97093242eb3a7691cc4e822bc00651..04178e5df2b5ca24c1b0d4055de736579e0dc5e4 100644 (file)
@@ -452,7 +452,7 @@ static int dns_packet_extend(DnsPacket *p, size_t add, void **ret, size_t *start
                 *start = p->size;
 
         if (ret)
-                *ret = (uint8_t*) DNS_PACKET_DATA(p) + p->size;
+                *ret = DNS_PACKET_DATA(p) + p->size;
 
         p->size += add;
         return 0;
@@ -1392,7 +1392,7 @@ int dns_packet_read(DnsPacket *p, size_t sz, const void **ret, size_t *start) {
                 return -EMSGSIZE;
 
         if (ret)
-                *ret = (uint8_t*) DNS_PACKET_DATA(p) + p->rindex;
+                *ret = DNS_PACKET_DATA(p) + p->rindex;
 
         if (start)
                 *start = p->rindex;
index 33f2ca3c54b6019a8e49df5eb51ac55cd537d222..58ff04d970a20fc9b948b1d43ca6b247fae85f2e 100644 (file)
@@ -182,8 +182,8 @@ int dns_packet_append_string(DnsPacket *p, const char *s, size_t *start);
 int dns_packet_append_raw_string(DnsPacket *p, const void *s, size_t size, size_t *start);
 int dns_packet_append_label(DnsPacket *p, const char *s, size_t l, bool canonical_candidate, size_t *start);
 int dns_packet_append_name(DnsPacket *p, const char *name, bool allow_compression, bool canonical_candidate, size_t *start);
-int dns_packet_append_key(DnsPacket *p, const DnsResourceKey *key, const DnsAnswerFlags flags, size_t *start);
-int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, const DnsAnswerFlags flags, size_t *start, size_t *rdata_start);
+int dns_packet_append_key(DnsPacket *p, const DnsResourceKey *key, DnsAnswerFlags flags, size_t *start);
+int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, DnsAnswerFlags flags, size_t *start, size_t *rdata_start);
 int dns_packet_append_opt(DnsPacket *p, uint16_t max_udp_size, bool edns0_do, bool include_rfc6975, const char *nsid, int rcode, size_t *ret_start);
 int dns_packet_append_question(DnsPacket *p, DnsQuestion *q);
 int dns_packet_append_answer(DnsPacket *p, DnsAnswer *a, unsigned *completed);
index a9f66927f90f0128fa8bfc204dc801d5b8f911a6..fa9aedb5c3d2cb3cf7238c1d32d969d573806206 100644 (file)
@@ -878,7 +878,7 @@ static char *format_svc_param_value(DnsSvcParam *i) {
                 size_t offset = 0;
                 _cleanup_strv_free_ char **values_strv = NULL;
                 while (offset < i->length) {
-                        size_t sz = (uint8_t) i->value[offset++];
+                        size_t sz = i->value[offset++];
 
                         char *alpn = cescape_length((char *)&i->value[offset], sz);
                         if (!alpn)
index 193b97c46753db5729155e209c45fa930e86f8d4..3710717e547ad4b15307dc189d2c1a9696465432 100644 (file)
@@ -523,22 +523,23 @@ int fexecve_or_execve(int executable_fd, const char *executable, char *const arg
 
         execveat(executable_fd, "", argv, envp, AT_EMPTY_PATH);
 
-        if (IN_SET(errno, ENOSYS, ENOENT) || ERRNO_IS_PRIVILEGE(errno))
-                /* Old kernel or a script or an overzealous seccomp filter? Let's fall back to execve().
-                 *
-                 * fexecve(3): "If fd refers to a script (i.e., it is an executable text file that names a
-                 * script interpreter with a first line that begins with the characters #!) and the
-                 * close-on-exec flag has been set for fd, then fexecve() fails with the error ENOENT. This
-                 * error occurs because, by the time the script interpreter is executed, fd has already been
-                 * closed because of the close-on-exec flag. Thus, the close-on-exec flag can't be set on fd
-                 * if it refers to a script."
-                 *
-                 * Unfortunately, if we unset close-on-exec, the script will be executed just fine, but (at
-                 * least in case of bash) the script name, $0, will be shown as /dev/fd/nnn, which breaks
-                 * scripts which make use of $0. Thus, let's fall back to execve() in this case.
-                 */
+        /* Old kernel or a script or an overzealous seccomp filter? Let's fall back to execve().
+         *
+         * fexecve(3): "If fd refers to a script (i.e., it is an executable text file that names a
+         * script interpreter with a first line that begins with the characters #!) and the
+         * close-on-exec flag has been set for fd, then fexecve() fails with the error ENOENT. This
+         * error occurs because, by the time the script interpreter is executed, fd has already been
+         * closed because of the close-on-exec flag. Thus, the close-on-exec flag can't be set on fd
+         * if it refers to a script."
+         *
+         * Unfortunately, if we unset close-on-exec, the script will be executed just fine, but (at
+         * least in case of bash) the script name, $0, will be shown as /dev/fd/nnn, which breaks
+         * scripts which make use of $0. Thus, let's fall back to execve() in this case.
+         */
+        if (!IN_SET(errno, ENOSYS, ENOENT) && !ERRNO_IS_PRIVILEGE(errno))
+                return -errno;
 #endif
-                execve(executable, argv, envp);
+        execve(executable, argv, envp);
         return -errno;
 }
 
index 9103ca9af61913c525a82b889406aca86594032c..95ebca25bc9ed402b838e6494e2058465b1c49a2 100644 (file)
@@ -128,7 +128,7 @@ static int parse_field(
         if (length < field_len)
                 return 0;
 
-        if (memcmp(data, field, field_len))
+        if (memcmp(data, field, field_len) != 0)
                 return 0;
 
         nl = length - field_len;
@@ -770,7 +770,7 @@ static int get_display_realtime(sd_journal *j, usec_t *ret) {
         if (r < 0)
                 return r;
 
-        (void) parse_display_realtime(j, realtime, monotonic, ret);
+        parse_display_realtime(j, realtime, monotonic, ret);
 
         /* Restart all data before */
         sd_journal_restart_data(j);
index 70adf36db291181051953bee8f9a35d3b2f7a89f..3500288189073522a0284b7b55d7bca5f6b683ba 100644 (file)
@@ -179,7 +179,7 @@ static int process_partition(
                  * just to make a point. */
                 partition = sd_device_unref(partition);
 
-                r = block_device_remove_partition(fd, subnode, (int) nr);
+                r = block_device_remove_partition(fd, subnode, nr);
                 if (r < 0)
                         return log_device_debug_errno(d, r, "Failed to remove kernel partition device '%s' in order to recreate it: %m", subnode);
 
index cdf986f4b04e667421867882d41dec42de8f837c..789295b68965b3d5e11070db94617e4e06b79e3c 100644 (file)
@@ -865,7 +865,7 @@ Tpm2Handle *tpm2_handle_free(Tpm2Handle *handle) {
         if (!handle)
                 return NULL;
 
-        _cleanup_(tpm2_context_unrefp) Tpm2Context *context = (Tpm2Context*)handle->tpm2_context;
+        _cleanup_(tpm2_context_unrefp) Tpm2Context *context = handle->tpm2_context;
         if (context)
                 tpm2_handle_cleanup(context->esys_context, handle->esys_handle, handle->flush);
 
@@ -6328,7 +6328,7 @@ int tpm2_list_devices(bool legend, bool quiet) {
         if (!t)
                 return log_oom();
 
-        (void) table_set_header(t, legend);
+        table_set_header(t, legend);
 
         d = opendir("/sys/class/tpmrm");
         if (!d) {
index 5c720de21ccef44b477650e9d506e2ac8fa2d144..127327bbaeefcc67bab23fbfb704033fd1bd71a4 100644 (file)
@@ -318,7 +318,7 @@ static int json_dispatch_rlimit_value(const char *name, sd_json_variant *variant
                 uint64_t w;
 
                 w = sd_json_variant_unsigned(variant);
-                if (w == RLIM_INFINITY || (uint64_t) w != sd_json_variant_unsigned(variant))
+                if (w == RLIM_INFINITY || w != sd_json_variant_unsigned(variant))
                         return json_log(variant, flags, SYNTHETIC_ERRNO(ERANGE), "Resource limit value '%s' is out of range.", name);
 
                 *ret = (rlim_t) w;
index ea7a5cf69db42fb85de21f120e0755bb447880d3..59ab497b9ffde6fdbf1c1347f743d037e843a804 100644 (file)
@@ -44,7 +44,7 @@ typedef _sd_destroy_t sd_netlink_destroy_t;
 /* bus */
 int sd_netlink_open(sd_netlink **ret);
 int sd_netlink_open_fd(sd_netlink **ret, int fd);
-int sd_netlink_increase_rxbuf(sd_netlink *nl, const size_t size);
+int sd_netlink_increase_rxbuf(sd_netlink *nl, size_t size);
 
 sd_netlink* sd_netlink_ref(sd_netlink *nl);
 sd_netlink* sd_netlink_unref(sd_netlink *nl);
index e4820fa3d12a0abc91ad420c761323c60af20cb6..0e32901c1784f2fc1fc650328570155aa7f36c32 100644 (file)
@@ -589,7 +589,7 @@ static int context_show_version(Context *c, const char *version) {
                 return log_error_errno(SYNTHETIC_ERRNO(ENOENT), "Update '%s' not found.", version);
 
         if (arg_json_format_flags & (SD_JSON_FORMAT_OFF|SD_JSON_FORMAT_PRETTY|SD_JSON_FORMAT_PRETTY_AUTO))
-                (void) pager_open(arg_pager_flags);
+                pager_open(arg_pager_flags);
 
         if (!sd_json_format_enabled(arg_json_format_flags))
                 printf("%s%s%s Version: %s\n"
index d22a7d88a827091b081b4b6b4cdab6b34987b307..dec7123c1e67b011c4cae6ec40ef3ce6ee2f9295 100644 (file)
@@ -815,7 +815,7 @@ static int sysupdate_run_simple(sd_json_variant **ret, Target *t, ...) {
                 if (DEBUG_LOGGING) {
                         _cleanup_free_ char *s = NULL;
 
-                        s = quote_command_line((char**) args, SHELL_ESCAPE_EMPTY);
+                        s = quote_command_line(args, SHELL_ESCAPE_EMPTY);
                         if (!s) {
                                 log_oom();
                                 _exit(EXIT_FAILURE);
index a3e0c88e40ad90b60fb903f8add22cef2cba052a..64a0de3fe94b309abd453560035fb660155e17f9 100644 (file)
@@ -734,10 +734,10 @@ TEST(tokenizer) {
         test_tokenizer_one("18446744073709551616", JSON_TOKEN_REAL, (double) 18446744073709551616.0L, JSON_TOKEN_END);
         test_tokenizer_one("-9223372036854775809", JSON_TOKEN_REAL, (double) -9223372036854775809.0L, JSON_TOKEN_END);
         test_tokenizer_one("-1234", JSON_TOKEN_INTEGER, (int64_t) -1234, JSON_TOKEN_END);
-        test_tokenizer_one("3.141", JSON_TOKEN_REAL, (double) 3.141, JSON_TOKEN_END);
-        test_tokenizer_one("0.0", JSON_TOKEN_REAL, (double) 0.0, JSON_TOKEN_END);
-        test_tokenizer_one("7e3", JSON_TOKEN_REAL, (double) 7e3, JSON_TOKEN_END);
-        test_tokenizer_one("-7e-3", JSON_TOKEN_REAL, (double) -7e-3, JSON_TOKEN_END);
+        test_tokenizer_one("3.141", JSON_TOKEN_REAL, 3.141, JSON_TOKEN_END);
+        test_tokenizer_one("0.0", JSON_TOKEN_REAL, 0.0, JSON_TOKEN_END);
+        test_tokenizer_one("7e3", JSON_TOKEN_REAL, 7e3, JSON_TOKEN_END);
+        test_tokenizer_one("-7e-3", JSON_TOKEN_REAL, -7e-3, JSON_TOKEN_END);
         test_tokenizer_one("true", JSON_TOKEN_BOOLEAN, true, JSON_TOKEN_END);
         test_tokenizer_one("false", JSON_TOKEN_BOOLEAN, false, JSON_TOKEN_END);
         test_tokenizer_one("null", JSON_TOKEN_NULL, JSON_TOKEN_END);
index fe4b020cf38528ee60846b14f14ff6331736ee06..d4c254e50ad8a17fd9f0f32ff4182a3e77811bdc 100644 (file)
@@ -42,7 +42,7 @@ TEST(rsa_pkey_n_e) {
         _cleanup_(EVP_PKEY_freep) EVP_PKEY *pkey = NULL;
         assert_se(rsa_pkey_from_n_e(n, n_len, &e, sizeof(e), &pkey) >= 0);
 
-        _cleanup_(EVP_PKEY_CTX_freep) EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new((EVP_PKEY*) pkey, NULL);
+        _cleanup_(EVP_PKEY_CTX_freep) EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(pkey, NULL);
         assert_se(ctx);
         assert_se(EVP_PKEY_verify_init(ctx) == 1);
 
@@ -69,7 +69,7 @@ TEST(ecc_pkey_curve_x_y) {
         _cleanup_(EVP_PKEY_freep) EVP_PKEY *pkey = NULL;
         assert_se(ecc_pkey_from_curve_x_y(curveid, x, x_len, y, y_len, &pkey) >= 0);
 
-        _cleanup_(EVP_PKEY_CTX_freep) EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new((EVP_PKEY*) pkey, NULL);
+        _cleanup_(EVP_PKEY_CTX_freep) EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(pkey, NULL);
         assert_se(ctx);
         assert_se(EVP_PKEY_verify_init(ctx) == 1);
 
index 95b4717b41f0dbe02c7755e9a3179693c8dd93a5..3c384575f81c7027b14e685bccc896706fbf861b 100644 (file)
@@ -37,7 +37,7 @@ int main(int argc, char *argv[]) {
 
         assert_se((fd = mkostemp(template, O_RDWR|O_CREAT|O_EXCL)) >= 0);
         assert_se(unlink(template) >= 0);
-        assert_se(posix_fallocate_loop(fd, 0, page_size() * 8) >= 0);
+        assert_se(posix_fallocate_loop(fd, 0, page_size() * 8) >= 0); /* NOLINT (posix-return) */
 
         p = mmap(NULL, page_size() * 16, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
         assert_se(p != MAP_FAILED);
index 4fd7afd4e2b23a4e7db99a7812604dfc5acd33d0..94a92fd2c6e9692aaeb77c05219fc0b20052e468 100644 (file)
@@ -782,7 +782,7 @@ TEST(tpm2b_public_to_openssl_pkey) {
         _cleanup_(EVP_PKEY_freep) EVP_PKEY *pkey_rsa = NULL;
         assert_se(tpm2_tpm2b_public_to_openssl_pkey(&public, &pkey_rsa) >= 0);
 
-        _cleanup_(EVP_PKEY_CTX_freep) EVP_PKEY_CTX *ctx_rsa = EVP_PKEY_CTX_new((EVP_PKEY*) pkey_rsa, NULL);
+        _cleanup_(EVP_PKEY_CTX_freep) EVP_PKEY_CTX *ctx_rsa = EVP_PKEY_CTX_new(pkey_rsa, NULL);
         assert_se(ctx_rsa);
         assert_se(EVP_PKEY_verify_init(ctx_rsa) == 1);
         assert_se(EVP_PKEY_CTX_set_signature_md(ctx_rsa, EVP_sha256()) > 0);
@@ -795,7 +795,7 @@ TEST(tpm2b_public_to_openssl_pkey) {
         _cleanup_(EVP_PKEY_freep) EVP_PKEY *pkey_ecc = NULL;
         assert_se(tpm2_tpm2b_public_to_openssl_pkey(&public, &pkey_ecc) >= 0);
 
-        _cleanup_(EVP_PKEY_CTX_freep) EVP_PKEY_CTX *ctx_ecc = EVP_PKEY_CTX_new((EVP_PKEY*) pkey_ecc, NULL);
+        _cleanup_(EVP_PKEY_CTX_freep) EVP_PKEY_CTX *ctx_ecc = EVP_PKEY_CTX_new(pkey_ecc, NULL);
         assert_se(ctx_ecc);
         assert_se(EVP_PKEY_verify_init(ctx_ecc) == 1);
 
index 6bfe4e075faffc9a01bc636d4ad89056ae323274..dcd0e9131f7ebd4a9b5de40f917dce2a4e21a81f 100644 (file)
@@ -337,7 +337,9 @@ static bool manager_sample_spike_detection(Manager *m, double offset, double del
         j = 0;
         FOREACH_ELEMENT(sample, m->samples)
                 j += pow(sample->offset - m->samples[idx_min].offset, 2);
-        m->samples_jitter = sqrt(j / (ELEMENTSOF(m->samples) - 1));
+
+        size_t n = ELEMENTSOF(m->samples);
+        m->samples_jitter = sqrt(j / (n - 1));
 
         /* ignore samples when resyncing */
         if (m->poll_resync)