diff mbox series

[2/3] block: sed-opal: Eliminating the dead error

Message ID 20190813214340.15533-3-revanth.rajashekar@intel.com (mailing list archive)
State New, archived
Headers show
Series block: sed-opal: Code Cleanup Patches | expand

Commit Message

Revanth Rajashekar Aug. 13, 2019, 9:43 p.m. UTC
In the function 'response_parse', num_entries will never be 0 as
slen is checked for 0. Hence, the condition 'if (num_entries == 0)'
can never be true.

Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com>
---
 block/sed-opal.c | 4 ----
 1 file changed, 4 deletions(-)

--
2.17.1

Comments

Jon Derrick Aug. 14, 2019, 8:33 p.m. UTC | #1
lgtm

Reviewed-by: Jon Derrick <jonathan.derrick@intel.com>

On Tue, 2019-08-13 at 15:43 -0600, Rajashekar, Revanth wrote:
> In the function 'response_parse', num_entries will never be 0 as
> slen is checked for 0. Hence, the condition 'if (num_entries == 0)'
> can never be true.
> 
> Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com>
> ---
>  block/sed-opal.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/block/sed-opal.c b/block/sed-opal.c
> index d442f29e84f1..4e95a9792162 100644
> --- a/block/sed-opal.c
> +++ b/block/sed-opal.c
> @@ -905,10 +905,6 @@ static int response_parse(const u8 *buf, size_t length,
>  		num_entries++;
>  	}
> 
> -	if (num_entries == 0) {
> -		pr_debug("Couldn't parse response.\n");
> -		return -EINVAL;
> -	}
>  	resp->num = num_entries;
> 
>  	return 0;
> --
> 2.17.1
>
Scott Bauer Aug. 15, 2019, 4:03 a.m. UTC | #2
On Tue, Aug 13, 2019 at 03:43:39PM -0600, Revanth Rajashekar wrote:
> In the function 'response_parse', num_entries will never be 0 as
> slen is checked for 0. Hence, the condition 'if (num_entries == 0)'
> can never be true.
> 
> Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com>
Reviewed-by: Scott Bauer <sbauer@plzdonthack.me>

Can we also change the title to something a little more obvious like:
Remove always false if statement
The current title is ambigious if you single-line look at commits.
diff mbox series

Patch

diff --git a/block/sed-opal.c b/block/sed-opal.c
index d442f29e84f1..4e95a9792162 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -905,10 +905,6 @@  static int response_parse(const u8 *buf, size_t length,
 		num_entries++;
 	}

-	if (num_entries == 0) {
-		pr_debug("Couldn't parse response.\n");
-		return -EINVAL;
-	}
 	resp->num = num_entries;

 	return 0;