tree-wide: Small fixes for various clang-tidy warnings
This commit is contained in:
committed by
Yu Watanabe
parent
2ba910ab06
commit
9a6a8f35eb
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user