From: Volker Lendecke Date: Mon, 26 Jan 2026 09:43:44 +0000 (+0100) Subject: lib: Simplify conv_str_size X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0db47765a467ba8887bd34e40bffbc0d4b934df4;p=thirdparty%2Fsamba.git lib: Simplify conv_str_size conv_str_size_error() from lib/util has almost the same code Signed-off-by: Volker Lendecke Reviewed-by: Anoop C S --- diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 68be9a0ec09..3a2964890b8 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -393,38 +393,10 @@ int fstr_sprintf(fstring s, const char *fmt, ...) uint64_t conv_str_size(const char * str) { uint64_t lval; - char *end; - int error = 0; + bool ok; - if (str == NULL || *str == '\0') { - return 0; - } - - lval = smb_strtoull(str, &end, 10, &error, SMB_STR_STANDARD); - - if (error != 0) { - return 0; - } - - if (*end == '\0') { - return lval; - } - - if (strwicmp(end, "K") == 0) { - lval *= 1024ULL; - } else if (strwicmp(end, "M") == 0) { - lval *= (1024ULL * 1024ULL); - } else if (strwicmp(end, "G") == 0) { - lval *= (1024ULL * 1024ULL * - 1024ULL); - } else if (strwicmp(end, "T") == 0) { - lval *= (1024ULL * 1024ULL * - 1024ULL * 1024ULL); - } else if (strwicmp(end, "P") == 0) { - lval *= (1024ULL * 1024ULL * - 1024ULL * 1024ULL * - 1024ULL); - } else { + ok = conv_str_size_error(str, &lval); + if (!ok) { return 0; }