From d08f3360f435f17590416857a95fa9ccfe19204c Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Fri, 28 Jul 2017 14:26:57 +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 files: @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 --- ax25mond/ax25mond.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'ax25mond') diff --git a/ax25mond/ax25mond.c b/ax25mond/ax25mond.c index 5530bf5..bc1186c 100644 --- a/ax25mond/ax25mond.c +++ b/ax25mond/ax25mond.c @@ -109,13 +109,15 @@ static struct sockaddr *build_sockaddr(const char *name, int *addrlen) addr.si.sin_addr.s_addr = INADDR_ANY; } else if (!strcmp(host_name, "loopback")) { addr.si.sin_addr.s_addr = inet_addr("127.0.0.1"); - } else if ((addr.si.sin_addr.s_addr = inet_addr(host_name)) == -1) { - struct hostent *hp = gethostbyname(host_name); - endhostent(); - if (!hp) - return NULL; - addr.si.sin_addr.s_addr = - ((struct in_addr *) (hp->h_addr))->s_addr; + } else {addr.si.sin_addr.s_addr = inet_addr(host_name); + if (addr.si.sin_addr.s_addr == -1) { + struct hostent *hp = gethostbyname(host_name); + endhostent(); + if (!hp) + return NULL; + addr.si.sin_addr.s_addr = + ((struct in_addr *) (hp->h_addr))->s_addr; + } } if (isdigit(*serv_name & 0xff)) { @@ -157,8 +159,8 @@ static void add_socket(char *sockname, char monmode) else sock_filename[sock_num][0] = 0; - if ((sock_list[sock_num] = - socket(saddr->sa_family, SOCK_STREAM, 0)) < 0) { + sock_list[sock_num] = socket(saddr->sa_family, SOCK_STREAM, 0); + if (sock_list[sock_num] < 0) { fprintf(stderr, "WARNING: Error opening socket \"%s\": %s\n", sockname, strerror(errno)); -- cgit v1.2.3