All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Wilck <mwilck@suse.com>
To: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Cc: lixiaokeng <lixiaokeng@huawei.com>,
	yanxiaodan@huawei.com, linfeilong@huawei.com,
	dm-devel@redhat.com, Zdenek Kabelac <zkabelac@redhat.com>
Subject: Re: [PATCH V3 2/5] multipathd: use daemon_status_msg to construct sd notify msg in do_sd_notify func
Date: Mon, 31 Aug 2020 11:55:48 +0200	[thread overview]
Message-ID: <cb97dfa97281bf9fe6738ffbf6abb20b5e2991ae.camel@suse.com> (raw)
In-Reply-To: <8e24c49b-6f56-e7ea-7f2a-e7bd9d266e23@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 1029 bytes --]

Hello Zhiqiang,

On Sat, 2020-08-29 at 11:03 +0800, Zhiqiang Liu wrote:
> sd_notify_status() is very similar with daemon_status(), except
> DAEMON_IDLE and DAEMON_RUNNING state. As suggested by Martin,
> we can create the sd notification string in a dynamic buffer,
> and treat DAEMON_IDLE and DAEMON_RUNNING cases first. Then,
> we can use daemon_status_msg[state] for other cases.
> 
> V2->V3:
> - set MSG_SIZE to 32 and use safe_sprintf as suggested by Martin.
> 
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> Signed-off-by: lixiaokeng <lixiaokeng@huawei.com>
> ---
>  multipathd/main.c | 34 ++++++++++++----------------------
>  1 file changed, 12 insertions(+), 22 deletions(-)

Thanks again. I'd like to modify the patch slightly as attached. 
I'm sorry that I didn't mention these minor issues in my previous
reviews. I'm sending you the fixup patch in order to short-circuit 
the procedure a bit and save both of us some work.

Would this be ok for you?
If yes, please resubmit this as v4.

Regards,
Martin


[-- Attachment #2: 0001-fixup-multipathd-use-daemon_status_msg-to-construct-.patch --]
[-- Type: text/x-patch, Size: 1303 bytes --]

From 73915fb32b2b0d233ee908a4789613c03c27285e Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Mon, 31 Aug 2020 11:43:56 +0200
Subject: [PATCH] fixup! multipathd: use daemon_status_msg to construct sd
 notify msg in do_sd_notify func

 - no need to initialize msg, it's always set
 - msg could be NULL, at least in theory, so check return value before passing
 it to snprintf()
 - avoid "prefix" variable; rather put the prefix in format string
---
 multipathd/main.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/multipathd/main.c b/multipathd/main.c
index 5df004a..f7229a7 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -183,8 +183,7 @@ static void do_sd_notify(enum daemon_status old_state,
 			 enum daemon_status new_state)
 {
 	char notify_msg[MSG_SIZE];
-	const char prefix[] = "STATUS=";
-	const char *msg = NULL;
+	const char *msg;
 	/*
 	 * Checkerloop switches back and forth between idle and running state.
 	 * No need to tell systemd each time.
@@ -199,7 +198,7 @@ static void do_sd_notify(enum daemon_status old_state,
 	else
 		msg = daemon_status_msg[new_state];
 
-	if (!safe_sprintf(notify_msg, "%s%s", prefix, msg))
+	if (msg && !safe_sprintf(notify_msg, "STATUS=%s", msg))
 		sd_notify(0, notify_msg);
 }
 #endif
-- 
2.28.0


[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2020-08-31  9:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-29  3:02 [PATCH V3 0/5] multipath-tools series: some cleanups and fixes Zhiqiang Liu
2020-08-29  3:03 ` [PATCH V3 1/5] multipathd: adopt static char* arr in daemon_status Zhiqiang Liu
2020-08-31 14:37   ` Martin Wilck
2020-08-29  3:03 ` [PATCH V3 2/5] multipathd: use daemon_status_msg to construct sd notify msg in do_sd_notify func Zhiqiang Liu
2020-08-31  9:55   ` Martin Wilck [this message]
2020-08-31 11:03     ` Zhiqiang Liu

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=cb97dfa97281bf9fe6738ffbf6abb20b5e2991ae.camel@suse.com \
    --to=mwilck@suse.com \
    --cc=dm-devel@redhat.com \
    --cc=linfeilong@huawei.com \
    --cc=liuzhiqiang26@huawei.com \
    --cc=lixiaokeng@huawei.com \
    --cc=yanxiaodan@huawei.com \
    --cc=zkabelac@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 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.