summaryrefslogtreecommitdiffstats
path: root/ax25
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
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')
-rw-r--r--ax25/access.c4
-rw-r--r--ax25/ax25d.c100
-rw-r--r--ax25/axctl.c6
-rw-r--r--ax25/axgetput/proto_bin.c19
-rw-r--r--ax25/axgetput/util.c6
-rw-r--r--ax25/axparms.c30
-rw-r--r--ax25/axspawn.c12
-rw-r--r--ax25/axwrapper.c3
-rw-r--r--ax25/beacon.c18
-rw-r--r--ax25/mheard.c27
-rw-r--r--ax25/mheardd.c19
-rw-r--r--ax25/rxecho.c24
12 files changed, 181 insertions, 87 deletions
diff --git a/ax25/access.c b/ax25/access.c
index 951830c..2ecbb1d 100644
--- a/ax25/access.c
+++ b/ax25/access.c
@@ -204,7 +204,9 @@ static void write_example_passwd(char *pwfile, char pwlocation,
FILE * f;
int i;
- if ((i = open(pwfile, O_CREAT|O_WRONLY|O_TRUNC, (S_IRUSR | S_IWUSR | (pwlocation == SYSTEMPW ? (S_IRGRP /* | S_IWGRP */ ) : 0)))) == -1)
+ i = open(pwfile, O_CREAT | O_WRONLY | O_TRUNC,
+ (S_IRUSR | S_IWUSR | (pwlocation == SYSTEMPW ? (S_IRGRP /* | S_IWGRP */) : 0)));
+ if (i == -1)
return;
fchown(i, (pwlocation == SYSTEMPW ? 0 : pw->pw_uid), (pwlocation == SYSTEMPW ? 0 : pw->pw_gid));
close(i);
diff --git a/ax25/ax25d.c b/ax25/ax25d.c
index af75d85..346ba90 100644
--- a/ax25/ax25d.c
+++ b/ax25/ax25d.c
@@ -518,15 +518,18 @@ static int ReadConfig(void)
signal(SIGALRM, SIG_IGN);
memset(&axl_defaults, 0, sizeof(axl_defaults));
- if ((fp = fopen(ConfigFile, "r")) == NULL)
+ fp = fopen(ConfigFile, "r");
+ if (fp == NULL)
return -1;
while (fgets(buffer, sizeof(buffer), fp) != NULL) {
line++;
- if ((s = strchr(buffer, '\n')) != NULL)
+ s = strchr(buffer, '\n');
+ if (s != NULL)
*s = '\0';
- if ((s = strchr(buffer, '\r')) != NULL)
+ s = strchr(buffer, '\r');
+ if (s != NULL)
*s = '\0';
if (buffer[0] == '#')
@@ -563,23 +566,28 @@ static int ReadConfig(void)
switch (af_type) {
case AF_AX25:
- if ((s = strchr(buffer, ']')) == NULL)
+ s = strchr(buffer, ']');
+ if (s == NULL)
goto BadLine;
*s = '\0';
- if ((s = strtok(buffer + 1, " \t")) == NULL)
+ s = strtok(buffer + 1, " \t");
+ if (s == NULL)
goto BadLine;
port = s;
call = NULL;
- if ((s = strtok(NULL, " \t")) != NULL) {
+ s = strtok(NULL, " \t");
+ if (s != NULL) {
if (strcasecmp(s, "VIA") == 0 || strcasecmp(s, "V") == 0) {
- if ((s = strtok(NULL, " \t")) == NULL)
+ s = strtok(NULL, " \t");
+ if (s == NULL)
goto BadLine;
}
call = port;
port = s;
- if ((s = strchr(call, '*')) != NULL) {
+ s = strchr(call, '*');
+ if (s != NULL) {
*s = '\0';
}
}
@@ -588,7 +596,8 @@ static int ReadConfig(void)
continue;
}
if (strcmp(port, "*") != 0) {
- if ((addr = ax25_config_get_addr(port)) == NULL) {
+ addr = ax25_config_get_addr(port);
+ if (addr == NULL) {
fprintf(stderr, "ax25d: invalid AX.25 port '%s'\n", port);
continue;
}
@@ -610,11 +619,13 @@ static int ReadConfig(void)
break;
case AF_NETROM:
- if ((s = strchr(buffer, '>')) == NULL)
+ s = strchr(buffer, '>');
+ if (s == NULL)
goto BadLine;
*s = '\0';
port = buffer + 1;
- if ((addr = nr_config_get_addr(port)) == NULL) {
+ addr = nr_config_get_addr(port);
+ if (addr == NULL) {
fprintf(stderr, "ax25d: invalid NET/ROM port '%s'\n", port);
continue;
}
@@ -625,20 +636,25 @@ static int ReadConfig(void)
break;
case AF_ROSE:
- if ((s = strchr(buffer, '}')) == NULL)
+ s = strchr(buffer, '}');
+ if (s == NULL)
goto BadLine;
*s = '\0';
- if ((s = strtok(buffer + 1, " \t")) == NULL)
+ s = strtok(buffer + 1, " \t");
+ if (s == NULL)
goto BadLine;
call = s;
- if ((s = strtok(NULL, " \t")) == NULL)
+ s = strtok(NULL, " \t");
+ if (s == NULL)
goto BadLine;
if (strcasecmp(s, "VIA") == 0 || strcasecmp(s, "V") == 0) {
- if ((s = strtok(NULL, " \t")) == NULL)
+ s = strtok(NULL, " \t");
+ if (s == NULL)
goto BadLine;
}
port = s;
- if ((addr = rs_config_get_addr(port)) == NULL) {
+ addr = rs_config_get_addr(port);
+ if (addr == NULL) {
fprintf(stderr, "ax25d: invalid Rose port '%s'\n", port);
continue;
}
@@ -661,7 +677,8 @@ static int ReadConfig(void)
exit(1);
}
- if ((axl_port = calloc(1, sizeof(*axl_port))) == NULL) {
+ axl_port = calloc(1, sizeof(*axl_port));
+ if (axl_port == NULL) {
fprintf(stderr, "ax25d: out of memory\n");
goto Error;
}
@@ -669,7 +686,9 @@ static int ReadConfig(void)
axl_port->port = strdup(port);
axl_port->af_type = af_type;
- if ((axl_port->fd = socket(axl_port->af_type, SOCK_SEQPACKET, 0)) < 0) {
+ axl_port->fd = socket(axl_port->af_type,
+ SOCK_SEQPACKET, 0);
+ if (axl_port->fd < 0) {
fprintf(stderr, "ax25d: socket: %s\n", strerror(errno));
free(axl_port->port);
free(axl_port);
@@ -708,14 +727,16 @@ static int ReadConfig(void)
hunt = FALSE; /* Next lines will be entries */
} else { /* This is an entry */
- if ((axl_ent = calloc(1, sizeof(*axl_ent))) == NULL) {
+ axl_ent = calloc(1, sizeof(*axl_ent));
+ if (axl_ent == NULL) {
fprintf(stderr, "ax25d: out of memory\n");
goto Error;
}
axl_ent->af_type = axl_port->af_type; /* Inherit this */
- if ((call = strtok(buffer, " \t")) == NULL) {
+ call = strtok(buffer, " \t");
+ if (call == NULL) {
free(axl_ent);
continue;
}
@@ -723,7 +744,8 @@ static int ReadConfig(void)
strupr(call);
if (axl_ent->af_type == AF_NETROM) {
- if ((s = strchr(call, '@')) != NULL) {
+ s = strchr(call, '@');
+ if (s != NULL) {
node = s + 1;
*s = '\0';
@@ -792,7 +814,8 @@ ignore:
axl_ent->call = strdup(call);
/* Window */
- if ((s = strtok(NULL, " \t")) == NULL)
+ s = strtok(NULL, " \t");
+ if (s == NULL)
goto BadArgsFree;
if (!parameters) {
@@ -806,7 +829,8 @@ ignore:
}
/* T1 */
- if ((s = strtok(NULL, " \t")) == NULL)
+ s = strtok(NULL, " \t");
+ if (s == NULL)
goto BadArgsFree;
if (!parameters) {
@@ -830,7 +854,8 @@ ignore:
}
/* T2 */
- if ((s = strtok(NULL, " \t")) == NULL)
+ s = strtok(NULL, " \t");
+ if (s == NULL)
goto BadArgsFree;
if (!parameters) {
@@ -854,7 +879,8 @@ ignore:
}
/* T3 */
- if ((s = strtok(NULL, " \t")) == NULL)
+ s = strtok(NULL, " \t");
+ if (s == NULL)
goto BadArgsFree;
if (!parameters) {
@@ -868,7 +894,8 @@ ignore:
}
/* Idle */
- if ((s = strtok(NULL, " \t")) == NULL)
+ s = strtok(NULL, " \t");
+ if (s == NULL)
goto BadArgsFree;
if (!parameters) {
@@ -882,7 +909,8 @@ ignore:
}
/* N2 */
- if ((s = strtok(NULL, " \t")) == NULL)
+ s = strtok(NULL, " \t");
+ if (s == NULL)
goto BadArgsFree;
if (!parameters) {
@@ -897,17 +925,20 @@ ignore:
if (!parameters) {
/* Flags */
- if ((s = strtok(NULL, " \t")) == NULL)
+ s = strtok(NULL, " \t");
+ if (s == NULL)
goto BadArgsFree;
axl_ent->flags = ParseFlags(s, line);
if (!(axl_ent->flags & FLAG_LOCKOUT)) {
/* Get username */
- if ((s = strtok(NULL, " \t")) == NULL)
+ s = strtok(NULL, " \t");
+ if (s == NULL)
goto BadArgsFree;
- if ((pwd = getpwnam(s)) == NULL) {
+ pwd = getpwnam(s);
+ if (pwd == NULL) {
fprintf(stderr, "ax25d: UID for user '%s' is unknown, ignoring entry\n", s);
goto BadUID;
}
@@ -916,13 +947,15 @@ ignore:
axl_ent->gid = pwd->pw_gid;
/* Get exec file */
- if ((s = strtok(NULL, " \t")) == NULL)
+ s = strtok(NULL, " \t");
+ if (s == NULL)
goto BadArgsFree;
axl_ent->exec = strdup(s);
/* Get command line */
- if ((s = strtok(NULL, "")) == NULL)
+ s = strtok(NULL, "");
+ if (s == NULL)
goto BadArgsFree2;
axl_ent->shell = strdup(s);
@@ -990,7 +1023,8 @@ static char *stripssid(const char *call)
strcpy(newcall, call);
- if ((s = strchr(newcall, '-')) != NULL)
+ s = strchr(newcall, '-');
+ if (s != NULL)
*s = '\0';
return newcall;
diff --git a/ax25/axctl.c b/ax25/axctl.c
index c27bcdf..942b902 100644
--- a/ax25/axctl.c
+++ b/ax25/axctl.c
@@ -40,7 +40,8 @@ int main(int argc, char **argv)
return 1;
}
- if ((addr = ax25_config_get_addr(argv[1])) == NULL) {
+ addr = ax25_config_get_addr(argv[1]);
+ if (addr == NULL) {
fprintf(stderr, "axctl: invalid port name - %s\n", argv[1]);
return 1;
}
@@ -52,7 +53,8 @@ int main(int argc, char **argv)
if (ax25_aton_entry(argv[3], (char *)&ax25_ctl.source_addr) == -1)
return 1;
- if ((s = socket(AF_AX25, SOCK_SEQPACKET, 0)) < 0) {
+ s = socket(AF_AX25, SOCK_SEQPACKET, 0);
+ if (s < 0) {
perror("axctl: socket");
return 1;
}
diff --git a/ax25/axgetput/proto_bin.c b/ax25/axgetput/proto_bin.c
index 40d946d..69d12a4 100644
--- a/ax25/axgetput/proto_bin.c
+++ b/ax25/axgetput/proto_bin.c
@@ -168,7 +168,8 @@ int bput(void)
goto abort;
}
}
- if ((fddata = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0640)) < 0) {
+ fddata = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0640);
+ if (fddata < 0) {
sprintf(err_msg, "error: cannot open %s (%s)\n", filename, strerror(errno));
write(fderr, "\r#NO#\r", 6);
return 1;
@@ -191,7 +192,10 @@ int bput(void)
for (;;) {
- if ((len = my_read(fdin, buf, ((term_line || len_read_left > sizeof(buf)) ? sizeof(buf) : len_read_left), &is_eof, "\r")) < 1) {
+ len = my_read(fdin, buf,
+ ((term_line || len_read_left > sizeof(buf)) ? sizeof(buf) : len_read_left),
+ &is_eof, "\r");
+ if (len < 1) {
save_close(fddata);
sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
goto abort;
@@ -325,7 +329,8 @@ int bget(void) {
init_crc();
if (!fdin_is_pipe && *filename) {
- if ((fddata = open(filename, O_RDONLY)) == -1) {
+ fddata = open(filename, O_RDONLY);
+ if (fddata == -1) {
sprintf(err_msg, "error: cannot open %s (%s)\n", filename, strerror(errno));
return 1;
}
@@ -440,7 +445,8 @@ int bget(void) {
FD_SET(fdin, &readfds);
if (select(fdin+1, &readfds, NULL, NULL, &timeout) &&
FD_ISSET(fdin, &readfds)) {
- if ((len = read(fdin, buf, sizeof(buf))) < 0) {
+ len = read(fdin, buf, sizeof(buf));
+ if (len < 0) {
sprintf(err_msg, "read from tty failed (%s)\n", strerror(errno));
save_close(fddata);
goto abort;
@@ -454,7 +460,10 @@ int bget(void) {
/* read data */
if (!fdin_is_pipe || is_stream) {
p_buf = buf;
- if ((len = my_read(fddata, buf, ((len_remains > BLOCKSIZ || is_stream) ? BLOCKSIZ : len_remains), &is_eof, NULL)) < 1) {
+ len = my_read(fddata, buf,
+ ((len_remains > BLOCKSIZ || is_stream) ? BLOCKSIZ : len_remains),
+ &is_eof, NULL);
+ if (len < 1) {
save_close(fddata);
if (len < 0) {
sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
diff --git a/ax25/axgetput/util.c b/ax25/axgetput/util.c
index c09de1a..a4a83c0 100644
--- a/ax25/axgetput/util.c
+++ b/ax25/axgetput/util.c
@@ -53,7 +53,8 @@ int my_read(int fd, char *s, int len_max, int *eof, char *p_break)
int len;
char *s_curr = s + len_got;
- if ((len = read(fd, s_curr, (p_break ? 1 : len_max))) < 1) {
+ len = read(fd, s_curr, (p_break ? 1 : len_max));
+ if (len < 1) {
if (len == -1 && errno == EAGAIN) {
sleep(10);
continue;
@@ -88,7 +89,8 @@ int secure_write(int fd, char *s, int len_write) {
while (len_write_left_curr) {
int len;
- if ((len = write(fd, s, len_write_left_curr)) < 0) {
+ len = write(fd, s, len_write_left_curr);
+ if (len < 0) {
if (len == -1 && errno == EAGAIN) {
sleep(10);
continue;
diff --git a/ax25/axparms.c b/ax25/axparms.c
index 6e6428d..6dda06b 100644
--- a/ax25/axparms.c
+++ b/ax25/axparms.c
@@ -135,7 +135,8 @@ static int routes(int s, int argc, char *argv[], ax25_address *callsign)
}
if (strcmp(argv[2], "list") == 0) {
- if ((fp=fopen(PROC_AX25_ROUTE_FILE,"r")) == NULL) {
+ fp = fopen(PROC_AX25_ROUTE_FILE, "r");
+ if (fp == NULL) {
fprintf(stderr, "axparms: route: cannot open %s\n",
PROC_AX25_ROUTE_FILE);
return 1;
@@ -184,7 +185,8 @@ static int associate(int s, int argc, char *argv[])
exit(1);
}
- if ((fp = fopen(PROC_AX25_CALLS_FILE, "r")) == NULL) {
+ fp = fopen(PROC_AX25_CALLS_FILE, "r");
+ if (fp == NULL) {
fprintf(stderr, "axparms: associate: cannot open %s\n", PROC_AX25_CALLS_FILE);
return 1;
}
@@ -196,7 +198,8 @@ static int associate(int s, int argc, char *argv[])
while (fgets(buffer, 80, fp) != NULL) {
u = strtok(buffer, " \t\n");
c = strtok(NULL, " \t\n");
- if ((pw = getpwuid(atoi(u))) != NULL)
+ pw = getpwuid(atoi(u));
+ if (pw != NULL)
printf("%-10s %s\n", pw->pw_name, c);
}
@@ -301,7 +304,8 @@ static int forward(int s, int argc, char *argv[])
return 1;
}
- if ((addr = ax25_config_get_addr(argv[2])) == NULL) {
+ addr = ax25_config_get_addr(argv[2]);
+ if (addr == NULL) {
fprintf(stderr, "axparms: invalid port name - %s\n", argv[2]);
return 1;
}
@@ -320,7 +324,8 @@ static int forward(int s, int argc, char *argv[])
return 0;
}
- if ((addr = ax25_config_get_addr(argv[3])) == NULL) {
+ addr = ax25_config_get_addr(argv[3]);
+ if (addr == NULL) {
fprintf(stderr, "axparms: invalid port name - %s\n", argv[3]);
return 1;
}
@@ -364,7 +369,8 @@ int main(int argc, char **argv)
return 1;
}
- if ((s = socket(AF_AX25, SOCK_SEQPACKET, 0)) < 0) {
+ s = socket(AF_AX25, SOCK_SEQPACKET, 0);
+ if (s < 0) {
perror("axparms: socket");
return 1;
}
@@ -382,7 +388,8 @@ int main(int argc, char **argv)
return 1;
}
- if ((s = socket(AF_AX25, SOCK_SEQPACKET, 0)) < 0) {
+ s = socket(AF_AX25, SOCK_SEQPACKET, 0);
+ if (s < 0) {
perror("axparms: socket");
return 1;
}
@@ -415,7 +422,8 @@ int main(int argc, char **argv)
return 1;
}
- if ((addr = ax25_config_get_addr(argv[3])) == NULL) {
+ addr = ax25_config_get_addr(argv[3]);
+ if (addr == NULL) {
fprintf(stderr, "axparms: invalid port name - %s\n", argv[3]);
return 1;
}
@@ -423,7 +431,8 @@ int main(int argc, char **argv)
if (ax25_aton_entry(addr, callsign.ax25_call) == -1)
return 1;
- if ((s = socket(AF_AX25, SOCK_SEQPACKET, 0)) < 0) {
+ s = socket(AF_AX25, SOCK_SEQPACKET, 0);
+ if (s < 0) {
perror("axparms: socket");
return 1;
}
@@ -441,7 +450,8 @@ int main(int argc, char **argv)
return 1;
}
- if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+ if (s < 0) {
perror("axparms: socket");
return 1;
}
diff --git a/ax25/axspawn.c b/ax25/axspawn.c
index c9736b6..60fc836 100644
--- a/ax25/axspawn.c
+++ b/ax25/axspawn.c
@@ -648,7 +648,8 @@ static int read_ax25(char *s, int size)
int declen;
struct termios termios;
- if ((len = read(0, s, size)) < 0)
+ len = read(0, s, size);
+ if (len < 0)
return len;
if (huffman) {
@@ -990,7 +991,8 @@ static void cleanup(char *tty)
gettimeofday(&tv, NULL);
ut_line->ut_tv.tv_sec = tv.tv_sec;
ut_line->ut_tv.tv_usec = tv.tv_usec;
- if ((fp = fopen(_PATH_WTMP, "r+")) != NULL) {
+ fp = fopen(_PATH_WTMP, "r+");
+ if (fp != NULL) {
fseek(fp, 0L, SEEK_END);
if (fwrite(ut_line, sizeof(ut), 1, fp) != 1)
syslog(LOG_ERR, "Ooops, I think I've just barbecued your wtmp file\n");
@@ -1270,7 +1272,8 @@ static void read_config(void)
while (!feof(fp))
{
fgets(buf, sizeof(buf), fp);
- if ((p = strchr(buf, '#')) || (p = strchr(buf, '\n')))
+ p = strchr(buf, '#');
+ if (p || (p = strchr(buf, '\n')))
*p='\0';
if (buf[0] != '\0')
@@ -1548,7 +1551,8 @@ int main(int argc, char **argv)
char *p_buf;
sprintf(buf, "Login (%s): ", user);
write_ax25(buf, strlen(buf), 1);
- if ((cnt = read_ax25(buf, sizeof(buf)-1)) < 0)
+ cnt = read_ax25(buf, sizeof(buf) - 1);
+ if (cnt < 0)
exit(1);
buf[cnt] = 0;
diff --git a/ax25/axwrapper.c b/ax25/axwrapper.c
index 8f2390b..f58ec8d 100644
--- a/ax25/axwrapper.c
+++ b/ax25/axwrapper.c
@@ -92,7 +92,8 @@ int main(int argc, char **argv)
exit(1);
}
- if ((stdoutbuf = malloc(paclen)) == NULL) {
+ stdoutbuf = malloc(paclen);
+ if (stdoutbuf == NULL) {
PERROR("axwrapper: malloc");
exit(1);
}
diff --git a/ax25/beacon.c b/ax25/beacon.c
index d4f39c7..79e918c 100644
--- a/ax25/beacon.c
+++ b/ax25/beacon.c
@@ -106,7 +106,8 @@ int main(int argc, char *argv[])
return 1;
}
- if ((portcall = ax25_config_get_addr(port)) == NULL) {
+ portcall = ax25_config_get_addr(port);
+ if (portcall == NULL) {
fprintf(stderr, "beacon: invalid AX.25 port setting - %s\n", port);
return 1;
}
@@ -121,7 +122,8 @@ int main(int argc, char *argv[])
if (addr == NULL)
return 1;
- if ((dlen = ax25_aton(addr, &dest)) == -1) {
+ dlen = ax25_aton(addr, &dest);
+ if (dlen == -1) {
fprintf(stderr, "beacon: unable to convert callsign '%s'\n", addr);
return 1;
}
@@ -131,15 +133,18 @@ int main(int argc, char *argv[])
}
if (srccall != NULL && strcmp(srccall, portcall) != 0) {
- if ((addr = malloc(strlen(srccall) + 1 + strlen(portcall) + 1)) == NULL)
+ addr = malloc(strlen(srccall) + 1 + strlen(portcall) + 1);
+ if (addr == NULL)
return 1;
sprintf(addr, "%s %s", srccall, portcall);
} else {
- if ((addr = strdup(portcall)) == NULL)
+ addr = strdup(portcall);
+ if (addr == NULL)
return 1;
}
- if ((len = ax25_aton(addr, &src)) == -1) {
+ len = ax25_aton(addr, &src);
+ if (len == -1) {
fprintf(stderr, "beacon: unable to convert callsign '%s'\n", addr);
return 1;
}
@@ -171,7 +176,8 @@ int main(int argc, char *argv[])
sleep(t_sleep);
}
- if ((s = socket(AF_AX25, SOCK_DGRAM, 0)) == -1) {
+ s = socket(AF_AX25, SOCK_DGRAM, 0);
+ if (s == -1) {
if (logging) {
syslog(LOG_ERR, "socket: %m");
closelog();
diff --git a/ax25/mheard.c b/ax25/mheard.c
index 2acd125..b4c631d 100644
--- a/ax25/mheard.c
+++ b/ax25/mheard.c
@@ -83,7 +83,8 @@ static void PrintPortEntry(struct PortRecord *pr, int data)
strftime(lh, sizeof(lh),"%Y-%m-%d %H:%M:%S", loc) == 0)
return;
call = ax25_ntoa(&pr->entry.from_call);
- if ((s = strstr(call, "-0")) != NULL)
+ s = strstr(call, "-0");
+ if (s != NULL)
*s = '\0';
printf("%-9s %-5s %8u %s\n",
call, pr->entry.portname, pr->entry.count, lh);
@@ -91,18 +92,21 @@ static void PrintPortEntry(struct PortRecord *pr, int data)
case 1:
buffer[0] = '\0';
call = ax25_ntoa(&pr->entry.from_call);
- if ((s = strstr(call, "-0")) != NULL)
+ s = strstr(call, "-0");
+ if (s != NULL)
*s = '\0';
strcat(buffer, call);
call = ax25_ntoa(&pr->entry.to_call);
- if ((s = strstr(call, "-0")) != NULL)
+ s = strstr(call, "-0");
+ if (s != NULL)
*s = '\0';
strcat(buffer, ">");
strcat(buffer, call);
for (i = 0; i < pr->entry.ndigis && i < 4; i++) {
strcat(buffer, ",");
call = ax25_ntoa(&pr->entry.digis[i]);
- if ((s = strstr(call, "-0")) != NULL)
+ s = strstr(call, "-0");
+ if (s != NULL)
*s = '\0';
strcat(buffer, call);
}
@@ -121,7 +125,8 @@ static void PrintPortEntry(struct PortRecord *pr, int data)
strftime(fh, sizeof(fh),"%Y-%m-%d %H:%M:%S", loc) == 0)
return;
call = ax25_ntoa(&pr->entry.from_call);
- if ((s = strstr(call, "-0")) != NULL)
+ s = strstr(call, "-0");
+ if (s != NULL)
*s = '\0';
printf("%-9s %-5s %8u %8u %8u %s %s\n",
call, pr->entry.portname, pr->entry.iframes, pr->entry.sframes, pr->entry.uframes, fh, lh);
@@ -130,7 +135,8 @@ static void PrintPortEntry(struct PortRecord *pr, int data)
if (!pr->entry.count)
return;
call = ax25_ntoa(&pr->entry.from_call);
- if ((s = strstr(call, "-0")) != NULL)
+ s = strstr(call, "-0");
+ if (s != NULL)
*s = '\0';
if (pr->entry.type > sizeof(types))
return;
@@ -176,7 +182,8 @@ static void PrintPortEntry(struct PortRecord *pr, int data)
strftime(fh, sizeof(fh),"%Y-%m-%d %H:%M:%S", loc) == 0)
return;
call = ax25_ntoa(&pr->entry.from_call);
- if ((s = strstr(call, "-0")) != NULL)
+ s = strstr(call, "-0");
+ if (s != NULL)
*s = '\0';
printf("%-9s %-5s %8u %8u %8u %s %s %8u %5s ",
call, pr->entry.portname, pr->entry.iframes, pr->entry.sframes, pr->entry.uframes, fh, lh, pr->entry.count, types[pr->entry.type]);
@@ -212,7 +219,8 @@ static void PrintPortEntry(struct PortRecord *pr, int data)
if (i)
strcat(buffer, ",");
call = ax25_ntoa(&pr->entry.digis[i]);
- if ((s = strstr(call, "-0")) != NULL)
+ s = strstr(call, "-0");
+ if (s != NULL)
*s = '\0';
strcat(buffer, call);
}
@@ -244,7 +252,8 @@ static void LoadPortData(void)
struct PortRecord *pr;
struct mheard_struct mheard;
- if ((fp = fopen(DATA_MHEARD_FILE, "r")) == NULL) {
+ fp = fopen(DATA_MHEARD_FILE, "r");
+ if (fp == NULL) {
fprintf(stderr, "mheard: cannot open mheard data file\n");
exit(1);
}
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;
diff --git a/ax25/rxecho.c b/ax25/rxecho.c
index bfc326a..14a5040 100644
--- a/ax25/rxecho.c
+++ b/ax25/rxecho.c
@@ -176,7 +176,8 @@ static struct config *readconfig(void)
char line[80], *cp, *dev;
struct config *p, *list = NULL;
- if ((fp = fopen(CONF_RXECHO_FILE, "r")) == NULL) {
+ fp = fopen(CONF_RXECHO_FILE, "r");
+ if (fp == NULL) {
fprintf(stderr, "rxecho: cannot open config file\n");
return NULL;
}
@@ -187,12 +188,14 @@ static struct config *readconfig(void)
if (cp == NULL || cp[0] == '#')
continue;
- if ((p = calloc(1, sizeof(struct config))) == NULL) {
+ p = calloc(1, sizeof(struct config));
+ if (p == NULL) {
perror("rxecho: malloc");
return NULL;
}
- if ((dev = ax25_config_get_dev(cp)) == NULL) {
+ dev = ax25_config_get_dev(cp);
+ if (dev == NULL) {
fprintf(stderr, "rxecho: invalid port name - %s\n", cp);
return NULL;
}
@@ -200,12 +203,14 @@ static struct config *readconfig(void)
strcpy(p->from, dev);
p->from_idx = -1;
- if ((cp = strtok(NULL, " \t\r\n")) == NULL) {
+ cp = strtok(NULL, " \t\r\n");
+ if (cp == NULL) {
fprintf(stderr, "rxecho: config file error.\n");
return NULL;
}
- if ((dev = ax25_config_get_dev(cp)) == NULL) {
+ dev = ax25_config_get_dev(cp);
+ if (dev == NULL) {
fprintf(stderr, "rxecho: invalid port name - %s\n", cp);
return NULL;
}
@@ -394,11 +399,13 @@ int main(int argc, char **argv)
return 1;
}
- if ((list = readconfig()) == NULL)
+ list = readconfig();
+ if (list == NULL)
return 1;
#ifdef USE_SOCKADDR_SLL
- if ((s = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_AX25))) == -1) {
+ s = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_AX25));
+ if (s == -1) {
#else
if ((s = socket(AF_INET, SOCK_PACKET, htons(ETH_P_AX25))) == -1) {
#endif
@@ -450,7 +457,8 @@ int main(int argc, char **argv)
for (;;) {
alen = sa_len;
- if ((size = recvfrom(s, buf, 1500, 0, psa, &alen)) == -1) {
+ size = recvfrom(s, buf, 1500, 0, psa, &alen);
+ if (size == -1) {
if (logging) {
syslog(LOG_ERR, "recvfrom: %m");
closelog();