aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/connect.c
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2005-11-11 18:18:19 -0500
committerSteve French <sfrench@us.ibm.com>2005-11-11 18:18:19 -0500
commite89dc9209692293434da45ec31826a55becb91c0 (patch)
tree171ebb84c30467cbff8a5bf8213dbf40e64d84f7 /fs/cifs/connect.c
parent8b94bcb923dff923a5a5b7c6f890702a54cb19cf (diff)
[CIFS] Cleanup sparse warnings for unicode little endian casts
Following Shaggy's suggestion, do a better job on the unicode string handling routines in cifs in specifying that the wchar_t are really little endian widechars (__le16). Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r--fs/cifs/connect.c91
1 files changed, 41 insertions, 50 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 2cb620716bc1..c467de857610 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1986,32 +1986,32 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
1986 bytes_returned = 0; /* skill null user */ 1986 bytes_returned = 0; /* skill null user */
1987 else 1987 else
1988 bytes_returned = 1988 bytes_returned =
1989 cifs_strtoUCS((wchar_t *) bcc_ptr, user, 100, 1989 cifs_strtoUCS((__le16 *) bcc_ptr, user, 100,
1990 nls_codepage); 1990 nls_codepage);
1991 /* convert number of 16 bit words to bytes */ 1991 /* convert number of 16 bit words to bytes */
1992 bcc_ptr += 2 * bytes_returned; 1992 bcc_ptr += 2 * bytes_returned;
1993 bcc_ptr += 2; /* trailing null */ 1993 bcc_ptr += 2; /* trailing null */
1994 if (domain == NULL) 1994 if (domain == NULL)
1995 bytes_returned = 1995 bytes_returned =
1996 cifs_strtoUCS((wchar_t *) bcc_ptr, 1996 cifs_strtoUCS((__le16 *) bcc_ptr,
1997 "CIFS_LINUX_DOM", 32, nls_codepage); 1997 "CIFS_LINUX_DOM", 32, nls_codepage);
1998 else 1998 else
1999 bytes_returned = 1999 bytes_returned =
2000 cifs_strtoUCS((wchar_t *) bcc_ptr, domain, 64, 2000 cifs_strtoUCS((__le16 *) bcc_ptr, domain, 64,
2001 nls_codepage); 2001 nls_codepage);
2002 bcc_ptr += 2 * bytes_returned; 2002 bcc_ptr += 2 * bytes_returned;
2003 bcc_ptr += 2; 2003 bcc_ptr += 2;
2004 bytes_returned = 2004 bytes_returned =
2005 cifs_strtoUCS((wchar_t *) bcc_ptr, "Linux version ", 2005 cifs_strtoUCS((__le16 *) bcc_ptr, "Linux version ",
2006 32, nls_codepage); 2006 32, nls_codepage);
2007 bcc_ptr += 2 * bytes_returned; 2007 bcc_ptr += 2 * bytes_returned;
2008 bytes_returned = 2008 bytes_returned =
2009 cifs_strtoUCS((wchar_t *) bcc_ptr, system_utsname.release, 2009 cifs_strtoUCS((__le16 *) bcc_ptr, system_utsname.release,
2010 32, nls_codepage); 2010 32, nls_codepage);
2011 bcc_ptr += 2 * bytes_returned; 2011 bcc_ptr += 2 * bytes_returned;
2012 bcc_ptr += 2; 2012 bcc_ptr += 2;
2013 bytes_returned = 2013 bytes_returned =
2014 cifs_strtoUCS((wchar_t *) bcc_ptr, CIFS_NETWORK_OPSYS, 2014 cifs_strtoUCS((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS,
2015 64, nls_codepage); 2015 64, nls_codepage);
2016 bcc_ptr += 2 * bytes_returned; 2016 bcc_ptr += 2 * bytes_returned;
2017 bcc_ptr += 2; 2017 bcc_ptr += 2;
@@ -2081,7 +2081,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2081 if(ses->serverOS == NULL) 2081 if(ses->serverOS == NULL)
2082 goto sesssetup_nomem; 2082 goto sesssetup_nomem;
2083 cifs_strfromUCS_le(ses->serverOS, 2083 cifs_strfromUCS_le(ses->serverOS,
2084 (wchar_t *)bcc_ptr, len,nls_codepage); 2084 (__le16 *)bcc_ptr, len,nls_codepage);
2085 bcc_ptr += 2 * (len + 1); 2085 bcc_ptr += 2 * (len + 1);
2086 remaining_words -= len + 1; 2086 remaining_words -= len + 1;
2087 ses->serverOS[2 * len] = 0; 2087 ses->serverOS[2 * len] = 0;
@@ -2093,7 +2093,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2093 if(ses->serverNOS == NULL) 2093 if(ses->serverNOS == NULL)
2094 goto sesssetup_nomem; 2094 goto sesssetup_nomem;
2095 cifs_strfromUCS_le(ses->serverNOS, 2095 cifs_strfromUCS_le(ses->serverNOS,
2096 (wchar_t *)bcc_ptr,len,nls_codepage); 2096 (__le16 *)bcc_ptr,len,nls_codepage);
2097 bcc_ptr += 2 * (len + 1); 2097 bcc_ptr += 2 * (len + 1);
2098 ses->serverNOS[2 * len] = 0; 2098 ses->serverNOS[2 * len] = 0;
2099 ses->serverNOS[1 + (2 * len)] = 0; 2099 ses->serverNOS[1 + (2 * len)] = 0;
@@ -2111,7 +2111,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2111 if(ses->serverDomain == NULL) 2111 if(ses->serverDomain == NULL)
2112 goto sesssetup_nomem; 2112 goto sesssetup_nomem;
2113 cifs_strfromUCS_le(ses->serverDomain, 2113 cifs_strfromUCS_le(ses->serverDomain,
2114 (wchar_t *)bcc_ptr,len,nls_codepage); 2114 (__le16 *)bcc_ptr,len,nls_codepage);
2115 bcc_ptr += 2 * (len + 1); 2115 bcc_ptr += 2 * (len + 1);
2116 ses->serverDomain[2*len] = 0; 2116 ses->serverDomain[2*len] = 0;
2117 ses->serverDomain[1+(2*len)] = 0; 2117 ses->serverDomain[1+(2*len)] = 0;
@@ -2255,30 +2255,30 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2255 bcc_ptr++; 2255 bcc_ptr++;
2256 } 2256 }
2257 bytes_returned = 2257 bytes_returned =
2258 cifs_strtoUCS((wchar_t *) bcc_ptr, user, 100, nls_codepage); 2258 cifs_strtoUCS((__le16 *) bcc_ptr, user, 100, nls_codepage);
2259 bcc_ptr += 2 * bytes_returned; /* convert num of 16 bit words to bytes */ 2259 bcc_ptr += 2 * bytes_returned; /* convert num of 16 bit words to bytes */
2260 bcc_ptr += 2; /* trailing null */ 2260 bcc_ptr += 2; /* trailing null */
2261 if (domain == NULL) 2261 if (domain == NULL)
2262 bytes_returned = 2262 bytes_returned =
2263 cifs_strtoUCS((wchar_t *) bcc_ptr, 2263 cifs_strtoUCS((__le16 *) bcc_ptr,
2264 "CIFS_LINUX_DOM", 32, nls_codepage); 2264 "CIFS_LINUX_DOM", 32, nls_codepage);
2265 else 2265 else
2266 bytes_returned = 2266 bytes_returned =
2267 cifs_strtoUCS((wchar_t *) bcc_ptr, domain, 64, 2267 cifs_strtoUCS((__le16 *) bcc_ptr, domain, 64,
2268 nls_codepage); 2268 nls_codepage);
2269 bcc_ptr += 2 * bytes_returned; 2269 bcc_ptr += 2 * bytes_returned;
2270 bcc_ptr += 2; 2270 bcc_ptr += 2;
2271 bytes_returned = 2271 bytes_returned =
2272 cifs_strtoUCS((wchar_t *) bcc_ptr, "Linux version ", 2272 cifs_strtoUCS((__le16 *) bcc_ptr, "Linux version ",
2273 32, nls_codepage); 2273 32, nls_codepage);
2274 bcc_ptr += 2 * bytes_returned; 2274 bcc_ptr += 2 * bytes_returned;
2275 bytes_returned = 2275 bytes_returned =
2276 cifs_strtoUCS((wchar_t *) bcc_ptr, system_utsname.release, 32, 2276 cifs_strtoUCS((__le16 *) bcc_ptr, system_utsname.release, 32,
2277 nls_codepage); 2277 nls_codepage);
2278 bcc_ptr += 2 * bytes_returned; 2278 bcc_ptr += 2 * bytes_returned;
2279 bcc_ptr += 2; 2279 bcc_ptr += 2;
2280 bytes_returned = 2280 bytes_returned =
2281 cifs_strtoUCS((wchar_t *) bcc_ptr, CIFS_NETWORK_OPSYS, 2281 cifs_strtoUCS((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS,
2282 64, nls_codepage); 2282 64, nls_codepage);
2283 bcc_ptr += 2 * bytes_returned; 2283 bcc_ptr += 2 * bytes_returned;
2284 bcc_ptr += 2; 2284 bcc_ptr += 2;
@@ -2357,7 +2357,7 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2357 ses->serverOS = 2357 ses->serverOS =
2358 kzalloc(2 * (len + 1), GFP_KERNEL); 2358 kzalloc(2 * (len + 1), GFP_KERNEL);
2359 cifs_strfromUCS_le(ses->serverOS, 2359 cifs_strfromUCS_le(ses->serverOS,
2360 (wchar_t *) 2360 (__le16 *)
2361 bcc_ptr, len, 2361 bcc_ptr, len,
2362 nls_codepage); 2362 nls_codepage);
2363 bcc_ptr += 2 * (len + 1); 2363 bcc_ptr += 2 * (len + 1);
@@ -2372,7 +2372,7 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2372 kzalloc(2 * (len + 1), 2372 kzalloc(2 * (len + 1),
2373 GFP_KERNEL); 2373 GFP_KERNEL);
2374 cifs_strfromUCS_le(ses->serverNOS, 2374 cifs_strfromUCS_le(ses->serverNOS,
2375 (wchar_t *)bcc_ptr, 2375 (__le16 *)bcc_ptr,
2376 len, 2376 len,
2377 nls_codepage); 2377 nls_codepage);
2378 bcc_ptr += 2 * (len + 1); 2378 bcc_ptr += 2 * (len + 1);
@@ -2384,9 +2384,8 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2384 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ 2384 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */
2385 ses->serverDomain = kzalloc(2*(len+1),GFP_KERNEL); 2385 ses->serverDomain = kzalloc(2*(len+1),GFP_KERNEL);
2386 cifs_strfromUCS_le(ses->serverDomain, 2386 cifs_strfromUCS_le(ses->serverDomain,
2387 (wchar_t *)bcc_ptr, 2387 (__le16 *)bcc_ptr,
2388 len, 2388 len, nls_codepage);
2389 nls_codepage);
2390 bcc_ptr += 2*(len+1); 2389 bcc_ptr += 2*(len+1);
2391 ses->serverDomain[2*len] = 0; 2390 ses->serverDomain[2*len] = 0;
2392 ses->serverDomain[1+(2*len)] = 0; 2391 ses->serverDomain[1+(2*len)] = 0;
@@ -2560,16 +2559,16 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2560 } 2559 }
2561 2560
2562 bytes_returned = 2561 bytes_returned =
2563 cifs_strtoUCS((wchar_t *) bcc_ptr, "Linux version ", 2562 cifs_strtoUCS((__le16 *) bcc_ptr, "Linux version ",
2564 32, nls_codepage); 2563 32, nls_codepage);
2565 bcc_ptr += 2 * bytes_returned; 2564 bcc_ptr += 2 * bytes_returned;
2566 bytes_returned = 2565 bytes_returned =
2567 cifs_strtoUCS((wchar_t *) bcc_ptr, system_utsname.release, 32, 2566 cifs_strtoUCS((__le16 *) bcc_ptr, system_utsname.release, 32,
2568 nls_codepage); 2567 nls_codepage);
2569 bcc_ptr += 2 * bytes_returned; 2568 bcc_ptr += 2 * bytes_returned;
2570 bcc_ptr += 2; /* null terminate Linux version */ 2569 bcc_ptr += 2; /* null terminate Linux version */
2571 bytes_returned = 2570 bytes_returned =
2572 cifs_strtoUCS((wchar_t *) bcc_ptr, CIFS_NETWORK_OPSYS, 2571 cifs_strtoUCS((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS,
2573 64, nls_codepage); 2572 64, nls_codepage);
2574 bcc_ptr += 2 * bytes_returned; 2573 bcc_ptr += 2 * bytes_returned;
2575 *(bcc_ptr + 1) = 0; 2574 *(bcc_ptr + 1) = 0;
@@ -2673,7 +2672,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2673 ses->serverOS = 2672 ses->serverOS =
2674 kzalloc(2 * (len + 1), GFP_KERNEL); 2673 kzalloc(2 * (len + 1), GFP_KERNEL);
2675 cifs_strfromUCS_le(ses->serverOS, 2674 cifs_strfromUCS_le(ses->serverOS,
2676 (wchar_t *) 2675 (__le16 *)
2677 bcc_ptr, len, 2676 bcc_ptr, len,
2678 nls_codepage); 2677 nls_codepage);
2679 bcc_ptr += 2 * (len + 1); 2678 bcc_ptr += 2 * (len + 1);
@@ -2690,7 +2689,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2690 GFP_KERNEL); 2689 GFP_KERNEL);
2691 cifs_strfromUCS_le(ses-> 2690 cifs_strfromUCS_le(ses->
2692 serverNOS, 2691 serverNOS,
2693 (wchar_t *) 2692 (__le16 *)
2694 bcc_ptr, 2693 bcc_ptr,
2695 len, 2694 len,
2696 nls_codepage); 2695 nls_codepage);
@@ -2708,23 +2707,15 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2708 1), 2707 1),
2709 GFP_KERNEL); 2708 GFP_KERNEL);
2710 cifs_strfromUCS_le 2709 cifs_strfromUCS_le
2711 (ses-> 2710 (ses->serverDomain,
2712 serverDomain, 2711 (__le16 *)bcc_ptr,
2713 (wchar_t *) 2712 len, nls_codepage);
2714 bcc_ptr, len,
2715 nls_codepage);
2716 bcc_ptr += 2713 bcc_ptr +=
2717 2 * (len + 1); 2714 2 * (len + 1);
2718 ses-> 2715 ses->serverDomain[2*len]
2719 serverDomain[2
2720 * len]
2721 = 0; 2716 = 0;
2722 ses-> 2717 ses->serverDomain
2723 serverDomain[1 2718 [1 + (2 * len)]
2724 +
2725 (2
2726 *
2727 len)]
2728 = 0; 2719 = 0;
2729 } /* else no more room so create dummy domain string */ 2720 } /* else no more room so create dummy domain string */
2730 else 2721 else
@@ -2903,7 +2894,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2903 SecurityBlob->DomainName.MaximumLength = 0; 2894 SecurityBlob->DomainName.MaximumLength = 0;
2904 } else { 2895 } else {
2905 __u16 len = 2896 __u16 len =
2906 cifs_strtoUCS((wchar_t *) bcc_ptr, domain, 64, 2897 cifs_strtoUCS((__le16 *) bcc_ptr, domain, 64,
2907 nls_codepage); 2898 nls_codepage);
2908 len *= 2; 2899 len *= 2;
2909 SecurityBlob->DomainName.MaximumLength = 2900 SecurityBlob->DomainName.MaximumLength =
@@ -2921,7 +2912,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2921 SecurityBlob->UserName.MaximumLength = 0; 2912 SecurityBlob->UserName.MaximumLength = 0;
2922 } else { 2913 } else {
2923 __u16 len = 2914 __u16 len =
2924 cifs_strtoUCS((wchar_t *) bcc_ptr, user, 64, 2915 cifs_strtoUCS((__le16 *) bcc_ptr, user, 64,
2925 nls_codepage); 2916 nls_codepage);
2926 len *= 2; 2917 len *= 2;
2927 SecurityBlob->UserName.MaximumLength = 2918 SecurityBlob->UserName.MaximumLength =
@@ -2934,7 +2925,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2934 cpu_to_le16(len); 2925 cpu_to_le16(len);
2935 } 2926 }
2936 2927
2937 /* SecurityBlob->WorkstationName.Length = cifs_strtoUCS((wchar_t *) bcc_ptr, "AMACHINE",64, nls_codepage); 2928 /* SecurityBlob->WorkstationName.Length = cifs_strtoUCS((__le16 *) bcc_ptr, "AMACHINE",64, nls_codepage);
2938 SecurityBlob->WorkstationName.Length *= 2; 2929 SecurityBlob->WorkstationName.Length *= 2;
2939 SecurityBlob->WorkstationName.MaximumLength = cpu_to_le16(SecurityBlob->WorkstationName.Length); 2930 SecurityBlob->WorkstationName.MaximumLength = cpu_to_le16(SecurityBlob->WorkstationName.Length);
2940 SecurityBlob->WorkstationName.Buffer = cpu_to_le32(SecurityBlobLength); 2931 SecurityBlob->WorkstationName.Buffer = cpu_to_le32(SecurityBlobLength);
@@ -2947,16 +2938,16 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2947 bcc_ptr++; 2938 bcc_ptr++;
2948 } 2939 }
2949 bytes_returned = 2940 bytes_returned =
2950 cifs_strtoUCS((wchar_t *) bcc_ptr, "Linux version ", 2941 cifs_strtoUCS((__le16 *) bcc_ptr, "Linux version ",
2951 32, nls_codepage); 2942 32, nls_codepage);
2952 bcc_ptr += 2 * bytes_returned; 2943 bcc_ptr += 2 * bytes_returned;
2953 bytes_returned = 2944 bytes_returned =
2954 cifs_strtoUCS((wchar_t *) bcc_ptr, system_utsname.release, 32, 2945 cifs_strtoUCS((__le16 *) bcc_ptr, system_utsname.release, 32,
2955 nls_codepage); 2946 nls_codepage);
2956 bcc_ptr += 2 * bytes_returned; 2947 bcc_ptr += 2 * bytes_returned;
2957 bcc_ptr += 2; /* null term version string */ 2948 bcc_ptr += 2; /* null term version string */
2958 bytes_returned = 2949 bytes_returned =
2959 cifs_strtoUCS((wchar_t *) bcc_ptr, CIFS_NETWORK_OPSYS, 2950 cifs_strtoUCS((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS,
2960 64, nls_codepage); 2951 64, nls_codepage);
2961 bcc_ptr += 2 * bytes_returned; 2952 bcc_ptr += 2 * bytes_returned;
2962 *(bcc_ptr + 1) = 0; 2953 *(bcc_ptr + 1) = 0;
@@ -3069,7 +3060,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3069 ses->serverOS = 3060 ses->serverOS =
3070 kzalloc(2 * (len + 1), GFP_KERNEL); 3061 kzalloc(2 * (len + 1), GFP_KERNEL);
3071 cifs_strfromUCS_le(ses->serverOS, 3062 cifs_strfromUCS_le(ses->serverOS,
3072 (wchar_t *) 3063 (__le16 *)
3073 bcc_ptr, len, 3064 bcc_ptr, len,
3074 nls_codepage); 3065 nls_codepage);
3075 bcc_ptr += 2 * (len + 1); 3066 bcc_ptr += 2 * (len + 1);
@@ -3086,7 +3077,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3086 GFP_KERNEL); 3077 GFP_KERNEL);
3087 cifs_strfromUCS_le(ses-> 3078 cifs_strfromUCS_le(ses->
3088 serverNOS, 3079 serverNOS,
3089 (wchar_t *) 3080 (__le16 *)
3090 bcc_ptr, 3081 bcc_ptr,
3091 len, 3082 len,
3092 nls_codepage); 3083 nls_codepage);
@@ -3105,7 +3096,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3105 cifs_strfromUCS_le 3096 cifs_strfromUCS_le
3106 (ses-> 3097 (ses->
3107 serverDomain, 3098 serverDomain,
3108 (wchar_t *) 3099 (__le16 *)
3109 bcc_ptr, len, 3100 bcc_ptr, len,
3110 nls_codepage); 3101 nls_codepage);
3111 bcc_ptr += 3102 bcc_ptr +=
@@ -3227,7 +3218,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3227 if (ses->capabilities & CAP_UNICODE) { 3218 if (ses->capabilities & CAP_UNICODE) {
3228 smb_buffer->Flags2 |= SMBFLG2_UNICODE; 3219 smb_buffer->Flags2 |= SMBFLG2_UNICODE;
3229 length = 3220 length =
3230 cifs_strtoUCS((wchar_t *) bcc_ptr, tree, 100, nls_codepage); 3221 cifs_strtoUCS((__le16 *) bcc_ptr, tree, 100, nls_codepage);
3231 bcc_ptr += 2 * length; /* convert num of 16 bit words to bytes */ 3222 bcc_ptr += 2 * length; /* convert num of 16 bit words to bytes */
3232 bcc_ptr += 2; /* skip trailing null */ 3223 bcc_ptr += 2; /* skip trailing null */
3233 } else { /* ASCII */ 3224 } else { /* ASCII */
@@ -3263,7 +3254,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3263 tcon->nativeFileSystem = 3254 tcon->nativeFileSystem =
3264 kzalloc(length + 2, GFP_KERNEL); 3255 kzalloc(length + 2, GFP_KERNEL);
3265 cifs_strfromUCS_le(tcon->nativeFileSystem, 3256 cifs_strfromUCS_le(tcon->nativeFileSystem,
3266 (wchar_t *) bcc_ptr, 3257 (__le16 *) bcc_ptr,
3267 length, nls_codepage); 3258 length, nls_codepage);
3268 bcc_ptr += 2 * length; 3259 bcc_ptr += 2 * length;
3269 bcc_ptr[0] = 0; /* null terminate the string */ 3260 bcc_ptr[0] = 0; /* null terminate the string */