DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] power: fix argument cannot be negative
@ 2016-04-20 14:39 Daniel Mrzyglod
  2016-05-16 12:16 ` Thomas Monjalon
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Mrzyglod @ 2016-04-20 14:39 UTC (permalink / raw)
  To: alan.carew; +Cc: dev, Daniel Mrzyglod

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 <danielx.t.mrzyglod@intel.com>
---
 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] power: fix argument cannot be negative
  2016-04-20 14:39 [dpdk-dev] [PATCH] power: fix argument cannot be negative Daniel Mrzyglod
@ 2016-05-16 12:16 ` Thomas Monjalon
  2016-05-16 12:39   ` Mcnamara, John
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Monjalon @ 2016-05-16 12:16 UTC (permalink / raw)
  To: Daniel Mrzyglod; +Cc: dev, alan.carew

The title do not convey the real issue.
We should be more concerned by an issue of "wrong error message"
rather than an "argument" which "cannot be negative".

2016-04-20 16:39, Daniel Mrzyglod:
> Fix issue reported by Coverity.
> Coverity ID 13269 & 13266:

It is better to put these references below and start with the
explanation of the issue.

> 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.

OK.
The next statement is probably a useless copy paste of the coverity report.

> In send_msg: Negative value used as argument to a function expecting
> a positive value (for example, size of buffer or allocation)

Coverity issue: 13266
Coverity issue: 13269

> Fixes: 445c6528b55f ("power: common interface for guest and host")
> 
> Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
[...]
>  		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");

The indent is messy. I sugest this:

+               RTE_LOG(ERR, GUEST_CHANNEL,
+                               "Error on channel '%s' communications test: %s\n",
+                               fd_path, ret > 0 ? strerror(ret) :
+                               "channel not connected");


> -	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");

+       RTE_LOG(DEBUG, POWER, "Error sending message: %s\n",
+                       ret > 0 ? strerror(ret) : "channel not connected");

Applied with above changes, thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] power: fix argument cannot be negative
  2016-05-16 12:16 ` Thomas Monjalon
@ 2016-05-16 12:39   ` Mcnamara, John
  2016-05-16 12:59     ` Thomas Monjalon
  0 siblings, 1 reply; 5+ messages in thread
From: Mcnamara, John @ 2016-05-16 12:39 UTC (permalink / raw)
  To: Thomas Monjalon, Mrzyglod, DanielX T; +Cc: dev, Carew, Alan



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monjalon
> Sent: Monday, May 16, 2016 1:17 PM
> To: Mrzyglod, DanielX T <danielx.t.mrzyglod@intel.com>
> Cc: dev@dpdk.org; Carew, Alan <alan.carew@intel.com>
> Subject: Re: [dpdk-dev] [PATCH] power: fix argument cannot be negative
> 
> The next statement is probably a useless copy paste of the coverity
> report.
> 
> > In send_msg: Negative value used as argument to a function expecting a
> > positive value (for example, size of buffer or allocation)


A question on this point. Is it just that the Coverity message is useless
in this case or in general? For other error/warning fixes we include the
message in the commit.

John

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] power: fix argument cannot be negative
  2016-05-16 12:39   ` Mcnamara, John
@ 2016-05-16 12:59     ` Thomas Monjalon
  2016-05-16 13:03       ` Mcnamara, John
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Monjalon @ 2016-05-16 12:59 UTC (permalink / raw)
  To: Mcnamara, John; +Cc: Mrzyglod, DanielX T, dev, Carew, Alan

2016-05-16 14:39 GMT+02:00 Mcnamara, John <john.mcnamara@intel.com>:
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monjalon
>> The next statement is probably a useless copy paste of the coverity
>> report.
>>
>> > In send_msg: Negative value used as argument to a function expecting a
>> > positive value (for example, size of buffer or allocation)
>
> A question on this point. Is it just that the Coverity message is useless
> in this case or in general? For other error/warning fixes we include the
> message in the commit.

Sometimes, the coverity message is accurate, sometimes it s better to reword it.
Anyway, having 2 sentences saying the same thing is disturbing.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] power: fix argument cannot be negative
  2016-05-16 12:59     ` Thomas Monjalon
@ 2016-05-16 13:03       ` Mcnamara, John
  0 siblings, 0 replies; 5+ messages in thread
From: Mcnamara, John @ 2016-05-16 13:03 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Mrzyglod, DanielX T, dev, Carew, Alan

> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Monday, May 16, 2016 2:00 PM
> ...
> > A question on this point. Is it just that the Coverity message is
> > useless in this case or in general? For other error/warning fixes we
> > include the message in the commit.
> 
> Sometimes, the coverity message is accurate, sometimes it s better to
> reword it.
> Anyway, having 2 sentences saying the same thing is disturbing.

Ok. Noted.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-05-16 13:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-20 14:39 [dpdk-dev] [PATCH] power: fix argument cannot be negative Daniel Mrzyglod
2016-05-16 12:16 ` Thomas Monjalon
2016-05-16 12:39   ` Mcnamara, John
2016-05-16 12:59     ` Thomas Monjalon
2016-05-16 13:03       ` Mcnamara, John

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).