[linux-cifs-client] [PATCH 5/7] [CIFS] cleanup code by moving often
repeated code sequence into a separate function - part2
Jeff Layton
jlayton at redhat.com
Fri Jul 25 15:23:18 GMT 2008
From: Günter Kukkukk <linux at kukkukk.com>
move the code sequences which use
- cifs_strtoUCS()
to the new function
- setup_ucs_nls_name()
passing the "remap" parameter as "0" (false).
Signed-off-by: Günter Kukkukk <linux at kukkukk.com>
---
fs/cifs/cifssmb.c | 47 +++++++++--------------------------------------
1 files changed, 9 insertions(+), 38 deletions(-)
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 12be35f..5971549 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -2162,20 +2162,9 @@ createSymLinkRetry:
(void **) &pSMBr);
if (rc)
return rc;
-
- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
- name_len =
- cifs_strtoUCS((__le16 *) pSMB->FileName, fromName, PATH_MAX
- /* find define for this maxpathcomponent */
- , nls_codepage);
- name_len++; /* trailing null */
- name_len *= 2;
-
- } else { /* BB improve the check for buffer overruns BB */
- name_len = strnlen(fromName, PATH_MAX);
- name_len++; /* trailing null */
- strncpy(pSMB->FileName, fromName, name_len);
- }
+ /* pass remap = 0 */
+ name_len = setup_ucs_nls_name(pSMB->hdr.Flags2, pSMB->FileName,
+ fromName, nls_codepage, 0);
params = 6 + name_len;
pSMB->MaxSetupCount = 0;
pSMB->Reserved = 0;
@@ -2187,19 +2176,10 @@ createSymLinkRetry:
offset = param_offset + params;
data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
- name_len_target =
- cifs_strtoUCS((__le16 *) data_offset, toName, PATH_MAX
- /* find define for this maxpathcomponent */
- , nls_codepage);
- name_len_target++; /* trailing null */
- name_len_target *= 2;
- } else { /* BB improve the check for buffer overruns BB */
- name_len_target = strnlen(toName, PATH_MAX);
- name_len_target++; /* trailing null */
- strncpy(data_offset, toName, name_len_target);
- }
+ /* pass remap = 0 */
+ name_len_target = setup_ucs_nls_name(pSMB->hdr.Flags2, data_offset,
+ toName, nls_codepage, 0);
pSMB->MaxParameterCount = cpu_to_le16(2);
/* BB find exact max on data count below from sess */
pSMB->MaxDataCount = cpu_to_le16(1000);
@@ -2389,18 +2369,9 @@ querySymLinkRetry:
if (rc)
return rc;
- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
- name_len =
- cifs_strtoUCS((__le16 *) pSMB->FileName, searchName,
- PATH_MAX, nls_codepage);
- name_len++; /* trailing null */
- name_len *= 2;
- } else { /* BB improve the check for buffer overruns BB */
- name_len = strnlen(searchName, PATH_MAX);
- name_len++; /* trailing null */
- strncpy(pSMB->FileName, searchName, name_len);
- }
-
+ /* pass remap = 0 */
+ name_len = setup_ucs_nls_name(pSMB->hdr.Flags2, pSMB->FileName,
+ searchName, nls_codepage, 0);
params = 2 /* level */ + 4 /* rsrvd */ + name_len /* incl null */ ;
pSMB->TotalDataCount = 0;
pSMB->MaxParameterCount = cpu_to_le16(2);
More information about the linux-cifs-client
mailing list