Skip to content

Commit 5022111

Browse files
committed
Merge branch 'net-sizeof-cleanups'
Stephen Hemminger says: ==================== net: various sizeof cleanups Noticed some places that were using sizeof as an operator. This is legal C but is not the convention used in the kernel. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 6b0355f + 31975e2 commit 5022111

File tree

19 files changed

+60
-60
lines changed

19 files changed

+60
-60
lines changed

drivers/net/ethernet/marvell/skge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3516,7 +3516,7 @@ static const char *skge_board_name(const struct skge_hw *hw)
35163516
if (skge_chips[i].id == hw->chip_id)
35173517
return skge_chips[i].name;
35183518

3519-
snprintf(buf, sizeof buf, "chipid 0x%x", hw->chip_id);
3519+
snprintf(buf, sizeof(buf), "chipid 0x%x", hw->chip_id);
35203520
return buf;
35213521
}
35223522

drivers/net/ethernet/mellanox/mlx4/alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask,
186186
bitmap->effective_len = bitmap->avail;
187187
spin_lock_init(&bitmap->lock);
188188
bitmap->table = kzalloc(BITS_TO_LONGS(bitmap->max) *
189-
sizeof (long), GFP_KERNEL);
189+
sizeof(long), GFP_KERNEL);
190190
if (!bitmap->table)
191191
return -ENOMEM;
192192

drivers/net/ethernet/mellanox/mlx4/cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2637,7 +2637,7 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev)
26372637
int err = 0;
26382638

26392639
priv->cmd.context = kmalloc(priv->cmd.max_cmds *
2640-
sizeof (struct mlx4_cmd_context),
2640+
sizeof(struct mlx4_cmd_context),
26412641
GFP_KERNEL);
26422642
if (!priv->cmd.context)
26432643
return -ENOMEM;
@@ -2695,7 +2695,7 @@ struct mlx4_cmd_mailbox *mlx4_alloc_cmd_mailbox(struct mlx4_dev *dev)
26952695
{
26962696
struct mlx4_cmd_mailbox *mailbox;
26972697

2698-
mailbox = kmalloc(sizeof *mailbox, GFP_KERNEL);
2698+
mailbox = kmalloc(sizeof(*mailbox), GFP_KERNEL);
26992699
if (!mailbox)
27002700
return ERR_PTR(-ENOMEM);
27012701

drivers/net/ethernet/mellanox/mlx4/en_resources.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride,
4444
struct mlx4_en_dev *mdev = priv->mdev;
4545
struct net_device *dev = priv->dev;
4646

47-
memset(context, 0, sizeof *context);
47+
memset(context, 0, sizeof(*context));
4848
context->flags = cpu_to_be32(7 << 16 | rss << MLX4_RSS_QPC_FLAG_OFFSET);
4949
context->pd = cpu_to_be32(mdev->priv_pdn);
5050
context->mtu_msgmax = 0xff;

drivers/net/ethernet/mellanox/mlx4/en_rx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn,
10561056
}
10571057
qp->event = mlx4_en_sqp_event;
10581058

1059-
memset(context, 0, sizeof *context);
1059+
memset(context, 0, sizeof(*context));
10601060
mlx4_en_fill_qp_context(priv, ring->actual_size, ring->stride, 0, 0,
10611061
qpn, ring->cqn, -1, context);
10621062
context->db_rec_addr = cpu_to_be64(ring->wqres.db.dma);

