diff mbox

[1/2] mkfs: initialize return value of parse_config_stream to success

Message ID 8318bdfe-ff7b-02b9-414e-f63f9ccdbdbc@sandeen.net (mailing list archive)
State New, archived
Headers show

Commit Message

Eric Sandeen June 13, 2018, 7:34 p.m. UTC
Right now the return value is initialized to -1 (failure) and set to zero
only if a valid token is found.  However, this means that i.e. a blank
or template config file containing only comments will yield failure on
parsing.
    
Initialize to success, and set to failure only if failure occurs.
    
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---


--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Carlos Maiolino June 14, 2018, 8:48 a.m. UTC | #1
On Wed, Jun 13, 2018 at 02:34:33PM -0500, Eric Sandeen wrote:
> Right now the return value is initialized to -1 (failure) and set to zero
> only if a valid token is found.  However, this means that i.e. a blank
> or template config file containing only comments will yield failure on
> parsing.
>     
> Initialize to success, and set to failure only if failure occurs.
>     
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> diff --git a/mkfs/config.c b/mkfs/config.c
> index 835adc4..1a2cd35 100644
> --- a/mkfs/config.c
> +++ b/mkfs/config.c
> @@ -385,7 +385,7 @@ parse_config_stream(
>  	const char 			*config_file,

Any chance you could fix this trailing whitespace here while you are touching
it? :P


>  	FILE				*fp)
>  {
> -	int				ret = -1;


Sounds fine

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> +	int				ret = 0;
>  	char				*line = NULL;
>  	ssize_t				linelen;
>  	size_t				len = 0, lineno = 0;
> 

> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Luis Chamberlain June 14, 2018, 4:20 p.m. UTC | #2
On Wed, Jun 13, 2018 at 02:34:33PM -0500, Eric Sandeen wrote:
> Right now the return value is initialized to -1 (failure) and set to zero
> only if a valid token is found.  However, this means that i.e. a blank
> or template config file containing only comments will yield failure on
> parsing.
>     
> Initialize to success, and set to failure only if failure occurs.
>     
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Reviewed-by: Luis R. Rodriguez <mcgrof@kernel.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Darrick J. Wong June 14, 2018, 4:41 p.m. UTC | #3
On Wed, Jun 13, 2018 at 02:34:33PM -0500, Eric Sandeen wrote:
> Right now the return value is initialized to -1 (failure) and set to zero
> only if a valid token is found.  However, this means that i.e. a blank
> or template config file containing only comments will yield failure on
> parsing.
>     
> Initialize to success, and set to failure only if failure occurs.
>     
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
> 
> diff --git a/mkfs/config.c b/mkfs/config.c
> index 835adc4..1a2cd35 100644
> --- a/mkfs/config.c
> +++ b/mkfs/config.c
> @@ -385,7 +385,7 @@ parse_config_stream(
>  	const char 			*config_file,
>  	FILE				*fp)
>  {
> -	int				ret = -1;
> +	int				ret = 0;
>  	char				*line = NULL;
>  	ssize_t				linelen;
>  	size_t				len = 0, lineno = 0;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/mkfs/config.c b/mkfs/config.c
index 835adc4..1a2cd35 100644
--- a/mkfs/config.c
+++ b/mkfs/config.c
@@ -385,7 +385,7 @@  parse_config_stream(
 	const char 			*config_file,
 	FILE				*fp)
 {
-	int				ret = -1;
+	int				ret = 0;
 	char				*line = NULL;
 	ssize_t				linelen;
 	size_t				len = 0, lineno = 0;