summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-10-12 19:36:47 +0900
committerGitHub <noreply@github.com>2022-10-12 19:36:47 +0900
commit6c65a9e1d6b84fec4ff01d0794607377e600b353 (patch)
tree4b0e256048aecf947f0132f3b11c66322cd09b61
parent25d615eb70b5c575462272836af1a617b09ad463 (diff)
parent67f047a6f2e5966db9669cb5289b40ef444c3dcc (diff)
downloadsystemd-6c65a9e1d6b84fec4ff01d0794607377e600b353.tar.gz
Merge pull request #24973 from keszybz/simplify-variable-declarations
Simplify variable declarations
-rw-r--r--src/basic/user-util.c24
-rw-r--r--src/libsystemd-network/dhcp6-option.c8
2 files changed, 10 insertions, 22 deletions
diff --git a/src/basic/user-util.c b/src/basic/user-util.c
index 80f9ff144b..e2857b3102 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);
diff --git a/src/libsystemd-network/dhcp6-option.c b/src/libsystemd-network/dhcp6-option.c
index 0b8393ca2c..62873e0111 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,
};