Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: <igt-dev@lists.freedesktop.org>, Tvrtko Ursulin <tursulin@ursulin.net>
Subject: Re: [PATCH i-g-t 1/8] lib/igt_drm_clients: Use calloc
Date: Wed, 3 Apr 2024 08:27:47 -0700	[thread overview]
Message-ID: <Zg11c9WlsvwNsnvT@unerlige-ril> (raw)
In-Reply-To: <20240402221716.1840148-2-lucas.demarchi@intel.com>

On Tue, Apr 02, 2024 at 03:17:09PM -0700, Lucas De Marchi wrote:
>Replace malloc + memset with a single calloc as it's shorter and there's
>no point keeping them separate.
>
>Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

LGTM,
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>

>---
> lib/igt_drm_clients.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
>diff --git a/lib/igt_drm_clients.c b/lib/igt_drm_clients.c
>index 025d60c51..90ca6d61c 100644
>--- a/lib/igt_drm_clients.c
>+++ b/lib/igt_drm_clients.c
>@@ -35,12 +35,10 @@ struct igt_drm_clients *igt_drm_clients_init(void *private_data)
> {
> 	struct igt_drm_clients *clients;
>
>-	clients = malloc(sizeof(*clients));
>+	clients = calloc(1, sizeof(*clients));
> 	if (!clients)
> 		return NULL;
>
>-	memset(clients, 0, sizeof(*clients));
>-
> 	clients->private_data = private_data;
>
> 	return clients;
>@@ -165,9 +163,8 @@ igt_drm_client_add(struct igt_drm_clients *clients,
> 	c->clients = clients;
>
> 	/* Engines */
>-	c->engines = malloc(sizeof(*c->engines));
>+	c->engines = calloc(1, sizeof(*c->engines));
> 	assert(c->engines);
>-	memset(c->engines, 0, sizeof(*c->engines));
> 	c->engines->capacity = calloc(info->last_engine_index + 1,
> 				      sizeof(*c->engines->capacity));
> 	assert(c->engines->capacity);
>@@ -190,9 +187,8 @@ igt_drm_client_add(struct igt_drm_clients *clients,
> 	assert(c->val && c->last);
>
> 	/* Memory regions */
>-	c->regions = malloc(sizeof(*c->regions));
>+	c->regions = calloc(1, sizeof(*c->regions));
> 	assert(c->regions);
>-	memset(c->regions, 0, sizeof(*c->regions));
> 	c->regions->names = calloc(info->last_region_index + 1,
> 				   sizeof(*c->regions->names));
> 	assert(c->regions->names);
>-- 
>2.43.0
>

  reply	other threads:[~2024-04-03 15:28 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-02 22:17 [PATCH i-g-t 0/8] Refactors and fixes for drm_clients Lucas De Marchi
2024-04-02 22:17 ` [PATCH i-g-t 1/8] lib/igt_drm_clients: Use calloc Lucas De Marchi
2024-04-03 15:27   ` Umesh Nerlige Ramappa [this message]
2024-04-03 17:23   ` Kamil Konieczny
2024-04-02 22:17 ` [PATCH i-g-t 2/8] lib/igt_drm_clients: Fix sizeof calculation Lucas De Marchi
2024-04-03 15:28   ` Umesh Nerlige Ramappa
2024-04-03 17:25   ` Kamil Konieczny
2024-04-02 22:17 ` [PATCH i-g-t 3/8] lib/igt_drm_clients: Fix leaks Lucas De Marchi
2024-04-03 15:39   ` Umesh Nerlige Ramappa
2024-04-03 16:09     ` Tvrtko Ursulin
2024-04-03 17:26   ` Kamil Konieczny
2024-04-02 22:17 ` [PATCH i-g-t 4/8] gputop: Free clients on exit Lucas De Marchi
2024-04-03 16:03   ` Umesh Nerlige Ramappa
2024-04-03 16:13   ` Tvrtko Ursulin
2024-04-03 17:28   ` Kamil Konieczny
2024-04-02 22:17 ` [PATCH i-g-t 5/8] lib/igt_drm_fdinfo: Simplify find_kv() Lucas De Marchi
2024-04-03 17:48   ` Kamil Konieczny
2024-04-02 22:17 ` [PATCH i-g-t 6/8] lib/igt_drm_fdinfo: Stop passing key twice Lucas De Marchi
2024-04-03 17:56   ` Kamil Konieczny
2024-04-02 22:17 ` [PATCH i-g-t 7/8] lib/igt_drm_fdinfo: Remove prefix arg from parse functions Lucas De Marchi
2024-04-03 23:53   ` Umesh Nerlige Ramappa
2024-04-02 22:17 ` [PATCH i-g-t 8/8] lib/igt_drm_clients: lazy stat process Lucas De Marchi
2024-04-03 16:24   ` Tvrtko Ursulin
2024-04-02 23:59 ` ✗ Fi.CI.BAT: failure for Refactors and fixes for drm_clients Patchwork
2024-04-03  0:31 ` ✓ CI.xeBAT: success " Patchwork

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=Zg11c9WlsvwNsnvT@unerlige-ril \
    --to=umesh.nerlige.ramappa@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=tursulin@ursulin.net \
    /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