]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: move `unsigned` to the start of type declaration
authorFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 10 Feb 2022 16:19:27 +0000 (17:19 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 10 Feb 2022 20:00:22 +0000 (21:00 +0100)
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".

src/basic/parse-util.c
src/basic/parse-util.h
src/basic/process-util.c
src/core/bpf/restrict_fs/restrict-fs.bpf.c
src/shared/mount-util.c
src/shared/mount-util.h
src/test/test-mountpoint-util.c
src/test/test-sizeof.c

index 2888ab6523f59e3395714d18b48de706341f38e4..222b2304cd05d353b346564507293d297b8001e0 100644 (file)
@@ -415,7 +415,7 @@ int safe_atoi(const char *s, int *ret_i) {
         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;
         unsigned long long l;
 
index 3dc5e140c9a0406e9fe03c9e456ff626b60bfd52..8273124626f2082f766687afee444ad5a82a6972 100644 (file)
@@ -65,9 +65,9 @@ static inline int safe_atoi32(const char *s, int32_t *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);
 }
 
@@ -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) {
-        assert_cc(sizeof(int64_t) == sizeof(long long unsigned));
-        return safe_atollu_full(s, 16, (long long unsigned*) ret);
+        assert_cc(sizeof(int64_t) == sizeof(unsigned long long));
+        return safe_atollu_full(s, 16, (unsigned long long*) ret);
 }
 
 #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));
         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
 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);
 }
 #endif
index c9718521584727bc9601cf5c30f3806e2fbb0bfd..0bf7448043cfba712caeb6850e4055a6b5fade20 100644 (file)
@@ -645,7 +645,7 @@ int get_process_environ(pid_t pid, char **ret) {
 
 int get_process_ppid(pid_t pid, pid_t *ret) {
         _cleanup_free_ char *line = NULL;
-        long unsigned ppid;
+        unsigned long ppid;
         const char *p;
         int r;
 
@@ -688,7 +688,7 @@ int get_process_ppid(pid_t pid, pid_t *ret) {
         if (ppid == 0)
                 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;
 
         if (ret)
index cdc0613a019a3abb6816555fc77cf3db672c4af3..99940bedfd8ca484af2063603ebf80fbafb8a88f 100644 (file)
@@ -16,7 +16,7 @@
 #include <stdint.h>
 
 struct super_block {
-        long unsigned int s_magic;
+        unsigned long int s_magic;
 } __attribute__((preserve_access_index));
 
 struct inode {
index c75c02f5be3210e127a7efee5f026c8d9db3da98..6e938fc19db47b7aaa88e1d4e9a17fb3c12f71a0 100644 (file)
@@ -592,9 +592,9 @@ int mode_to_inaccessible_node(
         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 {
-                long unsigned flag;
+                unsigned long flag;
                 const char *name;
         } map[] = {
                 { .flag = MS_RDONLY,      .name = "MS_RDONLY",      },
index ce73aebd4bc4832ad57f9fce1c810de45b738be7..9caf92308a6288adc2c403886bcf45174de78c21 100644 (file)
@@ -94,7 +94,7 @@ int mount_option_mangle(
                 char **ret_remaining_options);
 
 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 */
 static inline char* umount_and_rmdir_and_free(char *p) {
index a373c5f98c35c088b552b8a79b54434ddabbecb4..3c2523006a4e55ef9034b750e3722bb064120285 100644 (file)
@@ -18,7 +18,7 @@
 #include "tmpfile-util.h"
 
 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);
 
index f349852553de011e81028e8b32ca26a94c445d8b..55bd81e22fdb4966e2d7d6a760db78b23e82fba1 100644 (file)
@@ -53,8 +53,8 @@ int main(void) {
         info(unsigned char);
         info(short unsigned);
         info(unsigned);
-        info(long unsigned);
-        info(long long unsigned);
+        info(unsigned long);
+        info(unsigned long long);
         info(__syscall_ulong_t);
         info(__syscall_slong_t);
         info(intmax_t);