summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-12-04 19:40:46 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-12-16 11:02:18 +0100
commit536970d4f9828f30d508ac9143f717ea921f99c5 (patch)
treeadf078b90857cfb630e05309e2a4710cabced0e2
parentefda832d4f0523cdb544a1a6baf862d0ec57da6f (diff)
downloadsystemd-536970d4f9828f30d508ac9143f717ea921f99c5.tar.gz
hostnamed: minor style cleanups
-rw-r--r--src/hostname/hostnamed.c11
-rw-r--r--src/shared/hostname-setup.c1
2 files changed, 4 insertions, 8 deletions
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index 5ada47459d..c41d5fd741 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -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;
diff --git a/src/shared/hostname-setup.c b/src/shared/hostname-setup.c
index 19e528604b..7eccc86c3b 100644
--- a/src/shared/hostname-setup.c
+++ b/src/shared/hostname-setup.c
@@ -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) {