]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Remove very little used wrapper conv_str_u64()
authorVolker Lendecke <vl@samba.org>
Sun, 25 Jan 2026 09:28:45 +0000 (10:28 +0100)
committerAnoop C S <anoopcs@samba.org>
Sun, 15 Feb 2026 10:42:33 +0000 (10:42 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
lib/tsocket/tsocket_bsd.c
lib/util/samba_util.h
lib/util/util_str.c
source3/modules/vfs_fruit.c
source3/rpcclient/cmd_spotlight.c
source4/client/cifsdd.c

index aab30f12cb54bbfa96d132372e11e85c79f1078f..4c7684675e88a9dc46d00d9367a4ae493886766f 100644 (file)
@@ -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;
                }
index 03dee5c61379d3c5980346d236b6b16e19645919..d67200ba70504003d7494f4742b08f8cef7000e3 100644 (file)
@@ -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.
  *
index 19acff4a983ab8a120a4cc2f8a6c4e39bc186f73..3faf204d251a4fdf08e8a2c1a3e7972bc0fb364b 100644 (file)
@@ -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.
  *
index 3820833f0d92b118bdb805ee15a00da07a11590c..c8af698e483c3bad2b4e6601968cfb577471f6ca 100644 (file)
@@ -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);
 }
 
 /*
index df837f78f455b806e19d95bd88d5f3e2b0b97f90..e505adad3451eebee1756542b946ad25dc3ea934 100644 (file)
@@ -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;
        }
index 7bbc49df62bd5efea63839baee1691722392af1c..d6731c0ae2b67c13c60a77b8146062838ffb91e1 100644 (file)
@@ -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;