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 --- rose/rsattach.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'rose/rsattach.c') diff --git a/rose/rsattach.c b/rose/rsattach.c index f91935e..2afdc67 100644 --- a/rose/rsattach.c +++ b/rose/rsattach.c @@ -38,7 +38,8 @@ static int readconfig(char *port) char buffer[90], *s; int n = 0; - if ((fp = fopen(CONF_RSPORTS_FILE, "r")) == NULL) { + fp = fopen(CONF_RSPORTS_FILE, "r"); + if (fp == NULL) { fprintf(stderr, "rsattach: cannot open rsports file\n"); return FALSE; } @@ -46,13 +47,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 (strlen(buffer) > 0 && *buffer == '#') continue; - if ((s = strtok(buffer, " \t\r\n")) == NULL) { + s = strtok(buffer, " \t\r\n"); + if (s == NULL) { fprintf(stderr, "rsattach: unable to parse line %d of the rsports file\n", n); return FALSE; } @@ -60,7 +63,8 @@ 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, "rsattach: unable to parse line %d of the rsports file\n", n); return FALSE; } @@ -85,7 +89,8 @@ static int getfreedev(char *dev) int fd; int i; - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) { perror("rsattach: socket"); return FALSE; } @@ -116,7 +121,8 @@ static int startiface(char *dev, struct hostent *hp) char addr[5]; int fd; - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) { perror("rsattach: socket"); return FALSE; } @@ -187,7 +193,8 @@ int main(int argc, char *argv[]) while ((fd = getopt(argc, argv, "i:m:v")) != -1) { switch (fd) { case 'i': - if ((hp = gethostbyname(optarg)) == NULL) { + hp = gethostbyname(optarg); + if (hp == NULL) { fprintf(stderr, "rsattach: invalid internet name/address - %s\n", optarg); return 1; } -- cgit v1.2.3