Commit b1b63970 authored by Kamal Heib's avatar Kamal Heib Committed by Jason Gunthorpe

RDMA/ipoib: Fix use of sizeof()

Make sure to use sizeof(...) instead of sizeof ... which is more
preferred.
Signed-off-by: default avatarKamal Heib <kamalheib1@gmail.com>
Reviewed-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 0578cdad
...@@ -363,7 +363,7 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i ...@@ -363,7 +363,7 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i
if (!rx->rx_ring) if (!rx->rx_ring)
return -ENOMEM; return -ENOMEM;
t = kmalloc(sizeof *t, GFP_KERNEL); t = kmalloc(sizeof(*t), GFP_KERNEL);
if (!t) { if (!t) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_free_1; goto err_free_1;
...@@ -432,7 +432,7 @@ static int ipoib_cm_send_rep(struct net_device *dev, struct ib_cm_id *cm_id, ...@@ -432,7 +432,7 @@ static int ipoib_cm_send_rep(struct net_device *dev, struct ib_cm_id *cm_id,
data.mtu = cpu_to_be32(IPOIB_CM_BUF_SIZE); data.mtu = cpu_to_be32(IPOIB_CM_BUF_SIZE);
rep.private_data = &data; rep.private_data = &data;
rep.private_data_len = sizeof data; rep.private_data_len = sizeof(data);
rep.flow_control = 0; rep.flow_control = 0;
rep.rnr_retry_count = req->rnr_retry_count; rep.rnr_retry_count = req->rnr_retry_count;
rep.srq = ipoib_cm_has_srq(dev); rep.srq = ipoib_cm_has_srq(dev);
...@@ -450,7 +450,7 @@ static int ipoib_cm_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *even ...@@ -450,7 +450,7 @@ static int ipoib_cm_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *even
int ret; int ret;
ipoib_dbg(priv, "REQ arrived\n"); ipoib_dbg(priv, "REQ arrived\n");
p = kzalloc(sizeof *p, GFP_KERNEL); p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p) if (!p)
return -ENOMEM; return -ENOMEM;
p->dev = dev; p->dev = dev;
...@@ -658,7 +658,7 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc) ...@@ -658,7 +658,7 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
} }
ipoib_cm_dma_unmap_rx(priv, frags, rx_ring[wr_id].mapping); ipoib_cm_dma_unmap_rx(priv, frags, rx_ring[wr_id].mapping);
memcpy(rx_ring[wr_id].mapping, mapping, (frags + 1) * sizeof *mapping); memcpy(rx_ring[wr_id].mapping, mapping, (frags + 1) * sizeof(*mapping));
ipoib_dbg_data(priv, "received %d bytes, SLID 0x%04x\n", ipoib_dbg_data(priv, "received %d bytes, SLID 0x%04x\n",
wc->byte_len, wc->slid); wc->byte_len, wc->slid);
...@@ -1095,7 +1095,7 @@ static int ipoib_cm_send_req(struct net_device *dev, ...@@ -1095,7 +1095,7 @@ static int ipoib_cm_send_req(struct net_device *dev,
req.qp_num = qp->qp_num; req.qp_num = qp->qp_num;
req.qp_type = qp->qp_type; req.qp_type = qp->qp_type;
req.private_data = &data; req.private_data = &data;
req.private_data_len = sizeof data; req.private_data_len = sizeof(data);
req.flow_control = 0; req.flow_control = 0;
req.starting_psn = 0; /* FIXME */ req.starting_psn = 0; /* FIXME */
...@@ -1153,7 +1153,7 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn, ...@@ -1153,7 +1153,7 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn,
ret = -ENOMEM; ret = -ENOMEM;
goto err_tx; goto err_tx;
} }
memset(p->tx_ring, 0, ipoib_sendq_size * sizeof *p->tx_ring); memset(p->tx_ring, 0, ipoib_sendq_size * sizeof(*p->tx_ring));
p->qp = ipoib_cm_create_tx_qp(p->dev, p); p->qp = ipoib_cm_create_tx_qp(p->dev, p);
memalloc_noio_restore(noio_flag); memalloc_noio_restore(noio_flag);
...@@ -1306,7 +1306,7 @@ struct ipoib_cm_tx *ipoib_cm_create_tx(struct net_device *dev, struct ipoib_path ...@@ -1306,7 +1306,7 @@ struct ipoib_cm_tx *ipoib_cm_create_tx(struct net_device *dev, struct ipoib_path
struct ipoib_dev_priv *priv = ipoib_priv(dev); struct ipoib_dev_priv *priv = ipoib_priv(dev);
struct ipoib_cm_tx *tx; struct ipoib_cm_tx *tx;
tx = kzalloc(sizeof *tx, GFP_ATOMIC); tx = kzalloc(sizeof(*tx), GFP_ATOMIC);
if (!tx) if (!tx)
return NULL; return NULL;
...@@ -1371,7 +1371,7 @@ static void ipoib_cm_tx_start(struct work_struct *work) ...@@ -1371,7 +1371,7 @@ static void ipoib_cm_tx_start(struct work_struct *work)
neigh->daddr + QPN_AND_OPTIONS_OFFSET); neigh->daddr + QPN_AND_OPTIONS_OFFSET);
goto free_neigh; goto free_neigh;
} }
memcpy(&pathrec, &p->path->pathrec, sizeof pathrec); memcpy(&pathrec, &p->path->pathrec, sizeof(pathrec));
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
netif_tx_unlock_bh(dev); netif_tx_unlock_bh(dev);
......
...@@ -262,15 +262,15 @@ static const struct file_operations ipoib_path_fops = { ...@@ -262,15 +262,15 @@ static const struct file_operations ipoib_path_fops = {
void ipoib_create_debug_files(struct net_device *dev) void ipoib_create_debug_files(struct net_device *dev)
{ {
struct ipoib_dev_priv *priv = ipoib_priv(dev); struct ipoib_dev_priv *priv = ipoib_priv(dev);
char name[IFNAMSIZ + sizeof "_path"]; char name[IFNAMSIZ + sizeof("_path")];
snprintf(name, sizeof name, "%s_mcg", dev->name); snprintf(name, sizeof(name), "%s_mcg", dev->name);
priv->mcg_dentry = debugfs_create_file(name, S_IFREG | S_IRUGO, priv->mcg_dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
ipoib_root, dev, &ipoib_mcg_fops); ipoib_root, dev, &ipoib_mcg_fops);
if (!priv->mcg_dentry) if (!priv->mcg_dentry)
ipoib_warn(priv, "failed to create mcg debug file\n"); ipoib_warn(priv, "failed to create mcg debug file\n");
snprintf(name, sizeof name, "%s_path", dev->name); snprintf(name, sizeof(name), "%s_path", dev->name);
priv->path_dentry = debugfs_create_file(name, S_IFREG | S_IRUGO, priv->path_dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
ipoib_root, dev, &ipoib_path_fops); ipoib_root, dev, &ipoib_path_fops);
if (!priv->path_dentry) if (!priv->path_dentry)
......
...@@ -58,7 +58,7 @@ struct ipoib_ah *ipoib_create_ah(struct net_device *dev, ...@@ -58,7 +58,7 @@ struct ipoib_ah *ipoib_create_ah(struct net_device *dev,
struct ipoib_ah *ah; struct ipoib_ah *ah;
struct ib_ah *vah; struct ib_ah *vah;
ah = kmalloc(sizeof *ah, GFP_KERNEL); ah = kmalloc(sizeof(*ah), GFP_KERNEL);
if (!ah) if (!ah)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -203,7 +203,7 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc) ...@@ -203,7 +203,7 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
} }
memcpy(mapping, priv->rx_ring[wr_id].mapping, memcpy(mapping, priv->rx_ring[wr_id].mapping,
IPOIB_UD_RX_SG * sizeof *mapping); IPOIB_UD_RX_SG * sizeof(*mapping));
/* /*
* If we can't allocate a new RX buffer, dump * If we can't allocate a new RX buffer, dump
......
...@@ -634,7 +634,7 @@ struct ipoib_path_iter *ipoib_path_iter_init(struct net_device *dev) ...@@ -634,7 +634,7 @@ struct ipoib_path_iter *ipoib_path_iter_init(struct net_device *dev)
{ {
struct ipoib_path_iter *iter; struct ipoib_path_iter *iter;
iter = kmalloc(sizeof *iter, GFP_KERNEL); iter = kmalloc(sizeof(*iter), GFP_KERNEL);
if (!iter) if (!iter)
return NULL; return NULL;
...@@ -885,7 +885,7 @@ static struct ipoib_path *path_rec_create(struct net_device *dev, void *gid) ...@@ -885,7 +885,7 @@ static struct ipoib_path *path_rec_create(struct net_device *dev, void *gid)
if (!priv->broadcast) if (!priv->broadcast)
return NULL; return NULL;
path = kzalloc(sizeof *path, GFP_ATOMIC); path = kzalloc(sizeof(*path), GFP_ATOMIC);
if (!path) if (!path)
return NULL; return NULL;
...@@ -1207,7 +1207,7 @@ static int ipoib_hard_header(struct sk_buff *skb, ...@@ -1207,7 +1207,7 @@ static int ipoib_hard_header(struct sk_buff *skb,
{ {
struct ipoib_header *header; struct ipoib_header *header;
header = skb_push(skb, sizeof *header); header = skb_push(skb, sizeof(*header));
header->proto = htons(type); header->proto = htons(type);
header->reserved = 0; header->reserved = 0;
...@@ -1375,7 +1375,7 @@ static struct ipoib_neigh *ipoib_neigh_ctor(u8 *daddr, ...@@ -1375,7 +1375,7 @@ static struct ipoib_neigh *ipoib_neigh_ctor(u8 *daddr,
{ {
struct ipoib_neigh *neigh; struct ipoib_neigh *neigh;
neigh = kzalloc(sizeof *neigh, GFP_ATOMIC); neigh = kzalloc(sizeof(*neigh), GFP_ATOMIC);
if (!neigh) if (!neigh)
return NULL; return NULL;
...@@ -2366,7 +2366,7 @@ static void ipoib_add_one(struct ib_device *device) ...@@ -2366,7 +2366,7 @@ static void ipoib_add_one(struct ib_device *device)
int p; int p;
int count = 0; int count = 0;
dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL); dev_list = kmalloc(sizeof(*dev_list), GFP_KERNEL);
if (!dev_list) if (!dev_list)
return; return;
......
...@@ -140,7 +140,7 @@ static struct ipoib_mcast *ipoib_mcast_alloc(struct net_device *dev, ...@@ -140,7 +140,7 @@ static struct ipoib_mcast *ipoib_mcast_alloc(struct net_device *dev,
{ {
struct ipoib_mcast *mcast; struct ipoib_mcast *mcast;
mcast = kzalloc(sizeof *mcast, can_sleep ? GFP_KERNEL : GFP_ATOMIC); mcast = kzalloc(sizeof(*mcast), can_sleep ? GFP_KERNEL : GFP_ATOMIC);
if (!mcast) if (!mcast)
return NULL; return NULL;
...@@ -917,7 +917,7 @@ void ipoib_mcast_restart_task(struct work_struct *work) ...@@ -917,7 +917,7 @@ void ipoib_mcast_restart_task(struct work_struct *work)
if (!ipoib_mcast_addr_is_valid(ha->addr, dev->broadcast)) if (!ipoib_mcast_addr_is_valid(ha->addr, dev->broadcast))
continue; continue;
memcpy(mgid.raw, ha->addr + 4, sizeof mgid); memcpy(mgid.raw, ha->addr + 4, sizeof(mgid));
mcast = __ipoib_mcast_find(dev, &mgid); mcast = __ipoib_mcast_find(dev, &mgid);
if (!mcast || test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) { if (!mcast || test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) {
...@@ -997,7 +997,7 @@ struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct net_device *dev) ...@@ -997,7 +997,7 @@ struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct net_device *dev)
{ {
struct ipoib_mcast_iter *iter; struct ipoib_mcast_iter *iter;
iter = kmalloc(sizeof *iter, GFP_KERNEL); iter = kmalloc(sizeof(*iter), GFP_KERNEL);
if (!iter) if (!iter)
return NULL; return NULL;
......
...@@ -52,7 +52,7 @@ int ipoib_mcast_attach(struct net_device *dev, struct ib_device *hca, ...@@ -52,7 +52,7 @@ int ipoib_mcast_attach(struct net_device *dev, struct ib_device *hca,
if (set_qkey) { if (set_qkey) {
ret = -ENOMEM; ret = -ENOMEM;
qp_attr = kmalloc(sizeof *qp_attr, GFP_KERNEL); qp_attr = kmalloc(sizeof(*qp_attr), GFP_KERNEL);
if (!qp_attr) if (!qp_attr)
goto out; goto out;
......
...@@ -130,7 +130,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey) ...@@ -130,7 +130,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
if (test_bit(IPOIB_FLAG_GOING_DOWN, &ppriv->flags)) if (test_bit(IPOIB_FLAG_GOING_DOWN, &ppriv->flags))
return -EPERM; return -EPERM;
snprintf(intf_name, sizeof intf_name, "%s.%04x", snprintf(intf_name, sizeof(intf_name), "%s.%04x",
ppriv->dev->name, pkey); ppriv->dev->name, pkey);
if (!mutex_trylock(&ppriv->sysfs_mutex)) if (!mutex_trylock(&ppriv->sysfs_mutex))
......
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