netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH libnftnl] tests: nft-parsing-test: fix warning - ignoring return value of fgets
@ 2017-12-29  7:29 Harsha Sharma
  2017-12-30 21:02 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Harsha Sharma @ 2017-12-29  7:29 UTC (permalink / raw)
  To: pablo, harshasharmaiitr; +Cc: netfilter-devel

This patch fixes compilation warning: ignoring return value of fgets.

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
---
 tests/nft-parsing-test.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c
index d25a73e..97f402d 100644
--- a/tests/nft-parsing-test.c
+++ b/tests/nft-parsing-test.c
@@ -80,7 +80,8 @@ static int compare_test(uint32_t type, struct nftnl_ruleset *rs,
 	}
 
 	rewind(fp);
-	fgets(orig, sizeof(orig), fp);
+	if (fgets(orig, sizeof(orig), fp) == NULL)
+		fprintf(stderr, "Error in reading or end of file.\n");
 
 	if (strncmp(orig, out, strlen(out)) == 0) {
 		if (update)
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH libnftnl] tests: nft-parsing-test: fix warning - ignoring return value of fgets
  2017-12-29  7:29 [PATCH libnftnl] tests: nft-parsing-test: fix warning - ignoring return value of fgets Harsha Sharma
@ 2017-12-30 21:02 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2017-12-30 21:02 UTC (permalink / raw)
  To: Harsha Sharma; +Cc: netfilter-devel

Hi Harsha,

On Fri, Dec 29, 2017 at 12:59:25PM +0530, Harsha Sharma wrote:
> This patch fixes compilation warning: ignoring return value of fgets.
> 
> Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
> ---
>  tests/nft-parsing-test.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c
> index d25a73e..97f402d 100644
> --- a/tests/nft-parsing-test.c
> +++ b/tests/nft-parsing-test.c
> @@ -80,7 +80,8 @@ static int compare_test(uint32_t type, struct nftnl_ruleset *rs,
>  	}
>  
>  	rewind(fp);
> -	fgets(orig, sizeof(orig), fp);
> +	if (fgets(orig, sizeof(orig), fp) == NULL)
> +		fprintf(stderr, "Error in reading or end of file.\n");

Did you test this? Are you sure this is the right fix for this?
IIRC, EOF is reported via NULL too for fgets.

Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-30 21:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-29  7:29 [PATCH libnftnl] tests: nft-parsing-test: fix warning - ignoring return value of fgets Harsha Sharma
2017-12-30 21:02 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).