From: Justin Mitchell <jumitche@redhat.com>
To: Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Cc: Steve Dickson <steved@redhat.com>
Subject: [PATCH v3 3/8] nfs-utils: Use config file name in error messages
Date: Tue, 15 May 2018 16:52:47 +0100 [thread overview]
Message-ID: <1526399567.7441.7.camel@redhat.com> (raw)
In-Reply-To: <1526399410.7441.4.camel@redhat.com>
Improve readability of error configuration error messages
by including the filename currently being read.
Signed-off-by: Justin Mitchell <jumitche@redhat.com>
---
support/nfs/conffile.c | 45 ++++++++++++++++++++++++++-------------------
1 file changed, 26 insertions(+), 19 deletions(-)
diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index 95dda99..5fb58ea 100644
--- a/support/nfs/conffile.c
+++ b/support/nfs/conffile.c
@@ -285,8 +285,9 @@ conf_parse_line(int trans, char *line, const char *filename, int lineno, char **
/* find the closing ] */
ptr = strchr(line, ']');
if (ptr == NULL) {
- xlog_warn("config file error: line %d: "
- "non-matched ']', ignoring until next section", lineno);
+ xlog_warn("config error at %s:%d: "
+ "non-matched ']', ignoring until next section",
+ filename, lineno);
return;
}
@@ -311,7 +312,8 @@ conf_parse_line(int trans, char *line, const char *filename, int lineno, char **
/* copy the section name */
*section = strdup(line);
if (!*section) {
- xlog_warn("conf_parse_line: %d: malloc failed", lineno);
+ xlog_warn("config error at %s:%d:"
+ "malloc failed", filename, lineno);
return;
}
@@ -321,14 +323,16 @@ conf_parse_line(int trans, char *line, const char *filename, int lineno, char **
/* check for the closing " */
ptr = strchr(val, '"');
if (ptr == NULL) {
- xlog_warn("config file error: line %d: "
- "non-matched '\"', ignoring until next section", lineno);
+ xlog_warn("config error at %s:%d: "
+ "non-matched '\"', ignoring until next section",
+ filename, lineno);
return;
}
*ptr = '\0';
*subsection = strdup(val);
if (!*subsection)
- xlog_warn("conf_parse_line: %d: malloc arg failed", lineno);
+ xlog_warn("config error at %s:%d: "
+ "malloc failed", filename, lineno);
return;
}
@@ -339,15 +343,17 @@ conf_parse_line(int trans, char *line, const char *filename, int lineno, char **
if (ptr == NULL) {
/* Other non-empty lines are weird. */
if (line[strspn(line, " \t")])
- xlog_warn("config file error: line %d: "
- "line not empty and not an assignment", lineno);
+ xlog_warn("config error at %s:%d: "
+ "line not empty and not an assignment",
+ filename, lineno);
return;
}
/* If no section, we are ignoring the line. */
if (!*section) {
- xlog_warn("config file error: line %d: "
- "ignoring line due to no section", lineno);
+ xlog_warn("config error at %s:%d: "
+ "ignoring line not in a section",
+ filename, lineno);
return;
}
@@ -364,8 +370,8 @@ conf_parse_line(int trans, char *line, const char *filename, int lineno, char **
val++;
ptr = strchr(val, '"');
if (ptr == NULL) {
- xlog_warn("config file error: line %d: "
- "unmatched quotes", lineno);
+ xlog_warn("config error at %s:%d: "
+ "unmatched quotes",filename, lineno);
return;
}
*ptr = '\0';
@@ -374,8 +380,8 @@ conf_parse_line(int trans, char *line, const char *filename, int lineno, char **
val++;
ptr = strchr(val, '\'');
if (ptr == NULL) {
- xlog_warn("config file error: line %d: "
- "unmatched quotes", lineno);
+ xlog_warn("config error at %s:%d: "
+ "unmatched quotes", filename, lineno);
return;
}
*ptr = '\0';
@@ -392,13 +398,13 @@ conf_parse_line(int trans, char *line, const char *filename, int lineno, char **
}
if (*line == '\0') {
- xlog_warn("config file error: line %d: "
- "missing tag in assignment", lineno);
+ xlog_warn("config error at %s:%d: "
+ "missing tag in assignment", filename, lineno);
return;
}
if (*val == '\0') {
- xlog_warn("config file error: line %d: "
- "missing value in assignment", lineno);
+ xlog_warn("config error at %s:%d: "
+ "missing value in assignment", filename, lineno);
return;
}
@@ -409,7 +415,8 @@ conf_parse_line(int trans, char *line, const char *filename, int lineno, char **
char *relpath = relative_path(filename, val);
char *subconf = conf_readfile(relpath);
if (subconf == NULL) {
- xlog_warn("%s:%d: error loading included config",
+ xlog_warn("config error at %s:%d: "
+ "error loading included config",
filename, lineno);
if (relpath)
free(relpath);
--
1.8.3.1
next prev parent reply other threads:[~2018-05-15 15:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-15 15:50 [PATCH v3 0/8] nfs-utils: nfsconf cli tool and code tests Justin Mitchell
2018-05-15 15:51 ` [PATCH v3 1/8] nfs-utils: Fix minor memory leaks Justin Mitchell
2018-05-15 15:52 ` [PATCH v3 2/8] nfs-utils: Make config includes relative to current config Justin Mitchell
2018-05-15 15:52 ` Justin Mitchell [this message]
2018-05-15 15:53 ` [PATCH v3 4/8] nfs-utils: Indicate if config file was missing Justin Mitchell
2018-05-15 15:53 ` [PATCH v3 5/8] nfs-utils: tidy up output of conf_report Justin Mitchell
2018-05-15 15:54 ` [PATCH v3 6/8] nfs-utils: Add nfsconftool cli Justin Mitchell
2018-05-21 15:31 ` Steve Dickson
2018-05-22 9:25 ` Justin Mitchell
2018-05-15 15:55 ` [PATCH v3 7/8] nfs-utils: use nfsconftool cli to test library function Justin Mitchell
2018-05-15 15:56 ` [PATCH v3 8/8] nfs-utils: Add man page for nfsconftool cli Justin Mitchell
2018-05-22 18:23 ` [PATCH v3 0/8] nfs-utils: nfsconf cli tool and code tests Steve Dickson
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=1526399567.7441.7.camel@redhat.com \
--to=jumitche@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@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