Skip to content

Commit 90c81e0

Browse files
author
Steve French
committed
[CIFS] clean up some hard to read ifdefs
Christoph had noticed too many ifdefs in the CIFS code making it hard to read. This patch removes about a quarter of them from the C files in cifs by improving a few key ifdefs in the .h files. Signed-off-by: Steve French <sfrench@us.ibm.com>
1 parent ad7a292 commit 90c81e0

13 files changed

Lines changed: 51 additions & 84 deletions

File tree

‎fs/cifs/cifs_debug.c‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
438438

439439
return length;
440440
}
441-
#endif
441+
#endif /* STATS */
442442

443443
static struct proc_dir_entry *proc_fs_cifs;
444444
read_proc_t cifs_txanchor_read;
@@ -481,7 +481,7 @@ cifs_proc_init(void)
481481
cifs_stats_read, NULL);
482482
if (pde)
483483
pde->write_proc = cifs_stats_write;
484-
#endif
484+
#endif /* STATS */
485485
pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
486486
cifsFYI_read, NULL);
487487
if (pde)
@@ -917,4 +917,12 @@ security_flags_write(struct file *file, const char __user *buffer,
917917
/* BB should we turn on MAY flags for other MUST options? */
918918
return count;
919919
}
920-
#endif
920+
#else
921+
static inline void cifs_proc_init(void)
922+
{
923+
}
924+
925+
static inline void cifs_proc_clean(void)
926+
{
927+
}
928+
#endif /* PROC_FS */

‎fs/cifs/cifs_debug.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@
2525

2626
void cifs_dump_mem(char *label, void *data, int length);
2727
#ifdef CONFIG_CIFS_DEBUG2
28+
#define DBG2 2
2829
void cifs_dump_detail(struct smb_hdr *);
2930
void cifs_dump_mids(struct TCP_Server_Info *);
31+
#else
32+
#define DBG2 0
3033
#endif
3134
extern int traceSMB; /* flag which enables the function below */
3235
void dump_smb(struct smb_hdr *, int);

‎fs/cifs/cifsacl.c‎

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,7 @@ static void access_flags_to_mode(__le32 ace_flags, int type, umode_t *pmode,
215215

216216
if (flags & GENERIC_ALL) {
217217
*pmode |= (S_IRWXUGO & (*pbits_to_set));
218-
#ifdef CONFIG_CIFS_DEBUG2
219-
cFYI(1, ("all perms"));
220-
#endif
218+
cFYI(DBG2, ("all perms"));
221219
return;
222220
}
223221
if ((flags & GENERIC_WRITE) ||
@@ -230,9 +228,7 @@ static void access_flags_to_mode(__le32 ace_flags, int type, umode_t *pmode,
230228
((flags & FILE_EXEC_RIGHTS) == FILE_EXEC_RIGHTS))
231229
*pmode |= (S_IXUGO & (*pbits_to_set));
232230

233-
#ifdef CONFIG_CIFS_DEBUG2
234-
cFYI(1, ("access flags 0x%x mode now 0x%x", flags, *pmode));
235-
#endif
231+
cFYI(DBG2, ("access flags 0x%x mode now 0x%x", flags, *pmode));
236232
return;
237233
}
238234

@@ -261,9 +257,7 @@ static void mode_to_access_flags(umode_t mode, umode_t bits_to_use,
261257
if (mode & S_IXUGO)
262258
*pace_flags |= SET_FILE_EXEC_RIGHTS;
263259

264-
#ifdef CONFIG_CIFS_DEBUG2
265-
cFYI(1, ("mode: 0x%x, access flags now 0x%x", mode, *pace_flags));
266-
#endif
260+
cFYI(DBG2, ("mode: 0x%x, access flags now 0x%x", mode, *pace_flags));
267261
return;
268262
}
269263

@@ -357,11 +351,9 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,
357351
return;
358352
}
359353

