DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@amd.com>
To: Jie Hai <haijie1@huawei.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Cc: dev@dpdk.org, liudongdong3@huawei.com
Subject: Re: [PATCH v2 03/13] ethdev: extract codes parsing port ID as a function
Date: Wed, 7 Jun 2023 12:37:52 +0100	[thread overview]
Message-ID: <9a7832fe-df4f-caf7-c227-1cecea15da7e@amd.com> (raw)
In-Reply-To: <20230607074209.4798-4-haijie1@huawei.com>

On 6/7/2023 8:41 AM, Jie Hai wrote:
> This patch extracts codes parsing port_id as a function.
> The port id of 'int' or 'unsigned long' type passing as
> 'uint16_t' may cause truncation, fix it.
> 
> Signed-off-by: Jie Hai <haijie1@huawei.com>
> ---
>  lib/ethdev/rte_ethdev_telemetry.c | 95 ++++++++++++++++---------------
>  lib/ethdev/sff_telemetry.c        |  4 +-
>  2 files changed, 52 insertions(+), 47 deletions(-)
> 
> diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
> index ec8e48877187..5e70d0c2a66a 100644
> --- a/lib/ethdev/rte_ethdev_telemetry.c
> +++ b/lib/ethdev/rte_ethdev_telemetry.c
> @@ -11,6 +11,29 @@
>  #include "ethdev_driver.h"
>  #include "sff_telemetry.h"
>  
> +static int
> +eth_dev_parse_port_params(const char *params __rte_unused, uint16_t *port_id,
> +		char **end_param, bool has_next)
>

'__rte_unused' is not required for 'params'

> +{
> +	uint64_t pi;
> +
> +	if (params == NULL || strlen(params) == 0 ||
> +		!isdigit(*params) || port_id == NULL)
> +		return -EINVAL;
> +
> +	pi = strtoul(params, end_param, 0);
> +	if (**end_param != '\0' && !has_next)
> +		RTE_ETHDEV_LOG(NOTICE,
> +			"Extra parameters passed to ethdev telemetry command, ignoring\n");
> +
> +	if (pi >= UINT16_MAX || !rte_eth_dev_is_valid_port(pi))
> +		return -EINVAL;
> +
> +	*port_id = pi;
>

there is 64 -> 16 bit conversion, there is a "pi >= UINT16_MAX" check
already but not sure if all compilers get it, better to add explicit
cast for any case.

  reply	other threads:[~2023-06-07 11:38 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30  9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
2023-05-30  9:05 ` [PATCH 01/10] ethdev: support telemetry query MAC addresses Jie Hai
2023-06-01 14:39   ` Ferruh Yigit
2023-05-30  9:05 ` [PATCH 02/10] ethdev: support RxTx offload display Jie Hai
2023-05-30  9:05 ` [PATCH 03/10] ethdev: support telemetry query flow ctrl info Jie Hai
2023-05-30  9:05 ` [PATCH 04/10] ethdev: support telemetry query Rx queue info Jie Hai
2023-05-30  9:05 ` [PATCH 05/10] ethdev: support telemetry query Tx " Jie Hai
2023-05-30  9:05 ` [PATCH 06/10] ethdev: add firmware version in telemetry info command Jie Hai
2023-05-30  9:05 ` [PATCH 07/10] ethdev: support telemetry query DCB info Jie Hai
2023-05-30  9:05 ` [PATCH 08/10] ethdev: support telemetry query RSS info Jie Hai
2023-05-30  9:05 ` [PATCH 09/10] ethdev: support telemetry query FEC info Jie Hai
2023-05-30  9:05 ` [PATCH 10/10] ethdev: support telemetry query VLAN info Jie Hai
2023-06-01 12:05 ` [PATCH 00/10] support telemetry query ethdev info Ferruh Yigit
2023-06-01 12:23   ` Jie Hai
2023-06-01 14:36 ` Ferruh Yigit
2023-06-05  6:19   ` Jie Hai
2023-06-07  7:41 ` [PATCH v2 00/13] " Jie Hai
2023-06-07  7:41   ` [PATCH v2 01/13] ethdev: fix incorrect argument of calloc Jie Hai
2023-06-07 11:35     ` Ferruh Yigit
2023-06-07  7:41   ` [PATCH v2 02/13] ethdev: extract telemetry codes to a file Jie Hai
2023-06-07 11:37     ` Ferruh Yigit
2023-06-07  7:41   ` [PATCH v2 03/13] ethdev: extract codes parsing port ID as a function Jie Hai
2023-06-07 11:37     ` Ferruh Yigit [this message]
2023-06-07  7:41   ` [PATCH v2 04/13] ethdev: support telemetry query MAC addresses Jie Hai
2023-06-07  7:42   ` [PATCH v2 05/13] ethdev: support RxTx offload display Jie Hai
2023-06-07  7:42   ` [PATCH v2 06/13] ethdev: support telemetry query flow ctrl info Jie Hai
2023-06-07  7:42   ` [PATCH v2 07/13] ethdev: support telemetry query Rx queue info Jie Hai
2023-06-07  7:42   ` [PATCH v2 08/13] ethdev: support telemetry query Tx " Jie Hai
2023-06-07  7:42   ` [PATCH v2 09/13] ethdev: add firmware version in telemetry info command Jie Hai
2023-06-07  7:42   ` [PATCH v2 10/13] ethdev: support telemetry query DCB info Jie Hai
2023-06-07  7:42   ` [PATCH v2 11/13] ethdev: support telemetry query RSS info Jie Hai
2023-06-07 14:08     ` Ferruh Yigit
2023-06-07  7:42   ` [PATCH v2 12/13] ethdev: support telemetry query FEC info Jie Hai
2023-06-07  7:42   ` [PATCH v2 13/13] ethdev: support telemetry query VLAN info Jie Hai
2023-06-07 11:40   ` [PATCH v2 00/13] support telemetry query ethdev info Ferruh Yigit
2023-06-08  2:01     ` Jie Hai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9a7832fe-df4f-caf7-c227-1cecea15da7e@amd.com \
    --to=ferruh.yigit@amd.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=haijie1@huawei.com \
    --cc=liudongdong3@huawei.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).