diff mbox

[dpdk-dev] librte_eal: Add fscanf return value test

Message ID 1421418472-4640-1-git-send-email-tomaszx.kulasek@intel.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Tomasz Kulasek Jan. 16, 2015, 2:27 p.m. UTC
The lack of result checking of fscanf function, brakes compilation for default 
"-Werror=unused-result" flag.

Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
---
 lib/librte_eal/linuxapp/eal/eal.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Pablo de Lara Jan. 16, 2015, 2:55 p.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tomasz Kulasek
> Sent: Friday, January 16, 2015 2:28 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] librte_eal: Add fscanf return value test
> 
> The lack of result checking of fscanf function, brakes compilation for default
> "-Werror=unused-result" flag.
> 
> Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>

Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Thomas Monjalon Jan. 16, 2015, 5:05 p.m. UTC | #2
> > The lack of result checking of fscanf function, brakes compilation for default
> > "-Werror=unused-result" flag.
> > 
> > Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
> 
> Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Applied

Thanks
diff mbox

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 648ef81..f99e158 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -865,6 +865,7 @@  rte_eal_check_module(const char *module_name)
 {
 	char mod_name[30]; /* Any module names can be longer than 30 bytes? */
 	int ret = 0;
+	int n;
 
 	if (NULL == module_name)
 		return -1;
@@ -876,8 +877,8 @@  rte_eal_check_module(const char *module_name)
 		return -1;
 	}
 	while (!feof(fd)) {
-		fscanf(fd, "%29s %*[^\n]", mod_name);
-		if (!strcmp(mod_name, module_name)) {
+		n = fscanf(fd, "%29s %*[^\n]", mod_name);
+		if ((n == 1) && !strcmp(mod_name, module_name)) {
 			ret = 1;
 			break;
 		}