Skip to contentSkip to conversation

drivers/base/memory: fix a compilation warning

PATCH In review Qian Cai 2 participants 2 messages May 31, 2019

Subsystems (3)
lore
Share & tools
lore

Qian Cai

author
#0 lore raw

PATCH 1/1 drivers/base/memory: fix a compilation warning

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.

---
 drivers/base/memory.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/base/memory.c +4 -8
index f28efb0bf5c7..826dd76f662e 100644
@@ -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;
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 31 lines · Qian Cai

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.

---
 drivers/base/memory.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/base/memory.c +1 -4
index f28efb0bf5c7..826dd76f662e 100644
@@ -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;

drivers/base/memory.c static int init_memory_block(struct memory_block **memory, int block_id, · line 706

Quoted 10 lines
drivers/base/memory.c +3 -4
-		if (section_count == 0)
-			section_nr = i;
-		section_count++;
-	}
+	     i++)
+		if (present_section_nr(i))
+			section_count++;
 
 	if (section_count == 0)
 		return 0;

Thanks!

Signature · 3 lines
Thanks,

David / dhildenb