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 --- ax25/axgetput/proto_bin.c | 19 ++++++++++++++----- ax25/axgetput/util.c | 6 ++++-- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'ax25/axgetput') 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; -- cgit v1.2.3