Message ID | 1633550663-25571-2-git-send-email-bmarzins@redhat.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Delegated to: | christophe varoqui |
Headers | show |
Series | improving config parsing warnings | expand |
On Wed, 2021-10-06 at 15:04 -0500, Benjamin Marzinski wrote: > 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 and 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> Apart from typo in the subject: Reviewed-by: Martin Wilck <mwilck@suse.com> -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
On Thu, Nov 04, 2021 at 08:55:39PM +0000, Martin Wilck wrote: > On Wed, 2021-10-06 at 15:04 -0500, Benjamin Marzinski wrote: > > 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 and 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> > > Apart from typo in the subject: Oops. I'll fix that. -Ben > > Reviewed-by: Martin Wilck <mwilck@suse.com> -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
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);
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 and 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> --- libmultipath/parser.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)