aboutsummaryrefslogtreecommitdiff
path: root/e2fsprogs/old_e2fsprogs/e2fsck.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-01-08 09:07:25 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-01-08 09:07:25 +0100
commitef3817c6dcbf9270d36b48a0547e507221abce74 (patch)
treebf8ff94f617ca8b12ee84ba1238658df06db2f9a /e2fsprogs/old_e2fsprogs/e2fsck.c
parentb8f0e8036deb529bba8f71c13b6c934ea14c4447 (diff)
downloadbusybox-w32-ef3817c6dcbf9270d36b48a0547e507221abce74.tar.gz
busybox-w32-ef3817c6dcbf9270d36b48a0547e507221abce74.tar.bz2
busybox-w32-ef3817c6dcbf9270d36b48a0547e507221abce74.zip
old_e2fsprogs/e2fsck.c: fix indentation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'e2fsprogs/old_e2fsprogs/e2fsck.c')
-rw-r--r--e2fsprogs/old_e2fsprogs/e2fsck.c463
1 files changed, 215 insertions, 248 deletions
diff --git a/e2fsprogs/old_e2fsprogs/e2fsck.c b/e2fsprogs/old_e2fsprogs/e2fsck.c
index c715d3e9a..7e0996956 100644
--- a/e2fsprogs/old_e2fsprogs/e2fsck.c
+++ b/e2fsprogs/old_e2fsprogs/e2fsck.c
@@ -89,14 +89,14 @@ typedef __u32 problem_t;
89 89
90struct problem_context { 90struct problem_context {
91 errcode_t errcode; 91 errcode_t errcode;
92 ext2_ino_t ino, ino2, dir; 92 ext2_ino_t ino, ino2, dir;
93 struct ext2_inode *inode; 93 struct ext2_inode *inode;
94 struct ext2_dir_entry *dirent; 94 struct ext2_dir_entry *dirent;
95 blk_t blk, blk2; 95 blk_t blk, blk2;
96 e2_blkcnt_t blkcount; 96 e2_blkcnt_t blkcount;
97 int group; 97 int group;
98 __u64 num; 98 __u64 num;
99 const char *str; 99 const char *str;
100}; 100};
101 101
102 102
@@ -133,31 +133,31 @@ typedef unsigned long dictcount_t;
133typedef enum { dnode_red, dnode_black } dnode_color_t; 133typedef enum { dnode_red, dnode_black } dnode_color_t;
134 134
135typedef struct dnode_t { 135typedef struct dnode_t {
136 struct dnode_t *dict_left; 136 struct dnode_t *dict_left;
137 struct dnode_t *dict_right; 137 struct dnode_t *dict_right;
138 struct dnode_t *dict_parent; 138 struct dnode_t *dict_parent;
139 dnode_color_t dict_color; 139 dnode_color_t dict_color;
140 const void *dict_key; 140 const void *dict_key;
141 void *dict_data; 141 void *dict_data;
142} dnode_t; 142} dnode_t;
143 143
144typedef int (*dict_comp_t)(const void *, const void *); 144typedef int (*dict_comp_t)(const void *, const void *);
145typedef void (*dnode_free_t)(dnode_t *); 145typedef void (*dnode_free_t)(dnode_t *);
146 146
147typedef struct dict_t { 147typedef struct dict_t {
148 dnode_t dict_nilnode; 148 dnode_t dict_nilnode;
149 dictcount_t dict_nodecount; 149 dictcount_t dict_nodecount;
150 dictcount_t dict_maxcount; 150 dictcount_t dict_maxcount;
151 dict_comp_t dict_compare; 151 dict_comp_t dict_compare;
152 dnode_free_t dict_freenode; 152 dnode_free_t dict_freenode;
153 int dict_dupes; 153 int dict_dupes;
154} dict_t; 154} dict_t;
155 155
156typedef void (*dnode_process_t)(dict_t *, dnode_t *, void *); 156typedef void (*dnode_process_t)(dict_t *, dnode_t *, void *);
157 157
158typedef struct dict_load_t { 158typedef struct dict_load_t {
159 dict_t *dict_dictptr; 159 dict_t *dict_dictptr;
160 dnode_t dict_nilnode; 160 dnode_t dict_nilnode;
161} dict_load_t; 161} dict_load_t;
162 162
163#define dict_count(D) ((D)->dict_nodecount) 163#define dict_count(D) ((D)->dict_nodecount)
@@ -214,9 +214,8 @@ static kmem_cache_t * do_cache_create(int len)
214{ 214{
215 kmem_cache_t *new_cache; 215 kmem_cache_t *new_cache;
216 216
217 new_cache = malloc(sizeof(*new_cache)); 217 new_cache = xmalloc(sizeof(*new_cache));
218 if (new_cache) 218 new_cache->object_length = len;
219 new_cache->object_length = len;
220 return new_cache; 219 return new_cache;
221} 220}
222 221
@@ -269,26 +268,26 @@ static void dnode_free(dnode_t *node);
269 268
270static void rotate_left(dnode_t *upper) 269static void rotate_left(dnode_t *upper)
271{ 270{
272 dnode_t *lower, *lowleft, *upparent; 271 dnode_t *lower, *lowleft, *upparent;
273 272
274 lower = upper->right; 273 lower = upper->right;
275 upper->right = lowleft = lower->left; 274 upper->right = lowleft = lower->left;
276 lowleft->parent = upper; 275 lowleft->parent = upper;
277 276
278 lower->parent = upparent = upper->parent; 277 lower->parent = upparent = upper->parent;
279 278
280 /* don't need to check for root node here because root->parent is 279 /* don't need to check for root node here because root->parent is
281 the sentinel nil node, and root->parent->left points back to root */ 280 the sentinel nil node, and root->parent->left points back to root */
282 281
283 if (upper == upparent->left) { 282 if (upper == upparent->left) {
284 upparent->left = lower; 283 upparent->left = lower;
285 } else { 284 } else {
286 assert (upper == upparent->right); 285 assert (upper == upparent->right);
287 upparent->right = lower; 286 upparent->right = lower;
288 } 287 }
289 288
290 lower->left = upper; 289 lower->left = upper;
291 upper->parent = lower; 290 upper->parent = lower;
292} 291}
293 292
294/* 293/*
@@ -298,23 +297,23 @@ static void rotate_left(dnode_t *upper)
298 297
299static void rotate_right(dnode_t *upper) 298static void rotate_right(dnode_t *upper)
300{ 299{
301 dnode_t *lower, *lowright, *upparent; 300 dnode_t *lower, *lowright, *upparent;
302 301
303 lower = upper->left; 302 lower = upper->left;
304 upper->left = lowright = lower->right; 303 upper->left = lowright = lower->right;
305 lowright->parent = upper; 304 lowright->parent = upper;
306 305
307 lower->parent = upparent = upper->parent; 306 lower->parent = upparent = upper->parent;
308 307
309 if (upper == upparent->right) { 308 if (upper == upparent->right) {
310 upparent->right = lower; 309 upparent->right = lower;
311 } else { 310 } else {
312 assert (upper == upparent->left); 311 assert (upper == upparent->left);
313 upparent->left = lower; 312 upparent->left = lower;
314 } 313 }
315 314
316 lower->right = upper; 315 lower->right = upper;
317 upper->parent = lower; 316 upper->parent = lower;
318} 317}
319 318
320/* 319/*
@@ -324,11 +323,11 @@ static void rotate_right(dnode_t *upper)
324 323
325static void free_nodes(dict_t *dict, dnode_t *node, dnode_t *nil) 324static void free_nodes(dict_t *dict, dnode_t *node, dnode_t *nil)
326{ 325{
327 if (node == nil) 326 if (node == nil)
328 return; 327 return;
329 free_nodes(dict, node->left, nil); 328 free_nodes(dict, node->left, nil);
330 free_nodes(dict, node->right, nil); 329 free_nodes(dict, node->right, nil);
331 dict->dict_freenode(node); 330 dict->dict_freenode(node);
332} 331}
333 332
334/* 333/*
@@ -340,12 +339,12 @@ static void free_nodes(dict_t *dict, dnode_t *node, dnode_t *nil)
340 339
341static int verify_dict_has_node(dnode_t *nil, dnode_t *root, dnode_t *node) 340static int verify_dict_has_node(dnode_t *nil, dnode_t *root, dnode_t *node)
342{ 341{
343 if (root != nil) { 342 if (root != nil) {
344 return root == node 343 return root == node
345 || verify_dict_has_node(nil, root->left, node) 344 || verify_dict_has_node(nil, root->left, node)
346 || verify_dict_has_node(nil, root->right, node); 345 || verify_dict_has_node(nil, root->right, node);
347 } 346 }
348 return 0; 347 return 0;
349} 348}
350 349
351 350
@@ -355,8 +354,8 @@ static int verify_dict_has_node(dnode_t *nil, dnode_t *root, dnode_t *node)
355 354
356static void dict_set_allocator(dict_t *dict, dnode_free_t fr) 355static void dict_set_allocator(dict_t *dict, dnode_free_t fr)
357{ 356{
358 assert (dict_count(dict) == 0); 357 assert(dict_count(dict) == 0);
359 dict->dict_freenode = fr; 358 dict->dict_freenode = fr;
360} 359}
361 360
362/* 361/*
@@ -366,11 +365,11 @@ static void dict_set_allocator(dict_t *dict, dnode_free_t fr)
366 365
367static void dict_free_nodes(dict_t *dict) 366static void dict_free_nodes(dict_t *dict)
368{ 367{
369 dnode_t *nil = dict_nil(dict), *root = dict_root(dict); 368 dnode_t *nil = dict_nil(dict), *root = dict_root(dict);
370 free_nodes(dict, root, nil); 369 free_nodes(dict, root, nil);
371 dict->dict_nodecount = 0; 370 dict->dict_nodecount = 0;
372 dict->nilnode.left = &dict->nilnode; 371 dict->nilnode.left = &dict->nilnode;
373 dict->nilnode.right = &dict->nilnode; 372 dict->nilnode.right = &dict->nilnode;
374} 373}
375 374
376/* 375/*
@@ -379,16 +378,16 @@ static void dict_free_nodes(dict_t *dict)
379 378
380static dict_t *dict_init(dict_t *dict, dictcount_t maxcount, dict_comp_t comp) 379static dict_t *dict_init(dict_t *dict, dictcount_t maxcount, dict_comp_t comp)
381{ 380{
382 dict->compare = comp; 381 dict->compare = comp;
383 dict->dict_freenode = dnode_free; 382 dict->dict_freenode = dnode_free;
384 dict->dict_nodecount = 0; 383 dict->dict_nodecount = 0;
385 dict->maxcount = maxcount; 384 dict->maxcount = maxcount;
386 dict->nilnode.left = &dict->nilnode; 385 dict->nilnode.left = &dict->nilnode;
387 dict->nilnode.right = &dict->nilnode; 386 dict->nilnode.right = &dict->nilnode;
388 dict->nilnode.parent = &dict->nilnode; 387 dict->nilnode.parent = &dict->nilnode;
389 dict->nilnode.color = dnode_black; 388 dict->nilnode.color = dnode_black;
390 dict->dupes = 0; 389 dict->dupes = 0;
391 return dict; 390 return dict;
392} 391}
393 392
394/* 393/*
@@ -400,35 +399,35 @@ static dict_t *dict_init(dict_t *dict, dictcount_t maxcount, dict_comp_t comp)
400 399
401static dnode_t *dict_lookup(dict_t *dict, const void *key) 400static dnode_t *dict_lookup(dict_t *dict, const void *key)
402{ 401{
403 dnode_t *root = dict_root(dict); 402 dnode_t *root = dict_root(dict);
404 dnode_t *nil = dict_nil(dict); 403 dnode_t *nil = dict_nil(dict);
405 dnode_t *saved; 404 dnode_t *saved;
406 int result; 405 int result;
407 406
408 /* simple binary search adapted for trees that contain duplicate keys */ 407 /* simple binary search adapted for trees that contain duplicate keys */
409 408
410 while (root != nil) { 409 while (root != nil) {
411 result = dict->compare(key, root->key); 410 result = dict->compare(key, root->key);
412 if (result < 0) 411 if (result < 0)
413 root = root->left; 412 root = root->left;
414 else if (result > 0) 413 else if (result > 0)
415 root = root->right;
416 else {
417 if (!dict->dupes) { /* no duplicates, return match */
418 return root;
419 } else { /* could be dupes, find leftmost one */
420 do {
421 saved = root;
422 root = root->left;
423 while (root != nil && dict->compare(key, root->key))
424 root = root->right; 414 root = root->right;
425 } while (root != nil); 415 else {
426 return saved; 416 if (!dict->dupes) { /* no duplicates, return match */
427 } 417 return root;
418 } else { /* could be dupes, find leftmost one */
419 do {
420 saved = root;
421 root = root->left;
422 while (root != nil && dict->compare(key, root->key))
423 root = root->right;
424 } while (root != nil);
425 return saved;
426 }
427 }
428 } 428 }
429 }
430 429
431 return NULL; 430 return NULL;
432} 431}
433 432
434/* 433/*
@@ -441,87 +440,87 @@ static dnode_t *dict_lookup(dict_t *dict, const void *key)
441 440
442static void dict_insert(dict_t *dict, dnode_t *node, const void *key) 441static void dict_insert(dict_t *dict, dnode_t *node, const void *key)
443{ 442{
444 dnode_t *where = dict_root(dict), *nil = dict_nil(dict); 443 dnode_t *where = dict_root(dict), *nil = dict_nil(dict);
445 dnode_t *parent = nil, *uncle, *grandpa; 444 dnode_t *parent = nil, *uncle, *grandpa;
446 int result = -1; 445 int result = -1;
447 446
448 node->key = key; 447 node->key = key;
449 448
450 /* basic binary tree insert */ 449 /* basic binary tree insert */
450
451 while (where != nil) {
452 parent = where;
453 result = dict->compare(key, where->key);
454 /* trap attempts at duplicate key insertion unless it's explicitly allowed */
455 assert(dict->dupes || result != 0);
456 if (result < 0)
457 where = where->left;
458 else
459 where = where->right;
460 }
461
462 assert(where == nil);
451 463
452 while (where != nil) {
453 parent = where;
454 result = dict->compare(key, where->key);
455 /* trap attempts at duplicate key insertion unless it's explicitly allowed */
456 assert (dict->dupes || result != 0);
457 if (result < 0) 464 if (result < 0)
458 where = where->left; 465 parent->left = node;
459 else 466 else
460 where = where->right; 467 parent->right = node;
461 } 468
462 469 node->parent = parent;
463 assert (where == nil); 470 node->left = nil;
464 471 node->right = nil;
465 if (result < 0) 472
466 parent->left = node; 473 dict->dict_nodecount++;
467 else 474
468 parent->right = node; 475 /* red black adjustments */
469 476
470 node->parent = parent; 477 node->color = dnode_red;
471 node->left = nil; 478
472 node->right = nil; 479 while (parent->color == dnode_red) {
473 480 grandpa = parent->parent;
474 dict->dict_nodecount++; 481 if (parent == grandpa->left) {
475 482 uncle = grandpa->right;
476 /* red black adjustments */ 483 if (uncle->color == dnode_red) { /* red parent, red uncle */
477 484 parent->color = dnode_black;
478 node->color = dnode_red; 485 uncle->color = dnode_black;
479 486 grandpa->color = dnode_red;
480 while (parent->color == dnode_red) { 487 node = grandpa;
481 grandpa = parent->parent; 488 parent = grandpa->parent;
482 if (parent == grandpa->left) { 489 } else { /* red parent, black uncle */
483 uncle = grandpa->right; 490 if (node == parent->right) {
484 if (uncle->color == dnode_red) { /* red parent, red uncle */ 491 rotate_left(parent);
485 parent->color = dnode_black; 492 parent = node;
486 uncle->color = dnode_black; 493 assert (grandpa == parent->parent);
487 grandpa->color = dnode_red; 494 /* rotation between parent and child preserves grandpa */
488 node = grandpa; 495 }
489 parent = grandpa->parent; 496 parent->color = dnode_black;
490 } else { /* red parent, black uncle */ 497 grandpa->color = dnode_red;
491 if (node == parent->right) { 498 rotate_right(grandpa);
492 rotate_left(parent); 499 break;
493 parent = node; 500 }
494 assert (grandpa == parent->parent); 501 } else { /* symmetric cases: parent == parent->parent->right */
495 /* rotation between parent and child preserves grandpa */ 502 uncle = grandpa->left;
496 } 503 if (uncle->color == dnode_red) {
497 parent->color = dnode_black; 504 parent->color = dnode_black;
498 grandpa->color = dnode_red; 505 uncle->color = dnode_black;
499 rotate_right(grandpa); 506 grandpa->color = dnode_red;
500 break; 507 node = grandpa;
501 } 508 parent = grandpa->parent;
502 } else { /* symmetric cases: parent == parent->parent->right */ 509 } else {
503 uncle = grandpa->left; 510 if (node == parent->left) {
504 if (uncle->color == dnode_red) { 511 rotate_right(parent);
505 parent->color = dnode_black; 512 parent = node;
506 uncle->color = dnode_black; 513 assert (grandpa == parent->parent);
507 grandpa->color = dnode_red; 514 }
508 node = grandpa; 515 parent->color = dnode_black;
509 parent = grandpa->parent; 516 grandpa->color = dnode_red;
510 } else { 517 rotate_left(grandpa);
511 if (node == parent->left) { 518 break;
512 rotate_right(parent); 519 }
513 parent = node; 520 }
514 assert (grandpa == parent->parent);
515 }
516 parent->color = dnode_black;
517 grandpa->color = dnode_red;
518 rotate_left(grandpa);
519 break;
520 }
521 } 521 }
522 }
523 522
524 dict_root(dict)->color = dnode_black; 523 dict_root(dict)->color = dnode_black;
525 524
526} 525}
527 526
@@ -532,23 +531,20 @@ static void dict_insert(dict_t *dict, dnode_t *node, const void *key)
532 531
533static dnode_t *dnode_init(dnode_t *dnode, void *data) 532static dnode_t *dnode_init(dnode_t *dnode, void *data)
534{ 533{
535 dnode->data = data; 534 dnode->data = data;
536 dnode->parent = NULL; 535 dnode->parent = NULL;
537 dnode->left = NULL; 536 dnode->left = NULL;
538 dnode->right = NULL; 537 dnode->right = NULL;
539 return dnode; 538 return dnode;
540} 539}
541 540
542static int dict_alloc_insert(dict_t *dict, const void *key, void *data) 541static int dict_alloc_insert(dict_t *dict, const void *key, void *data)
543{ 542{
544 dnode_t *node = malloc(sizeof(dnode_t)); 543 dnode_t *node = xmalloc(sizeof(dnode_t));
545 544
546 if (node) {
547 dnode_init(node, data); 545 dnode_init(node, data);
548 dict_insert(dict, node, key); 546 dict_insert(dict, node, key);
549 return 1; 547 return 1;
550 }
551 return 0;
552} 548}
553 549
554/* 550/*
@@ -558,13 +554,13 @@ static int dict_alloc_insert(dict_t *dict, const void *key, void *data)
558 554
559static dnode_t *dict_first(dict_t *dict) 555static dnode_t *dict_first(dict_t *dict)
560{ 556{
561 dnode_t *nil = dict_nil(dict), *root = dict_root(dict), *left; 557 dnode_t *nil = dict_nil(dict), *root = dict_root(dict), *left;
562 558
563 if (root != nil) 559 if (root != nil)
564 while ((left = root->left) != nil) 560 while ((left = root->left) != nil)
565 root = left; 561 root = left;
566 562
567 return (root == nil) ? NULL : root; 563 return (root == nil) ? NULL : root;
568} 564}
569 565
570/* 566/*
@@ -576,29 +572,29 @@ static dnode_t *dict_first(dict_t *dict)
576 572
577static dnode_t *dict_next(dict_t *dict, dnode_t *curr) 573static dnode_t *dict_next(dict_t *dict, dnode_t *curr)
578{ 574{
579 dnode_t *nil = dict_nil(dict), *parent, *left; 575 dnode_t *nil = dict_nil(dict), *parent, *left;
580 576
581 if (curr->right != nil) { 577 if (curr->right != nil) {
582 curr = curr->right; 578 curr = curr->right;
583 while ((left = curr->left) != nil) 579 while ((left = curr->left) != nil)
584 curr = left; 580 curr = left;
585 return curr; 581 return curr;
586 } 582 }
587
588 parent = curr->parent;
589 583
590 while (parent != nil && curr == parent->right) {
591 curr = parent;
592 parent = curr->parent; 584 parent = curr->parent;
593 }
594 585
595 return (parent == nil) ? NULL : parent; 586 while (parent != nil && curr == parent->right) {
587 curr = parent;
588 parent = curr->parent;
589 }
590
591 return (parent == nil) ? NULL : parent;
596} 592}
597 593
598 594
599static void dnode_free(dnode_t *node) 595static void dnode_free(dnode_t *node)
600{ 596{
601 free(node); 597 free(node);
602} 598}
603 599
604 600
@@ -2392,8 +2388,8 @@ static const char *const abbrevs[] = {
2392 N_("hHTREE @d @i"), 2388 N_("hHTREE @d @i"),
2393 N_("llost+found"), 2389 N_("llost+found"),
2394 N_("Lis a link"), 2390 N_("Lis a link"),
2395 N_("mmultiply-claimed"), 2391 N_("mmultiply-claimed"),
2396 N_("ninvalid"), 2392 N_("ninvalid"),
2397 N_("oorphaned"), 2393 N_("oorphaned"),
2398 N_("pproblem in"), 2394 N_("pproblem in"),
2399 N_("rroot @i"), 2395 N_("rroot @i"),
@@ -2742,10 +2738,7 @@ static region_t region_create(region_addr_t min, region_addr_t max)
2742{ 2738{
2743 region_t region; 2739 region_t region;
2744 2740
2745 region = malloc(sizeof(struct region_struct)); 2741 region = xzalloc(sizeof(struct region_struct));
2746 if (!region)
2747 return NULL;
2748 memset(region, 0, sizeof(struct region_struct));
2749 region->min = min; 2742 region->min = min;
2750 region->max = max; 2743 region->max = max;
2751 return region; 2744 return region;
@@ -2810,9 +2803,7 @@ static int region_allocate(region_t region, region_addr_t start, int n)
2810 /* 2803 /*
2811 * Insert a new region element structure into the linked list 2804 * Insert a new region element structure into the linked list
2812 */ 2805 */
2813 new_region = malloc(sizeof(struct region_el)); 2806 new_region = xmalloc(sizeof(struct region_el));
2814 if (!new_region)
2815 return -1;
2816 new_region->start = start; 2807 new_region->start = start;
2817 new_region->end = start + n; 2808 new_region->end = start + n;
2818 new_region->next = r; 2809 new_region->next = r;
@@ -10311,12 +10302,8 @@ static int fill_dir_block(ext2_filsys fs,
10311 continue; 10302 continue;
10312 } 10303 }
10313 if (fd->num_array >= fd->max_array) { 10304 if (fd->num_array >= fd->max_array) {
10314 new_array = realloc(fd->harray, 10305 new_array = xrealloc(fd->harray,
10315 sizeof(struct hash_entry) * (fd->max_array+500)); 10306 sizeof(struct hash_entry) * (fd->max_array+500));
10316 if (!new_array) {
10317 fd->err = ENOMEM;
10318 return BLOCK_ABORT;
10319 }
10320 fd->harray = new_array; 10307 fd->harray = new_array;
10321 fd->max_array += 500; 10308 fd->max_array += 500;
10322 } 10309 }
@@ -10391,18 +10378,14 @@ static errcode_t alloc_size_dir(ext2_filsys fs, struct out_dir *outdir,
10391 void *new_mem; 10378 void *new_mem;
10392 10379
10393 if (outdir->max) { 10380 if (outdir->max) {
10394 new_mem = realloc(outdir->buf, blocks * fs->blocksize); 10381 new_mem = xrealloc(outdir->buf, blocks * fs->blocksize);
10395 if (!new_mem)
10396 return ENOMEM;
10397 outdir->buf = new_mem; 10382 outdir->buf = new_mem;
10398 new_mem = realloc(outdir->hashes, 10383 new_mem = xrealloc(outdir->hashes,
10399 blocks * sizeof(ext2_dirhash_t)); 10384 blocks * sizeof(ext2_dirhash_t));
10400 if (!new_mem)
10401 return ENOMEM;
10402 outdir->hashes = new_mem; 10385 outdir->hashes = new_mem;
10403 } else { 10386 } else {
10404 outdir->buf = malloc(blocks * fs->blocksize); 10387 outdir->buf = xmalloc(blocks * fs->blocksize);
10405 outdir->hashes = malloc(blocks * sizeof(ext2_dirhash_t)); 10388 outdir->hashes = xmalloc(blocks * sizeof(ext2_dirhash_t));
10406 outdir->num = 0; 10389 outdir->num = 0;
10407 } 10390 }
10408 outdir->max = blocks; 10391 outdir->max = blocks;
@@ -10849,15 +10832,11 @@ static errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino)
10849 10832
10850 retval = ENOMEM; 10833 retval = ENOMEM;
10851 fd.harray = 0; 10834 fd.harray = 0;
10852 dir_buf = malloc(inode.i_size); 10835 dir_buf = xmalloc(inode.i_size);
10853 if (!dir_buf)
10854 goto errout;
10855 10836
10856 fd.max_array = inode.i_size / 32; 10837 fd.max_array = inode.i_size / 32;
10857 fd.num_array = 0; 10838 fd.num_array = 0;
10858 fd.harray = malloc(fd.max_array * sizeof(struct hash_entry)); 10839 fd.harray = xmalloc(fd.max_array * sizeof(struct hash_entry));
10859 if (!fd.harray)
10860 goto errout;
10861 10840
10862 fd.ctx = ctx; 10841 fd.ctx = ctx;
10863 fd.buf = dir_buf; 10842 fd.buf = dir_buf;
@@ -11162,12 +11141,7 @@ int journal_init_revoke(journal_t *journal, int hash_size)
11162 shift++; 11141 shift++;
11163 journal->j_revoke->hash_shift = shift; 11142 journal->j_revoke->hash_shift = shift;
11164 11143
11165 journal->j_revoke->hash_table = malloc(hash_size * sizeof(struct list_head)); 11144 journal->j_revoke->hash_table = xmalloc(hash_size * sizeof(struct list_head));
11166 if (!journal->j_revoke->hash_table) {
11167 free(journal->j_revoke);
11168 journal->j_revoke = NULL;
11169 return -ENOMEM;
11170 }
11171 11145
11172 for (tmp = 0; tmp < hash_size; tmp++) 11146 for (tmp = 0; tmp < hash_size; tmp++)
11173 INIT_LIST_HEAD(&journal->j_revoke->hash_table[tmp]); 11147 INIT_LIST_HEAD(&journal->j_revoke->hash_table[tmp]);
@@ -12219,12 +12193,7 @@ void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
12219 void *ret; 12193 void *ret;
12220 char buf[256]; 12194 char buf[256];
12221 12195
12222 ret = malloc(size); 12196 ret = xzalloc(size);
12223 if (!ret) {
12224 sprintf(buf, "Can't allocate %s\n", description);
12225 bb_error_msg_and_die(buf);
12226 }
12227 memset(ret, 0, size);
12228 return ret; 12197 return ret;
12229} 12198}
12230 12199
@@ -12236,11 +12205,9 @@ static char *string_copy(const char *str, int len)
12236 return NULL; 12205 return NULL;
12237 if (!len) 12206 if (!len)
12238 len = strlen(str); 12207 len = strlen(str);
12239 ret = malloc(len+1); 12208 ret = xmalloc(len+1);
12240 if (ret) { 12209 strncpy(ret, str, len);
12241 strncpy(ret, str, len); 12210 ret[len] = 0;
12242 ret[len] = 0;
12243 }
12244 return ret; 12211 return ret;
12245} 12212}
12246 12213