1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

tree-wide: move unsigned to the start of type declaration

Even though ISO C11 doesn't mandate in which order the type specifiers
should appear, having `unsigned` at the beginning of each type
declaration feels more natural and, more importantly, it unbreaks
Coccinelle, which has a hard time parsing `long unsigned` and others:

```
init_defs_builtins: /usr/lib64/coccinelle/standard.h
init_defs: /home/mrc0mmand/repos/systemd/coccinelle/macros.h
HANDLING: src/shared/mount-util.c
: 1: strange type1, maybe because of weird order: long unsigned
```

Most of the codebase already "complies", so let's fix the remaining
"offenders".
This commit is contained in:
Frantisek Sumsal 2022-02-10 17:19:27 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent 4ba5594390
commit da185cd04d
8 changed files with 16 additions and 16 deletions

View File

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

View File

@ -65,9 +65,9 @@ static inline int safe_atoi32(const char *s, int32_t *ret_i) {
return safe_atoi(s, (int*) ret_i); return safe_atoi(s, (int*) ret_i);
} }
int safe_atollu_full(const char *s, unsigned base, long long unsigned *ret_llu); int safe_atollu_full(const char *s, unsigned base, unsigned long long *ret_llu);
static inline int safe_atollu(const char *s, long long unsigned *ret_llu) { static inline int safe_atollu(const char *s, unsigned long long *ret_llu) {
return safe_atollu_full(s, 0, ret_llu); return safe_atollu_full(s, 0, ret_llu);
} }
@ -82,12 +82,12 @@ static inline int safe_atoi64(const char *s, int64_t *ret_i) {
} }
static inline int safe_atoux64(const char *s, uint64_t *ret) { static inline int safe_atoux64(const char *s, uint64_t *ret) {
assert_cc(sizeof(int64_t) == sizeof(long long unsigned)); assert_cc(sizeof(int64_t) == sizeof(unsigned long long));
return safe_atollu_full(s, 16, (long long unsigned*) ret); return safe_atollu_full(s, 16, (unsigned long long*) ret);
} }
#if LONG_MAX == INT_MAX #if LONG_MAX == INT_MAX
static inline int safe_atolu_full(const char *s, unsigned base, long unsigned *ret_u) { static inline int safe_atolu_full(const char *s, unsigned base, unsigned long *ret_u) {
assert_cc(sizeof(unsigned long) == sizeof(unsigned)); assert_cc(sizeof(unsigned long) == sizeof(unsigned));
return safe_atou_full(s, base, (unsigned*) ret_u); return safe_atou_full(s, base, (unsigned*) ret_u);
} }
@ -117,7 +117,7 @@ static inline int safe_atozu(const char *s, size_t *ret_u) {
} }
#else #else
static inline int safe_atozu(const char *s, size_t *ret_u) { static inline int safe_atozu(const char *s, size_t *ret_u) {
assert_cc(sizeof(size_t) == sizeof(long unsigned)); assert_cc(sizeof(size_t) == sizeof(unsigned long));
return safe_atolu(s, ret_u); return safe_atolu(s, ret_u);
} }
#endif #endif

View File

@ -645,7 +645,7 @@ int get_process_environ(pid_t pid, char **ret) {
int get_process_ppid(pid_t pid, pid_t *ret) { int get_process_ppid(pid_t pid, pid_t *ret) {
_cleanup_free_ char *line = NULL; _cleanup_free_ char *line = NULL;
long unsigned ppid; unsigned long ppid;
const char *p; const char *p;
int r; int r;
@ -688,7 +688,7 @@ int get_process_ppid(pid_t pid, pid_t *ret) {
if (ppid == 0) if (ppid == 0)
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
if ((pid_t) ppid < 0 || (long unsigned) (pid_t) ppid != ppid) if ((pid_t) ppid < 0 || (unsigned long) (pid_t) ppid != ppid)
return -ERANGE; return -ERANGE;
if (ret) if (ret)

View File

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

View File

@ -592,9 +592,9 @@ int mode_to_inaccessible_node(
return 0; return 0;
} }
int mount_flags_to_string(long unsigned flags, char **ret) { int mount_flags_to_string(unsigned long flags, char **ret) {
static const struct { static const struct {
long unsigned flag; unsigned long flag;
const char *name; const char *name;
} map[] = { } map[] = {
{ .flag = MS_RDONLY, .name = "MS_RDONLY", }, { .flag = MS_RDONLY, .name = "MS_RDONLY", },

View File

@ -94,7 +94,7 @@ int mount_option_mangle(
char **ret_remaining_options); char **ret_remaining_options);
int mode_to_inaccessible_node(const char *runtime_dir, mode_t mode, char **dest); int mode_to_inaccessible_node(const char *runtime_dir, mode_t mode, char **dest);
int mount_flags_to_string(long unsigned flags, char **ret); int mount_flags_to_string(unsigned long flags, char **ret);
/* Useful for usage with _cleanup_(), unmounts, removes a directory and frees the pointer */ /* Useful for usage with _cleanup_(), unmounts, removes a directory and frees the pointer */
static inline char* umount_and_rmdir_and_free(char *p) { static inline char* umount_and_rmdir_and_free(char *p) {

View File

@ -18,7 +18,7 @@
#include "tmpfile-util.h" #include "tmpfile-util.h"
static void test_mount_propagation_flags_one(const char *name, int ret, unsigned long expected) { static void test_mount_propagation_flags_one(const char *name, int ret, unsigned long expected) {
long unsigned flags; unsigned long flags;
log_info("/* %s(%s) */", __func__, name); log_info("/* %s(%s) */", __func__, name);

View File

@ -53,8 +53,8 @@ int main(void) {
info(unsigned char); info(unsigned char);
info(short unsigned); info(short unsigned);
info(unsigned); info(unsigned);
info(long unsigned); info(unsigned long);
info(long long unsigned); info(unsigned long long);
info(__syscall_ulong_t); info(__syscall_ulong_t);
info(__syscall_slong_t); info(__syscall_slong_t);
info(intmax_t); info(intmax_t);