linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Dev Jain <dev.jain@arm.com>,
	Zhu Jun <zhujun2@cmss.chinamobile.com>,
	linux-mm@kvack.org, kernel-janitors@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: tools/mm: Use calloc and check the potential memory allocation failure
Date: Thu, 29 Aug 2024 09:55:49 +0200	[thread overview]
Message-ID: <22213ddd-90b3-4d33-aa80-4b3500a21a2e@web.de> (raw)
In-Reply-To: <37577635-89c9-4afe-a30d-add02c0eb896@arm.com>

>>> Replace malloc with calloc and add memory allocating check
>>                        memset(…, 0, …) call by calloc()?
>
> Calloc returns zeroed-out memory.

I propose to improve the change description considerably.


>>> of comm_str before used.
>> * Add also a null pointer check for the detection of a memory allocation failure.
>
> Which is exactly what Zhu has done?

Can the commit message become nicer anyhow?


…
>> * How do you think about to omit the statement “fprintf(stderr, "Out of memory\n");”?
>
> Why?

I imagine that a returned null pointer can eventually be sufficient already.
Would you get helpful background information from the variable “errno”?

Regards,
Markus


  reply	other threads:[~2024-08-29  7:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-29  5:56 [PATCH] " Zhu Jun
2024-08-29  6:25 ` Markus Elfring
2024-08-29  7:39   ` Dev Jain
2024-08-29  7:55     ` Markus Elfring [this message]
2024-08-29  8:14       ` Dev Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=22213ddd-90b3-4d33-aa80-4b3500a21a2e@web.de \
    --to=markus.elfring@web.de \
    --cc=akpm@linux-foundation.org \
    --cc=dev.jain@arm.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=zhujun2@cmss.chinamobile.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox