Skip to content

Commit a45e5f1

Browse files
Ruan Jinjierleon
authored andcommitted
RDMA/mlx: Remove unnecessary variable initializations
Remove unnecessary variable initializations. Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> Link: https://lore.kernel.org/r/20230728065139.3411703-1-ruanjinjie@huawei.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent 72d422c commit a45e5f1

File tree

2 files changed

+42
-42
lines changed

2 files changed

+42
-42
lines changed

drivers/infiniband/hw/mlx4/main.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static struct net_device *mlx4_ib_get_netdev(struct ib_device *device,
132132

133133
if (dev) {
134134
if (mlx4_is_bonded(ibdev->dev)) {
135-
struct net_device *upper = NULL;
135+
struct net_device *upper;
136136

137137
upper = netdev_master_upper_dev_get_rcu(dev);
138138
if (upper) {
@@ -254,7 +254,7 @@ static int mlx4_ib_add_gid(const struct ib_gid_attr *attr, void **context)
254254
int ret = 0;
255255
int hw_update = 0;
256256
int i;
257-
struct gid_entry *gids = NULL;
257+
struct gid_entry *gids;
258258
u16 vlan_id = 0xffff;
259259
u8 mac[ETH_ALEN];
260260

@@ -345,7 +345,7 @@ static int mlx4_ib_del_gid(const struct ib_gid_attr *attr, void **context)
345345
struct mlx4_port_gid_table *port_gid_table;
346346
int ret = 0;
347347
int hw_update = 0;
348-
struct gid_entry *gids = NULL;
348+
struct gid_entry *gids;
349349

350350
if (!rdma_cap_roce_gid_table(attr->device, attr->port_num))
351351
return -EINVAL;
@@ -431,8 +431,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
431431
struct ib_udata *uhw)
432432
{
433433
struct mlx4_ib_dev *dev = to_mdev(ibdev);
434-
struct ib_smp *in_mad = NULL;
435-
struct ib_smp *out_mad = NULL;
434+
struct ib_smp *in_mad;
435+
struct ib_smp *out_mad;
436436
int err;
437437
int have_ib_ports;
438438
struct mlx4_uverbs_ex_query_device cmd;
@@ -649,8 +649,8 @@ mlx4_ib_port_link_layer(struct ib_device *device, u32 port_num)
649649
static int ib_link_query_port(struct ib_device *ibdev, u32 port,
650650
struct ib_port_attr *props, int netw_view)
651651
{
652-
struct ib_smp *in_mad = NULL;
653-
struct ib_smp *out_mad = NULL;
652+
struct ib_smp *in_mad;
653+
struct ib_smp *out_mad;
654654
int ext_active_speed;
655655
int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
656656
int err = -ENOMEM;
@@ -827,8 +827,8 @@ static int mlx4_ib_query_port(struct ib_device *ibdev, u32 port,
827827
int __mlx4_ib_query_gid(struct ib_device *ibdev, u32 port, int index,
828828
union ib_gid *gid, int netw_view)
829829
{
830-
struct ib_smp *in_mad = NULL;
831-
struct ib_smp *out_mad = NULL;
830+
struct ib_smp *in_mad;
831+
struct ib_smp *out_mad;
832832
int err = -ENOMEM;
833833
struct mlx4_ib_dev *dev = to_mdev(ibdev);
834834
int clear = 0;
@@ -892,8 +892,8 @@ static int mlx4_ib_query_sl2vl(struct ib_device *ibdev, u32 port,
892892
u64 *sl2vl_tbl)
893893
{
894894
union sl2vl_tbl_to_u64 sl2vl64;
895-
struct ib_smp *in_mad = NULL;
896-
struct ib_smp *out_mad = NULL;
895+
struct ib_smp *in_mad;
896+
struct ib_smp *out_mad;
897897
int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
898898
int err = -ENOMEM;
899899
int jj;
@@ -952,8 +952,8 @@ static void mlx4_init_sl2vl_tbl(struct mlx4_ib_dev *mdev)
952952
int __mlx4_ib_query_pkey(struct ib_device *ibdev, u32 port, u16 index,
953953
u16 *pkey, int netw_view)
954954
{
955-
struct ib_smp *in_mad = NULL;
956-
struct ib_smp *out_mad = NULL;
955+
struct ib_smp *in_mad;
956+
struct ib_smp *out_mad;
957957
int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
958958
int err = -ENOMEM;
959959

@@ -1968,8 +1968,8 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
19681968

19691969
static int init_node_data(struct mlx4_ib_dev *dev)
19701970
{
1971-
struct ib_smp *in_mad = NULL;
1972-
struct ib_smp *out_mad = NULL;
1971+
struct ib_smp *in_mad;
1972+
struct ib_smp *out_mad;
19731973
int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
19741974
int err = -ENOMEM;
19751975

@@ -2621,7 +2621,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
26212621
int num_req_counters;
26222622
int allocated;
26232623
u32 counter_index;
2624-
struct counter_index *new_counter_index = NULL;
2624+
struct counter_index *new_counter_index;
26252625

26262626
pr_info_once("%s", mlx4_ib_version);
26272627

@@ -2923,7 +2923,7 @@ int mlx4_ib_steer_qp_reg(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,
29232923
{
29242924
int err;
29252925
size_t flow_size;
2926-
struct ib_flow_attr *flow = NULL;
2926+
struct ib_flow_attr *flow;
29272927
struct ib_flow_spec_ib *ib_spec;
29282928

29292929
if (is_attach) {
@@ -2943,11 +2943,11 @@ int mlx4_ib_steer_qp_reg(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,
29432943

29442944
err = __mlx4_ib_create_flow(&mqp->ibqp, flow, MLX4_DOMAIN_NIC,
29452945
MLX4_FS_REGULAR, &mqp->reg_id);
2946-
} else {
2947-
err = __mlx4_ib_destroy_flow(mdev->dev, mqp->reg_id);
2946+
kfree(flow);
2947+
return err;
29482948
}
2949-
kfree(flow);
2950-
return err;
2949+
2950+
return __mlx4_ib_destroy_flow(mdev->dev, mqp->reg_id);
29512951
}
29522952

29532953
static void mlx4_ib_remove(struct mlx4_dev *dev, void *ibdev_ptr)
@@ -2992,7 +2992,7 @@ static void mlx4_ib_remove(struct mlx4_dev *dev, void *ibdev_ptr)
29922992

29932993
static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
29942994
{
2995-
struct mlx4_ib_demux_work **dm = NULL;
2995+
struct mlx4_ib_demux_work **dm;
29962996
struct mlx4_dev *dev = ibdev->dev;
29972997
int i;
29982998
unsigned long flags;

drivers/infiniband/hw/mlx5/mad.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u32 port_num,
308308

309309
int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, unsigned int port)
310310
{
311-
struct ib_smp *in_mad = NULL;
312-
struct ib_smp *out_mad = NULL;
311+
struct ib_smp *in_mad;
312+
struct ib_smp *out_mad;
313313
int err = -ENOMEM;
314314
u16 packet_error;
315315

@@ -338,8 +338,8 @@ int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, unsigned int port)
338338
static int mlx5_query_mad_ifc_smp_attr_node_info(struct ib_device *ibdev,
339339
struct ib_smp *out_mad)
340340
{
341-
struct ib_smp *in_mad = NULL;
342-
int err = -ENOMEM;
341+
struct ib_smp *in_mad;
342+
int err;
343343

344344
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
345345
if (!in_mad)
@@ -358,8 +358,8 @@ static int mlx5_query_mad_ifc_smp_attr_node_info(struct ib_device *ibdev,
358358
int mlx5_query_mad_ifc_system_image_guid(struct ib_device *ibdev,
359359
__be64 *sys_image_guid)
360360
{
361-
struct ib_smp *out_mad = NULL;
362-
int err = -ENOMEM;
361+
struct ib_smp *out_mad;
362+
int err;
363363

364364
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
365365
if (!out_mad)
@@ -380,8 +380,8 @@ int mlx5_query_mad_ifc_system_image_guid(struct ib_device *ibdev,
380380
int mlx5_query_mad_ifc_max_pkeys(struct ib_device *ibdev,
381381
u16 *max_pkeys)
382382
{
383-
struct ib_smp *out_mad = NULL;
384-
int err = -ENOMEM;
383+
struct ib_smp *out_mad;
384+
int err;
385385

386386
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
387387
if (!out_mad)
@@ -402,8 +402,8 @@ int mlx5_query_mad_ifc_max_pkeys(struct ib_device *ibdev,
402402
int mlx5_query_mad_ifc_vendor_id(struct ib_device *ibdev,
403403
u32 *vendor_id)
404404
{
405-
struct ib_smp *out_mad = NULL;
406-
int err = -ENOMEM;
405+
struct ib_smp *out_mad;
406+
int err;
407407

408408
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
409409
if (!out_mad)
@@ -423,8 +423,8 @@ int mlx5_query_mad_ifc_vendor_id(struct ib_device *ibdev,
423423

424424
int mlx5_query_mad_ifc_node_desc(struct mlx5_ib_dev *dev, char *node_desc)
425425
{
426-
struct ib_smp *in_mad = NULL;
427-
struct ib_smp *out_mad = NULL;
426+
struct ib_smp *in_mad;
427+
struct ib_smp *out_mad;
428428
int err = -ENOMEM;
429429

430430
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
@@ -448,8 +448,8 @@ int mlx5_query_mad_ifc_node_desc(struct mlx5_ib_dev *dev, char *node_desc)
448448

449449
int mlx5_query_mad_ifc_node_guid(struct mlx5_ib_dev *dev, __be64 *node_guid)
450450
{
451-
struct ib_smp *in_mad = NULL;
452-
struct ib_smp *out_mad = NULL;
451+
struct ib_smp *in_mad;
452+
struct ib_smp *out_mad;
453453
int err = -ENOMEM;
454454

455455
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
@@ -474,8 +474,8 @@ int mlx5_query_mad_ifc_node_guid(struct mlx5_ib_dev *dev, __be64 *node_guid)
474474
int mlx5_query_mad_ifc_pkey(struct ib_device *ibdev, u32 port, u16 index,
475475
u16 *pkey)
476476
{
477-
struct ib_smp *in_mad = NULL;
478-
struct ib_smp *out_mad = NULL;
477+
struct ib_smp *in_mad;
478+
struct ib_smp *out_mad;
479479
int err = -ENOMEM;
480480

481481
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
@@ -503,8 +503,8 @@ int mlx5_query_mad_ifc_pkey(struct ib_device *ibdev, u32 port, u16 index,
503503
int mlx5_query_mad_ifc_gids(struct ib_device *ibdev, u32 port, int index,
504504
union ib_gid *gid)
505505
{
506-
struct ib_smp *in_mad = NULL;
507-
struct ib_smp *out_mad = NULL;
506+
struct ib_smp *in_mad;
507+
struct ib_smp *out_mad;
508508
int err = -ENOMEM;
509509

510510
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
@@ -545,8 +545,8 @@ int mlx5_query_mad_ifc_port(struct ib_device *ibdev, u32 port,
545545
{
546546
struct mlx5_ib_dev *dev = to_mdev(ibdev);
547547
struct mlx5_core_dev *mdev = dev->mdev;
548-
struct ib_smp *in_mad = NULL;
549-
struct ib_smp *out_mad = NULL;
548+
struct ib_smp *in_mad;
549+
struct ib_smp *out_mad;
550550
int ext_active_speed;
551551
int err = -ENOMEM;
552552

0 commit comments

Comments
 (0)