chiark / gitweb /
tree-wide: drop spurious newlines (#8764)
authorLennart Poettering <lennart@poettering.net>
Thu, 19 Apr 2018 10:13:23 +0000 (12:13 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
Double newlines (i.e. one empty lines) are great to structure code. But
let's avoid triple newlines (i.e. two empty lines), quadruple newlines,
quintuple newlines, …, that's just spurious whitespace.

It's an easy way to drop 121 lines of code, and keeps the coding style
of our sources a bit tigther.

22 files changed:
man/sd_get_seats.xml
src/basic/format-table.c
src/basic/hash-funcs.c
src/basic/mount-util.c
src/basic/random-util.c
src/basic/selinux-util.c
src/basic/socket-util.c
src/core/cgroup.c
src/libelogind/sd-bus/bus-creds.c
src/libelogind/sd-bus/bus-match.c
src/libelogind/sd-bus/bus-message.c
src/libelogind/sd-bus/bus-signature.c
src/libelogind/sd-bus/bus-slot.c
src/libelogind/sd-bus/sd-bus.c
src/login/logind-session.c
src/shared/utmp-wtmp.c
src/test/test-exec-util.c
src/test/test-locale-util.c
src/test/test-parse-util.c
src/test/test-stat-util.c
src/test/test-string-util.c
tools/find-double-newline.sh [new file with mode: 0644]

index 58b436be00fb02f3199d260f40937827a82330e7..b06c9c9f51b9ff5191d6dc78e942233dd10942af 100644 (file)
     errno-style error code.</para>
   </refsect1>
 
-
   <refsect1>
     <title>Errors</title>
 
index f1ef562ab71475e2eb5270adab05578931706607..35948a602a1c2ba51648e6559abaf11c979543fe 100644 (file)
@@ -855,7 +855,6 @@ static const char *table_data_format(TableData *d) {
                 assert_not_reached("Unexpected type?");
         }
 
-
         return d->formatted;
 }
 
index b62f2bd877e768f0fc4404ff05594e04c3ccd6af..13e357efd4bdb73fa909165c384f394d9f6bd739 100644 (file)
@@ -24,7 +24,6 @@ const struct hash_ops string_hash_ops = {
         .compare = string_compare_func
 };
 
-
 void path_hash_func(const void *p, struct siphash *state) {
         const char *q = p;
         size_t n;
index b3817c03c1b29a309b178562da47373d2cb6fd60..1736cf19b5f5522751944ccd5e0368809583a222 100644 (file)
@@ -860,7 +860,6 @@ const char *mount_propagation_flags_to_string(unsigned long flags) {
         return NULL;
 }
 
-
 int mount_propagation_flags_from_string(const char *name, unsigned long *ret) {
 
         if (isempty(name))
index 803ca790fddf90af34177272ad9d99f30d63ea2f..fe283050c434468b7902f5d7f629da3be9beb867 100644 (file)
@@ -109,7 +109,6 @@ void initialize_srand(void) {
 #endif
                 x = 0;
 
-
         x ^= (unsigned) now(CLOCK_REALTIME);
         x ^= (unsigned) gettid();
 
index 518a6f5a4d53bd499b781074585efeda4f5f3f7a..c02ee2ca51a5a10b2626f0b43176c106211941f9 100644 (file)
@@ -316,7 +316,6 @@ char* mac_selinux_free(char *label) {
         if (!mac_selinux_use())
                 return NULL;
 
-
         freecon(label);
 #endif
 
index 983a7b423e5d93a7c012f5e891994d51b6aa3f7d..75bfcf98a4448f0116de5311fd2e7547cca153f8 100644 (file)
@@ -687,7 +687,6 @@ int sockaddr_pretty(const struct sockaddr *_sa, socklen_t salen, bool translate_
                 return -EOPNOTSUPP;
         }
 
-
         *ret = p;
         return 0;
 }
@@ -1154,7 +1153,6 @@ int flush_accept(int fd) {
         };
         int r;
 
-
         /* Similar to flush_fd() but flushes all incoming connection by accepting them and immediately closing them. */
 
         for (;;) {
index 9b69fa82e791f2de08fb13c323340b0980c417b0..34ff984df5ad79b2b3c2d8dd05fd065d36ded148 100644 (file)
@@ -1693,7 +1693,6 @@ static void unit_remove_from_cgroup_realize_queue(Unit *u) {
         u->in_cgroup_realize_queue = false;
 }
 
-
 /* Check if necessary controllers and attributes for a unit are in place.
  *
  * If so, do nothing.
index 7db80e72f8fa9f4673c8ff7bd89512d4d8f86d52..8ccb96ff9181a07e48b3678f318d364b0c5a20b8 100644 (file)
@@ -116,7 +116,6 @@ _public_ sd_bus_creds *sd_bus_creds_unref(sd_bus_creds *c) {
                 sd_bus_message_unref(m);
         }
 
-
         return NULL;
 }
 
@@ -209,7 +208,6 @@ _public_ int sd_bus_creds_get_suid(sd_bus_creds *c, uid_t *suid) {
         return 0;
 }
 
-
 _public_ int sd_bus_creds_get_fsuid(sd_bus_creds *c, uid_t *fsuid) {
         assert_return(c, -EINVAL);
         assert_return(fsuid, -EINVAL);
index 65947264f07284158e20d71f81630051a8e45c4d..d425a686101604fc420db41abe1eb1f62b8ce26f 100644 (file)
@@ -894,7 +894,6 @@ int bus_match_parse(
                 components[n_components].value_u8 = u;
                 n_components++;
 
-
                 if (q[quoted] == 0)
                         break;
 
index c26df38d22b73247237eb016fa49b2aef1946e82..f48125e64701bcdee0b09d36eace11f467cb7101 100644 (file)
@@ -3221,7 +3221,6 @@ end:
         return 0;
 }
 
-
 static int message_peek_body(
                 sd_bus_message *m,
                 size_t *rindex,
@@ -5315,7 +5314,6 @@ int bus_message_parse_fields(sd_bus_message *m) {
 
                         break;
 
-
                 case BUS_MESSAGE_HEADER_SIGNATURE: {
                         const char *s;
                         char *c;
index ab9afdb499a1efe41bc54cf39f0b41256058f093..662a1eac5f78775554ef4095333b0244382828ea 100644 (file)
@@ -96,7 +96,6 @@ static int signature_element_length_internal(
         return -EINVAL;
 }
 
-
 int signature_element_length(const char *s, size_t *l) {
         return signature_element_length_internal(s, true, 0, 0, l);
 }
index 06b9b0edb2b476708ce1b9197068f6ab50b78788..3745426c5c03d9fac353c8ad330c799e92a5c4fd 100644 (file)
@@ -157,7 +157,6 @@ void bus_slot_disconnect(sd_bus_slot *slot) {
                                         key.interface = slot->node_vtable.interface;
                                         key.member = v->x.method.member;
 
-
                                         x = hashmap_remove(slot->bus->vtable_properties, &key);
                                         break;
                                 }}
index b0874515e5fc66c332ef0861613027292f01dc8a..7b32c3f8888b35a83d0951f2aebc62d5f0cb4072 100644 (file)
@@ -3692,7 +3692,6 @@ _public_ int sd_bus_default_system(sd_bus **ret) {
         return bus_default(sd_bus_open_system, &default_system_bus, ret);
 }
 
-
 _public_ int sd_bus_default_user(sd_bus **ret) {
 #if 0 /// elogind does not support user buses
         return bus_default(sd_bus_open_user, &default_user_bus, ret);
index 39d7a366fdb4ae370c2c539217bd8f081633ddbf..857f43827ad2c9929087667b9f46f75f91b0deda 100644 (file)
@@ -261,7 +261,6 @@ int session_save(Session *s) {
         if (s->desktop) {
                 _cleanup_free_ char *escaped;
 
-
                 escaped = cescape(s->desktop);
                 if (!escaped) {
                         r = -ENOMEM;
index 314488ab8f2e14d141c8fded87a100de4502f7b9..5ecc23f6e572e42cd356ab5f60a64a98d1005a63 100644 (file)
@@ -275,7 +275,6 @@ int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
         return write_utmp_wtmp(&store, &store_wtmp);
 }
 
-
 int utmp_put_runlevel(int runlevel, int previous) {
         struct utmpx store = {};
         int r;
index 118720313ed710b1cf20b2e292983286cf649193..0138af7d80f47deef869e8bfa9ee1cedd5ad5faa 100644 (file)
@@ -236,7 +236,6 @@ const gather_stdout_callback_t gather_stdout[] = {
         gather_stdout_three,
 };
 
-
 static void test_stdout_gathering(void) {
         char template[] = "/tmp/test-exec-util.XXXXXXX";
         const char *dirs[] = {template, NULL};
index 5008630e018017386950ca3829325b48a03f1e12..d26e633466d9a120250bca10b208c491dc003f11 100644 (file)
@@ -5,7 +5,6 @@
   Copyright 2014 Ronny Chevalier
 ***/
 
-
 #include "locale-util.h"
 #include "macro.h"
 #include "strv.h"
index 8209b98c3f069b10f6454b7a51ee2c824be79972..e8c12710a72e4838d9b52a8397b5a5a1c726b129 100644 (file)
@@ -668,7 +668,6 @@ static void test_parse_nice(void) {
         assert_se(parse_nice("19", &n) >= 0 && n == 19);
         assert_se(parse_nice("+19", &n) >= 0 && n == 19);
 
-
         assert_se(parse_nice("", &n) == -EINVAL);
         assert_se(parse_nice("-", &n) == -EINVAL);
         assert_se(parse_nice("+", &n) == -EINVAL);
index d3a98ec66e690e15797292bcf0c677c75e8613a6..3d8d911accce221669f219b795eab762d619c3f2 100644 (file)
@@ -49,7 +49,6 @@ static void test_is_symlink(void) {
         assert_se(is_symlink(name_link) == 1);
         assert_se(is_symlink("/a/file/which/does/not/exist/i/guess") < 0);
 
-
         unlink(name);
         unlink(name_link);
 }
index 48e418f48ade4ef55d37630fbb088bc9e01c5f4a..97f8fde976d4727dd044d2a6c25a3b0acb835744 100644 (file)
@@ -137,7 +137,6 @@ static void test_strrep(void) {
         assert_se(streq(zero, ""));
 }
 
-
 static void test_strappend(void) {
         _cleanup_free_ char *t1, *t2, *t3, *t4;
 
diff --git a/tools/find-double-newline.sh b/tools/find-double-newline.sh
new file mode 100644 (file)
index 0000000..c418114
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+# SPDX-License-Identifier: LGPL-2.1+
+
+case "$1" in
+
+        recdiff)
+                if [ "$2" = "" ] ; then
+                        DIR="$PWD/.."
+                else
+                        DIR="$2"
+                fi
+
+                find $DIR -type f \( -name '*.c' -o -name '*.xml' \) -exec $0 diff \{\} \;
+                ;;
+
+        recpatch)
+                if [ "$2" = "" ] ; then
+                        DIR="$PWD/.."
+                else
+                        DIR="$2"
+                fi
+
+                find $DIR -type f \( -name '*.c' -o -name '*.xml' \) -exec $0 patch \{\} \;
+                ;;
+
+        diff)
+                T=`mktemp`
+                sed '/^$/N;/^\n$/D' < "$2" > "$T"
+                diff -u "$2" "$T"
+                rm -f "$T"
+                ;;
+
+        patch)
+                sed -i '/^$/N;/^\n$/D' "$2"
+                ;;
+
+        *)
+                echo "Expected recdiff|recpatch|diff|patch as verb." >&2
+                ;;
+esac