All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Benjamin Marzinski" <bmarzins@redhat.com>
To: device-mapper development <dm-devel@redhat.com>
Cc: Martin Wilck <mwilck@suse.com>
Subject: [PATCH 6/6] libmultipath: don't print undefined values
Date: Thu, 29 Mar 2018 22:37:03 -0500	[thread overview]
Message-ID: <1522381023-15262-7-git-send-email-bmarzins@redhat.com> (raw)
In-Reply-To: <1522381023-15262-1-git-send-email-bmarzins@redhat.com>

commit 48e9fd9f ("libmultipath: parser: use call-by-value for "snprint"
methods") removed some of the code that checked for undefined values to
avoid printing them.  This lead to device configurations that printed
out values for parameters that they hadn't configured. This patch adds
that code back in.

Fixes: 48e9fd9f ("libmultipath: parser: use call-by-value for "snprint" methods")
Cc: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/dict.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libmultipath/dict.c b/libmultipath/dict.c
index ac9216c..1a18337 100644
--- a/libmultipath/dict.c
+++ b/libmultipath/dict.c
@@ -101,12 +101,16 @@ print_int (char *buff, int len, long v)
 static int
 print_nonzero (char *buff, int len, long v)
 {
+	if (!v)
+		return 0;
 	return snprintf(buff, len, "%li", v);
 }
 
 static int
 print_str (char *buff, int len, const char *ptr)
 {
+	if (!ptr)
+		return 0;
 	return snprintf(buff, len, "\"%s\"", ptr);
 }
 
@@ -120,6 +124,8 @@ print_yes_no (char *buff, int len, long v)
 static int
 print_yes_no_undef (char *buff, int len, long v)
 {
+	if (!v)
+		return 0;
 	return snprintf(buff, len, "\"%s\"",
 			(v == YNU_NO)? "no" : "yes");
 }
@@ -665,6 +671,8 @@ set_dev_loss(vector strvec, void *ptr)
 int
 print_dev_loss(char * buff, int len, unsigned long v)
 {
+	if (!v)
+		return 0;
 	if (v >= MAX_DEV_LOSS_TMO)
 		return snprintf(buff, len, "\"infinity\"");
 	return snprintf(buff, len, "%lu", v);
-- 
2.7.4

      parent reply	other threads:[~2018-03-30  3:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-30  3:36 [PATCH 0/6] multipath cleanup patches Benjamin Marzinski
2018-03-30  3:36 ` [PATCH 1/6] multipathd: remove incorrect pthread_testcancel Benjamin Marzinski
2018-04-04 15:33   ` Martin Wilck
2018-03-30  3:36 ` [PATCH 2/6] multipath: add comments Benjamin Marzinski
2018-04-04 15:34   ` Martin Wilck
2018-03-30  3:37 ` [PATCH 3/6] multipathd: minor dmevents polling code cleanups Benjamin Marzinski
2018-04-04 15:35   ` Martin Wilck
2018-03-30  3:37 ` [PATCH 4/6] multipathd: remove unneeded function parameter Benjamin Marzinski
2018-04-04 15:50   ` Martin Wilck
2018-03-30  3:37 ` [PATCH 5/6] mpathcmd: fix libmpathcmd license Benjamin Marzinski
2018-04-04 15:50   ` Martin Wilck
2018-03-30  3:37 ` Benjamin Marzinski [this message]

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=1522381023-15262-7-git-send-email-bmarzins@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=mwilck@suse.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.