Commit 21e2156f authored by Andreas Gruenbacher's avatar Andreas Gruenbacher

gfs2: Get rid of gfs2_ea_strlen

Function gfs2_ea_strlen is only called from ea_list_i, so inline it
there.  Remove the duplicate switch statement and the creative use of
memcpy to set a null byte.
Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: default avatarAndrew Price <anprice@redhat.com>
Reviewed-by: default avatarBob Peterson <rpeterso@redhat.com>
parent 3f30f929
...@@ -343,60 +343,45 @@ struct ea_list { ...@@ -343,60 +343,45 @@ struct ea_list {
unsigned int ei_size; unsigned int ei_size;
}; };
static inline unsigned int gfs2_ea_strlen(struct gfs2_ea_header *ea)
{
switch (ea->ea_type) {
case GFS2_EATYPE_USR:
return 5 + ea->ea_name_len + 1;
case GFS2_EATYPE_SYS:
return 7 + ea->ea_name_len + 1;
case GFS2_EATYPE_SECURITY:
return 9 + ea->ea_name_len + 1;
default:
return 0;
}
}
static int ea_list_i(struct gfs2_inode *ip, struct buffer_head *bh, static int ea_list_i(struct gfs2_inode *ip, struct buffer_head *bh,
struct gfs2_ea_header *ea, struct gfs2_ea_header *prev, struct gfs2_ea_header *ea, struct gfs2_ea_header *prev,
void *private) void *private)
{ {
struct ea_list *ei = private; struct ea_list *ei = private;
struct gfs2_ea_request *er = ei->ei_er; struct gfs2_ea_request *er = ei->ei_er;
unsigned int ea_size = gfs2_ea_strlen(ea); unsigned int ea_size;
char *prefix;
unsigned int l;
if (ea->ea_type == GFS2_EATYPE_UNUSED) if (ea->ea_type == GFS2_EATYPE_UNUSED)
return 0; return 0;
if (er->er_data_len) { switch (ea->ea_type) {
char *prefix = NULL; case GFS2_EATYPE_USR:
unsigned int l = 0; prefix = "user.";
char c = 0; l = 5;
break;
case GFS2_EATYPE_SYS:
prefix = "system.";
l = 7;
break;
case GFS2_EATYPE_SECURITY:
prefix = "security.";
l = 9;
break;
default:
BUG();
}
ea_size = l + ea->ea_name_len + 1;
if (er->er_data_len) {
if (ei->ei_size + ea_size > er->er_data_len) if (ei->ei_size + ea_size > er->er_data_len)
return -ERANGE; return -ERANGE;
switch (ea->ea_type) {
case GFS2_EATYPE_USR:
prefix = "user.";
l = 5;
break;
case GFS2_EATYPE_SYS:
prefix = "system.";
l = 7;
break;
case GFS2_EATYPE_SECURITY:
prefix = "security.";
l = 9;
break;
}
BUG_ON(l == 0);
memcpy(er->er_data + ei->ei_size, prefix, l); memcpy(er->er_data + ei->ei_size, prefix, l);
memcpy(er->er_data + ei->ei_size + l, GFS2_EA2NAME(ea), memcpy(er->er_data + ei->ei_size + l, GFS2_EA2NAME(ea),
ea->ea_name_len); ea->ea_name_len);
memcpy(er->er_data + ei->ei_size + ea_size - 1, &c, 1); er->er_data[ei->ei_size + ea_size - 1] = 0;
} }
ei->ei_size += ea_size; ei->ei_size += ea_size;
......
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