Message ID | 20171229072925.15689-1-harshasharmaiitr@gmail.com |
---|---|
State | Changes Requested |
Delegated to: | Pablo Neira |
Headers | show |
Series | [libnftnl] tests: nft-parsing-test: fix warning - ignoring return value of fgets | expand |
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. -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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)
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(-)