old_e2fsprogs/e2fsck.c: fix indentation

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2010-01-08 09:07:25 +01:00
parent b8f0e8036d
commit ef3817c6dc

View File

@ -214,8 +214,7 @@ static kmem_cache_t * do_cache_create(int len)
{ {
kmem_cache_t *new_cache; kmem_cache_t *new_cache;
new_cache = malloc(sizeof(*new_cache)); new_cache = xmalloc(sizeof(*new_cache));
if (new_cache)
new_cache->object_length = len; new_cache->object_length = len;
return new_cache; return new_cache;
} }
@ -355,7 +354,7 @@ static int verify_dict_has_node(dnode_t *nil, dnode_t *root, dnode_t *node)
static void dict_set_allocator(dict_t *dict, dnode_free_t fr) static void dict_set_allocator(dict_t *dict, dnode_free_t fr)
{ {
assert (dict_count(dict) == 0); assert(dict_count(dict) == 0);
dict->dict_freenode = fr; dict->dict_freenode = fr;
} }
@ -453,14 +452,14 @@ static void dict_insert(dict_t *dict, dnode_t *node, const void *key)
parent = where; parent = where;
result = dict->compare(key, where->key); result = dict->compare(key, where->key);
/* trap attempts at duplicate key insertion unless it's explicitly allowed */ /* trap attempts at duplicate key insertion unless it's explicitly allowed */
assert (dict->dupes || result != 0); assert(dict->dupes || result != 0);
if (result < 0) if (result < 0)
where = where->left; where = where->left;
else else
where = where->right; where = where->right;
} }
assert (where == nil); assert(where == nil);
if (result < 0) if (result < 0)
parent->left = node; parent->left = node;
@ -541,14 +540,11 @@ static dnode_t *dnode_init(dnode_t *dnode, void *data)
static int dict_alloc_insert(dict_t *dict, const void *key, void *data) static int dict_alloc_insert(dict_t *dict, const void *key, void *data)
{ {
dnode_t *node = malloc(sizeof(dnode_t)); dnode_t *node = xmalloc(sizeof(dnode_t));
if (node) {
dnode_init(node, data); dnode_init(node, data);
dict_insert(dict, node, key); dict_insert(dict, node, key);
return 1; return 1;
}
return 0;
} }
/* /*
@ -2742,10 +2738,7 @@ static region_t region_create(region_addr_t min, region_addr_t max)
{ {
region_t region; region_t region;
region = malloc(sizeof(struct region_struct)); region = xzalloc(sizeof(struct region_struct));
if (!region)
return NULL;
memset(region, 0, sizeof(struct region_struct));
region->min = min; region->min = min;
region->max = max; region->max = max;
return region; return region;
@ -2810,9 +2803,7 @@ static int region_allocate(region_t region, region_addr_t start, int n)
/* /*
* Insert a new region element structure into the linked list * Insert a new region element structure into the linked list
*/ */
new_region = malloc(sizeof(struct region_el)); new_region = xmalloc(sizeof(struct region_el));
if (!new_region)
return -1;
new_region->start = start; new_region->start = start;
new_region->end = start + n; new_region->end = start + n;
new_region->next = r; new_region->next = r;
@ -10311,12 +10302,8 @@ static int fill_dir_block(ext2_filsys fs,
continue; continue;
} }
if (fd->num_array >= fd->max_array) { if (fd->num_array >= fd->max_array) {
new_array = realloc(fd->harray, new_array = xrealloc(fd->harray,
sizeof(struct hash_entry) * (fd->max_array+500)); sizeof(struct hash_entry) * (fd->max_array+500));
if (!new_array) {
fd->err = ENOMEM;
return BLOCK_ABORT;
}
fd->harray = new_array; fd->harray = new_array;
fd->max_array += 500; fd->max_array += 500;
} }
@ -10391,18 +10378,14 @@ static errcode_t alloc_size_dir(ext2_filsys fs, struct out_dir *outdir,
void *new_mem; void *new_mem;
if (outdir->max) { if (outdir->max) {
new_mem = realloc(outdir->buf, blocks * fs->blocksize); new_mem = xrealloc(outdir->buf, blocks * fs->blocksize);
if (!new_mem)
return ENOMEM;
outdir->buf = new_mem; outdir->buf = new_mem;
new_mem = realloc(outdir->hashes, new_mem = xrealloc(outdir->hashes,
blocks * sizeof(ext2_dirhash_t)); blocks * sizeof(ext2_dirhash_t));
if (!new_mem)
return ENOMEM;
outdir->hashes = new_mem; outdir->hashes = new_mem;
} else { } else {
outdir->buf = malloc(blocks * fs->blocksize); outdir->buf = xmalloc(blocks * fs->blocksize);
outdir->hashes = malloc(blocks * sizeof(ext2_dirhash_t)); outdir->hashes = xmalloc(blocks * sizeof(ext2_dirhash_t));
outdir->num = 0; outdir->num = 0;
} }
outdir->max = blocks; outdir->max = blocks;
@ -10849,15 +10832,11 @@ static errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino)
retval = ENOMEM; retval = ENOMEM;
fd.harray = 0; fd.harray = 0;
dir_buf = malloc(inode.i_size); dir_buf = xmalloc(inode.i_size);
if (!dir_buf)
goto errout;
fd.max_array = inode.i_size / 32; fd.max_array = inode.i_size / 32;
fd.num_array = 0; fd.num_array = 0;
fd.harray = malloc(fd.max_array * sizeof(struct hash_entry)); fd.harray = xmalloc(fd.max_array * sizeof(struct hash_entry));
if (!fd.harray)
goto errout;
fd.ctx = ctx; fd.ctx = ctx;
fd.buf = dir_buf; fd.buf = dir_buf;
@ -11162,12 +11141,7 @@ int journal_init_revoke(journal_t *journal, int hash_size)
shift++; shift++;
journal->j_revoke->hash_shift = shift; journal->j_revoke->hash_shift = shift;
journal->j_revoke->hash_table = malloc(hash_size * sizeof(struct list_head)); journal->j_revoke->hash_table = xmalloc(hash_size * sizeof(struct list_head));
if (!journal->j_revoke->hash_table) {
free(journal->j_revoke);
journal->j_revoke = NULL;
return -ENOMEM;
}
for (tmp = 0; tmp < hash_size; tmp++) for (tmp = 0; tmp < hash_size; tmp++)
INIT_LIST_HEAD(&journal->j_revoke->hash_table[tmp]); INIT_LIST_HEAD(&journal->j_revoke->hash_table[tmp]);
@ -12219,12 +12193,7 @@ void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
void *ret; void *ret;
char buf[256]; char buf[256];
ret = malloc(size); ret = xzalloc(size);
if (!ret) {
sprintf(buf, "Can't allocate %s\n", description);
bb_error_msg_and_die(buf);
}
memset(ret, 0, size);
return ret; return ret;
} }
@ -12236,11 +12205,9 @@ static char *string_copy(const char *str, int len)
return NULL; return NULL;
if (!len) if (!len)
len = strlen(str); len = strlen(str);
ret = malloc(len+1); ret = xmalloc(len+1);
if (ret) {
strncpy(ret, str, len); strncpy(ret, str, len);
ret[len] = 0; ret[len] = 0;
}
return ret; return ret;
} }