public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] staging: gpib: Remove a dead condition in if statement
@ 2024-10-16  7:53 Everest K.C.
  2024-10-16  8:04 ` Greg KH
  0 siblings, 1 reply; 10+ messages in thread
From: Everest K.C. @ 2024-10-16  7:53 UTC (permalink / raw)
  To: dpenkler, gregkh; +Cc: Everest K.C., skhan, linux-staging, linux-kernel

The variable `residue` is an unsigned int, also the function
`fluke_get_dma_residue` returns an unsigned int. The value of
an unsigned int can only be 0 at minimum.
The less-than-zero comparison can never be true.
Fix it by removing the dead condition in the if statement.

This issue was reported by Coverity Scan.
Report:
CID 1600782: (#1 of 1): Macro compares unsigned to 0 (NO_EFFECT)
unsigned_compare: This less-than-zero comparison of an unsigned value
is never true. residue < 0U.

Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
---
V1 -> V2: - Fixed typo of comparison in changelog
          - Removed Fixes tag 

 drivers/staging/gpib/eastwood/fluke_gpib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/gpib/eastwood/fluke_gpib.c b/drivers/staging/gpib/eastwood/fluke_gpib.c
index f9f149db222d..51b4f9891a34 100644
--- a/drivers/staging/gpib/eastwood/fluke_gpib.c
+++ b/drivers/staging/gpib/eastwood/fluke_gpib.c
@@ -644,7 +644,7 @@ static int fluke_dma_read(gpib_board_t *board, uint8_t *buffer,
 	 */
 	usleep_range(10, 15);
 	residue = fluke_get_dma_residue(e_priv->dma_channel, dma_cookie);
-	if (WARN_ON_ONCE(residue > length || residue < 0))
+	if (WARN_ON_ONCE(residue > length))
 		return -EFAULT;
 	*bytes_read += length - residue;
 	dmaengine_terminate_all(e_priv->dma_channel);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-10-17  7:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-16  7:53 [PATCH V2] staging: gpib: Remove a dead condition in if statement Everest K.C.
2024-10-16  8:04 ` Greg KH
2024-10-16 12:54   ` Everest K.C.
2024-10-16 15:00     ` Dan Carpenter
2024-10-17  2:47       ` Everest K.C.
2024-10-17  7:03         ` Dan Carpenter
2024-10-16 15:12     ` Greg KH
2024-10-17  2:50       ` Everest K.C.
2024-10-17  4:42         ` Everest K.C.
2024-10-17  6:01           ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox