All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ondrej Mosnacek <omosnace@redhat.com>
To: selinux@vger.kernel.org
Subject: [PATCH userspace v4 2/8] selinux_restorecon: simplify fl_head allocation by using calloc()
Date: Tue, 26 Oct 2021 13:52:33 +0200	[thread overview]
Message-ID: <20211026115239.267449-3-omosnace@redhat.com> (raw)
In-Reply-To: <20211026115239.267449-1-omosnace@redhat.com>

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
 libselinux/src/selinux_restorecon.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
index 04d95650..15129336 100644
--- a/libselinux/src/selinux_restorecon.c
+++ b/libselinux/src/selinux_restorecon.c
@@ -425,10 +425,9 @@ static int filespec_add(ino_t ino, const char *con, const char *file,
 	struct stat64 sb;
 
 	if (!fl_head) {
-		fl_head = malloc(sizeof(file_spec_t) * HASH_BUCKETS);
+		fl_head = calloc(HASH_BUCKETS, sizeof(file_spec_t));
 		if (!fl_head)
 			goto oom;
-		memset(fl_head, 0, sizeof(file_spec_t) * HASH_BUCKETS);
 	}
 
 	h = (ino + (ino >> HASH_BITS)) & HASH_MASK;
-- 
2.31.1


  parent reply	other threads:[~2021-10-26 11:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-26 11:52 [PATCH userspace v4 0/8] Parallel setfiles/restorecon Ondrej Mosnacek
2021-10-26 11:52 ` [PATCH userspace v4 1/8] label_file: fix a data race Ondrej Mosnacek
2021-10-26 11:52 ` Ondrej Mosnacek [this message]
2021-10-26 11:52 ` [PATCH userspace v4 3/8] selinux_restorecon: protect file_spec list with a mutex Ondrej Mosnacek
2021-10-26 11:52 ` [PATCH userspace v4 4/8] libselinux: make selinux_log() thread-safe Ondrej Mosnacek
2021-10-26 11:52 ` [PATCH userspace v4 5/8] libselinux: make is_context_customizable() thread-safe Ondrej Mosnacek
2021-11-05 15:32   ` Christian Göttsche
2021-10-26 11:52 ` [PATCH userspace v4 6/8] selinux_restorecon: add a global mutex to synchronize progress output Ondrej Mosnacek
2021-10-26 11:52 ` [PATCH userspace v4 7/8] selinux_restorecon: introduce selinux_restorecon_parallel(3) Ondrej Mosnacek
2021-10-26 11:52 ` [PATCH userspace v4 8/8] setfiles/restorecon: support parallel relabeling Ondrej Mosnacek
2021-11-22 11:56 ` [PATCH userspace v4 0/8] Parallel setfiles/restorecon Ondrej Mosnacek
2021-11-23  9:26   ` Petr Lautrbach
2021-11-23  9:40     ` Petr Lautrbach

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=20211026115239.267449-3-omosnace@redhat.com \
    --to=omosnace@redhat.com \
    --cc=selinux@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.