devlink: Remove custom string conversions
Subsystems (2)
cover devlink: Remove custom string conversions
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(-)
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH 2/4 devlink: Remove strtouint32_t in favor of get_u32
strtouint32_t duplicates get_u32; remove it.
--- devlink/devlink.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-)
devlink/devlink.c +5 -19
@@ -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)
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH 3/4 devlink: Remove strtouint16_t in favor of get_u16
In reply to David Ahernstrtouint16_t duplicates get_u16; remove it.
--- devlink/devlink.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
devlink/devlink.c +3 -17
@@ -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;
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH 4/4 devlink: Remove strtouint8_t in favor of get_u8
In reply to David Ahernstrtouint8_t duplicates get_u8; remove it.
--- devlink/devlink.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
devlink/devlink.c +2 -16
@@ -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;
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH 1/4 devlink: Remove strtouint64_t in favor of get_u64
In reply to David Ahernstrtouint64_t duplicates get_u64; remove it.
--- devlink/devlink.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-)
devlink/devlink.c +8 -22
@@ -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;
Signature · 1 line
2.24.3 (Apple Git-128)
This series was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:
Hello:
This series was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:
Quoted 9 lines · 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: Removestrtouint64_tin favor ofget_u64
devlink: Removestrtouint32_tin favor ofget_u32
devlink: Removestrtouint16_tin favor ofget_u16
devlink: Removestrtouint8_tin favor ofget_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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html