Skip to content

drivers/usb: refactor min/max with min_t/max_t

Sabyrzhan Tasbolatov linux-usb lkml 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest8 patches 1 replyIn review
  2. v11 patch 1 replySuperseded

Changes in v2 from the cover letter

- split a single patch into a patch series per each drivers/usb/* subdirectory (Greg).

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8drivers/usb/gadget: refactor min with min_tdrivers/usb/gadget/composite.c drivers/usb/gadget/configfs.c drivers/usb/gadget/function/f_fs.c +5 more+21 -210 replies
2/8drivers/usb/core: refactor max with max_tdrivers/usb/core/config.c+1 -10 replies
3/8drivers/usb/host: refactor min/max with min_t/max_tdrivers/usb/host/ehci-hcd.c drivers/usb/host/oxu210hp-hcd.c drivers/usb/host/r8a66597-hcd.c+4 -40 replies
4/8drivers/usb/misc: refactor min with min_tdrivers/usb/misc/usbtest.c+2 -10 replies
5/8drivers/usb/mon: refactor min with min_tdrivers/usb/mon/mon_bin.c+1 -10 replies
6/8drivers/usb/musb: refactor min/max with min_t/max_tdrivers/usb/musb/musb_core.c drivers/usb/musb/musb_gadget_ep0.c drivers/usb/musb/musb_host.c+4 -50 replies
7/8drivers/usb/serial: refactor min with min_tdrivers/usb/serial/io_edgeport.c drivers/usb/serial/sierra.c+2 -20 replies
8/8drivers/usb/storage: refactor min with min_tdrivers/usb/storage/sddr09.c drivers/usb/storage/sddr55.c+6 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/8] drivers/usb: refactor min/max with min_t/max_t

This patch series improves type safety in the drivers/usb/*
by using min_t() and max_t() instead of min(), max()
with the casting inside. It should address potential type promotion issues.

Scanned the current drivers/usb code with max\(.*\( and min\(.*\( regexp queries to find casting inside of min() and max() which may lead to subtle bugs or even security vulnerabilities, especially if negative values are involved.

Let's refactor to min_t() and max_t() specifying the data type to ensure it's applicable for the both compareable arguments.

Changes v1 -> v2:
- split a single patch into a patch series per each drivers/usb/* subdirectory (Greg).

Sabyrzhan Tasbolatov (8):
drivers/usb/gadget: refactor min with min_t drivers/usb/core: refactor max with max_t drivers/usb/host: refactor min/max with min_t/max_t drivers/usb/misc: refactor min with min_t drivers/usb/mon: refactor min with min_t drivers/usb/musb: refactor min/max with min_t/max_t drivers/usb/serial: refactor min with min_t drivers/usb/storage: refactor min with min_t

 drivers/usb/core/config.c                    |  2 +-
 drivers/usb/gadget/composite.c               | 12 ++++++------
 drivers/usb/gadget/configfs.c                |  2 +-
 drivers/usb/gadget/function/f_fs.c           |  6 +++---
 drivers/usb/gadget/function/f_mass_storage.c |  8 ++++----
 drivers/usb/gadget/function/uvc_video.c      |  4 ++--
 drivers/usb/gadget/legacy/raw_gadget.c       |  4 ++--
 drivers/usb/gadget/udc/omap_udc.c            |  4 ++--
 drivers/usb/gadget/usbstring.c               |  2 +-
 drivers/usb/host/ehci-hcd.c                  |  2 +-
 drivers/usb/host/oxu210hp-hcd.c              |  4 ++--
 drivers/usb/host/r8a66597-hcd.c              |  2 +-
 drivers/usb/misc/usbtest.c                   |  3 ++-
 drivers/usb/mon/mon_bin.c                    |  2 +-
 drivers/usb/musb/musb_core.c                 |  2 +-
 drivers/usb/musb/musb_gadget_ep0.c           |  2 +-
 drivers/usb/musb/musb_host.c                 |  5 ++---
 drivers/usb/serial/io_edgeport.c             |  2 +-
 drivers/usb/serial/sierra.c                  |  2 +-
 drivers/usb/storage/sddr09.c                 |  4 ++--
 drivers/usb/storage/sddr55.c                 |  8 ++++----
 21 files changed, 41 insertions(+), 41 deletions(-)
Signature · 1 line
2.34.1