summaryrefslogtreecommitdiffstats
path: root/6pack
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 /6pack
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 '6pack')
-rw-r--r--6pack/m6pack.c26
1 files changed, 15 insertions, 11 deletions
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 :