* [PATCH iproute2-next 0/4] devlink: Remove custom string conversions
@ 2022-02-17 2:57 David Ahern
2022-02-17 2:57 ` [PATCH iproute2-next 1/4] devlink: Remove strtouint64_t in favor of get_u64 David Ahern
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: David Ahern @ 2022-02-17 2:57 UTC (permalink / raw)
To: netdev; +Cc: stephen, parav, jiri, David Ahern
Remove strtouint${N}_t variants in favor of the library functions get_u${N}
David Ahern (4):
devlink: Remove strtouint64_t in favor of get_u64
devlink: Remove strtouint32_t in favor of get_u32
devlink: Remove strtouint16_t in favor of get_u16
devlink: Remove strtouint8_t in favor of get_u8
devlink/devlink.c | 92 ++++++++++-------------------------------------
1 file changed, 18 insertions(+), 74 deletions(-)
--
2.24.3 (Apple Git-128)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH iproute2-next 1/4] devlink: Remove strtouint64_t in favor of get_u64
2022-02-17 2:57 [PATCH iproute2-next 0/4] devlink: Remove custom string conversions David Ahern
@ 2022-02-17 2:57 ` David Ahern
2022-02-17 2:57 ` [PATCH iproute2-next 2/4] devlink: Remove strtouint32_t in favor of get_u32 David Ahern
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: David Ahern @ 2022-02-17 2:57 UTC (permalink / raw)
To: netdev; +Cc: stephen, parav, jiri, David Ahern
strtouint64_t duplicates get_u64; remove it.
Signed-off-by: David Ahern <dsahern@kernel.org>
---
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;
--
2.24.3 (Apple Git-128)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH iproute2-next 2/4] devlink: Remove strtouint32_t in favor of get_u32
2022-02-17 2:57 [PATCH iproute2-next 0/4] devlink: Remove custom string conversions David Ahern
2022-02-17 2:57 ` [PATCH iproute2-next 1/4] devlink: Remove strtouint64_t in favor of get_u64 David Ahern
@ 2022-02-17 2:57 ` David Ahern
2022-02-17 2:57 ` [PATCH iproute2-next 3/4] devlink: Remove strtouint16_t in favor of get_u16 David Ahern
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: David Ahern @ 2022-02-17 2:57 UTC (permalink / raw)
To: netdev; +Cc: stephen, parav, jiri, David Ahern
strtouint32_t duplicates get_u32; remove it.
Signed-off-by: David Ahern <dsahern@kernel.org>
---
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)
--
2.24.3 (Apple Git-128)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH iproute2-next 3/4] devlink: Remove strtouint16_t in favor of get_u16
2022-02-17 2:57 [PATCH iproute2-next 0/4] devlink: Remove custom string conversions David Ahern
2022-02-17 2:57 ` [PATCH iproute2-next 1/4] devlink: Remove strtouint64_t in favor of get_u64 David Ahern
2022-02-17 2:57 ` [PATCH iproute2-next 2/4] devlink: Remove strtouint32_t in favor of get_u32 David Ahern
@ 2022-02-17 2:57 ` David Ahern
2022-02-17 2:57 ` [PATCH iproute2-next 4/4] devlink: Remove strtouint8_t in favor of get_u8 David Ahern
2022-02-21 16:40 ` [PATCH iproute2-next 0/4] devlink: Remove custom string conversions patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: David Ahern @ 2022-02-17 2:57 UTC (permalink / raw)
To: netdev; +Cc: stephen, parav, jiri, David Ahern
strtouint16_t duplicates get_u16; remove it.
Signed-off-by: David Ahern <dsahern@kernel.org>
---
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;
--
2.24.3 (Apple Git-128)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH iproute2-next 4/4] devlink: Remove strtouint8_t in favor of get_u8
2022-02-17 2:57 [PATCH iproute2-next 0/4] devlink: Remove custom string conversions David Ahern
` (2 preceding siblings ...)
2022-02-17 2:57 ` [PATCH iproute2-next 3/4] devlink: Remove strtouint16_t in favor of get_u16 David Ahern
@ 2022-02-17 2:57 ` David Ahern
2022-02-21 16:40 ` [PATCH iproute2-next 0/4] devlink: Remove custom string conversions patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: David Ahern @ 2022-02-17 2:57 UTC (permalink / raw)
To: netdev; +Cc: stephen, parav, jiri, David Ahern
strtouint8_t duplicates get_u8; remove it.
Signed-off-by: David Ahern <dsahern@kernel.org>
---
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;
--
2.24.3 (Apple Git-128)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH iproute2-next 0/4] devlink: Remove custom string conversions
2022-02-17 2:57 [PATCH iproute2-next 0/4] devlink: Remove custom string conversions David Ahern
` (3 preceding siblings ...)
2022-02-17 2:57 ` [PATCH iproute2-next 4/4] devlink: Remove strtouint8_t in favor of get_u8 David Ahern
@ 2022-02-21 16:40 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-21 16:40 UTC (permalink / raw)
To: David Ahern; +Cc: netdev, stephen, parav, jiri
Hello:
This series was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:
On Wed, 16 Feb 2022 19:57:07 -0700 you wrote:
> Remove strtouint${N}_t variants in favor of the library functions get_u${N}
>
> David Ahern (4):
> devlink: Remove strtouint64_t in favor of get_u64
> devlink: Remove strtouint32_t in favor of get_u32
> devlink: Remove strtouint16_t in favor of get_u16
> devlink: Remove strtouint8_t in favor of get_u8
>
> [...]
Here is the summary with links:
- [iproute2-next,1/4] devlink: Remove strtouint64_t in favor of get_u64
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=7cb0e24dcfaa
- [iproute2-next,2/4] devlink: Remove strtouint32_t in favor of get_u32
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=95c03f405183
- [iproute2-next,3/4] devlink: Remove strtouint16_t in favor of get_u16
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=2688abf0c98d
- [iproute2-next,4/4] devlink: Remove strtouint8_t in favor of get_u8
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=e8fd4d4b8448
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-02-21 16:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-17 2:57 [PATCH iproute2-next 0/4] devlink: Remove custom string conversions David Ahern
2022-02-17 2:57 ` [PATCH iproute2-next 1/4] devlink: Remove strtouint64_t in favor of get_u64 David Ahern
2022-02-17 2:57 ` [PATCH iproute2-next 2/4] devlink: Remove strtouint32_t in favor of get_u32 David Ahern
2022-02-17 2:57 ` [PATCH iproute2-next 3/4] devlink: Remove strtouint16_t in favor of get_u16 David Ahern
2022-02-17 2:57 ` [PATCH iproute2-next 4/4] devlink: Remove strtouint8_t in favor of get_u8 David Ahern
2022-02-21 16:40 ` [PATCH iproute2-next 0/4] devlink: Remove custom string conversions patchwork-bot+netdevbpf
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).