Commit dea80134 authored by KaiGai Kohei's avatar KaiGai Kohei

[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: default avatarKaiGai Kohei <kaigai@ak.jp.nec.com>
parent 5a14959c
...@@ -48,9 +48,11 @@ static int jffs2_acl_count(size_t size) ...@@ -48,9 +48,11 @@ static int jffs2_acl_count(size_t size)
} }
} }
static struct posix_acl *jffs2_acl_from_medium(const void *value, size_t size) static struct posix_acl *jffs2_acl_from_medium(void *value, size_t size)
{ {
const char *end = (char *)value + size; void *end = value + size;
struct jffs2_acl_header *header = value;
struct jffs2_acl_entry *entry;
struct posix_acl *acl; struct posix_acl *acl;
uint32_t ver; uint32_t ver;
int i, count; int i, count;
...@@ -59,13 +61,13 @@ static struct posix_acl *jffs2_acl_from_medium(const void *value, size_t size) ...@@ -59,13 +61,13 @@ static struct posix_acl *jffs2_acl_from_medium(const void *value, size_t size)
return NULL; return NULL;
if (size < sizeof(struct jffs2_acl_header)) if (size < sizeof(struct jffs2_acl_header))
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
ver = je32_to_cpu(((struct jffs2_acl_header *)value)->a_version); ver = je32_to_cpu(header->a_version);
if (ver != JFFS2_ACL_VERSION) { if (ver != JFFS2_ACL_VERSION) {
JFFS2_WARNING("Invalid ACL version. (=%u)\n", ver); JFFS2_WARNING("Invalid ACL version. (=%u)\n", ver);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
value = (char *)value + sizeof(struct jffs2_acl_header); value += sizeof(struct jffs2_acl_header);
count = jffs2_acl_count(size); count = jffs2_acl_count(size);
if (count < 0) if (count < 0)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
...@@ -77,8 +79,8 @@ static struct posix_acl *jffs2_acl_from_medium(const void *value, size_t size) ...@@ -77,8 +79,8 @@ static struct posix_acl *jffs2_acl_from_medium(const void *value, size_t size)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
for (i=0; i < count; i++) { for (i=0; i < count; i++) {
struct jffs2_acl_entry *entry = (struct jffs2_acl_entry *)value; entry = value;
if ((char *)value + sizeof(struct jffs2_acl_entry_short) > end) if (value + sizeof(struct jffs2_acl_entry_short) > end)
goto fail; goto fail;
acl->a_entries[i].e_tag = je16_to_cpu(entry->e_tag); acl->a_entries[i].e_tag = je16_to_cpu(entry->e_tag);
acl->a_entries[i].e_perm = je16_to_cpu(entry->e_perm); 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,14 +89,14 @@ static struct posix_acl *jffs2_acl_from_medium(const void *value, size_t size)
case ACL_GROUP_OBJ: case ACL_GROUP_OBJ:
case ACL_MASK: case ACL_MASK:
case ACL_OTHER: case ACL_OTHER:
value = (char *)value + sizeof(struct jffs2_acl_entry_short); value += sizeof(struct jffs2_acl_entry_short);
acl->a_entries[i].e_id = ACL_UNDEFINED_ID; acl->a_entries[i].e_id = ACL_UNDEFINED_ID;
break; break;
case ACL_USER: case ACL_USER:
case ACL_GROUP: case ACL_GROUP:
value = (char *)value + sizeof(struct jffs2_acl_entry); value += sizeof(struct jffs2_acl_entry);
if ((char *)value > end) if (value > end)
goto fail; goto fail;
acl->a_entries[i].e_id = je32_to_cpu(entry->e_id); acl->a_entries[i].e_id = je32_to_cpu(entry->e_id);
break; break;
...@@ -113,20 +115,19 @@ static struct posix_acl *jffs2_acl_from_medium(const void *value, size_t size) ...@@ -113,20 +115,19 @@ static struct posix_acl *jffs2_acl_from_medium(const void *value, size_t size)
static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size) static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size)
{ {
struct jffs2_acl_header *jffs2_acl; struct jffs2_acl_header *header;
char *e; struct jffs2_acl_entry *entry;
void *e;
size_t i; size_t i;
*size = jffs2_acl_size(acl->a_count); *size = jffs2_acl_size(acl->a_count);
jffs2_acl = kmalloc(sizeof(struct jffs2_acl_header) header = kmalloc(sizeof(*header) + acl->a_count * sizeof(*entry), GFP_KERNEL);
+ acl->a_count * sizeof(struct jffs2_acl_entry), if (!header)
GFP_KERNEL);
if (!jffs2_acl)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
jffs2_acl->a_version = cpu_to_je32(JFFS2_ACL_VERSION); header->a_version = cpu_to_je32(JFFS2_ACL_VERSION);
e = (char *)jffs2_acl + sizeof(struct jffs2_acl_header); e = header + 1;
for (i=0; i < acl->a_count; i++) { for (i=0; i < acl->a_count; i++) {
struct jffs2_acl_entry *entry = (struct jffs2_acl_entry *)e; entry = e;
entry->e_tag = cpu_to_je16(acl->a_entries[i].e_tag); entry->e_tag = cpu_to_je16(acl->a_entries[i].e_tag);
entry->e_perm = cpu_to_je16(acl->a_entries[i].e_perm); entry->e_perm = cpu_to_je16(acl->a_entries[i].e_perm);
switch(acl->a_entries[i].e_tag) { 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,9 +148,9 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size)
goto fail; goto fail;
} }
} }
return (char *)jffs2_acl; return header;
fail: fail:
kfree(jffs2_acl); kfree(header);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment