[linux-next] recordmcount: use "!P" instead of "P == 0"

Message ID 202211301547353578204@zte.com.cn
State New
Headers
Series [linux-next] recordmcount: use "!P" instead of "P == 0" |

Commit Message

zhang.songyi@zte.com.cn Nov. 30, 2022, 7:47 a.m. UTC
  From: zhang songyi <zhang.songyi@zte.com.cn>

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

Signed-off-by: zhang songyi <zhang.songyi@zte.com.cn>
---
 scripts/recordmcount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.15.2
  

Comments

Steven Rostedt Nov. 30, 2022, 2:05 p.m. UTC | #1
On Wed, 30 Nov 2022 15:47:35 +0800 (CST)
<zhang.songyi@zte.com.cn> wrote:

> From: zhang songyi <zhang.songyi@zte.com.cn>
> 
> comparing pointer to 0, use !P instead of it.

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

-- Steve

> 
> Signed-off-by: zhang songyi <zhang.songyi@zte.com.cn>
> ---
>  scripts/recordmcount.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
> index cce12e1971d8..8d01decd12e9 100644
> --- a/scripts/recordmcount.c
> +++ b/scripts/recordmcount.c
> @@ -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
  

Patch

diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index cce12e1971d8..8d01decd12e9 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -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();