From patchwork Thu Feb 17 02:57:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 12749246 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3A12C433FE for ; Thu, 17 Feb 2022 02:57:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232042AbiBQC5j (ORCPT ); Wed, 16 Feb 2022 21:57:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232019AbiBQC5d (ORCPT ); Wed, 16 Feb 2022 21:57:33 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EBC3B151D for ; Wed, 16 Feb 2022 18:57:19 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CDED5B81ABE for ; Thu, 17 Feb 2022 02:57:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D27EFC36AE2; Thu, 17 Feb 2022 02:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645066636; bh=JlUxpAgdOJZl1cuOLmBLR3293NpUWW6uq3b6l7s5S0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tR08zR/2hOJbrCXKHC4/hAxWcX/goPCsKoqRy9iKZWJMwiRdAZ/DEG47XcbYwsdfd cPfp2sCheWbej9HVEdVlyxVpZJa6g9mI066nS5sO90eCglAZeH5NQD/8gaWDYD1c43 nt9zQi327XxOqhkCrkLnLL+5LCVoiRLCJQ4lpPj2w8wKCqbkhmhVLr0kzGGybYnby1 n2a6nHkP4x1pp88pSvHffnY5qN+vCuuO+Yo/A/SckOk+7fHQvF0Peo/Xs797TTD1uZ rYCqyE/bxS6D36whHzrsebBSqyrhMf8ouaYQ2zVvQx2VxGzw1E4O/u5/cGH+TtDxmI pHzMPemW8bczw== From: David Ahern To: netdev@vger.kernel.org Cc: stephen@networkplumber.org, parav@nvidia.com, jiri@nvidia.com, David Ahern Subject: [PATCH iproute2-next 1/4] devlink: Remove strtouint64_t in favor of get_u64 Date: Wed, 16 Feb 2022 19:57:08 -0700 Message-Id: <20220217025711.9369-2-dsahern@kernel.org> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20220217025711.9369-1-dsahern@kernel.org> References: <20220217025711.9369-1-dsahern@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com strtouint64_t duplicates get_u64; remove it. Signed-off-by: David Ahern --- devlink/devlink.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index d39792ec9212..4e2dc6e09682 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -315,7 +315,7 @@ struct dl_opts { bool dpipe_counters_enabled; enum devlink_eswitch_encap_mode eswitch_encap_mode; const char *resource_path; - uint64_t resource_size; + __u64 resource_size; uint32_t resource_id; bool resource_id_valid; const char *param_name; @@ -323,12 +323,12 @@ struct dl_opts { enum devlink_param_cmode cmode; char *region_name; uint32_t region_snapshot_id; - uint64_t region_address; - uint64_t region_length; + __u64 region_address; + __u64 region_length; const char *flash_file_name; const char *flash_component; const char *reporter_name; - uint64_t reporter_graceful_period; + __u64 reporter_graceful_period; bool reporter_auto_recover; bool reporter_auto_dump; const char *trap_name; @@ -337,8 +337,8 @@ struct dl_opts { bool netns_is_pid; uint32_t netns; uint32_t trap_policer_id; - uint64_t trap_policer_rate; - uint64_t trap_policer_burst; + __u64 trap_policer_rate; + __u64 trap_policer_burst; char port_function_hw_addr[MAX_ADDR_LEN]; uint32_t port_function_hw_addr_len; uint32_t overwrite_mask; @@ -857,20 +857,6 @@ static int ifname_map_rev_lookup(struct dl *dl, const char *bus_name, return -ENOENT; } -static int strtouint64_t(const char *str, uint64_t *p_val) -{ - char *endptr; - unsigned long long int val; - - val = strtoull(str, &endptr, 10); - if (endptr == str || *endptr != '\0') - return -EINVAL; - if (val > ULONG_MAX) - return -ERANGE; - *p_val = val; - return 0; -} - static int strtouint32_t(const char *str, uint32_t *p_val) { char *endptr; @@ -1173,7 +1159,7 @@ static int dl_argv_handle_rate(struct dl *dl, char **p_bus_name, return 0; } -static int dl_argv_uint64_t(struct dl *dl, uint64_t *p_val) +static int dl_argv_uint64_t(struct dl *dl, __u64 *p_val) { char *str = dl_argv_next(dl); int err; @@ -1183,7 +1169,7 @@ static int dl_argv_uint64_t(struct dl *dl, uint64_t *p_val) return -EINVAL; } - err = strtouint64_t(str, p_val); + err = get_u64(p_val, str, 10); if (err) { pr_err("\"%s\" is not a number or not within range\n", str); return err; From patchwork Thu Feb 17 02:57:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 12749243 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17EBEC433F5 for ; Thu, 17 Feb 2022 02:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232030AbiBQC5g (ORCPT ); Wed, 16 Feb 2022 21:57:36 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232020AbiBQC5d (ORCPT ); Wed, 16 Feb 2022 21:57:33 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1080B12F3 for ; Wed, 16 Feb 2022 18:57:19 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 79682B820E3 for ; Thu, 17 Feb 2022 02:57:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A8FDC340F1; Thu, 17 Feb 2022 02:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645066637; bh=RwMlQ/J0b+vyDvDGMxa12nHz7CmdiN5sSmM0Lhfrd8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FaJAhWJkMyTZBjQbl50jNvxFxY7mpgZ56oKKhe0pGXSgF87xXDNmqEll0NT2B6DSp mt1qRtDZCFlz17cP9vw/CIfhKE5uK6FMdYRZ0feV8BF5UakJzEHfDXPKIkYBSlZsjl NoOZb+9A54DgJlxwgT5bFw4bDH6cctrPLXOTjbrwZgwFUIJxyBr3ZzwNAowJmzVNHm CSWfWJo++P45wHB7jKUJ7DSQPMz4On+6V1xkpEB5OZ/smsASM9gmY1F8GOdnnGnFkx y+tUx2is4LEB9m1LIWwAUgrYcyXVGgRILaQ5Dnor8MSDBII4G7wfqOfycG0W5a2iev vV3M3UMjPNHug== From: David Ahern To: netdev@vger.kernel.org Cc: stephen@networkplumber.org, parav@nvidia.com, jiri@nvidia.com, David Ahern Subject: [PATCH iproute2-next 2/4] devlink: Remove strtouint32_t in favor of get_u32 Date: Wed, 16 Feb 2022 19:57:09 -0700 Message-Id: <20220217025711.9369-3-dsahern@kernel.org> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20220217025711.9369-1-dsahern@kernel.org> References: <20220217025711.9369-1-dsahern@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com strtouint32_t duplicates get_u32; remove it. Signed-off-by: David Ahern --- devlink/devlink.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index 4e2dc6e09682..4a5f7f7a0ba1 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -857,20 +857,6 @@ static int ifname_map_rev_lookup(struct dl *dl, const char *bus_name, return -ENOENT; } -static int strtouint32_t(const char *str, uint32_t *p_val) -{ - char *endptr; - unsigned long int val; - - val = strtoul(str, &endptr, 10); - if (endptr == str || *endptr != '\0') - return -EINVAL; - if (val > UINT_MAX) - return -ERANGE; - *p_val = val; - return 0; -} - static int strtouint16_t(const char *str, uint16_t *p_val) { char *endptr; @@ -966,7 +952,7 @@ static int __dl_argv_handle_port(char *str, pr_err("Port identification \"%s\" is invalid\n", str); return err; } - err = strtouint32_t(portstr, p_port_index); + err = get_u32(p_port_index, portstr, 10); if (err) { pr_err("Port index \"%s\" is not a number or not within range\n", portstr); @@ -1145,7 +1131,7 @@ static int dl_argv_handle_rate(struct dl *dl, char **p_bus_name, } if (strspn(identifier, "0123456789") == strlen(identifier)) { - err = strtouint32_t(identifier, p_port_index); + err = get_u32(p_port_index, identifier, 10); if (err) { pr_err("Port index \"%s\" is not a number" " or not within range\n", identifier); @@ -1187,7 +1173,7 @@ static int dl_argv_uint32_t(struct dl *dl, uint32_t *p_val) return -EINVAL; } - err = strtouint32_t(str, p_val); + err = get_u32(p_val, str, 10); if (err) { pr_err("\"%s\" is not a number or not within range\n", str); return err; @@ -3184,7 +3170,7 @@ static int cmd_dev_param_set(struct dl *dl) dl->opts.param_value, &val_u32); else - err = strtouint32_t(dl->opts.param_value, &val_u32); + err = get_u32(&val_u32, dl->opts.param_value, 10); if (err) goto err_param_value_parse; if (val_u32 == ctx.value.vu32) @@ -4446,7 +4432,7 @@ static int cmd_port_param_set(struct dl *dl) dl->opts.param_value, &val_u32); else - err = strtouint32_t(dl->opts.param_value, &val_u32); + err = get_u32(&val_u32, dl->opts.param_value, 10); if (err) goto err_param_value_parse; if (val_u32 == ctx.value.vu32) From patchwork Thu Feb 17 02:57:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 12749244 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7341C433FE for ; Thu, 17 Feb 2022 02:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232041AbiBQC5h (ORCPT ); Wed, 16 Feb 2022 21:57:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232021AbiBQC5e (ORCPT ); Wed, 16 Feb 2022 21:57:34 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97646C117F for ; Wed, 16 Feb 2022 18:57:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4BADEB820E0 for ; Thu, 17 Feb 2022 02:57:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65219C004E1; Thu, 17 Feb 2022 02:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645066637; bh=iRiOHhzwXc0EhNJb+xtIR9zAisrJqxV2/ZbTsgZRrQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NbZSlx88GCCjJHafW6QzFob3ChER+bk6CRcReI0K50Hh5WxYwSf2PqTdnZy+BhFgF OMW92qYhj6W0EHvpgvh374PdQ6VvvBeqDx02iZOTxsVeVzRG5p5VuZ8c6s27V0ZYOK joEWeG8SESgR3oLTm5X6acdhcIoDSoaHuyE0fBZUvgTV/HBCh9iDksmSBudOuIz5Zg LN0t5U1a8fJ5TU7TvCzNB4ehldXiea3cNkrIckaJnVpfOluGM/yF5DpNvRH3Er3bQ9 yliZmxrUdV41m3YqrDDqGtPxqAqmbwzTw86QI4IXZj1RtKhG5dmqDv1wRe1/ol5Huo 6i8ncWYl0ycyA== From: David Ahern To: netdev@vger.kernel.org Cc: stephen@networkplumber.org, parav@nvidia.com, jiri@nvidia.com, David Ahern Subject: [PATCH iproute2-next 3/4] devlink: Remove strtouint16_t in favor of get_u16 Date: Wed, 16 Feb 2022 19:57:10 -0700 Message-Id: <20220217025711.9369-4-dsahern@kernel.org> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20220217025711.9369-1-dsahern@kernel.org> References: <20220217025711.9369-1-dsahern@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com strtouint16_t duplicates get_u16; remove it. Signed-off-by: David Ahern --- devlink/devlink.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index 4a5f7f7a0ba1..54570df94b7f 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -857,20 +857,6 @@ static int ifname_map_rev_lookup(struct dl *dl, const char *bus_name, return -ENOENT; } -static int strtouint16_t(const char *str, uint16_t *p_val) -{ - char *endptr; - unsigned long int val; - - val = strtoul(str, &endptr, 10); - if (endptr == str || *endptr != '\0') - return -EINVAL; - if (val > USHRT_MAX) - return -ERANGE; - *p_val = val; - return 0; -} - static int strtouint8_t(const char *str, uint8_t *p_val) { char *endptr; @@ -1191,7 +1177,7 @@ static int dl_argv_uint16_t(struct dl *dl, uint16_t *p_val) return -EINVAL; } - err = strtouint16_t(str, p_val); + err = get_u16(p_val, str, 10); if (err) { pr_err("\"%s\" is not a number or not within range\n", str); return err; @@ -3154,7 +3140,7 @@ static int cmd_dev_param_set(struct dl *dl) &val_u32); val_u16 = val_u32; } else { - err = strtouint16_t(dl->opts.param_value, &val_u16); + err = get_u16(&val_u16, dl->opts.param_value, 10); } if (err) goto err_param_value_parse; @@ -4416,7 +4402,7 @@ static int cmd_port_param_set(struct dl *dl) &val_u32); val_u16 = val_u32; } else { - err = strtouint16_t(dl->opts.param_value, &val_u16); + err = get_u16(&val_u16, dl->opts.param_value, 10); } if (err) goto err_param_value_parse; From patchwork Thu Feb 17 02:57:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 12749245 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D43BDC433EF for ; Thu, 17 Feb 2022 02:57:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232021AbiBQC5i (ORCPT ); Wed, 16 Feb 2022 21:57:38 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232026AbiBQC5e (ORCPT ); Wed, 16 Feb 2022 21:57:34 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58A1FB9D68 for ; Wed, 16 Feb 2022 18:57:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 09FA0B820E6 for ; Thu, 17 Feb 2022 02:57:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BDEEC340F3; Thu, 17 Feb 2022 02:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645066638; bh=jVTBPp8RsDkgQk4Wvqdo2x4dBO0Qj+o9lqNfff+Q60k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d8jNpgf/7MrOMqA2qfAocUHBOlOnj/Q5ZPc9bFKBpz/0OsVXWENw49toqHgcNh5vZ UfcJL2WT3QzTIgbNNGl1FlGY7+O+L6ZOmOxI6bdjAjvY+zPEG62bPmO3k/mMzjKn76 rlj7FC8YharfH/Fj5y9He3/GUR+L9BnqVQXYFmtXuhRAl0Ef8HSaI9IQOnnbUMn2GG ytXCzEhtMsEQwxBne2bnNslDKvniVD4Yw3oiJ4exWmFnrhPrKJ82kzlcGeWcElxhGP usrAGIFtuqiphhCp2L+rwG9pZPKHEnThlisl3uVbx/z3HYLrt2XBniGyoj3hSrDcDw IhJSn4z4+OgTw== From: David Ahern To: netdev@vger.kernel.org Cc: stephen@networkplumber.org, parav@nvidia.com, jiri@nvidia.com, David Ahern Subject: [PATCH iproute2-next 4/4] devlink: Remove strtouint8_t in favor of get_u8 Date: Wed, 16 Feb 2022 19:57:11 -0700 Message-Id: <20220217025711.9369-5-dsahern@kernel.org> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20220217025711.9369-1-dsahern@kernel.org> References: <20220217025711.9369-1-dsahern@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com strtouint8_t duplicates get_u8; remove it. Signed-off-by: David Ahern --- devlink/devlink.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index 54570df94b7f..da9f97788bcf 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -857,20 +857,6 @@ static int ifname_map_rev_lookup(struct dl *dl, const char *bus_name, return -ENOENT; } -static int strtouint8_t(const char *str, uint8_t *p_val) -{ - char *endptr; - unsigned long int val; - - val = strtoul(str, &endptr, 10); - if (endptr == str || *endptr != '\0') - return -EINVAL; - if (val > UCHAR_MAX) - return -ERANGE; - *p_val = val; - return 0; -} - static int strtobool(const char *str, bool *p_val) { bool val; @@ -3123,7 +3109,7 @@ static int cmd_dev_param_set(struct dl *dl) &val_u32); val_u8 = val_u32; } else { - err = strtouint8_t(dl->opts.param_value, &val_u8); + err = get_u8(&val_u8, dl->opts.param_value, 10); } if (err) goto err_param_value_parse; @@ -4385,7 +4371,7 @@ static int cmd_port_param_set(struct dl *dl) &val_u32); val_u8 = val_u32; } else { - err = strtouint8_t(dl->opts.param_value, &val_u8); + err = get_u8(&val_u8, dl->opts.param_value, 10); } if (err) goto err_param_value_parse;