Skip to content

Commit

Permalink
RDS: cleanup: remove "== NULL"s and "!= NULL"s in ptr comparisons
Browse files Browse the repository at this point in the history
Favor "if (foo)" style over "if (foo != NULL)".

Signed-off-by: Andy Grover <andy.grover@oracle.com>
  • Loading branch information
Andy Grover committed Sep 9, 2010
1 parent 2dc3935 commit 8690bfa
Show file tree
Hide file tree
Showing 26 changed files with 90 additions and 90 deletions.
2 changes: 1 addition & 1 deletion net/rds/af_rds.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static int rds_release(struct socket *sock)
struct rds_sock *rs;
unsigned long flags;

if (sk == NULL)
if (!sk)
goto out;

rs = rds_sk_to_rs(sk);
Expand Down
4 changes: 2 additions & 2 deletions net/rds/bind.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static int rds_add_bound(struct rds_sock *rs, __be32 addr, __be16 *port)
do {
if (rover == 0)
rover++;
if (rds_bind_tree_walk(addr, cpu_to_be16(rover), rs) == NULL) {
if (!rds_bind_tree_walk(addr, cpu_to_be16(rover), rs)) {
*port = cpu_to_be16(rover);
ret = 0;
break;
Expand Down Expand Up @@ -184,7 +184,7 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
goto out;

trans = rds_trans_get_preferred(sin->sin_addr.s_addr);
if (trans == NULL) {
if (!trans) {
ret = -EADDRNOTAVAIL;
rds_remove_bound(rs);
if (printk_ratelimit())
Expand Down
6 changes: 3 additions & 3 deletions net/rds/cong.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static struct rds_cong_map *rds_cong_from_addr(__be32 addr)
unsigned long flags;

map = kzalloc(sizeof(struct rds_cong_map), GFP_KERNEL);
if (map == NULL)
if (!map)
return NULL;

map->m_addr = addr;
Expand All @@ -159,7 +159,7 @@ static struct rds_cong_map *rds_cong_from_addr(__be32 addr)
ret = rds_cong_tree_walk(addr, map);
spin_unlock_irqrestore(&rds_cong_lock, flags);

if (ret == NULL) {
if (!ret) {
ret = map;
map = NULL;
}
Expand Down Expand Up @@ -205,7 +205,7 @@ int rds_cong_get_maps(struct rds_connection *conn)
conn->c_lcong = rds_cong_from_addr(conn->c_laddr);
conn->c_fcong = rds_cong_from_addr(conn->c_faddr);

if (conn->c_lcong == NULL || conn->c_fcong == NULL)
if (!(conn->c_lcong && conn->c_fcong))
return -ENOMEM;

return 0;
Expand Down
4 changes: 2 additions & 2 deletions net/rds/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static struct rds_connection *__rds_conn_create(__be32 laddr, __be32 faddr,
goto out;

conn = kmem_cache_zalloc(rds_conn_slab, gfp);
if (conn == NULL) {
if (!conn) {
conn = ERR_PTR(-ENOMEM);
goto out;
}
Expand Down Expand Up @@ -502,7 +502,7 @@ int __init rds_conn_init(void)
rds_conn_slab = kmem_cache_create("rds_connection",
sizeof(struct rds_connection),
0, 0, NULL);
if (rds_conn_slab == NULL)
if (!rds_conn_slab)
return -ENOMEM;

rds_info_register_func(RDS_INFO_CONNECTIONS, rds_conn_info);
Expand Down
14 changes: 7 additions & 7 deletions net/rds/ib_cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
* the rds_ibdev at all.
*/
rds_ibdev = ib_get_client_data(dev, &rds_ib_client);
if (rds_ibdev == NULL) {
if (!rds_ibdev) {
if (printk_ratelimit())
printk(KERN_NOTICE "RDS/IB: No client_data for device %s\n",
dev->name);
Expand Down Expand Up @@ -306,7 +306,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
ic->i_send_ring.w_nr *
sizeof(struct rds_header),
&ic->i_send_hdrs_dma, GFP_KERNEL);
if (ic->i_send_hdrs == NULL) {
if (!ic->i_send_hdrs) {
ret = -ENOMEM;
rdsdebug("ib_dma_alloc_coherent send failed\n");
goto out;
Expand All @@ -316,30 +316,30 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
ic->i_recv_ring.w_nr *
sizeof(struct rds_header),
&ic->i_recv_hdrs_dma, GFP_KERNEL);
if (ic->i_recv_hdrs == NULL) {
if (!ic->i_recv_hdrs) {
ret = -ENOMEM;
rdsdebug("ib_dma_alloc_coherent recv failed\n");
goto out;
}

ic->i_ack = ib_dma_alloc_coherent(dev, sizeof(struct rds_header),
&ic->i_ack_dma, GFP_KERNEL);
if (ic->i_ack == NULL) {
if (!ic->i_ack) {
ret = -ENOMEM;
rdsdebug("ib_dma_alloc_coherent ack failed\n");
goto out;
}

ic->i_sends = vmalloc(ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work));
if (ic->i_sends == NULL) {
if (!ic->i_sends) {
ret = -ENOMEM;
rdsdebug("send allocation failed\n");
goto out;
}
memset(ic->i_sends, 0, ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work));

ic->i_recvs = vmalloc(ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work));
if (ic->i_recvs == NULL) {
if (!ic->i_recvs) {
ret = -ENOMEM;
rdsdebug("recv allocation failed\n");
goto out;
Expand Down Expand Up @@ -693,7 +693,7 @@ int rds_ib_conn_alloc(struct rds_connection *conn, gfp_t gfp)

/* XXX too lazy? */
ic = kzalloc(sizeof(struct rds_ib_connection), GFP_KERNEL);
if (ic == NULL)
if (!ic)
return -ENOMEM;

INIT_LIST_HEAD(&ic->ib_node);
Expand Down
20 changes: 10 additions & 10 deletions net/rds/ib_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static void rds_ib_frag_drop_page(struct rds_page_frag *frag)
static void rds_ib_frag_free(struct rds_page_frag *frag)
{
rdsdebug("frag %p page %p\n", frag, frag->f_page);
BUG_ON(frag->f_page != NULL);
BUG_ON(frag->f_page);
kmem_cache_free(rds_ib_frag_slab, frag);
}

Expand Down Expand Up @@ -143,32 +143,32 @@ static int rds_ib_recv_refill_one(struct rds_connection *conn,
struct ib_sge *sge;
int ret = -ENOMEM;

if (recv->r_ibinc == NULL) {
if (!recv->r_ibinc) {
if (!atomic_add_unless(&rds_ib_allocation, 1, rds_ib_sysctl_max_recv_allocation)) {
rds_ib_stats_inc(s_ib_rx_alloc_limit);
goto out;
}
recv->r_ibinc = kmem_cache_alloc(rds_ib_incoming_slab,
kptr_gfp);
if (recv->r_ibinc == NULL) {
if (!recv->r_ibinc) {
atomic_dec(&rds_ib_allocation);
goto out;
}
INIT_LIST_HEAD(&recv->r_ibinc->ii_frags);
rds_inc_init(&recv->r_ibinc->ii_inc, conn, conn->c_faddr);
}

if (recv->r_frag == NULL) {
if (!recv->r_frag) {
recv->r_frag = kmem_cache_alloc(rds_ib_frag_slab, kptr_gfp);
if (recv->r_frag == NULL)
if (!recv->r_frag)
goto out;
INIT_LIST_HEAD(&recv->r_frag->f_item);
recv->r_frag->f_page = NULL;
}

if (ic->i_frag.f_page == NULL) {
if (!ic->i_frag.f_page) {
ic->i_frag.f_page = alloc_page(page_gfp);
if (ic->i_frag.f_page == NULL)
if (!ic->i_frag.f_page)
goto out;
ic->i_frag.f_offset = 0;
}
Expand Down Expand Up @@ -757,7 +757,7 @@ static void rds_ib_process_recv(struct rds_connection *conn,
* into the inc and save the inc so we can hang upcoming fragments
* off its list.
*/
if (ibinc == NULL) {
if (!ibinc) {
ibinc = recv->r_ibinc;
recv->r_ibinc = NULL;
ic->i_ibinc = ibinc;
Expand Down Expand Up @@ -940,13 +940,13 @@ int __init rds_ib_recv_init(void)
rds_ib_incoming_slab = kmem_cache_create("rds_ib_incoming",
sizeof(struct rds_ib_incoming),
0, 0, NULL);
if (rds_ib_incoming_slab == NULL)
if (!rds_ib_incoming_slab)
goto out;

rds_ib_frag_slab = kmem_cache_create("rds_ib_frag",
sizeof(struct rds_page_frag),
0, 0, NULL);
if (rds_ib_frag_slab == NULL)
if (!rds_ib_frag_slab)
kmem_cache_destroy(rds_ib_incoming_slab);
else
ret = 0;
Expand Down
4 changes: 2 additions & 2 deletions net/rds/ib_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static void rds_ib_send_unmap_rm(struct rds_ib_connection *ic,
rm->m_sg, rm->m_nents,
DMA_TO_DEVICE);

if (rm->m_rdma_op != NULL) {
if (rm->m_rdma_op) {
rds_ib_send_unmap_rdma(ic, rm->m_rdma_op);

/* If the user asked for a completion notification on this
Expand Down Expand Up @@ -525,7 +525,7 @@ int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm,
}

/* map the message the first time we see it */
if (ic->i_rm == NULL) {
if (!ic->i_rm) {
/*
printk(KERN_NOTICE "rds_ib_xmit prep msg dport=%u flags=0x%x len=%d\n",
be16_to_cpu(rm->m_inc.i_hdr.h_dport),
Expand Down
2 changes: 1 addition & 1 deletion net/rds/ib_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void rds_ib_sysctl_exit(void)
int __init rds_ib_sysctl_init(void)
{
rds_ib_sysctl_hdr = register_sysctl_paths(rds_ib_sysctl_path, rds_ib_sysctl_table);
if (rds_ib_sysctl_hdr == NULL)
if (!rds_ib_sysctl_hdr)
return -ENOMEM;
return 0;
}
12 changes: 6 additions & 6 deletions net/rds/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void rds_info_register_func(int optname, rds_info_func func)
BUG_ON(optname < RDS_INFO_FIRST || optname > RDS_INFO_LAST);

spin_lock(&rds_info_lock);
BUG_ON(rds_info_funcs[offset] != NULL);
BUG_ON(rds_info_funcs[offset]);
rds_info_funcs[offset] = func;
spin_unlock(&rds_info_lock);
}
Expand All @@ -102,7 +102,7 @@ EXPORT_SYMBOL_GPL(rds_info_deregister_func);
*/
void rds_info_iter_unmap(struct rds_info_iterator *iter)
{
if (iter->addr != NULL) {
if (iter->addr) {
kunmap_atomic(iter->addr, KM_USER0);
iter->addr = NULL;
}
Expand All @@ -117,7 +117,7 @@ void rds_info_copy(struct rds_info_iterator *iter, void *data,
unsigned long this;

while (bytes) {
if (iter->addr == NULL)
if (!iter->addr)
iter->addr = kmap_atomic(*iter->pages, KM_USER0);

this = min(bytes, PAGE_SIZE - iter->offset);
Expand Down Expand Up @@ -188,7 +188,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval,
>> PAGE_SHIFT;

pages = kmalloc(nr_pages * sizeof(struct page *), GFP_KERNEL);
if (pages == NULL) {
if (!pages) {
ret = -ENOMEM;
goto out;
}
Expand All @@ -206,7 +206,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval,

call_func:
func = rds_info_funcs[optname - RDS_INFO_FIRST];
if (func == NULL) {
if (!func) {
ret = -ENOPROTOOPT;
goto out;
}
Expand Down Expand Up @@ -234,7 +234,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval,
ret = -EFAULT;

out:
for (i = 0; pages != NULL && i < nr_pages; i++)
for (i = 0; pages && i < nr_pages; i++)
put_page(pages[i]);
kfree(pages);

Expand Down
14 changes: 7 additions & 7 deletions net/rds/iw_cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ static int rds_iw_setup_qp(struct rds_connection *conn)
* the rds_iwdev at all.
*/
rds_iwdev = ib_get_client_data(dev, &rds_iw_client);
if (rds_iwdev == NULL) {
if (!rds_iwdev) {
if (printk_ratelimit())
printk(KERN_NOTICE "RDS/IW: No client_data for device %s\n",
dev->name);
Expand Down Expand Up @@ -292,7 +292,7 @@ static int rds_iw_setup_qp(struct rds_connection *conn)
ic->i_send_ring.w_nr *
sizeof(struct rds_header),
&ic->i_send_hdrs_dma, GFP_KERNEL);
if (ic->i_send_hdrs == NULL) {
if (!ic->i_send_hdrs) {
ret = -ENOMEM;
rdsdebug("ib_dma_alloc_coherent send failed\n");
goto out;
Expand All @@ -302,30 +302,30 @@ static int rds_iw_setup_qp(struct rds_connection *conn)
ic->i_recv_ring.w_nr *
sizeof(struct rds_header),
&ic->i_recv_hdrs_dma, GFP_KERNEL);
if (ic->i_recv_hdrs == NULL) {
if (!ic->i_recv_hdrs) {
ret = -ENOMEM;
rdsdebug("ib_dma_alloc_coherent recv failed\n");
goto out;
}

ic->i_ack = ib_dma_alloc_coherent(dev, sizeof(struct rds_header),
&ic->i_ack_dma, GFP_KERNEL);
if (ic->i_ack == NULL) {
if (!ic->i_ack) {
ret = -ENOMEM;
rdsdebug("ib_dma_alloc_coherent ack failed\n");
goto out;
}

ic->i_sends = vmalloc(ic->i_send_ring.w_nr * sizeof(struct rds_iw_send_work));
if (ic->i_sends == NULL) {
if (!ic->i_sends) {
ret = -ENOMEM;
rdsdebug("send allocation failed\n");
goto out;
}
rds_iw_send_init_ring(ic);

ic->i_recvs = vmalloc(ic->i_recv_ring.w_nr * sizeof(struct rds_iw_recv_work));
if (ic->i_recvs == NULL) {
if (!ic->i_recvs) {
ret = -ENOMEM;
rdsdebug("recv allocation failed\n");
goto out;
Expand Down Expand Up @@ -696,7 +696,7 @@ int rds_iw_conn_alloc(struct rds_connection *conn, gfp_t gfp)

/* XXX too lazy? */
ic = kzalloc(sizeof(struct rds_iw_connection), GFP_KERNEL);
if (ic == NULL)
if (!ic)
return -ENOMEM;

INIT_LIST_HEAD(&ic->iw_node);
Expand Down
Loading

0 comments on commit 8690bfa

Please sign in to comment.