Skip to contentSkip to conversation

mm: cma: Return cma->name directly in cma_get_name

PATCH In review Nathan Chancellor 2 participants 2 messages Jun 23, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: cma: Return cma->name directly in cma_get_name

clang warns:

mm/cma.c:55:14: warning: address of array 'cma->name' will always evaluate to 'true' [-Wpointer-bool-conversion]

        return cma->name ? cma->name : "(undefined)";
               ~~~~~^~~~ ~

1 warning generated.

After commit e7f0557d7de9 ("mm: cma: fix the name of CMA areas"), cma->name will be an array with some value worth printing so we do not need to check for NULL.

---
 mm/cma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/cma.c +1 -1
index 31a61d410c59..6cf08817bac6 100644
@@ -52,7 +52,7 @@ unsigned long cma_get_size(const struct cma *cma)
 
 const char *cma_get_name(const struct cma *cma)
 {
-	return cma->name ? cma->name : "(undefined)";
+	return cma->name;
 }
 
 static unsigned long cma_bitmap_aligned_mask(const struct cma *cma,

base-commit: 27f11fea33608cbd321a97cbecfa2ef97dcc1821

Signature · 1 line
2.27.0
Acked-by on v1 1/1
#1 lore raw
Quoted 18 lines

-----Original Message-----
From: Nathan Chancellor [mailto:[email protected]]
Sent: Tuesday, June 23, 2020 1:59 PM
To: Andrew Morton <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Song Bao Hua (Barry Song) <[email protected]>; Nathan Chancellor <[email protected]>
Subject: [PATCH] mm: cma: Return cma->name directly in cma_get_name

clang warns:

mm/cma.c:55:14: warning: address of array 'cma->name' will always evaluate to 'true' [-Wpointer-bool-conversion]

        return cma->name ? cma->name : "(undefined)";
               ~~~~~^~~~ ~
Quoted 8 lines

1 warning generated.

After commit e7f0557d7de9 ("mm: cma: fix the name of CMA areas"), cma->name will be an array with some value worth printing so we do not need to check for NULL.

Thanks!

Quoted 21 lines
---
 mm/cma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/cma.c +1 -1
index 31a61d410c59..6cf08817bac6 100644
@@ -52,7 +52,7 @@ unsigned long cma_get_size(const struct cma *cma)
 
 const char *cma_get_name(const struct cma *cma)
 {
-	return cma->name ? cma->name : "(undefined)";
+	return cma->name;
 }
 
 static unsigned long cma_bitmap_aligned_mask(const struct cma *cma,

base-commit: 27f11fea33608cbd321a97cbecfa2ef97dcc1821 --
2.27.0