[PATCH 2/2] [CIFS] cleanup code by moving often repeated code sequence into a separate function - part2

View: New views
1 Messages — Rating Filter:   Alert me  

[PATCH 2/2] [CIFS] cleanup code by moving often repeated code sequence into a separate function - part2

by Günter Kukkukk-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...>

 fs/cifs/cifssmb.c |   47 +++++++++--------------------------------------
 1 files changed, 9 insertions(+), 38 deletions(-)
--
1.5.4.4

[cleanup_ucs_nls_02.patch]

diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 7283dd3..1f005fa 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -2163,20 +2163,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;
@@ -2188,19 +2177,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);
@@ -2390,18 +2370,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);


_______________________________________________
linux-cifs-client mailing list
linux-cifs-client@...
https://lists.samba.org/mailman/listinfo/linux-cifs-client
LightInTheBox - Buy quality products at wholesale price!