aboutsummaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorPaul Moore <paul.moore@hp.com>2006-08-29 17:55:11 -0700
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-22 15:18:37 -0700
commit7b3bbb926f4b3dd3a007dcf8dfa00203f52cb58d (patch)
tree1ee2ab452f5c94ce4779171d6ebaa07f7d1fcd21 /security
parentc1b14c0a46232246f61d3157bac1201e1e102227 (diff)
[NetLabel]: Cleanup ebitmap_import()
Rewrite ebitmap_import() so it is a bit cleaner and easier to read. Signed-off-by: Paul Moore <paul.moore@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'security')
-rw-r--r--security/selinux/ss/ebitmap.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
index 4b915eb60c4..cfed1d30fa6 100644
--- a/security/selinux/ss/ebitmap.c
+++ b/security/selinux/ss/ebitmap.c
@@ -145,29 +145,28 @@ int ebitmap_import(const unsigned char *src,
struct ebitmap *dst)
{
size_t src_off = 0;
+ size_t node_limit;
struct ebitmap_node *node_new;
struct ebitmap_node *node_last = NULL;
- size_t iter;
- size_t iter_bit;
- size_t iter_limit;
+ u32 i_byte;
+ u32 i_bit;
unsigned char src_byte;
- do {
- iter_limit = src_len - src_off;
- if (iter_limit >= sizeof(MAPTYPE)) {
+ while (src_off < src_len) {
+ if (src_len - src_off >= sizeof(MAPTYPE)) {
if (*(MAPTYPE *)&src[src_off] == 0) {
src_off += sizeof(MAPTYPE);
continue;
}
- iter_limit = sizeof(MAPTYPE);
+ node_limit = sizeof(MAPTYPE);
} else {
- iter = src_off;
- src_byte = 0;
- do {
- src_byte |= src[iter++];
- } while (iter < src_len && src_byte == 0);
+ for (src_byte = 0, i_byte = src_off;
+ i_byte < src_len && src_byte == 0;
+ i_byte++)
+ src_byte |= src[i_byte];
if (src_byte == 0)
break;
+ node_limit = src_len - src_off;
}
node_new = kzalloc(sizeof(*node_new), GFP_ATOMIC);
@@ -176,24 +175,21 @@ int ebitmap_import(const unsigned char *src,
return -ENOMEM;
}
node_new->startbit = src_off * 8;
- iter = 0;
- do {
+ for (i_byte = 0; i_byte < node_limit; i_byte++) {
src_byte = src[src_off++];
- iter_bit = iter++ * 8;
- while (src_byte != 0) {
+ for (i_bit = i_byte * 8; src_byte != 0; i_bit++) {
if (src_byte & 0x80)
- node_new->map |= MAPBIT << iter_bit;
- iter_bit++;
+ node_new->map |= MAPBIT << i_bit;
src_byte <<= 1;
}
- } while (iter < iter_limit);
+ }
if (node_last != NULL)
node_last->next = node_new;
else
dst->node = node_new;
node_last = node_new;
- } while (src_off < src_len);
+ }
if (likely(node_last != NULL))
dst->highbit = node_last->startbit + MAPSIZE;