From daba307035faf4cc01f1ccb883b21281d91234cc Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Fri, 28 Jul 2017 14:10:07 +0200 Subject: 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 --- kiss/kissattach.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'kiss/kissattach.c') diff --git a/kiss/kissattach.c b/kiss/kissattach.c index 9667da1..2b05956 100644 --- a/kiss/kissattach.c +++ b/kiss/kissattach.c @@ -68,7 +68,8 @@ static int readconfig(char *port) char buffer[90], *s; int n = 0; - if ((fp = fopen(CONF_AXPORTS_FILE, "r")) == NULL) { + fp = fopen(CONF_AXPORTS_FILE, "r"); + if (fp == NULL) { fprintf(stderr, "%s: cannot open axports file %s\n", progname, CONF_AXPORTS_FILE); return FALSE; @@ -77,13 +78,15 @@ static int readconfig(char *port) while (fgets(buffer, 90, fp) != NULL) { n++; - if ((s = strchr(buffer, '\n')) != NULL) + s = strchr(buffer, '\n'); + if (s != NULL) *s = '\0'; if (*buffer == 0 || *buffer == '#') continue; - if ((s = strtok(buffer, " \t\r\n")) == NULL) { + s = strtok(buffer, " \t\r\n"); + if (s == NULL) { fprintf(stderr, "%s: unable to parse line %d of the axports file\n", progname, n); return FALSE; } @@ -91,27 +94,31 @@ static int readconfig(char *port) if (strcmp(s, port) != 0) continue; - if ((s = strtok(NULL, " \t\r\n")) == NULL) { + s = strtok(NULL, " \t\r\n"); + if (s == NULL) { fprintf(stderr, "%s: unable to parse line %d of the axports file\n", progname, n); return FALSE; } callsign = strdup(s); - if ((s = strtok(NULL, " \t\r\n")) == NULL) { + s = strtok(NULL, " \t\r\n"); + if (s == NULL) { fprintf(stderr, "%s: unable to parse line %d of the axports file\n", progname, n); return FALSE; } speed = atoi(s); - if ((s = strtok(NULL, " \t\r\n")) == NULL) { + s = strtok(NULL, " \t\r\n"); + if (s == NULL) { fprintf(stderr, "%s: unable to parse line %d of the axports file\n", progname, n); return FALSE; } if (mtu == 0) { - if ((mtu = atoi(s)) <= 0) { + mtu = atoi(s); + if (mtu <= 0) { fprintf(stderr, "%s: invalid paclen setting\n", progname); return FALSE; } @@ -153,7 +160,8 @@ static int startiface(char *dev, struct hostent *hp) struct ifreq ifr; int fd; - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) { fprintf(stderr, "%s: ", progname); perror("socket"); return FALSE; @@ -248,7 +256,8 @@ int main(int argc, char *argv[]) logging = TRUE; break; case 'm': - if ((mtu = atoi(optarg)) <= 0) { + mtu = atoi(optarg); + if (mtu <= 0) { fprintf(stderr, "%s: invalid mtu size - %s\n", progname, optarg); return 1; } @@ -296,7 +305,8 @@ int main(int argc, char *argv[]) return 1; } - if ((fd = open(kttyname, O_RDONLY | O_NONBLOCK)) == -1) { + fd = open(kttyname, O_RDONLY | O_NONBLOCK); + if (fd == -1) { if (errno == ENOENT) { fprintf(stderr, "%s: Cannot find serial device %s, no such file or directory.\n", progname, kttyname); } else { @@ -308,7 +318,8 @@ int main(int argc, char *argv[]) if (i_am_unix98_pty_master) { /* get name of pts-device */ - if ((namepts = ptsname(fd)) == NULL) { + namepts = ptsname(fd); + if (namepts == NULL) { fprintf(stderr, "%s: Cannot get name of pts-device.\n", progname); return 1; } -- cgit v1.2.3