diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2017-07-28 14:10:07 +0200 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2017-07-31 04:29:44 +0200 |
commit | daba307035faf4cc01f1ccb883b21281d91234cc (patch) | |
tree | edbd5df9285303f281524fac8064866057ce35ce /kiss/mkiss.c | |
parent | 71b0582584ac5de97141ea207ddf17f7c938b2df (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 'kiss/mkiss.c')
-rw-r--r-- | kiss/mkiss.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/kiss/mkiss.c b/kiss/mkiss.c index 35e7ed0..1747c33 100644 --- a/kiss/mkiss.c +++ b/kiss/mkiss.c @@ -510,12 +510,14 @@ int main(int argc, char *argv[]) * non-blocking so it won't block regardless of the modem * status lines. */ - if ((tty = calloc(1, sizeof(struct iface))) == NULL) { + tty = calloc(1, sizeof(struct iface)); + if (tty == NULL) { perror("mkiss: malloc"); return 1; } - if ((tty->fd = open(argv[optind], O_RDWR | O_NDELAY)) == -1) { + tty->fd = open(argv[optind], O_RDWR | O_NDELAY); + if (tty->fd == -1) { perror("mkiss: open"); return 1; } @@ -542,7 +544,8 @@ int main(int argc, char *argv[]) static char name_ptmx[] = "/dev/ptmx"; char *pty_name = (i < numptys ? argv[optind+i+1] : name_ptmx); - if ((pty[i] = calloc(1, sizeof(struct iface))) == NULL) { + pty[i] = calloc(1, sizeof(struct iface)); + if (pty[i] == NULL) { perror("mkiss: malloc"); return 1; } @@ -550,7 +553,8 @@ int main(int argc, char *argv[]) pty[i]->fd = -1; strcpy(pty[i]->namepts, "none"); } else { - if ((pty[i]->fd = open(pty_name, O_RDWR)) == -1) { + pty[i]->fd = open(pty_name, O_RDWR); + if (pty[i]->fd == -1) { perror("mkiss: open"); free(pty[i]); pty[i] = NULL; @@ -564,7 +568,8 @@ int main(int argc, char *argv[]) pty[i]->optr = pty[i]->obuf; if (!strcmp(pty[i]->name, "/dev/ptmx")) { /* get name of pts-device */ - if ((npts = ptsname(pty[i]->fd)) == NULL) { + npts = ptsname(pty[i]->fd); + if (npts == NULL) { fprintf(stderr, "mkiss: Cannot get name of pts-device.\n"); free(pty[i]); pty[i] = NULL; @@ -672,7 +677,8 @@ int main(int argc, char *argv[]) break; } for (icp = ibuf; size > 0; size--, icp++) { - if ((len = kiss_rx(tty, *icp, crcflag)) != 0) { + len = kiss_rx(tty, *icp, crcflag); + if (len != 0) { if ((i = (*tty->obuf & 0xF0) >> 4) < numptys) { if (pty[i]->fd != -1) { kiss_tx(pty[i]->fd, 0, tty->obuf, len, FALSE); @@ -698,7 +704,8 @@ int main(int argc, char *argv[]) goto end; } for (icp = ibuf; size > 0; size--, icp++) { - if ((len = kiss_rx(pty[i], *icp, FALSE)) != 0) { + len = kiss_rx(pty[i], *icp, FALSE); + if (len != 0) { kiss_tx(tty->fd, i, pty[i]->obuf, len, crcflag); tty->txpackets++; tty->txbytes += len; |