summaryrefslogtreecommitdiffstats
path: root/ax25/mheardd.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2017-07-28 14:10:07 +0200
committerRalf Baechle <ralf@linux-mips.org>2017-07-31 04:29:44 +0200
commitdaba307035faf4cc01f1ccb883b21281d91234cc (patch)
treeedbd5df9285303f281524fac8064866057ce35ce /ax25/mheardd.c
parent71b0582584ac5de97141ea207ddf17f7c938b2df (diff)
treewide: Kill assignments in if conditions.
Somewhat hard to read and the code base already has many overlong lines. Found with below spatch file and some manual editing in ax25/access.c to restore a comment lost by spatch. @parens@ expression E, F, G; binary operator X; statement S; @@ - if ((E = F) X G) + E = F; + if (E X G) S Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'ax25/mheardd.c')
-rw-r--r--ax25/mheardd.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/ax25/mheardd.c b/ax25/mheardd.c
index a1c121b..53b1f68 100644
--- a/ax25/mheardd.c
+++ b/ax25/mheardd.c
@@ -164,7 +164,9 @@ int main(int argc, char **argv)
return 1;
}
- if ((mheard_list = calloc(mheard_list_size, sizeof(struct mheard_list_struct))) == NULL) {
+ mheard_list = calloc(mheard_list_size,
+ sizeof(struct mheard_list_struct));
+ if (mheard_list == NULL) {
fprintf(stderr, "mheardd: cannot allocate memory\n");
return 1;
}
@@ -187,11 +189,13 @@ int main(int argc, char **argv)
fclose(fp);
} else {
- if ((fp = fopen(DATA_MHEARD_FILE, "w")) != NULL)
+ fp = fopen(DATA_MHEARD_FILE, "w");
+ if (fp != NULL)
fclose(fp);
}
- if ((s = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_AX25))) == -1) {
+ s = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_AX25));
+ if (s == -1) {
perror("mheardd: socket");
return 1;
}
@@ -210,7 +214,8 @@ int main(int argc, char **argv)
for (;;) {
asize = sizeof(sa);
- if ((size = recvfrom(s, buffer, sizeof(buffer), 0, &sa, &asize)) == -1) {
+ size = recvfrom(s, buffer, sizeof(buffer), 0, &sa, &asize);
+ if (size == -1) {
if (logging) {
syslog(LOG_ERR, "recv: %m");
closelog();
@@ -218,7 +223,8 @@ int main(int argc, char **argv)
return 1;
}
- if ((port = ax25_config_get_name(sa.sa_data)) == NULL) {
+ port = ax25_config_get_name(sa.sa_data);
+ if (port == NULL) {
if (logging)
syslog(LOG_WARNING, "unknown port '%s'\n", sa.sa_data);
continue;
@@ -392,7 +398,8 @@ int main(int argc, char **argv)
time(&mheard->entry.last_heard);
- if ((fp = fopen(DATA_MHEARD_FILE, "r+")) == NULL) {
+ fp = fopen(DATA_MHEARD_FILE, "r+");
+ if (fp == NULL) {
if (logging)
syslog(LOG_ERR, "cannot open mheard data file\n");
continue;