All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: vt6656: Remove logically dead code
@ 2020-05-10  9:09 ` Oscar Carter
  0 siblings, 0 replies; 2+ messages in thread
From: Oscar Carter @ 2020-05-10  9:09 UTC (permalink / raw)
  To: Forest Bond, Greg Kroah-Hartman
  Cc: Oscar Carter, Malcolm Priestley, Quentin Deslandes, devel, linux-kernel

In the start of the "vnt_rf_set_txpower" function the "power" variable
is set at most to VNT_RF_MAX_POWER (hex = 0x3f, dec = 63). Then, in the
switch statement there are four comparisons with the "power" variable
against AL7230_PWR_IDX_LEN (dec = 64), VT3226_PWR_IDX_LEN (dec = 64),
VT3342_PWR_IDX_LEN (dec = 64). Due to all the commented comparisons are
to check if the "power" variable is "greater than or equal" to 64, this
never happens. So, remove the logically dead code.

Also, remove all the defines that are no longer required.

Addresses-Coverity-ID: 1230228 ("Logically dead code")
Fixes: f53d9f12c51a ("staging: vt6656: rf.c additional power.")
Signed-off-by: Oscar Carter <oscar.carter@gmx.com>
---
 drivers/staging/vt6656/rf.c | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c
index fb708467b99b..5b8da06e3916 100644
--- a/drivers/staging/vt6656/rf.c
+++ b/drivers/staging/vt6656/rf.c
@@ -28,15 +28,9 @@
 #include "usbpipe.h"

 #define CB_AL2230_INIT_SEQ    15
-
 #define CB_AL7230_INIT_SEQ    16
-#define AL7230_PWR_IDX_LEN    64
-
 #define CB_VT3226_INIT_SEQ    11
-#define VT3226_PWR_IDX_LEN    64
-
 #define CB_VT3342_INIT_SEQ    13
-#define VT3342_PWR_IDX_LEN    64

 static u8 al2230_init_table[CB_AL2230_INIT_SEQ][3] = {
 	{0x03, 0xf7, 0x90},
@@ -658,9 +652,6 @@ static int vnt_rf_set_txpower(struct vnt_private *priv, u8 power,
 		if (ret)
 			return ret;

-		if (power >= AL7230_PWR_IDX_LEN)
-			return -EINVAL;
-
 		/*
 		 * 0x080F1B00 for 3 wire control TxGain(D10)
 		 * and 0x31 as TX Gain value
@@ -671,16 +662,11 @@ static int vnt_rf_set_txpower(struct vnt_private *priv, u8 power,
 		break;

 	case RF_VT3226:
-		if (power >= VT3226_PWR_IDX_LEN)
-			return -EINVAL;
 		power_setting = ((0x3f - power) << 20) | (0x17 << 8);

 		ret = vnt_rf_write_embedded(priv, power_setting);
 		break;
 	case RF_VT3226D0:
-		if (power >= VT3226_PWR_IDX_LEN)
-			return -EINVAL;
-
 		if (ch->flags & IEEE80211_CHAN_NO_OFDM) {
 			u16 hw_value = ch->hw_value;

@@ -731,9 +717,6 @@ static int vnt_rf_set_txpower(struct vnt_private *priv, u8 power,
 		break;

 	case RF_VT3342A0:
-		if (power >= VT3342_PWR_IDX_LEN)
-			return -EINVAL;
-
 		power_setting =  ((0x3f - power) << 20) | (0x27 << 8);

 		ret = vnt_rf_write_embedded(priv, power_setting);
--
2.20.1


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

* [PATCH] staging: vt6656: Remove logically dead code
@ 2020-05-10  9:09 ` Oscar Carter
  0 siblings, 0 replies; 2+ messages in thread
From: Oscar Carter @ 2020-05-10  9:09 UTC (permalink / raw)
  To: Forest Bond, Greg Kroah-Hartman
  Cc: Malcolm Priestley, devel, Oscar Carter, linux-kernel

In the start of the "vnt_rf_set_txpower" function the "power" variable
is set at most to VNT_RF_MAX_POWER (hex = 0x3f, dec = 63). Then, in the
switch statement there are four comparisons with the "power" variable
against AL7230_PWR_IDX_LEN (dec = 64), VT3226_PWR_IDX_LEN (dec = 64),
VT3342_PWR_IDX_LEN (dec = 64). Due to all the commented comparisons are
to check if the "power" variable is "greater than or equal" to 64, this
never happens. So, remove the logically dead code.

Also, remove all the defines that are no longer required.

Addresses-Coverity-ID: 1230228 ("Logically dead code")
Fixes: f53d9f12c51a ("staging: vt6656: rf.c additional power.")
Signed-off-by: Oscar Carter <oscar.carter@gmx.com>
---
 drivers/staging/vt6656/rf.c | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c
index fb708467b99b..5b8da06e3916 100644
--- a/drivers/staging/vt6656/rf.c
+++ b/drivers/staging/vt6656/rf.c
@@ -28,15 +28,9 @@
 #include "usbpipe.h"

 #define CB_AL2230_INIT_SEQ    15
-
 #define CB_AL7230_INIT_SEQ    16
-#define AL7230_PWR_IDX_LEN    64
-
 #define CB_VT3226_INIT_SEQ    11
-#define VT3226_PWR_IDX_LEN    64
-
 #define CB_VT3342_INIT_SEQ    13
-#define VT3342_PWR_IDX_LEN    64

 static u8 al2230_init_table[CB_AL2230_INIT_SEQ][3] = {
 	{0x03, 0xf7, 0x90},
@@ -658,9 +652,6 @@ static int vnt_rf_set_txpower(struct vnt_private *priv, u8 power,
 		if (ret)
 			return ret;

-		if (power >= AL7230_PWR_IDX_LEN)
-			return -EINVAL;
-
 		/*
 		 * 0x080F1B00 for 3 wire control TxGain(D10)
 		 * and 0x31 as TX Gain value
@@ -671,16 +662,11 @@ static int vnt_rf_set_txpower(struct vnt_private *priv, u8 power,
 		break;

 	case RF_VT3226:
-		if (power >= VT3226_PWR_IDX_LEN)
-			return -EINVAL;
 		power_setting = ((0x3f - power) << 20) | (0x17 << 8);

 		ret = vnt_rf_write_embedded(priv, power_setting);
 		break;
 	case RF_VT3226D0:
-		if (power >= VT3226_PWR_IDX_LEN)
-			return -EINVAL;
-
 		if (ch->flags & IEEE80211_CHAN_NO_OFDM) {
 			u16 hw_value = ch->hw_value;

@@ -731,9 +717,6 @@ static int vnt_rf_set_txpower(struct vnt_private *priv, u8 power,
 		break;

 	case RF_VT3342A0:
-		if (power >= VT3342_PWR_IDX_LEN)
-			return -EINVAL;
-
 		power_setting =  ((0x3f - power) << 20) | (0x27 << 8);

 		ret = vnt_rf_write_embedded(priv, power_setting);
--
2.20.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

end of thread, other threads:[~2020-05-10  9:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-10  9:09 [PATCH] staging: vt6656: Remove logically dead code Oscar Carter
2020-05-10  9:09 ` Oscar Carter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.