diff mbox series

[v2] ata: pata_via: fix sloppy typing in via_do_set_mode()

Message ID e8d0b22b-9052-7cfc-4088-b407643c4bf8@omp.ru
State New
Headers show
Series [v2] ata: pata_via: fix sloppy typing in via_do_set_mode() | expand

Commit Message

Sergey Shtylyov April 12, 2022, 8:39 p.m. UTC
The local variables 'T' and 'UT' are needlessly declared as *unsigned*
*long* -- the corresponding parameters of ata_timing_compute() are both
declared as *int*.  While fixing up those declarations, also make the
'via_clock' and 'T' variables *const* as they are never re-assigned
after initialization -- the object code should remain the same as gcc
previously used copy propagation anyway...

Found by Linux Verification Center (linuxtesting.org) with the SVACE static
analysis tool.

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

---
This patch is against the 'for-next' branch of Damien Le Moal's 'libata.git'
repo.

Changes in version 2:
- declared the 'T' and 'UT' variables as *int* instead of *unsigned long*;
- dropped *unsigned* from the 'via_clock' variable declaration;
- updated the patch description.

 drivers/ata/pata_via.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Damien Le Moal April 13, 2022, 3:47 a.m. UTC | #1
On 4/13/22 05:39, Sergey Shtylyov wrote:
> The local variables 'T' and 'UT' are needlessly declared as *unsigned*
> *long* -- the corresponding parameters of ata_timing_compute() are both
> declared as *int*.  While fixing up those declarations, also make the
> 'via_clock' and 'T' variables *const* as they are never re-assigned
> after initialization -- the object code should remain the same as gcc
> previously used copy propagation anyway...
> 
> Found by Linux Verification Center (linuxtesting.org) with the SVACE static
> analysis tool.
> 
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

Applied to for-5.19. Thanks !
diff mbox series

Patch

Index: libata/drivers/ata/pata_via.c
===================================================================
--- libata.orig/drivers/ata/pata_via.c
+++ libata/drivers/ata/pata_via.c
@@ -248,9 +248,9 @@  static void via_do_set_mode(struct ata_p
 	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
 	struct ata_device *peer = ata_dev_pair(adev);
 	struct ata_timing t, p;
-	static int via_clock = 33333;	/* Bus clock in kHZ */
-	unsigned long T =  1000000000 / via_clock;
-	unsigned long UT = T;
+	const int via_clock = 33333;	/* Bus clock in kHz */
+	const int T = 1000000000 / via_clock;
+	int UT = T;
 	int ut;
 	int offset = 3 - (2*ap->port_no) - adev->devno;