diff mbox series

[-next] drivers/base/memory: fix a compilation warning

Message ID 1559320186-28337-1-git-send-email-cai@lca.pw (mailing list archive)
State New, archived
Headers show
Series [-next] drivers/base/memory: fix a compilation warning | expand

Commit Message

Qian Cai May 31, 2019, 4:29 p.m. UTC
The linux-next commit 8553938ba3bd ("drivers/base/memory: pass a
block_id to init_memory_block()") left an unused variable,

drivers/base/memory.c: In function 'add_memory_block':
drivers/base/memory.c:697:33: warning: variable 'section_nr' set but not
used [-Wunused-but-set-variable]

Also, rework the code logic a bit.

Signed-off-by: Qian Cai <cai@lca.pw>
---
 drivers/base/memory.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

David Hildenbrand May 31, 2019, 5:33 p.m. UTC | #1
On 31.05.19 18:29, Qian Cai wrote:
> The linux-next commit 8553938ba3bd ("drivers/base/memory: pass a
> block_id to init_memory_block()") left an unused variable,
> 
> drivers/base/memory.c: In function 'add_memory_block':
> drivers/base/memory.c:697:33: warning: variable 'section_nr' set but not
> used [-Wunused-but-set-variable]
> 
> Also, rework the code logic a bit.
> 
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
>  drivers/base/memory.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/base/memory.c b/drivers/base/memory.c
> index f28efb0bf5c7..826dd76f662e 100644
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -694,17 +694,13 @@ static int init_memory_block(struct memory_block **memory, int block_id,
>  static int add_memory_block(int base_section_nr)
>  {
>  	struct memory_block *mem;
> -	int i, ret, section_count = 0, section_nr;
> +	int i, ret, section_count = 0;
>  
>  	for (i = base_section_nr;
>  	     i < base_section_nr + sections_per_block;
> -	     i++) {
> -		if (!present_section_nr(i))
> -			continue;
> -		if (section_count == 0)
> -			section_nr = i;
> -		section_count++;
> -	}
> +	     i++)
> +		if (present_section_nr(i))
> +			section_count++;
>  
>  	if (section_count == 0)
>  		return 0;
> 

Thanks!

Reviewed-by: David Hildenbrand <david@redhat.com>
diff mbox series

Patch

diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index f28efb0bf5c7..826dd76f662e 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -694,17 +694,13 @@  static int init_memory_block(struct memory_block **memory, int block_id,
 static int add_memory_block(int base_section_nr)
 {
 	struct memory_block *mem;
-	int i, ret, section_count = 0, section_nr;
+	int i, ret, section_count = 0;
 
 	for (i = base_section_nr;
 	     i < base_section_nr + sections_per_block;
-	     i++) {
-		if (!present_section_nr(i))
-			continue;
-		if (section_count == 0)
-			section_nr = i;
-		section_count++;
-	}
+	     i++)
+		if (present_section_nr(i))
+			section_count++;
 
 	if (section_count == 0)
 		return 0;