# HG changeset patch # User Matti Hamalainen # Date 1289779576 -7200 # Node ID 8d4cdbeae6064bd0171c119bc5548a2012fbf484 # Parent fd93de78a1157f7e3c19454937a404660b5ebe75 Clean up connection forming. diff -r fd93de78a115 -r 8d4cdbeae606 nnchat.c --- a/nnchat.c Mon Nov 15 02:05:33 2010 +0200 +++ b/nnchat.c Mon Nov 15 02:06:16 2010 +0200 @@ -925,12 +925,11 @@ /* To emulate the official client, we first make a request for * policy file, even though we don't use it for anything... */ - if ((conn = nn_conn_open((struct in_addr *) tmpHost->h_addr, 843)) == NULL) { + conn = nn_conn_open((struct in_addr *) tmpHost->h_addr, 843); + if (!nn_conn_check(conn)) { THERR("Policy file request connection setup failed!\n"); goto err_exit; } - if (!nn_conn_check(conn)) - goto err_exit; tmpStr = ""; if (nn_conn_send_buf(conn, tmpStr, strlen(tmpStr) + 1) == FALSE) { @@ -947,12 +946,11 @@ nn_conn_close(conn); /* Okay, now do the proper connection ... */ - if ((conn = nn_conn_open((struct in_addr *) tmpHost->h_addr, optPort)) == NULL) { + conn = nn_conn_open((struct in_addr *) tmpHost->h_addr, optPort); + if (!nn_conn_check(conn)) { THERR("Main connection setup failed!\n"); goto err_exit; } - if (!nn_conn_check(conn)) - goto err_exit; THMSG(1, "Connected, logging in as '%s', site '%s'.\n", optUserName, optSite); optUserName2 = nn_dblencode_str(optUserName);