From 59818f4381fe7d0cfebfa1f7b79d8c1d93efeb92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 12 Oct 2022 09:18:24 +0200 Subject: [PATCH 1/2] libsystemd-network: trivial simplification --- src/libsystemd-network/dhcp6-option.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/libsystemd-network/dhcp6-option.c b/src/libsystemd-network/dhcp6-option.c index 0b8393ca2cf..62873e01112 100644 --- a/src/libsystemd-network/dhcp6-option.c +++ b/src/libsystemd-network/dhcp6-option.c @@ -285,15 +285,13 @@ int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *offset, OrderedSet } static int option_append_ia_address(uint8_t **buf, size_t *offset, const struct iaaddr *address) { - struct iaaddr a; - assert(buf); assert(*buf); assert(offset); assert(address); /* Do not append T1 and T2. */ - a = (struct iaaddr) { + const struct iaaddr a = { .address = address->address, }; @@ -301,8 +299,6 @@ static int option_append_ia_address(uint8_t **buf, size_t *offset, const struct } static int option_append_pd_prefix(uint8_t **buf, size_t *offset, const struct iapdprefix *prefix) { - struct iapdprefix p; - assert(buf); assert(*buf); assert(offset); @@ -312,7 +308,7 @@ static int option_append_pd_prefix(uint8_t **buf, size_t *offset, const struct i return -EINVAL; /* Do not append T1 and T2. */ - p = (struct iapdprefix) { + const struct iapdprefix p = { .prefixlen = prefix->prefixlen, .address = prefix->address, }; From 67f047a6f2e5966db9669cb5289b40ef444c3dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 3 Oct 2022 11:50:16 +0200 Subject: [PATCH 2/2] basic/user-util: simplify variable declarations in fget{pw,gr}ent_sane() --- src/basic/user-util.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/basic/user-util.c b/src/basic/user-util.c index 80f9ff144b1..e2857b31027 100644 --- a/src/basic/user-util.c +++ b/src/basic/user-util.c @@ -990,13 +990,11 @@ int putsgent_sane(const struct sgrp *sg, FILE *stream) { #endif int fgetpwent_sane(FILE *stream, struct passwd **pw) { - struct passwd *p; - - assert(pw); assert(stream); + assert(pw); errno = 0; - p = fgetpwent(stream); + struct passwd *p = fgetpwent(stream); if (!p && errno != ENOENT) return errno_or_else(EIO); @@ -1005,13 +1003,11 @@ int fgetpwent_sane(FILE *stream, struct passwd **pw) { } int fgetspent_sane(FILE *stream, struct spwd **sp) { - struct spwd *s; - - assert(sp); assert(stream); + assert(sp); errno = 0; - s = fgetspent(stream); + struct spwd *s = fgetspent(stream); if (!s && errno != ENOENT) return errno_or_else(EIO); @@ -1020,13 +1016,11 @@ int fgetspent_sane(FILE *stream, struct spwd **sp) { } int fgetgrent_sane(FILE *stream, struct group **gr) { - struct group *g; - - assert(gr); assert(stream); + assert(gr); errno = 0; - g = fgetgrent(stream); + struct group *g = fgetgrent(stream); if (!g && errno != ENOENT) return errno_or_else(EIO); @@ -1036,13 +1030,11 @@ int fgetgrent_sane(FILE *stream, struct group **gr) { #if ENABLE_GSHADOW int fgetsgent_sane(FILE *stream, struct sgrp **sg) { - struct sgrp *s; - - assert(sg); assert(stream); + assert(sg); errno = 0; - s = fgetsgent(stream); + struct sgrp *s = fgetsgent(stream); if (!s && errno != ENOENT) return errno_or_else(EIO);