summaryrefslogtreecommitdiffstats
path: root/ax25mond
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2017-07-28 14:26:57 +0200
committerRalf Baechle <ralf@linux-mips.org>2017-08-03 03:46:12 +0200
commitd08f3360f435f17590416857a95fa9ccfe19204c (patch)
tree0a3434ba7d43bd3d4be7081377f147da400268f1 /ax25mond
parentb541f5ddd8936a1f2fa69d1917d6812139da0c4e (diff)
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 <ralf@linux-mips.org>
Diffstat (limited to 'ax25mond')
-rw-r--r--ax25mond/ax25mond.c20
1 files changed, 11 insertions, 9 deletions
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));