Bug 98271 - Suspected bug in drivers/net/ethernet/mellanox/mlx4/resource_tracker.c function ‘verify_qp_parameters’ (misleading indentation)
Summary: Suspected bug in drivers/net/ethernet/mellanox/mlx4/resource_tracker.c functi...
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Network (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_network@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-13 18:35 UTC by Dave Malcolm
Modified: 2016-03-19 17:14 UTC (History)
1 user (show)

See Also:
Kernel Version: 4.0.3
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Dave Malcolm 2015-05-13 18:35:43 UTC
In linux-4.0.3/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c function "verify_qp_parameters":

  2957                  switch (transition) {
  2958                  case QP_TRANS_INIT2RTR:
  2959                  case QP_TRANS_RTR2RTS:
  2960                  case QP_TRANS_RTS2RTS:
  2961                  case QP_TRANS_SQD2SQD:
  2962                  case QP_TRANS_SQD2RTS:
  2963                          if (slave != mlx4_master_func_num(dev))
  2964                                  if (optpar & MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH) {
  2965                                          port = (qp_ctx->pri_path.sched_queue >> 6 & 1) + 1;
  2966                                          if (dev->caps.port_mask[port] != MLX4_PORT_TYPE_IB)
  2967                                                  num_gids = mlx4_get_slave_num_gids(dev, slave, port);
  2968                                          else
  2969                                                  num_gids = 1;
  2970                                          if (qp_ctx->pri_path.mgid_index >= num_gids)
  2971                                                  return -EINVAL;
  2972                                  }
  2973                                  if (optpar & MLX4_QP_OPTPAR_ALT_ADDR_PATH) {
  2974                                          port = (qp_ctx->alt_path.sched_queue >> 6 & 1) + 1;
  2975                                          if (dev->caps.port_mask[port] != MLX4_PORT_TYPE_IB)
  2976                                                  num_gids = mlx4_get_slave_num_gids(dev, slave, port);
  2977                                          else
  2978                                                  num_gids = 1;
  2979                                          if (qp_ctx->alt_path.mgid_index >= num_gids)
  2980                                                  return -EINVAL;
  2981                                  }
  2982                          break;
  2983                  default:
  2984                          break;
  2985                  }

Note how the "if" clause at line 2963 doesn't have braces, and hence only guards the "if" at line 2964, *not* the "if" at line 2973.  Should it?

Seen via an experimental new gcc warning I'm working on for gcc 6, -Wmisleading-indentation, using gcc r223098 adding -Werror=misleading-indentation" to KBUILD_CFLAGS in Makefile, where the experimental gcc emits this error:

drivers/net/ethernet/mellanox/mlx4/resource_tracker.c: In function ‘verify_qp_parameters’:
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:2973:5: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
     if (optpar & MLX4_QP_OPTPAR_ALT_ADDR_PATH) {
     ^
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:2963:4: note: ...this ‘if’ clause, but it is not
    if (slave != mlx4_master_func_num(dev))
    ^
Comment 1 Dave Malcolm 2015-05-20 19:42:35 UTC
Retested with -rc git; still present as of 1113cdfe7d2c1fe08b64caa3affe19260e66dd95.

Note You need to log in before you can comment on or make changes to this bug.