360-
#ifdef CONFIG_CIFS_DEBUG2
361-
cFYI(1, ("DACL revision %d size %d num aces %d",
354+
cFYI(DBG2, ("DACL revision %d size %d num aces %d",
362355
le16_to_cpu(pdacl->revision), le16_to_cpu(pdacl->size),
363356
le32_to_cpu(pdacl->num_aces)));
364-
#endif
365357

366358
/* reset rwx permissions for user/group/other.
367359
Also, if num_aces is 0 i.e. DACL has no ACEs,
@@ -494,13 +486,11 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,
494486
le32_to_cpu(pntsd->gsidoffset));
495487
dacloffset = le32_to_cpu(pntsd->dacloffset);
496488
dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset);
497-
#ifdef CONFIG_CIFS_DEBUG2
498-
cFYI(1, ("revision %d type 0x%x ooffset 0x%x goffset 0x%x "
489+
cFYI(DBG2, ("revision %d type 0x%x ooffset 0x%x goffset 0x%x "
499490
"sacloffset 0x%x dacloffset 0x%x",
500491
pntsd->revision, pntsd->type, le32_to_cpu(pntsd->osidoffset),
501492
le32_to_cpu(pntsd->gsidoffset),
502493
le32_to_cpu(pntsd->sacloffset), dacloffset));
503-
#endif
504494
/* cifs_dump_mem("owner_sid: ", owner_sid_ptr, 64); */
505495
rc = parse_sid(owner_sid_ptr, end_of_acl);
506496
if (rc)
@@ -635,9 +625,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
635625
struct super_block *sb;
636626
struct cifs_sb_info *cifs_sb;
637627

638-
#ifdef CONFIG_CIFS_DEBUG2
639-
cFYI(1, ("set ACL for %s from mode 0x%x", path, inode->i_mode));
640-
#endif
628+
cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode));
641629

642630
if (!inode)
643631
return (rc);
@@ -668,9 +656,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
668656
}
669657

670658
rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen);
671-
#ifdef CONFIG_CIFS_DEBUG2
672-
cFYI(1, ("SetCIFSACL rc = %d", rc));
673-
#endif
659+
cFYI(DBG2, ("SetCIFSACL rc = %d", rc));
674660
if (unlock_file == TRUE)
675661
atomic_dec(&open_file->wrtPending);
676662
else
@@ -688,9 +674,7 @@ void acl_to_uid_mode(struct inode *inode, const char *path)
688674
u32 acllen = 0;
689675
int rc = 0;
690676

691-
#ifdef CONFIG_CIFS_DEBUG2
692-
cFYI(1, ("converting ACL to mode for %s", path));
693-
#endif
677+
cFYI(DBG2, ("converting ACL to mode for %s", path));
694678
pntsd = get_cifs_acl(&acllen, inode, path);
695679

696680
/* if we can retrieve the ACL, now parse Access Control Entries, ACEs */
@@ -711,9 +695,7 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
711695
struct cifs_ntsd *pntsd = NULL; /* acl obtained from server */
712696
struct cifs_ntsd *pnntsd = NULL; /* modified acl to be sent to server */
713697

714-
#ifdef CONFIG_CIFS_DEBUG2
715-
cFYI(1, ("set ACL from mode for %s", path));
716-
#endif
698+
cFYI(DBG2, ("set ACL from mode for %s", path));
717699

718700
/* Get the security descriptor */
719701
pntsd = get_cifs_acl(&acllen, inode, path);
@@ -735,16 +717,12 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
735717

736718
rc = build_sec_desc(pntsd, pnntsd, acllen, inode, nmode);
737719

738-
#ifdef CONFIG_CIFS_DEBUG2
739-
cFYI(1, ("build_sec_desc rc: %d", rc));
740-
#endif
720+
cFYI(DBG2, ("build_sec_desc rc: %d", rc));
741721

742722
if (!rc) {
743723
/* Set the security descriptor */
744724
rc = set_cifs_acl(pnntsd, acllen, inode, path);
745-
#ifdef CONFIG_CIFS_DEBUG2
746-
cFYI(1, ("set_cifs_acl rc: %d", rc));
747-
#endif
725+
cFYI(DBG2, ("set_cifs_acl rc: %d", rc));
748726
}
749727

750728
kfree(pnntsd);

