diff options
author | KaiGai Kohei <kaigai@ak.jp.nec.com> | 2006-05-13 02:20:24 -0400 |
---|---|---|
committer | KaiGai Kohei <kaigai@ak.jp.nec.com> | 2006-05-13 02:20:24 -0400 |
commit | dea80134dc4d54df52c0c59b0ba2bb5aa999bf30 (patch) | |
tree | 37bfacafa5f5ad58b211c483497218d0ec82443b /fs | |
parent | 5a14959c0700cd389d9e7ba312e15c8e85255e1f (diff) |
[JFFS2][XATTR] remove redundant pointer cast in acl.c
remove redundant pointer cast in acl.c.
[10/10] jffs2-xattr-v5.1-10-remove_pointer_cast.patch
Signed-off-by: KaiGai Kohei <kaigai@ak.jp.nec.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/jffs2/acl.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c index 1682278d9742..320dd48b834e 100644 --- a/fs/jffs2/acl.c +++ b/fs/jffs2/acl.c | |||
@@ -48,9 +48,11 @@ static int jffs2_acl_count(size_t size) | |||
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | static struct posix_acl *jffs2_acl_from_medium(const void *value, size_t size) | 51 | static struct posix_acl *jffs2_acl_from_medium(void *value, size_t size) |
52 | { | 52 | { |
53 | const char *end = (char *)value + size; | 53 | void *end = value + size; |
54 | struct jffs2_acl_header *header = value; | ||
55 | struct jffs2_acl_entry *entry; | ||
54 | struct posix_acl *acl; | 56 | struct posix_acl *acl; |
55 | uint32_t ver; | 57 | uint32_t ver; |
56 | int i, count; | 58 | int i, count; |
@@ -59,13 +61,13 @@ static struct posix_acl *jffs2_acl_from_medium(const void *value, size_t size) | |||
59 | return NULL; | 61 | return NULL; |
60 | if (size < sizeof(struct jffs2_acl_header)) | 62 | if (size < sizeof(struct jffs2_acl_header)) |
61 | return ERR_PTR(-EINVAL); | 63 | return ERR_PTR(-EINVAL); |
62 | ver = je32_to_cpu(((struct jffs2_acl_header *)value)->a_version); | 64 | ver = je32_to_cpu(header->a_version); |
63 | if (ver != JFFS2_ACL_VERSION) { | 65 | if (ver != JFFS2_ACL_VERSION) { |
64 | JFFS2_WARNING("Invalid ACL version. (=%u)\n", ver); | 66 | JFFS2_WARNING("Invalid ACL version. (=%u)\n", ver); |
65 | return ERR_PTR(-EINVAL); | 67 | return ERR_PTR(-EINVAL); |
66 | } | 68 | } |
67 | 69 | ||
68 | value = (char *)value + sizeof(struct jffs2_acl_header); | 70 | value += sizeof(struct jffs2_acl_header); |
69 | count = jffs2_acl_count(size); | 71 | count = jffs2_acl_count(size); |
70 | if (count < 0) | 72 | if (count < 0) |
71 | return ERR_PTR(-EINVAL); | 73 | return ERR_PTR(-EINVAL); |
@@ -77,8 +79,8 @@ static struct posix_acl *jffs2_acl_from_medium(const void *value, size_t size) | |||
77 | return ERR_PTR(-ENOMEM); | 79 | return ERR_PTR(-ENOMEM); |
78 | 80 | ||
79 | for (i=0; i < count; i++) { | 81 | for (i=0; i < count; i++) { |
80 | struct jffs2_acl_entry *entry = (struct jffs2_acl_entry *)value; | 82 | entry = value; |
81 | if ((char *)value + sizeof(struct jffs2_acl_entry_short) > end) | 83 | if (value + sizeof(struct jffs2_acl_entry_short) > end) |
82 | goto fail; | 84 | goto fail; |
83 | acl->a_entries[i].e_tag = je16_to_cpu(entry->e_tag); | 85 | acl->a_entries[i].e_tag = je16_to_cpu(entry->e_tag); |
84 | acl->a_entries[i].e_perm = je16_to_cpu(entry->e_perm); | 86 | acl->a_entries[i].e_perm = je16_to_cpu(entry->e_perm); |
@@ -87,14 +89,14 @@ static struct posix_acl *jffs2_acl_from_medium(const void *value, size_t size) | |||
87 | case ACL_GROUP_OBJ: | 89 | case ACL_GROUP_OBJ: |
88 | case ACL_MASK: | 90 | case ACL_MASK: |
89 | case ACL_OTHER: | 91 | case ACL_OTHER: |
90 | value = (char *)value + sizeof(struct jffs2_acl_entry_short); | 92 | value += sizeof(struct jffs2_acl_entry_short); |
91 | acl->a_entries[i].e_id = ACL_UNDEFINED_ID; | 93 | acl->a_entries[i].e_id = ACL_UNDEFINED_ID; |
92 | break; | 94 | break; |
93 | 95 | ||
94 | case ACL_USER: | 96 | case ACL_USER: |
95 | case ACL_GROUP: | 97 | case ACL_GROUP: |
96 | value = (char *)value + sizeof(struct jffs2_acl_entry); | 98 | value += sizeof(struct jffs2_acl_entry); |
97 | if ((char *)value > end) | 99 | if (value > end) |
98 | goto fail; | 100 | goto fail; |
99 | acl->a_entries[i].e_id = je32_to_cpu(entry->e_id); | 101 | acl->a_entries[i].e_id = je32_to_cpu(entry->e_id); |
100 | break; | 102 | break; |
@@ -113,20 +115,19 @@ static struct posix_acl *jffs2_acl_from_medium(const void *value, size_t size) | |||
113 | 115 | ||
114 | static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size) | 116 | static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size) |
115 | { | 117 | { |
116 | struct jffs2_acl_header *jffs2_acl; | 118 | struct jffs2_acl_header *header; |
117 | char *e; | 119 | struct jffs2_acl_entry *entry; |
120 | void *e; | ||
118 | size_t i; | 121 | size_t i; |
119 | 122 | ||
120 | *size = jffs2_acl_size(acl->a_count); | 123 | *size = jffs2_acl_size(acl->a_count); |
121 | jffs2_acl = kmalloc(sizeof(struct jffs2_acl_header) | 124 | header = kmalloc(sizeof(*header) + acl->a_count * sizeof(*entry), GFP_KERNEL); |
122 | + acl->a_count * sizeof(struct jffs2_acl_entry), | 125 | if (!header) |
123 | GFP_KERNEL); | ||
124 | if (!jffs2_acl) | ||
125 | return ERR_PTR(-ENOMEM); | 126 | return ERR_PTR(-ENOMEM); |
126 | jffs2_acl->a_version = cpu_to_je32(JFFS2_ACL_VERSION); | 127 | header->a_version = cpu_to_je32(JFFS2_ACL_VERSION); |
127 | e = (char *)jffs2_acl + sizeof(struct jffs2_acl_header); | 128 | e = header + 1; |
128 | for (i=0; i < acl->a_count; i++) { | 129 | for (i=0; i < acl->a_count; i++) { |
129 | struct jffs2_acl_entry *entry = (struct jffs2_acl_entry *)e; | 130 | entry = e; |
130 | entry->e_tag = cpu_to_je16(acl->a_entries[i].e_tag); | 131 | entry->e_tag = cpu_to_je16(acl->a_entries[i].e_tag); |
131 | entry->e_perm = cpu_to_je16(acl->a_entries[i].e_perm); | 132 | entry->e_perm = cpu_to_je16(acl->a_entries[i].e_perm); |
132 | switch(acl->a_entries[i].e_tag) { | 133 | switch(acl->a_entries[i].e_tag) { |
@@ -147,9 +148,9 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size) | |||
147 | goto fail; | 148 | goto fail; |
148 | } | 149 | } |
149 | } | 150 | } |
150 | return (char *)jffs2_acl; | 151 | return header; |
151 | fail: | 152 | fail: |
152 | kfree(jffs2_acl); | 153 | kfree(header); |
153 | return ERR_PTR(-EINVAL); | 154 | return ERR_PTR(-EINVAL); |
154 | } | 155 | } |
155 | 156 | ||