old_e2fsprogs/e2fsck.c: fix indentation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
@@ -214,8 +214,7 @@ static kmem_cache_t * do_cache_create(int len)
|
||||
{
|
||||
kmem_cache_t *new_cache;
|
||||
|
||||
new_cache = malloc(sizeof(*new_cache));
|
||||
if (new_cache)
|
||||
new_cache = xmalloc(sizeof(*new_cache));
|
||||
new_cache->object_length = len;
|
||||
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)
|
||||
{
|
||||
assert (dict_count(dict) == 0);
|
||||
assert(dict_count(dict) == 0);
|
||||
dict->dict_freenode = fr;
|
||||
}
|
||||
|
||||
@@ -453,14 +452,14 @@ static void dict_insert(dict_t *dict, dnode_t *node, const void *key)
|
||||
parent = where;
|
||||
result = dict->compare(key, where->key);
|
||||
/* trap attempts at duplicate key insertion unless it's explicitly allowed */
|
||||
assert (dict->dupes || result != 0);
|
||||
assert(dict->dupes || result != 0);
|
||||
if (result < 0)
|
||||
where = where->left;
|
||||
else
|
||||
where = where->right;
|
||||
}
|
||||
|
||||
assert (where == nil);
|
||||
assert(where == nil);
|
||||
|
||||
if (result < 0)
|
||||
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)
|
||||
{
|
||||
dnode_t *node = malloc(sizeof(dnode_t));
|
||||
dnode_t *node = xmalloc(sizeof(dnode_t));
|
||||
|
||||
if (node) {
|
||||
dnode_init(node, data);
|
||||
dict_insert(dict, node, key);
|
||||
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 = malloc(sizeof(struct region_struct));
|
||||
if (!region)
|
||||
return NULL;
|
||||
memset(region, 0, sizeof(struct region_struct));
|
||||
region = xzalloc(sizeof(struct region_struct));
|
||||
region->min = min;
|
||||
region->max = max;
|
||||
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
|
||||
*/
|
||||
new_region = malloc(sizeof(struct region_el));
|
||||
if (!new_region)
|
||||
return -1;
|
||||
new_region = xmalloc(sizeof(struct region_el));
|
||||
new_region->start = start;
|
||||
new_region->end = start + n;
|
||||
new_region->next = r;
|
||||
@@ -10311,12 +10302,8 @@ static int fill_dir_block(ext2_filsys fs,
|
||||
continue;
|
||||
}
|
||||
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));
|
||||
if (!new_array) {
|
||||
fd->err = ENOMEM;
|
||||
return BLOCK_ABORT;
|
||||
}
|
||||
fd->harray = new_array;
|
||||
fd->max_array += 500;
|
||||
}
|
||||
@@ -10391,18 +10378,14 @@ static errcode_t alloc_size_dir(ext2_filsys fs, struct out_dir *outdir,
|
||||
void *new_mem;
|
||||
|
||||
if (outdir->max) {
|
||||
new_mem = realloc(outdir->buf, blocks * fs->blocksize);
|
||||
if (!new_mem)
|
||||
return ENOMEM;
|
||||
new_mem = xrealloc(outdir->buf, blocks * fs->blocksize);
|
||||
outdir->buf = new_mem;
|
||||
new_mem = realloc(outdir->hashes,
|
||||
new_mem = xrealloc(outdir->hashes,
|
||||
blocks * sizeof(ext2_dirhash_t));
|
||||
if (!new_mem)
|
||||
return ENOMEM;
|
||||
outdir->hashes = new_mem;
|
||||
} else {
|
||||
outdir->buf = malloc(blocks * fs->blocksize);
|
||||
outdir->hashes = malloc(blocks * sizeof(ext2_dirhash_t));
|
||||
outdir->buf = xmalloc(blocks * fs->blocksize);
|
||||
outdir->hashes = xmalloc(blocks * sizeof(ext2_dirhash_t));
|
||||
outdir->num = 0;
|
||||
}
|
||||
outdir->max = blocks;
|
||||
@@ -10849,15 +10832,11 @@ static errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino)
|
||||
|
||||
retval = ENOMEM;
|
||||
fd.harray = 0;
|
||||
dir_buf = malloc(inode.i_size);
|
||||
if (!dir_buf)
|
||||
goto errout;
|
||||
dir_buf = xmalloc(inode.i_size);
|
||||
|
||||
fd.max_array = inode.i_size / 32;
|
||||
fd.num_array = 0;
|
||||
fd.harray = malloc(fd.max_array * sizeof(struct hash_entry));
|
||||
if (!fd.harray)
|
||||
goto errout;
|
||||
fd.harray = xmalloc(fd.max_array * sizeof(struct hash_entry));
|
||||
|
||||
fd.ctx = ctx;
|
||||
fd.buf = dir_buf;
|
||||
@@ -11162,12 +11141,7 @@ int journal_init_revoke(journal_t *journal, int hash_size)
|
||||
shift++;
|
||||
journal->j_revoke->hash_shift = shift;
|
||||
|
||||
journal->j_revoke->hash_table = malloc(hash_size * sizeof(struct list_head));
|
||||
if (!journal->j_revoke->hash_table) {
|
||||
free(journal->j_revoke);
|
||||
journal->j_revoke = NULL;
|
||||
return -ENOMEM;
|
||||
}
|
||||
journal->j_revoke->hash_table = xmalloc(hash_size * sizeof(struct list_head));
|
||||
|
||||
for (tmp = 0; tmp < hash_size; 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;
|
||||
char buf[256];
|
||||
|
||||
ret = malloc(size);
|
||||
if (!ret) {
|
||||
sprintf(buf, "Can't allocate %s\n", description);
|
||||
bb_error_msg_and_die(buf);
|
||||
}
|
||||
memset(ret, 0, size);
|
||||
ret = xzalloc(size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -12236,11 +12205,9 @@ static char *string_copy(const char *str, int len)
|
||||
return NULL;
|
||||
if (!len)
|
||||
len = strlen(str);
|
||||
ret = malloc(len+1);
|
||||
if (ret) {
|
||||
ret = xmalloc(len+1);
|
||||
strncpy(ret, str, len);
|
||||
ret[len] = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user