diff mbox series

cpu: microcode: remove redundant check on pointer entry

Message ID 20191207153343.112887-1-colin.king@canonical.com
State Accepted
Headers show
Series cpu: microcode: remove redundant check on pointer entry | expand

Commit Message

Colin Ian King Dec. 7, 2019, 3:33 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The check for a null entry is redundant as the while loop
also checks for this.  Remove the redundant check. Cleans
up cppcheck style warning:

src/cpu/microcode/microcode.c:203:14: style: Condition 'entry' is
always true [knownConditionTrueFalse]
         if (entry &&

src/cpu/microcode/microcode.c:202:32: note: Assuming that condition
'(entry=readdir(dir))!=NULL' is not redundant

 while ((entry = readdir(dir)) != NULL) {

src/cpu/microcode/microcode.c:203:14: note: Condition 'entry' is
always true
         if (entry &&

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

Comments

Alex Hung Dec. 7, 2019, 3:39 p.m. UTC | #1
On 2019-12-07 8:33 a.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The check for a null entry is redundant as the while loop
> also checks for this.  Remove the redundant check. Cleans
> up cppcheck style warning:
> 
> src/cpu/microcode/microcode.c:203:14: style: Condition 'entry' is
> always true [knownConditionTrueFalse]
>           if (entry &&
> 
> src/cpu/microcode/microcode.c:202:32: note: Assuming that condition
> '(entry=readdir(dir))!=NULL' is not redundant
> 
>   while ((entry = readdir(dir)) != NULL) {
> 
> src/cpu/microcode/microcode.c:203:14: note: Condition 'entry' is
> always true
>           if (entry &&
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/cpu/microcode/microcode.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/src/cpu/microcode/microcode.c b/src/cpu/microcode/microcode.c
> index 974fdec9..65abe50a 100644
> --- a/src/cpu/microcode/microcode.c
> +++ b/src/cpu/microcode/microcode.c
> @@ -200,8 +200,7 @@ static int microcode_test1(fwts_framework *fw)
>   
>   	/* Scan and check */
>   	while ((entry = readdir(dir)) != NULL) {
> -	        if (entry &&
> -		    (strlen(entry->d_name) > 3) &&
> +	        if ((strlen(entry->d_name) > 3) &&
>   		    (strncmp(entry->d_name,"cpu", 3) == 0) &&
>   		    (isdigit(entry->d_name[3]))) {
>   			char path[PATH_MAX];
> 

Acked-by: Alex Hung <alex.hung@canonical.com>
Colin Ian King Dec. 7, 2019, 3:39 p.m. UTC | #2
Sorry, I didn't mean to cc this to kernel-janitors. please ignore.

On 07/12/2019 15:33, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The check for a null entry is redundant as the while loop
> also checks for this.  Remove the redundant check. Cleans
> up cppcheck style warning:
> 
> src/cpu/microcode/microcode.c:203:14: style: Condition 'entry' is
> always true [knownConditionTrueFalse]
>          if (entry &&
> 
> src/cpu/microcode/microcode.c:202:32: note: Assuming that condition
> '(entry=readdir(dir))!=NULL' is not redundant
> 
>  while ((entry = readdir(dir)) != NULL) {
> 
> src/cpu/microcode/microcode.c:203:14: note: Condition 'entry' is
> always true
>          if (entry &&
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/cpu/microcode/microcode.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/src/cpu/microcode/microcode.c b/src/cpu/microcode/microcode.c
> index 974fdec9..65abe50a 100644
> --- a/src/cpu/microcode/microcode.c
> +++ b/src/cpu/microcode/microcode.c
> @@ -200,8 +200,7 @@ static int microcode_test1(fwts_framework *fw)
>  
>  	/* Scan and check */
>  	while ((entry = readdir(dir)) != NULL) {
> -	        if (entry &&
> -		    (strlen(entry->d_name) > 3) &&
> +	        if ((strlen(entry->d_name) > 3) &&
>  		    (strncmp(entry->d_name,"cpu", 3) == 0) &&
>  		    (isdigit(entry->d_name[3]))) {
>  			char path[PATH_MAX];
>
Ivan Hu Dec. 9, 2019, 3:31 a.m. UTC | #3
在 2019年12月7日 下午11:33 於 下午11:33,Colin King <colin.king@canonical.com>曾寫:
>From: Colin Ian King <colin.king@canonical.com>
>
>The check for a null entry is redundant as the while loop
>also checks for this.  Remove the redundant check. Cleans
>up cppcheck style warning:
>
>src/cpu/microcode/microcode.c:203:14: style: Condition 'entry' is
>always true [knownConditionTrueFalse]
>         if (entry &&
>
>src/cpu/microcode/microcode.c:202:32: note: Assuming that condition
>'(entry=readdir(dir))!=NULL' is not redundant
>
> while ((entry = readdir(dir)) != NULL) {
>
>src/cpu/microcode/microcode.c:203:14: note: Condition 'entry' is
>always true
>         if (entry &&
>
>Signed-off-by: Colin Ian King <colin.king@canonical.com>
>---
> src/cpu/microcode/microcode.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
>diff --git a/src/cpu/microcode/microcode.c
>b/src/cpu/microcode/microcode.c
>index 974fdec9..65abe50a 100644
>--- a/src/cpu/microcode/microcode.c
>+++ b/src/cpu/microcode/microcode.c
>@@ -200,8 +200,7 @@ static int microcode_test1(fwts_framework *fw)
> 
> 	/* Scan and check */
> 	while ((entry = readdir(dir)) != NULL) {
>-	        if (entry &&
>-		    (strlen(entry->d_name) > 3) &&
>+	        if ((strlen(entry->d_name) > 3) &&
> 		    (strncmp(entry->d_name,"cpu", 3) == 0) &&
> 		    (isdigit(entry->d_name[3]))) {
> 			char path[PATH_MAX];
>-- 
>2.24.0
>
>
>-- 
>fwts-devel mailing list
>fwts-devel@lists.ubuntu.com
>Modify settings or unsubscribe at:
>https://lists.ubuntu.com/mailman/listinfo/fwts-devel
diff mbox series

Patch

diff --git a/src/cpu/microcode/microcode.c b/src/cpu/microcode/microcode.c
index 974fdec9..65abe50a 100644
--- a/src/cpu/microcode/microcode.c
+++ b/src/cpu/microcode/microcode.c
@@ -200,8 +200,7 @@  static int microcode_test1(fwts_framework *fw)
 
 	/* Scan and check */
 	while ((entry = readdir(dir)) != NULL) {
-	        if (entry &&
-		    (strlen(entry->d_name) > 3) &&
+	        if ((strlen(entry->d_name) > 3) &&
 		    (strncmp(entry->d_name,"cpu", 3) == 0) &&
 		    (isdigit(entry->d_name[3]))) {
 			char path[PATH_MAX];