diff mbox series

acpi: cstates: remove redundant null check on entry

Message ID 20210922101226.176760-1-colin.king@canonical.com
State Accepted
Headers show
Series acpi: cstates: remove redundant null check on entry | expand

Commit Message

Colin Ian King Sept. 22, 2021, 10:12 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The pointer check on entry is redundant as this is already checked
in the while loop condition above. Clean up code by removing it.

Cleans up cppcheck style warning.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/cstates/cstates.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alex Hung Sept. 22, 2021, 7:07 p.m. UTC | #1
On 2021-09-22 4:12 a.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The pointer check on entry is redundant as this is already checked
> in the while loop condition above. Clean up code by removing it.
> 
> Cleans up cppcheck style warning.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/cstates/cstates.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/acpi/cstates/cstates.c b/src/acpi/cstates/cstates.c
> index 45073c15..1fd65f9e 100644
> --- a/src/acpi/cstates/cstates.c
> +++ b/src/acpi/cstates/cstates.c
> @@ -66,7 +66,7 @@ static void get_cstates(char *path, fwts_cstates *state)
>  		return;
>  
>  	while ((entry = readdir(dir)) != NULL) {
> -		if (entry && strlen(entry->d_name)>3) {
> +		if (strlen(entry->d_name) > 3) {
>  			long int nr;
>  			int count;
>  
> 


Acked-by: Alex Hung <alex.hung@canonical.com>
ivanhu Sept. 23, 2021, 3:41 a.m. UTC | #2
On 9/22/21 6:12 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The pointer check on entry is redundant as this is already checked
> in the while loop condition above. Clean up code by removing it.
> 
> Cleans up cppcheck style warning.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/cstates/cstates.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/acpi/cstates/cstates.c b/src/acpi/cstates/cstates.c
> index 45073c15..1fd65f9e 100644
> --- a/src/acpi/cstates/cstates.c
> +++ b/src/acpi/cstates/cstates.c
> @@ -66,7 +66,7 @@ static void get_cstates(char *path, fwts_cstates *state)
>  		return;
>  
>  	while ((entry = readdir(dir)) != NULL) {
> -		if (entry && strlen(entry->d_name)>3) {
> +		if (strlen(entry->d_name) > 3) {
>  			long int nr;
>  			int count;
>  
> 

Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox series

Patch

diff --git a/src/acpi/cstates/cstates.c b/src/acpi/cstates/cstates.c
index 45073c15..1fd65f9e 100644
--- a/src/acpi/cstates/cstates.c
+++ b/src/acpi/cstates/cstates.c
@@ -66,7 +66,7 @@  static void get_cstates(char *path, fwts_cstates *state)
 		return;
 
 	while ((entry = readdir(dir)) != NULL) {
-		if (entry && strlen(entry->d_name)>3) {
+		if (strlen(entry->d_name) > 3) {
 			long int nr;
 			int count;