Skip to content

Commit

Permalink
[CIFS] clean up some hard to read ifdefs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Steve French committed Feb 12, 2008
1 parent ad7a292 commit 90c81e0
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 84 deletions.
14 changes: 11 additions & 3 deletions fs/cifs/cifs_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,

return length;
}
#endif
#endif /* STATS */

static struct proc_dir_entry *proc_fs_cifs;
read_proc_t cifs_txanchor_read;
Expand Down Expand Up @@ -481,7 +481,7 @@ cifs_proc_init(void)
cifs_stats_read, NULL);
if (pde)
pde->write_proc = cifs_stats_write;
#endif
#endif /* STATS */
pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
cifsFYI_read, NULL);
if (pde)
Expand Down Expand Up @@ -917,4 +917,12 @@ security_flags_write(struct file *file, const char __user *buffer,
/* BB should we turn on MAY flags for other MUST options? */
return count;
}
#endif
#else
static inline void cifs_proc_init(void)
{
}

static inline void cifs_proc_clean(void)
{
}
#endif /* PROC_FS */
3 changes: 3 additions & 0 deletions fs/cifs/cifs_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@

void cifs_dump_mem(char *label, void *data, int length);
#ifdef CONFIG_CIFS_DEBUG2
#define DBG2 2
void cifs_dump_detail(struct smb_hdr *);
void cifs_dump_mids(struct TCP_Server_Info *);
#else
#define DBG2 0
#endif
extern int traceSMB; /* flag which enables the function below */
void dump_smb(struct smb_hdr *, int);
Expand Down
44 changes: 11 additions & 33 deletions fs/cifs/cifsacl.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,7 @@ static void access_flags_to_mode(__le32 ace_flags, int type, umode_t *pmode,

if (flags & GENERIC_ALL) {
*pmode |= (S_IRWXUGO & (*pbits_to_set));
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("all perms"));
#endif
cFYI(DBG2, ("all perms"));
return;
}
if ((flags & GENERIC_WRITE) ||
Expand All @@ -230,9 +228,7 @@ static void access_flags_to_mode(__le32 ace_flags, int type, umode_t *pmode,
((flags & FILE_EXEC_RIGHTS) == FILE_EXEC_RIGHTS))
*pmode |= (S_IXUGO & (*pbits_to_set));

#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("access flags 0x%x mode now 0x%x", flags, *pmode));
#endif
cFYI(DBG2, ("access flags 0x%x mode now 0x%x", flags, *pmode));
return;
}

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

#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("mode: 0x%x, access flags now 0x%x", mode, *pace_flags));
#endif
cFYI(DBG2, ("mode: 0x%x, access flags now 0x%x", mode, *pace_flags));
return;
}

Expand Down Expand Up @@ -357,11 +351,9 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,
return;
}

#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("DACL revision %d size %d num aces %d",
cFYI(DBG2, ("DACL revision %d size %d num aces %d",
le16_to_cpu(pdacl->revision), le16_to_cpu(pdacl->size),
le32_to_cpu(pdacl->num_aces)));
#endif

/* reset rwx permissions for user/group/other.
Also, if num_aces is 0 i.e. DACL has no ACEs,
Expand Down Expand Up @@ -494,13 +486,11 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,
le32_to_cpu(pntsd->gsidoffset));
dacloffset = le32_to_cpu(pntsd->dacloffset);
dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset);
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("revision %d type 0x%x ooffset 0x%x goffset 0x%x "
cFYI(DBG2, ("revision %d type 0x%x ooffset 0x%x goffset 0x%x "
"sacloffset 0x%x dacloffset 0x%x",
pntsd->revision, pntsd->type, le32_to_cpu(pntsd->osidoffset),
le32_to_cpu(pntsd->gsidoffset),
le32_to_cpu(pntsd->sacloffset), dacloffset));
#endif
/* cifs_dump_mem("owner_sid: ", owner_sid_ptr, 64); */
rc = parse_sid(owner_sid_ptr, end_of_acl);
if (rc)
Expand Down Expand Up @@ -635,9 +625,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
struct super_block *sb;
struct cifs_sb_info *cifs_sb;

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

if (!inode)
return (rc);
Expand Down Expand Up @@ -668,9 +656,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
}

rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen);
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("SetCIFSACL rc = %d", rc));
#endif
cFYI(DBG2, ("SetCIFSACL rc = %d", rc));
if (unlock_file == TRUE)
atomic_dec(&open_file->wrtPending);
else
Expand All @@ -688,9 +674,7 @@ void acl_to_uid_mode(struct inode *inode, const char *path)
u32 acllen = 0;
int rc = 0;

