cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 1/3] dlm_controld: initialize waiter->flags
Date: Fri, 17 Mar 2023 16:41:00 -0400	[thread overview]
Message-ID: <20230317204102.1776638-2-aahringo@redhat.com> (raw)
In-Reply-To: <20230317204102.1776638-1-aahringo@redhat.com>

From: Andreas Gruenbacher <agruenba@redhat.com>

In function add_waiter(), waiter->flags is left uninitialized.  Fix that.

In function add_lock(), the allocated lock is zeroed out and then all
fields except po->flags are initialized.  That's not wrong, but it seems
easier to initialize po->flags instead, like add_waiter() does now.
---
 dlm_controld/plock.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index 24ad777a..f03f3abe 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -455,7 +455,6 @@ static int add_lock(struct resource *r, uint32_t nodeid, uint64_t owner,
 	po = malloc(sizeof(struct posix_lock));
 	if (!po)
 		return -ENOMEM;
-	memset(po, 0, sizeof(struct posix_lock));
 
 	po->start = start;
 	po->end = end;
@@ -463,6 +462,7 @@ static int add_lock(struct resource *r, uint32_t nodeid, uint64_t owner,
 	po->owner = owner;
 	po->pid = pid;
 	po->ex = ex;
+	po->flags = 0;
 	list_add_tail(&po->list, &r->locks);
 
 	return 0;
@@ -680,6 +680,7 @@ static int add_waiter(struct lockspace *ls, struct resource *r,
 	if (!w)
 		return -ENOMEM;
 	memcpy(&w->info, in, sizeof(struct dlm_plock_info));
+	w->flags = 0;
 	list_add_tail(&w->list, &r->waiters);
 	return 0;
 }
@@ -1095,6 +1096,7 @@ static void save_pending_plock(struct lockspace *ls, struct resource *r,
 		return;
 	}
 	memcpy(&w->info, in, sizeof(struct dlm_plock_info));
+	w->flags = 0;
 	list_add_tail(&w->list, &r->pending);
 }
 
@@ -1967,6 +1969,7 @@ void receive_plocks_data(struct lockspace *ls, struct dlm_header *hd, int len)
 			w->info.pid	= le32_to_cpu(pp->pid);
 			w->info.nodeid	= le32_to_cpu(pp->nodeid);
 			w->info.ex	= pp->ex;
+			w->flags	= 0;
 			list_add_tail(&w->list, &r->waiters);
 		}
 		pp++;
-- 
2.31.1


  reply	other threads:[~2023-03-17 20:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 20:40 [Cluster-devel] [PATCH 0/3] dlm_controld: more plock fixes and cleanups Alexander Aring
2023-03-17 20:41 ` Alexander Aring [this message]
2023-03-17 20:41 ` [Cluster-devel] [PATCH 2/3] dlm_controld: get rid of unnecessary memset Alexander Aring
2023-03-17 20:41 ` [Cluster-devel] [PATCH 3/3] dlm_controld: remove unnecessary list_empty check Alexander Aring

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=20230317204102.1776638-2-aahringo@redhat.com \
    --to=aahringo@redhat.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;
as well as URLs for NNTP newsgroup(s).