From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 98C2D9A88 for ; Mon, 23 Feb 2015 15:46:09 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 23 Feb 2015 06:38:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,631,1418112000"; d="scan'208";a="689453857" Received: from unknown (HELO Sent) ([10.217.248.233]) by orsmga002.jf.intel.com with SMTP; 23 Feb 2015 06:46:06 -0800 Received: by Sent (sSMTP sendmail emulation); Mon, 23 Feb 2015 15:40:39 +0100 From: Pawel Wodkowski To: dev@dpdk.org Date: Mon, 23 Feb 2015 15:10:00 +0100 Message-Id: <1424700600-1765-6-git-send-email-pawelx.wodkowski@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424700600-1765-1-git-send-email-pawelx.wodkowski@intel.com> References: <1424700600-1765-1-git-send-email-pawelx.wodkowski@intel.com> Subject: [dpdk-dev] [PATCH 5/5] Fix usage of fgets in various places X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Feb 2015 14:46:10 -0000 Declaration of fgets() is char *fgets(char *str, int size, FILE *stream); Klocwork complain about passing "sizeof()" as size parameter since implicit casting size_t to int might cause loss of precision. Signed-off-by: Pawel Wodkowski --- lib/librte_cfgfile/rte_cfgfile.c | 2 +- lib/librte_eal/bsdapp/eal/eal.c | 2 +- lib/librte_eal/linuxapp/eal/eal_hugepage_info.c | 4 ++-- lib/librte_eal/linuxapp/eal/eal_memory.c | 2 +- lib/librte_eal/linuxapp/eal/eal_pci.c | 2 +- lib/librte_eal/linuxapp/eal/eal_timer.c | 2 +- lib/librte_pmd_virtio/virtio_ethdev.c | 2 +- lib/librte_power/rte_power_acpi_cpufreq.c | 10 +++++----- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c index b81c273..15ef447 100644 --- a/lib/librte_cfgfile/rte_cfgfile.c +++ b/lib/librte_cfgfile/rte_cfgfile.c @@ -107,7 +107,7 @@ rte_cfgfile_load(const char *filename, int flags) memset(cfg->sections, 0, sizeof(cfg->sections[0]) * allocated_sections); - while (fgets(buffer, sizeof(buffer), f) != NULL) { + while (fgets(buffer, (int)sizeof(buffer), f) != NULL) { char *pos = NULL; size_t len = strnlen(buffer, sizeof(buffer)); lineno++; diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 69f3c03..ca51868 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -134,7 +134,7 @@ eal_parse_sysfs_value(const char *filename, unsigned long *val) return -1; } - if (fgets(buf, sizeof(buf), f) == NULL) { + if (fgets(buf, (int)sizeof(buf), f) == NULL) { RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n", __func__, filename); fclose(f); diff --git a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c index 590cb56..551472c 100644 --- a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c +++ b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c @@ -115,7 +115,7 @@ get_default_hp_size(void) FILE *fd = fopen(proc_meminfo, "r"); if (fd == NULL) rte_panic("Cannot open %s\n", proc_meminfo); - while(fgets(buffer, sizeof(buffer), fd)){ + while (fgets(buffer, (int)sizeof(buffer), fd)) { if (strncmp(buffer, str_hugepagesz, hugepagesz_len) == 0){ size = rte_str_to_size(&buffer[hugepagesz_len]); break; @@ -155,7 +155,7 @@ get_hugepage_dir(uint64_t hugepage_sz) if (default_size == 0) default_size = get_default_hp_size(); - while (fgets(buf, sizeof(buf), fd)){ + while (fgets(buf, (int)sizeof(buf), fd)) { if (rte_strsplit(buf, sizeof(buf), splitstr, _FIELDNAME_MAX, split_tok) != _FIELDNAME_MAX) { RTE_LOG(ERR, EAL, "Error parsing %s\n", proc_mounts); diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index a67a1b0..0c7f8ce 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -614,7 +614,7 @@ find_numasocket(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi) "%s/%s", hpi->hugedir, internal_config.hugefile_prefix); /* parse numa map */ - while (fgets(buf, sizeof(buf), f) != NULL) { + while (fgets(buf, (int)sizeof(buf), f) != NULL) { /* ignore non huge page */ if (strstr(buf, " huge ") == NULL && diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index 63bcbce..ee4e1d8 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -162,7 +162,7 @@ pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev) for (i = 0; i