diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2014-04-22 23:17:25 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2014-05-06 21:21:56 -0400 |
commit | e112326805a50ee2016faf0971660122471f7c04 (patch) | |
tree | da96339315e39b2f1ae9a395aac425dff9de2be8 | |
parent | 454ae7e519f90db11c0ae082df12a162d2e206ce (diff) |
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>
-rw-r--r-- | fs/f2fs/xattr.c | 86 | ||||
-rw-r--r-- | fs/f2fs/xattr.h | 6 |
2 files changed, 47 insertions, 45 deletions
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index 503c2451131e..1de057d9e7a7 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "xattr.h" | 26 | #include "xattr.h" |
27 | 27 | ||
28 | static size_t f2fs_xattr_generic_list(struct dentry *dentry, char *list, | 28 | static size_t f2fs_xattr_generic_list(struct dentry *dentry, char *list, |
29 | size_t list_size, const char *name, size_t name_len, int type) | 29 | size_t list_size, const char *name, size_t len, int type) |
30 | { | 30 | { |
31 | struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb); | 31 | struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb); |
32 | int total_len, prefix_len = 0; | 32 | int total_len, prefix_len = 0; |
@@ -53,11 +53,11 @@ static size_t f2fs_xattr_generic_list(struct dentry *dentry, char *list, | |||
53 | return -EINVAL; | 53 | return -EINVAL; |
54 | } | 54 | } |
55 | 55 | ||
56 | total_len = prefix_len + name_len + 1; | 56 | total_len = prefix_len + len + 1; |
57 | if (list && total_len <= list_size) { | 57 | if (list && total_len <= list_size) { |
58 | memcpy(list, prefix, prefix_len); | 58 | memcpy(list, prefix, prefix_len); |
59 | memcpy(list + prefix_len, name, name_len); | 59 | memcpy(list + prefix_len, name, len); |
60 | list[prefix_len + name_len] = '\0'; | 60 | list[prefix_len + len] = '\0'; |
61 | } | 61 | } |
62 | return total_len; | 62 | return total_len; |
63 | } | 63 | } |
@@ -112,7 +112,7 @@ static int f2fs_xattr_generic_set(struct dentry *dentry, const char *name, | |||
112 | } | 112 | } |
113 | 113 | ||
114 | static size_t f2fs_xattr_advise_list(struct dentry *dentry, char *list, | 114 | static size_t f2fs_xattr_advise_list(struct dentry *dentry, char *list, |
115 | size_t list_size, const char *name, size_t name_len, int type) | 115 | size_t list_size, const char *name, size_t len, int type) |
116 | { | 116 | { |
117 | const char *xname = F2FS_SYSTEM_ADVISE_PREFIX; | 117 | const char *xname = F2FS_SYSTEM_ADVISE_PREFIX; |
118 | size_t size; | 118 | size_t size; |
@@ -155,9 +155,10 @@ static int f2fs_xattr_advise_set(struct dentry *dentry, const char *name, | |||
155 | } | 155 | } |
156 | 156 | ||
157 | #ifdef CONFIG_F2FS_FS_SECURITY | 157 | #ifdef CONFIG_F2FS_FS_SECURITY |
158 | static int __f2fs_setxattr(struct inode *inode, int name_index, | 158 | static int __f2fs_setxattr(struct inode *inode, int index, |
159 | const char *name, const void *value, size_t value_len, | 159 | const char *name, const void *value, size_t size, |
160 | struct page *ipage); | 160 | struct page *ipage); |
161 | |||
161 | static int f2fs_initxattrs(struct inode *inode, const struct xattr *xattr_array, | 162 | static int f2fs_initxattrs(struct inode *inode, const struct xattr *xattr_array, |
162 | void *page) | 163 | void *page) |
163 | { | 164 | { |
@@ -241,26 +242,26 @@ const struct xattr_handler *f2fs_xattr_handlers[] = { | |||
241 | NULL, | 242 | NULL, |
242 | }; | 243 | }; |
243 | 244 | ||
244 | static inline const struct xattr_handler *f2fs_xattr_handler(int name_index) | 245 | static inline const struct xattr_handler *f2fs_xattr_handler(int index) |
245 | { | 246 | { |
246 | const struct xattr_handler *handler = NULL; | 247 | const struct xattr_handler *handler = NULL; |
247 | 248 | ||
248 | if (name_index > 0 && name_index < ARRAY_SIZE(f2fs_xattr_handler_map)) | 249 | if (index > 0 && index < ARRAY_SIZE(f2fs_xattr_handler_map)) |
249 | handler = f2fs_xattr_handler_map[name_index]; | 250 | handler = f2fs_xattr_handler_map[index]; |
250 | return handler; | 251 | return handler; |
251 | } | 252 | } |
252 | 253 | ||
253 | static struct f2fs_xattr_entry *__find_xattr(void *base_addr, int name_index, | 254 | static struct f2fs_xattr_entry *__find_xattr(void *base_addr, int index, |
254 | size_t name_len, const char *name) | 255 | size_t len, const char *name) |
255 | { | 256 | { |
256 | struct f2fs_xattr_entry *entry; | 257 | struct f2fs_xattr_entry *entry; |
257 | 258 | ||
258 | list_for_each_xattr(entry, base_addr) { | 259 | list_for_each_xattr(entry, base_addr) { |
259 | if (entry->e_name_index != name_index) | 260 | if (entry->e_name_index != index) |
260 | continue; | 261 | continue; |
261 | if (entry->e_name_len != name_len) | 262 | if (entry->e_name_len != len) |
262 | continue; | 263 | continue; |
263 | if (!memcmp(entry->e_name, name, name_len)) | 264 | if (!memcmp(entry->e_name, name, len)) |
264 | break; | 265 | break; |
265 | } | 266 | } |
266 | return entry; | 267 | return entry; |
@@ -396,42 +397,43 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize, | |||
396 | return 0; | 397 | return 0; |
397 | } | 398 | } |
398 | 399 | ||
399 | int f2fs_getxattr(struct inode *inode, int name_index, const char *name, | 400 | int f2fs_getxattr(struct inode *inode, int index, const char *name, |
400 | void *buffer, size_t buffer_size) | 401 | void *buffer, size_t buffer_size) |
401 | { | 402 | { |
402 | struct f2fs_xattr_entry *entry; | 403 | struct f2fs_xattr_entry *entry; |
403 | void *base_addr; | 404 | void *base_addr; |
404 | int error = 0; | 405 | int error = 0; |
405 | size_t value_len, name_len; | 406 | size_t size, len; |
406 | 407 | ||
407 | if (name == NULL) | 408 | if (name == NULL) |
408 | return -EINVAL; | 409 | return -EINVAL; |
409 | name_len = strlen(name); | 410 | |
410 | if (name_len > F2FS_NAME_LEN) | 411 | len = strlen(name); |
412 | if (len > F2FS_NAME_LEN) | ||
411 | return -ERANGE; | 413 | return -ERANGE; |
412 | 414 | ||
413 | base_addr = read_all_xattrs(inode, NULL); | 415 | base_addr = read_all_xattrs(inode, NULL); |
414 | if (!base_addr) | 416 | if (!base_addr) |
415 | return -ENOMEM; | 417 | return -ENOMEM; |
416 | 418 | ||
417 | entry = __find_xattr(base_addr, name_index, name_len, name); | 419 | entry = __find_xattr(base_addr, index, len, name); |
418 | if (IS_XATTR_LAST_ENTRY(entry)) { | 420 | if (IS_XATTR_LAST_ENTRY(entry)) { |
419 | error = -ENODATA; | 421 | error = -ENODATA; |
420 | goto cleanup; | 422 | goto cleanup; |
421 | } | 423 | } |
422 | 424 | ||
423 | value_len = le16_to_cpu(entry->e_value_size); | 425 | size = le16_to_cpu(entry->e_value_size); |
424 | 426 | ||
425 | if (buffer && value_len > buffer_size) { | 427 | if (buffer && size > buffer_size) { |
426 | error = -ERANGE; | 428 | error = -ERANGE; |
427 | goto cleanup; | 429 | goto cleanup; |
428 | } | 430 | } |
429 | 431 | ||
430 | if (buffer) { | 432 | if (buffer) { |
431 | char *pval = entry->e_name + entry->e_name_len; | 433 | char *pval = entry->e_name + entry->e_name_len; |
432 | memcpy(buffer, pval, value_len); | 434 | memcpy(buffer, pval, size); |
433 | } | 435 | } |
434 | error = value_len; | 436 | error = size; |
435 | 437 | ||
436 | cleanup: | 438 | cleanup: |
437 | kzfree(base_addr); | 439 | kzfree(base_addr); |
@@ -475,15 +477,15 @@ cleanup: | |||
475 | return error; | 477 | return error; |
476 | } | 478 | } |
477 | 479 | ||
478 | static int __f2fs_setxattr(struct inode *inode, int name_index, | 480 | static int __f2fs_setxattr(struct inode *inode, int index, |
479 | const char *name, const void *value, size_t value_len, | 481 | const char *name, const void *value, size_t size, |
480 | struct page *ipage) | 482 | struct page *ipage) |
481 | { | 483 | { |
482 | struct f2fs_inode_info *fi = F2FS_I(inode); | 484 | struct f2fs_inode_info *fi = F2FS_I(inode); |
483 | struct f2fs_xattr_entry *here, *last; | 485 | struct f2fs_xattr_entry *here, *last; |
484 | void *base_addr; | 486 | void *base_addr; |
485 | int found, newsize; | 487 | int found, newsize; |
486 | size_t name_len; | 488 | size_t len; |
487 | __u32 new_hsize; | 489 | __u32 new_hsize; |
488 | int error = -ENOMEM; | 490 | int error = -ENOMEM; |
489 | 491 | ||
@@ -491,11 +493,11 @@ static int __f2fs_setxattr(struct inode *inode, int name_index, | |||
491 | return -EINVAL; | 493 | return -EINVAL; |
492 | 494 | ||
493 | if (value == NULL) | 495 | if (value == NULL) |
494 | value_len = 0; | 496 | size = 0; |
495 | 497 | ||
496 | name_len = strlen(name); | 498 | len = strlen(name); |
497 | 499 | ||
498 | if (name_len > F2FS_NAME_LEN || value_len > MAX_VALUE_LEN(inode)) | 500 | if (len > F2FS_NAME_LEN || size > MAX_VALUE_LEN(inode)) |
499 | return -ERANGE; | 501 | return -ERANGE; |
500 | 502 | ||
501 | base_addr = read_all_xattrs(inode, ipage); | 503 | base_addr = read_all_xattrs(inode, ipage); |
@@ -503,7 +505,7 @@ static int __f2fs_setxattr(struct inode *inode, int name_index, | |||
503 | goto exit; | 505 | goto exit; |
504 | 506 | ||
505 | /* find entry with wanted name. */ | 507 | /* find entry with wanted name. */ |
506 | here = __find_xattr(base_addr, name_index, name_len, name); | 508 | here = __find_xattr(base_addr, index, len, name); |
507 | 509 | ||
508 | found = IS_XATTR_LAST_ENTRY(here) ? 0 : 1; | 510 | found = IS_XATTR_LAST_ENTRY(here) ? 0 : 1; |
509 | last = here; | 511 | last = here; |
@@ -511,8 +513,7 @@ static int __f2fs_setxattr(struct inode *inode, int name_index, | |||
511 | while (!IS_XATTR_LAST_ENTRY(last)) | 513 | while (!IS_XATTR_LAST_ENTRY(last)) |
512 | last = XATTR_NEXT_ENTRY(last); | 514 | last = XATTR_NEXT_ENTRY(last); |
513 | 515 | ||
514 | newsize = XATTR_ALIGN(sizeof(struct f2fs_xattr_entry) + | 516 | newsize = XATTR_ALIGN(sizeof(struct f2fs_xattr_entry) + len + size); |
515 | name_len + value_len); | ||
516 | 517 | ||
517 | /* 1. Check space */ | 518 | /* 1. Check space */ |
518 | if (value) { | 519 | if (value) { |
@@ -555,12 +556,12 @@ static int __f2fs_setxattr(struct inode *inode, int name_index, | |||
555 | * We just write new entry. | 556 | * We just write new entry. |
556 | */ | 557 | */ |
557 | memset(last, 0, newsize); | 558 | memset(last, 0, newsize); |
558 | last->e_name_index = name_index; | 559 | last->e_name_index = index; |
559 | last->e_name_len = name_len; | 560 | last->e_name_len = len; |
560 | memcpy(last->e_name, name, name_len); | 561 | memcpy(last->e_name, name, len); |
561 | pval = last->e_name + name_len; | 562 | pval = last->e_name + len; |
562 | memcpy(pval, value, value_len); | 563 | memcpy(pval, value, size); |
563 | last->e_value_size = cpu_to_le16(value_len); | 564 | last->e_value_size = cpu_to_le16(size); |
564 | new_hsize += newsize; | 565 | new_hsize += newsize; |
565 | } | 566 | } |
566 | 567 | ||
@@ -583,8 +584,9 @@ exit: | |||
583 | return error; | 584 | return error; |
584 | } | 585 | } |
585 | 586 | ||
586 | int f2fs_setxattr(struct inode *inode, int name_index, const char *name, | 587 | int f2fs_setxattr(struct inode *inode, int index, const char *name, |
587 | const void *value, size_t value_len, struct page *ipage) | 588 | const void *value, size_t size, |
589 | struct page *ipage) | ||
588 | { | 590 | { |
589 | struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); | 591 | struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); |
590 | int err; | 592 | int err; |
@@ -594,7 +596,7 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name, | |||
594 | f2fs_lock_op(sbi); | 596 | f2fs_lock_op(sbi); |
595 | /* protect xattr_ver */ | 597 | /* protect xattr_ver */ |
596 | down_write(&F2FS_I(inode)->i_sem); | 598 | down_write(&F2FS_I(inode)->i_sem); |
597 | err = __f2fs_setxattr(inode, name_index, name, value, value_len, ipage); | 599 | err = __f2fs_setxattr(inode, index, name, value, size, ipage); |
598 | up_write(&F2FS_I(inode)->i_sem); | 600 | up_write(&F2FS_I(inode)->i_sem); |
599 | f2fs_unlock_op(sbi); | 601 | f2fs_unlock_op(sbi); |
600 | 602 | ||
diff --git a/fs/f2fs/xattr.h b/fs/f2fs/xattr.h index b21d9ebdeff3..79bc2bb32aeb 100644 --- a/fs/f2fs/xattr.h +++ b/fs/f2fs/xattr.h | |||
@@ -120,12 +120,12 @@ extern ssize_t f2fs_listxattr(struct dentry *, char *, size_t); | |||
120 | #else | 120 | #else |
121 | 121 | ||
122 | #define f2fs_xattr_handlers NULL | 122 | #define f2fs_xattr_handlers NULL |
123 | static inline int f2fs_setxattr(struct inode *inode, int name_index, | 123 | static inline int f2fs_setxattr(struct inode *inode, int index, |
124 | const char *name, const void *value, size_t value_len) | 124 | const char *name, const void *value, size_t size) |
125 | { | 125 | { |
126 | return -EOPNOTSUPP; | 126 | return -EOPNOTSUPP; |
127 | } | 127 | } |
128 | static inline int f2fs_getxattr(struct inode *inode, int name_index, | 128 | static inline int f2fs_getxattr(struct inode *inode, int index, |
129 | const char *name, void *buffer, size_t buffer_size) | 129 | const char *name, void *buffer, size_t buffer_size) |
130 | { | 130 | { |
131 | return -EOPNOTSUPP; | 131 | return -EOPNOTSUPP; |