diff mbox

[4/5] libmultipath: Print line number for which parsing failed

Message ID 53C918F5.2050703@acm.org (mailing list archive)
State Not Applicable, archived
Delegated to: Mike Snitzer
Headers show

Commit Message

Bart Van Assche July 18, 2014, 12:54 p.m. UTC
Make it easier to figure out which line contains a syntax error
by printing the line number and the offending line itself.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 libmultipath/parser.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Sebastian Herbszt July 24, 2014, 2:44 p.m. UTC | #1
Bart Van Assche wrote:
> Make it easier to figure out which line contains a syntax error
> by printing the line number and the offending line itself.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  libmultipath/parser.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/libmultipath/parser.c b/libmultipath/parser.c
> index b7bdfcc..d8673bc 100644
> --- a/libmultipath/parser.c
> +++ b/libmultipath/parser.c
> @@ -460,7 +460,7 @@ int
>  process_stream(vector keywords)
>  {
>  	int i;
> -	int r = 0;
> +	int r = 0, t;
>  	struct keyword *keyword;
>  	char *str;
>  	char *buf;
> @@ -501,8 +501,13 @@ process_stream(vector keywords)
>  						free_strvec(strvec);
>  						goto out;
>  				}
> -				if (keyword->handler)
> -					r += (*keyword->handler) (strvec);
> +				if (keyword->handler) {
> +					t = (*keyword->handler) (strvec);
> +					r += t;
> +					if (t)
> +						condlog(1, "multipath.conf +%d parsing failed: %s",
> +							line_nr, buf);
> +				}
>  
>  				if (keyword->sub) {
>  					kw_level++;

Further below
condlog(1, "multipath.conf +%d, invalid keyword: %s", line_nr, str);
is used, so maybe also add a comma after the line number too.

Sebastian

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
Christophe Varoqui July 25, 2014, 9:15 a.m. UTC | #2
Done,
Thanks.


On Thu, Jul 24, 2014 at 4:44 PM, Sebastian Herbszt <herbszt@gmx.de> wrote:

> Bart Van Assche wrote:
> > Make it easier to figure out which line contains a syntax error
> > by printing the line number and the offending line itself.
> >
> > Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> > ---
> >  libmultipath/parser.c | 11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/libmultipath/parser.c b/libmultipath/parser.c
> > index b7bdfcc..d8673bc 100644
> > --- a/libmultipath/parser.c
> > +++ b/libmultipath/parser.c
> > @@ -460,7 +460,7 @@ int
> >  process_stream(vector keywords)
> >  {
> >       int i;
> > -     int r = 0;
> > +     int r = 0, t;
> >       struct keyword *keyword;
> >       char *str;
> >       char *buf;
> > @@ -501,8 +501,13 @@ process_stream(vector keywords)
> >                                               free_strvec(strvec);
> >                                               goto out;
> >                               }
> > -                             if (keyword->handler)
> > -                                     r += (*keyword->handler) (strvec);
> > +                             if (keyword->handler) {
> > +                                     t = (*keyword->handler) (strvec);
> > +                                     r += t;
> > +                                     if (t)
> > +                                             condlog(1, "multipath.conf
> +%d parsing failed: %s",
> > +                                                     line_nr, buf);
> > +                             }
> >
> >                               if (keyword->sub) {
> >                                       kw_level++;
>
> Further below
> condlog(1, "multipath.conf +%d, invalid keyword: %s", line_nr, str);
> is used, so maybe also add a comma after the line number too.
>
> Sebastian
>
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox

Patch

diff --git a/libmultipath/parser.c b/libmultipath/parser.c
index b7bdfcc..d8673bc 100644
--- a/libmultipath/parser.c
+++ b/libmultipath/parser.c
@@ -460,7 +460,7 @@  int
 process_stream(vector keywords)
 {
 	int i;
-	int r = 0;
+	int r = 0, t;
 	struct keyword *keyword;
 	char *str;
 	char *buf;
@@ -501,8 +501,13 @@  process_stream(vector keywords)
 						free_strvec(strvec);
 						goto out;
 				}
-				if (keyword->handler)
-					r += (*keyword->handler) (strvec);
+				if (keyword->handler) {
+					t = (*keyword->handler) (strvec);
+					r += t;
+					if (t)
+						condlog(1, "multipath.conf +%d parsing failed: %s",
+							line_nr, buf);
+				}
 
 				if (keyword->sub) {
 					kw_level++;