diff options
| author | gkostka <kostka.grzegorz@gmail.com> | 2015-10-09 17:28:40 +0200 |
|---|---|---|
| committer | gkostka <kostka.grzegorz@gmail.com> | 2015-10-09 17:28:40 +0200 |
| commit | a1a24db03c42c2f6af2aa97dc9a145dbb03559e2 (patch) | |
| tree | bd322c30af6f152914c1fe7e8f09a355bea1def8 | |
| parent | 5ddffb5961175beb6f5946b13cbc977662955115 (diff) | |
Fix const correctness
| -rw-r--r-- | lwext4/ext4.c | 38 | ||||
| -rw-r--r-- | lwext4/ext4.h | 14 | ||||
| -rw-r--r-- | lwext4/ext4_xattr.c | 22 | ||||
| -rw-r--r-- | lwext4/ext4_xattr.h | 12 |
4 files changed, 34 insertions, 52 deletions
diff --git a/lwext4/ext4.c b/lwext4/ext4.c index 446d026..216fc9d 100644 --- a/lwext4/ext4.c +++ b/lwext4/ext4.c @@ -1925,18 +1925,14 @@ Finish: return r; } -int ext4_setxattr(char *path, - char *name, - size_t name_len, - void *data, - size_t data_size, - bool replace) +int ext4_setxattr(const char *path, const char *name, size_t name_len, + const void *data, size_t data_size, bool replace) { int r = EOK; ext4_file f; uint32_t inode; uint8_t name_index; - char *dissected_name = NULL; + const char *dissected_name = NULL; size_t dissected_len = 0; struct ext4_xattr_ref xattr_ref; struct ext4_inode_ref inode_ref; @@ -1968,10 +1964,8 @@ int ext4_setxattr(char *path, goto Finish; } - r = ext4_fs_set_xattr(&xattr_ref, name_index, - dissected_name, dissected_len, - data, data_size, - replace); + r = ext4_fs_set_xattr(&xattr_ref, name_index, dissected_name, + dissected_len, data, data_size, replace); ext4_fs_put_xattr_ref(&xattr_ref); ext4_fs_put_inode_ref(&inode_ref); @@ -1980,18 +1974,14 @@ Finish: return r; } -int ext4_getxattr(char *path, - char *name, - size_t name_len, - void *buf, - size_t buf_size, - size_t *data_size) +int ext4_getxattr(const char *path, const char *name, size_t name_len, + void *buf, size_t buf_size, size_t *data_size) { int r = EOK; ext4_file f; uint32_t inode; uint8_t name_index; - char *dissected_name = NULL; + const char *dissected_name = NULL; size_t dissected_len = 0; struct ext4_xattr_ref xattr_ref; struct ext4_inode_ref inode_ref; @@ -2072,8 +2062,7 @@ static int ext4_iterate_ea_list(struct ext4_xattr_ref *ref, return EXT4_XATTR_ITERATE_CONT; } -int ext4_listxattr(const char *path, char *list, size_t size, - size_t *ret_size) +int ext4_listxattr(const char *path, char *list, size_t size, size_t *ret_size) { int r = EOK; ext4_file f; @@ -2126,15 +2115,13 @@ Finish: } -int ext4_removexattr(char *path, - char *name, - size_t name_len) +int ext4_removexattr(const char *path, const char *name, size_t name_len) { int r = EOK; ext4_file f; uint32_t inode; uint8_t name_index; - char *dissected_name = NULL; + const char *dissected_name = NULL; size_t dissected_len = 0; struct ext4_xattr_ref xattr_ref; struct ext4_inode_ref inode_ref; @@ -2166,8 +2153,7 @@ int ext4_removexattr(char *path, goto Finish; } - r = ext4_fs_remove_xattr(&xattr_ref, - name_index, dissected_name, + r = ext4_fs_remove_xattr(&xattr_ref, name_index, dissected_name, dissected_len); ext4_fs_put_xattr_ref(&xattr_ref); diff --git a/lwext4/ext4.h b/lwext4/ext4.h index 9b44f36..abf6a35 100644 --- a/lwext4/ext4.h +++ b/lwext4/ext4.h @@ -363,16 +363,12 @@ int ext4_fsymlink(const char *target, const char *path); int ext4_readlink(const char *path, char *buf, size_t bufsize, size_t *rcnt); -int ext4_setxattr(char *path, char *name, size_t name_len, - void *data, size_t data_size, - bool replace); -int ext4_getxattr(char *path, char *name, size_t name_len, +int ext4_setxattr(const char *path, const char *name, size_t name_len, + const void *data, size_t data_size, bool replace); +int ext4_getxattr(const char *path, const char *name, size_t name_len, void *buf, size_t buf_size, size_t *data_size); -int ext4_listxattr(const char *path, char *list, size_t size, - size_t *ret_size); -int ext4_removexattr(char *path, - char *name, - size_t name_len); +int ext4_listxattr(const char *path, char *list, size_t size, size_t *ret_size); +int ext4_removexattr(const char *path, const char *name, size_t name_len); /*********************************DIRECTORY OPERATION***********************/ diff --git a/lwext4/ext4_xattr.c b/lwext4/ext4_xattr.c index 2eb6edf..9491e9a 100644 --- a/lwext4/ext4_xattr.c +++ b/lwext4/ext4_xattr.c @@ -131,7 +131,7 @@ RB_GENERATE_INTERNAL(ext4_xattr_tree, ext4_xattr_item, node, ext4_xattr_item_cmp, static inline) static struct ext4_xattr_item * -ext4_xattr_item_alloc(uint8_t name_index, char *name, size_t name_len) +ext4_xattr_item_alloc(uint8_t name_index, const char *name, size_t name_len) { struct ext4_xattr_item *item; item = malloc(sizeof(struct ext4_xattr_item) + name_len); @@ -151,7 +151,7 @@ ext4_xattr_item_alloc(uint8_t name_index, char *name, size_t name_len) } static int ext4_xattr_item_alloc_data(struct ext4_xattr_item *item, - void *orig_data, size_t data_size) + const void *orig_data, size_t data_size) { void *data = NULL; ext4_assert(!item->data); @@ -350,11 +350,11 @@ static int ext4_xattr_fetch(struct ext4_xattr_ref *xattr_ref) static struct ext4_xattr_item * ext4_xattr_lookup_item(struct ext4_xattr_ref *xattr_ref, uint8_t name_index, - char *name, size_t name_len) + const char *name, size_t name_len) { struct ext4_xattr_item tmp = { .name_index = name_index, - .name = name, + .name = (char *)name, /*RB_FIND - won't touch this string*/ .name_len = name_len, }; @@ -363,7 +363,7 @@ ext4_xattr_lookup_item(struct ext4_xattr_ref *xattr_ref, uint8_t name_index, static struct ext4_xattr_item * ext4_xattr_insert_item(struct ext4_xattr_ref *xattr_ref, uint8_t name_index, - char *name, size_t name_len, void *data, + const char *name, size_t name_len, const void *data, size_t data_size) { struct ext4_xattr_item *item; @@ -390,7 +390,7 @@ ext4_xattr_insert_item(struct ext4_xattr_ref *xattr_ref, uint8_t name_index, } static int ext4_xattr_remove_item(struct ext4_xattr_ref *xattr_ref, - uint8_t name_index, char *name, + uint8_t name_index, const char *name, size_t name_len) { int ret = ENOENT; @@ -683,8 +683,8 @@ void ext4_fs_xattr_iterate_reset(struct ext4_xattr_ref *ref) } int ext4_fs_set_xattr(struct ext4_xattr_ref *ref, uint8_t name_index, - char *name, size_t name_len, void *data, size_t data_size, - bool replace) + const char *name, size_t name_len, const void *data, + size_t data_size, bool replace) { int ret = EOK; struct ext4_xattr_item *item = @@ -716,13 +716,13 @@ Finish: } int ext4_fs_remove_xattr(struct ext4_xattr_ref *ref, uint8_t name_index, - char *name, size_t name_len) + const char *name, size_t name_len) { return ext4_xattr_remove_item(ref, name_index, name, name_len); } int ext4_fs_get_xattr(struct ext4_xattr_ref *ref, uint8_t name_index, - char *name, size_t name_len, void *buf, size_t buf_size, + const char *name, size_t name_len, void *buf, size_t buf_size, size_t *data_size) { int ret = EOK; @@ -811,7 +811,7 @@ static const struct xattr_prefix prefix_tbl[] = { {NULL, 0}, }; -char *ext4_extract_xattr_name(char *full_name, size_t full_name_len, +const char *ext4_extract_xattr_name(const char *full_name, size_t full_name_len, uint8_t *name_index, size_t *name_len) { int i; diff --git a/lwext4/ext4_xattr.h b/lwext4/ext4_xattr.h index d353d1e..46df6f5 100644 --- a/lwext4/ext4_xattr.h +++ b/lwext4/ext4_xattr.h @@ -46,15 +46,15 @@ int ext4_fs_get_xattr_ref(struct ext4_fs *fs, struct ext4_inode_ref *inode_ref, void ext4_fs_put_xattr_ref(struct ext4_xattr_ref *ref); int ext4_fs_set_xattr(struct ext4_xattr_ref *ref, uint8_t name_index, - char *name, size_t name_len, void *data, size_t data_size, - bool replace); + const char *name, size_t name_len, const void *data, + size_t data_size, bool replace); int ext4_fs_remove_xattr(struct ext4_xattr_ref *ref, uint8_t name_index, - char *name, size_t name_len); + const char *name, size_t name_len); int ext4_fs_get_xattr(struct ext4_xattr_ref *ref, uint8_t name_index, - char *name, size_t name_len, void *buf, size_t buf_size, - size_t *data_size); + const char *name, size_t name_len, void *buf, + size_t buf_size, size_t *data_size); void ext4_fs_xattr_iterate(struct ext4_xattr_ref *ref, int (*iter)(struct ext4_xattr_ref *ref, @@ -62,7 +62,7 @@ void ext4_fs_xattr_iterate(struct ext4_xattr_ref *ref, void ext4_fs_xattr_iterate_reset(struct ext4_xattr_ref *ref); -char *ext4_extract_xattr_name(char *full_name, size_t full_name_len, +const char *ext4_extract_xattr_name(const char *full_name, size_t full_name_len, uint8_t *name_index, size_t *name_len); const char *ext4_get_xattr_name_prefix(uint8_t name_index, |
