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 --- tcpip/rip98d.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'tcpip/rip98d.c') diff --git a/tcpip/rip98d.c b/tcpip/rip98d.c index 4b7be6b..c0543d0 100644 --- a/tcpip/rip98d.c +++ b/tcpip/rip98d.c @@ -180,7 +180,8 @@ static int read_routes(void) first_route = NULL; } - if ((fp = fopen(PROC_IP_ROUTE_FILE, "r")) == NULL) { + fp = fopen(PROC_IP_ROUTE_FILE, "r"); + if (fp == NULL) { if (logging) syslog(LOG_ERR, "error cannot open %s\n", PROC_IP_ROUTE_FILE); return FALSE; @@ -213,7 +214,8 @@ static int read_routes(void) } } - if ((route = malloc(sizeof(struct route_struct))) == NULL) { + route = malloc(sizeof(struct route_struct)); + if (route == NULL) { if (logging) syslog(LOG_ERR, "out of memory !\n"); return FALSE; @@ -239,15 +241,18 @@ static int load_dests(void) char buffer[255], *s; FILE *fp; - if ((fp = fopen(CONF_RIP98D_FILE, "r")) == NULL) { + fp = fopen(CONF_RIP98D_FILE, "r"); + if (fp == NULL) { fprintf(stderr, "rip98d: cannot open config file\n"); return FALSE; } while (fgets(buffer, 255, fp) != NULL) { - if ((s = strchr(buffer, '\n')) != NULL) *s = '\0'; + s = strchr(buffer, '\n'); + if (s != NULL) *s = '\0'; - if ((host = gethostbyname(buffer)) == NULL) { + host = gethostbyname(buffer); + if (host == NULL) { fprintf(stderr, "rip98d: cannot resolve name %s\n", buffer); fclose(fp); return FALSE; @@ -311,7 +316,8 @@ int main(int argc, char **argv) signal(SIGTERM, terminate); - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + s = socket(AF_INET, SOCK_DGRAM, 0); + if (s < 0) { perror("rip98d: socket"); return 1; } -- cgit v1.2.3