‎fs/cifs/cifsfs.c‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,7 @@ static void cifs_umount_begin(struct vfsmount *vfsmnt, int flags)
470470
struct cifs_sb_info *cifs_sb;
471471
struct cifsTconInfo *tcon;
472472

473-
#ifdef CONFIG_CIFS_DFS_UPCALL
474473
dfs_shrink_umount_helper(vfsmnt);
475-
#endif /* CONFIG CIFS_DFS_UPCALL */
476474

477475
if (!(flags & MNT_FORCE))
478476
return;
@@ -991,9 +989,7 @@ static int __init
991989
init_cifs(void)
992990
{
993991
int rc = 0;
994-
#ifdef CONFIG_PROC_FS
995992
cifs_proc_init();
996-
#endif
997993
/* INIT_LIST_HEAD(&GlobalServerList);*/ /* BB not implemented yet */
998994
INIT_LIST_HEAD(&GlobalSMBSessionList);
999995
INIT_LIST_HEAD(&GlobalTreeConnectionList);
@@ -1094,19 +1090,15 @@ init_cifs(void)
10941090
out_destroy_inodecache:
10951091
cifs_destroy_inodecache();
10961092
out_clean_proc:
1097-
#ifdef CONFIG_PROC_FS
10981093
cifs_proc_clean();
1099-
#endif
11001094
return rc;
11011095
}
11021096

11031097
static void __exit
11041098
exit_cifs(void)
11051099
{
1106-
cFYI(0, ("exit_cifs"));
1107-
#ifdef CONFIG_PROC_FS
1100+
cFYI(DBG2, ("exit_cifs"));
11081101
cifs_proc_clean();
1109-
#endif
11101102
#ifdef CONFIG_CIFS_DFS_UPCALL
11111103
unregister_key_type(&key_type_dns_resolver);
11121104
#endif

‎fs/cifs/cifsproto.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,13 @@ extern int mode_to_acl(struct inode *inode, const char *path, __u64);
102102
extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *,
103103
const char *);
104104
extern int cifs_umount(struct super_block *, struct cifs_sb_info *);
105-
#ifdef CONFIG_CIFS_DFS_UPCALL
105+
#ifdef CONFIG_CIFS_DFS
106106
extern void dfs_shrink_umount_helper(struct vfsmount *vfsmnt);
107-
#endif
107+
#else
108+
static inline void dfs_shrink_umount_helper(struct vfsmount *vfsmnt)
109+
{
110+
}
111+
#endif /* DFS_UPCALL */
108112
void cifs_proc_init(void);
109113
void cifs_proc_clean(void);
110114

‎fs/cifs/cifssmb.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
602602
server->maxBuf = min(le32_to_cpu(pSMBr->MaxBufferSize),
603603
(__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);
604604
server->maxRw = le32_to_cpu(pSMBr->MaxRawSize);
605-
cFYI(0, ("Max buf = %d", ses->server->maxBuf));
605+
cFYI(DBG2, ("Max buf = %d", ses->server->maxBuf));
606606
GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey);
607607
server->capabilities = le32_to_cpu(pSMBr->Capabilities);
608608
server->timeAdj = (int)(__s16)le16_to_cpu(pSMBr->ServerTimeZone);
@@ -1108,9 +1108,7 @@ CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags,
11081108
/* check to make sure response data is there */
11091109
if (psx_rsp->ReturnedLevel != cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC)) {
11101110
pRetData->Type = cpu_to_le32(-1); /* unknown */
1111-
#ifdef CONFIG_CIFS_DEBUG2
1112-
cFYI(1, ("unknown type"));
1113-
#endif
1111+
cFYI(DBG2, ("unknown type"));
11141112
} else {
11151113
if (pSMBr->ByteCount < sizeof(OPEN_PSX_RSP)
11161114
+ sizeof(FILE_UNIX_BASIC_INFO)) {

‎fs/cifs/connect.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,9 +1753,8 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo *tcon,
17531753
if (sb && (CIFS_SB(sb)->rsize > 127 * 1024)) {
17541754
if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) {
17551755
CIFS_SB(sb)->rsize = 127 * 1024;
1756-
#ifdef CONFIG_CIFS_DEBUG2
1757-
cFYI(1, ("larger reads not supported by srv"));
1758-
#endif
1756+
cFYI(DBG2,
1757+
("larger reads not supported by srv"));
17591758
}
17601759
}
17611760

@@ -2227,9 +2226,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
22272226

22282227
if ((tcon->unix_ext == 0) && (cifs_sb->rsize > (1024 * 127))) {
22292228
cifs_sb->rsize = 1024 * 127;
2230-
#ifdef CONFIG_CIFS_DEBUG2
2231-
cFYI(1, ("no very large read support, rsize now 127K"));
2232-
#endif
2229+
cFYI(DBG2,
2230+
("no very large read support, rsize now 127K"));
22332231
}
22342232
if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X))
22352233
cifs_sb->wsize = min(cifs_sb->wsize,

‎fs/cifs/file.c‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,8 @@ int cifs_close(struct inode *inode, struct file *file)
499499
the struct would be in each open file,
500500
but this should give enough time to
501501
clear the socket */
502-
#ifdef CONFIG_CIFS_DEBUG2
503-
cFYI(1, ("close delay, write pending"));
504-
#endif /* DEBUG2 */
502+
cFYI(DBG2,
503+
("close delay, write pending"));
505504
msleep(timeout);
506505
timeout *= 4;
507506
}
@@ -1812,9 +1811,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
18121811
pTcon = cifs_sb->tcon;
18131812

