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 --- 6pack/m6pack.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to '6pack') diff --git a/6pack/m6pack.c b/6pack/m6pack.c index edc6014..aa18579 100644 --- a/6pack/m6pack.c +++ b/6pack/m6pack.c @@ -487,12 +487,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("m6pack: 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("m6pack: open"); return 1; } @@ -517,11 +519,13 @@ 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("m6pack: malloc"); return 1; } - if ((pty[i]->fd = open(pty_name, O_RDWR)) == -1) { + pty[i]->fd = open(pty_name, O_RDWR); + if (pty[i]->fd == -1) { perror("m6pack: open"); return 1; } @@ -533,7 +537,8 @@ int main(int argc, char *argv[]) pty[i]->namepts[0] = '\0'; 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, "m6pack: Cannot get name of pts-device.\n"); return 1; } @@ -627,8 +632,8 @@ int main(int argc, char *argv[]) } for (icp = ibuf; size > 0; size--, icp++) { - if ((len = sixpack_rx(tty,*icp,&tnc_addr, - &type)) != 0) { + len = sixpack_rx(tty, *icp, &tnc_addr, &type); + if (len != 0) { if (tnc_addr <= numptys) { sixpack_tx(pty[tnc_addr]->fd, 0, @@ -659,10 +664,9 @@ int main(int argc, char *argv[]) } for (icp = ibuf; size > 0; size--, icp++) { - if ((len = sixpack_rx(pty[i], - *icp, - &tnc_addr, - &type)) != 0) { + len = sixpack_rx(pty[i], *icp, + &tnc_addr, &type); + if (len != 0) { sixpack_tx(tty->fd, i, (type == data) ? pty[i]->databuf : -- cgit v1.2.3