Skip to contentSkip to conversation

recordmcount: use "!P" instead of "P == 0"

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 recordmcount: use "!P" instead of "P == 0"

From: zhang songyi <[email protected]>

comparing pointer to 0, use !P instead of it.

---
 scripts/recordmcount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/recordmcount.c +1 -1
index cce12e1971d8..8d01decd12e9 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();

--
2.15.2

#1 lore raw
Quoted 3 lines · On Wed, 30 Nov 2022 15:47:35 +0800 (CST) <[email protected]> wrote:

From: zhang songyi <[email protected]>

comparing pointer to 0, use !P instead of it.

Both are correct. No need for useless churn like this.

-- Steve

Quoted 21 lines
---
 scripts/recordmcount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/recordmcount.c +1 -2
index cce12e1971d8..8d01decd12e9 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();
--

2.15.2