From 1ffbbdb138e86ec49034d1590d2c8b1459907409 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 25 Jan 2026 10:28:45 +0100 Subject: [PATCH] lib: Remove very little used wrapper conv_str_u64() Signed-off-by: Volker Lendecke Reviewed-by: Anoop C S --- lib/tsocket/tsocket_bsd.c | 13 ++++++++----- lib/util/samba_util.h | 9 --------- lib/util/util_str.c | 25 ------------------------- source3/modules/vfs_fruit.c | 16 ++++++++-------- source3/rpcclient/cmd_spotlight.c | 6 ++++-- source4/client/cifsdd.c | 15 ++++++++++----- 6 files changed, 30 insertions(+), 54 deletions(-) diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c index aab30f12cb5..4c7684675e8 100644 --- a/lib/tsocket/tsocket_bsd.c +++ b/lib/tsocket/tsocket_bsd.c @@ -31,6 +31,7 @@ #include "lib/util/util_net.h" #include "lib/util/samba_util.h" #include "lib/async_req/async_sock.h" +#include "lib/util/smb_strtox.h" static int tsocket_bsd_error_from_errno(int ret, int sys_errno, @@ -443,7 +444,7 @@ int _tsocket_address_inet_from_hostport_strings(TALLOC_CTX *mem_ctx, int ret; char *s_addr = NULL; uint16_t s_port = default_port; - bool conv_ret; + int error = 0; bool is_ipv6_by_squares = false; if (host_port_addr == NULL) { @@ -480,8 +481,9 @@ int _tsocket_address_inet_from_hostport_strings(TALLOC_CTX *mem_ctx, return -1; } cport = port_sep + 1; - conv_ret = conv_str_u64(cport, &port); - if (!conv_ret) { + port = smb_strtoull( + cport, NULL, 10, &error, SMB_STR_FULL_STR_CONV); + if (error != 0) { errno = EINVAL; return -1; } @@ -498,8 +500,9 @@ int _tsocket_address_inet_from_hostport_strings(TALLOC_CTX *mem_ctx, } else if (pl_period != NULL && port_sep != NULL) { /* IPv4 with port - more than one period in string */ cport = port_sep + 1; - conv_ret = conv_str_u64(cport, &port); - if (!conv_ret) { + port = smb_strtoull( + cport, NULL, 10, &error, SMB_STR_FULL_STR_CONV); + if (error != 0) { errno = EINVAL; return -1; } diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index 03dee5c6137..d67200ba705 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -308,15 +308,6 @@ _PUBLIC_ bool conv_str_bool(const char * str, bool * val); **/ _PUBLIC_ bool conv_str_size_error(const char * str, uint64_t * val); -/** - * Parse a uint64_t value from a string - * - * val will be set to the value read. - * - * @retval true if parsing was successful, false otherwise - */ -_PUBLIC_ bool conv_str_u64(const char * str, uint64_t * val); - /** * @brief Constant time compare to memory regions. * diff --git a/lib/util/util_str.c b/lib/util/util_str.c index 19acff4a983..3faf204d251 100644 --- a/lib/util/util_str.c +++ b/lib/util/util_str.c @@ -96,31 +96,6 @@ _PUBLIC_ bool conv_str_size_error(const char * str, uint64_t * val) return true; } -/** - * Parse a uint64_t value from a string - * - * val will be set to the value read. - * - * @retval true if parsing was successful, false otherwise - */ -_PUBLIC_ bool conv_str_u64(const char * str, uint64_t * val) -{ - unsigned long long lval; - int error = 0; - - if (str == NULL || *str == '\0') { - return false; - } - - lval = smb_strtoull(str, NULL, 10, &error, SMB_STR_FULL_STR_CONV); - if (error != 0) { - return false; - } - - *val = (uint64_t)lval; - return true; -} - /** * Compare 2 strings. * diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 3820833f0d9..c8af698e483 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -37,6 +37,7 @@ #include "lib/adouble.h" #include "lib/util_macstreams.h" #include "source3/smbd/dir.h" +#include "lib/util/smb_strtox.h" /* * Enhanced OS X and Netatalk compatibility @@ -5095,9 +5096,8 @@ static bool fruit_get_bandsize_from_line(char *line, size_t *_band_size) static regex_t re; static bool re_initialized = false; regmatch_t matches[2]; - uint64_t band_size; int ret; - bool ok; + int error = 0; if (!re_initialized) { ret = regcomp(&re, @@ -5118,12 +5118,12 @@ static bool fruit_get_bandsize_from_line(char *line, size_t *_band_size) line[matches[1].rm_eo] = '\0'; - ok = conv_str_u64(&line[matches[1].rm_so], &band_size); - if (!ok) { - return false; - } - *_band_size = (size_t)band_size; - return true; + *_band_size = smb_strtoull(&line[matches[1].rm_so], + NULL, + 10, + &error, + SMB_STR_FULL_STR_CONV); + return (error == 0); } /* diff --git a/source3/rpcclient/cmd_spotlight.c b/source3/rpcclient/cmd_spotlight.c index df837f78f45..e505adad345 100644 --- a/source3/rpcclient/cmd_spotlight.c +++ b/source3/rpcclient/cmd_spotlight.c @@ -24,6 +24,7 @@ #include "../rpc_server/mdssvc/mdssvc.h" #include "../rpc_server/mdssvc/dalloc.h" #include "../rpc_server/mdssvc/marshalling.h" +#include "lib/util/smb_strtox.h" static NTSTATUS cmd_mdssvc_fetch_properties( struct rpc_pipe_client *cli, @@ -202,6 +203,7 @@ static NTSTATUS cmd_mdssvc_fetch_attributes( uint64_t cnid; uint32_t unkn4; int result; + int error = 0; bool ok; if (argc != 4) { @@ -209,8 +211,8 @@ static NTSTATUS cmd_mdssvc_fetch_attributes( return NT_STATUS_OK; } - ok = conv_str_u64(argv[3], &cnid); - if (!ok) { + cnid = smb_strtoull(argv[3], NULL, 10, &error, SMB_STR_FULL_STR_CONV); + if (error != 0) { printf("Failed to parse: %s\n", argv[3]); return NT_STATUS_INVALID_PARAMETER; } diff --git a/source4/client/cifsdd.c b/source4/client/cifsdd.c index 7bbc49df62b..d6731c0ae2b 100644 --- a/source4/client/cifsdd.c +++ b/source4/client/cifsdd.c @@ -25,6 +25,7 @@ #include "libcli/resolve/resolve.h" #include "libcli/raw/libcliraw.h" #include "lib/events/events.h" +#include "lib/util/smb_strtox.h" #include "cifsdd.h" #include "param/param.h" @@ -190,11 +191,15 @@ int set_arg_argv(const char * argv) /* Found a matching name; convert the variable argument. */ switch (arg->arg_type) { - case ARG_NUMERIC: - if (!conv_str_u64(val, &arg->arg_val.nval)) { - goto fail; - } - break; + case ARG_NUMERIC: { + int error = 0; + arg->arg_val.nval = smb_strtoull( + val, NULL, 10, &error, SMB_STR_FULL_STR_CONV); + if (error != 0) { + goto fail; + } + break; + } case ARG_SIZE: if (!conv_str_size_error(val, &arg->arg_val.nval)) { goto fail; -- 2.47.3