drivers/net/ethernet/mellanox/mlx4/en_tx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc,
643643
void *fragptr)
644644
{
645645
struct mlx4_wqe_inline_seg *inl = &tx_desc->inl;
646-
int spc = MLX4_INLINE_ALIGN - CTRL_SIZE - sizeof *inl;
646+
int spc = MLX4_INLINE_ALIGN - CTRL_SIZE - sizeof(*inl);
647647
unsigned int hlen = skb_headlen(skb);
648648

649649
if (skb->len <= spc) {

drivers/net/ethernet/mellanox/mlx4/eq.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ int mlx4_gen_pkey_eqe(struct mlx4_dev *dev, int slave, u8 port)
259259
if (!s_slave->active)
260260
return 0;
261261

262-
memset(&eqe, 0, sizeof eqe);
262+
memset(&eqe, 0, sizeof(eqe));
263263

264264
eqe.type = MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT;
265265
eqe.subtype = MLX4_DEV_PMC_SUBTYPE_PKEY_TABLE;
@@ -276,7 +276,7 @@ int mlx4_gen_guid_change_eqe(struct mlx4_dev *dev, int slave, u8 port)
276276
/*don't send if we don't have the that slave */
277277
if (dev->persist->num_vfs < slave)
278278
return 0;
279-
memset(&eqe, 0, sizeof eqe);
279+
memset(&eqe, 0, sizeof(eqe));
280280

281281
eqe.type = MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT;
282282
eqe.subtype = MLX4_DEV_PMC_SUBTYPE_GUID_INFO;
@@ -295,7 +295,7 @@ int mlx4_gen_port_state_change_eqe(struct mlx4_dev *dev, int slave, u8 port,
295295
/*don't send if we don't have the that slave */
296296
if (dev->persist->num_vfs < slave)
297297
return 0;
298-
memset(&eqe, 0, sizeof eqe);
298+
memset(&eqe, 0, sizeof(eqe));
299299

300300
eqe.type = MLX4_EVENT_TYPE_PORT_CHANGE;
301301
eqe.subtype = port_subtype_change;
@@ -432,7 +432,7 @@ int mlx4_gen_slaves_port_mgt_ev(struct mlx4_dev *dev, u8 port, int attr)
432432
{
433433
struct mlx4_eqe eqe;
434434

435-
memset(&eqe, 0, sizeof eqe);
435+
memset(&eqe, 0, sizeof(eqe));
436436

437437
eqe.type = MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT;
438438
eqe.subtype = MLX4_DEV_PMC_SUBTYPE_PORT_INFO;
@@ -726,7 +726,7 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq)
726726
}
727727
memcpy(&priv->mfunc.master.comm_arm_bit_vector,
728728
eqe->event.comm_channel_arm.bit_vec,
729-
sizeof eqe->event.comm_channel_arm.bit_vec);
729+
sizeof(eqe)->event.comm_channel_arm.bit_vec);
730730
queue_work(priv->mfunc.master.comm_wq,
731731
&priv->mfunc.master.comm_work);
732732
break;
@@ -984,15 +984,15 @@ static int mlx4_create_eq(struct mlx4_dev *dev, int nent,
984984
*/
985985
npages = PAGE_ALIGN(eq->nent * dev->caps.eqe_size) / PAGE_SIZE;
986986

987-
eq->page_list = kmalloc(npages * sizeof *eq->page_list,
988-
GFP_KERNEL);
987+
eq->page_list = kmalloc_array(npages, sizeof(*eq->page_list),
988+
GFP_KERNEL);
989989
if (!eq->page_list)
990990
goto err_out;
991991

992992
for (i = 0; i < npages; ++i)
993993
eq->page_list[i].buf = NULL;
994994

995-
dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
995+
dma_list = kmalloc_array(npages, sizeof(*dma_list), GFP_KERNEL);
996996
if (!dma_list)
997997
goto err_out_free;
998998

@@ -1161,7 +1161,7 @@ int mlx4_alloc_eq_table(struct mlx4_dev *dev)
11611161
struct mlx4_priv *priv = mlx4_priv(dev);
11621162

11631163
priv->eq_table.eq = kcalloc(dev->caps.num_eqs - dev->caps.reserved_eqs,
1164-
sizeof *priv->eq_table.eq, GFP_KERNEL);
1164+
sizeof(*priv->eq_table.eq), GFP_KERNEL);
11651165
if (!priv->eq_table.eq)
11661166
return -ENOMEM;
11671167

@@ -1180,7 +1180,7 @@ int mlx4_init_eq_table(struct mlx4_dev *dev)
11801180
int i;
11811181

11821182
priv->eq_table.uar_map = kcalloc(mlx4_num_eq_uar(dev),
1183-
sizeof *priv->eq_table.uar_map,
1183+
sizeof(*priv->eq_table.uar_map),
11841184
GFP_KERNEL);
11851185
if (!priv->eq_table.uar_map) {
11861186
err = -ENOMEM;

drivers/net/ethernet/mellanox/mlx4/fw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ MODULE_PARM_DESC(enable_qos, "Enable Enhanced QoS support (default: off)");
5757
do { \
5858
void *__p = (char *) (source) + (offset); \
5959
u64 val; \
60-
switch (sizeof (dest)) { \
60+
switch (sizeof(dest)) { \
6161
case 1: (dest) = *(u8 *) __p; break; \
6262
case 2: (dest) = be16_to_cpup(__p); break; \
6363
case 4: (dest) = be32_to_cpup(__p); break; \

drivers/net/ethernet/mellanox/mlx4/icm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table,
400400
obj_per_chunk = MLX4_TABLE_CHUNK_SIZE / obj_size;
401401
num_icm = (nobj + obj_per_chunk - 1) / obj_per_chunk;
402402

403-
table->icm = kcalloc(num_icm, sizeof *table->icm, GFP_KERNEL);
403+
table->icm = kcalloc(num_icm, sizeof(*table->icm), GFP_KERNEL);
404404
if (!table->icm)
405405
return -ENOMEM;
406406
table->virt = virt;

drivers/net/ethernet/mellanox/mlx4/icm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
#include <linux/mutex.h>
4040

4141
#define MLX4_ICM_CHUNK_LEN \
42-
((256 - sizeof (struct list_head) - 2 * sizeof (int)) / \
43-
(sizeof (struct scatterlist)))
42+
((256 - sizeof(struct list_head) - 2 * sizeof(int)) / \
43+
(sizeof(struct scatterlist)))
4444

4545
enum {
4646
MLX4_ICM_PAGE_SHIFT = 12,

drivers/net/ethernet/mellanox/mlx4/intf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static void mlx4_add_device(struct mlx4_interface *intf, struct mlx4_priv *priv)
5353
{
5454
struct mlx4_device_context *dev_ctx;
5555

56-
dev_ctx = kmalloc(sizeof *dev_ctx, GFP_KERNEL);
56+
dev_ctx = kmalloc(sizeof(*dev_ctx), GFP_KERNEL);
5757
if (!dev_ctx)
5858
return;
5959

drivers/net/ethernet/mellanox/mlx4/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -925,10 +925,10 @@ static int mlx4_slave_cap(struct mlx4_dev *dev)
925925
mlx4_replace_zero_macs(dev);
926926

927927
dev->caps.qp0_qkey = kcalloc(dev->caps.num_ports, sizeof(u32), GFP_KERNEL);
928-
dev->caps.qp0_tunnel = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL);
929-
dev->caps.qp0_proxy = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL);
930-
dev->caps.qp1_tunnel = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL);
931-
dev->caps.qp1_proxy = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL);
928+
dev->caps.qp0_tunnel = kcalloc(dev->caps.num_ports, sizeof(u32), GFP_KERNEL);
929+
dev->caps.qp0_proxy = kcalloc(dev->caps.num_ports, sizeof(u32), GFP_KERNEL);
930+
dev->caps.qp1_tunnel = kcalloc(dev->caps.num_ports, sizeof(u32), GFP_KERNEL);
931+
dev->caps.qp1_proxy = kcalloc(dev->caps.num_ports, sizeof(u32), GFP_KERNEL);
932932

933933
if (!dev->caps.qp0_tunnel || !dev->caps.qp0_proxy ||
934934
!dev->caps.qp1_tunnel || !dev->caps.qp1_proxy ||
@@ -2399,7 +2399,7 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
23992399
dev->caps.rx_checksum_flags_port[2] = params.rx_csum_flags_port_2;
24002400
}
24012401
priv->eq_table.inta_pin = adapter.inta_pin;
2402-
memcpy(dev->board_id, adapter.board_id, sizeof dev->board_id);
2402+
memcpy(dev->board_id, adapter.board_id, sizeof(dev->board_id));
24032403

24042404
return 0;
24052405

@@ -2869,7 +2869,7 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
28692869
dev->caps.num_eqs - dev->caps.reserved_eqs,
28702870
MAX_MSIX);
28712871

2872-
entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
2872+
entries = kcalloc(nreq, sizeof(*entries), GFP_KERNEL);
28732873
if (!entries)
28742874
goto no_msi;
28752875

drivers/net/ethernet/mellanox/mlx4/mcg.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static int new_steering_entry(struct mlx4_dev *dev, u8 port,
162162
return -EINVAL;
163163

164164
s_steer = &mlx4_priv(dev)->steer[port - 1];
165-
new_entry = kzalloc(sizeof *new_entry, GFP_KERNEL);
165+
new_entry = kzalloc(sizeof(*new_entry), GFP_KERNEL);
166166
if (!new_entry)
167167
return -ENOMEM;
168168

@@ -175,7 +175,7 @@ static int new_steering_entry(struct mlx4_dev *dev, u8 port,
175175
*/
176176
pqp = get_promisc_qp(dev, port, steer, qpn);
177177
if (pqp) {
178-
dqp = kmalloc(sizeof *dqp, GFP_KERNEL);
178+
dqp = kmalloc(sizeof(*dqp), GFP_KERNEL);
179179
if (!dqp) {
180180
err = -ENOMEM;
181181
goto out_alloc;
@@ -274,7 +274,7 @@ static int existing_steering_entry(struct mlx4_dev *dev, u8 port,
274274
}
275275

276276
/* add the qp as a duplicate on this index */
277-
dqp = kmalloc(sizeof *dqp, GFP_KERNEL);
277+
dqp = kmalloc(sizeof(*dqp), GFP_KERNEL);
278278
if (!dqp)
279279
return -ENOMEM;
280280
dqp->qpn = qpn;
@@ -443,7 +443,7 @@ static int add_promisc_qp(struct mlx4_dev *dev, u8 port,
443443
goto out_mutex;
444444
}
445445

446-
pqp = kmalloc(sizeof *pqp, GFP_KERNEL);
446+
pqp = kmalloc(sizeof(*pqp), GFP_KERNEL);
447447
if (!pqp) {
448448
err = -ENOMEM;
449449
goto out_mutex;
@@ -514,7 +514,7 @@ static int add_promisc_qp(struct mlx4_dev *dev, u8 port,
514514
/* add the new qpn to list of promisc qps */
515515
list_add_tail(&pqp->list, &s_steer->promisc_qps[steer]);
516516
/* now need to add all the promisc qps to default entry */
517-
memset(mgm, 0, sizeof *mgm);
517+
memset(mgm, 0, sizeof(*mgm));
518518
members_count = 0;
519519
list_for_each_entry(dqp, &s_steer->promisc_qps[steer], list) {
520520
if (members_count == dev->caps.num_qp_per_mgm) {
@@ -1144,7 +1144,7 @@ int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
11441144
index += dev->caps.num_mgms;
11451145

11461146
new_entry = 1;
1147-
memset(mgm, 0, sizeof *mgm);
1147+
memset(mgm, 0, sizeof(*mgm));
11481148
memcpy(mgm->gid, gid, 16);
11491149
}
11501150

drivers/net/ethernet/mellanox/mlx4/mr.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ static int mlx4_buddy_init(struct mlx4_buddy *buddy, int max_order)
106106
buddy->max_order = max_order;
107107
spin_lock_init(&buddy->lock);
108108

109-
buddy->bits = kcalloc(buddy->max_order + 1, sizeof (long *),
109+
buddy->bits = kcalloc(buddy->max_order + 1, sizeof(long *),
110110
GFP_KERNEL);
111-
buddy->num_free = kcalloc((buddy->max_order + 1), sizeof *buddy->num_free,
111+
buddy->num_free = kcalloc(buddy->max_order + 1, sizeof(*buddy->num_free),
112112
GFP_KERNEL);
113113
if (!buddy->bits || !buddy->num_free)
114114
goto err_out;
@@ -703,13 +703,13 @@ static int mlx4_write_mtt_chunk(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
703703
return -ENOMEM;
704704

705705
dma_sync_single_for_cpu(&dev->persist->pdev->dev, dma_handle,
706-
npages * sizeof (u64), DMA_TO_DEVICE);
706+
npages * sizeof(u64), DMA_TO_DEVICE);
707707

708708
for (i = 0; i < npages; ++i)
709709
mtts[i] = cpu_to_be64(page_list[i] | MLX4_MTT_FLAG_PRESENT);
710710

711711
dma_sync_single_for_device(&dev->persist->pdev->dev, dma_handle,
712-
npages * sizeof (u64), DMA_TO_DEVICE);
712+
npages * sizeof(u64), DMA_TO_DEVICE);
713713

714714
return 0;
715715
}
@@ -1052,7 +1052,7 @@ int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages,
10521052
return -EINVAL;
10531053

10541054
/* All MTTs must fit in the same page */
1055-
if (max_pages * sizeof *fmr->mtts > PAGE_SIZE)
1055+
if (max_pages * sizeof(*fmr->mtts) > PAGE_SIZE)
10561056
return -EINVAL;
10571057

10581058
fmr->page_shift = page_shift;

drivers/net/ethernet/mellanox/mlx4/qp.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static int __mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
174174
cpu_to_be16(mlx4_qp_roce_entropy(dev, qp->qpn));
175175

176176
*(__be32 *) mailbox->buf = cpu_to_be32(optpar);
177-
memcpy(mailbox->buf + 8, context, sizeof *context);
177+
memcpy(mailbox->buf + 8, context, sizeof(*context));
178178

179179
((struct mlx4_qp_context *) (mailbox->buf + 8))->local_qpn =
180180
cpu_to_be32(qp->qpn);
@@ -844,10 +844,10 @@ int mlx4_init_qp_table(struct mlx4_dev *dev)
844844

845845
/* In mfunc, calculate proxy and tunnel qp offsets for the PF here,
846846
* since the PF does not call mlx4_slave_caps */
847-
dev->caps.qp0_tunnel = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL);
848-
dev->caps.qp0_proxy = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL);
849-
dev->caps.qp1_tunnel = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL);
850-
dev->caps.qp1_proxy = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL);
847+
dev->caps.qp0_tunnel = kcalloc(dev->caps.num_ports, sizeof(u32), GFP_KERNEL);
848+
dev->caps.qp0_proxy = kcalloc(dev->caps.num_ports, sizeof(u32), GFP_KERNEL);
849+
dev->caps.qp1_tunnel = kcalloc(dev->caps.num_ports, sizeof(u32), GFP_KERNEL);
850+
dev->caps.qp1_proxy = kcalloc(dev->caps.num_ports, sizeof(u32), GFP_KERNEL);
851851

852852
if (!dev->caps.qp0_tunnel || !dev->caps.qp0_proxy ||
853853
!dev->caps.qp1_tunnel || !dev->caps.qp1_proxy) {
@@ -907,7 +907,7 @@ int mlx4_qp_query(struct mlx4_dev *dev, struct mlx4_qp *qp,
907907
MLX4_CMD_QUERY_QP, MLX4_CMD_TIME_CLASS_A,
908908
MLX4_CMD_WRAPPED);
909909
if (!err)
910-
memcpy(context, mailbox->buf + 8, sizeof *context);
910+
memcpy(context, mailbox->buf + 8, sizeof(*context));
911911

912912
mlx4_free_cmd_mailbox(dev, mailbox);
913913
return err;

0 commit comments

Comments
 (0)