All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Sowden <jeremy@azazel.net>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Netfilter Devel <netfilter-devel@vger.kernel.org>
Subject: [PATCH libnetfilter_log 4/6] src: use calloc instead of malloc + memset.
Date: Sat, 28 Aug 2021 20:38:22 +0100	[thread overview]
Message-ID: <20210828193824.1288478-5-jeremy@azazel.net> (raw)
In-Reply-To: <20210828193824.1288478-1-jeremy@azazel.net>

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
---
 src/libipulog_compat.c | 3 +--
 src/libnetfilter_log.c | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/libipulog_compat.c b/src/libipulog_compat.c
index 2d5b23a25c88..99cd86622d9b 100644
--- a/src/libipulog_compat.c
+++ b/src/libipulog_compat.c
@@ -90,12 +90,11 @@ struct ipulog_handle *ipulog_create_handle(uint32_t gmask,
 	struct ipulog_handle *h;
 	unsigned int group = gmask2group(gmask);
 
-	h = malloc(sizeof(*h)+PAYLOAD_SIZE);
+	h = calloc(1, sizeof(*h)+PAYLOAD_SIZE);
 	if (! h) {
 		ipulog_errno = IPULOG_ERR_HANDLE;
 		return NULL;
 	}
-	memset(h, 0, sizeof(*h));
 	h->nfulh = nflog_open();
 	if (!h->nfulh)
 		goto out_free;
diff --git a/src/libnetfilter_log.c b/src/libnetfilter_log.c
index 339f286f36bc..7d37570e70cb 100644
--- a/src/libnetfilter_log.c
+++ b/src/libnetfilter_log.c
@@ -238,11 +238,10 @@ struct nflog_handle *nflog_open_nfnl(struct nfnl_handle *nfnlh)
 	struct nflog_handle *h;
 	int err;
 
-	h = malloc(sizeof(*h));
+	h = calloc(1, sizeof(*h));
 	if (!h)
 		return NULL;
 
-	memset(h, 0, sizeof(*h));
 	h->nfnlh = nfnlh;
 
 	h->nfnlssh = nfnl_subsys_open(h->nfnlh, NFNL_SUBSYS_ULOG, 
@@ -398,11 +397,10 @@ nflog_bind_group(struct nflog_handle *h, uint16_t num)
 	if (find_gh(h, num))
 		return NULL;
 	
-	gh = malloc(sizeof(*gh));
+	gh = calloc(1, sizeof(*gh));
 	if (!gh)
 		return NULL;
 
-	memset(gh, 0, sizeof(*gh));
 	gh->h = h;
 	gh->id = num;
 
-- 
2.33.0


  parent reply	other threads:[~2021-08-28 19:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-28 19:38 [PATCH libnetfilter_log 0/6] Implementation of some fields omitted by `ipulog_get_packet` Jeremy Sowden
2021-08-28 19:38 ` [PATCH libnetfilter_log 1/6] Add doxygen directory to .gitignore Jeremy Sowden
2021-08-28 19:38 ` [PATCH libnetfilter_log 2/6] build: remove references to non-existent man-pages Jeremy Sowden
2021-08-28 19:38 ` [PATCH libnetfilter_log 3/6] doc: fix typo's in example Jeremy Sowden
2021-08-28 19:38 ` Jeremy Sowden [this message]
2021-08-28 19:38 ` [PATCH libnetfilter_log 5/6] libipulog: use correct index to find attribute in packet Jeremy Sowden
2021-08-28 19:38 ` [PATCH libnetfilter_log 6/6] libipulog: fill in missing packet fields Jeremy Sowden
2021-08-28 19:53 ` [PATCH libnetfilter_log 0/6] Implementation of some fields omitted by `ipulog_get_packet` Jan Engelhardt
2021-08-28 22:19   ` Jeremy Sowden
2021-08-30  0:16 ` Pablo Neira Ayuso
2021-08-30  1:33   ` Duncan Roe
2021-08-30 10:02     ` Jeremy Sowden
2021-08-31  9:00       ` Duncan Roe
2021-09-01 10:03         ` Jeremy Sowden
2021-08-30 10:05   ` Jeremy Sowden
2021-08-30 10:46     ` Pablo Neira Ayuso

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=20210828193824.1288478-5-jeremy@azazel.net \
    --to=jeremy@azazel.net \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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.