18141813
pagevec_init(&lru_pvec, 0);
1815-
#ifdef CONFIG_CIFS_DEBUG2
1816-
cFYI(1, ("rpages: num pages %d", num_pages));
1817-
#endif
1814+
cFYI(DBG2, ("rpages: num pages %d", num_pages));
18181815
for (i = 0; i < num_pages; ) {
18191816
unsigned contig_pages;
18201817
struct page *tmp_page;
@@ -1847,10 +1844,8 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
18471844
/* Read size needs to be in multiples of one page */
18481845
read_size = min_t(const unsigned int, read_size,
18491846
cifs_sb->rsize & PAGE_CACHE_MASK);
1850-
#ifdef CONFIG_CIFS_DEBUG2
1851-
cFYI(1, ("rpages: read size 0x%x contiguous pages %d",
1847+
cFYI(DBG2, ("rpages: read size 0x%x contiguous pages %d",
18521848
read_size, contig_pages));
1853-
#endif
18541849
rc = -EAGAIN;
18551850
while (rc == -EAGAIN) {
18561851
if ((open_file->invalidHandle) &&

‎fs/cifs/inode.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,9 +837,7 @@ static void posix_fill_in_inode(struct inode *tmp_inode,
837837
cFYI(1, ("unknown inode type %d", type));
838838
}
839839

840-
#ifdef CONFIG_CIFS_DEBUG2
841-
cFYI(1, ("object type: %d", type));
842-
#endif
840+
cFYI(DBG2, ("object type: %d", type));
843841
tmp_inode->i_uid = le64_to_cpu(pData->Uid);
844842
tmp_inode->i_gid = le64_to_cpu(pData->Gid);
845843
tmp_inode->i_nlink = le64_to_cpu(pData->Nlinks);

‎fs/cifs/netmisc.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ static int canonicalize_unc(char *cp)
150150
if (cp[i] == '\\')
151151
break;
152152
if (cp[i] == '/') {
153-
#ifdef CONFIG_CIFS_DEBUG2
154-
cFYI(1, ("change slash to backslash in malformed UNC"));
155-
#endif
153+
cFYI(DBG2, ("change slash to \\ in malformed UNC"));
156154
cp[i] = '\\';
157155
return 1;
158156
}
@@ -178,9 +176,7 @@ cifs_inet_pton(int address_family, char *cp, void *dst)
178176
} else if (address_family == AF_INET6) {
179177
ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL);
180178
}
181-
#ifdef CONFIG_CIFS_DEBUG2
182-
cFYI(1, ("address conversion returned %d for %s", ret, cp));
183-
#endif
179+
cFYI(DBG2, ("address conversion returned %d for %s", ret, cp));
184180
if (ret > 0)
185181
ret = 1;
186182
return ret;

0 commit comments

Comments
 (0)