use malloc instead of xmalloc
This commit is contained in:
parent
d1a9d57bd6
commit
7fde8debc4
@ -84,12 +84,10 @@ extern blkid_dev_iterate blkid_dev_iterate_begin(blkid_cache cache)
|
|||||||
{
|
{
|
||||||
blkid_dev_iterate iter;
|
blkid_dev_iterate iter;
|
||||||
|
|
||||||
iter = malloc(sizeof(struct blkid_struct_dev_iterate));
|
iter = xmalloc(sizeof(struct blkid_struct_dev_iterate));
|
||||||
if (iter) {
|
|
||||||
iter->magic = DEV_ITERATE_MAGIC;
|
iter->magic = DEV_ITERATE_MAGIC;
|
||||||
iter->cache = cache;
|
iter->cache = cache;
|
||||||
iter->p = cache->bic_devs.next;
|
iter->p = cache->bic_devs.next;
|
||||||
}
|
|
||||||
return (iter);
|
return (iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,9 +192,7 @@ static void lvm_probe_all(blkid_cache cache)
|
|||||||
vg_name = vg_iter->d_name;
|
vg_name = vg_iter->d_name;
|
||||||
if (!strcmp(vg_name, ".") || !strcmp(vg_name, ".."))
|
if (!strcmp(vg_name, ".") || !strcmp(vg_name, ".."))
|
||||||
continue;
|
continue;
|
||||||
vdirname = malloc(vg_len + strlen(vg_name) + 8);
|
vdirname = xmalloc(vg_len + strlen(vg_name) + 8);
|
||||||
if (!vdirname)
|
|
||||||
goto exit;
|
|
||||||
sprintf(vdirname, "%s/%s/LVs", VG_DIR, vg_name);
|
sprintf(vdirname, "%s/%s/LVs", VG_DIR, vg_name);
|
||||||
|
|
||||||
lv_list = opendir(vdirname);
|
lv_list = opendir(vdirname);
|
||||||
@ -209,12 +207,8 @@ static void lvm_probe_all(blkid_cache cache)
|
|||||||
if (!strcmp(lv_name, ".") || !strcmp(lv_name, ".."))
|
if (!strcmp(lv_name, ".") || !strcmp(lv_name, ".."))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
lvm_device = malloc(vg_len + strlen(vg_name) +
|
lvm_device = xmalloc(vg_len + strlen(vg_name) +
|
||||||
strlen(lv_name) + 8);
|
strlen(lv_name) + 8);
|
||||||
if (!lvm_device) {
|
|
||||||
closedir(lv_list);
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
sprintf(lvm_device, "%s/%s/LVs/%s", VG_DIR, vg_name,
|
sprintf(lvm_device, "%s/%s/LVs/%s", VG_DIR, vg_name,
|
||||||
lv_name);
|
lv_name);
|
||||||
dev = lvm_get_devno(lvm_device);
|
dev = lvm_get_devno(lvm_device);
|
||||||
@ -227,7 +221,6 @@ static void lvm_probe_all(blkid_cache cache)
|
|||||||
}
|
}
|
||||||
closedir(lv_list);
|
closedir(lv_list);
|
||||||
}
|
}
|
||||||
exit:
|
|
||||||
closedir(vg_list);
|
closedir(vg_list);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -48,11 +48,9 @@ char *blkid_strndup(const char *s, int length)
|
|||||||
if (!length)
|
if (!length)
|
||||||
length = strlen(s);
|
length = strlen(s);
|
||||||
|
|
||||||
ret = malloc(length + 1);
|
ret = xmalloc(length + 1);
|
||||||
if (ret) {
|
|
||||||
strncpy(ret, s, length);
|
strncpy(ret, s, length);
|
||||||
ret[length] = '\0';
|
ret[length] = '\0';
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,14 +66,8 @@ static void add_to_dirlist(const char *name, struct dir_list **list)
|
|||||||
{
|
{
|
||||||
struct dir_list *dp;
|
struct dir_list *dp;
|
||||||
|
|
||||||
dp = malloc(sizeof(struct dir_list));
|
dp = xmalloc(sizeof(struct dir_list));
|
||||||
if (!dp)
|
|
||||||
return;
|
|
||||||
dp->name = blkid_strdup(name);
|
dp->name = blkid_strdup(name);
|
||||||
if (!dp->name) {
|
|
||||||
free(dp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dp->next = *list;
|
dp->next = *list;
|
||||||
*list = dp;
|
*list = dp;
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ static int probe_swap1(int fd,
|
|||||||
* pagesize).
|
* pagesize).
|
||||||
*/
|
*/
|
||||||
if (lseek(fd, 1024, SEEK_SET) < 0) return 1;
|
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) {
|
if (read(fd, sws, 1024) != 1024) {
|
||||||
free(sws);
|
free(sws);
|
||||||
return 1;
|
return 1;
|
||||||
@ -602,8 +602,7 @@ try_again:
|
|||||||
if (lseek(fd, idx << 10, SEEK_SET) < 0)
|
if (lseek(fd, idx << 10, SEEK_SET) < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!(buf = (unsigned char *)malloc(1024)))
|
buf = (unsigned char *)xmalloc(1024);
|
||||||
continue;
|
|
||||||
|
|
||||||
if (read(fd, buf, 1024) != 1024) {
|
if (read(fd, buf, 1024) != 1024) {
|
||||||
free(buf);
|
free(buf);
|
||||||
|
@ -90,8 +90,7 @@ int blkid_flush_cache(blkid_cache cache)
|
|||||||
* a temporary file then we open it directly.
|
* a temporary file then we open it directly.
|
||||||
*/
|
*/
|
||||||
if (ret == 0 && S_ISREG(st.st_mode)) {
|
if (ret == 0 && S_ISREG(st.st_mode)) {
|
||||||
tmp = malloc(strlen(filename) + 8);
|
tmp = xmalloc(strlen(filename) + 8);
|
||||||
if (tmp) {
|
|
||||||
sprintf(tmp, "%s-XXXXXX", filename);
|
sprintf(tmp, "%s-XXXXXX", filename);
|
||||||
fd = mkstemp(tmp);
|
fd = mkstemp(tmp);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
@ -100,7 +99,6 @@ int blkid_flush_cache(blkid_cache cache)
|
|||||||
}
|
}
|
||||||
fchmod(fd, 0644);
|
fchmod(fd, 0644);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
file = fopen(filename, "w");
|
file = fopen(filename, "w");
|
||||||
@ -138,13 +136,11 @@ int blkid_flush_cache(blkid_cache cache)
|
|||||||
} else {
|
} else {
|
||||||
char *backup;
|
char *backup;
|
||||||
|
|
||||||
backup = malloc(strlen(filename) + 5);
|
backup = xmalloc(strlen(filename) + 5);
|
||||||
if (backup) {
|
|
||||||
sprintf(backup, "%s.old", filename);
|
sprintf(backup, "%s.old", filename);
|
||||||
unlink(backup);
|
unlink(backup);
|
||||||
link(filename, backup);
|
link(filename, backup);
|
||||||
free(backup);
|
free(backup);
|
||||||
}
|
|
||||||
rename(opened, filename);
|
rename(opened, filename);
|
||||||
DBG(DEBUG_SAVE,
|
DBG(DEBUG_SAVE,
|
||||||
printf("moved temp cache %s\n", opened));
|
printf("moved temp cache %s\n", opened));
|
||||||
|
@ -246,12 +246,10 @@ extern blkid_tag_iterate blkid_tag_iterate_begin(blkid_dev dev)
|
|||||||
{
|
{
|
||||||
blkid_tag_iterate iter;
|
blkid_tag_iterate iter;
|
||||||
|
|
||||||
iter = malloc(sizeof(struct blkid_struct_tag_iterate));
|
iter = xmalloc(sizeof(struct blkid_struct_tag_iterate));
|
||||||
if (iter) {
|
|
||||||
iter->magic = TAG_ITERATE_MAGIC;
|
iter->magic = TAG_ITERATE_MAGIC;
|
||||||
iter->dev = dev;
|
iter->dev = dev;
|
||||||
iter->p = dev->bid_tags.next;
|
iter->p = dev->bid_tags.next;
|
||||||
}
|
|
||||||
return (iter);
|
return (iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user