[linux-cifs-client] [CIFS] clean up build warnings in backported
kernel series
Jeff Layton
jlayton at redhat.com
Wed May 7 12:40:42 GMT 2008
I had some folks complain that my most recent backporting efforts caused
kernel builds to generate a lot of warnings. Most of them were due to
things like inode/file/super_operations structs that are now const.
This patch is intended for the backported kernel tarballs that Steve and
Shirish have been maintaining. While it makes the code a bit more
unsightly, it does silence the compiler warnings.
From: Jeff Layton <jlayton at redhat.com>
---
fs/cifs/cifsfs.c | 51 ++++++++++++++++++++++++++++++++++++++++++---------
fs/cifs/cifsfs.h | 25 +++++++++++++++++++++++++
fs/cifs/connect.c | 6 +++---
fs/cifs/file.c | 10 ++++++++--
fs/cifs/netmisc.c | 2 ++
5 files changed, 80 insertions(+), 14 deletions(-)
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index d023ade..9bd71b0 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -73,7 +73,11 @@ extern struct task_struct *oplockThread; /* remove sparse warning */
struct task_struct *oplockThread = NULL;
/* extern struct task_struct * dnotifyThread; remove sparse warning */
static struct task_struct *dnotifyThread = NULL;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
static const struct super_operations cifs_super_ops;
+#else
+static struct super_operations cifs_super_ops;
+#endif
unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE;
module_param(CIFSMaxBufSize, int, 0);
MODULE_PARM_DESC(CIFSMaxBufSize, "Network buffer size (not including header). "
@@ -528,7 +532,11 @@ static int cifs_remount(struct super_block *sb, int *flags, char *data)
return 0;
}
-static const struct super_operations cifs_super_ops = {
+static
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
+const
+#endif
+struct super_operations cifs_super_ops = {
.read_inode = cifs_read_inode,
.put_super = cifs_put_super,
.statfs = cifs_statfs,
@@ -660,7 +668,11 @@ static struct file_system_type cifs_fs_type = {
.kill_sb = kill_anon_super,
/* .fs_flags */
};
-const struct inode_operations cifs_dir_inode_ops = {
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
+const
+#endif
+struct inode_operations cifs_dir_inode_ops = {
.create = cifs_create,
.lookup = cifs_lookup,
.getattr = cifs_getattr,
@@ -682,7 +694,10 @@ const struct inode_operations cifs_dir_inode_ops = {
#endif
};
-const struct inode_operations cifs_file_inode_ops = {
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
+const
+#endif
+struct inode_operations cifs_file_inode_ops = {
/* revalidate:cifs_revalidate, */
.setattr = cifs_setattr,
.getattr = cifs_getattr, /* do we need this anymore? */
@@ -696,7 +711,10 @@ const struct inode_operations cifs_file_inode_ops = {
#endif
};
-const struct inode_operations cifs_symlink_inode_ops = {
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
+const
+#endif
+struct inode_operations cifs_symlink_inode_ops = {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
.readlink = cifs_readlink,
#else
@@ -716,7 +734,10 @@ const struct inode_operations cifs_symlink_inode_ops = {
#endif
};
-const struct file_operations cifs_file_ops = {
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
+const
+#endif
+struct file_operations cifs_file_ops = {
.read = do_sync_read,
.write = do_sync_write,
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
@@ -746,7 +767,10 @@ const struct file_operations cifs_file_ops = {
#endif /* CONFIG_CIFS_EXPERIMENTAL */
};
-const struct file_operations cifs_file_direct_ops = {
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
+const
+#endif
+struct file_operations cifs_file_direct_ops = {
/* no mmap, no aio, no readv -
BB reevaluate whether they can be done with directio, no cache */
.read = cifs_user_read,
@@ -769,7 +793,10 @@ const struct file_operations cifs_file_direct_ops = {
.dir_notify = cifs_dir_notify,
#endif /* CONFIG_CIFS_EXPERIMENTAL */
};
-const struct file_operations cifs_file_nobrl_ops = {
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
+const
+#endif
+struct file_operations cifs_file_nobrl_ops = {
.read = do_sync_read,
.write = do_sync_write,
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
@@ -798,7 +825,10 @@ const struct file_operations cifs_file_nobrl_ops = {
#endif /* CONFIG_CIFS_EXPERIMENTAL */
};
-const struct file_operations cifs_file_direct_nobrl_ops = {
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
+const
+#endif
+struct file_operations cifs_file_direct_nobrl_ops = {
/* no mmap, no aio, no readv -
BB reevaluate whether they can be done with directio, no cache */
.read = cifs_user_read,
@@ -821,7 +851,10 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
#endif /* CONFIG_CIFS_EXPERIMENTAL */
};
-const struct file_operations cifs_dir_ops = {
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
+const
+#endif
+struct file_operations cifs_dir_ops = {
.readdir = cifs_readdir,
.release = cifs_closedir,
.read = generic_read_dir,
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index c6d2dea..839f003 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -77,8 +77,13 @@ static inline int cifs_filemap_write_and_wait(struct address_space *mapping)
#define cifs_filemap_write_and_wait(x) filemap_write_and_wait(x)
#endif
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
extern const struct address_space_operations cifs_addr_ops;
extern const struct address_space_operations cifs_addr_ops_smallbuf;
+#else
+extern struct address_space_operations cifs_addr_ops;
+extern struct address_space_operations cifs_addr_ops_smallbuf;
+#endif
/* Functions related to super block operations */
/* extern const struct super_operations cifs_super_ops;*/
@@ -87,7 +92,11 @@ extern void cifs_read_inode(struct inode *);
/* extern void cifs_write_inode(struct inode *); */ /* BB not needed yet */
/* Functions related to inodes */
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
extern const struct inode_operations cifs_dir_inode_ops;
+#else
+extern struct inode_operations cifs_dir_inode_ops;
+#endif
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)
extern int cifs_create(struct inode *, struct dentry *, int,
struct nameidata *);
@@ -109,14 +118,26 @@ extern int cifs_rename(struct inode *, struct dentry *, struct inode *,
extern int cifs_revalidate(struct dentry *);
extern int cifs_setattr(struct dentry *, struct iattr *);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
extern const struct inode_operations cifs_file_inode_ops;
extern const struct inode_operations cifs_symlink_inode_ops;
+#else
+extern struct inode_operations cifs_file_inode_ops;
+extern struct inode_operations cifs_symlink_inode_ops;
+#endif
/* Functions related to files and directories */
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
extern const struct file_operations cifs_file_ops;
extern const struct file_operations cifs_file_direct_ops; /* if directio mnt */
extern const struct file_operations cifs_file_nobrl_ops;
extern const struct file_operations cifs_file_direct_nobrl_ops; /* no brlocks */
+#else
+extern struct file_operations cifs_file_ops;
+extern struct file_operations cifs_file_direct_ops; /* if directio mnt */
+extern struct file_operations cifs_file_nobrl_ops;
+extern struct file_operations cifs_file_direct_nobrl_ops; /* no brlocks */
+#endif
extern int cifs_open(struct inode *inode, struct file *file);
extern int cifs_close(struct inode *inode, struct file *file);
extern int cifs_closedir(struct inode *inode, struct file *file);
@@ -132,7 +153,11 @@ extern int cifs_flush(struct file *, fl_owner_t id);
extern int cifs_flush(struct file *);
#endif /* 2.6.17 */
extern int cifs_file_mmap(struct file * , struct vm_area_struct *);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
extern const struct file_operations cifs_dir_ops;
+#else
+extern struct file_operations cifs_dir_ops;
+#endif
extern int cifs_dir_open(struct inode *inode, struct file *file);
extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir);
extern int cifs_dir_notify(struct file *, unsigned long arg);
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 53f3db8..e5fb205 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1850,16 +1850,16 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo *tcon,
cFYI(1, ("very large write cap"));
#endif /* CIFS_DEBUG2 */
if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) {
- if (vol_info == NULL)
+ if (vol_info == NULL) {
cFYI(1, ("resetting capabilities failed"));
- else
+ } else {
cERROR(1, ("Negotiating Unix capabilities "
"with the server failed. Consider "
"mounting with the Unix Extensions\n"
"disabled, if problems are found, "
"by specifying the nounix mount "
"option."));
-
+ }
}
}
}
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index cce611a..da93580 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2322,7 +2322,10 @@ static int cifs_prepare_write(struct file *file, struct page *page,
return 0;
}
-const struct address_space_operations cifs_addr_ops = {
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
+const
+#endif
+struct address_space_operations cifs_addr_ops = {
.readpage = cifs_readpage,
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)
.readpages = cifs_readpages,
@@ -2345,7 +2348,10 @@ const struct address_space_operations cifs_addr_ops = {
* contain the header plus one complete page of data. Otherwise, we need
* to leave cifs_readpages out of the address space operations.
*/
-const struct address_space_operations cifs_addr_ops_smallbuf = {
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
+const
+#endif
+struct address_space_operations cifs_addr_ops_smallbuf = {
.readpage = cifs_readpage,
.writepage = cifs_writepage,
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 14)
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index 173ed1c..82a4072 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -133,6 +133,7 @@ static const struct smb_to_posix_error mapping_table_ERRHRD[] = {
};
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19)
/* if the mount helper is missing we need to reverse the 1st slash
from '/' to backslash in order to format the UNC properly for
ip address parsing and for tree connect (unless the user
@@ -159,6 +160,7 @@ static int canonicalize_unc(char *cp)
}
return 0;
}
+#endif
/* Convert string containing dotted ip address to binary form */
/* returns 0 if invalid address */
More information about the linux-cifs-client
mailing list