Commit 06ace26e authored by James Simmons's avatar James Simmons Committed by Greg Kroah-Hartman

staging: lustre: fix all NULL comparisons in LNet layer

This removes every instance of checking a variable against
NULL in the LNet source code.
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 06f2f2f2
...@@ -197,7 +197,7 @@ lnet_md_alloc(lnet_md_t *umd) ...@@ -197,7 +197,7 @@ lnet_md_alloc(lnet_md_t *umd)
LIBCFS_ALLOC(md, size); LIBCFS_ALLOC(md, size);
if (md != NULL) { if (md) {
/* Set here in case of early free */ /* Set here in case of early free */
md->md_options = umd->options; md->md_options = umd->options;
md->md_niov = niov; md->md_niov = niov;
...@@ -267,7 +267,7 @@ lnet_res_lh_invalidate(lnet_libhandle_t *lh) ...@@ -267,7 +267,7 @@ lnet_res_lh_invalidate(lnet_libhandle_t *lh)
static inline void static inline void
lnet_eq2handle(lnet_handle_eq_t *handle, lnet_eq_t *eq) lnet_eq2handle(lnet_handle_eq_t *handle, lnet_eq_t *eq)
{ {
if (eq == NULL) { if (!eq) {
LNetInvalidateHandle(handle); LNetInvalidateHandle(handle);
return; return;
} }
...@@ -281,7 +281,7 @@ lnet_handle2eq(lnet_handle_eq_t *handle) ...@@ -281,7 +281,7 @@ lnet_handle2eq(lnet_handle_eq_t *handle)
lnet_libhandle_t *lh; lnet_libhandle_t *lh;
lh = lnet_res_lh_lookup(&the_lnet.ln_eq_container, handle->cookie); lh = lnet_res_lh_lookup(&the_lnet.ln_eq_container, handle->cookie);
if (lh == NULL) if (!lh)
return NULL; return NULL;
return lh_entry(lh, lnet_eq_t, eq_lh); return lh_entry(lh, lnet_eq_t, eq_lh);
...@@ -303,7 +303,7 @@ lnet_handle2md(lnet_handle_md_t *handle) ...@@ -303,7 +303,7 @@ lnet_handle2md(lnet_handle_md_t *handle)
cpt = lnet_cpt_of_cookie(handle->cookie); cpt = lnet_cpt_of_cookie(handle->cookie);
lh = lnet_res_lh_lookup(the_lnet.ln_md_containers[cpt], lh = lnet_res_lh_lookup(the_lnet.ln_md_containers[cpt],
handle->cookie); handle->cookie);
if (lh == NULL) if (!lh)
return NULL; return NULL;
return lh_entry(lh, lnet_libmd_t, md_lh); return lh_entry(lh, lnet_libmd_t, md_lh);
...@@ -322,7 +322,7 @@ lnet_wire_handle2md(lnet_handle_wire_t *wh) ...@@ -322,7 +322,7 @@ lnet_wire_handle2md(lnet_handle_wire_t *wh)
cpt = lnet_cpt_of_cookie(wh->wh_object_cookie); cpt = lnet_cpt_of_cookie(wh->wh_object_cookie);
lh = lnet_res_lh_lookup(the_lnet.ln_md_containers[cpt], lh = lnet_res_lh_lookup(the_lnet.ln_md_containers[cpt],
wh->wh_object_cookie); wh->wh_object_cookie);
if (lh == NULL) if (!lh)
return NULL; return NULL;
return lh_entry(lh, lnet_libmd_t, md_lh); return lh_entry(lh, lnet_libmd_t, md_lh);
...@@ -344,7 +344,7 @@ lnet_handle2me(lnet_handle_me_t *handle) ...@@ -344,7 +344,7 @@ lnet_handle2me(lnet_handle_me_t *handle)
cpt = lnet_cpt_of_cookie(handle->cookie); cpt = lnet_cpt_of_cookie(handle->cookie);
lh = lnet_res_lh_lookup(the_lnet.ln_me_containers[cpt], lh = lnet_res_lh_lookup(the_lnet.ln_me_containers[cpt],
handle->cookie); handle->cookie);
if (lh == NULL) if (!lh)
return NULL; return NULL;
return lh_entry(lh, lnet_me_t, me_lh); return lh_entry(lh, lnet_me_t, me_lh);
......
...@@ -126,7 +126,7 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx) ...@@ -126,7 +126,7 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
int nob; int nob;
/* Not NOOP message */ /* Not NOOP message */
LASSERT(tx->tx_lnetmsg != NULL); LASSERT(tx->tx_lnetmsg);
/* /*
* NB we can't trust socket ops to either consume our iovs * NB we can't trust socket ops to either consume our iovs
...@@ -147,7 +147,7 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx) ...@@ -147,7 +147,7 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
fragsize < tx->tx_resid) fragsize < tx->tx_resid)
msgflg |= MSG_MORE; msgflg |= MSG_MORE;
if (sk->sk_prot->sendpage != NULL) { if (sk->sk_prot->sendpage) {
rc = sk->sk_prot->sendpage(sk, page, rc = sk->sk_prot->sendpage(sk, page,
offset, fragsize, msgflg); offset, fragsize, msgflg);
} else { } else {
...@@ -266,7 +266,7 @@ ksocknal_lib_recv_iov(ksock_conn_t *conn) ...@@ -266,7 +266,7 @@ ksocknal_lib_recv_iov(ksock_conn_t *conn)
static void static void
ksocknal_lib_kiov_vunmap(void *addr) ksocknal_lib_kiov_vunmap(void *addr)
{ {
if (addr == NULL) if (!addr)
return; return;
vunmap(addr); vunmap(addr);
...@@ -280,7 +280,7 @@ ksocknal_lib_kiov_vmap(lnet_kiov_t *kiov, int niov, ...@@ -280,7 +280,7 @@ ksocknal_lib_kiov_vmap(lnet_kiov_t *kiov, int niov,
int nob; int nob;
int i; int i;
if (!*ksocknal_tunables.ksnd_zc_recv || pages == NULL) if (!*ksocknal_tunables.ksnd_zc_recv || !pages)
return NULL; return NULL;
LASSERT(niov <= LNET_MAX_IOV); LASSERT(niov <= LNET_MAX_IOV);
...@@ -299,7 +299,7 @@ ksocknal_lib_kiov_vmap(lnet_kiov_t *kiov, int niov, ...@@ -299,7 +299,7 @@ ksocknal_lib_kiov_vmap(lnet_kiov_t *kiov, int niov,
} }
addr = vmap(pages, niov, VM_MAP, PAGE_KERNEL); addr = vmap(pages, niov, VM_MAP, PAGE_KERNEL);
if (addr == NULL) if (!addr)
return NULL; return NULL;
iov->iov_base = addr + kiov[0].kiov_offset; iov->iov_base = addr + kiov[0].kiov_offset;
...@@ -342,7 +342,7 @@ ksocknal_lib_recv_kiov(ksock_conn_t *conn) ...@@ -342,7 +342,7 @@ ksocknal_lib_recv_kiov(ksock_conn_t *conn)
* or leave them alone. * or leave them alone.
*/ */
addr = ksocknal_lib_kiov_vmap(kiov, niov, scratchiov, pages); addr = ksocknal_lib_kiov_vmap(kiov, niov, scratchiov, pages);
if (addr != NULL) { if (addr) {
nob = scratchiov[0].iov_len; nob = scratchiov[0].iov_len;
n = 1; n = 1;
...@@ -382,7 +382,7 @@ ksocknal_lib_recv_kiov(ksock_conn_t *conn) ...@@ -382,7 +382,7 @@ ksocknal_lib_recv_kiov(ksock_conn_t *conn)
} }
} }
if (addr != NULL) { if (addr) {
ksocknal_lib_kiov_vunmap(addr); ksocknal_lib_kiov_vunmap(addr);
} else { } else {
for (i = 0; i < niov; i++) for (i = 0; i < niov; i++)
...@@ -400,7 +400,7 @@ ksocknal_lib_csum_tx(ksock_tx_t *tx) ...@@ -400,7 +400,7 @@ ksocknal_lib_csum_tx(ksock_tx_t *tx)
void *base; void *base;
LASSERT(tx->tx_iov[0].iov_base == &tx->tx_msg); LASSERT(tx->tx_iov[0].iov_base == &tx->tx_msg);
LASSERT(tx->tx_conn != NULL); LASSERT(tx->tx_conn);
LASSERT(tx->tx_conn->ksnc_proto == &ksocknal_protocol_v2x); LASSERT(tx->tx_conn->ksnc_proto == &ksocknal_protocol_v2x);
tx->tx_msg.ksm_csum = 0; tx->tx_msg.ksm_csum = 0;
...@@ -408,7 +408,7 @@ ksocknal_lib_csum_tx(ksock_tx_t *tx) ...@@ -408,7 +408,7 @@ ksocknal_lib_csum_tx(ksock_tx_t *tx)
csum = ksocknal_csum(~0, tx->tx_iov[0].iov_base, csum = ksocknal_csum(~0, tx->tx_iov[0].iov_base,
tx->tx_iov[0].iov_len); tx->tx_iov[0].iov_len);
if (tx->tx_kiov != NULL) { if (tx->tx_kiov) {
for (i = 0; i < tx->tx_nkiov; i++) { for (i = 0; i < tx->tx_nkiov; i++) {
base = kmap(tx->tx_kiov[i].kiov_page) + base = kmap(tx->tx_kiov[i].kiov_page) +
tx->tx_kiov[i].kiov_offset; tx->tx_kiov[i].kiov_offset;
...@@ -606,7 +606,7 @@ ksocknal_data_ready(struct sock *sk) ...@@ -606,7 +606,7 @@ ksocknal_data_ready(struct sock *sk)
read_lock(&ksocknal_data.ksnd_global_lock); read_lock(&ksocknal_data.ksnd_global_lock);
conn = sk->sk_user_data; conn = sk->sk_user_data;
if (conn == NULL) { /* raced with ksocknal_terminate_conn */ if (!conn) { /* raced with ksocknal_terminate_conn */
LASSERT(sk->sk_data_ready != &ksocknal_data_ready); LASSERT(sk->sk_data_ready != &ksocknal_data_ready);
sk->sk_data_ready(sk); sk->sk_data_ready(sk);
} else { } else {
...@@ -633,14 +633,14 @@ ksocknal_write_space(struct sock *sk) ...@@ -633,14 +633,14 @@ ksocknal_write_space(struct sock *sk)
CDEBUG(D_NET, "sk %p wspace %d low water %d conn %p%s%s%s\n", CDEBUG(D_NET, "sk %p wspace %d low water %d conn %p%s%s%s\n",
sk, wspace, min_wpace, conn, sk, wspace, min_wpace, conn,
(conn == NULL) ? "" : (conn->ksnc_tx_ready ? !conn ? "" : (conn->ksnc_tx_ready ?
" ready" : " blocked"), " ready" : " blocked"),
(conn == NULL) ? "" : (conn->ksnc_tx_scheduled ? !conn ? "" : (conn->ksnc_tx_scheduled ?
" scheduled" : " idle"), " scheduled" : " idle"),
(conn == NULL) ? "" : (list_empty(&conn->ksnc_tx_queue) ? !conn ? "" : (list_empty(&conn->ksnc_tx_queue) ?
" empty" : " queued")); " empty" : " queued"));
if (conn == NULL) { /* raced with ksocknal_terminate_conn */ if (!conn) { /* raced with ksocknal_terminate_conn */
LASSERT(sk->sk_write_space != &ksocknal_write_space); LASSERT(sk->sk_write_space != &ksocknal_write_space);
sk->sk_write_space(sk); sk->sk_write_space(sk);
......
...@@ -56,7 +56,7 @@ ksocknal_next_tx_carrier(ksock_conn_t *conn) ...@@ -56,7 +56,7 @@ ksocknal_next_tx_carrier(ksock_conn_t *conn)
/* Called holding BH lock: conn->ksnc_scheduler->kss_lock */ /* Called holding BH lock: conn->ksnc_scheduler->kss_lock */
LASSERT(!list_empty(&conn->ksnc_tx_queue)); LASSERT(!list_empty(&conn->ksnc_tx_queue));
LASSERT(tx != NULL); LASSERT(tx);
/* Next TX that can carry ZC-ACK or LNet message */ /* Next TX that can carry ZC-ACK or LNet message */
if (tx->tx_list.next == &conn->ksnc_tx_queue) { if (tx->tx_list.next == &conn->ksnc_tx_queue) {
...@@ -75,7 +75,7 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn, ...@@ -75,7 +75,7 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn,
{ {
ksock_tx_t *tx = conn->ksnc_tx_carrier; ksock_tx_t *tx = conn->ksnc_tx_carrier;
LASSERT(tx_ack == NULL || LASSERT(!tx_ack ||
tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP); tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP);
/* /*
...@@ -85,8 +85,8 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn, ...@@ -85,8 +85,8 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn,
* . There is tx can piggyback cookie of tx_ack (or cookie), * . There is tx can piggyback cookie of tx_ack (or cookie),
* piggyback the cookie and return the tx. * piggyback the cookie and return the tx.
*/ */
if (tx == NULL) { if (!tx) {
if (tx_ack != NULL) { if (tx_ack) {
list_add_tail(&tx_ack->tx_list, list_add_tail(&tx_ack->tx_list,
&conn->ksnc_tx_queue); &conn->ksnc_tx_queue);
conn->ksnc_tx_carrier = tx_ack; conn->ksnc_tx_carrier = tx_ack;
...@@ -96,7 +96,7 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn, ...@@ -96,7 +96,7 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn,
if (tx->tx_msg.ksm_type == KSOCK_MSG_NOOP) { if (tx->tx_msg.ksm_type == KSOCK_MSG_NOOP) {
/* tx is noop zc-ack, can't piggyback zc-ack cookie */ /* tx is noop zc-ack, can't piggyback zc-ack cookie */
if (tx_ack != NULL) if (tx_ack)
list_add_tail(&tx_ack->tx_list, list_add_tail(&tx_ack->tx_list,
&conn->ksnc_tx_queue); &conn->ksnc_tx_queue);
return 0; return 0;
...@@ -105,7 +105,7 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn, ...@@ -105,7 +105,7 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn,
LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_LNET); LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_LNET);
LASSERT(tx->tx_msg.ksm_zc_cookies[1] == 0); LASSERT(tx->tx_msg.ksm_zc_cookies[1] == 0);
if (tx_ack != NULL) if (tx_ack)
cookie = tx_ack->tx_msg.ksm_zc_cookies[1]; cookie = tx_ack->tx_msg.ksm_zc_cookies[1];
/* piggyback the zc-ack cookie */ /* piggyback the zc-ack cookie */
...@@ -128,7 +128,7 @@ ksocknal_queue_tx_msg_v2(ksock_conn_t *conn, ksock_tx_t *tx_msg) ...@@ -128,7 +128,7 @@ ksocknal_queue_tx_msg_v2(ksock_conn_t *conn, ksock_tx_t *tx_msg)
* . If there is NOOP on the connection, piggyback the cookie * . If there is NOOP on the connection, piggyback the cookie
* and replace the NOOP tx, and return the NOOP tx. * and replace the NOOP tx, and return the NOOP tx.
*/ */
if (tx == NULL) { /* nothing on queue */ if (!tx) { /* nothing on queue */
list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue); list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue);
conn->ksnc_tx_carrier = tx_msg; conn->ksnc_tx_carrier = tx_msg;
return NULL; return NULL;
...@@ -162,12 +162,12 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn, ...@@ -162,12 +162,12 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn,
return ksocknal_queue_tx_zcack_v2(conn, tx_ack, cookie); return ksocknal_queue_tx_zcack_v2(conn, tx_ack, cookie);
/* non-blocking ZC-ACK (to router) */ /* non-blocking ZC-ACK (to router) */
LASSERT(tx_ack == NULL || LASSERT(!tx_ack ||
tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP); tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP);
tx = conn->ksnc_tx_carrier; tx = conn->ksnc_tx_carrier;
if (tx == NULL) { if (!tx) {
if (tx_ack != NULL) { if (tx_ack) {
list_add_tail(&tx_ack->tx_list, list_add_tail(&tx_ack->tx_list,
&conn->ksnc_tx_queue); &conn->ksnc_tx_queue);
conn->ksnc_tx_carrier = tx_ack; conn->ksnc_tx_carrier = tx_ack;
...@@ -175,9 +175,9 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn, ...@@ -175,9 +175,9 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn,
return 0; return 0;
} }
/* conn->ksnc_tx_carrier != NULL */ /* conn->ksnc_tx_carrier */
if (tx_ack != NULL) if (tx_ack)
cookie = tx_ack->tx_msg.ksm_zc_cookies[1]; cookie = tx_ack->tx_msg.ksm_zc_cookies[1];
if (cookie == SOCKNAL_KEEPALIVE_PING) /* ignore keepalive PING */ if (cookie == SOCKNAL_KEEPALIVE_PING) /* ignore keepalive PING */
...@@ -261,7 +261,7 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn, ...@@ -261,7 +261,7 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn,
} }
/* failed to piggyback ZC-ACK */ /* failed to piggyback ZC-ACK */
if (tx_ack != NULL) { if (tx_ack) {
list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue); list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue);
/* the next tx can piggyback at least 1 ACK */ /* the next tx can piggyback at least 1 ACK */
ksocknal_next_tx_carrier(conn); ksocknal_next_tx_carrier(conn);
...@@ -280,7 +280,7 @@ ksocknal_match_tx(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk) ...@@ -280,7 +280,7 @@ ksocknal_match_tx(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk)
return SOCKNAL_MATCH_YES; return SOCKNAL_MATCH_YES;
#endif #endif
if (tx == NULL || tx->tx_lnetmsg == NULL) { if (!tx || !tx->tx_lnetmsg) {
/* noop packet */ /* noop packet */
nob = offsetof(ksock_msg_t, ksm_u); nob = offsetof(ksock_msg_t, ksm_u);
} else { } else {
...@@ -319,7 +319,7 @@ ksocknal_match_tx_v3(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk) ...@@ -319,7 +319,7 @@ ksocknal_match_tx_v3(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk)
{ {
int nob; int nob;
if (tx == NULL || tx->tx_lnetmsg == NULL) if (!tx || !tx->tx_lnetmsg)
nob = offsetof(ksock_msg_t, ksm_u); nob = offsetof(ksock_msg_t, ksm_u);
else else
nob = tx->tx_lnetmsg->msg_len + sizeof(ksock_msg_t); nob = tx->tx_lnetmsg->msg_len + sizeof(ksock_msg_t);
...@@ -334,7 +334,7 @@ ksocknal_match_tx_v3(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk) ...@@ -334,7 +334,7 @@ ksocknal_match_tx_v3(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk)
case SOCKLND_CONN_ACK: case SOCKLND_CONN_ACK:
if (nonblk) if (nonblk)
return SOCKNAL_MATCH_YES; return SOCKNAL_MATCH_YES;
else if (tx == NULL || tx->tx_lnetmsg == NULL) else if (!tx || !tx->tx_lnetmsg)
return SOCKNAL_MATCH_MAY; return SOCKNAL_MATCH_MAY;
else else
return SOCKNAL_MATCH_NO; return SOCKNAL_MATCH_NO;
...@@ -369,10 +369,10 @@ ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote) ...@@ -369,10 +369,10 @@ ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote)
read_lock(&ksocknal_data.ksnd_global_lock); read_lock(&ksocknal_data.ksnd_global_lock);
conn = ksocknal_find_conn_locked(peer, NULL, !!remote); conn = ksocknal_find_conn_locked(peer, NULL, !!remote);
if (conn != NULL) { if (conn) {
ksock_sched_t *sched = conn->ksnc_scheduler; ksock_sched_t *sched = conn->ksnc_scheduler;
LASSERT(conn->ksnc_proto->pro_queue_tx_zcack != NULL); LASSERT(conn->ksnc_proto->pro_queue_tx_zcack);
spin_lock_bh(&sched->kss_lock); spin_lock_bh(&sched->kss_lock);
...@@ -390,7 +390,7 @@ ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote) ...@@ -390,7 +390,7 @@ ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote)
/* ACK connection is not ready, or can't piggyback the ACK */ /* ACK connection is not ready, or can't piggyback the ACK */
tx = ksocknal_alloc_tx_noop(cookie, !!remote); tx = ksocknal_alloc_tx_noop(cookie, !!remote);
if (tx == NULL) if (!tx)
return -ENOMEM; return -ENOMEM;
rc = ksocknal_launch_packet(peer->ksnp_ni, tx, peer->ksnp_id); rc = ksocknal_launch_packet(peer->ksnp_ni, tx, peer->ksnp_id);
...@@ -461,7 +461,7 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello) ...@@ -461,7 +461,7 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello)
CLASSERT(sizeof(lnet_magicversion_t) == offsetof(lnet_hdr_t, src_nid)); CLASSERT(sizeof(lnet_magicversion_t) == offsetof(lnet_hdr_t, src_nid));
LIBCFS_ALLOC(hdr, sizeof(*hdr)); LIBCFS_ALLOC(hdr, sizeof(*hdr));
if (hdr == NULL) { if (!hdr) {
CERROR("Can't allocate lnet_hdr_t\n"); CERROR("Can't allocate lnet_hdr_t\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -576,7 +576,7 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello, ...@@ -576,7 +576,7 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
int i; int i;
LIBCFS_ALLOC(hdr, sizeof(*hdr)); LIBCFS_ALLOC(hdr, sizeof(*hdr));
if (hdr == NULL) { if (!hdr) {
CERROR("Can't allocate lnet_hdr_t\n"); CERROR("Can't allocate lnet_hdr_t\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -713,7 +713,7 @@ ksocknal_pack_msg_v1(ksock_tx_t *tx) ...@@ -713,7 +713,7 @@ ksocknal_pack_msg_v1(ksock_tx_t *tx)
{ {
/* V1.x has no KSOCK_MSG_NOOP */ /* V1.x has no KSOCK_MSG_NOOP */
LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP); LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
LASSERT(tx->tx_lnetmsg != NULL); LASSERT(tx->tx_lnetmsg);
tx->tx_iov[0].iov_base = &tx->tx_lnetmsg->msg_hdr; tx->tx_iov[0].iov_base = &tx->tx_lnetmsg->msg_hdr;
tx->tx_iov[0].iov_len = sizeof(lnet_hdr_t); tx->tx_iov[0].iov_len = sizeof(lnet_hdr_t);
...@@ -727,7 +727,7 @@ ksocknal_pack_msg_v2(ksock_tx_t *tx) ...@@ -727,7 +727,7 @@ ksocknal_pack_msg_v2(ksock_tx_t *tx)
{ {
tx->tx_iov[0].iov_base = &tx->tx_msg; tx->tx_iov[0].iov_base = &tx->tx_msg;
if (tx->tx_lnetmsg != NULL) { if (tx->tx_lnetmsg) {
LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP); LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
tx->tx_msg.ksm_u.lnetmsg.ksnm_hdr = tx->tx_lnetmsg->msg_hdr; tx->tx_msg.ksm_u.lnetmsg.ksnm_hdr = tx->tx_lnetmsg->msg_hdr;
......
...@@ -299,16 +299,16 @@ lnet_accept(struct socket *sock, __u32 magic) ...@@ -299,16 +299,16 @@ lnet_accept(struct socket *sock, __u32 magic)
__swab64s(&cr.acr_nid); __swab64s(&cr.acr_nid);
ni = lnet_net2ni(LNET_NIDNET(cr.acr_nid)); ni = lnet_net2ni(LNET_NIDNET(cr.acr_nid));
if (ni == NULL || /* no matching net */ if (!ni || /* no matching net */
ni->ni_nid != cr.acr_nid) { /* right NET, wrong NID! */ ni->ni_nid != cr.acr_nid) { /* right NET, wrong NID! */
if (ni != NULL) if (ni)
lnet_ni_decref(ni); lnet_ni_decref(ni);
LCONSOLE_ERROR_MSG(0x120, "Refusing connection from %pI4h for %s: No matching NI\n", LCONSOLE_ERROR_MSG(0x120, "Refusing connection from %pI4h for %s: No matching NI\n",
&peer_ip, libcfs_nid2str(cr.acr_nid)); &peer_ip, libcfs_nid2str(cr.acr_nid));
return -EPERM; return -EPERM;
} }
if (ni->ni_lnd->lnd_accept == NULL) { if (!ni->ni_lnd->lnd_accept) {
/* This catches a request for the loopback LND */ /* This catches a request for the loopback LND */
lnet_ni_decref(ni); lnet_ni_decref(ni);
LCONSOLE_ERROR_MSG(0x121, "Refusing connection from %pI4h for %s: NI doesn not accept IP connections\n", LCONSOLE_ERROR_MSG(0x121, "Refusing connection from %pI4h for %s: NI doesn not accept IP connections\n",
...@@ -335,7 +335,7 @@ lnet_acceptor(void *arg) ...@@ -335,7 +335,7 @@ lnet_acceptor(void *arg)
int peer_port; int peer_port;
int secure = (int)((long_ptr_t)arg); int secure = (int)((long_ptr_t)arg);
LASSERT(lnet_acceptor_state.pta_sock == NULL); LASSERT(!lnet_acceptor_state.pta_sock);
cfs_block_allsigs(); cfs_block_allsigs();
...@@ -443,7 +443,7 @@ lnet_acceptor_start(void) ...@@ -443,7 +443,7 @@ lnet_acceptor_start(void)
long rc2; long rc2;
long secure; long secure;
LASSERT(lnet_acceptor_state.pta_sock == NULL); LASSERT(!lnet_acceptor_state.pta_sock);
rc = lnet_acceptor_get_tunables(); rc = lnet_acceptor_get_tunables();
if (rc != 0) if (rc != 0)
...@@ -471,11 +471,11 @@ lnet_acceptor_start(void) ...@@ -471,11 +471,11 @@ lnet_acceptor_start(void)
if (!lnet_acceptor_state.pta_shutdown) { if (!lnet_acceptor_state.pta_shutdown) {
/* started OK */ /* started OK */
LASSERT(lnet_acceptor_state.pta_sock != NULL); LASSERT(lnet_acceptor_state.pta_sock);
return 0; return 0;
} }
LASSERT(lnet_acceptor_state.pta_sock == NULL); LASSERT(!lnet_acceptor_state.pta_sock);
return -ENETDOWN; return -ENETDOWN;
} }
...@@ -483,7 +483,7 @@ lnet_acceptor_start(void) ...@@ -483,7 +483,7 @@ lnet_acceptor_start(void)
void void
lnet_acceptor_stop(void) lnet_acceptor_stop(void)
{ {
if (lnet_acceptor_state.pta_sock == NULL) /* not running */ if (!lnet_acceptor_state.pta_sock) /* not running */
return; return;
lnet_acceptor_state.pta_shutdown = 1; lnet_acceptor_state.pta_shutdown = 1;
......
...@@ -107,10 +107,10 @@ lnet_create_remote_nets_table(void) ...@@ -107,10 +107,10 @@ lnet_create_remote_nets_table(void)
int i; int i;
struct list_head *hash; struct list_head *hash;
LASSERT(the_lnet.ln_remote_nets_hash == NULL); LASSERT(!the_lnet.ln_remote_nets_hash);
LASSERT(the_lnet.ln_remote_nets_hbits > 0); LASSERT(the_lnet.ln_remote_nets_hbits > 0);
LIBCFS_ALLOC(hash, LNET_REMOTE_NETS_HASH_SIZE * sizeof(*hash)); LIBCFS_ALLOC(hash, LNET_REMOTE_NETS_HASH_SIZE * sizeof(*hash));
if (hash == NULL) { if (!hash) {
CERROR("Failed to create remote nets hash table\n"); CERROR("Failed to create remote nets hash table\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -126,7 +126,7 @@ lnet_destroy_remote_nets_table(void) ...@@ -126,7 +126,7 @@ lnet_destroy_remote_nets_table(void)
{ {
int i; int i;
if (the_lnet.ln_remote_nets_hash == NULL) if (!the_lnet.ln_remote_nets_hash)
return; return;
for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE; i++) for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE; i++)
...@@ -141,12 +141,12 @@ lnet_destroy_remote_nets_table(void) ...@@ -141,12 +141,12 @@ lnet_destroy_remote_nets_table(void)
static void static void
lnet_destroy_locks(void) lnet_destroy_locks(void)
{ {
if (the_lnet.ln_res_lock != NULL) { if (the_lnet.ln_res_lock) {
cfs_percpt_lock_free(the_lnet.ln_res_lock); cfs_percpt_lock_free(the_lnet.ln_res_lock);
the_lnet.ln_res_lock = NULL; the_lnet.ln_res_lock = NULL;
} }
if (the_lnet.ln_net_lock != NULL) { if (the_lnet.ln_net_lock) {
cfs_percpt_lock_free(the_lnet.ln_net_lock); cfs_percpt_lock_free(the_lnet.ln_net_lock);
the_lnet.ln_net_lock = NULL; the_lnet.ln_net_lock = NULL;
} }
...@@ -158,11 +158,11 @@ lnet_create_locks(void) ...@@ -158,11 +158,11 @@ lnet_create_locks(void)
lnet_init_locks(); lnet_init_locks();
the_lnet.ln_res_lock = cfs_percpt_lock_alloc(lnet_cpt_table()); the_lnet.ln_res_lock = cfs_percpt_lock_alloc(lnet_cpt_table());
if (the_lnet.ln_res_lock == NULL) if (!the_lnet.ln_res_lock)
goto failed; goto failed;
the_lnet.ln_net_lock = cfs_percpt_lock_alloc(lnet_cpt_table()); the_lnet.ln_net_lock = cfs_percpt_lock_alloc(lnet_cpt_table());
if (the_lnet.ln_net_lock == NULL) if (!the_lnet.ln_net_lock)
goto failed; goto failed;
return 0; return 0;
...@@ -291,7 +291,7 @@ lnet_register_lnd(lnd_t *lnd) ...@@ -291,7 +291,7 @@ lnet_register_lnd(lnd_t *lnd)
LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_init);
LASSERT(libcfs_isknown_lnd(lnd->lnd_type)); LASSERT(libcfs_isknown_lnd(lnd->lnd_type));
LASSERT(lnet_find_lnd_by_type(lnd->lnd_type) == NULL); LASSERT(!lnet_find_lnd_by_type(lnd->lnd_type));
list_add_tail(&lnd->lnd_list, &the_lnet.ln_lnds); list_add_tail(&lnd->lnd_list, &the_lnet.ln_lnds);
lnd->lnd_refcount = 0; lnd->lnd_refcount = 0;
...@@ -408,7 +408,7 @@ lnet_res_container_cleanup(struct lnet_res_container *rec) ...@@ -408,7 +408,7 @@ lnet_res_container_cleanup(struct lnet_res_container *rec)
count, lnet_res_type2str(rec->rec_type)); count, lnet_res_type2str(rec->rec_type));
} }
if (rec->rec_lh_hash != NULL) { if (rec->rec_lh_hash) {
LIBCFS_FREE(rec->rec_lh_hash, LIBCFS_FREE(rec->rec_lh_hash,
LNET_LH_HASH_SIZE * sizeof(rec->rec_lh_hash[0])); LNET_LH_HASH_SIZE * sizeof(rec->rec_lh_hash[0]));
rec->rec_lh_hash = NULL; rec->rec_lh_hash = NULL;
...@@ -432,7 +432,7 @@ lnet_res_container_setup(struct lnet_res_container *rec, int cpt, int type) ...@@ -432,7 +432,7 @@ lnet_res_container_setup(struct lnet_res_container *rec, int cpt, int type)
/* Arbitrary choice of hash table size */ /* Arbitrary choice of hash table size */
LIBCFS_CPT_ALLOC(rec->rec_lh_hash, lnet_cpt_table(), cpt, LIBCFS_CPT_ALLOC(rec->rec_lh_hash, lnet_cpt_table(), cpt,
LNET_LH_HASH_SIZE * sizeof(rec->rec_lh_hash[0])); LNET_LH_HASH_SIZE * sizeof(rec->rec_lh_hash[0]));
if (rec->rec_lh_hash == NULL) { if (!rec->rec_lh_hash) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
...@@ -470,7 +470,7 @@ lnet_res_containers_create(int type) ...@@ -470,7 +470,7 @@ lnet_res_containers_create(int type)
int i; int i;
recs = cfs_percpt_alloc(lnet_cpt_table(), sizeof(*rec)); recs = cfs_percpt_alloc(lnet_cpt_table(), sizeof(*rec));
if (recs == NULL) { if (!recs) {
CERROR("Failed to allocate %s resource containers\n", CERROR("Failed to allocate %s resource containers\n",
lnet_res_type2str(type)); lnet_res_type2str(type));
return NULL; return NULL;
...@@ -557,7 +557,7 @@ lnet_prepare(lnet_pid_t requested_pid) ...@@ -557,7 +557,7 @@ lnet_prepare(lnet_pid_t requested_pid)
the_lnet.ln_counters = cfs_percpt_alloc(lnet_cpt_table(), the_lnet.ln_counters = cfs_percpt_alloc(lnet_cpt_table(),
sizeof(lnet_counters_t)); sizeof(lnet_counters_t));
if (the_lnet.ln_counters == NULL) { if (!the_lnet.ln_counters) {
CERROR("Failed to allocate counters for LNet\n"); CERROR("Failed to allocate counters for LNet\n");
rc = -ENOMEM; rc = -ENOMEM;
goto failed; goto failed;
...@@ -577,7 +577,7 @@ lnet_prepare(lnet_pid_t requested_pid) ...@@ -577,7 +577,7 @@ lnet_prepare(lnet_pid_t requested_pid)
goto failed; goto failed;
recs = lnet_res_containers_create(LNET_COOKIE_TYPE_ME); recs = lnet_res_containers_create(LNET_COOKIE_TYPE_ME);
if (recs == NULL) { if (!recs) {
rc = -ENOMEM; rc = -ENOMEM;
goto failed; goto failed;
} }
...@@ -585,7 +585,7 @@ lnet_prepare(lnet_pid_t requested_pid) ...@@ -585,7 +585,7 @@ lnet_prepare(lnet_pid_t requested_pid)
the_lnet.ln_me_containers = recs; the_lnet.ln_me_containers = recs;
recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD); recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD);
if (recs == NULL) { if (!recs) {
rc = -ENOMEM; rc = -ENOMEM;
goto failed; goto failed;
} }
...@@ -624,12 +624,12 @@ lnet_unprepare(void) ...@@ -624,12 +624,12 @@ lnet_unprepare(void)
lnet_portals_destroy(); lnet_portals_destroy();
if (the_lnet.ln_md_containers != NULL) { if (the_lnet.ln_md_containers) {
lnet_res_containers_destroy(the_lnet.ln_md_containers); lnet_res_containers_destroy(the_lnet.ln_md_containers);
the_lnet.ln_md_containers = NULL; the_lnet.ln_md_containers = NULL;
} }
if (the_lnet.ln_me_containers != NULL) { if (the_lnet.ln_me_containers) {
lnet_res_containers_destroy(the_lnet.ln_me_containers); lnet_res_containers_destroy(the_lnet.ln_me_containers);
the_lnet.ln_me_containers = NULL; the_lnet.ln_me_containers = NULL;
} }
...@@ -640,7 +640,7 @@ lnet_unprepare(void) ...@@ -640,7 +640,7 @@ lnet_unprepare(void)
lnet_peer_tables_destroy(); lnet_peer_tables_destroy();
lnet_rtrpools_free(); lnet_rtrpools_free();
if (the_lnet.ln_counters != NULL) { if (the_lnet.ln_counters) {
cfs_percpt_free(the_lnet.ln_counters); cfs_percpt_free(the_lnet.ln_counters);
the_lnet.ln_counters = NULL; the_lnet.ln_counters = NULL;
} }
...@@ -716,7 +716,7 @@ lnet_cpt_of_nid_locked(lnet_nid_t nid) ...@@ -716,7 +716,7 @@ lnet_cpt_of_nid_locked(lnet_nid_t nid)
if (LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid)) if (LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid))
continue; continue;
LASSERT(ni->ni_cpts != NULL); LASSERT(ni->ni_cpts);
return ni->ni_cpts[lnet_nid_cpt_hash return ni->ni_cpts[lnet_nid_cpt_hash
(nid, ni->ni_ncpts)]; (nid, ni->ni_ncpts)];
} }
...@@ -754,12 +754,12 @@ lnet_islocalnet(__u32 net) ...@@ -754,12 +754,12 @@ lnet_islocalnet(__u32 net)
cpt = lnet_net_lock_current(); cpt = lnet_net_lock_current();
ni = lnet_net2ni_locked(net, cpt); ni = lnet_net2ni_locked(net, cpt);
if (ni != NULL) if (ni)
lnet_ni_decref_locked(ni, cpt); lnet_ni_decref_locked(ni, cpt);
lnet_net_unlock(cpt); lnet_net_unlock(cpt);
return ni != NULL; return !!ni;
} }
lnet_ni_t * lnet_ni_t *
...@@ -790,11 +790,11 @@ lnet_islocalnid(lnet_nid_t nid) ...@@ -790,11 +790,11 @@ lnet_islocalnid(lnet_nid_t nid)
cpt = lnet_net_lock_current(); cpt = lnet_net_lock_current();
ni = lnet_nid2ni_locked(nid, cpt); ni = lnet_nid2ni_locked(nid, cpt);
if (ni != NULL) if (ni)
lnet_ni_decref_locked(ni, cpt); lnet_ni_decref_locked(ni, cpt);
lnet_net_unlock(cpt); lnet_net_unlock(cpt);
return ni != NULL; return !!ni;
} }
int int
...@@ -810,7 +810,7 @@ lnet_count_acceptor_nis(void) ...@@ -810,7 +810,7 @@ lnet_count_acceptor_nis(void)
list_for_each(tmp, &the_lnet.ln_nis) { list_for_each(tmp, &the_lnet.ln_nis) {
ni = list_entry(tmp, lnet_ni_t, ni_list); ni = list_entry(tmp, lnet_ni_t, ni_list);
if (ni->ni_lnd->lnd_accept != NULL) if (ni->ni_lnd->lnd_accept)
count++; count++;
} }
...@@ -868,13 +868,13 @@ lnet_shutdown_lndnis(void) ...@@ -868,13 +868,13 @@ lnet_shutdown_lndnis(void)
} }
/* Drop the cached eqwait NI. */ /* Drop the cached eqwait NI. */
if (the_lnet.ln_eq_waitni != NULL) { if (the_lnet.ln_eq_waitni) {
lnet_ni_decref_locked(the_lnet.ln_eq_waitni, 0); lnet_ni_decref_locked(the_lnet.ln_eq_waitni, 0);
the_lnet.ln_eq_waitni = NULL; the_lnet.ln_eq_waitni = NULL;
} }
/* Drop the cached loopback NI. */ /* Drop the cached loopback NI. */
if (the_lnet.ln_loni != NULL) { if (the_lnet.ln_loni) {
lnet_ni_decref_locked(the_lnet.ln_loni, 0); lnet_ni_decref_locked(the_lnet.ln_loni, 0);
the_lnet.ln_loni = NULL; the_lnet.ln_loni = NULL;
} }
...@@ -953,7 +953,7 @@ lnet_shutdown_lndnis(void) ...@@ -953,7 +953,7 @@ lnet_shutdown_lndnis(void)
the_lnet.ln_shutdown = 0; the_lnet.ln_shutdown = 0;
lnet_net_unlock(LNET_LOCK_EX); lnet_net_unlock(LNET_LOCK_EX);
if (the_lnet.ln_network_tokens != NULL) { if (the_lnet.ln_network_tokens) {
LIBCFS_FREE(the_lnet.ln_network_tokens, LIBCFS_FREE(the_lnet.ln_network_tokens,
the_lnet.ln_network_tokens_nob); the_lnet.ln_network_tokens_nob);
the_lnet.ln_network_tokens = NULL; the_lnet.ln_network_tokens = NULL;
...@@ -975,7 +975,7 @@ lnet_startup_lndnis(void) ...@@ -975,7 +975,7 @@ lnet_startup_lndnis(void)
INIT_LIST_HEAD(&nilist); INIT_LIST_HEAD(&nilist);
if (nets == NULL) if (!nets)
goto failed; goto failed;
rc = lnet_parse_networks(&nilist, nets); rc = lnet_parse_networks(&nilist, nets);
...@@ -1000,14 +1000,14 @@ lnet_startup_lndnis(void) ...@@ -1000,14 +1000,14 @@ lnet_startup_lndnis(void)
mutex_lock(&the_lnet.ln_lnd_mutex); mutex_lock(&the_lnet.ln_lnd_mutex);
lnd = lnet_find_lnd_by_type(lnd_type); lnd = lnet_find_lnd_by_type(lnd_type);
if (lnd == NULL) { if (!lnd) {
mutex_unlock(&the_lnet.ln_lnd_mutex); mutex_unlock(&the_lnet.ln_lnd_mutex);
rc = request_module("%s", rc = request_module("%s",
libcfs_lnd2modname(lnd_type)); libcfs_lnd2modname(lnd_type));
mutex_lock(&the_lnet.ln_lnd_mutex); mutex_lock(&the_lnet.ln_lnd_mutex);
lnd = lnet_find_lnd_by_type(lnd_type); lnd = lnet_find_lnd_by_type(lnd_type);
if (lnd == NULL) { if (!lnd) {
mutex_unlock(&the_lnet.ln_lnd_mutex); mutex_unlock(&the_lnet.ln_lnd_mutex);
CERROR("Can't load LND %s, module %s, rc=%d\n", CERROR("Can't load LND %s, module %s, rc=%d\n",
libcfs_lnd2str(lnd_type), libcfs_lnd2str(lnd_type),
...@@ -1035,7 +1035,7 @@ lnet_startup_lndnis(void) ...@@ -1035,7 +1035,7 @@ lnet_startup_lndnis(void)
goto failed; goto failed;
} }
LASSERT(ni->ni_peertimeout <= 0 || lnd->lnd_query != NULL); LASSERT(ni->ni_peertimeout <= 0 || lnd->lnd_query);
list_del(&ni->ni_list); list_del(&ni->ni_list);
...@@ -1043,7 +1043,7 @@ lnet_startup_lndnis(void) ...@@ -1043,7 +1043,7 @@ lnet_startup_lndnis(void)
/* refcount for ln_nis */ /* refcount for ln_nis */
lnet_ni_addref_locked(ni, 0); lnet_ni_addref_locked(ni, 0);
list_add_tail(&ni->ni_list, &the_lnet.ln_nis); list_add_tail(&ni->ni_list, &the_lnet.ln_nis);
if (ni->ni_cpts != NULL) { if (ni->ni_cpts) {
list_add_tail(&ni->ni_cptlist, list_add_tail(&ni->ni_cptlist,
&the_lnet.ln_nis_cpt); &the_lnet.ln_nis_cpt);
lnet_ni_addref_locked(ni, 0); lnet_ni_addref_locked(ni, 0);
...@@ -1053,7 +1053,7 @@ lnet_startup_lndnis(void) ...@@ -1053,7 +1053,7 @@ lnet_startup_lndnis(void)
if (lnd->lnd_type == LOLND) { if (lnd->lnd_type == LOLND) {
lnet_ni_addref(ni); lnet_ni_addref(ni);
LASSERT(the_lnet.ln_loni == NULL); LASSERT(!the_lnet.ln_loni);
the_lnet.ln_loni = ni; the_lnet.ln_loni = ni;
continue; continue;
} }
...@@ -1081,7 +1081,7 @@ lnet_startup_lndnis(void) ...@@ -1081,7 +1081,7 @@ lnet_startup_lndnis(void)
nicount++; nicount++;
} }
if (the_lnet.ln_eq_waitni != NULL && nicount > 1) { if (the_lnet.ln_eq_waitni && nicount > 1) {
lnd_type = the_lnet.ln_eq_waitni->ni_lnd->lnd_type; lnd_type = the_lnet.ln_eq_waitni->ni_lnd->lnd_type;
LCONSOLE_ERROR_MSG(0x109, "LND %s can only run single-network\n", LCONSOLE_ERROR_MSG(0x109, "LND %s can only run single-network\n",
libcfs_lnd2str(lnd_type)); libcfs_lnd2str(lnd_type));
...@@ -1402,10 +1402,10 @@ LNetCtl(unsigned int cmd, void *arg) ...@@ -1402,10 +1402,10 @@ LNetCtl(unsigned int cmd, void *arg)
default: default:
ni = lnet_net2ni(data->ioc_net); ni = lnet_net2ni(data->ioc_net);
if (ni == NULL) if (!ni)
return -EINVAL; return -EINVAL;
if (ni->ni_lnd->lnd_ctl == NULL) if (!ni->ni_lnd->lnd_ctl)
rc = -EINVAL; rc = -EINVAL;
else else
rc = ni->ni_lnd->lnd_ctl(ni, cmd, arg); rc = ni->ni_lnd->lnd_ctl(ni, cmd, arg);
...@@ -1499,7 +1499,7 @@ lnet_create_ping_info(void) ...@@ -1499,7 +1499,7 @@ lnet_create_ping_info(void)
infosz = offsetof(lnet_ping_info_t, pi_ni[n]); infosz = offsetof(lnet_ping_info_t, pi_ni[n]);
LIBCFS_ALLOC(pinfo, infosz); LIBCFS_ALLOC(pinfo, infosz);
if (pinfo == NULL) { if (!pinfo) {
CERROR("Can't allocate ping info[%d]\n", n); CERROR("Can't allocate ping info[%d]\n", n);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1521,10 +1521,10 @@ lnet_create_ping_info(void) ...@@ -1521,10 +1521,10 @@ lnet_create_ping_info(void)
lnet_net_lock(0); lnet_net_lock(0);
ni = lnet_nid2ni_locked(id.nid, 0); ni = lnet_nid2ni_locked(id.nid, 0);
LASSERT(ni != NULL); LASSERT(ni);
lnet_ni_lock(ni); lnet_ni_lock(ni);
LASSERT(ni->ni_status == NULL); LASSERT(!ni->ni_status);
ni->ni_status = ns; ni->ni_status = ns;
lnet_ni_unlock(ni); lnet_ni_unlock(ni);
...@@ -1694,7 +1694,7 @@ static int lnet_ping(lnet_process_id_t id, int timeout_ms, ...@@ -1694,7 +1694,7 @@ static int lnet_ping(lnet_process_id_t id, int timeout_ms,
id.pid = LUSTRE_SRV_LNET_PID; id.pid = LUSTRE_SRV_LNET_PID;
LIBCFS_ALLOC(info, infosz); LIBCFS_ALLOC(info, infosz);
if (info == NULL) if (!info)
return -ENOMEM; return -ENOMEM;
/* NB 2 events max (including any unlink event) */ /* NB 2 events max (including any unlink event) */
......
...@@ -96,13 +96,13 @@ lnet_net_unique(__u32 net, struct list_head *nilist) ...@@ -96,13 +96,13 @@ lnet_net_unique(__u32 net, struct list_head *nilist)
void void
lnet_ni_free(struct lnet_ni *ni) lnet_ni_free(struct lnet_ni *ni)
{ {
if (ni->ni_refs != NULL) if (ni->ni_refs)
cfs_percpt_free(ni->ni_refs); cfs_percpt_free(ni->ni_refs);
if (ni->ni_tx_queues != NULL) if (ni->ni_tx_queues)
cfs_percpt_free(ni->ni_tx_queues); cfs_percpt_free(ni->ni_tx_queues);
if (ni->ni_cpts != NULL) if (ni->ni_cpts)
cfs_expr_list_values_free(ni->ni_cpts, ni->ni_ncpts); cfs_expr_list_values_free(ni->ni_cpts, ni->ni_ncpts);
LIBCFS_FREE(ni, sizeof(*ni)); LIBCFS_FREE(ni, sizeof(*ni));
...@@ -123,7 +123,7 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist) ...@@ -123,7 +123,7 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
} }
LIBCFS_ALLOC(ni, sizeof(*ni)); LIBCFS_ALLOC(ni, sizeof(*ni));
if (ni == NULL) { if (!ni) {
CERROR("Out of memory creating network %s\n", CERROR("Out of memory creating network %s\n",
libcfs_net2str(net)); libcfs_net2str(net));
return NULL; return NULL;
...@@ -133,18 +133,18 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist) ...@@ -133,18 +133,18 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
INIT_LIST_HEAD(&ni->ni_cptlist); INIT_LIST_HEAD(&ni->ni_cptlist);
ni->ni_refs = cfs_percpt_alloc(lnet_cpt_table(), ni->ni_refs = cfs_percpt_alloc(lnet_cpt_table(),
sizeof(*ni->ni_refs[0])); sizeof(*ni->ni_refs[0]));
if (ni->ni_refs == NULL) if (!ni->ni_refs)
goto failed; goto failed;
ni->ni_tx_queues = cfs_percpt_alloc(lnet_cpt_table(), ni->ni_tx_queues = cfs_percpt_alloc(lnet_cpt_table(),
sizeof(*ni->ni_tx_queues[0])); sizeof(*ni->ni_tx_queues[0]));
if (ni->ni_tx_queues == NULL) if (!ni->ni_tx_queues)
goto failed; goto failed;
cfs_percpt_for_each(tq, i, ni->ni_tx_queues) cfs_percpt_for_each(tq, i, ni->ni_tx_queues)
INIT_LIST_HEAD(&tq->tq_delayed); INIT_LIST_HEAD(&tq->tq_delayed);
if (el == NULL) { if (!el) {
ni->ni_cpts = NULL; ni->ni_cpts = NULL;
ni->ni_ncpts = LNET_CPT_NUMBER; ni->ni_ncpts = LNET_CPT_NUMBER;
} else { } else {
...@@ -194,7 +194,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks) ...@@ -194,7 +194,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
} }
LIBCFS_ALLOC(tokens, tokensize); LIBCFS_ALLOC(tokens, tokensize);
if (tokens == NULL) { if (!tokens) {
CERROR("Can't allocate net tokens\n"); CERROR("Can't allocate net tokens\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -207,10 +207,10 @@ lnet_parse_networks(struct list_head *nilist, char *networks) ...@@ -207,10 +207,10 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
/* Add in the loopback network */ /* Add in the loopback network */
ni = lnet_ni_alloc(LNET_MKNET(LOLND, 0), NULL, nilist); ni = lnet_ni_alloc(LNET_MKNET(LOLND, 0), NULL, nilist);
if (ni == NULL) if (!ni)
goto failed; goto failed;
while (str != NULL && *str != 0) { while (str && *str != 0) {
char *comma = strchr(str, ','); char *comma = strchr(str, ',');
char *bracket = strchr(str, '('); char *bracket = strchr(str, '(');
char *square = strchr(str, '['); char *square = strchr(str, '[');
...@@ -222,18 +222,18 @@ lnet_parse_networks(struct list_head *nilist, char *networks) ...@@ -222,18 +222,18 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
* NB we don't check interface conflicts here; it's the LNDs * NB we don't check interface conflicts here; it's the LNDs
* responsibility (if it cares at all) * responsibility (if it cares at all)
*/ */
if (square != NULL && (comma == NULL || square < comma)) { if (square && (!comma || square < comma)) {
/* /*
* i.e: o2ib0(ib0)[1,2], number between square * i.e: o2ib0(ib0)[1,2], number between square
* brackets are CPTs this NI needs to be bond * brackets are CPTs this NI needs to be bond
*/ */
if (bracket != NULL && bracket > square) { if (bracket && bracket > square) {
tmp = square; tmp = square;
goto failed_syntax; goto failed_syntax;
} }
tmp = strchr(square, ']'); tmp = strchr(square, ']');
if (tmp == NULL) { if (!tmp) {
tmp = square; tmp = square;
goto failed_syntax; goto failed_syntax;
} }
...@@ -249,11 +249,10 @@ lnet_parse_networks(struct list_head *nilist, char *networks) ...@@ -249,11 +249,10 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
*square++ = ' '; *square++ = ' ';
} }
if (bracket == NULL || if (!bracket || (comma && comma < bracket)) {
(comma != NULL && comma < bracket)) {
/* no interface list specified */ /* no interface list specified */
if (comma != NULL) if (comma)
*comma++ = 0; *comma++ = 0;
net = libcfs_str2net(cfs_trimwhite(str)); net = libcfs_str2net(cfs_trimwhite(str));
...@@ -265,10 +264,10 @@ lnet_parse_networks(struct list_head *nilist, char *networks) ...@@ -265,10 +264,10 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
} }
if (LNET_NETTYP(net) != LOLND && /* LO is implicit */ if (LNET_NETTYP(net) != LOLND && /* LO is implicit */
lnet_ni_alloc(net, el, nilist) == NULL) !lnet_ni_alloc(net, el, nilist))
goto failed; goto failed;
if (el != NULL) { if (el) {
cfs_expr_list_free(el); cfs_expr_list_free(el);
el = NULL; el = NULL;
} }
...@@ -286,10 +285,10 @@ lnet_parse_networks(struct list_head *nilist, char *networks) ...@@ -286,10 +285,10 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
nnets++; nnets++;
ni = lnet_ni_alloc(net, el, nilist); ni = lnet_ni_alloc(net, el, nilist);
if (ni == NULL) if (!ni)
goto failed; goto failed;
if (el != NULL) { if (el) {
cfs_expr_list_free(el); cfs_expr_list_free(el);
el = NULL; el = NULL;
} }
...@@ -298,7 +297,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks) ...@@ -298,7 +297,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
iface = bracket + 1; iface = bracket + 1;
bracket = strchr(iface, ')'); bracket = strchr(iface, ')');
if (bracket == NULL) { if (!bracket) {
tmp = iface; tmp = iface;
goto failed_syntax; goto failed_syntax;
} }
...@@ -306,7 +305,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks) ...@@ -306,7 +305,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
*bracket = 0; *bracket = 0;
do { do {
comma = strchr(iface, ','); comma = strchr(iface, ',');
if (comma != NULL) if (comma)
*comma++ = 0; *comma++ = 0;
iface = cfs_trimwhite(iface); iface = cfs_trimwhite(iface);
...@@ -324,11 +323,11 @@ lnet_parse_networks(struct list_head *nilist, char *networks) ...@@ -324,11 +323,11 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
ni->ni_interfaces[niface++] = iface; ni->ni_interfaces[niface++] = iface;
iface = comma; iface = comma;
} while (iface != NULL); } while (iface);
str = bracket + 1; str = bracket + 1;
comma = strchr(bracket + 1, ','); comma = strchr(bracket + 1, ',');
if (comma != NULL) { if (comma) {
*comma = 0; *comma = 0;
str = cfs_trimwhite(str); str = cfs_trimwhite(str);
if (*str != 0) { if (*str != 0) {
...@@ -359,7 +358,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks) ...@@ -359,7 +358,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
lnet_ni_free(ni); lnet_ni_free(ni);
} }
if (el != NULL) if (el)
cfs_expr_list_free(el); cfs_expr_list_free(el);
LIBCFS_FREE(tokens, tokensize); LIBCFS_FREE(tokens, tokensize);
...@@ -388,7 +387,7 @@ lnet_new_text_buf(int str_len) ...@@ -388,7 +387,7 @@ lnet_new_text_buf(int str_len)
} }
LIBCFS_ALLOC(ltb, nob); LIBCFS_ALLOC(ltb, nob);
if (ltb == NULL) if (!ltb)
return NULL; return NULL;
ltb->ltb_size = nob; ltb->ltb_size = nob;
...@@ -442,7 +441,7 @@ lnet_str2tbs_sep(struct list_head *tbs, char *str) ...@@ -442,7 +441,7 @@ lnet_str2tbs_sep(struct list_head *tbs, char *str)
nob = (int)(sep - str); nob = (int)(sep - str);
if (nob > 0) { if (nob > 0) {
ltb = lnet_new_text_buf(nob); ltb = lnet_new_text_buf(nob);
if (ltb == NULL) { if (!ltb) {
lnet_free_text_bufs(&pending); lnet_free_text_bufs(&pending);
return -1; return -1;
} }
...@@ -488,7 +487,7 @@ lnet_expand1tb(struct list_head *list, ...@@ -488,7 +487,7 @@ lnet_expand1tb(struct list_head *list,
LASSERT(*sep2 == ']'); LASSERT(*sep2 == ']');
ltb = lnet_new_text_buf(len1 + itemlen + len2); ltb = lnet_new_text_buf(len1 + itemlen + len2);
if (ltb == NULL) if (!ltb)
return -ENOMEM; return -ENOMEM;
memcpy(ltb->ltb_text, str, len1); memcpy(ltb->ltb_text, str, len1);
...@@ -519,11 +518,11 @@ lnet_str2tbs_expand(struct list_head *tbs, char *str) ...@@ -519,11 +518,11 @@ lnet_str2tbs_expand(struct list_head *tbs, char *str)
INIT_LIST_HEAD(&pending); INIT_LIST_HEAD(&pending);
sep = strchr(str, '['); sep = strchr(str, '[');
if (sep == NULL) /* nothing to expand */ if (!sep) /* nothing to expand */
return 0; return 0;
sep2 = strchr(sep, ']'); sep2 = strchr(sep, ']');
if (sep2 == NULL) if (!sep2)
goto failed; goto failed;
for (parsed = sep; parsed < sep2; parsed = enditem) { for (parsed = sep; parsed < sep2; parsed = enditem) {
...@@ -599,7 +598,7 @@ lnet_parse_priority(char *str, unsigned int *priority, char **token) ...@@ -599,7 +598,7 @@ lnet_parse_priority(char *str, unsigned int *priority, char **token)
int len; int len;
sep = strchr(str, LNET_PRIORITY_SEPARATOR); sep = strchr(str, LNET_PRIORITY_SEPARATOR);
if (sep == NULL) { if (!sep) {
*priority = 0; *priority = 0;
return 0; return 0;
} }
...@@ -683,7 +682,7 @@ lnet_parse_route(char *str, int *im_a_router) ...@@ -683,7 +682,7 @@ lnet_parse_route(char *str, int *im_a_router)
} }
ltb = lnet_new_text_buf(strlen(token)); ltb = lnet_new_text_buf(strlen(token));
if (ltb == NULL) if (!ltb)
goto out; goto out;
strcpy(ltb->ltb_text, token); strcpy(ltb->ltb_text, token);
...@@ -889,12 +888,12 @@ lnet_netspec2net(char *netspec) ...@@ -889,12 +888,12 @@ lnet_netspec2net(char *netspec)
char *bracket = strchr(netspec, '('); char *bracket = strchr(netspec, '(');
__u32 net; __u32 net;
if (bracket != NULL) if (bracket)
*bracket = 0; *bracket = 0;
net = libcfs_str2net(netspec); net = libcfs_str2net(netspec);
if (bracket != NULL) if (bracket)
*bracket = '('; *bracket = '(';
return net; return net;
...@@ -922,9 +921,7 @@ lnet_splitnets(char *source, struct list_head *nets) ...@@ -922,9 +921,7 @@ lnet_splitnets(char *source, struct list_head *nets)
sep = strchr(tb->ltb_text, ','); sep = strchr(tb->ltb_text, ',');
bracket = strchr(tb->ltb_text, '('); bracket = strchr(tb->ltb_text, '(');
if (sep != NULL && if (sep && bracket && bracket < sep) {
bracket != NULL &&
bracket < sep) {
/* netspec lists interfaces... */ /* netspec lists interfaces... */
offset2 = offset + (int)(bracket - tb->ltb_text); offset2 = offset + (int)(bracket - tb->ltb_text);
...@@ -932,7 +929,7 @@ lnet_splitnets(char *source, struct list_head *nets) ...@@ -932,7 +929,7 @@ lnet_splitnets(char *source, struct list_head *nets)
bracket = strchr(bracket + 1, ')'); bracket = strchr(bracket + 1, ')');
if (bracket == NULL || if (!bracket ||
!(bracket[1] == ',' || bracket[1] == 0)) { !(bracket[1] == ',' || bracket[1] == 0)) {
lnet_syntax("ip2nets", source, offset2, len); lnet_syntax("ip2nets", source, offset2, len);
return -EINVAL; return -EINVAL;
...@@ -941,7 +938,7 @@ lnet_splitnets(char *source, struct list_head *nets) ...@@ -941,7 +938,7 @@ lnet_splitnets(char *source, struct list_head *nets)
sep = (bracket[1] == 0) ? NULL : bracket + 1; sep = (bracket[1] == 0) ? NULL : bracket + 1;
} }
if (sep != NULL) if (sep)
*sep++ = 0; *sep++ = 0;
net = lnet_netspec2net(tb->ltb_text); net = lnet_netspec2net(tb->ltb_text);
...@@ -965,13 +962,13 @@ lnet_splitnets(char *source, struct list_head *nets) ...@@ -965,13 +962,13 @@ lnet_splitnets(char *source, struct list_head *nets)
} }
} }
if (sep == NULL) if (!sep)
return 0; return 0;
offset += (int)(sep - tb->ltb_text); offset += (int)(sep - tb->ltb_text);
len = strlen(sep); len = strlen(sep);
tb2 = lnet_new_text_buf(len); tb2 = lnet_new_text_buf(len);
if (tb2 == NULL) if (!tb2)
return -ENOMEM; return -ENOMEM;
strncpy(tb2->ltb_text, sep, len); strncpy(tb2->ltb_text, sep, len);
...@@ -1118,7 +1115,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp) ...@@ -1118,7 +1115,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
return nif; return nif;
LIBCFS_ALLOC(ipaddrs, nif * sizeof(*ipaddrs)); LIBCFS_ALLOC(ipaddrs, nif * sizeof(*ipaddrs));
if (ipaddrs == NULL) { if (!ipaddrs) {
CERROR("Can't allocate ipaddrs[%d]\n", nif); CERROR("Can't allocate ipaddrs[%d]\n", nif);
lnet_ipif_free_enumeration(ifnames, nif); lnet_ipif_free_enumeration(ifnames, nif);
return -ENOMEM; return -ENOMEM;
...@@ -1151,7 +1148,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp) ...@@ -1151,7 +1148,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
} else { } else {
if (nip > 0) { if (nip > 0) {
LIBCFS_ALLOC(ipaddrs2, nip * sizeof(*ipaddrs2)); LIBCFS_ALLOC(ipaddrs2, nip * sizeof(*ipaddrs2));
if (ipaddrs2 == NULL) { if (!ipaddrs2) {
CERROR("Can't allocate ipaddrs[%d]\n", nip); CERROR("Can't allocate ipaddrs[%d]\n", nip);
nip = -ENOMEM; nip = -ENOMEM;
} else { } else {
......
...@@ -94,12 +94,12 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback, ...@@ -94,12 +94,12 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback,
return -EINVAL; return -EINVAL;
eq = lnet_eq_alloc(); eq = lnet_eq_alloc();
if (eq == NULL) if (!eq)
return -ENOMEM; return -ENOMEM;
if (count != 0) { if (count != 0) {
LIBCFS_ALLOC(eq->eq_events, count * sizeof(lnet_event_t)); LIBCFS_ALLOC(eq->eq_events, count * sizeof(lnet_event_t));
if (eq->eq_events == NULL) if (!eq->eq_events)
goto failed; goto failed;
/* /*
* NB allocator has set all event sequence numbers to 0, * NB allocator has set all event sequence numbers to 0,
...@@ -114,7 +114,7 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback, ...@@ -114,7 +114,7 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback,
eq->eq_refs = cfs_percpt_alloc(lnet_cpt_table(), eq->eq_refs = cfs_percpt_alloc(lnet_cpt_table(),
sizeof(*eq->eq_refs[0])); sizeof(*eq->eq_refs[0]));
if (eq->eq_refs == NULL) if (!eq->eq_refs)
goto failed; goto failed;
/* MUST hold both exclusive lnet_res_lock */ /* MUST hold both exclusive lnet_res_lock */
...@@ -135,10 +135,10 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback, ...@@ -135,10 +135,10 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback,
return 0; return 0;
failed: failed:
if (eq->eq_events != NULL) if (eq->eq_events)
LIBCFS_FREE(eq->eq_events, count * sizeof(lnet_event_t)); LIBCFS_FREE(eq->eq_events, count * sizeof(lnet_event_t));
if (eq->eq_refs != NULL) if (eq->eq_refs)
cfs_percpt_free(eq->eq_refs); cfs_percpt_free(eq->eq_refs);
lnet_eq_free(eq); lnet_eq_free(eq);
...@@ -178,7 +178,7 @@ LNetEQFree(lnet_handle_eq_t eqh) ...@@ -178,7 +178,7 @@ LNetEQFree(lnet_handle_eq_t eqh)
lnet_eq_wait_lock(); lnet_eq_wait_lock();
eq = lnet_handle2eq(&eqh); eq = lnet_handle2eq(&eqh);
if (eq == NULL) { if (!eq) {
rc = -ENOENT; rc = -ENOENT;
goto out; goto out;
} }
...@@ -206,9 +206,9 @@ LNetEQFree(lnet_handle_eq_t eqh) ...@@ -206,9 +206,9 @@ LNetEQFree(lnet_handle_eq_t eqh)
lnet_eq_wait_unlock(); lnet_eq_wait_unlock();
lnet_res_unlock(LNET_LOCK_EX); lnet_res_unlock(LNET_LOCK_EX);
if (events != NULL) if (events)
LIBCFS_FREE(events, size * sizeof(lnet_event_t)); LIBCFS_FREE(events, size * sizeof(lnet_event_t));
if (refs != NULL) if (refs)
cfs_percpt_free(refs); cfs_percpt_free(refs);
return rc; return rc;
...@@ -395,7 +395,7 @@ LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms, ...@@ -395,7 +395,7 @@ LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms,
for (i = 0; i < neq; i++) { for (i = 0; i < neq; i++) {
lnet_eq_t *eq = lnet_handle2eq(&eventqs[i]); lnet_eq_t *eq = lnet_handle2eq(&eventqs[i]);
if (eq == NULL) { if (!eq) {
lnet_eq_wait_unlock(); lnet_eq_wait_unlock();
return -ENOENT; return -ENOENT;
} }
......
...@@ -57,7 +57,7 @@ lnet_md_unlink(lnet_libmd_t *md) ...@@ -57,7 +57,7 @@ lnet_md_unlink(lnet_libmd_t *md)
* and unlink it if it was created * and unlink it if it was created
* with LNET_UNLINK * with LNET_UNLINK
*/ */
if (me != NULL) { if (me) {
/* detach MD from portal */ /* detach MD from portal */
lnet_ptl_detach_md(me, md); lnet_ptl_detach_md(me, md);
if (me->me_unlink == LNET_UNLINK) if (me->me_unlink == LNET_UNLINK)
...@@ -75,7 +75,7 @@ lnet_md_unlink(lnet_libmd_t *md) ...@@ -75,7 +75,7 @@ lnet_md_unlink(lnet_libmd_t *md)
CDEBUG(D_NET, "Unlinking md %p\n", md); CDEBUG(D_NET, "Unlinking md %p\n", md);
if (md->md_eq != NULL) { if (md->md_eq) {
int cpt = lnet_cpt_of_cookie(md->md_lh.lh_cookie); int cpt = lnet_cpt_of_cookie(md->md_lh.lh_cookie);
LASSERT(*md->md_eq->eq_refs[cpt] > 0); LASSERT(*md->md_eq->eq_refs[cpt] > 0);
...@@ -187,7 +187,7 @@ lnet_md_link(lnet_libmd_t *md, lnet_handle_eq_t eq_handle, int cpt) ...@@ -187,7 +187,7 @@ lnet_md_link(lnet_libmd_t *md, lnet_handle_eq_t eq_handle, int cpt)
* TODO - reevaluate what should be here in light of * TODO - reevaluate what should be here in light of
* the removal of the start and end events * the removal of the start and end events
* maybe there we shouldn't even allow LNET_EQ_NONE!) * maybe there we shouldn't even allow LNET_EQ_NONE!)
* LASSERT (eq == NULL); * LASSERT(!eq);
*/ */
if (!LNetHandleIsInvalid(eq_handle)) { if (!LNetHandleIsInvalid(eq_handle)) {
md->md_eq = lnet_handle2eq(&eq_handle); md->md_eq = lnet_handle2eq(&eq_handle);
...@@ -306,7 +306,7 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd, ...@@ -306,7 +306,7 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd,
me = lnet_handle2me(&meh); me = lnet_handle2me(&meh);
if (!me) if (!me)
rc = -ENOENT; rc = -ENOENT;
else if (me->me_md != NULL) else if (me->me_md)
rc = -EBUSY; rc = -EBUSY;
else else
rc = lnet_md_link(md, umd.eq_handle, cpt); rc = lnet_md_link(md, umd.eq_handle, cpt);
...@@ -453,7 +453,7 @@ LNetMDUnlink(lnet_handle_md_t mdh) ...@@ -453,7 +453,7 @@ LNetMDUnlink(lnet_handle_md_t mdh)
* when the LND is done, the completion event flags that the MD was * when the LND is done, the completion event flags that the MD was
* unlinked. Otherwise, we enqueue an event now... * unlinked. Otherwise, we enqueue an event now...
*/ */
if (md->md_eq != NULL && md->md_refcount == 0) { if (md->md_eq && md->md_refcount == 0) {
lnet_build_unlink_event(md, &ev); lnet_build_unlink_event(md, &ev);
lnet_eq_enqueue_event(md->md_eq, &ev); lnet_eq_enqueue_event(md->md_eq, &ev);
} }
......
...@@ -91,11 +91,11 @@ LNetMEAttach(unsigned int portal, ...@@ -91,11 +91,11 @@ LNetMEAttach(unsigned int portal,
mtable = lnet_mt_of_attach(portal, match_id, mtable = lnet_mt_of_attach(portal, match_id,
match_bits, ignore_bits, pos); match_bits, ignore_bits, pos);
if (mtable == NULL) /* can't match portal type */ if (!mtable) /* can't match portal type */
return -EPERM; return -EPERM;
me = lnet_me_alloc(); me = lnet_me_alloc();
if (me == NULL) if (!me)
return -ENOMEM; return -ENOMEM;
lnet_res_lock(mtable->mt_cpt); lnet_res_lock(mtable->mt_cpt);
...@@ -163,7 +163,7 @@ LNetMEInsert(lnet_handle_me_t current_meh, ...@@ -163,7 +163,7 @@ LNetMEInsert(lnet_handle_me_t current_meh,
return -EPERM; return -EPERM;
new_me = lnet_me_alloc(); new_me = lnet_me_alloc();
if (new_me == NULL) if (!new_me)
return -ENOMEM; return -ENOMEM;
cpt = lnet_cpt_of_cookie(current_meh.cookie); cpt = lnet_cpt_of_cookie(current_meh.cookie);
...@@ -171,7 +171,7 @@ LNetMEInsert(lnet_handle_me_t current_meh, ...@@ -171,7 +171,7 @@ LNetMEInsert(lnet_handle_me_t current_meh,
lnet_res_lock(cpt); lnet_res_lock(cpt);
current_me = lnet_handle2me(&current_meh); current_me = lnet_handle2me(&current_meh);
if (current_me == NULL) { if (!current_me) {
lnet_me_free(new_me); lnet_me_free(new_me);
lnet_res_unlock(cpt); lnet_res_unlock(cpt);
...@@ -240,15 +240,15 @@ LNetMEUnlink(lnet_handle_me_t meh) ...@@ -240,15 +240,15 @@ LNetMEUnlink(lnet_handle_me_t meh)
lnet_res_lock(cpt); lnet_res_lock(cpt);
me = lnet_handle2me(&meh); me = lnet_handle2me(&meh);
if (me == NULL) { if (!me) {
lnet_res_unlock(cpt); lnet_res_unlock(cpt);
return -ENOENT; return -ENOENT;
} }
md = me->me_md; md = me->me_md;
if (md != NULL) { if (md) {
md->md_flags |= LNET_MD_FLAG_ABORTED; md->md_flags |= LNET_MD_FLAG_ABORTED;
if (md->md_eq != NULL && md->md_refcount == 0) { if (md->md_eq && md->md_refcount == 0) {
lnet_build_unlink_event(md, &ev); lnet_build_unlink_event(md, &ev);
lnet_eq_enqueue_event(md->md_eq, &ev); lnet_eq_enqueue_event(md->md_eq, &ev);
} }
...@@ -267,7 +267,7 @@ lnet_me_unlink(lnet_me_t *me) ...@@ -267,7 +267,7 @@ lnet_me_unlink(lnet_me_t *me)
{ {
list_del(&me->me_list); list_del(&me->me_list);
if (me->me_md != NULL) { if (me->me_md) {
lnet_libmd_t *md = me->me_md; lnet_libmd_t *md = me->me_md;
/* detach MD from portal of this ME */ /* detach MD from portal of this ME */
......
This diff is collapsed.
...@@ -350,7 +350,7 @@ lnet_msg_detach_md(lnet_msg_t *msg, int status) ...@@ -350,7 +350,7 @@ lnet_msg_detach_md(lnet_msg_t *msg, int status)
LASSERT(md->md_refcount >= 0); LASSERT(md->md_refcount >= 0);
unlink = lnet_md_unlinkable(md); unlink = lnet_md_unlinkable(md);
if (md->md_eq != NULL) { if (md->md_eq) {
msg->msg_ev.status = status; msg->msg_ev.status = status;
msg->msg_ev.unlinked = unlink; msg->msg_ev.unlinked = unlink;
lnet_eq_enqueue_event(md->md_eq, &msg->msg_ev); lnet_eq_enqueue_event(md->md_eq, &msg->msg_ev);
...@@ -451,7 +451,7 @@ lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int status) ...@@ -451,7 +451,7 @@ lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int status)
LASSERT(!in_interrupt()); LASSERT(!in_interrupt());
if (msg == NULL) if (!msg)
return; return;
#if 0 #if 0
CDEBUG(D_WARNING, "%s msg->%s Flags:%s%s%s%s%s%s%s%s%s%s%s txp %s rxp %s\n", CDEBUG(D_WARNING, "%s msg->%s Flags:%s%s%s%s%s%s%s%s%s%s%s txp %s rxp %s\n",
...@@ -467,12 +467,12 @@ lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int status) ...@@ -467,12 +467,12 @@ lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int status)
msg->msg_rtrcredit ? "F" : "", msg->msg_rtrcredit ? "F" : "",
msg->msg_peerrtrcredit ? "f" : "", msg->msg_peerrtrcredit ? "f" : "",
msg->msg_onactivelist ? "!" : "", msg->msg_onactivelist ? "!" : "",
msg->msg_txpeer == NULL ? "<none>" : libcfs_nid2str(msg->msg_txpeer->lp_nid), !msg->msg_txpeer ? "<none>" : libcfs_nid2str(msg->msg_txpeer->lp_nid),
msg->msg_rxpeer == NULL ? "<none>" : libcfs_nid2str(msg->msg_rxpeer->lp_nid)); !msg->msg_rxpeer ? "<none>" : libcfs_nid2str(msg->msg_rxpeer->lp_nid));
#endif #endif
msg->msg_ev.status = status; msg->msg_ev.status = status;
if (msg->msg_md != NULL) { if (msg->msg_md) {
cpt = lnet_cpt_of_cookie(msg->msg_md->md_lh.lh_cookie); cpt = lnet_cpt_of_cookie(msg->msg_md->md_lh.lh_cookie);
lnet_res_lock(cpt); lnet_res_lock(cpt);
...@@ -509,7 +509,7 @@ lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int status) ...@@ -509,7 +509,7 @@ lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int status)
if (container->msc_finalizers[i] == current) if (container->msc_finalizers[i] == current)
break; break;
if (my_slot < 0 && container->msc_finalizers[i] == NULL) if (my_slot < 0 && !container->msc_finalizers[i])
my_slot = i; my_slot = i;
} }
...@@ -565,7 +565,7 @@ lnet_msg_container_cleanup(struct lnet_msg_container *container) ...@@ -565,7 +565,7 @@ lnet_msg_container_cleanup(struct lnet_msg_container *container)
if (count > 0) if (count > 0)
CERROR("%d active msg on exit\n", count); CERROR("%d active msg on exit\n", count);
if (container->msc_finalizers != NULL) { if (container->msc_finalizers) {
LIBCFS_FREE(container->msc_finalizers, LIBCFS_FREE(container->msc_finalizers,
container->msc_nfinalizers * container->msc_nfinalizers *
sizeof(*container->msc_finalizers)); sizeof(*container->msc_finalizers));
...@@ -607,7 +607,7 @@ lnet_msg_container_setup(struct lnet_msg_container *container, int cpt) ...@@ -607,7 +607,7 @@ lnet_msg_container_setup(struct lnet_msg_container *container, int cpt)
container->msc_nfinalizers * container->msc_nfinalizers *
sizeof(*container->msc_finalizers)); sizeof(*container->msc_finalizers));
if (container->msc_finalizers == NULL) { if (!container->msc_finalizers) {
CERROR("Failed to allocate message finalizers\n"); CERROR("Failed to allocate message finalizers\n");
lnet_msg_container_cleanup(container); lnet_msg_container_cleanup(container);
return -ENOMEM; return -ENOMEM;
...@@ -622,7 +622,7 @@ lnet_msg_containers_destroy(void) ...@@ -622,7 +622,7 @@ lnet_msg_containers_destroy(void)
struct lnet_msg_container *container; struct lnet_msg_container *container;
int i; int i;
if (the_lnet.ln_msg_containers == NULL) if (!the_lnet.ln_msg_containers)
return; return;
cfs_percpt_for_each(container, i, the_lnet.ln_msg_containers) cfs_percpt_for_each(container, i, the_lnet.ln_msg_containers)
...@@ -642,7 +642,7 @@ lnet_msg_containers_create(void) ...@@ -642,7 +642,7 @@ lnet_msg_containers_create(void)
the_lnet.ln_msg_containers = cfs_percpt_alloc(lnet_cpt_table(), the_lnet.ln_msg_containers = cfs_percpt_alloc(lnet_cpt_table(),
sizeof(*container)); sizeof(*container));
if (the_lnet.ln_msg_containers == NULL) { if (!the_lnet.ln_msg_containers) {
CERROR("Failed to allocate cpu-partition data for network\n"); CERROR("Failed to allocate cpu-partition data for network\n");
return -ENOMEM; return -ENOMEM;
} }
......
...@@ -243,7 +243,7 @@ lnet_mt_of_attach(unsigned int index, lnet_process_id_t id, ...@@ -243,7 +243,7 @@ lnet_mt_of_attach(unsigned int index, lnet_process_id_t id,
ptl = the_lnet.ln_portals[index]; ptl = the_lnet.ln_portals[index];
mtable = lnet_match2mt(ptl, id, mbits); mtable = lnet_match2mt(ptl, id, mbits);
if (mtable != NULL) /* unique portal or only one match-table */ if (mtable) /* unique portal or only one match-table */
return mtable; return mtable;
/* it's a wildcard portal */ /* it's a wildcard portal */
...@@ -280,7 +280,7 @@ lnet_mt_of_match(struct lnet_match_info *info, struct lnet_msg *msg) ...@@ -280,7 +280,7 @@ lnet_mt_of_match(struct lnet_match_info *info, struct lnet_msg *msg)
LASSERT(lnet_ptl_is_wildcard(ptl) || lnet_ptl_is_unique(ptl)); LASSERT(lnet_ptl_is_wildcard(ptl) || lnet_ptl_is_unique(ptl));
mtable = lnet_match2mt(ptl, info->mi_id, info->mi_mbits); mtable = lnet_match2mt(ptl, info->mi_id, info->mi_mbits);
if (mtable != NULL) if (mtable)
return mtable; return mtable;
/* it's a wildcard portal */ /* it's a wildcard portal */
...@@ -399,7 +399,7 @@ lnet_mt_match_md(struct lnet_match_table *mtable, ...@@ -399,7 +399,7 @@ lnet_mt_match_md(struct lnet_match_table *mtable,
list_for_each_entry_safe(me, tmp, head, me_list) { list_for_each_entry_safe(me, tmp, head, me_list) {
/* ME attached but MD not attached yet */ /* ME attached but MD not attached yet */
if (me->me_md == NULL) if (!me->me_md)
continue; continue;
LASSERT(me == me->me_md->md_me); LASSERT(me == me->me_md->md_me);
...@@ -516,7 +516,7 @@ lnet_ptl_match_delay(struct lnet_portal *ptl, ...@@ -516,7 +516,7 @@ lnet_ptl_match_delay(struct lnet_portal *ptl,
* could be matched by lnet_ptl_attach_md() * could be matched by lnet_ptl_attach_md()
* which is called by another thread * which is called by another thread
*/ */
rc = msg->msg_md == NULL ? rc = !msg->msg_md ?
LNET_MATCHMD_DROP : LNET_MATCHMD_OK; LNET_MATCHMD_DROP : LNET_MATCHMD_OK;
} }
...@@ -733,7 +733,7 @@ lnet_ptl_cleanup(struct lnet_portal *ptl) ...@@ -733,7 +733,7 @@ lnet_ptl_cleanup(struct lnet_portal *ptl)
struct lnet_match_table *mtable; struct lnet_match_table *mtable;
int i; int i;
if (ptl->ptl_mtables == NULL) /* uninitialized portal */ if (!ptl->ptl_mtables) /* uninitialized portal */
return; return;
LASSERT(list_empty(&ptl->ptl_msg_delayed)); LASSERT(list_empty(&ptl->ptl_msg_delayed));
...@@ -743,7 +743,7 @@ lnet_ptl_cleanup(struct lnet_portal *ptl) ...@@ -743,7 +743,7 @@ lnet_ptl_cleanup(struct lnet_portal *ptl)
lnet_me_t *me; lnet_me_t *me;
int j; int j;
if (mtable->mt_mhash == NULL) /* uninitialized match-table */ if (!mtable->mt_mhash) /* uninitialized match-table */
continue; continue;
mhash = mtable->mt_mhash; mhash = mtable->mt_mhash;
...@@ -775,7 +775,7 @@ lnet_ptl_setup(struct lnet_portal *ptl, int index) ...@@ -775,7 +775,7 @@ lnet_ptl_setup(struct lnet_portal *ptl, int index)
ptl->ptl_mtables = cfs_percpt_alloc(lnet_cpt_table(), ptl->ptl_mtables = cfs_percpt_alloc(lnet_cpt_table(),
sizeof(struct lnet_match_table)); sizeof(struct lnet_match_table));
if (ptl->ptl_mtables == NULL) { if (!ptl->ptl_mtables) {
CERROR("Failed to create match table for portal %d\n", index); CERROR("Failed to create match table for portal %d\n", index);
return -ENOMEM; return -ENOMEM;
} }
...@@ -788,7 +788,7 @@ lnet_ptl_setup(struct lnet_portal *ptl, int index) ...@@ -788,7 +788,7 @@ lnet_ptl_setup(struct lnet_portal *ptl, int index)
/* the extra entry is for MEs with ignore bits */ /* the extra entry is for MEs with ignore bits */
LIBCFS_CPT_ALLOC(mhash, lnet_cpt_table(), i, LIBCFS_CPT_ALLOC(mhash, lnet_cpt_table(), i,
sizeof(*mhash) * (LNET_MT_HASH_SIZE + 1)); sizeof(*mhash) * (LNET_MT_HASH_SIZE + 1));
if (mhash == NULL) { if (!mhash) {
CERROR("Failed to create match hash for portal %d\n", CERROR("Failed to create match hash for portal %d\n",
index); index);
goto failed; goto failed;
...@@ -816,7 +816,7 @@ lnet_portals_destroy(void) ...@@ -816,7 +816,7 @@ lnet_portals_destroy(void)
{ {
int i; int i;
if (the_lnet.ln_portals == NULL) if (!the_lnet.ln_portals)
return; return;
for (i = 0; i < the_lnet.ln_nportals; i++) for (i = 0; i < the_lnet.ln_nportals; i++)
...@@ -836,7 +836,7 @@ lnet_portals_create(void) ...@@ -836,7 +836,7 @@ lnet_portals_create(void)
the_lnet.ln_nportals = MAX_PORTALS; the_lnet.ln_nportals = MAX_PORTALS;
the_lnet.ln_portals = cfs_array_alloc(the_lnet.ln_nportals, size); the_lnet.ln_portals = cfs_array_alloc(the_lnet.ln_nportals, size);
if (the_lnet.ln_portals == NULL) { if (!the_lnet.ln_portals) {
CERROR("Failed to allocate portals table\n"); CERROR("Failed to allocate portals table\n");
return -ENOMEM; return -ENOMEM;
} }
......
...@@ -165,7 +165,7 @@ lnet_ipif_enumerate(char ***namesp) ...@@ -165,7 +165,7 @@ lnet_ipif_enumerate(char ***namesp)
} }
LIBCFS_ALLOC(ifr, nalloc * sizeof(*ifr)); LIBCFS_ALLOC(ifr, nalloc * sizeof(*ifr));
if (ifr == NULL) { if (!ifr) {
CERROR("ENOMEM enumerating up to %d interfaces\n", CERROR("ENOMEM enumerating up to %d interfaces\n",
nalloc); nalloc);
rc = -ENOMEM; rc = -ENOMEM;
...@@ -197,7 +197,7 @@ lnet_ipif_enumerate(char ***namesp) ...@@ -197,7 +197,7 @@ lnet_ipif_enumerate(char ***namesp)
goto out1; goto out1;
LIBCFS_ALLOC(names, nfound * sizeof(*names)); LIBCFS_ALLOC(names, nfound * sizeof(*names));
if (names == NULL) { if (!names) {
rc = -ENOMEM; rc = -ENOMEM;
goto out1; goto out1;
} }
...@@ -213,7 +213,7 @@ lnet_ipif_enumerate(char ***namesp) ...@@ -213,7 +213,7 @@ lnet_ipif_enumerate(char ***namesp)
} }
LIBCFS_ALLOC(names[i], IFNAMSIZ); LIBCFS_ALLOC(names[i], IFNAMSIZ);
if (names[i] == NULL) { if (!names[i]) {
rc = -ENOMEM; rc = -ENOMEM;
goto out2; goto out2;
} }
...@@ -242,7 +242,7 @@ lnet_ipif_free_enumeration(char **names, int n) ...@@ -242,7 +242,7 @@ lnet_ipif_free_enumeration(char **names, int n)
LASSERT(n > 0); LASSERT(n > 0);
for (i = 0; i < n && names[i] != NULL; i++) for (i = 0; i < n && names[i]; i++)
LIBCFS_FREE(names[i], IFNAMSIZ); LIBCFS_FREE(names[i], IFNAMSIZ);
LIBCFS_FREE(names, n * sizeof(*names)); LIBCFS_FREE(names, n * sizeof(*names));
...@@ -468,10 +468,10 @@ lnet_sock_getaddr(struct socket *sock, bool remote, __u32 *ip, int *port) ...@@ -468,10 +468,10 @@ lnet_sock_getaddr(struct socket *sock, bool remote, __u32 *ip, int *port)
return rc; return rc;
} }
if (ip != NULL) if (ip)
*ip = ntohl(sin.sin_addr.s_addr); *ip = ntohl(sin.sin_addr.s_addr);
if (port != NULL) if (port)
*port = ntohs(sin.sin_port); *port = ntohs(sin.sin_port);
return 0; return 0;
...@@ -481,10 +481,10 @@ EXPORT_SYMBOL(lnet_sock_getaddr); ...@@ -481,10 +481,10 @@ EXPORT_SYMBOL(lnet_sock_getaddr);
int int
lnet_sock_getbuf(struct socket *sock, int *txbufsize, int *rxbufsize) lnet_sock_getbuf(struct socket *sock, int *txbufsize, int *rxbufsize)
{ {
if (txbufsize != NULL) if (txbufsize)
*txbufsize = sock->sk->sk_sndbuf; *txbufsize = sock->sk->sk_sndbuf;
if (rxbufsize != NULL) if (rxbufsize)
*rxbufsize = sock->sk->sk_rcvbuf; *rxbufsize = sock->sk->sk_rcvbuf;
return 0; return 0;
......
...@@ -52,9 +52,9 @@ lolnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, ...@@ -52,9 +52,9 @@ lolnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
{ {
lnet_msg_t *sendmsg = private; lnet_msg_t *sendmsg = private;
if (lntmsg != NULL) { /* not discarding */ if (lntmsg) { /* not discarding */
if (sendmsg->msg_iov != NULL) { if (sendmsg->msg_iov) {
if (iov != NULL) if (iov)
lnet_copy_iov2iov(niov, iov, offset, lnet_copy_iov2iov(niov, iov, offset,
sendmsg->msg_niov, sendmsg->msg_niov,
sendmsg->msg_iov, sendmsg->msg_iov,
...@@ -65,7 +65,7 @@ lolnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, ...@@ -65,7 +65,7 @@ lolnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
sendmsg->msg_iov, sendmsg->msg_iov,
sendmsg->msg_offset, mlen); sendmsg->msg_offset, mlen);
} else { } else {
if (iov != NULL) if (iov)
lnet_copy_kiov2iov(niov, iov, offset, lnet_copy_kiov2iov(niov, iov, offset,
sendmsg->msg_niov, sendmsg->msg_niov,
sendmsg->msg_kiov, sendmsg->msg_kiov,
......
...@@ -170,7 +170,7 @@ parse_addrange(const struct cfs_lstr *src, struct nidrange *nidrange) ...@@ -170,7 +170,7 @@ parse_addrange(const struct cfs_lstr *src, struct nidrange *nidrange)
} }
LIBCFS_ALLOC(addrrange, sizeof(struct addrrange)); LIBCFS_ALLOC(addrrange, sizeof(struct addrrange));
if (addrrange == NULL) if (!addrrange)
return -ENOMEM; return -ENOMEM;
list_add_tail(&addrrange->ar_link, &nidrange->nr_addrranges); list_add_tail(&addrrange->ar_link, &nidrange->nr_addrranges);
INIT_LIST_HEAD(&addrrange->ar_numaddr_ranges); INIT_LIST_HEAD(&addrrange->ar_numaddr_ranges);
...@@ -203,7 +203,7 @@ add_nidrange(const struct cfs_lstr *src, ...@@ -203,7 +203,7 @@ add_nidrange(const struct cfs_lstr *src,
return NULL; return NULL;
nf = libcfs_namenum2netstrfns(src->ls_str); nf = libcfs_namenum2netstrfns(src->ls_str);
if (nf == NULL) if (!nf)
return NULL; return NULL;
endlen = src->ls_len - strlen(nf->nf_name); endlen = src->ls_len - strlen(nf->nf_name);
if (endlen == 0) if (endlen == 0)
...@@ -229,7 +229,7 @@ add_nidrange(const struct cfs_lstr *src, ...@@ -229,7 +229,7 @@ add_nidrange(const struct cfs_lstr *src,
} }
LIBCFS_ALLOC(nr, sizeof(struct nidrange)); LIBCFS_ALLOC(nr, sizeof(struct nidrange));
if (nr == NULL) if (!nr)
return NULL; return NULL;
list_add_tail(&nr->nr_link, nidlist); list_add_tail(&nr->nr_link, nidlist);
INIT_LIST_HEAD(&nr->nr_addrranges); INIT_LIST_HEAD(&nr->nr_addrranges);
...@@ -258,11 +258,11 @@ parse_nidrange(struct cfs_lstr *src, struct list_head *nidlist) ...@@ -258,11 +258,11 @@ parse_nidrange(struct cfs_lstr *src, struct list_head *nidlist)
if (cfs_gettok(src, '@', &addrrange) == 0) if (cfs_gettok(src, '@', &addrrange) == 0)
goto failed; goto failed;
if (cfs_gettok(src, '@', &net) == 0 || src->ls_str != NULL) if (cfs_gettok(src, '@', &net) == 0 || src->ls_str)
goto failed; goto failed;
nr = add_nidrange(&net, nidlist); nr = add_nidrange(&net, nidlist);
if (nr == NULL) if (!nr)
goto failed; goto failed;
if (parse_addrange(&addrrange, nr) != 0) if (parse_addrange(&addrrange, nr) != 0)
...@@ -489,13 +489,13 @@ static void cfs_ip_ar_min_max(struct addrrange *ar, __u32 *min_nid, ...@@ -489,13 +489,13 @@ static void cfs_ip_ar_min_max(struct addrrange *ar, __u32 *min_nid,
tmp_ip_addr = ((min_ip[0] << 24) | (min_ip[1] << 16) | tmp_ip_addr = ((min_ip[0] << 24) | (min_ip[1] << 16) |
(min_ip[2] << 8) | min_ip[3]); (min_ip[2] << 8) | min_ip[3]);
if (min_nid != NULL) if (min_nid)
*min_nid = tmp_ip_addr; *min_nid = tmp_ip_addr;
tmp_ip_addr = ((max_ip[0] << 24) | (max_ip[1] << 16) | tmp_ip_addr = ((max_ip[0] << 24) | (max_ip[1] << 16) |
(max_ip[2] << 8) | max_ip[3]); (max_ip[2] << 8) | max_ip[3]);
if (max_nid != NULL) if (max_nid)
*max_nid = tmp_ip_addr; *max_nid = tmp_ip_addr;
} }
...@@ -524,9 +524,9 @@ static void cfs_num_ar_min_max(struct addrrange *ar, __u32 *min_nid, ...@@ -524,9 +524,9 @@ static void cfs_num_ar_min_max(struct addrrange *ar, __u32 *min_nid,
} }
} }
if (min_nid != NULL) if (min_nid)
*min_nid = min_addr; *min_nid = min_addr;
if (max_nid != NULL) if (max_nid)
*max_nid = max_addr; *max_nid = max_addr;
} }
...@@ -548,7 +548,7 @@ bool cfs_nidrange_is_contiguous(struct list_head *nidlist) ...@@ -548,7 +548,7 @@ bool cfs_nidrange_is_contiguous(struct list_head *nidlist)
list_for_each_entry(nr, nidlist, nr_link) { list_for_each_entry(nr, nidlist, nr_link) {
nf = nr->nr_netstrfns; nf = nr->nr_netstrfns;
if (lndname == NULL) if (!lndname)
lndname = nf->nf_name; lndname = nf->nf_name;
if (netnum == -1) if (netnum == -1)
netnum = nr->nr_netnum; netnum = nr->nr_netnum;
...@@ -558,7 +558,7 @@ bool cfs_nidrange_is_contiguous(struct list_head *nidlist) ...@@ -558,7 +558,7 @@ bool cfs_nidrange_is_contiguous(struct list_head *nidlist)
return false; return false;
} }
if (nf == NULL) if (!nf)
return false; return false;
if (!nf->nf_is_contiguous(nidlist)) if (!nf->nf_is_contiguous(nidlist))
...@@ -765,9 +765,9 @@ static void cfs_ip_min_max(struct list_head *nidlist, __u32 *min_nid, ...@@ -765,9 +765,9 @@ static void cfs_ip_min_max(struct list_head *nidlist, __u32 *min_nid,
} }
} }
if (min_nid != NULL) if (min_nid)
*min_nid = min_ip_addr; *min_nid = min_ip_addr;
if (max_nid != NULL) if (max_nid)
*max_nid = max_ip_addr; *max_nid = max_ip_addr;
} }
...@@ -828,7 +828,7 @@ cfs_ip_addr_parse(char *str, int len, struct list_head *list) ...@@ -828,7 +828,7 @@ cfs_ip_addr_parse(char *str, int len, struct list_head *list)
src.ls_len = len; src.ls_len = len;
i = 0; i = 0;
while (src.ls_str != NULL) { while (src.ls_str) {
struct cfs_lstr res; struct cfs_lstr res;
if (!cfs_gettok(&src, '.', &res)) { if (!cfs_gettok(&src, '.', &res)) {
...@@ -1064,7 +1064,7 @@ libcfs_name2netstrfns(const char *name) ...@@ -1064,7 +1064,7 @@ libcfs_name2netstrfns(const char *name)
int int
libcfs_isknown_lnd(__u32 lnd) libcfs_isknown_lnd(__u32 lnd)
{ {
return libcfs_lnd2netstrfns(lnd) != NULL; return !!libcfs_lnd2netstrfns(lnd);
} }
EXPORT_SYMBOL(libcfs_isknown_lnd); EXPORT_SYMBOL(libcfs_isknown_lnd);
...@@ -1073,7 +1073,7 @@ libcfs_lnd2modname(__u32 lnd) ...@@ -1073,7 +1073,7 @@ libcfs_lnd2modname(__u32 lnd)
{ {
struct netstrfns *nf = libcfs_lnd2netstrfns(lnd); struct netstrfns *nf = libcfs_lnd2netstrfns(lnd);
return (nf == NULL) ? NULL : nf->nf_modname; return nf ? nf->nf_modname : NULL;
} }
EXPORT_SYMBOL(libcfs_lnd2modname); EXPORT_SYMBOL(libcfs_lnd2modname);
...@@ -1082,7 +1082,7 @@ libcfs_str2lnd(const char *str) ...@@ -1082,7 +1082,7 @@ libcfs_str2lnd(const char *str)
{ {
struct netstrfns *nf = libcfs_name2netstrfns(str); struct netstrfns *nf = libcfs_name2netstrfns(str);
if (nf != NULL) if (nf)
return nf->nf_type; return nf->nf_type;
return -1; return -1;
...@@ -1095,7 +1095,7 @@ libcfs_lnd2str_r(__u32 lnd, char *buf, size_t buf_size) ...@@ -1095,7 +1095,7 @@ libcfs_lnd2str_r(__u32 lnd, char *buf, size_t buf_size)
struct netstrfns *nf; struct netstrfns *nf;
nf = libcfs_lnd2netstrfns(lnd); nf = libcfs_lnd2netstrfns(lnd);
if (nf == NULL) if (!nf)
snprintf(buf, buf_size, "?%u?", lnd); snprintf(buf, buf_size, "?%u?", lnd);
else else
snprintf(buf, buf_size, "%s", nf->nf_name); snprintf(buf, buf_size, "%s", nf->nf_name);
...@@ -1112,7 +1112,7 @@ libcfs_net2str_r(__u32 net, char *buf, size_t buf_size) ...@@ -1112,7 +1112,7 @@ libcfs_net2str_r(__u32 net, char *buf, size_t buf_size)
struct netstrfns *nf; struct netstrfns *nf;
nf = libcfs_lnd2netstrfns(lnd); nf = libcfs_lnd2netstrfns(lnd);
if (nf == NULL) if (!nf)
snprintf(buf, buf_size, "<%u:%u>", lnd, nnum); snprintf(buf, buf_size, "<%u:%u>", lnd, nnum);
else if (nnum == 0) else if (nnum == 0)
snprintf(buf, buf_size, "%s", nf->nf_name); snprintf(buf, buf_size, "%s", nf->nf_name);
...@@ -1139,7 +1139,7 @@ libcfs_nid2str_r(lnet_nid_t nid, char *buf, size_t buf_size) ...@@ -1139,7 +1139,7 @@ libcfs_nid2str_r(lnet_nid_t nid, char *buf, size_t buf_size)
} }
nf = libcfs_lnd2netstrfns(lnd); nf = libcfs_lnd2netstrfns(lnd);
if (nf == NULL) { if (!nf) {
snprintf(buf, buf_size, "%x@<%u:%u>", addr, lnd, nnum); snprintf(buf, buf_size, "%x@<%u:%u>", addr, lnd, nnum);
} else { } else {
size_t addr_len; size_t addr_len;
...@@ -1199,7 +1199,7 @@ libcfs_str2net(const char *str) ...@@ -1199,7 +1199,7 @@ libcfs_str2net(const char *str)
{ {
__u32 net; __u32 net;
if (libcfs_str2net_internal(str, &net) != NULL) if (libcfs_str2net_internal(str, &net))
return net; return net;
return LNET_NIDNET(LNET_NID_ANY); return LNET_NIDNET(LNET_NID_ANY);
...@@ -1214,15 +1214,15 @@ libcfs_str2nid(const char *str) ...@@ -1214,15 +1214,15 @@ libcfs_str2nid(const char *str)
__u32 net; __u32 net;
__u32 addr; __u32 addr;
if (sep != NULL) { if (sep) {
nf = libcfs_str2net_internal(sep + 1, &net); nf = libcfs_str2net_internal(sep + 1, &net);
if (nf == NULL) if (!nf)
return LNET_NID_ANY; return LNET_NID_ANY;
} else { } else {
sep = str + strlen(str); sep = str + strlen(str);
net = LNET_MKNET(SOCKLND, 0); net = LNET_MKNET(SOCKLND, 0);
nf = libcfs_lnd2netstrfns(SOCKLND); nf = libcfs_lnd2netstrfns(SOCKLND);
LASSERT(nf != NULL); LASSERT(nf);
} }
if (!nf->nf_str2addr(str, (int)(sep - str), &addr)) if (!nf->nf_str2addr(str, (int)(sep - str), &addr))
......
...@@ -50,7 +50,7 @@ lnet_peer_tables_create(void) ...@@ -50,7 +50,7 @@ lnet_peer_tables_create(void)
the_lnet.ln_peer_tables = cfs_percpt_alloc(lnet_cpt_table(), the_lnet.ln_peer_tables = cfs_percpt_alloc(lnet_cpt_table(),
sizeof(*ptable)); sizeof(*ptable));
if (the_lnet.ln_peer_tables == NULL) { if (!the_lnet.ln_peer_tables) {
CERROR("Failed to allocate cpu-partition peer tables\n"); CERROR("Failed to allocate cpu-partition peer tables\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -60,7 +60,7 @@ lnet_peer_tables_create(void) ...@@ -60,7 +60,7 @@ lnet_peer_tables_create(void)
LIBCFS_CPT_ALLOC(hash, lnet_cpt_table(), i, LIBCFS_CPT_ALLOC(hash, lnet_cpt_table(), i,
LNET_PEER_HASH_SIZE * sizeof(*hash)); LNET_PEER_HASH_SIZE * sizeof(*hash));
if (hash == NULL) { if (!hash) {
CERROR("Failed to create peer hash table\n"); CERROR("Failed to create peer hash table\n");
lnet_peer_tables_destroy(); lnet_peer_tables_destroy();
return -ENOMEM; return -ENOMEM;
...@@ -82,12 +82,12 @@ lnet_peer_tables_destroy(void) ...@@ -82,12 +82,12 @@ lnet_peer_tables_destroy(void)
int i; int i;
int j; int j;
if (the_lnet.ln_peer_tables == NULL) if (!the_lnet.ln_peer_tables)
return; return;
cfs_percpt_for_each(ptable, i, the_lnet.ln_peer_tables) { cfs_percpt_for_each(ptable, i, the_lnet.ln_peer_tables) {
hash = ptable->pt_hash; hash = ptable->pt_hash;
if (hash == NULL) /* not initialized */ if (!hash) /* not initialized */
break; break;
LASSERT(list_empty(&ptable->pt_deathrow)); LASSERT(list_empty(&ptable->pt_deathrow));
...@@ -220,7 +220,7 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt) ...@@ -220,7 +220,7 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt)
ptable = the_lnet.ln_peer_tables[cpt2]; ptable = the_lnet.ln_peer_tables[cpt2];
lp = lnet_find_peer_locked(ptable, nid); lp = lnet_find_peer_locked(ptable, nid);
if (lp != NULL) { if (lp) {
*lpp = lp; *lpp = lp;
return 0; return 0;
} }
...@@ -238,12 +238,12 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt) ...@@ -238,12 +238,12 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt)
ptable->pt_number++; ptable->pt_number++;
lnet_net_unlock(cpt); lnet_net_unlock(cpt);
if (lp != NULL) if (lp)
memset(lp, 0, sizeof(*lp)); memset(lp, 0, sizeof(*lp));
else else
LIBCFS_CPT_ALLOC(lp, lnet_cpt_table(), cpt2, sizeof(*lp)); LIBCFS_CPT_ALLOC(lp, lnet_cpt_table(), cpt2, sizeof(*lp));
if (lp == NULL) { if (!lp) {
rc = -ENOMEM; rc = -ENOMEM;
lnet_net_lock(cpt); lnet_net_lock(cpt);
goto out; goto out;
...@@ -276,13 +276,13 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt) ...@@ -276,13 +276,13 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt)
} }
lp2 = lnet_find_peer_locked(ptable, nid); lp2 = lnet_find_peer_locked(ptable, nid);
if (lp2 != NULL) { if (lp2) {
*lpp = lp2; *lpp = lp2;
goto out; goto out;
} }
lp->lp_ni = lnet_net2ni_locked(LNET_NIDNET(nid), cpt2); lp->lp_ni = lnet_net2ni_locked(LNET_NIDNET(nid), cpt2);
if (lp->lp_ni == NULL) { if (!lp->lp_ni) {
rc = -EHOSTUNREACH; rc = -EHOSTUNREACH;
goto out; goto out;
} }
...@@ -299,7 +299,7 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt) ...@@ -299,7 +299,7 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt)
return 0; return 0;
out: out:
if (lp != NULL) if (lp)
list_add(&lp->lp_hashlist, &ptable->pt_deathrow); list_add(&lp->lp_hashlist, &ptable->pt_deathrow);
ptable->pt_number--; ptable->pt_number--;
return rc; return rc;
......
...@@ -138,7 +138,7 @@ lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp) ...@@ -138,7 +138,7 @@ lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp)
* NB individual events can be missed; the only guarantee is that you * NB individual events can be missed; the only guarantee is that you
* always get the most recent news * always get the most recent news
*/ */
if (lp->lp_notifying || ni == NULL) if (lp->lp_notifying || !ni)
return; return;
lp->lp_notifying = 1; lp->lp_notifying = 1;
...@@ -150,7 +150,7 @@ lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp) ...@@ -150,7 +150,7 @@ lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp)
lp->lp_notifylnd = 0; lp->lp_notifylnd = 0;
lp->lp_notify = 0; lp->lp_notify = 0;
if (notifylnd && ni->ni_lnd->lnd_notify != NULL) { if (notifylnd && ni->ni_lnd->lnd_notify) {
lnet_net_unlock(lp->lp_cpt); lnet_net_unlock(lp->lp_cpt);
/* /*
...@@ -204,7 +204,7 @@ lnet_rtr_decref_locked(lnet_peer_t *lp) ...@@ -204,7 +204,7 @@ lnet_rtr_decref_locked(lnet_peer_t *lp)
if (lp->lp_rtr_refcount == 0) { if (lp->lp_rtr_refcount == 0) {
LASSERT(list_empty(&lp->lp_routes)); LASSERT(list_empty(&lp->lp_routes));
if (lp->lp_rcd != NULL) { if (lp->lp_rcd) {
list_add(&lp->lp_rcd->rcd_list, list_add(&lp->lp_rcd->rcd_list,
&the_lnet.ln_rcd_deathrow); &the_lnet.ln_rcd_deathrow);
lp->lp_rcd = NULL; lp->lp_rcd = NULL;
...@@ -323,12 +323,12 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway, ...@@ -323,12 +323,12 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
/* Assume net, route, all new */ /* Assume net, route, all new */
LIBCFS_ALLOC(route, sizeof(*route)); LIBCFS_ALLOC(route, sizeof(*route));
LIBCFS_ALLOC(rnet, sizeof(*rnet)); LIBCFS_ALLOC(rnet, sizeof(*rnet));
if (route == NULL || rnet == NULL) { if (!route || !rnet) {
CERROR("Out of memory creating route %s %d %s\n", CERROR("Out of memory creating route %s %d %s\n",
libcfs_net2str(net), hops, libcfs_nid2str(gateway)); libcfs_net2str(net), hops, libcfs_nid2str(gateway));
if (route != NULL) if (route)
LIBCFS_FREE(route, sizeof(*route)); LIBCFS_FREE(route, sizeof(*route));
if (rnet != NULL) if (rnet)
LIBCFS_FREE(rnet, sizeof(*rnet)); LIBCFS_FREE(rnet, sizeof(*rnet));
return -ENOMEM; return -ENOMEM;
} }
...@@ -359,7 +359,7 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway, ...@@ -359,7 +359,7 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
LASSERT(!the_lnet.ln_shutdown); LASSERT(!the_lnet.ln_shutdown);
rnet2 = lnet_find_net_locked(net); rnet2 = lnet_find_net_locked(net);
if (rnet2 == NULL) { if (!rnet2) {
/* new network */ /* new network */
list_add_tail(&rnet->lrn_list, lnet_net2rnethash(net)); list_add_tail(&rnet->lrn_list, lnet_net2rnethash(net));
rnet2 = rnet; rnet2 = rnet;
...@@ -387,7 +387,7 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway, ...@@ -387,7 +387,7 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
lnet_net_unlock(LNET_LOCK_EX); lnet_net_unlock(LNET_LOCK_EX);
/* XXX Assume alive */ /* XXX Assume alive */
if (ni->ni_lnd->lnd_notify != NULL) if (ni->ni_lnd->lnd_notify)
ni->ni_lnd->lnd_notify(ni, gateway, 1); ni->ni_lnd->lnd_notify(ni, gateway, 1);
lnet_net_lock(LNET_LOCK_EX); lnet_net_lock(LNET_LOCK_EX);
...@@ -433,7 +433,7 @@ lnet_check_routes(void) ...@@ -433,7 +433,7 @@ lnet_check_routes(void)
route = list_entry(e2, lnet_route_t, lr_list); route = list_entry(e2, lnet_route_t, lr_list);
if (route2 == NULL) { if (!route2) {
route2 = route; route2 = route;
continue; continue;
} }
...@@ -518,7 +518,7 @@ lnet_del_route(__u32 net, lnet_nid_t gw_nid) ...@@ -518,7 +518,7 @@ lnet_del_route(__u32 net, lnet_nid_t gw_nid)
LIBCFS_FREE(route, sizeof(*route)); LIBCFS_FREE(route, sizeof(*route));
if (rnet != NULL) if (rnet)
LIBCFS_FREE(rnet, sizeof(*rnet)); LIBCFS_FREE(rnet, sizeof(*rnet));
rc = 0; rc = 0;
...@@ -696,7 +696,7 @@ lnet_router_checker_event(lnet_event_t *event) ...@@ -696,7 +696,7 @@ lnet_router_checker_event(lnet_event_t *event)
lnet_rc_data_t *rcd = event->md.user_ptr; lnet_rc_data_t *rcd = event->md.user_ptr;
struct lnet_peer *lp; struct lnet_peer *lp;
LASSERT(rcd != NULL); LASSERT(rcd);
if (event->unlinked) { if (event->unlinked) {
LNetInvalidateHandle(&rcd->rcd_mdh); LNetInvalidateHandle(&rcd->rcd_mdh);
...@@ -707,7 +707,7 @@ lnet_router_checker_event(lnet_event_t *event) ...@@ -707,7 +707,7 @@ lnet_router_checker_event(lnet_event_t *event)
event->type == LNET_EVENT_REPLY); event->type == LNET_EVENT_REPLY);
lp = rcd->rcd_gateway; lp = rcd->rcd_gateway;
LASSERT(lp != NULL); LASSERT(lp);
/* /*
* NB: it's called with holding lnet_res_lock, we have a few * NB: it's called with holding lnet_res_lock, we have a few
...@@ -822,7 +822,7 @@ lnet_update_ni_status_locked(void) ...@@ -822,7 +822,7 @@ lnet_update_ni_status_locked(void)
continue; continue;
} }
LASSERT(ni->ni_status != NULL); LASSERT(ni->ni_status);
if (ni->ni_status->ns_status != LNET_NI_STATUS_DOWN) { if (ni->ni_status->ns_status != LNET_NI_STATUS_DOWN) {
CDEBUG(D_NET, "NI(%s:%d) status changed to down\n", CDEBUG(D_NET, "NI(%s:%d) status changed to down\n",
...@@ -844,7 +844,7 @@ lnet_destroy_rc_data(lnet_rc_data_t *rcd) ...@@ -844,7 +844,7 @@ lnet_destroy_rc_data(lnet_rc_data_t *rcd)
/* detached from network */ /* detached from network */
LASSERT(LNetHandleIsInvalid(rcd->rcd_mdh)); LASSERT(LNetHandleIsInvalid(rcd->rcd_mdh));
if (rcd->rcd_gateway != NULL) { if (rcd->rcd_gateway) {
int cpt = rcd->rcd_gateway->lp_cpt; int cpt = rcd->rcd_gateway->lp_cpt;
lnet_net_lock(cpt); lnet_net_lock(cpt);
...@@ -852,7 +852,7 @@ lnet_destroy_rc_data(lnet_rc_data_t *rcd) ...@@ -852,7 +852,7 @@ lnet_destroy_rc_data(lnet_rc_data_t *rcd)
lnet_net_unlock(cpt); lnet_net_unlock(cpt);
} }
if (rcd->rcd_pinginfo != NULL) if (rcd->rcd_pinginfo)
LIBCFS_FREE(rcd->rcd_pinginfo, LNET_PINGINFO_SIZE); LIBCFS_FREE(rcd->rcd_pinginfo, LNET_PINGINFO_SIZE);
LIBCFS_FREE(rcd, sizeof(*rcd)); LIBCFS_FREE(rcd, sizeof(*rcd));
...@@ -869,14 +869,14 @@ lnet_create_rc_data_locked(lnet_peer_t *gateway) ...@@ -869,14 +869,14 @@ lnet_create_rc_data_locked(lnet_peer_t *gateway)
lnet_net_unlock(gateway->lp_cpt); lnet_net_unlock(gateway->lp_cpt);
LIBCFS_ALLOC(rcd, sizeof(*rcd)); LIBCFS_ALLOC(rcd, sizeof(*rcd));
if (rcd == NULL) if (!rcd)
goto out; goto out;
LNetInvalidateHandle(&rcd->rcd_mdh); LNetInvalidateHandle(&rcd->rcd_mdh);
INIT_LIST_HEAD(&rcd->rcd_list); INIT_LIST_HEAD(&rcd->rcd_list);
LIBCFS_ALLOC(pi, LNET_PINGINFO_SIZE); LIBCFS_ALLOC(pi, LNET_PINGINFO_SIZE);
if (pi == NULL) if (!pi)
goto out; goto out;
for (i = 0; i < LNET_MAX_RTR_NIS; i++) { for (i = 0; i < LNET_MAX_RTR_NIS; i++) {
...@@ -902,7 +902,7 @@ lnet_create_rc_data_locked(lnet_peer_t *gateway) ...@@ -902,7 +902,7 @@ lnet_create_rc_data_locked(lnet_peer_t *gateway)
lnet_net_lock(gateway->lp_cpt); lnet_net_lock(gateway->lp_cpt);
/* router table changed or someone has created rcd for this gateway */ /* router table changed or someone has created rcd for this gateway */
if (!lnet_isrouter(gateway) || gateway->lp_rcd != NULL) { if (!lnet_isrouter(gateway) || gateway->lp_rcd) {
lnet_net_unlock(gateway->lp_cpt); lnet_net_unlock(gateway->lp_cpt);
goto out; goto out;
} }
...@@ -915,7 +915,7 @@ lnet_create_rc_data_locked(lnet_peer_t *gateway) ...@@ -915,7 +915,7 @@ lnet_create_rc_data_locked(lnet_peer_t *gateway)
return rcd; return rcd;
out: out:
if (rcd != NULL) { if (rcd) {
if (!LNetHandleIsInvalid(rcd->rcd_mdh)) { if (!LNetHandleIsInvalid(rcd->rcd_mdh)) {
rc = LNetMDUnlink(rcd->rcd_mdh); rc = LNetMDUnlink(rcd->rcd_mdh);
LASSERT(rc == 0); LASSERT(rc == 0);
...@@ -963,10 +963,10 @@ lnet_ping_router_locked(lnet_peer_t *rtr) ...@@ -963,10 +963,10 @@ lnet_ping_router_locked(lnet_peer_t *rtr)
return; return;
} }
rcd = rtr->lp_rcd != NULL ? rcd = rtr->lp_rcd ?
rtr->lp_rcd : lnet_create_rc_data_locked(rtr); rtr->lp_rcd : lnet_create_rc_data_locked(rtr);
if (rcd == NULL) if (!rcd)
return; return;
secs = lnet_router_check_interval(rtr); secs = lnet_router_check_interval(rtr);
...@@ -1109,7 +1109,7 @@ lnet_prune_rc_data(int wait_unlink) ...@@ -1109,7 +1109,7 @@ lnet_prune_rc_data(int wait_unlink)
/* router checker is stopping, prune all */ /* router checker is stopping, prune all */
list_for_each_entry(lp, &the_lnet.ln_routers, list_for_each_entry(lp, &the_lnet.ln_routers,
lp_rtr_list) { lp_rtr_list) {
if (lp->lp_rcd == NULL) if (!lp->lp_rcd)
continue; continue;
LASSERT(list_empty(&lp->lp_rcd->rcd_list)); LASSERT(list_empty(&lp->lp_rcd->rcd_list));
...@@ -1256,7 +1256,7 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt) ...@@ -1256,7 +1256,7 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt)
int i; int i;
LIBCFS_CPT_ALLOC(rb, lnet_cpt_table(), cpt, sz); LIBCFS_CPT_ALLOC(rb, lnet_cpt_table(), cpt, sz);
if (rb == NULL) if (!rb)
return NULL; return NULL;
rb->rb_pool = rbp; rb->rb_pool = rbp;
...@@ -1265,7 +1265,7 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt) ...@@ -1265,7 +1265,7 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt)
page = alloc_pages_node( page = alloc_pages_node(
cfs_cpt_spread_node(lnet_cpt_table(), cpt), cfs_cpt_spread_node(lnet_cpt_table(), cpt),
GFP_KERNEL | __GFP_ZERO, 0); GFP_KERNEL | __GFP_ZERO, 0);
if (page == NULL) { if (!page) {
while (--i >= 0) while (--i >= 0)
__free_page(rb->rb_kiov[i].kiov_page); __free_page(rb->rb_kiov[i].kiov_page);
...@@ -1325,7 +1325,7 @@ lnet_rtrpool_alloc_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt) ...@@ -1325,7 +1325,7 @@ lnet_rtrpool_alloc_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt)
for (i = 0; i < nbufs; i++) { for (i = 0; i < nbufs; i++) {
rb = lnet_new_rtrbuf(rbp, cpt); rb = lnet_new_rtrbuf(rbp, cpt);
if (rb == NULL) { if (!rb) {
CERROR("Failed to allocate %d router bufs of %d pages\n", CERROR("Failed to allocate %d router bufs of %d pages\n",
nbufs, rbp->rbp_npages); nbufs, rbp->rbp_npages);
return -ENOMEM; return -ENOMEM;
...@@ -1362,7 +1362,7 @@ lnet_rtrpools_free(void) ...@@ -1362,7 +1362,7 @@ lnet_rtrpools_free(void)
lnet_rtrbufpool_t *rtrp; lnet_rtrbufpool_t *rtrp;
int i; int i;
if (the_lnet.ln_rtrpools == NULL) /* uninitialized or freed */ if (!the_lnet.ln_rtrpools) /* uninitialized or freed */
return; return;
cfs_percpt_for_each(rtrp, i, the_lnet.ln_rtrpools) { cfs_percpt_for_each(rtrp, i, the_lnet.ln_rtrpools) {
...@@ -1475,7 +1475,7 @@ lnet_rtrpools_alloc(int im_a_router) ...@@ -1475,7 +1475,7 @@ lnet_rtrpools_alloc(int im_a_router)
the_lnet.ln_rtrpools = cfs_percpt_alloc(lnet_cpt_table(), the_lnet.ln_rtrpools = cfs_percpt_alloc(lnet_cpt_table(),
LNET_NRBPOOLS * LNET_NRBPOOLS *
sizeof(lnet_rtrbufpool_t)); sizeof(lnet_rtrbufpool_t));
if (the_lnet.ln_rtrpools == NULL) { if (!the_lnet.ln_rtrpools) {
LCONSOLE_ERROR_MSG(0x10c, LCONSOLE_ERROR_MSG(0x10c,
"Failed to initialize router buffe pool\n"); "Failed to initialize router buffe pool\n");
return -ENOMEM; return -ENOMEM;
...@@ -1519,11 +1519,11 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when) ...@@ -1519,11 +1519,11 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when)
LASSERT(!in_interrupt()); LASSERT(!in_interrupt());
CDEBUG(D_NET, "%s notifying %s: %s\n", CDEBUG(D_NET, "%s notifying %s: %s\n",
(ni == NULL) ? "userspace" : libcfs_nid2str(ni->ni_nid), !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
libcfs_nid2str(nid), libcfs_nid2str(nid),
alive ? "up" : "down"); alive ? "up" : "down");
if (ni != NULL && if (ni &&
LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid)) { LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid)) {
CWARN("Ignoring notification of %s %s by %s (different net)\n", CWARN("Ignoring notification of %s %s by %s (different net)\n",
libcfs_nid2str(nid), alive ? "birth" : "death", libcfs_nid2str(nid), alive ? "birth" : "death",
...@@ -1534,13 +1534,13 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when) ...@@ -1534,13 +1534,13 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when)
/* can't do predictions... */ /* can't do predictions... */
if (cfs_time_after(when, now)) { if (cfs_time_after(when, now)) {
CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n", CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n",
(ni == NULL) ? "userspace" : libcfs_nid2str(ni->ni_nid), !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
libcfs_nid2str(nid), alive ? "up" : "down", libcfs_nid2str(nid), alive ? "up" : "down",
cfs_duration_sec(cfs_time_sub(when, now))); cfs_duration_sec(cfs_time_sub(when, now)));
return -EINVAL; return -EINVAL;
} }
if (ni != NULL && !alive && /* LND telling me she's down */ if (ni && !alive && /* LND telling me she's down */
!auto_down) { /* auto-down disabled */ !auto_down) { /* auto-down disabled */
CDEBUG(D_NET, "Auto-down disabled\n"); CDEBUG(D_NET, "Auto-down disabled\n");
return 0; return 0;
...@@ -1554,7 +1554,7 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when) ...@@ -1554,7 +1554,7 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when)
} }
lp = lnet_find_peer_locked(the_lnet.ln_peer_tables[cpt], nid); lp = lnet_find_peer_locked(the_lnet.ln_peer_tables[cpt], nid);
if (lp == NULL) { if (!lp) {
/* nid not found */ /* nid not found */
lnet_net_unlock(cpt); lnet_net_unlock(cpt);
CDEBUG(D_NET, "%s not found\n", libcfs_nid2str(nid)); CDEBUG(D_NET, "%s not found\n", libcfs_nid2str(nid));
...@@ -1567,10 +1567,10 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when) ...@@ -1567,10 +1567,10 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when)
* call us with when == _time_when_the_node_was_booted_ if * call us with when == _time_when_the_node_was_booted_ if
* no connections were successfully established * no connections were successfully established
*/ */
if (ni != NULL && !alive && when < lp->lp_last_alive) if (ni && !alive && when < lp->lp_last_alive)
when = lp->lp_last_alive; when = lp->lp_last_alive;
lnet_notify_locked(lp, ni == NULL, alive, when); lnet_notify_locked(lp, !ni, alive, when);
lnet_ni_notify_locked(ni, lp); lnet_ni_notify_locked(ni, lp);
......
...@@ -114,11 +114,11 @@ static int __proc_lnet_stats(void *data, int write, ...@@ -114,11 +114,11 @@ static int __proc_lnet_stats(void *data, int write,
/* read */ /* read */
LIBCFS_ALLOC(ctrs, sizeof(*ctrs)); LIBCFS_ALLOC(ctrs, sizeof(*ctrs));
if (ctrs == NULL) if (!ctrs)
return -ENOMEM; return -ENOMEM;
LIBCFS_ALLOC(tmpstr, tmpsiz); LIBCFS_ALLOC(tmpstr, tmpsiz);
if (tmpstr == NULL) { if (!tmpstr) {
LIBCFS_FREE(ctrs, sizeof(*ctrs)); LIBCFS_FREE(ctrs, sizeof(*ctrs));
return -ENOMEM; return -ENOMEM;
} }
...@@ -174,7 +174,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, ...@@ -174,7 +174,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
return 0; return 0;
LIBCFS_ALLOC(tmpstr, tmpsiz); LIBCFS_ALLOC(tmpstr, tmpsiz);
if (tmpstr == NULL) if (!tmpstr)
return -ENOMEM; return -ENOMEM;
s = tmpstr; /* points to current position in tmpstr[] */ s = tmpstr; /* points to current position in tmpstr[] */
...@@ -209,13 +209,12 @@ static int proc_lnet_routes(struct ctl_table *table, int write, ...@@ -209,13 +209,12 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
return -ESTALE; return -ESTALE;
} }
for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE && route == NULL; for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE && !route; i++) {
i++) {
rn_list = &the_lnet.ln_remote_nets_hash[i]; rn_list = &the_lnet.ln_remote_nets_hash[i];
n = rn_list->next; n = rn_list->next;
while (n != rn_list && route == NULL) { while (n != rn_list && !route) {
rnet = list_entry(n, lnet_remotenet_t, rnet = list_entry(n, lnet_remotenet_t,
lrn_list); lrn_list);
...@@ -238,7 +237,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, ...@@ -238,7 +237,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
} }
} }
if (route != NULL) { if (route) {
__u32 net = rnet->lrn_net; __u32 net = rnet->lrn_net;
unsigned int hops = route->lr_hops; unsigned int hops = route->lr_hops;
unsigned int priority = route->lr_priority; unsigned int priority = route->lr_priority;
...@@ -298,7 +297,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write, ...@@ -298,7 +297,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
return 0; return 0;
LIBCFS_ALLOC(tmpstr, tmpsiz); LIBCFS_ALLOC(tmpstr, tmpsiz);
if (tmpstr == NULL) if (!tmpstr)
return -ENOMEM; return -ENOMEM;
s = tmpstr; /* points to current position in tmpstr[] */ s = tmpstr; /* points to current position in tmpstr[] */
...@@ -344,7 +343,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write, ...@@ -344,7 +343,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
r = r->next; r = r->next;
} }
if (peer != NULL) { if (peer) {
lnet_nid_t nid = peer->lp_nid; lnet_nid_t nid = peer->lp_nid;
unsigned long now = cfs_time_current(); unsigned long now = cfs_time_current();
unsigned long deadline = peer->lp_ping_deadline; unsigned long deadline = peer->lp_ping_deadline;
...@@ -441,7 +440,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write, ...@@ -441,7 +440,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
} }
LIBCFS_ALLOC(tmpstr, tmpsiz); LIBCFS_ALLOC(tmpstr, tmpsiz);
if (tmpstr == NULL) if (!tmpstr)
return -ENOMEM; return -ENOMEM;
s = tmpstr; /* points to current position in tmpstr[] */ s = tmpstr; /* points to current position in tmpstr[] */
...@@ -475,7 +474,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write, ...@@ -475,7 +474,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
} }
while (hash < LNET_PEER_HASH_SIZE) { while (hash < LNET_PEER_HASH_SIZE) {
if (p == NULL) if (!p)
p = ptable->pt_hash[hash].next; p = ptable->pt_hash[hash].next;
while (p != &ptable->pt_hash[hash]) { while (p != &ptable->pt_hash[hash]) {
...@@ -504,7 +503,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write, ...@@ -504,7 +503,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
p = lp->lp_hashlist.next; p = lp->lp_hashlist.next;
} }
if (peer != NULL) if (peer)
break; break;
p = NULL; p = NULL;
...@@ -512,7 +511,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write, ...@@ -512,7 +511,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
hash++; hash++;
} }
if (peer != NULL) { if (peer) {
lnet_nid_t nid = peer->lp_nid; lnet_nid_t nid = peer->lp_nid;
int nrefs = peer->lp_refcount; int nrefs = peer->lp_refcount;
int lastalive = -1; int lastalive = -1;
...@@ -560,7 +559,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write, ...@@ -560,7 +559,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
cpt++; cpt++;
hash = 0; hash = 0;
hoff = 1; hoff = 1;
if (peer == NULL && cpt < LNET_CPT_NUMBER) if (!peer && cpt < LNET_CPT_NUMBER)
goto again; goto again;
} }
} }
...@@ -600,7 +599,7 @@ static int __proc_lnet_buffers(void *data, int write, ...@@ -600,7 +599,7 @@ static int __proc_lnet_buffers(void *data, int write,
/* (4 %d) * 4 * LNET_CPT_NUMBER */ /* (4 %d) * 4 * LNET_CPT_NUMBER */
tmpsiz = 64 * (LNET_NRBPOOLS + 1) * LNET_CPT_NUMBER; tmpsiz = 64 * (LNET_NRBPOOLS + 1) * LNET_CPT_NUMBER;
LIBCFS_ALLOC(tmpstr, tmpsiz); LIBCFS_ALLOC(tmpstr, tmpsiz);
if (tmpstr == NULL) if (!tmpstr)
return -ENOMEM; return -ENOMEM;
s = tmpstr; /* points to current position in tmpstr[] */ s = tmpstr; /* points to current position in tmpstr[] */
...@@ -610,7 +609,7 @@ static int __proc_lnet_buffers(void *data, int write, ...@@ -610,7 +609,7 @@ static int __proc_lnet_buffers(void *data, int write,
"pages", "count", "credits", "min"); "pages", "count", "credits", "min");
LASSERT(tmpstr + tmpsiz - s > 0); LASSERT(tmpstr + tmpsiz - s > 0);
if (the_lnet.ln_rtrpools == NULL) if (!the_lnet.ln_rtrpools)
goto out; /* I'm not a router */ goto out; /* I'm not a router */
for (idx = 0; idx < LNET_NRBPOOLS; idx++) { for (idx = 0; idx < LNET_NRBPOOLS; idx++) {
...@@ -664,7 +663,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write, ...@@ -664,7 +663,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
return 0; return 0;
LIBCFS_ALLOC(tmpstr, tmpsiz); LIBCFS_ALLOC(tmpstr, tmpsiz);
if (tmpstr == NULL) if (!tmpstr)
return -ENOMEM; return -ENOMEM;
s = tmpstr; /* points to current position in tmpstr[] */ s = tmpstr; /* points to current position in tmpstr[] */
...@@ -696,7 +695,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write, ...@@ -696,7 +695,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
n = n->next; n = n->next;
} }
if (ni != NULL) { if (ni) {
struct lnet_tx_queue *tq; struct lnet_tx_queue *tq;
char *stat; char *stat;
time64_t now = ktime_get_real_seconds(); time64_t now = ktime_get_real_seconds();
...@@ -712,7 +711,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write, ...@@ -712,7 +711,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
last_alive = 0; last_alive = 0;
lnet_ni_lock(ni); lnet_ni_lock(ni);
LASSERT(ni->ni_status != NULL); LASSERT(ni->ni_status);
stat = (ni->ni_status->ns_status == stat = (ni->ni_status->ns_status ==
LNET_NI_STATUS_UP) ? "up" : "down"; LNET_NI_STATUS_UP) ? "up" : "down";
lnet_ni_unlock(ni); lnet_ni_unlock(ni);
...@@ -722,7 +721,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write, ...@@ -722,7 +721,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
* TX queue of each partition * TX queue of each partition
*/ */
cfs_percpt_for_each(tq, i, ni->ni_tx_queues) { cfs_percpt_for_each(tq, i, ni->ni_tx_queues) {
for (j = 0; ni->ni_cpts != NULL && for (j = 0; ni->ni_cpts &&
j < ni->ni_ncpts; j++) { j < ni->ni_ncpts; j++) {
if (i == ni->ni_cpts[j]) if (i == ni->ni_cpts[j])
break; break;
...@@ -817,7 +816,7 @@ static int __proc_lnet_portal_rotor(void *data, int write, ...@@ -817,7 +816,7 @@ static int __proc_lnet_portal_rotor(void *data, int write,
int i; int i;
LIBCFS_ALLOC(buf, buf_len); LIBCFS_ALLOC(buf, buf_len);
if (buf == NULL) if (!buf)
return -ENOMEM; return -ENOMEM;
if (!write) { if (!write) {
...@@ -854,7 +853,7 @@ static int __proc_lnet_portal_rotor(void *data, int write, ...@@ -854,7 +853,7 @@ static int __proc_lnet_portal_rotor(void *data, int write,
rc = -EINVAL; rc = -EINVAL;
lnet_res_lock(0); lnet_res_lock(0);
for (i = 0; portal_rotors[i].pr_name != NULL; i++) { for (i = 0; portal_rotors[i].pr_name; i++) {
if (strncasecmp(portal_rotors[i].pr_name, tmp, if (strncasecmp(portal_rotors[i].pr_name, tmp,
strlen(portal_rotors[i].pr_name)) == 0) { strlen(portal_rotors[i].pr_name)) == 0) {
portal_rotor = portal_rotors[i].pr_value; portal_rotor = portal_rotors[i].pr_value;
......
...@@ -58,7 +58,7 @@ brw_client_fini(sfw_test_instance_t *tsi) ...@@ -58,7 +58,7 @@ brw_client_fini(sfw_test_instance_t *tsi)
list_for_each_entry(tsu, &tsi->tsi_units, tsu_list) { list_for_each_entry(tsu, &tsi->tsi_units, tsu_list) {
bulk = tsu->tsu_private; bulk = tsu->tsu_private;
if (bulk == NULL) if (!bulk)
continue; continue;
srpc_free_bulk(bulk); srpc_free_bulk(bulk);
...@@ -77,7 +77,7 @@ brw_client_init(sfw_test_instance_t *tsi) ...@@ -77,7 +77,7 @@ brw_client_init(sfw_test_instance_t *tsi)
srpc_bulk_t *bulk; srpc_bulk_t *bulk;
sfw_test_unit_t *tsu; sfw_test_unit_t *tsu;
LASSERT(sn != NULL); LASSERT(sn);
LASSERT(tsi->tsi_is_client); LASSERT(tsi->tsi_is_client);
if ((sn->sn_features & LST_FEAT_BULK_LEN) == 0) { if ((sn->sn_features & LST_FEAT_BULK_LEN) == 0) {
...@@ -120,7 +120,7 @@ brw_client_init(sfw_test_instance_t *tsi) ...@@ -120,7 +120,7 @@ brw_client_init(sfw_test_instance_t *tsi)
list_for_each_entry(tsu, &tsi->tsi_units, tsu_list) { list_for_each_entry(tsu, &tsi->tsi_units, tsu_list) {
bulk = srpc_alloc_bulk(lnet_cpt_of_nid(tsu->tsu_dest.nid), bulk = srpc_alloc_bulk(lnet_cpt_of_nid(tsu->tsu_dest.nid),
npg, len, opc == LST_BRW_READ); npg, len, opc == LST_BRW_READ);
if (bulk == NULL) { if (!bulk) {
brw_client_fini(tsi); brw_client_fini(tsi);
return -ENOMEM; return -ENOMEM;
} }
...@@ -157,7 +157,7 @@ brw_fill_page(struct page *pg, int pattern, __u64 magic) ...@@ -157,7 +157,7 @@ brw_fill_page(struct page *pg, int pattern, __u64 magic)
char *addr = page_address(pg); char *addr = page_address(pg);
int i; int i;
LASSERT(addr != NULL); LASSERT(addr);
if (pattern == LST_BRW_CHECK_NONE) if (pattern == LST_BRW_CHECK_NONE)
return; return;
...@@ -188,7 +188,7 @@ brw_check_page(struct page *pg, int pattern, __u64 magic) ...@@ -188,7 +188,7 @@ brw_check_page(struct page *pg, int pattern, __u64 magic)
__u64 data = 0; /* make compiler happy */ __u64 data = 0; /* make compiler happy */
int i; int i;
LASSERT(addr != NULL); LASSERT(addr);
if (pattern == LST_BRW_CHECK_NONE) if (pattern == LST_BRW_CHECK_NONE)
return 0; return 0;
...@@ -269,8 +269,8 @@ brw_client_prep_rpc(sfw_test_unit_t *tsu, ...@@ -269,8 +269,8 @@ brw_client_prep_rpc(sfw_test_unit_t *tsu,
int opc; int opc;
int rc; int rc;
LASSERT(sn != NULL); LASSERT(sn);
LASSERT(bulk != NULL); LASSERT(bulk);
if ((sn->sn_features & LST_FEAT_BULK_LEN) == 0) { if ((sn->sn_features & LST_FEAT_BULK_LEN) == 0) {
test_bulk_req_t *breq = &tsi->tsi_u.bulk_v0; test_bulk_req_t *breq = &tsi->tsi_u.bulk_v0;
...@@ -324,7 +324,7 @@ brw_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc) ...@@ -324,7 +324,7 @@ brw_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
srpc_brw_reply_t *reply = &msg->msg_body.brw_reply; srpc_brw_reply_t *reply = &msg->msg_body.brw_reply;
srpc_brw_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.brw_reqst; srpc_brw_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.brw_reqst;
LASSERT(sn != NULL); LASSERT(sn);
if (rpc->crpc_status != 0) { if (rpc->crpc_status != 0) {
CERROR("BRW RPC to %s failed with %d\n", CERROR("BRW RPC to %s failed with %d\n",
...@@ -368,7 +368,7 @@ brw_server_rpc_done(struct srpc_server_rpc *rpc) ...@@ -368,7 +368,7 @@ brw_server_rpc_done(struct srpc_server_rpc *rpc)
{ {
srpc_bulk_t *blk = rpc->srpc_bulk; srpc_bulk_t *blk = rpc->srpc_bulk;
if (blk == NULL) if (!blk)
return; return;
if (rpc->srpc_status != 0) if (rpc->srpc_status != 0)
...@@ -391,8 +391,8 @@ brw_bulk_ready(struct srpc_server_rpc *rpc, int status) ...@@ -391,8 +391,8 @@ brw_bulk_ready(struct srpc_server_rpc *rpc, int status)
srpc_brw_reqst_t *reqst; srpc_brw_reqst_t *reqst;
srpc_msg_t *reqstmsg; srpc_msg_t *reqstmsg;
LASSERT(rpc->srpc_bulk != NULL); LASSERT(rpc->srpc_bulk);
LASSERT(rpc->srpc_reqstbuf != NULL); LASSERT(rpc->srpc_reqstbuf);
reqstmsg = &rpc->srpc_reqstbuf->buf_msg; reqstmsg = &rpc->srpc_reqstbuf->buf_msg;
reqst = &reqstmsg->msg_body.brw_reqst; reqst = &reqstmsg->msg_body.brw_reqst;
......
...@@ -70,7 +70,7 @@ lnet_selftest_fini(void) ...@@ -70,7 +70,7 @@ lnet_selftest_fini(void)
case LST_INIT_WI_TEST: case LST_INIT_WI_TEST:
for (i = 0; for (i = 0;
i < cfs_cpt_number(lnet_cpt_table()); i++) { i < cfs_cpt_number(lnet_cpt_table()); i++) {
if (lst_sched_test[i] == NULL) if (!lst_sched_test[i])
continue; continue;
cfs_wi_sched_destroy(lst_sched_test[i]); cfs_wi_sched_destroy(lst_sched_test[i]);
} }
...@@ -106,7 +106,7 @@ lnet_selftest_init(void) ...@@ -106,7 +106,7 @@ lnet_selftest_init(void)
nscheds = cfs_cpt_number(lnet_cpt_table()); nscheds = cfs_cpt_number(lnet_cpt_table());
LIBCFS_ALLOC(lst_sched_test, sizeof(lst_sched_test[0]) * nscheds); LIBCFS_ALLOC(lst_sched_test, sizeof(lst_sched_test[0]) * nscheds);
if (lst_sched_test == NULL) if (!lst_sched_test)
goto error; goto error;
lst_init_step = LST_INIT_WI_TEST; lst_init_step = LST_INIT_WI_TEST;
......
...@@ -61,7 +61,7 @@ ping_client_init(sfw_test_instance_t *tsi) ...@@ -61,7 +61,7 @@ ping_client_init(sfw_test_instance_t *tsi)
sfw_session_t *sn = tsi->tsi_batch->bat_session; sfw_session_t *sn = tsi->tsi_batch->bat_session;
LASSERT(tsi->tsi_is_client); LASSERT(tsi->tsi_is_client);
LASSERT(sn != NULL && (sn->sn_features & ~LST_FEATS_MASK) == 0); LASSERT(sn && (sn->sn_features & ~LST_FEATS_MASK) == 0);
spin_lock_init(&lst_ping_data.pnd_lock); spin_lock_init(&lst_ping_data.pnd_lock);
lst_ping_data.pnd_counter = 0; lst_ping_data.pnd_counter = 0;
...@@ -75,7 +75,7 @@ ping_client_fini(sfw_test_instance_t *tsi) ...@@ -75,7 +75,7 @@ ping_client_fini(sfw_test_instance_t *tsi)
sfw_session_t *sn = tsi->tsi_batch->bat_session; sfw_session_t *sn = tsi->tsi_batch->bat_session;
int errors; int errors;
LASSERT(sn != NULL); LASSERT(sn);
LASSERT(tsi->tsi_is_client); LASSERT(tsi->tsi_is_client);
errors = atomic_read(&sn->sn_ping_errors); errors = atomic_read(&sn->sn_ping_errors);
...@@ -95,7 +95,7 @@ ping_client_prep_rpc(sfw_test_unit_t *tsu, ...@@ -95,7 +95,7 @@ ping_client_prep_rpc(sfw_test_unit_t *tsu,
struct timespec64 ts; struct timespec64 ts;
int rc; int rc;
LASSERT(sn != NULL); LASSERT(sn);
LASSERT((sn->sn_features & ~LST_FEATS_MASK) == 0); LASSERT((sn->sn_features & ~LST_FEATS_MASK) == 0);
rc = sfw_create_test_rpc(tsu, dest, sn->sn_features, 0, 0, rpc); rc = sfw_create_test_rpc(tsu, dest, sn->sn_features, 0, 0, rpc);
...@@ -126,7 +126,7 @@ ping_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc) ...@@ -126,7 +126,7 @@ ping_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
srpc_ping_reply_t *reply = &rpc->crpc_replymsg.msg_body.ping_reply; srpc_ping_reply_t *reply = &rpc->crpc_replymsg.msg_body.ping_reply;
struct timespec64 ts; struct timespec64 ts;
LASSERT(sn != NULL); LASSERT(sn);
if (rpc->crpc_status != 0) { if (rpc->crpc_status != 0) {
if (!tsi->tsi_stopping) /* rpc could have been aborted */ if (!tsi->tsi_stopping) /* rpc could have been aborted */
......
This diff is collapsed.
...@@ -504,11 +504,11 @@ void srpc_shutdown(void); ...@@ -504,11 +504,11 @@ void srpc_shutdown(void);
static inline void static inline void
srpc_destroy_client_rpc(srpc_client_rpc_t *rpc) srpc_destroy_client_rpc(srpc_client_rpc_t *rpc)
{ {
LASSERT(rpc != NULL); LASSERT(rpc);
LASSERT(!srpc_event_pending(rpc)); LASSERT(!srpc_event_pending(rpc));
LASSERT(atomic_read(&rpc->crpc_refcount) == 0); LASSERT(atomic_read(&rpc->crpc_refcount) == 0);
if (rpc->crpc_fini == NULL) if (!rpc->crpc_fini)
LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc)); LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc));
else else
(*rpc->crpc_fini) (rpc); (*rpc->crpc_fini) (rpc);
......
...@@ -75,7 +75,7 @@ stt_add_timer(stt_timer_t *timer) ...@@ -75,7 +75,7 @@ stt_add_timer(stt_timer_t *timer)
LASSERT(stt_data.stt_nthreads > 0); LASSERT(stt_data.stt_nthreads > 0);
LASSERT(!stt_data.stt_shuttingdown); LASSERT(!stt_data.stt_shuttingdown);
LASSERT(timer->stt_func != NULL); LASSERT(timer->stt_func);
LASSERT(list_empty(&timer->stt_list)); LASSERT(list_empty(&timer->stt_list));
LASSERT(timer->stt_expires > ktime_get_real_seconds()); LASSERT(timer->stt_expires > ktime_get_real_seconds());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment