Commit 1397f2ee4be65542fdc3460c7e8b6317779ea680
Committed by
Steve French
1 parent
a0f8b4fb4c
Exists in
master
and in
4 other branches
cifs: replace some hardcoded values with preprocessor constants
A number of places that deal with RFC1001/1002 negotiations have bare "15" or "16" values. Replace them with RFC_1001_NAME_LEN and RFC_1001_NAME_LEN_WITH_NULL. The patch also cleans up some checkpatch warnings for code surrounding the changes. This should apply cleanly on top of the patch to remove Local_System_Name. Reported-and-Reviwed-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com> Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Showing 1 changed file with 19 additions and 18 deletions Side-by-side Diff
fs/cifs/connect.c
... | ... | @@ -64,8 +64,8 @@ |
64 | 64 | char *UNC; |
65 | 65 | char *UNCip; |
66 | 66 | char *iocharset; /* local code page for mapping to and from Unicode */ |
67 | - char source_rfc1001_name[16]; /* netbios name of client */ | |
68 | - char target_rfc1001_name[16]; /* netbios name of server for Win9x/ME */ | |
67 | + char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */ | |
68 | + char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */ | |
69 | 69 | uid_t cred_uid; |
70 | 70 | uid_t linux_uid; |
71 | 71 | gid_t linux_gid; |
72 | 72 | |
... | ... | @@ -816,11 +816,11 @@ |
816 | 816 | * informational, only used for servers that do not support |
817 | 817 | * port 445 and it can be overridden at mount time |
818 | 818 | */ |
819 | - memset(vol->source_rfc1001_name, 0x20, 15); | |
820 | - for (i = 0; i < strnlen(nodename, 15); i++) | |
819 | + memset(vol->source_rfc1001_name, 0x20, RFC1001_NAME_LEN); | |
820 | + for (i = 0; i < strnlen(nodename, RFC1001_NAME_LEN); i++) | |
821 | 821 | vol->source_rfc1001_name[i] = toupper(nodename[i]); |
822 | 822 | |
823 | - vol->source_rfc1001_name[15] = 0; | |
823 | + vol->source_rfc1001_name[RFC1001_NAME_LEN] = 0; | |
824 | 824 | /* null target name indicates to use *SMBSERVR default called name |
825 | 825 | if we end up sending RFC1001 session initialize */ |
826 | 826 | vol->target_rfc1001_name[0] = 0; |
827 | 827 | |
828 | 828 | |
... | ... | @@ -1167,22 +1167,22 @@ |
1167 | 1167 | if (!value || !*value || (*value == ' ')) { |
1168 | 1168 | cFYI(1, "invalid (empty) netbiosname"); |
1169 | 1169 | } else { |
1170 | - memset(vol->source_rfc1001_name, 0x20, 15); | |
1171 | - for (i = 0; i < 15; i++) { | |
1172 | - /* BB are there cases in which a comma can be | |
1173 | - valid in this workstation netbios name (and need | |
1174 | - special handling)? */ | |
1175 | - | |
1176 | - /* We do not uppercase netbiosname for user */ | |
1170 | + memset(vol->source_rfc1001_name, 0x20, | |
1171 | + RFC1001_NAME_LEN); | |
1172 | + /* | |
1173 | + * FIXME: are there cases in which a comma can | |
1174 | + * be valid in workstation netbios name (and | |
1175 | + * need special handling)? | |
1176 | + */ | |
1177 | + for (i = 0; i < RFC1001_NAME_LEN; i++) { | |
1178 | + /* don't ucase netbiosname for user */ | |
1177 | 1179 | if (value[i] == 0) |
1178 | 1180 | break; |
1179 | - else | |
1180 | - vol->source_rfc1001_name[i] = | |
1181 | - value[i]; | |
1181 | + vol->source_rfc1001_name[i] = value[i]; | |
1182 | 1182 | } |
1183 | 1183 | /* The string has 16th byte zero still from |
1184 | 1184 | set at top of the function */ |
1185 | - if ((i == 15) && (value[i] != 0)) | |
1185 | + if (i == RFC1001_NAME_LEN && value[i] != 0) | |
1186 | 1186 | printk(KERN_WARNING "CIFS: netbiosname" |
1187 | 1187 | " longer than 15 truncated.\n"); |
1188 | 1188 | } |
... | ... | @@ -1192,7 +1192,8 @@ |
1192 | 1192 | cFYI(1, "empty server netbiosname specified"); |
1193 | 1193 | } else { |
1194 | 1194 | /* last byte, type, is 0x20 for servr type */ |
1195 | - memset(vol->target_rfc1001_name, 0x20, 16); | |
1195 | + memset(vol->target_rfc1001_name, 0x20, | |
1196 | + RFC1001_NAME_LEN_WITH_NULL); | |
1196 | 1197 | |
1197 | 1198 | for (i = 0; i < 15; i++) { |
1198 | 1199 | /* BB are there cases in which a comma can be |
... | ... | @@ -1209,7 +1210,7 @@ |
1209 | 1210 | } |
1210 | 1211 | /* The string has 16th byte zero still from |
1211 | 1212 | set at top of the function */ |
1212 | - if ((i == 15) && (value[i] != 0)) | |
1213 | + if (i == RFC1001_NAME_LEN && value[i] != 0) | |
1213 | 1214 | printk(KERN_WARNING "CIFS: server net" |
1214 | 1215 | "biosname longer than 15 truncated.\n"); |
1215 | 1216 | } |