#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("converting ACL to mode for %s", path));
#endif
cFYI(DBG2, ("converting ACL to mode for %s", path));
pntsd = get_cifs_acl(&acllen, inode, path);

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

#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("set ACL from mode for %s", path));
#endif
cFYI(DBG2, ("set ACL from mode for %s", path));

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

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

#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("build_sec_desc rc: %d", rc));
#endif
cFYI(DBG2, ("build_sec_desc rc: %d", rc));

if (!rc) {
/* Set the security descriptor */
rc = set_cifs_acl(pnntsd, acllen, inode, path);
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("set_cifs_acl rc: %d", rc));
#endif
cFYI(DBG2, ("set_cifs_acl rc: %d", rc));
}

kfree(pnntsd);
Expand Down
10 changes: 1 addition & 9 deletions fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,7 @@ static void cifs_umount_begin(struct vfsmount *vfsmnt, int flags)
struct cifs_sb_info *cifs_sb;
struct cifsTconInfo *tcon;

#ifdef CONFIG_CIFS_DFS_UPCALL
dfs_shrink_umount_helper(vfsmnt);
#endif /* CONFIG CIFS_DFS_UPCALL */

if (!(flags & MNT_FORCE))
return;
Expand Down Expand Up @@ -991,9 +989,7 @@ static int __init
init_cifs(void)
{
int rc = 0;
#ifdef CONFIG_PROC_FS
cifs_proc_init();
#endif
/* INIT_LIST_HEAD(&GlobalServerList);*/ /* BB not implemented yet */
INIT_LIST_HEAD(&GlobalSMBSessionList);
INIT_LIST_HEAD(&GlobalTreeConnectionList);
Expand Down Expand Up @@ -1094,19 +1090,15 @@ init_cifs(void)
out_destroy_inodecache:
cifs_destroy_inodecache();
out_clean_proc:
#ifdef CONFIG_PROC_FS
cifs_proc_clean();
#endif
return rc;
}

static void __exit
exit_cifs(void)
{
cFYI(0, ("exit_cifs"));
#ifdef CONFIG_PROC_FS
cFYI(DBG2, ("exit_cifs"));
cifs_proc_clean();
#endif
#ifdef CONFIG_CIFS_DFS_UPCALL
unregister_key_type(&key_type_dns_resolver);
#endif
Expand Down
8 changes: 6 additions & 2 deletions fs/cifs/cifsproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,13 @@ extern int mode_to_acl(struct inode *inode, const char *path, __u64);
extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *,
const char *);
extern int cifs_umount(struct super_block *, struct cifs_sb_info *);
#ifdef CONFIG_CIFS_DFS_UPCALL
#ifdef CONFIG_CIFS_DFS
extern void dfs_shrink_umount_helper(struct vfsmount *vfsmnt);
#endif
#else
static inline void dfs_shrink_umount_helper(struct vfsmount *vfsmnt)
{
}
#endif /* DFS_UPCALL */
void cifs_proc_init(void);
void cifs_proc_clean(void);

Expand Down
6 changes: 2 additions & 4 deletions fs/cifs/cifssmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
server->maxBuf = min(le32_to_cpu(pSMBr->MaxBufferSize),
(__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);
server->maxRw = le32_to_cpu(pSMBr->MaxRawSize);
cFYI(0, ("Max buf = %d", ses->server->maxBuf));
cFYI(DBG2, ("Max buf = %d", ses->server->maxBuf));
GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey);
server->capabilities = le32_to_cpu(pSMBr->Capabilities);
server->timeAdj = (int)(__s16)le16_to_cpu(pSMBr->ServerTimeZone);
Expand Down Expand Up @@ -1108,9 +1108,7 @@ CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags,
/* check to make sure response data is there */
if (psx_rsp->ReturnedLevel != cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC)) {
pRetData->Type = cpu_to_le32(-1); /* unknown */
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("unknown type"));
#endif
cFYI(DBG2, ("unknown type"));
} else {
if (pSMBr->ByteCount < sizeof(OPEN_PSX_RSP)
+ sizeof(FILE_UNIX_BASIC_INFO)) {
Expand Down
10 changes: 4 additions & 6 deletions fs/cifs/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1753,9 +1753,8 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo *tcon,
if (sb && (CIFS_SB(sb)->rsize > 127 * 1024)) {
if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) {
CIFS_SB(sb)->rsize = 127 * 1024;
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("larger reads not supported by srv"));
#endif
cFYI(DBG2,
("larger reads not supported by srv"));
}
}

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

