]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hostnamed: minor style cleanups
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 4 Dec 2020 18:40:46 +0000 (19:40 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 16 Dec 2020 10:02:18 +0000 (11:02 +0100)
src/hostname/hostnamed.c
src/shared/hostname-setup.c

index 5ada47459d07320a4ca3000d97ae0a8d21547c0b..c41d5fd741f473045d4b388d077649c83551dc5a 100644 (file)
@@ -68,11 +68,9 @@ typedef struct Context {
 } Context;
 
 static void context_reset(Context *c, uint64_t mask) {
-        int p;
-
         assert(c);
 
-        for (p = 0; p < _PROP_MAX; p++) {
+        for (int p = 0; p < _PROP_MAX; p++) {
                 if (!FLAGS_SET(mask, UINT64_C(1) << p))
                         continue;
 
@@ -366,12 +364,11 @@ static int context_write_data_static_hostname(Context *c) {
         assert(c);
 
         if (isempty(c->data[PROP_STATIC_HOSTNAME])) {
-
                 if (unlink("/etc/hostname") < 0)
                         return errno == ENOENT ? 0 : -errno;
-
                 return 0;
         }
+
         return write_string_file_atomic_label("/etc/hostname", c->data[PROP_STATIC_HOSTNAME]);
 }
 
@@ -386,7 +383,7 @@ static int context_write_data_machine_info(Context *c) {
         };
 
         _cleanup_strv_free_ char **l = NULL;
-        int r, p;
+        int r;
 
         assert(c);
 
@@ -394,7 +391,7 @@ static int context_write_data_machine_info(Context *c) {
         if (r < 0 && r != -ENOENT)
                 return r;
 
-        for (p = PROP_PRETTY_HOSTNAME; p <= PROP_LOCATION; p++) {
+        for (int p = PROP_PRETTY_HOSTNAME; p <= PROP_LOCATION; p++) {
                 _cleanup_free_ char *t = NULL;
                 char **u;
 
index 19e528604bdfd59b67e296e480bfd431b2a60615..7eccc86c3bfe58e4e79c405b01344848270aed1e 100644 (file)
@@ -121,7 +121,6 @@ int read_etc_hostname(const char *path, char **ret) {
                 return -errno;
 
         return read_etc_hostname_stream(f, ret);
-
 }
 
 static bool hostname_is_set(void) {