mbox series

[00/14] SCSI: Replace ternary operations with min()/max() macros

Message ID 20240626101342.1440049-1-prabhakar.pujeri@gmail.com
Headers show
Series SCSI: Replace ternary operations with min()/max() macros | expand

Message

Prabhakar Pujeri June 26, 2024, 10:13 a.m. UTC
Hi All,

This patch series, generated using Coccinelle, aims to improve code readability and maintainability by replacing ternary operations with the min() and max() macros where applicable in the SCSI subsystem.

I acknowledge that some of these drivers are old and may not require modifications unless addressing critical issues. However, I intend to include these patches for those older drivers alongside any future critical fixes.

The patches have been compiled and tested on an x86_64 system. Physical device testing was conducted for the megaraid_sas and mpi3mr drivers.


Prabhakar Pujeri (14):
  scsi: advansys: Simplified memcpy length calculation in adv_build_req
  scsi: bfa: Used min() in fc_rftid_build_sol for bitmap size
  scsi: bfa:Simplified logic in bfa_fcs_rport_update and bfa_sgpg_mfree
  scsi: cxlflash: Replaced ternary operation in write_same16 with min()
  scsi: hpsa: Used min() for sense data size and buffer size in
    complete_scsi_command and hpsa_vpd_page_supported
  scsi: megaraid_sas: Simplified transfer length calculation using max()
    in mega_m_to_n
  scsi: megaraid_sas: Replaced ternary operation with max() in
    megasas_alloc_irq_vectors
  scsi: mpi3mr: Used min() in mpi3mr_map_data_buffer_dma for buffer size
  scsi: ncr53c8xx: Simplified tag number calculation with max() in
    ncr_sir_to_redo
  scsi: qla2xxx: Used max() for queue count in qla25xx_copy_mq
  scsi: qla2xxx: Simplified outstanding commands calculation in
    qla2x00_alloc_outstanding_cmds and qla24xx_read_fcp_prio_cfg
  scsi: scsi_debug: Replaced ternary operation with min() in
    resp_get_lba_status
  scsi: scsi_transport_spi: Simplified period calculation with max() in
    spi_dv_retrain
  scsi: st: Used max() for buffer size in setup_buffering and Simplified
    transfer calculations in st_read, append_to_buffer, and from_buffer

 drivers/scsi/advansys.c                   |  2 +-
 drivers/scsi/bfa/bfa_fcbuild.c            |  2 +-
 drivers/scsi/bfa/bfa_fcs_rport.c          |  6 ++----
 drivers/scsi/bfa/bfa_svc.c                |  5 +----
 drivers/scsi/cxlflash/vlun.c              |  2 +-
 drivers/scsi/hpsa.c                       | 11 +++--------
 drivers/scsi/megaraid.c                   |  3 +--
 drivers/scsi/megaraid/megaraid_sas_base.c |  5 +----
 drivers/scsi/mpi3mr/mpi3mr_app.c          |  7 ++-----
 drivers/scsi/ncr53c8xx.c                  |  2 +-
 drivers/scsi/qla2xxx/qla_dbg.c            |  3 +--
 drivers/scsi/qla2xxx/qla_init.c           |  6 ++----
 drivers/scsi/qla2xxx/qla_sup.c            |  2 +-
 drivers/scsi/scsi_debug.c                 |  5 +----
 drivers/scsi/scsi_transport_spi.c         |  2 +-
 drivers/scsi/st.c                         | 10 ++++------
 16 files changed, 24 insertions(+), 49 deletions(-)

--
2.45.1

Comments

Martin K. Petersen June 27, 2024, 3:20 a.m. UTC | #1
Hi Prabhakar!

> This patch series, generated using Coccinelle, aims to improve code
> readability and maintainability by replacing ternary operations with
> the min() and max() macros where applicable in the SCSI subsystem.

Your proposed changes do not improve maintainability. They are creating
additional maintenance work and making backports of bug fixes more
difficult. Plus they introduce the potential for regressions of tried
and true code. So the series has the opposite effect of what is claimed.

Readability is in the eye of the beholder. Whether to use one approach
or the other is the code author's choice...
Bart Van Assche June 27, 2024, 4:20 p.m. UTC | #2
On 6/26/24 3:13 AM, Prabhakar Pujeri wrote:
> The patches have been compiled and tested on an x86_64 system.
> Physical device testing was conducted for the megaraid_sas and mpi3mr
> drivers.

Compiled? Really? So why is the kernel test robot complaining?

A script that builds all SCSI drivers is available here:

https://github.com/bvanassche/build-scsi-drivers

Bart.