tree-wide: Small fixes for various clang-tidy warnings

This commit is contained in:
Daan De Meyer
2025-11-26 16:22:00 +09:00
committed by Yu Watanabe
parent 2ba910ab06
commit 9a6a8f35eb
69 changed files with 139 additions and 132 deletions
+1 -1
View 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);
+1 -1
View 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)
+1 -1
View 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);
+1 -1
View File
@@ -1228,7 +1228,7 @@ int search_and_open(
assert(path);
copy = strv_copy((char**) search);
copy = strv_copy(search);
if (!copy)
return -ENOMEM;
+2 -2
View 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);
+1 -1
View 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;
}
+2 -2
View 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;
}
+1 -1
View 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);
+4 -4
View 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)
+1 -1
View 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);
}
+1 -1
View 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(
+1 -1
View 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. */
+1 -1
View 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) {
+1 -1
View 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;
}
+1 -1
View 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;
}
+1 -1
View 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) {
+1 -3
View 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] = {
+2 -2
View 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);
}
}
+1 -1
View 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);
+1 -1
View 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;
+1 -1
View 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;
+1 -1
View 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)
+1 -1
View 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) */
+5 -5
View 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,
+1 -1
View 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))
+1 -1
View 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?");
+1 -1
View 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);
+1 -1
View 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;
}
+1 -1
View 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)
+1 -1
View 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)
+2 -2
View 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");
+1 -1
View 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;
+5 -5
View 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;
}
+2 -2
View 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;
+3 -3
View 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;
+2 -2
View 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;
+13 -7
View 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;
+6 -6
View 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);
+2 -2
View 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;
}
+1 -1
View 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)
+1 -1
View 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);
+4 -4
View 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);
}
+1 -1
View 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);
+1 -1
View 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) {
+4 -4
View 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.");
}
+1 -1
View 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;
+2 -2
View 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",
+1 -1
View 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);
+1 -1
View 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))
+1 -1
View 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);
+1 -1
View 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) {
+1 -1
View 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.");
+1 -1
View 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);
+2 -2
View 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;
+2 -2
View 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);
+1 -1
View 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)
+16 -15
View 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;
}
+2 -2
View 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);
+1 -1
View 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);
+2 -2
View 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) {
+1 -1
View 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;
+1 -1
View 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);
+1 -1
View 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"
+1 -1
View 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);
+4 -4
View 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);
+2 -2
View 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);
+1 -1
View 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);
+2 -2
View 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);
+3 -1
View 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)