if ((tcon->unix_ext == 0) && (cifs_sb->rsize > (1024 * 127))) {
cifs_sb->rsize = 1024 * 127;
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("no very large read support, rsize now 127K"));
#endif
cFYI(DBG2,
("no very large read support, rsize now 127K"));
}
if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X))
cifs_sb->wsize = min(cifs_sb->wsize,
Expand Down
13 changes: 4 additions & 9 deletions fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,8 @@ int cifs_close(struct inode *inode, struct file *file)
the struct would be in each open file,
but this should give enough time to
clear the socket */
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("close delay, write pending"));
#endif /* DEBUG2 */
cFYI(DBG2,
("close delay, write pending"));
msleep(timeout);
timeout *= 4;
}
Expand Down Expand Up @@ -1812,9 +1811,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
pTcon = cifs_sb->tcon;

pagevec_init(&lru_pvec, 0);
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("rpages: num pages %d", num_pages));
#endif
cFYI(DBG2, ("rpages: num pages %d", num_pages));
for (i = 0; i < num_pages; ) {
unsigned contig_pages;
struct page *tmp_page;
Expand Down Expand Up @@ -1847,10 +1844,8 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
/* Read size needs to be in multiples of one page */
read_size = min_t(const unsigned int, read_size,
cifs_sb->rsize & PAGE_CACHE_MASK);
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("rpages: read size 0x%x contiguous pages %d",
cFYI(DBG2, ("rpages: read size 0x%x contiguous pages %d",
read_size, contig_pages));
#endif
rc = -EAGAIN;
while (rc == -EAGAIN) {
if ((open_file->invalidHandle) &&
Expand Down
4 changes: 1 addition & 3 deletions fs/cifs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,9 +837,7 @@ static void posix_fill_in_inode(struct inode *tmp_inode,
cFYI(1, ("unknown inode type %d", type));
}

#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("object type: %d", type));
#endif
cFYI(DBG2, ("object type: %d", type));
tmp_inode->i_uid = le64_to_cpu(pData->Uid);
tmp_inode->i_gid = le64_to_cpu(pData->Gid);
tmp_inode->i_nlink = le64_to_cpu(pData->Nlinks);
Expand Down
8 changes: 2 additions & 6 deletions fs/cifs/netmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ static int canonicalize_unc(char *cp)
if (cp[i] == '\\')
break;
if (cp[i] == '/') {
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("change slash to backslash in malformed UNC"));
#endif
cFYI(DBG2, ("change slash to \\ in malformed UNC"));
cp[i] = '\\';
return 1;
}
Expand All @@ -178,9 +176,7 @@ cifs_inet_pton(int address_family, char *cp, void *dst)
} else if (address_family == AF_INET6) {
ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL);
}
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("address conversion returned %d for %s", ret, cp));
#endif
cFYI(DBG2, ("address conversion returned %d for %s", ret, cp));
if (ret > 0)
ret = 1;
return ret;
Expand Down
6 changes: 4 additions & 2 deletions fs/cifs/readdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ static void dump_cifs_file_struct(struct file *file, char *label)
cFYI(1, ("empty dir"));
}
}
#else
static inline void dump_cifs_file_struct(struct file *file, char *label)
{
}
#endif /* DEBUG2 */

/* Returns one if new inode created (which therefore needs to be hashed) */
Expand Down Expand Up @@ -660,9 +664,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
. and .. for the root of a drive and for those we need
to start two entries earlier */

#ifdef CONFIG_CIFS_DEBUG2
dump_cifs_file_struct(file, "In fce ");
#endif
if (((index_to_find < cifsFile->srch_inf.index_of_last_entry) &&
is_dir_changed(file)) ||
(index_to_find < first_entry_in_buffer)) {
Expand Down
4 changes: 0 additions & 4 deletions fs/cifs/sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,6 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,

calc_lanman_hash(ses, lnm_session_key);
ses->flags |= CIFS_SES_LANMAN;
/* #ifdef CONFIG_CIFS_DEBUG2
cifs_dump_mem("cryptkey: ",ses->server->cryptKey,
CIFS_SESS_KEY_SIZE);
#endif */
memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_SESS_KEY_SIZE);
bcc_ptr += CIFS_SESS_KEY_SIZE;

Expand Down
5 changes: 2 additions & 3 deletions fs/cifs/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,8 @@ SendReceiveNoRsp(const unsigned int xid, struct cifsSesInfo *ses,
iov[0].iov_len = in_buf->smb_buf_length + 4;
flags |= CIFS_NO_RESP;
rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags);
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("SendRcvNoR flags %d rc %d", flags, rc));
#endif
cFYI(DBG2, ("SendRcvNoRsp flags %d rc %d", flags, rc));

return rc;
}

Expand Down

0 comments on commit 90c81e0

Please sign in to comment.