From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id E32432BF9 for ; Wed, 20 Apr 2016 15:37:10 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 20 Apr 2016 06:37:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,509,1455004800"; d="scan'208";a="962714106" Received: from gklab-246-025.igk.intel.com (HELO Sent) ([10.217.246.25]) by fmsmga002.fm.intel.com with SMTP; 20 Apr 2016 06:37:08 -0700 Received: by Sent (sSMTP sendmail emulation); Wed, 20 Apr 2016 16:39:32 +0200 From: Daniel Mrzyglod To: alan.carew@intel.com Cc: dev@dpdk.org, Daniel Mrzyglod Date: Wed, 20 Apr 2016 16:39:30 +0200 Message-Id: <1461163170-237505-1-git-send-email-danielx.t.mrzyglod@intel.com> X-Mailer: git-send-email 2.5.5 Subject: [dpdk-dev] [PATCH] power: fix argument cannot be negative 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: Wed, 20 Apr 2016 13:37:11 -0000 Fix issue reported by Coverity. Coverity ID 13269 & 13266: Function strerror(errno) has built strings only for non-negative errno values. for negative values of errno it describe error as "Unknown error -errno" to be more descriptive i put string "channel not found" taken from header. The negative argument will be interpreted as a very large unsigned value. In send_msg: Negative value used as argument to a function expecting a positive value (for example, size of buffer or allocation) Fixes: 445c6528b55f ("power: common interface for guest and host") Signed-off-by: Daniel Mrzyglod --- lib/librte_power/guest_channel.c | 3 ++- lib/librte_power/rte_power_kvm_vm.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/librte_power/guest_channel.c b/lib/librte_power/guest_channel.c index d6b6d0a..c0d23d8 100644 --- a/lib/librte_power/guest_channel.c +++ b/lib/librte_power/guest_channel.c @@ -104,7 +104,8 @@ guest_channel_host_connect(const char *path, unsigned lcore_id) ret = guest_channel_send_msg(&pkt, lcore_id); if (ret != 0) { RTE_LOG(ERR, GUEST_CHANNEL, "Error on channel '%s' communications " - "test: %s\n", fd_path, strerror(ret)); + "test: %s\n", fd_path, ret > 0 ? strerror(ret) : + "channel not connected"); goto error; } RTE_LOG(INFO, GUEST_CHANNEL, "Channel '%s' is now connected\n", fd_path); diff --git a/lib/librte_power/rte_power_kvm_vm.c b/lib/librte_power/rte_power_kvm_vm.c index 7bb2774..5d53e6a 100644 --- a/lib/librte_power/rte_power_kvm_vm.c +++ b/lib/librte_power/rte_power_kvm_vm.c @@ -106,7 +106,8 @@ send_msg(unsigned lcore_id, uint32_t scale_direction) ret = guest_channel_send_msg(&pkt[lcore_id], lcore_id); if (ret == 0) return 1; - RTE_LOG(DEBUG, POWER, "Error sending message: %s\n", strerror(ret)); + RTE_LOG(DEBUG, POWER, "Error sending message: %s\n", ret > 0 ? strerror(ret) + : "channel not connected"); return -1; } -- 2.5.5