* [PATCH] recordmcount: Fix warning comparing pointer to 0
@ 2022-11-06 15:11 wangkailong
2022-11-06 15:56 ` Christophe JAILLET
0 siblings, 1 reply; 2+ messages in thread
From: wangkailong @ 2022-11-06 15:11 UTC (permalink / raw)
To: linux-kernel
Fix the following coccicheck warning:
scripts/recordmcount.c:142:13-14: WARNING comparing pointer to 0.
Signed-off-by: KaiLong Wang <wangkailong@jari.cn>
---
scripts/recordmcount.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index cce12e1971d8..750f5196608c 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.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] recordmcount: Fix warning comparing pointer to 0
2022-11-06 15:11 [PATCH] recordmcount: Fix warning comparing pointer to 0 wangkailong
@ 2022-11-06 15:56 ` Christophe JAILLET
0 siblings, 0 replies; 2+ messages in thread
From: Christophe JAILLET @ 2022-11-06 15:56 UTC (permalink / raw)
To: wangkailong, linux-kernel
Le 06/11/2022 à 16:11, wangkailong@jari.cn a écrit :
> Fix the following coccicheck warning:
>
> scripts/recordmcount.c:142:13-14: WARNING comparing pointer to 0.
>
> Signed-off-by: KaiLong Wang <wangkailong@jari.cn>
> ---
> scripts/recordmcount.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
> index cce12e1971d8..750f5196608c 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) {
Hi,
this change looks incorrect.
if (!addr)
maybe?
CJ
> fprintf(stderr, "malloc failed: %zu bytes\n", size);
> file_append_cleanup();
> mmap_cleanup();
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-06 15:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-06 15:11 [PATCH] recordmcount: Fix warning comparing pointer to 0 wangkailong
2022-11-06 15:56 ` Christophe JAILLET
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®