From: Ralph Boehme Date: Fri, 28 Nov 2025 09:57:23 +0000 (+0100) Subject: libcli/smb: move smb2_util_lease_state() to libcli/smb/util.c X-Git-Tag: talloc-2.5.0~210 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4155b3059b0ce41c57f8aa3bc0992597ca99c99e;p=thirdparty%2Fsamba.git libcli/smb: move smb2_util_lease_state() to libcli/smb/util.c While at it, get rid of the strlen(), we don't need it. Signed-off-by: Ralph Boehme Reviewed-by: Anoop C S --- diff --git a/libcli/smb/smb_util.h b/libcli/smb/smb_util.h index c3533a2d2e1..dcbb92f3e07 100644 --- a/libcli/smb/smb_util.h +++ b/libcli/smb/smb_util.h @@ -78,4 +78,6 @@ struct smb_transports { struct smb_transports smb_transports_parse(const char *param_name, const char * const *transports); +uint32_t smb2_util_lease_state(const char *ls); + #endif /* _SMB_UTIL_H */ diff --git a/libcli/smb/util.c b/libcli/smb/util.c index e92acccf47a..909fdd27b16 100644 --- a/libcli/smb/util.c +++ b/libcli/smb/util.c @@ -783,3 +783,25 @@ struct smb_transports smb_transports_parse(const char *param_name, return ts; } + +uint32_t smb2_util_lease_state(const char *ls) +{ + uint32_t val = 0; + int i; + + for (i = 0; ls[i] != '\0'; i++) { + switch (ls[i]) { + case 'R': + val |= SMB2_LEASE_READ; + break; + case 'H': + val |= SMB2_LEASE_HANDLE; + break; + case 'W': + val |= SMB2_LEASE_WRITE; + break; + } + } + + return val; +} diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 22b11e425b6..7c8b839433c 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -801,29 +801,6 @@ bool smb2_util_verify_attrib(TALLOC_CTX *tctx, struct smb2_tree *tree, return ret; } - -uint32_t smb2_util_lease_state(const char *ls) -{ - uint32_t val = 0; - int i; - - for (i = 0; i < strlen(ls); i++) { - switch (ls[i]) { - case 'R': - val |= SMB2_LEASE_READ; - break; - case 'H': - val |= SMB2_LEASE_HANDLE; - break; - case 'W': - val |= SMB2_LEASE_WRITE; - break; - } - } - - return val; -} - char *smb2_util_lease_state_string(TALLOC_CTX *mem_ctx, uint32_t ls) { return talloc_asprintf(mem_ctx, "0x%0x (%s%s%s)",