From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 523AF1B21B for ; Wed, 1 Nov 2017 13:10:35 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Nov 2017 05:10:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,327,1505804400"; d="scan'208";a="916224042" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by FMSMGA003.fm.intel.com with ESMTP; 01 Nov 2017 05:10:32 -0700 From: Bernard Iremonger To: dev@dpdk.org, jasvinder.singh@intel.com Cc: Bernard Iremonger Date: Wed, 1 Nov 2017 12:10:29 +0000 Message-Id: <1509538229-1354-1-git-send-email-bernard.iremonger@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] examples/flow_classify: fix fseek error handling X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Nov 2017 12:10:36 -0000 Check return value of fseek and exit if non zero. Coverity issue: 143435 Fixes: bab16ddaf2c1 ("examples/flow_classify: add sample application") Signed-off-by: Bernard Iremonger --- examples/flow_classify/flow_classify.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/flow_classify/flow_classify.c b/examples/flow_classify/flow_classify.c index e4cabdb..766f1dd 100644 --- a/examples/flow_classify/flow_classify.c +++ b/examples/flow_classify/flow_classify.c @@ -657,13 +657,17 @@ static __attribute__((noreturn)) void unsigned int i = 0; unsigned int total_num = 0; struct rte_eth_ntuple_filter ntuple_filter; + int ret; fh = fopen(rule_path, "rb"); if (fh == NULL) - rte_exit(EXIT_FAILURE, "%s: Open %s failed\n", __func__, + rte_exit(EXIT_FAILURE, "%s: fopen %s failed\n", __func__, rule_path); - fseek(fh, 0, SEEK_SET); + ret = fseek(fh, 0, SEEK_SET); + if (ret) + rte_exit(EXIT_FAILURE, "%s: fseek %d failed\n", __func__, + ret); i = 0; while (fgets(buff, LINE_MAX, fh) != NULL) { -- 1.9.1