From: Adrian Bunk This patch contains the following possible cleanups: - make needlessly global functions static - there's usually no reason for functions in C files to be marked as inline - gcc usually knows best whether or not to inline a function Signed-off-by: Adrian Bunk Acked-by: Michael Halcrow Signed-off-by: Andrew Morton --- fs/ecryptfs/crypto.c | 53 ++++++++++++++++++++------------ fs/ecryptfs/ecryptfs_kernel.h | 15 --------- fs/ecryptfs/inode.c | 11 +++--- fs/ecryptfs/keystore.c | 2 - fs/ecryptfs/main.c | 4 +- fs/ecryptfs/mmap.c | 2 - fs/ecryptfs/super.c | 4 +- 7 files changed, 46 insertions(+), 45 deletions(-) diff -puN fs/ecryptfs/crypto.c~fs-ecryptfs-possible-cleanups fs/ecryptfs/crypto.c --- a/fs/ecryptfs/crypto.c~fs-ecryptfs-possible-cleanups +++ a/fs/ecryptfs/crypto.c @@ -36,6 +36,17 @@ #include #include "ecryptfs_kernel.h" +static int +ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, + struct page *dst_page, int dst_offset, + struct page *src_page, int src_offset, int size, + unsigned char *iv); +static int +ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, + struct page *dst_page, int dst_offset, + struct page *src_page, int src_offset, int size, + unsigned char *iv); + /** * ecryptfs_to_hex * @dst: Buffer to take hex character representation of contents of @@ -43,7 +54,7 @@ * @src: Buffer to be converted to a hex string respresentation * @src_size: number of bytes to convert */ -inline void ecryptfs_to_hex(char *dst, char *src, int src_size) +void ecryptfs_to_hex(char *dst, char *src, int src_size) { int x; @@ -58,7 +69,7 @@ inline void ecryptfs_to_hex(char *dst, c * @src: Buffer to be converted from a hex string respresentation to raw value * @dst_size: size of dst buffer, or number of hex characters pairs to convert */ -inline void ecryptfs_from_hex(char *dst, char *src, int dst_size) +void ecryptfs_from_hex(char *dst, char *src, int dst_size) { int x; char tmp[3] = { 0, }; @@ -80,8 +91,9 @@ inline void ecryptfs_from_hex(char *dst, * Uses the allocated crypto context that crypt_stat references to * generate the MD5 sum of the contents of src. */ -int ecryptfs_calculate_md5(char *dst, struct ecryptfs_crypt_stat *crypt_stat, - char *src, int len) +static int ecryptfs_calculate_md5(char *dst, + struct ecryptfs_crypt_stat *crypt_stat, + char *src, int len) { int rc = 0; struct scatterlist sg; @@ -117,8 +129,8 @@ out: * * Returns zero on success; non-zero on error. */ -int ecryptfs_derive_iv(char *iv, struct ecryptfs_crypt_stat *crypt_stat, - pgoff_t offset) +static int ecryptfs_derive_iv(char *iv, struct ecryptfs_crypt_stat *crypt_stat, + pgoff_t offset) { int rc = 0; char dst[MD5_DIGEST_SIZE]; @@ -271,7 +283,7 @@ out: return rc; } -void +static void ecryptfs_extent_to_lwr_pg_idx_and_offset(unsigned long *lower_page_idx, int *byte_offset, struct ecryptfs_crypt_stat *crypt_stat, @@ -313,9 +325,10 @@ ecryptfs_extent_to_lwr_pg_idx_and_offset (*byte_offset)); } -int ecryptfs_write_out_page(struct ecryptfs_page_crypt_context *ctx, - struct page *lower_page, struct inode *lower_inode, - int byte_offset_in_page, int bytes_to_write) +static int ecryptfs_write_out_page(struct ecryptfs_page_crypt_context *ctx, + struct page *lower_page, + struct inode *lower_inode, + int byte_offset_in_page, int bytes_to_write) { int rc = 0; @@ -343,9 +356,11 @@ out: return rc; } -int ecryptfs_read_in_page(struct ecryptfs_page_crypt_context *ctx, - struct page **lower_page, struct inode *lower_inode, - unsigned long lower_page_idx, int byte_offset_in_page) +static int ecryptfs_read_in_page(struct ecryptfs_page_crypt_context *ctx, + struct page **lower_page, + struct inode *lower_inode, + unsigned long lower_page_idx, + int byte_offset_in_page) { int rc = 0; @@ -674,7 +689,7 @@ out: * * Returns the number of bytes encrypted */ -int +static int ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, struct page *dst_page, int dst_offset, struct page *src_page, int src_offset, int size, @@ -696,7 +711,7 @@ ecryptfs_encrypt_page_offset(struct ecry * * Returns the number of bytes decrypted */ -int +static int ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, struct page *dst_page, int dst_offset, struct page *src_page, int src_offset, int size, @@ -1302,7 +1317,7 @@ static int parse_header_metadata(struct * compatibility for files created with the prior versions of * eCryptfs. */ -inline void set_default_header_data(struct ecryptfs_crypt_stat *crypt_stat) +static void set_default_header_data(struct ecryptfs_crypt_stat *crypt_stat) { crypt_stat->header_extent_size = 4096; crypt_stat->num_header_extents_at_front = 1; @@ -1316,9 +1331,9 @@ inline void set_default_header_data(stru * * Returns zero on success */ -int ecryptfs_read_headers_virt(char *page_virt, - struct ecryptfs_crypt_stat *crypt_stat, - struct dentry *ecryptfs_dentry) +static int ecryptfs_read_headers_virt(char *page_virt, + struct ecryptfs_crypt_stat *crypt_stat, + struct dentry *ecryptfs_dentry) { int rc = 0; int offset; diff -puN fs/ecryptfs/ecryptfs_kernel.h~fs-ecryptfs-possible-cleanups fs/ecryptfs/ecryptfs_kernel.h --- a/fs/ecryptfs/ecryptfs_kernel.h~fs-ecryptfs-possible-cleanups +++ a/fs/ecryptfs/ecryptfs_kernel.h @@ -400,17 +400,12 @@ int ecryptfs_encode_filename(struct ecry const char *name, int length, char **encoded_name); struct dentry *ecryptfs_lower_dentry(struct dentry *this_dentry); -void ecryptfs_copy_attr_times(struct inode *dest, const struct inode *src); void ecryptfs_copy_attr_atime(struct inode *dest, const struct inode *src); void ecryptfs_copy_attr_all(struct inode *dest, const struct inode *src); void ecryptfs_copy_inode_size(struct inode *dst, const struct inode *src); void ecryptfs_dump_hex(char *data, int bytes); int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg, int sg_size); -int ecryptfs_calculate_md5(char *dst, struct ecryptfs_crypt_stat *crypt_stat, - char *src, int len); -int ecryptfs_derive_iv(char *iv, struct ecryptfs_crypt_stat *crypt_stat, - pgoff_t offset); int ecryptfs_compute_root_iv(struct ecryptfs_crypt_stat *crypt_stat); void ecryptfs_rotate_iv(unsigned char *iv); void ecryptfs_init_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat); @@ -439,17 +434,7 @@ int ecryptfs_writepage_and_release_lower struct inode *lower_inode, struct writeback_control *wbc); int ecryptfs_encrypt_page(struct ecryptfs_page_crypt_context *ctx); -int -ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, - struct page *dst_page, int dst_offset, - struct page *src_page, int src_offset, int size, - unsigned char *iv); int ecryptfs_decrypt_page(struct file *file, struct page *page); -int -ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, - struct page *dst_page, int dst_offset, - struct page *src_page, int src_offset, int size, - unsigned char *iv); int ecryptfs_write_headers(struct dentry *ecryptfs_dentry, struct file *lower_file); int ecryptfs_write_headers_virt(char *page_virt, diff -puN fs/ecryptfs/inode.c~fs-ecryptfs-possible-cleanups fs/ecryptfs/inode.c --- a/fs/ecryptfs/inode.c~fs-ecryptfs-possible-cleanups +++ a/fs/ecryptfs/inode.c @@ -32,7 +32,7 @@ #include #include "ecryptfs_kernel.h" -static inline struct dentry *lock_parent(struct dentry *dentry) +static struct dentry *lock_parent(struct dentry *dentry) { struct dentry *dir; @@ -41,13 +41,13 @@ static inline struct dentry *lock_parent return dir; } -static inline void unlock_parent(struct dentry *dentry) +static void unlock_parent(struct dentry *dentry) { mutex_unlock(&(dentry->d_parent->d_inode->i_mutex)); dput(dentry->d_parent); } -static inline void unlock_dir(struct dentry *dir) +static void unlock_dir(struct dentry *dir) { mutex_unlock(&dir->d_inode->i_mutex); dput(dir); @@ -66,7 +66,8 @@ void ecryptfs_copy_attr_atime(struct ino dest->i_atime = src->i_atime; } -void ecryptfs_copy_attr_times(struct inode *dest, const struct inode *src) +static void ecryptfs_copy_attr_times(struct inode *dest, + const struct inode *src) { ASSERT(dest != NULL); ASSERT(src != NULL); @@ -771,7 +772,7 @@ out: return ERR_PTR(rc); } -static inline void +static void ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr) { /* Free the char* */ diff -puN fs/ecryptfs/keystore.c~fs-ecryptfs-possible-cleanups fs/ecryptfs/keystore.c --- a/fs/ecryptfs/keystore.c~fs-ecryptfs-possible-cleanups +++ a/fs/ecryptfs/keystore.c @@ -724,7 +724,7 @@ out: * * Returns zero on success; non-zero on error. */ -int +static int write_tag_11_packet(char *dest, int max, char *contents, int contents_length, int *packet_length) { diff -puN fs/ecryptfs/main.c~fs-ecryptfs-possible-cleanups fs/ecryptfs/main.c --- a/fs/ecryptfs/main.c~fs-ecryptfs-possible-cleanups +++ a/fs/ecryptfs/main.c @@ -141,7 +141,7 @@ static match_table_t tokens = { * * Returns zero on good version; non-zero otherwise */ -int ecryptfs_verify_version(u16 version) +static int ecryptfs_verify_version(u16 version) { int rc = 0; unsigned char major; @@ -322,7 +322,7 @@ struct kmem_cache *ecryptfs_sb_info_cach * * Preform the cleanup for ecryptfs_read_super() */ -static inline void ecryptfs_cleanup_read_super(struct super_block *sb) +static void ecryptfs_cleanup_read_super(struct super_block *sb) { up_write(&sb->s_umount); deactivate_super(sb); diff -puN fs/ecryptfs/mmap.c~fs-ecryptfs-possible-cleanups fs/ecryptfs/mmap.c --- a/fs/ecryptfs/mmap.c~fs-ecryptfs-possible-cleanups +++ a/fs/ecryptfs/mmap.c @@ -396,7 +396,7 @@ out: return rc; } -void ecryptfs_unmap_and_release_lower_page(struct page *lower_page) +static void ecryptfs_unmap_and_release_lower_page(struct page *lower_page) { kunmap(lower_page); ecryptfs_printk(KERN_DEBUG, "Unlocking lower page with index = " diff -puN fs/ecryptfs/super.c~fs-ecryptfs-possible-cleanups fs/ecryptfs/super.c --- a/fs/ecryptfs/super.c~fs-ecryptfs-possible-cleanups +++ a/fs/ecryptfs/super.c @@ -124,7 +124,7 @@ static void ecryptfs_put_super(struct su * Get the filesystem statistics. Currently, we let this pass right through * to the lower filesystem and take no action ourselves. */ -static inline int ecryptfs_statfs(struct dentry *dentry, struct kstatfs *buf) +static int ecryptfs_statfs(struct dentry *dentry, struct kstatfs *buf) { return vfs_statfs(ecryptfs_dentry_to_lower(dentry), buf); } @@ -139,7 +139,7 @@ static inline int ecryptfs_statfs(struct * on the inode free list. We use this to drop out reference to the * lower inode. */ -static inline void ecryptfs_clear_inode(struct inode *inode) +static void ecryptfs_clear_inode(struct inode *inode) { iput(ecryptfs_inode_to_lower(inode)); } _