Skip to contentSkip to conversation

recordmcount: Fix warning comparing pointer to 0

PATCH In review [email protected] 2 participants 2 messages Nov 6, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 recordmcount: Fix warning comparing pointer to 0

Fix the following coccicheck warning:

scripts/recordmcount.c:142:13-14: WARNING comparing pointer to 0.

---
 scripts/recordmcount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/recordmcount.c +1 -1
index cce12e1971d8..750f5196608c 100644
@@ -139,7 +139,7 @@ static ssize_t uwrite(void const *const buf, size_t const count)
 static void * umalloc(size_t size)
 {
 	void *const addr = malloc(size);
-	if (addr == 0) {
+	if (addr) {
 		fprintf(stderr, "malloc failed: %zu bytes\n", size);
 		file_append_cleanup();
 		mmap_cleanup();
Signature · 1 line
2.25.1
#1 lore raw

Le 06/11/2022 à 16:11, [email protected] a écrit :

Quoted 14 lines

Fix the following coccicheck warning:

scripts/recordmcount.c:142:13-14: WARNING comparing pointer to 0.

---
  scripts/recordmcount.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
scripts/recordmcount.c +0 -0
index cce12e1971d8..750f5196608c 100644

scripts/recordmcount.c static ssize_t uwrite(void const *const buf, size_t const count) · line 142

Quoted 5 lines
scripts/recordmcount.c +1 -1
@@ -139,7 +139,7 @@ static ssize_t uwrite(void const *const buf, size_t const count)
  static void * umalloc(size_t size)
  {
  	void *const addr = malloc(size);
-	if (addr == 0) {
+	if (addr) {

Hi,
this change looks incorrect.

	if (!addr)

maybe?

CJ

Quoted 3 lines
scripts/recordmcount.c +0 -0
  		fprintf(stderr, "malloc failed: %zu bytes\n", size);
  		file_append_cleanup();
  		mmap_cleanup();