All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Marzinski <bmarzins@redhat.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>,
	Martin Wilck <Martin.Wilck@suse.com>
Subject: [dm-devel] [PATCH v2 1/9] libmultipath: add section name to invalid keyword output
Date: Wed, 10 Nov 2021 19:06:12 -0600	[thread overview]
Message-ID: <1636592780-20391-2-git-send-email-bmarzins@redhat.com> (raw)
In-Reply-To: <1636592780-20391-1-git-send-email-bmarzins@redhat.com>

If users forget the closing brace for a section in multipath.conf,
multipath has no way to detect that. When it sees the keyword at the
start of the next section, it will complain that there is an invalid
keyword, because that keyword doesn't belong in previous section (which
was never ended with a closing brace). This can confuse users. To make
this easier to understand, when multipath prints an invalid keyword
message, it now also prints the current section name, which can give
users a hint that they didn't end the previous section.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
---
 libmultipath/parser.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/libmultipath/parser.c b/libmultipath/parser.c
index 8ca91bf2..611054f7 100644
--- a/libmultipath/parser.c
+++ b/libmultipath/parser.c
@@ -504,7 +504,7 @@ validate_config_strvec(vector strvec, const char *file)
 
 static int
 process_stream(struct config *conf, FILE *stream, vector keywords,
-	       const char *file)
+	       const char *section, const char *file)
 {
 	int i;
 	int r = 0, t;
@@ -568,16 +568,22 @@ process_stream(struct config *conf, FILE *stream, vector keywords,
 				if (keyword->sub) {
 					kw_level++;
 					r += process_stream(conf, stream,
-							    keyword->sub, file);
+							    keyword->sub,
+							    keyword->string,
+							    file);
 					kw_level--;
 				}
 				break;
 			}
 		}
-		if (i >= VECTOR_SIZE(keywords))
-			condlog(1, "%s line %d, invalid keyword: %s",
-				file, line_nr, str);
-
+		if (i >= VECTOR_SIZE(keywords)) {
+			if (section)
+				condlog(1, "%s line %d, invalid keyword in the %s section: %s",
+					file, line_nr, section, str);
+			else
+				condlog(1, "%s line %d, invalid keyword: %s",
+					file, line_nr, str);
+		}
 		free_strvec(strvec);
 	}
 	if (kw_level == 1)
@@ -608,7 +614,7 @@ process_file(struct config *conf, const char *file)
 
 	/* Stream handling */
 	line_nr = 0;
-	r = process_stream(conf, stream, conf->keywords, file);
+	r = process_stream(conf, stream, conf->keywords, NULL, file);
 	fclose(stream);
 	//free_keywords(keywords);
 
-- 
2.17.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  reply	other threads:[~2021-11-11  1:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11  1:06 [dm-devel] [PATCH v2 0/9] improving config parsing warnings Benjamin Marzinski
2021-11-11  1:06 ` Benjamin Marzinski [this message]
2021-11-11  1:06 ` [dm-devel] [PATCH v2 2/9] libmultipath: use typedef for keyword handler function Benjamin Marzinski
2021-11-11  1:06 ` [dm-devel] [PATCH v2 3/9] libmultipath: print the correct file when parsing fails Benjamin Marzinski
2021-11-11  1:06 ` [dm-devel] [PATCH v2 4/9] libmultipath: pass file and line number to keyword handlers Benjamin Marzinski
2021-11-11 11:31   ` Martin Wilck
2021-11-11  1:06 ` [dm-devel] [PATCH v2 5/9] libmultipath: make set_int take a range for valid values Benjamin Marzinski
2021-11-11 11:33   ` Martin Wilck
2021-11-11  1:06 ` [dm-devel] [PATCH v2 6/9] libmultipath: improve checks for set_str Benjamin Marzinski
2021-11-11 11:34   ` Martin Wilck
2021-11-11  1:06 ` [dm-devel] [PATCH v2 7/9] libmultipath: deprecate file and directory config options Benjamin Marzinski
2021-11-11 11:44   ` Martin Wilck
2021-11-11 15:36     ` Benjamin Marzinski
2021-11-11  1:06 ` [dm-devel] [PATCH v2 8/9] libmultipath: split set_int to enable reuse Benjamin Marzinski
2021-11-11 11:52   ` Martin Wilck
2021-11-11  1:06 ` [dm-devel] [PATCH v2 9/9] libmultipath: cleanup invalid config handling Benjamin Marzinski
2021-11-11 11:54   ` Martin Wilck

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=1636592780-20391-2-git-send-email-bmarzins@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=Martin.Wilck@suse.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@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.