aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2005-06-12 00:45:09 +0000
committerMike Frysinger <vapier@gentoo.org>2005-06-12 00:45:09 +0000
commitd5826903c171981d967dc6a8c430dfaaed05c53a (patch)
treee60fa099cc881ef65c0ac4115b91b0874a5d781d
parent7fde8debc450c19927b82e3434fc5d6a6dd4d35d (diff)
downloadbusybox-w32-d5826903c171981d967dc6a8c430dfaaed05c53a.tar.gz
busybox-w32-d5826903c171981d967dc6a8c430dfaaed05c53a.tar.bz2
busybox-w32-d5826903c171981d967dc6a8c430dfaaed05c53a.zip
use xmalloc instead of malloc
-rw-r--r--e2fsprogs/ext2fs/finddev.c16
-rw-r--r--e2fsprogs/ext2fs/imager.c20
-rw-r--r--e2fsprogs/ext2fs/inode.c8
3 files changed, 10 insertions, 34 deletions
diff --git a/e2fsprogs/ext2fs/finddev.c b/e2fsprogs/ext2fs/finddev.c
index fa2cadde4..c459c0833 100644
--- a/e2fsprogs/ext2fs/finddev.c
+++ b/e2fsprogs/ext2fs/finddev.c
@@ -46,14 +46,8 @@ static void add_to_dirlist(const char *name, struct dir_list **list)
46{ 46{
47 struct dir_list *dp; 47 struct dir_list *dp;
48 48
49 dp = malloc(sizeof(struct dir_list)); 49 dp = xmalloc(sizeof(struct dir_list));
50 if (!dp) 50 dp->name = xmalloc(strlen(name)+1);
51 return;
52 dp->name = malloc(strlen(name)+1);
53 if (!dp->name) {
54 free(dp);
55 return;
56 }
57 strcpy(dp->name, name); 51 strcpy(dp->name, name);
58 dp->next = *list; 52 dp->next = *list;
59 *list = dp; 53 *list = dp;
@@ -100,11 +94,7 @@ static int scan_dir(char *dir_name, dev_t device, struct dir_list **list,
100 if (S_ISDIR(st.st_mode)) 94 if (S_ISDIR(st.st_mode))
101 add_to_dirlist(path, list); 95 add_to_dirlist(path, list);
102 if (S_ISBLK(st.st_mode) && st.st_rdev == device) { 96 if (S_ISBLK(st.st_mode) && st.st_rdev == device) {
103 cp = malloc(strlen(path)+1); 97 cp = xmalloc(strlen(path)+1);
104 if (!cp) {
105 closedir(dir);
106 return ENOMEM;
107 }
108 strcpy(cp, path); 98 strcpy(cp, path);
109 *ret_path = cp; 99 *ret_path = cp;
110 goto success; 100 goto success;
diff --git a/e2fsprogs/ext2fs/imager.c b/e2fsprogs/ext2fs/imager.c
index 596fbbebe..3f2826b82 100644
--- a/e2fsprogs/ext2fs/imager.c
+++ b/e2fsprogs/ext2fs/imager.c
@@ -66,9 +66,7 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags)
66 ssize_t actual; 66 ssize_t actual;
67 errcode_t retval; 67 errcode_t retval;
68 68
69 buf = malloc(fs->blocksize * BUF_BLOCKS); 69 buf = xmalloc(fs->blocksize * BUF_BLOCKS);
70 if (!buf)
71 return ENOMEM;
72 70
73 for (group = 0; group < fs->group_desc_count; group++) { 71 for (group = 0; group < fs->group_desc_count; group++) {
74 blk = fs->group_desc[(unsigned)group].bg_inode_table; 72 blk = fs->group_desc[(unsigned)group].bg_inode_table;
@@ -138,9 +136,7 @@ errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd,
138 ssize_t actual; 136 ssize_t actual;
139 errcode_t retval; 137 errcode_t retval;
140 138
141 buf = malloc(fs->blocksize * BUF_BLOCKS); 139 buf = xmalloc(fs->blocksize * BUF_BLOCKS);
142 if (!buf)
143 return ENOMEM;
144 140
145 for (group = 0; group < fs->group_desc_count; group++) { 141 for (group = 0; group < fs->group_desc_count; group++) {
146 blk = fs->group_desc[(unsigned)group].bg_inode_table; 142 blk = fs->group_desc[(unsigned)group].bg_inode_table;
@@ -187,9 +183,7 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd,
187 ssize_t actual; 183 ssize_t actual;
188 errcode_t retval; 184 errcode_t retval;
189 185
190 buf = malloc(fs->blocksize); 186 buf = xmalloc(fs->blocksize);
191 if (!buf)
192 return ENOMEM;
193 187
194 /* 188 /*
195 * Write out the superblock 189 * Write out the superblock
@@ -238,9 +232,7 @@ errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd,
238 errcode_t retval; 232 errcode_t retval;
239 233
240 size = fs->blocksize * (fs->group_desc_count + 1); 234 size = fs->blocksize * (fs->group_desc_count + 1);
241 buf = malloc(size); 235 buf = xmalloc(size);
242 if (!buf)
243 return ENOMEM;
244 236
245 /* 237 /*
246 * Read it all in. 238 * Read it all in.
@@ -364,9 +356,7 @@ errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)
364 } 356 }
365 size = size * fs->group_desc_count; 357 size = size * fs->group_desc_count;
366 358
367 buf = malloc(size); 359 buf = xmalloc(size);
368 if (!buf)
369 return ENOMEM;
370 360
371 actual = read(fd, buf, size); 361 actual = read(fd, buf, size);
372 if (actual == -1) { 362 if (actual == -1) {
diff --git a/e2fsprogs/ext2fs/inode.c b/e2fsprogs/ext2fs/inode.c
index 222568ebe..30580bf6d 100644
--- a/e2fsprogs/ext2fs/inode.c
+++ b/e2fsprogs/ext2fs/inode.c
@@ -641,9 +641,7 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
641 length = EXT2_INODE_SIZE(fs->super); 641 length = EXT2_INODE_SIZE(fs->super);
642 642
643 if (length > (int) sizeof(struct ext2_inode_large)) { 643 if (length > (int) sizeof(struct ext2_inode_large)) {
644 w_inode = malloc(length); 644 w_inode = xmalloc(length);
645 if (!w_inode)
646 return ENOMEM;
647 } else 645 } else
648 w_inode = &temp_inode; 646 w_inode = &temp_inode;
649 memset(w_inode, 0, length); 647 memset(w_inode, 0, length);
@@ -731,9 +729,7 @@ errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino,
731 return ext2fs_write_inode_full(fs, ino, inode, 729 return ext2fs_write_inode_full(fs, ino, inode,
732 sizeof(struct ext2_inode)); 730 sizeof(struct ext2_inode));
733 731
734 buf = malloc(size); 732 buf = xmalloc(size);
735 if (!buf)
736 return ENOMEM;
737 733
738 memset(buf, 0, size); 734 memset(buf, 0, size);
739 *buf = *inode; 735 *buf = *inode;