f2fs: clean up long variable names
This patch includes simple clean-ups to reduce unnecessary long variable names. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
This commit is contained in:
parent
454ae7e519
commit
e112326805
2 changed files with 47 additions and 45 deletions
|
@ -26,7 +26,7 @@
|
||||||
#include "xattr.h"
|
#include "xattr.h"
|
||||||
|
|
||||||
static size_t f2fs_xattr_generic_list(struct dentry *dentry, char *list,
|
static size_t f2fs_xattr_generic_list(struct dentry *dentry, char *list,
|
||||||
size_t list_size, const char *name, size_t name_len, int type)
|
size_t list_size, const char *name, size_t len, int type)
|
||||||
{
|
{
|
||||||
struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
|
struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
|
||||||
int total_len, prefix_len = 0;
|
int total_len, prefix_len = 0;
|
||||||
|
@ -53,11 +53,11 @@ static size_t f2fs_xattr_generic_list(struct dentry *dentry, char *list,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
total_len = prefix_len + name_len + 1;
|
total_len = prefix_len + len + 1;
|
||||||
if (list && total_len <= list_size) {
|
if (list && total_len <= list_size) {
|
||||||
memcpy(list, prefix, prefix_len);
|
memcpy(list, prefix, prefix_len);
|
||||||
memcpy(list + prefix_len, name, name_len);
|
memcpy(list + prefix_len, name, len);
|
||||||
list[prefix_len + name_len] = '\0';
|
list[prefix_len + len] = '\0';
|
||||||
}
|
}
|
||||||
return total_len;
|
return total_len;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ static int f2fs_xattr_generic_set(struct dentry *dentry, const char *name,
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t f2fs_xattr_advise_list(struct dentry *dentry, char *list,
|
static size_t f2fs_xattr_advise_list(struct dentry *dentry, char *list,
|
||||||
size_t list_size, const char *name, size_t name_len, int type)
|
size_t list_size, const char *name, size_t len, int type)
|
||||||
{
|
{
|
||||||
const char *xname = F2FS_SYSTEM_ADVISE_PREFIX;
|
const char *xname = F2FS_SYSTEM_ADVISE_PREFIX;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
@ -155,9 +155,10 @@ static int f2fs_xattr_advise_set(struct dentry *dentry, const char *name,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_F2FS_FS_SECURITY
|
#ifdef CONFIG_F2FS_FS_SECURITY
|
||||||
static int __f2fs_setxattr(struct inode *inode, int name_index,
|
static int __f2fs_setxattr(struct inode *inode, int index,
|
||||||
const char *name, const void *value, size_t value_len,
|
const char *name, const void *value, size_t size,
|
||||||
struct page *ipage);
|
struct page *ipage);
|
||||||
|
|
||||||
static int f2fs_initxattrs(struct inode *inode, const struct xattr *xattr_array,
|
static int f2fs_initxattrs(struct inode *inode, const struct xattr *xattr_array,
|
||||||
void *page)
|
void *page)
|
||||||
{
|
{
|
||||||
|
@ -241,26 +242,26 @@ const struct xattr_handler *f2fs_xattr_handlers[] = {
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline const struct xattr_handler *f2fs_xattr_handler(int name_index)
|
static inline const struct xattr_handler *f2fs_xattr_handler(int index)
|
||||||
{
|
{
|
||||||
const struct xattr_handler *handler = NULL;
|
const struct xattr_handler *handler = NULL;
|
||||||
|
|
||||||
if (name_index > 0 && name_index < ARRAY_SIZE(f2fs_xattr_handler_map))
|
if (index > 0 && index < ARRAY_SIZE(f2fs_xattr_handler_map))
|
||||||
handler = f2fs_xattr_handler_map[name_index];
|
handler = f2fs_xattr_handler_map[index];
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct f2fs_xattr_entry *__find_xattr(void *base_addr, int name_index,
|
static struct f2fs_xattr_entry *__find_xattr(void *base_addr, int index,
|
||||||
size_t name_len, const char *name)
|
size_t len, const char *name)
|
||||||
{
|
{
|
||||||
struct f2fs_xattr_entry *entry;
|
struct f2fs_xattr_entry *entry;
|
||||||
|
|
||||||
list_for_each_xattr(entry, base_addr) {
|
list_for_each_xattr(entry, base_addr) {
|
||||||
if (entry->e_name_index != name_index)
|
if (entry->e_name_index != index)
|
||||||
continue;
|
continue;
|
||||||
if (entry->e_name_len != name_len)
|
if (entry->e_name_len != len)
|
||||||
continue;
|
continue;
|
||||||
if (!memcmp(entry->e_name, name, name_len))
|
if (!memcmp(entry->e_name, name, len))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return entry;
|
return entry;
|
||||||
|
@ -396,42 +397,43 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int f2fs_getxattr(struct inode *inode, int name_index, const char *name,
|
int f2fs_getxattr(struct inode *inode, int index, const char *name,
|
||||||
void *buffer, size_t buffer_size)
|
void *buffer, size_t buffer_size)
|
||||||
{
|
{
|
||||||
struct f2fs_xattr_entry *entry;
|
struct f2fs_xattr_entry *entry;
|
||||||
void *base_addr;
|
void *base_addr;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
size_t value_len, name_len;
|
size_t size, len;
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
name_len = strlen(name);
|
|
||||||
if (name_len > F2FS_NAME_LEN)
|
len = strlen(name);
|
||||||
|
if (len > F2FS_NAME_LEN)
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
|
|
||||||
base_addr = read_all_xattrs(inode, NULL);
|
base_addr = read_all_xattrs(inode, NULL);
|
||||||
if (!base_addr)
|
if (!base_addr)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
entry = __find_xattr(base_addr, name_index, name_len, name);
|
entry = __find_xattr(base_addr, index, len, name);
|
||||||
if (IS_XATTR_LAST_ENTRY(entry)) {
|
if (IS_XATTR_LAST_ENTRY(entry)) {
|
||||||
error = -ENODATA;
|
error = -ENODATA;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_len = le16_to_cpu(entry->e_value_size);
|
size = le16_to_cpu(entry->e_value_size);
|
||||||
|
|
||||||
if (buffer && value_len > buffer_size) {
|
if (buffer && size > buffer_size) {
|
||||||
error = -ERANGE;
|
error = -ERANGE;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
char *pval = entry->e_name + entry->e_name_len;
|
char *pval = entry->e_name + entry->e_name_len;
|
||||||
memcpy(buffer, pval, value_len);
|
memcpy(buffer, pval, size);
|
||||||
}
|
}
|
||||||
error = value_len;
|
error = size;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
kzfree(base_addr);
|
kzfree(base_addr);
|
||||||
|
@ -475,15 +477,15 @@ cleanup:
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __f2fs_setxattr(struct inode *inode, int name_index,
|
static int __f2fs_setxattr(struct inode *inode, int index,
|
||||||
const char *name, const void *value, size_t value_len,
|
const char *name, const void *value, size_t size,
|
||||||
struct page *ipage)
|
struct page *ipage)
|
||||||
{
|
{
|
||||||
struct f2fs_inode_info *fi = F2FS_I(inode);
|
struct f2fs_inode_info *fi = F2FS_I(inode);
|
||||||
struct f2fs_xattr_entry *here, *last;
|
struct f2fs_xattr_entry *here, *last;
|
||||||
void *base_addr;
|
void *base_addr;
|
||||||
int found, newsize;
|
int found, newsize;
|
||||||
size_t name_len;
|
size_t len;
|
||||||
__u32 new_hsize;
|
__u32 new_hsize;
|
||||||
int error = -ENOMEM;
|
int error = -ENOMEM;
|
||||||
|
|
||||||
|
@ -491,11 +493,11 @@ static int __f2fs_setxattr(struct inode *inode, int name_index,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
value_len = 0;
|
size = 0;
|
||||||
|
|
||||||
name_len = strlen(name);
|
len = strlen(name);
|
||||||
|
|
||||||
if (name_len > F2FS_NAME_LEN || value_len > MAX_VALUE_LEN(inode))
|
if (len > F2FS_NAME_LEN || size > MAX_VALUE_LEN(inode))
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
|
|
||||||
base_addr = read_all_xattrs(inode, ipage);
|
base_addr = read_all_xattrs(inode, ipage);
|
||||||
|
@ -503,7 +505,7 @@ static int __f2fs_setxattr(struct inode *inode, int name_index,
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
/* find entry with wanted name. */
|
/* find entry with wanted name. */
|
||||||
here = __find_xattr(base_addr, name_index, name_len, name);
|
here = __find_xattr(base_addr, index, len, name);
|
||||||
|
|
||||||
found = IS_XATTR_LAST_ENTRY(here) ? 0 : 1;
|
found = IS_XATTR_LAST_ENTRY(here) ? 0 : 1;
|
||||||
last = here;
|
last = here;
|
||||||
|
@ -511,8 +513,7 @@ static int __f2fs_setxattr(struct inode *inode, int name_index,
|
||||||
while (!IS_XATTR_LAST_ENTRY(last))
|
while (!IS_XATTR_LAST_ENTRY(last))
|
||||||
last = XATTR_NEXT_ENTRY(last);
|
last = XATTR_NEXT_ENTRY(last);
|
||||||
|
|
||||||
newsize = XATTR_ALIGN(sizeof(struct f2fs_xattr_entry) +
|
newsize = XATTR_ALIGN(sizeof(struct f2fs_xattr_entry) + len + size);
|
||||||
name_len + value_len);
|
|
||||||
|
|
||||||
/* 1. Check space */
|
/* 1. Check space */
|
||||||
if (value) {
|
if (value) {
|
||||||
|
@ -555,12 +556,12 @@ static int __f2fs_setxattr(struct inode *inode, int name_index,
|
||||||
* We just write new entry.
|
* We just write new entry.
|
||||||
*/
|
*/
|
||||||
memset(last, 0, newsize);
|
memset(last, 0, newsize);
|
||||||
last->e_name_index = name_index;
|
last->e_name_index = index;
|
||||||
last->e_name_len = name_len;
|
last->e_name_len = len;
|
||||||
memcpy(last->e_name, name, name_len);
|
memcpy(last->e_name, name, len);
|
||||||
pval = last->e_name + name_len;
|
pval = last->e_name + len;
|
||||||
memcpy(pval, value, value_len);
|
memcpy(pval, value, size);
|
||||||
last->e_value_size = cpu_to_le16(value_len);
|
last->e_value_size = cpu_to_le16(size);
|
||||||
new_hsize += newsize;
|
new_hsize += newsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,8 +584,9 @@ exit:
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int f2fs_setxattr(struct inode *inode, int name_index, const char *name,
|
int f2fs_setxattr(struct inode *inode, int index, const char *name,
|
||||||
const void *value, size_t value_len, struct page *ipage)
|
const void *value, size_t size,
|
||||||
|
struct page *ipage)
|
||||||
{
|
{
|
||||||
struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
|
struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
|
||||||
int err;
|
int err;
|
||||||
|
@ -594,7 +596,7 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name,
|
||||||
f2fs_lock_op(sbi);
|
f2fs_lock_op(sbi);
|
||||||
/* protect xattr_ver */
|
/* protect xattr_ver */
|
||||||
down_write(&F2FS_I(inode)->i_sem);
|
down_write(&F2FS_I(inode)->i_sem);
|
||||||
err = __f2fs_setxattr(inode, name_index, name, value, value_len, ipage);
|
err = __f2fs_setxattr(inode, index, name, value, size, ipage);
|
||||||
up_write(&F2FS_I(inode)->i_sem);
|
up_write(&F2FS_I(inode)->i_sem);
|
||||||
f2fs_unlock_op(sbi);
|
f2fs_unlock_op(sbi);
|
||||||
|
|
||||||
|
|
|
@ -120,12 +120,12 @@ extern ssize_t f2fs_listxattr(struct dentry *, char *, size_t);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define f2fs_xattr_handlers NULL
|
#define f2fs_xattr_handlers NULL
|
||||||
static inline int f2fs_setxattr(struct inode *inode, int name_index,
|
static inline int f2fs_setxattr(struct inode *inode, int index,
|
||||||
const char *name, const void *value, size_t value_len)
|
const char *name, const void *value, size_t size)
|
||||||
{
|
{
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
static inline int f2fs_getxattr(struct inode *inode, int name_index,
|
static inline int f2fs_getxattr(struct inode *inode, int index,
|
||||||
const char *name, void *buffer, size_t buffer_size)
|
const char *name, void *buffer, size_t buffer_size)
|
||||||
{
|
{
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
Loading…
Add table
Reference in a new issue