1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Always zalloc device structure

Since there is zalloc behind the macro, put 'z' into the name.
Make the 'use_malloc' code path also using zalloc() call,
so it also give zeroed area.
This commit is contained in:
Zdenek Kabelac 2011-12-21 13:14:54 +00:00
parent 0e0f706f2e
commit b062ee2826
2 changed files with 10 additions and 9 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.89 - Version 2.02.89 -
================================== ==================================
Always zalloc device structure during initialization.
Fix missing thread list manipulation protection in dmeventd. Fix missing thread list manipulation protection in dmeventd.
Do not derefence lv pointer in _percent_run() function before NULL check. Do not derefence lv pointer in _percent_run() function before NULL check.
Allow empty strings for description and creation_host config fields. Allow empty strings for description and creation_host config fields.

View File

@ -48,7 +48,7 @@ static struct {
} _cache; } _cache;
#define _alloc(x) dm_pool_zalloc(_cache.mem, (x)) #define _zalloc(x) dm_pool_zalloc(_cache.mem, (x))
#define _free(x) dm_pool_free(_cache.mem, (x)) #define _free(x) dm_pool_free(_cache.mem, (x))
#define _strdup(x) dm_pool_strdup(_cache.mem, (x)) #define _strdup(x) dm_pool_strdup(_cache.mem, (x))
@ -61,11 +61,11 @@ struct device *dev_create_file(const char *filename, struct device *dev,
if (allocate) { if (allocate) {
if (use_malloc) { if (use_malloc) {
if (!(dev = dm_malloc(sizeof(*dev)))) { if (!(dev = dm_zalloc(sizeof(*dev)))) {
log_error("struct device allocation failed"); log_error("struct device allocation failed");
return NULL; return NULL;
} }
if (!(alias = dm_malloc(sizeof(*alias)))) { if (!(alias = dm_zalloc(sizeof(*alias)))) {
log_error("struct str_list allocation failed"); log_error("struct str_list allocation failed");
dm_free(dev); dm_free(dev);
return NULL; return NULL;
@ -78,11 +78,11 @@ struct device *dev_create_file(const char *filename, struct device *dev,
} }
dev->flags = DEV_ALLOCED; dev->flags = DEV_ALLOCED;
} else { } else {
if (!(dev = _alloc(sizeof(*dev)))) { if (!(dev = _zalloc(sizeof(*dev)))) {
log_error("struct device allocation failed"); log_error("struct device allocation failed");
return NULL; return NULL;
} }
if (!(alias = _alloc(sizeof(*alias)))) { if (!(alias = _zalloc(sizeof(*alias)))) {
log_error("struct str_list allocation failed"); log_error("struct str_list allocation failed");
_free(dev); _free(dev);
return NULL; return NULL;
@ -118,7 +118,7 @@ static struct device *_dev_create(dev_t d)
{ {
struct device *dev; struct device *dev;
if (!(dev = _alloc(sizeof(*dev)))) { if (!(dev = _zalloc(sizeof(*dev)))) {
log_error("struct device allocation failed"); log_error("struct device allocation failed");
return NULL; return NULL;
} }
@ -303,7 +303,7 @@ static int _compare_paths(const char *path0, const char *path1)
static int _add_alias(struct device *dev, const char *path) static int _add_alias(struct device *dev, const char *path)
{ {
struct str_list *sl = _alloc(sizeof(*sl)); struct str_list *sl = _zalloc(sizeof(*sl));
struct str_list *strl; struct str_list *strl;
const char *oldpath; const char *oldpath;
int prefer_old = 1; int prefer_old = 1;
@ -788,7 +788,7 @@ int dev_cache_add_dir(const char *path)
return 1; return 1;
} }
if (!(dl = _alloc(sizeof(*dl) + strlen(path) + 1))) { if (!(dl = _zalloc(sizeof(*dl) + strlen(path) + 1))) {
log_error("dir_list allocation failed"); log_error("dir_list allocation failed");
return 0; return 0;
} }
@ -814,7 +814,7 @@ int dev_cache_add_loopfile(const char *path)
return 1; return 1;
} }
if (!(dl = _alloc(sizeof(*dl) + strlen(path) + 1))) { if (!(dl = _zalloc(sizeof(*dl) + strlen(path) + 1))) {
log_error("dir_list allocation failed for file"); log_error("dir_list allocation failed for file");
return 0; return 0;
} }