Two trivial cleanups (#36980)

This commit is contained in:
Yu Watanabe
2025-04-03 08:56:46 +09:00
committed by GitHub
18 changed files with 40 additions and 43 deletions

View File

@@ -72,13 +72,13 @@ int memfd_new_full(const char *name, unsigned extra_flags) {
MFD_CLOEXEC | MFD_NOEXEC_SEAL | extra_flags);
}
int memfd_add_seals(int fd, unsigned seals) {
static int memfd_add_seals(int fd, unsigned seals) {
assert(fd >= 0);
return RET_NERRNO(fcntl(fd, F_ADD_SEALS, seals));
}
int memfd_get_seals(int fd, unsigned *ret_seals) {
static int memfd_get_seals(int fd, unsigned *ret_seals) {
int r;
assert(fd >= 0);
@@ -97,7 +97,7 @@ int memfd_set_sealed(int fd) {
}
int memfd_get_sealed(int fd) {
unsigned int seals;
unsigned seals;
int r;
r = memfd_get_seals(fd, &seals);

View File

@@ -20,9 +20,6 @@ static inline int memfd_new_and_seal_string(const char *name, const char *s) {
return memfd_new_and_seal(name, s, SIZE_MAX);
}
int memfd_add_seals(int fd, unsigned seals);
int memfd_get_seals(int fd, unsigned *ret_seals);
int memfd_set_sealed(int fd);
int memfd_get_sealed(int fd);

View File

@@ -201,10 +201,10 @@ enum nss_status _nss_##module##_getsgent_r( \
enum nss_status _nss_##module##_initgroups_dyn( \
const char *user, \
gid_t group, \
long int *start, \
long int *size, \
long *start, \
long *size, \
gid_t **groupsp, \
long int limit, \
long limit, \
int *errnop) _public_;
typedef enum nss_status (*_nss_gethostbyname4_r_t)(

View File

@@ -528,7 +528,7 @@ int safe_atollu_full(const char *s, unsigned base, unsigned long long *ret_llu)
return 0;
}
int safe_atolli(const char *s, long long int *ret_lli) {
int safe_atolli(const char *s, long long *ret_lli) {
unsigned base = 0;
char *x = NULL;
long long l;

View File

@@ -41,7 +41,7 @@ static inline int safe_atou(const char *s, unsigned *ret_u) {
int safe_atou_bounded(const char *s, unsigned min, unsigned max, unsigned *ret);
int safe_atoi(const char *s, int *ret_i);
int safe_atolli(const char *s, long long int *ret_i);
int safe_atolli(const char *s, long long *ret_i);
int safe_atou8_full(const char *s, unsigned base, uint8_t *ret);
@@ -87,8 +87,8 @@ static inline int safe_atou64(const char *s, uint64_t *ret_u) {
}
static inline int safe_atoi64(const char *s, int64_t *ret_i) {
assert_cc(sizeof(int64_t) == sizeof(long long int));
return safe_atolli(s, (long long int*) ret_i);
assert_cc(sizeof(int64_t) == sizeof(long long));
return safe_atolli(s, (long long*) ret_i);
}
static inline int safe_atoux64(const char *s, uint64_t *ret) {
@@ -101,8 +101,8 @@ static inline int safe_atolu_full(const char *s, unsigned base, unsigned long *r
assert_cc(sizeof(unsigned long) == sizeof(unsigned));
return safe_atou_full(s, base, (unsigned*) ret_u);
}
static inline int safe_atoli(const char *s, long int *ret_u) {
assert_cc(sizeof(long int) == sizeof(int));
static inline int safe_atoli(const char *s, long *ret_u) {
assert_cc(sizeof(long) == sizeof(int));
return safe_atoi(s, (int*) ret_u);
}
#else
@@ -110,9 +110,9 @@ static inline int safe_atolu_full(const char *s, unsigned base, unsigned long *r
assert_cc(sizeof(unsigned long) == sizeof(unsigned long long));
return safe_atollu_full(s, base, (unsigned long long*) ret_u);
}
static inline int safe_atoli(const char *s, long int *ret_u) {
assert_cc(sizeof(long int) == sizeof(long long int));
return safe_atolli(s, (long long int*) ret_u);
static inline int safe_atoli(const char *s, long *ret_u) {
assert_cc(sizeof(long) == sizeof(long long));
return safe_atolli(s, (long long*) ret_u);
}
#endif

View File

@@ -16,7 +16,7 @@
#include <stdint.h>
struct super_block {
unsigned long int s_magic;
unsigned long s_magic;
} __attribute__((preserve_access_index));
struct inode {

View File

@@ -3493,7 +3493,7 @@ static int exec_context_deserialize(ExecContext *c, FILE *f) {
if (r < 0)
return r;
} else if ((val = startswith(l, "exec-context-syscall-archs="))) {
unsigned int id;
unsigned id;
r = safe_atou(val, &id);
if (r < 0)

View File

@@ -141,7 +141,7 @@ int BPF_PROG(userns_restrict_path_mkdir, struct path *dir, struct dentry *dentry
}
SEC("lsm/path_mknod")
int BPF_PROG(userns_restrict_path_mknod, const struct path *dir, struct dentry *dentry, umode_t mode, unsigned int dev, int ret) {
int BPF_PROG(userns_restrict_path_mknod, const struct path *dir, struct dentry *dentry, umode_t mode, unsigned dev, int ret) {
return validate_path(dir, ret);
}

View File

@@ -521,15 +521,15 @@ static int ringbuf_event(void *userdata, void *data, size_t size) {
Manager *m = ASSERT_PTR(userdata);
size_t n;
if ((size % sizeof(unsigned int)) != 0) /* Not multiples of "unsigned int"? */
if ((size % sizeof(unsigned)) != 0) /* Not multiples of "unsigned"? */
return -EIO;
n = size / sizeof(unsigned int);
n = size / sizeof(unsigned);
for (size_t i = 0; i < n; i++) {
const void *d;
uint64_t inode;
d = (const uint8_t*) data + i * sizeof(unsigned int);
d = (const uint8_t*) data + i * sizeof(unsigned);
inode = unaligned_read_ne32(d);
log_debug("Got BPF ring buffer notification that user namespace %" PRIu64 " is now dead.", inode);

View File

@@ -101,7 +101,7 @@ int userns_restrict_install(
if (r < 0)
return log_error_errno(r, "Failed to size userns/mnt_id hash table: %m");
r = sym_bpf_map__set_max_entries(obj->maps.userns_ringbuf, USERNS_MAX * sizeof(unsigned int));
r = sym_bpf_map__set_max_entries(obj->maps.userns_ringbuf, USERNS_MAX * sizeof(unsigned));
if (r < 0)
return log_error_errno(r, "Failed to size userns ring buffer: %m");

View File

@@ -965,7 +965,7 @@ enum nss_status _nss_systemd_initgroups_dyn(
long *start,
long *size,
gid_t **groupsp,
long int limit,
long limit,
int *errnop) {
_cleanup_(userdb_iterator_freep) UserDBIterator *iterator = NULL;

View File

@@ -156,14 +156,14 @@ int nss_pack_user_record_shadow(
.sp_namp = buffer,
.sp_lstchg = hr->last_password_change_usec == 0 ? 1 : /* map 0 to 1, since 0 means please change password on next login */
hr->last_password_change_usec == UINT64_MAX ? -1 :
(long int) (hr->last_password_change_usec / USEC_PER_DAY),
.sp_min = hr->password_change_min_usec != UINT64_MAX ? (long int) (hr->password_change_min_usec / USEC_PER_DAY) : -1,
.sp_max = hr->password_change_max_usec != UINT64_MAX ? (long int) (hr->password_change_max_usec / USEC_PER_DAY) : -1,
.sp_warn = hr->password_change_warn_usec != UINT64_MAX ? (long int) (hr->password_change_warn_usec / USEC_PER_DAY) : -1,
.sp_inact = hr->password_change_inactive_usec != UINT64_MAX ? (long int) (hr->password_change_inactive_usec / USEC_PER_DAY) : -1,
(long) (hr->last_password_change_usec / USEC_PER_DAY),
.sp_min = hr->password_change_min_usec != UINT64_MAX ? (long) (hr->password_change_min_usec / USEC_PER_DAY) : -1,
.sp_max = hr->password_change_max_usec != UINT64_MAX ? (long) (hr->password_change_max_usec / USEC_PER_DAY) : -1,
.sp_warn = hr->password_change_warn_usec != UINT64_MAX ? (long) (hr->password_change_warn_usec / USEC_PER_DAY) : -1,
.sp_inact = hr->password_change_inactive_usec != UINT64_MAX ? (long) (hr->password_change_inactive_usec / USEC_PER_DAY) : -1,
.sp_expire = hr->locked > 0 || hr->not_after_usec == 0 ? 1 : /* already expired/locked */
hr->not_after_usec == UINT64_MAX ? -1 :
(long int) (hr->not_after_usec / USEC_PER_DAY),
(long) (hr->not_after_usec / USEC_PER_DAY),
.sp_flag = ULONG_MAX,
};

View File

@@ -857,10 +857,10 @@ void fw_nftables_exit(FirewallContext *ctx) {
static int nft_message_append_setelem_iprange(
sd_netlink_message *m,
const union in_addr_union *source,
unsigned int prefixlen) {
unsigned prefixlen) {
uint32_t mask, start, end;
unsigned int nplen;
unsigned nplen;
int r;
assert(m);
@@ -896,7 +896,7 @@ static int nft_message_append_setelem_iprange(
static int nft_message_append_setelem_ip6range(
sd_netlink_message *m,
const union in_addr_union *source,
unsigned int prefixlen) {
unsigned prefixlen) {
union in_addr_union start, end;
int r;
@@ -931,7 +931,7 @@ int nft_set_element_modify_iprange(
const char *table,
const char *set,
const union in_addr_union *source,
unsigned int source_prefixlen) {
unsigned source_prefixlen) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
int r;
@@ -1041,7 +1041,7 @@ int fw_nftables_add_masquerade(
bool add,
int af,
const union in_addr_union *source,
unsigned int source_prefixlen) {
unsigned source_prefixlen) {
int r;

View File

@@ -74,7 +74,7 @@ int nft_set_element_modify_iprange(
const char *table,
const char *set,
const union in_addr_union *source,
unsigned int source_prefixlen);
unsigned source_prefixlen);
int nft_set_element_modify_ip(
FirewallContext *ctx,

View File

@@ -164,7 +164,7 @@ int openssl_digest_many(
if (!buf)
return log_oom_debug();
unsigned int size;
unsigned size;
if (!EVP_DigestFinal_ex(ctx, buf, &size))
return log_openssl_errors("Failed to finalize Digest");
@@ -260,7 +260,7 @@ int openssl_hmac_many(
size_t size;
if (!EVP_MAC_final(ctx, buf, &size, digest_size))
#else
unsigned int size;
unsigned size;
if (!HMAC_Final(ctx, buf, &size))
#endif
return log_openssl_errors("Failed to finalize HMAC");

View File

@@ -82,7 +82,7 @@ static void print_border(FILE *output, unsigned width, unsigned row, unsigned co
}
}
static void write_qrcode(FILE *output, QRcode *qr, unsigned int row, unsigned int column) {
static void write_qrcode(FILE *output, QRcode *qr, unsigned row, unsigned column) {
assert(qr);
if (!output)

View File

@@ -66,7 +66,7 @@ static void test_log_struct(void) {
log_struct(LOG_INFO,
LOG_MESSAGE("Foobar PID="PID_FMT, getpid_cached()),
LOG_ITEM("FORMAT_STR_TEST=1=%i A=%c 2=%hi 3=%li 4=%lli 1=%p foo=%s 2.5=%g 3.5=%g 4.5=%Lg",
(int) 1, 'A', (short) 2, (long int) 3, (long long int) 4, (void*) 1, "foo", (float) 2.5f, (double) 3.5, (long double) 4.5),
(int) 1, 'A', (short) 2, (long) 3, (long long) 4, (void*) 1, "foo", (float) 2.5f, (double) 3.5, (long double) 4.5),
LOG_ITEM("SUFFIX=GOT IT"));
}

View File

@@ -288,7 +288,7 @@ static bool test_pointers(
* libinput uses similar heuristics, any changes here should be added to libinput too.
*/
if (is_joystick) {
static const unsigned int well_known_keyboard_keys[] = {
static const unsigned well_known_keyboard_keys[] = {
KEY_LEFTCTRL, KEY_CAPSLOCK, KEY_NUMLOCK, KEY_INSERT,
KEY_MUTE, KEY_CALC, KEY_FILE, KEY_MAIL, KEY_PLAYPAUSE,
KEY_BRIGHTNESSDOWN,