* [dpdk-dev] [PATCH] app/proc-info:fix port mask parse bug
@ 2018-09-27 7:01 Li Han
2018-11-05 11:41 ` Thomas Monjalon
2018-11-05 15:27 ` Pattan, Reshma
0 siblings, 2 replies; 3+ messages in thread
From: Li Han @ 2018-09-27 7:01 UTC (permalink / raw)
To: maryam.tahhan; +Cc: dev, Li Han
parse_portmask return type is int,but global variable
"enabled_port_mask" type is uint32_t.so in proc_info_parse_args
function,when parse_portmask return -1,"enabled_port_mask" will
get a huge value and "if (enabled_port_mask == 0)" will never happen.
Signed-off-by: Li Han <han.li1@zte.com.cn>
---
app/proc-info/main.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index c20effa..5b06735 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -90,7 +90,7 @@
/*
* Parse the portmask provided at run time.
*/
-static int
+static uint32_t
parse_portmask(const char *portmask)
{
char *end = NULL;
@@ -103,13 +103,10 @@
if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0') ||
(errno != 0)) {
printf("%s ERROR parsing the port mask\n", __func__);
- return -1;
+ return 0;
}
- if (pm == 0)
- return -1;
-
- return pm;
+ return (uint32_t)pm;
}
--
1.8.3.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] app/proc-info:fix port mask parse bug
2018-09-27 7:01 [dpdk-dev] [PATCH] app/proc-info:fix port mask parse bug Li Han
@ 2018-11-05 11:41 ` Thomas Monjalon
2018-11-05 15:27 ` Pattan, Reshma
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2018-11-05 11:41 UTC (permalink / raw)
To: Reshma Pattan; +Cc: dev, Li Han, maryam.tahhan
+Cc Reshma
Please could you review this patch?
27/09/2018 09:01, Li Han:
> parse_portmask return type is int,but global variable
> "enabled_port_mask" type is uint32_t.so in proc_info_parse_args
> function,when parse_portmask return -1,"enabled_port_mask" will
> get a huge value and "if (enabled_port_mask == 0)" will never happen.
>
> Signed-off-by: Li Han <han.li1@zte.com.cn>
> ---
> app/proc-info/main.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/app/proc-info/main.c b/app/proc-info/main.c
> index c20effa..5b06735 100644
> --- a/app/proc-info/main.c
> +++ b/app/proc-info/main.c
> @@ -90,7 +90,7 @@
> /*
> * Parse the portmask provided at run time.
> */
> -static int
> +static uint32_t
> parse_portmask(const char *portmask)
> {
> char *end = NULL;
> @@ -103,13 +103,10 @@
> if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0') ||
> (errno != 0)) {
> printf("%s ERROR parsing the port mask\n", __func__);
> - return -1;
> + return 0;
> }
>
> - if (pm == 0)
> - return -1;
> -
> - return pm;
> + return (uint32_t)pm;
>
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] app/proc-info:fix port mask parse bug
2018-09-27 7:01 [dpdk-dev] [PATCH] app/proc-info:fix port mask parse bug Li Han
2018-11-05 11:41 ` Thomas Monjalon
@ 2018-11-05 15:27 ` Pattan, Reshma
1 sibling, 0 replies; 3+ messages in thread
From: Pattan, Reshma @ 2018-11-05 15:27 UTC (permalink / raw)
To: Li Han, Tahhan, Maryam; +Cc: dev
Hi,
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Li Han
To avoid typecast below , please use uint64_t for enabled_port_mask.
So change below function return type to uint64_t
> -static int
> +static uint32_t
> parse_portmask(const char *portmask)
> {
Declare pm to be of type uint64_t.
> + return (uint32_t)pm;
You can remove above typecast after change to uint64_t.
Thanks,
Reshma
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-05 15:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-27 7:01 [dpdk-dev] [PATCH] app/proc-info:fix port mask parse bug Li Han
2018-11-05 11:41 ` Thomas Monjalon
2018-11-05 15:27 ` Pattan, Reshma
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).