use malloc instead of xmalloc
diff --git a/e2fsprogs/blkid/dev.c b/e2fsprogs/blkid/dev.c
index 23af887..0e2b4e1 100644
--- a/e2fsprogs/blkid/dev.c
+++ b/e2fsprogs/blkid/dev.c
@@ -84,12 +84,10 @@
{
blkid_dev_iterate iter;
- iter = malloc(sizeof(struct blkid_struct_dev_iterate));
- if (iter) {
- iter->magic = DEV_ITERATE_MAGIC;
- iter->cache = cache;
- iter->p = cache->bic_devs.next;
- }
+ iter = xmalloc(sizeof(struct blkid_struct_dev_iterate));
+ iter->magic = DEV_ITERATE_MAGIC;
+ iter->cache = cache;
+ iter->p = cache->bic_devs.next;
return (iter);
}
diff --git a/e2fsprogs/blkid/devname.c b/e2fsprogs/blkid/devname.c
index 87d5cbe..b323021 100644
--- a/e2fsprogs/blkid/devname.c
+++ b/e2fsprogs/blkid/devname.c
@@ -192,9 +192,7 @@
vg_name = vg_iter->d_name;
if (!strcmp(vg_name, ".") || !strcmp(vg_name, ".."))
continue;
- vdirname = malloc(vg_len + strlen(vg_name) + 8);
- if (!vdirname)
- goto exit;
+ vdirname = xmalloc(vg_len + strlen(vg_name) + 8);
sprintf(vdirname, "%s/%s/LVs", VG_DIR, vg_name);
lv_list = opendir(vdirname);
@@ -209,12 +207,8 @@
if (!strcmp(lv_name, ".") || !strcmp(lv_name, ".."))
continue;
- lvm_device = malloc(vg_len + strlen(vg_name) +
+ lvm_device = xmalloc(vg_len + strlen(vg_name) +
strlen(lv_name) + 8);
- if (!lvm_device) {
- closedir(lv_list);
- goto exit;
- }
sprintf(lvm_device, "%s/%s/LVs/%s", VG_DIR, vg_name,
lv_name);
dev = lvm_get_devno(lvm_device);
@@ -227,7 +221,6 @@
}
closedir(lv_list);
}
-exit:
closedir(vg_list);
}
#endif
diff --git a/e2fsprogs/blkid/devno.c b/e2fsprogs/blkid/devno.c
index 31aa52b..93a57fd 100644
--- a/e2fsprogs/blkid/devno.c
+++ b/e2fsprogs/blkid/devno.c
@@ -48,11 +48,9 @@
if (!length)
length = strlen(s);
- ret = malloc(length + 1);
- if (ret) {
- strncpy(ret, s, length);
- ret[length] = '\0';
- }
+ ret = xmalloc(length + 1);
+ strncpy(ret, s, length);
+ ret[length] = '\0';
return ret;
}
@@ -68,14 +66,8 @@
{
struct dir_list *dp;
- dp = malloc(sizeof(struct dir_list));
- if (!dp)
- return;
+ dp = xmalloc(sizeof(struct dir_list));
dp->name = blkid_strdup(name);
- if (!dp->name) {
- free(dp);
- return;
- }
dp->next = *list;
*list = dp;
}
diff --git a/e2fsprogs/blkid/probe.c b/e2fsprogs/blkid/probe.c
index 5fa37ad..5ae88b1 100644
--- a/e2fsprogs/blkid/probe.c
+++ b/e2fsprogs/blkid/probe.c
@@ -331,7 +331,7 @@
* pagesize).
*/
if (lseek(fd, 1024, SEEK_SET) < 0) return 1;
- if (!(sws = (struct swap_id_block *)malloc(1024))) return 1;
+ sws = (struct swap_id_block *)xmalloc(1024);
if (read(fd, sws, 1024) != 1024) {
free(sws);
return 1;
@@ -602,9 +602,8 @@
if (lseek(fd, idx << 10, SEEK_SET) < 0)
continue;
- if (!(buf = (unsigned char *)malloc(1024)))
- continue;
-
+ buf = (unsigned char *)xmalloc(1024);
+
if (read(fd, buf, 1024) != 1024) {
free(buf);
continue;
diff --git a/e2fsprogs/blkid/save.c b/e2fsprogs/blkid/save.c
index a2fbd7b..1830e45 100644
--- a/e2fsprogs/blkid/save.c
+++ b/e2fsprogs/blkid/save.c
@@ -90,16 +90,14 @@
* a temporary file then we open it directly.
*/
if (ret == 0 && S_ISREG(st.st_mode)) {
- tmp = malloc(strlen(filename) + 8);
- if (tmp) {
- sprintf(tmp, "%s-XXXXXX", filename);
- fd = mkstemp(tmp);
- if (fd >= 0) {
- file = fdopen(fd, "w");
- opened = tmp;
- }
- fchmod(fd, 0644);
+ tmp = xmalloc(strlen(filename) + 8);
+ sprintf(tmp, "%s-XXXXXX", filename);
+ fd = mkstemp(tmp);
+ if (fd >= 0) {
+ file = fdopen(fd, "w");
+ opened = tmp;
}
+ fchmod(fd, 0644);
}
if (!file) {
@@ -138,13 +136,11 @@
} else {
char *backup;
- backup = malloc(strlen(filename) + 5);
- if (backup) {
- sprintf(backup, "%s.old", filename);
- unlink(backup);
- link(filename, backup);
- free(backup);
- }
+ backup = xmalloc(strlen(filename) + 5);
+ sprintf(backup, "%s.old", filename);
+ unlink(backup);
+ link(filename, backup);
+ free(backup);
rename(opened, filename);
DBG(DEBUG_SAVE,
printf("moved temp cache %s\n", opened));
diff --git a/e2fsprogs/blkid/tag.c b/e2fsprogs/blkid/tag.c
index 63e5e7b4..699d0fb 100644
--- a/e2fsprogs/blkid/tag.c
+++ b/e2fsprogs/blkid/tag.c
@@ -246,12 +246,10 @@
{
blkid_tag_iterate iter;
- iter = malloc(sizeof(struct blkid_struct_tag_iterate));
- if (iter) {
- iter->magic = TAG_ITERATE_MAGIC;
- iter->dev = dev;
- iter->p = dev->bid_tags.next;
- }
+ iter = xmalloc(sizeof(struct blkid_struct_tag_iterate));
+ iter->magic = TAG_ITERATE_MAGIC;
+ iter->dev = dev;
+ iter->p = dev->bid_tags.next;
return (iter);
}