summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2006-05-09 21:23:51 +0000
committerAlasdair Kergon <agk@redhat.com>2006-05-09 21:23:51 +0000
commit72b2cb613a57918dadf9722c59a30ca71d751c8e (patch)
treeae0130e37b873591370abd65ff44cb2a554db049 /lib
parentb810c547004a98a7fc25c8dde65cf88d82ad9652 (diff)
downloadlvm2-72b2cb613a57918dadf9722c59a30ca71d751c8e.tar.gz
lvm2-72b2cb613a57918dadf9722c59a30ca71d751c8e.tar.xz
lvm2-72b2cb613a57918dadf9722c59a30ca71d751c8e.zip
Make SIZE_SHORT the default for display_size().
Fix some memory leaks in error paths found by coverity. Use C99 struct initialisers. Move DEFS into configure.h. Clean-ups to remove miscellaneous compiler warnings.
Diffstat (limited to 'lib')
-rw-r--r--lib/activate/dev_manager.c3
-rw-r--r--lib/activate/targets.h2
-rw-r--r--lib/cache/lvmcache.c4
-rw-r--r--lib/display/display.c68
-rw-r--r--lib/display/display.h7
-rw-r--r--lib/error/errseg.c10
-rw-r--r--lib/filters/filter.c4
-rw-r--r--lib/format1/disk-rep.c26
-rw-r--r--lib/format1/disk-rep.h16
-rw-r--r--lib/format1/format1.c39
-rw-r--r--lib/format1/import-export.c40
-rw-r--r--lib/format1/import-extents.c2
-rw-r--r--lib/format1/lvm1-label.c20
-rw-r--r--lib/format1/vg_number.c2
-rw-r--r--lib/format_pool/disk_rep.c2
-rw-r--r--lib/format_pool/format_pool.c17
-rw-r--r--lib/format_pool/import_export.c4
-rw-r--r--lib/format_pool/pool_label.c14
-rw-r--r--lib/format_text/archive.c2
-rw-r--r--lib/format_text/format-text.c63
-rw-r--r--lib/format_text/import_vsn1.c12
-rw-r--r--lib/format_text/layout.h6
-rw-r--r--lib/format_text/text_label.c20
-rw-r--r--lib/label/label.c6
-rw-r--r--lib/label/label.h4
-rw-r--r--lib/locking/locking.h4
-rw-r--r--lib/metadata/lv_alloc.h10
-rw-r--r--lib/metadata/lv_manip.c22
-rw-r--r--lib/metadata/metadata.c6
-rw-r--r--lib/metadata/metadata.h78
-rw-r--r--lib/metadata/mirror.c12
-rw-r--r--lib/metadata/pv_manip.c4
-rw-r--r--lib/metadata/segtype.h14
-rw-r--r--lib/mirror/mirrored.c29
-rw-r--r--lib/misc/configure.h430
-rw-r--r--lib/misc/configure.h.in429
-rw-r--r--lib/misc/lib.h2
-rw-r--r--lib/misc/lvm-exec.h4
-rw-r--r--lib/misc/lvm-file.c8
-rw-r--r--lib/misc/lvm-file.h5
-rw-r--r--lib/misc/sharedlib.c2
-rw-r--r--lib/misc/sharedlib.h7
-rw-r--r--lib/regex/matcher.c15
-rw-r--r--lib/report/report.c4
-rw-r--r--lib/snapshot/snapshot.c12
-rw-r--r--lib/striped/striped.c18
-rw-r--r--lib/uuid/uuid.c11
-rw-r--r--lib/uuid/uuid.h2
-rw-r--r--lib/zero/zero.c22
49 files changed, 1218 insertions, 325 deletions
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 72482565..934adecc 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -664,7 +664,8 @@ fail:
}
int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
- struct dm_tree_node *node, int start_area, int areas)
+ struct dm_tree_node *node, uint32_t start_area,
+ uint32_t areas)
{
uint64_t extent_size = seg->lv->vg->extent_size;
uint32_t s;
diff --git a/lib/activate/targets.h b/lib/activate/targets.h
index ac5413e8..4a1d0709 100644
--- a/lib/activate/targets.h
+++ b/lib/activate/targets.h
@@ -24,7 +24,7 @@ int compose_areas_line(struct dev_manager *dm, struct lv_segment *seg,
int start_area, int areas);
int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
- struct dm_tree_node *node, int start_area, int areas);
+ struct dm_tree_node *node, uint32_t start_area, uint32_t areas);
int build_dev_string(struct dev_manager *dm, char *dlid, char *devbuf,
size_t bufsize, const char *desc);
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index b2c0696b..f3bc24fd 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -474,10 +474,10 @@ static int _insert_vginfo(struct lvmcache_vginfo *new_vginfo, const char *vgid,
/* Pre-existing VG takes precedence. Unexported VG takes precedence. */
if (primary_vginfo) {
- if (!id_write_format((struct id *)vgid, uuid_new, sizeof(uuid_new)))
+ if (!id_write_format((const struct id *)vgid, uuid_new, sizeof(uuid_new)))
return_0;
- if (!id_write_format((struct id *)&primary_vginfo->vgid, uuid_primary,
+ if (!id_write_format((const struct id *)&primary_vginfo->vgid, uuid_primary,
sizeof(uuid_primary)))
return_0;
diff --git a/lib/display/display.c b/lib/display/display.c
index da63bc7a..a7743f2a 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -22,6 +22,8 @@
#define SIZE_BUF 128
+typedef enum { SIZE_LONG = 0, SIZE_SHORT = 1, SIZE_UNIT = 2 } size_len_t;
+
static struct {
alloc_policy_t alloc;
const char *str;
@@ -132,7 +134,7 @@ alloc_policy_t get_alloc_from_string(const char *str)
}
/* Size supplied in sectors */
-const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
+static const char *_display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
{
int s;
int suffix = 1, precision;
@@ -200,6 +202,21 @@ const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
return size_buf;
}
+const char *display_size_long(struct cmd_context *cmd, uint64_t size)
+{
+ return _display_size(cmd, size, SIZE_LONG);
+}
+
+const char *display_size_units(struct cmd_context *cmd, uint64_t size)
+{
+ return _display_size(cmd, size, SIZE_UNIT);
+}
+
+const char *display_size(struct cmd_context *cmd, uint64_t size)
+{
+ return _display_size(cmd, size, SIZE_SHORT);
+}
+
void pvdisplay_colons(struct physical_volume *pv)
{
char uuid[64];
@@ -228,7 +245,7 @@ void pvdisplay_colons(struct physical_volume *pv)
/* FIXME Include label fields */
void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
- void *handle)
+ void *handle __attribute((unused)))
{
char uuid[64];
const char *size;
@@ -248,18 +265,17 @@ void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
log_print("VG Name %s%s", pv->vg_name,
pv->status & EXPORTED_VG ? " (exported)" : "");
- size = display_size(cmd, (uint64_t) pv->size, SIZE_SHORT);
+ size = display_size(cmd, (uint64_t) pv->size);
if (pv->pe_size && pv->pe_count) {
/******** FIXME display LVM on-disk data size
- size2 = display_size(pv->size, SIZE_SHORT);
+ size2 = display_size(cmd, pv->size);
********/
log_print("PV Size %s" " / not usable %s", /* [LVM: %s]", */
size,
display_size(cmd, (pv->size -
- (uint64_t) pv->pe_count * pv->pe_size),
- SIZE_SHORT));
+ (uint64_t) pv->pe_count * pv->pe_size)));
} else
log_print("PV Size %s", size);
@@ -288,8 +304,10 @@ void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
return;
}
-int pvdisplay_short(struct cmd_context *cmd, struct volume_group *vg,
- struct physical_volume *pv, void *handle)
+int pvdisplay_short(struct cmd_context *cmd __attribute((unused)),
+ struct volume_group *vg __attribute((unused)),
+ struct physical_volume *pv,
+ void *handle __attribute((unused)))
{
char uuid[64];
@@ -334,7 +352,7 @@ void lvdisplay_colons(struct logical_volume *lv)
}
int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle)
+ void *handle __attribute((unused)))
{
struct lvinfo info;
int inkernel, snap_active = 0;
@@ -404,23 +422,21 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
log_print("LV Size %s",
display_size(cmd,
- snap_seg ? snap_seg->origin->size : lv->size,
- SIZE_SHORT));
+ snap_seg ? snap_seg->origin->size : lv->size));
log_print("Current LE %u",
snap_seg ? snap_seg->origin->le_count : lv->le_count);
if (snap_seg) {
log_print("COW-table size %s",
- display_size(cmd, (uint64_t) lv->size, SIZE_SHORT));
+ display_size(cmd, (uint64_t) lv->size));
log_print("COW-table LE %u", lv->le_count);
if (snap_active)
log_print("Allocated to snapshot %.2f%% ", snap_percent);
log_print("Snapshot chunk size %s",
- display_size(cmd, (uint64_t) snap_seg->chunk_size,
- SIZE_SHORT));
+ display_size(cmd, (uint64_t) snap_seg->chunk_size));
}
log_print("Segments %u", list_size(&lv->segments));
@@ -497,7 +513,7 @@ int lvdisplay_segments(struct logical_volume *lv)
return 1;
}
-void vgdisplay_extents(struct volume_group *vg)
+void vgdisplay_extents(struct volume_group *vg __attribute((unused)))
{
return;
}
@@ -544,7 +560,7 @@ void vgdisplay_full(struct volume_group *vg)
log_print("Open LV %u", lvs_in_vg_opened(vg));
/****** FIXME Max LV Size
log_print ( "MAX LV Size %s",
- ( s1 = display_size ( LVM_LV_SIZE_MAX(vg), SIZE_SHORT)));
+ ( s1 = display_size ( LVM_LV_SIZE_MAX(vg))));
free ( s1);
*********/
log_print("Max PV %u", vg->max_pv);
@@ -553,12 +569,10 @@ void vgdisplay_full(struct volume_group *vg)
log_print("VG Size %s",
display_size(vg->cmd,
- (uint64_t) vg->extent_count * vg->extent_size,
- SIZE_SHORT));
+ (uint64_t) vg->extent_count * vg->extent_size));
log_print("PE Size %s",
- display_size(vg->cmd, (uint64_t) vg->extent_size,
- SIZE_SHORT));
+ display_size(vg->cmd, (uint64_t) vg->extent_size));
log_print("Total PE %u", vg->extent_count);
@@ -566,12 +580,11 @@ void vgdisplay_full(struct volume_group *vg)
vg->extent_count - vg->free_count,
display_size(vg->cmd,
((uint64_t) vg->extent_count - vg->free_count) *
- vg->extent_size, SIZE_SHORT));
+ vg->extent_size));
log_print("Free PE / Size %u / %s", vg->free_count,
display_size(vg->cmd,
- (uint64_t) vg->free_count * vg->extent_size,
- SIZE_SHORT));
+ (uint64_t) vg->free_count * vg->extent_size));
if (!id_write_format(&vg->id, uuid, sizeof(uuid))) {
stack;
@@ -641,15 +654,12 @@ void vgdisplay_short(struct volume_group *vg)
log_print("\"%s\" %-9s [%-9s used / %s free]", vg->name,
/********* FIXME if "open" print "/used" else print "/idle"??? ******/
display_size(vg->cmd,
- (uint64_t) vg->extent_count * vg->extent_size,
- SIZE_SHORT),
+ (uint64_t) vg->extent_count * vg->extent_size),
display_size(vg->cmd,
((uint64_t) vg->extent_count -
- vg->free_count) * vg->extent_size,
- SIZE_SHORT),
+ vg->free_count) * vg->extent_size),
display_size(vg->cmd,
- (uint64_t) vg->free_count * vg->extent_size,
- SIZE_SHORT));
+ (uint64_t) vg->free_count * vg->extent_size));
return;
}
diff --git a/lib/display/display.h b/lib/display/display.h
index fbd7b266..2a932d9c 100644
--- a/lib/display/display.h
+++ b/lib/display/display.h
@@ -20,12 +20,13 @@
#include <stdint.h>
-typedef enum { SIZE_LONG = 0, SIZE_SHORT = 1, SIZE_UNIT = 2 } size_len_t;
-
uint64_t units_to_bytes(const char *units, char *unit_type);
/* Specify size in KB */
-const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl);
+const char *display_size(struct cmd_context *cmd, uint64_t size);
+const char *display_size_long(struct cmd_context *cmd, uint64_t size);
+const char *display_size_units(struct cmd_context *cmd, uint64_t size);
+
char *display_uuid(char *uuidstr);
void display_stripe(const struct lv_segment *seg, uint32_t s, const char *pre);
diff --git a/lib/error/errseg.c b/lib/error/errseg.c
index 1327dad7..520394b9 100644
--- a/lib/error/errseg.c
+++ b/lib/error/errseg.c
@@ -68,13 +68,13 @@ static void _errseg_destroy(const struct segment_type *segtype)
}
static struct segtype_handler _error_ops = {
- name:_errseg_name,
- merge_segments:_errseg_merge_segments,
+ .name = _errseg_name,
+ .merge_segments = _errseg_merge_segments,
#ifdef DEVMAPPER_SUPPORT
- add_target_line:_errseg_add_target_line,
- target_present:_errseg_target_present,
+ .add_target_line = _errseg_add_target_line,
+ .target_present = _errseg_target_present,
#endif
- destroy:_errseg_destroy,
+ .destroy = _errseg_destroy,
};
struct segment_type *init_error_segtype(struct cmd_context *cmd)
diff --git a/lib/filters/filter.c b/lib/filters/filter.c
index 15bc6450..88934c33 100644
--- a/lib/filters/filter.c
+++ b/lib/filters/filter.c
@@ -204,6 +204,7 @@ static int _scan_proc_dev(const char *proc, const struct config_node *cn)
if (cv->type != CFG_STRING) {
log_error("Expecting string in devices/types "
"in config file");
+ fclose(pd);
return 0;
}
dev_len = strlen(cv->v.str);
@@ -213,12 +214,14 @@ static int _scan_proc_dev(const char *proc, const struct config_node *cn)
log_error("Max partition count missing for %s "
"in devices/types in config file",
name);
+ fclose(pd);
return 0;
}
if (!cv->v.i) {
log_error("Zero partition count invalid for "
"%s in devices/types in config file",
name);
+ fclose(pd);
return 0;
}
if (dev_len <= strlen(line + i) &&
@@ -254,6 +257,7 @@ struct dev_filter *lvm_type_filter_create(const char *proc,
if (!_scan_proc_dev(proc, cn)) {
stack;
+ dm_free(f);
return NULL;
}
diff --git a/lib/format1/disk-rep.c b/lib/format1/disk-rep.c
index a5b4e090..4c0b1a5e 100644
--- a/lib/format1/disk-rep.c
+++ b/lib/format1/disk-rep.c
@@ -102,7 +102,7 @@ static void _xlate_vgd(struct vg_disk *disk)
static void _xlate_extents(struct pe_disk *extents, uint32_t count)
{
- int i;
+ unsigned i;
for (i = 0; i < count; i++) {
extents[i].lv_num = xlate16(extents[i].lv_num);
@@ -116,7 +116,7 @@ static void _xlate_extents(struct pe_disk *extents, uint32_t count)
static int _munge_formats(struct pv_disk *pvd)
{
uint32_t pe_start;
- int b, e;
+ unsigned b, e;
switch (pvd->version) {
case 1:
@@ -154,7 +154,7 @@ static int _munge_formats(struct pv_disk *pvd)
/* If UUID is missing, create one */
if (pvd->pv_uuid[0] == '\0')
- uuid_from_num(pvd->pv_uuid, pvd->pv_number);
+ uuid_from_num((char *)pvd->pv_uuid, pvd->pv_number);
return 1;
}
@@ -172,9 +172,9 @@ static void _munge_exported_vg(struct pv_disk *pvd)
return;
/* FIXME also check vgd->status & VG_EXPORTED? */
- l = strlen(pvd->vg_name);
+ l = strlen((char *)pvd->vg_name);
s = sizeof(EXPORTED_TAG);
- if (!strncmp(pvd->vg_name + l - s + 1, EXPORTED_TAG, s)) {
+ if (!strncmp((char *)pvd->vg_name + l - s + 1, EXPORTED_TAG, s)) {
pvd->vg_name[l - s + 1] = '\0';
pvd->pv_status |= VG_EXPORTED;
}
@@ -237,14 +237,14 @@ int read_vgd(struct device *dev, struct vg_disk *vgd, struct pv_disk *pvd)
/* If UUID is missing, create one */
if (vgd->vg_uuid[0] == '\0')
- uuid_from_num(vgd->vg_uuid, vgd->vg_number);
+ uuid_from_num((char *)vgd->vg_uuid, vgd->vg_number);
return 1;
}
static int _read_uuids(struct disk_list *data)
{
- int num_read = 0;
+ unsigned num_read = 0;
struct uuid_list *ul;
char buffer[NAME_LEN];
uint64_t pos = data->pvd.pv_uuidlist_on_disk.base;
@@ -322,12 +322,12 @@ static int _read_extents(struct disk_list *data)
static void __update_lvmcache(const struct format_type *fmt,
struct disk_list *dl,
struct device *dev, const char *vgid,
- int exported)
+ unsigned exported)
{
struct lvmcache_info *info;
- if (!(info = lvmcache_add(fmt->labeller, dl->pvd.pv_uuid, dev,
- dl->pvd.vg_name, vgid,
+ if (!(info = lvmcache_add(fmt->labeller, (char *)dl->pvd.pv_uuid, dev,
+ (char *)dl->pvd.vg_name, vgid,
exported ? EXPORTED_VG : 0))) {
stack;
return;
@@ -376,14 +376,14 @@ static struct disk_list *__read_disk(const struct format_type *fmt,
goto bad;
}
- if (vg_name && strcmp(vg_name, dl->pvd.vg_name)) {
+ if (vg_name && strcmp(vg_name, (char *)dl->pvd.vg_name)) {
log_very_verbose("%s is not a member of the VG %s",
name, vg_name);
__update_lvmcache(fmt, dl, dev, NULL, 0);
goto bad;
}
- __update_lvmcache(fmt, dl, dev, dl->vgd.vg_uuid,
+ __update_lvmcache(fmt, dl, dev, (char *)dl->vgd.vg_uuid,
dl->vgd.vg_status & VG_EXPORTED);
if (!_read_uuids(dl)) {
@@ -437,7 +437,7 @@ static void _add_pv_to_list(struct list *head, struct disk_list *data)
list_iterate_items(diskl, head) {
pvd = &diskl->pvd;
- if (!strncmp(data->pvd.pv_uuid, pvd->pv_uuid,
+ if (!strncmp((char *)data->pvd.pv_uuid, (char *)pvd->pv_uuid,
sizeof(pvd->pv_uuid))) {
if (MAJOR(data->dev->dev) != md_major()) {
log_very_verbose("Ignoring duplicate PV %s on "
diff --git a/lib/format1/disk-rep.h b/lib/format1/disk-rep.h
index d0e8d544..30ea3e11 100644
--- a/lib/format1/disk-rep.h
+++ b/lib/format1/disk-rep.h
@@ -73,16 +73,16 @@ struct data_area {
} __attribute__ ((packed));
struct pv_disk {
- uint8_t id[2];
+ int8_t id[2];
uint16_t version; /* lvm version */
struct data_area pv_on_disk;
struct data_area vg_on_disk;
struct data_area pv_uuidlist_on_disk;
struct data_area lv_on_disk;
struct data_area pe_on_disk;
- uint8_t pv_uuid[NAME_LEN];
- uint8_t vg_name[NAME_LEN];
- uint8_t system_id[NAME_LEN]; /* for vgexport/vgimport */
+ int8_t pv_uuid[NAME_LEN];
+ int8_t vg_name[NAME_LEN];
+ int8_t system_id[NAME_LEN]; /* for vgexport/vgimport */
uint32_t pv_major;
uint32_t pv_number;
uint32_t pv_status;
@@ -98,8 +98,8 @@ struct pv_disk {
} __attribute__ ((packed));
struct lv_disk {
- uint8_t lv_name[NAME_LEN];
- uint8_t vg_name[NAME_LEN];
+ int8_t lv_name[NAME_LEN];
+ int8_t vg_name[NAME_LEN];
uint32_t lv_access;
uint32_t lv_status;
uint32_t lv_open;
@@ -122,8 +122,8 @@ struct lv_disk {
} __attribute__ ((packed));
struct vg_disk {
- uint8_t vg_uuid[ID_LEN]; /* volume group UUID */
- uint8_t vg_name_dummy[NAME_LEN - ID_LEN]; /* rest of v1 VG name */
+ int8_t vg_uuid[ID_LEN]; /* volume group UUID */
+ int8_t vg_name_dummy[NAME_LEN - ID_LEN]; /* rest of v1 VG name */
uint32_t vg_number; /* volume group number */
uint32_t vg_access; /* read/write */
uint32_t vg_status; /* active or not */
diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index 1049ba09..394d659b 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -337,8 +337,7 @@ static int _format1_pv_setup(const struct format_type *fmt,
pv->size--;
if (pv->size > MAX_PV_SIZE) {
log_error("Physical volumes cannot be bigger than %s",
- display_size(fmt->cmd, (uint64_t) MAX_PV_SIZE,
- SIZE_SHORT));
+ display_size(fmt->cmd, (uint64_t) MAX_PV_SIZE));
return 0;
}
@@ -378,8 +377,7 @@ static int _format1_lv_setup(struct format_instance *fid, struct logical_volume
}
if (lv->size > max_size) {
log_error("logical volumes cannot be larger than %s",
- display_size(fid->fmt->cmd, max_size,
- SIZE_SHORT));
+ display_size(fid->fmt->cmd, max_size));
return 0;
}
@@ -460,18 +458,15 @@ static int _format1_vg_setup(struct format_instance *fid, struct volume_group *v
if (vg->extent_size > MAX_PE_SIZE || vg->extent_size < MIN_PE_SIZE) {
log_error("Extent size must be between %s and %s",
- display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE,
- SIZE_SHORT),
- display_size(fid->fmt->cmd, (uint64_t) MAX_PE_SIZE,
- SIZE_SHORT));
+ display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE),
+ display_size(fid->fmt->cmd, (uint64_t) MAX_PE_SIZE));
return 0;
}
if (vg->extent_size % MIN_PE_SIZE) {
log_error("Extent size must be multiple of %s",
- display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE,
- SIZE_SHORT));
+ display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE));
return 0;
}
@@ -485,7 +480,7 @@ static int _format1_vg_setup(struct format_instance *fid, struct volume_group *v
}
static int _format1_segtype_supported(struct format_instance *fid,
- struct segment_type *segtype)
+ const struct segment_type *segtype)
{
if (!(segtype->flags & SEG_FORMAT1_SUPPORT)) {
stack;
@@ -496,8 +491,8 @@ static int _format1_segtype_supported(struct format_instance *fid,
}
static struct metadata_area_ops _metadata_format1_ops = {
- vg_read:_format1_vg_read,
- vg_write:_format1_vg_write,
+ .vg_read = _format1_vg_read,
+ .vg_write = _format1_vg_write,
};
static struct format_instance *_format1_create_instance(const struct format_type *fmt,
@@ -541,15 +536,15 @@ static void _format1_destroy(const struct format_type *fmt)
}
static struct format_handler _format1_ops = {
- pv_read:_format1_pv_read,
- pv_setup:_format1_pv_setup,
- pv_write:_format1_pv_write,
- lv_setup:_format1_lv_setup,
- vg_setup:_format1_vg_setup,
- segtype_supported:_format1_segtype_supported,
- create_instance:_format1_create_instance,
- destroy_instance:_format1_destroy_instance,
- destroy:_format1_destroy,
+ .pv_read = _format1_pv_read,
+ .pv_setup = _format1_pv_setup,
+ .pv_write = _format1_pv_write,
+ .lv_setup = _format1_lv_setup,
+ .vg_setup = _format1_vg_setup,
+ .segtype_supported = _format1_segtype_supported,
+ .create_instance = _format1_create_instance,
+ .destroy_instance = _format1_destroy_instance,
+ .destroy = _format1_destroy,
};
#ifdef LVM1_INTERNAL
diff --git a/lib/format1/import-export.c b/lib/format1/import-export.c
index 52febf44..a9da3815 100644
--- a/lib/format1/import-export.c
+++ b/lib/format1/import-export.c
@@ -56,7 +56,7 @@ int import_pv(struct dm_pool *mem, struct device *dev,
memcpy(&pv->id, pvd->pv_uuid, ID_LEN);
pv->dev = dev;
- if (!(pv->vg_name = dm_pool_strdup(mem, pvd->vg_name))) {
+ if (!(pv->vg_name = dm_pool_strdup(mem, (char *)pvd->vg_name))) {
stack;
return 0;
}
@@ -65,10 +65,10 @@ int import_pv(struct dm_pool *mem, struct device *dev,
/* Store system_id from first PV if PV belongs to a VG */
if (vg && !*vg->system_id)
- strncpy(vg->system_id, pvd->system_id, NAME_LEN);
+ strncpy(vg->system_id, (char *)pvd->system_id, NAME_LEN);
if (vg &&
- strncmp(vg->system_id, pvd->system_id, sizeof(pvd->system_id)))
+ strncmp(vg->system_id, (char *)pvd->system_id, sizeof(pvd->system_id)))
log_very_verbose("System ID %s on %s differs from %s for "
"volume group", pvd->system_id,
dev_name(pv->dev), vg->system_id);
@@ -132,11 +132,11 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem,
memset(pvd->vg_name, 0, sizeof(pvd->vg_name));
if (pv->vg_name)
- strncpy(pvd->vg_name, pv->vg_name, sizeof(pvd->vg_name));
+ strncpy((char *)pvd->vg_name, pv->vg_name, sizeof(pvd->vg_name));
/* Preserve existing system_id if it exists */
if (vg && *vg->system_id)
- strncpy(pvd->system_id, vg->system_id, sizeof(pvd->system_id));
+ strncpy((char *)pvd->system_id, vg->system_id, sizeof(pvd->system_id));
/* Is VG already exported or being exported? */
if (vg && (vg->status & EXPORTED_VG)) {
@@ -144,24 +144,24 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem,
if (!*vg->system_id ||
strncmp(vg->system_id, EXPORTED_TAG,
sizeof(EXPORTED_TAG) - 1)) {
- if (!_system_id(cmd, pvd->system_id, EXPORTED_TAG)) {
+ if (!_system_id(cmd, (char *)pvd->system_id, EXPORTED_TAG)) {
stack;
return 0;
}
}
- if (strlen(pvd->vg_name) + sizeof(EXPORTED_TAG) >
+ if (strlen((char *)pvd->vg_name) + sizeof(EXPORTED_TAG) >
sizeof(pvd->vg_name)) {
log_error("Volume group name %s too long to export",
pvd->vg_name);
return 0;
}
- strcat(pvd->vg_name, EXPORTED_TAG);
+ strcat((char *)pvd->vg_name, EXPORTED_TAG);
}
/* Is VG being imported? */
if (vg && !(vg->status & EXPORTED_VG) && *vg->system_id &&
!strncmp(vg->system_id, EXPORTED_TAG, sizeof(EXPORTED_TAG) - 1)) {
- if (!_system_id(cmd, pvd->system_id, IMPORTED_TAG)) {
+ if (!_system_id(cmd, (char *)pvd->system_id, IMPORTED_TAG)) {
stack;
return 0;
}
@@ -169,7 +169,7 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem,
/* Generate system_id if PV is in VG */
if (!pvd->system_id || !*pvd->system_id)
- if (!_system_id(cmd, pvd->system_id, "")) {
+ if (!_system_id(cmd, (char *)pvd->system_id, "")) {
stack;
return 0;
}
@@ -177,8 +177,8 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem,
/* Update internal system_id if we changed it */
if (vg &&
(!*vg->system_id ||
- strncmp(vg->system_id, pvd->system_id, sizeof(pvd->system_id))))
- strncpy(vg->system_id, pvd->system_id, NAME_LEN);
+ strncmp(vg->system_id, (char *)pvd->system_id, sizeof(pvd->system_id))))
+ strncpy(vg->system_id, (char *)pvd->system_id, NAME_LEN);
//pvd->pv_major = MAJOR(pv->dev);
@@ -204,12 +204,12 @@ int import_vg(struct dm_pool *mem,
struct vg_disk *vgd = &dl->vgd;
memcpy(vg->id.uuid, vgd->vg_uuid, ID_LEN);
- if (!_check_vg_name(dl->pvd.vg_name)) {
+ if (!_check_vg_name((char *)dl->pvd.vg_name)) {
stack;
return 0;
}
- if (!(vg->name = dm_pool_strdup(mem, dl->pvd.vg_name))) {
+ if (!(vg->name = dm_pool_strdup(mem, (char *)dl->pvd.vg_name))) {
stack;
return 0;
}
@@ -292,7 +292,7 @@ int import_lv(struct dm_pool *mem, struct logical_volume *lv, struct lv_disk *lv
{
lvid_from_lvnum(&lv->lvid, &lv->vg->id, lvd->lv_number);
- if (!(lv->name = _create_lv_name(mem, lvd->lv_name))) {
+ if (!(lv->name = _create_lv_name(mem, (char *)lvd->lv_name))) {
stack;
return 0;
}
@@ -342,10 +342,10 @@ static void _export_lv(struct lv_disk *lvd, struct volume_group *vg,
struct logical_volume *lv, const char *dev_dir)
{
memset(lvd, 0, sizeof(*lvd));
- snprintf(lvd->lv_name, sizeof(lvd->lv_name), "%s%s/%s",
+ snprintf((char *)lvd->lv_name, sizeof(lvd->lv_name), "%s%s/%s",
dev_dir, vg->name, lv->name);
- strcpy(lvd->vg_name, vg->name);
+ strcpy((char *)lvd->vg_name, vg->name);
if (lv->status & LVM_READ)
lvd->lv_access |= LV_READ;
@@ -478,7 +478,7 @@ int import_lvs(struct dm_pool *mem, struct volume_group *vg, struct list *pvds)
list_iterate_items(ll, &dl->lvds) {
lvd = &ll->lvd;
- if (!find_lv(vg, lvd->lv_name) &&
+ if (!find_lv(vg, (char *)lvd->lv_name) &&
!_add_lv(mem, vg, lvd)) {
stack;
return 0;
@@ -586,14 +586,14 @@ int import_snapshots(struct dm_pool *mem, struct volume_group *vg,
lvnum = lvd->lv_number;
- if (lvnum > MAX_LV) {
+ if (lvnum >= MAX_LV) {
log_err("Logical volume number "
"out of bounds.");
return 0;
}
if (!lvs[lvnum] &&
- !(lvs[lvnum] = find_lv(vg, lvd->lv_name))) {
+ !(lvs[lvnum] = find_lv(vg, (char *)lvd->lv_name))) {
log_err("Couldn't find logical volume '%s'.",
lvd->lv_name);
return 0;
diff --git a/lib/format1/import-extents.c b/lib/format1/import-extents.c
index 54c4a546..0f308907 100644
--- a/lib/format1/import-extents.c
+++ b/lib/format1/import-extents.c
@@ -93,7 +93,7 @@ static int _fill_lv_array(struct lv_map **lvs,
memset(lvs, 0, sizeof(*lvs) * MAX_LV);
list_iterate_items(ll, &dl->lvds) {
- if (!(lvm = dm_hash_lookup(maps, strrchr(ll->lvd.lv_name, '/')
+ if (!(lvm = dm_hash_lookup(maps, strrchr((char *)ll->lvd.lv_name, '/')
+ 1))) {
log_err("Physical volume (%s) contains an "
"unknown logical volume (%s).",
diff --git a/lib/format1/lvm1-label.c b/lib/format1/lvm1-label.c
index 276b063e..320651c5 100644
--- a/lib/format1/lvm1-label.c
+++ b/lib/format1/lvm1-label.c
@@ -61,16 +61,16 @@ static int _lvm1_read(struct labeller *l, struct device *dev, char *buf,
struct vg_disk vgd;
struct lvmcache_info *info;
const char *vgid = NULL;
- int exported = 0;
+ unsigned exported = 0;
munge_pvd(dev, pvd);
if (*pvd->vg_name && read_vgd(dev, &vgd, pvd)) {
- vgid = vgd.vg_uuid;
+ vgid = (char *) vgd.vg_uuid;
exported = pvd->pv_status & VG_EXPORTED;
}
- if (!(info = lvmcache_add(l, pvd->pv_uuid, dev, pvd->vg_name, vgid,
+ if (!(info = lvmcache_add(l, (char *)pvd->pv_uuid, dev, (char *)pvd->vg_name, vgid,
exported))) {
stack;
return 0;
@@ -103,13 +103,13 @@ static void _lvm1_destroy(struct labeller *l)
}
struct label_ops _lvm1_ops = {
- can_handle:_lvm1_can_handle,
- write:_lvm1_write,
- read:_lvm1_read,
- verify:_lvm1_can_handle,
- initialise_label:_lvm1_initialise_label,
- destroy_label:_lvm1_destroy_label,
- destroy:_lvm1_destroy
+ .can_handle = _lvm1_can_handle,
+ .write = _lvm1_write,
+ .read = _lvm1_read,
+ .verify = _lvm1_can_handle,
+ .initialise_label = _lvm1_initialise_label,
+ .destroy_label = _lvm1_destroy_label,
+ .destroy = _lvm1_destroy,
};
struct labeller *lvm1_labeller_create(struct format_type *fmt)
diff --git a/lib/format1/vg_number.c b/lib/format1/vg_number.c
index a57dd097..ad3e996e 100644
--- a/lib/format1/vg_number.c
+++ b/lib/format1/vg_number.c
@@ -46,7 +46,7 @@ int get_free_vg_number(struct format_instance *fid, struct dev_filter *filter,
memset(numbers, 0, sizeof(numbers));
list_iterate_items(dl, &all_pvs) {
- if (!*dl->pvd.vg_name || !strcmp(dl->pvd.vg_name, candidate_vg))
+ if (!*dl->pvd.vg_name || !strcmp((char *)dl->pvd.vg_name, candidate_vg))
continue;
numbers[dl->vgd.vg_number] = 1;
diff --git a/lib/format_pool/disk_rep.c b/lib/format_pool/disk_rep.c
index 3c41e973..1afc2e4e 100644
--- a/lib/format_pool/disk_rep.c
+++ b/lib/format_pool/disk_rep.c
@@ -248,7 +248,7 @@ static int _read_vg_pds(const struct format_type *fmt, struct dm_pool *mem,
uint32_t sp_count = 0;
uint32_t *sp_devs = NULL;
- int i;
+ uint32_t i;
/* FIXME: maybe should return a different error in memory
* allocation failure */
diff --git a/lib/format_pool/format_pool.c b/lib/format_pool/format_pool.c
index 45bd781a..0452e824 100644
--- a/lib/format_pool/format_pool.c
+++ b/lib/format_pool/format_pool.c
@@ -79,7 +79,8 @@ static struct user_subpool *_build_usp(struct list *pls, struct dm_pool *mem,
static int _check_usp(char *vgname, struct user_subpool *usp, int sp_count)
{
- int i, j;
+ int i;
+ unsigned j;
for (i = 0; i < sp_count; i++) {
if (!usp[i].initialized) {
@@ -88,7 +89,7 @@ static int _check_usp(char *vgname, struct user_subpool *usp, int sp_count)
}
for (j = 0; j < usp[i].num_devs; j++) {
if (!usp[i].devs[j].initialized) {
- log_error("Missing device %d for subpool %d"
+ log_error("Missing device %u for subpool %d"
" in pool %s", j, i, vgname);
return 0;
}
@@ -262,7 +263,7 @@ static int _pool_pv_read(const struct format_type *fmt, const char *pv_name,
/* *INDENT-OFF* */
static struct metadata_area_ops _metadata_format_pool_ops = {
- vg_read:_pool_vg_read,
+ .vg_read = _pool_vg_read,
};
/* *INDENT-ON* */
@@ -310,11 +311,11 @@ static void _pool_destroy(const struct format_type *fmt)
/* *INDENT-OFF* */
static struct format_handler _format_pool_ops = {
- pv_read:_pool_pv_read,
- pv_setup:_pool_pv_setup,
- create_instance:_pool_create_instance,
- destroy_instance:_pool_destroy_instance,
- destroy:_pool_destroy,
+ .pv_read = _pool_pv_read,
+ .pv_setup = _pool_pv_setup,
+ .create_instance = _pool_create_instance,
+ .destroy_instance = _pool_destroy_instance,
+ .destroy = _pool_destroy,
};
/* *INDENT-ON */
diff --git a/lib/format_pool/import_export.c b/lib/format_pool/import_export.c
index e6f60999..2d3ad9db 100644
--- a/lib/format_pool/import_export.c
+++ b/lib/format_pool/import_export.c
@@ -203,7 +203,7 @@ static int _add_stripe_seg(struct dm_pool *mem,
{
struct lv_segment *seg;
struct segment_type *segtype;
- int j;
+ unsigned j;
uint32_t area_len;
if (usp->striping & (usp->striping - 1)) {
@@ -249,7 +249,7 @@ static int _add_linear_seg(struct dm_pool *mem,
{
struct lv_segment *seg;
struct segment_type *segtype;
- int j;
+ unsigned j;
uint32_t area_len;
if (!(segtype = get_segtype_from_string(lv->vg->cmd, "striped"))) {
diff --git a/lib/format_pool/pool_label.c b/lib/format_pool/pool_label.c
index f95e11bb..55c31fc0 100644
--- a/lib/format_pool/pool_label.c
+++ b/lib/format_pool/pool_label.c
@@ -82,13 +82,13 @@ static void _label_pool_destroy(struct labeller *l)
}
struct label_ops _pool_ops = {
- can_handle:_pool_can_handle,
- write:_pool_write,
- read:_pool_read,
- verify:_pool_can_handle,
- initialise_label:_pool_initialise_label,
- destroy_label:_pool_destroy_label,
- destroy:_label_pool_destroy
+ .can_handle = _pool_can_handle,
+ .write = _pool_write,
+ .read = _pool_read,
+ .verify = _pool_can_handle,
+ .initialise_label = _pool_initialise_label,
+ .destroy_label = _pool_destroy_label,
+ .destroy = _label_pool_destroy,
};
struct labeller *pool_labeller_create(struct format_type *fmt)
diff --git a/lib/format_text/archive.c b/lib/format_text/archive.c
index 9f419690..68cab240 100644
--- a/lib/format_text/archive.c
+++ b/lib/format_text/archive.c
@@ -328,7 +328,7 @@ static void _display_archive(struct cmd_context *cmd, struct archive_file *af)
}
log_print("VG name: \t%s", vg->name);
- log_print("Description:\t%s", desc ? desc : "<No description>");
+ log_print("Description:\t%s", desc ? : "<No description>");
log_print("Backup Time:\t%s", ctime(&when));
dm_pool_free(cmd->mem, vg);
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 3ca480b8..82a3dbf7 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -85,7 +85,7 @@ static int _text_lv_setup(struct format_instance *fid, struct logical_volume *lv
uint64_t max_size = UINT_MAX;
if (lv->size > max_size) {
- char *dummy = display_size(max_size, SIZE_SHORT);
+ char *dummy = display_size(max_size);
log_error("logical volumes cannot be larger than %s", dummy);
dm_free(dummy);
return 0;
@@ -143,7 +143,7 @@ static struct mda_header *_raw_read_mda_header(const struct format_type *fmt,
_xlate_mdah(mdah);
- if (strncmp(mdah->magic, FMTT_MAGIC, sizeof(mdah->magic))) {
+ if (strncmp((char *)mdah->magic, FMTT_MAGIC, sizeof(mdah->magic))) {
log_error("Wrong magic number in metadata area header");
return NULL;
}
@@ -167,7 +167,7 @@ static int _raw_write_mda_header(const struct format_type *fmt,
struct device *dev,
uint64_t start_byte, struct mda_header *mdah)
{
- strncpy(mdah->magic, FMTT_MAGIC, sizeof(mdah->magic));
+ strncpy((char *)mdah->magic, FMTT_MAGIC, sizeof(mdah->magic));
mdah->version = FMTT_VERSION;
mdah->start = start_byte;
@@ -1073,7 +1073,7 @@ static int _mda_setup(const struct format_type *fmt,
if (!dev_zero((struct device *) pv->dev, start1,
(size_t) (mda_size1 >
- wipe_size ? wipe_size : mda_size1))) {
+ wipe_size ? : mda_size1))) {
log_error("Failed to wipe new metadata area");
return 0;
}
@@ -1119,7 +1119,7 @@ static int _mda_setup(const struct format_type *fmt,
mda_size2)) return 0;
if (!dev_zero(pv->dev, start2,
(size_t) (mda_size1 >
- wipe_size ? wipe_size : mda_size1))) {
+ wipe_size ? : mda_size1))) {
log_error("Failed to wipe new metadata area");
return 0;
}
@@ -1376,28 +1376,28 @@ static void _text_destroy(const struct format_type *fmt)
}
static struct metadata_area_ops _metadata_text_file_ops = {
- vg_read:_vg_read_file,
- vg_read_precommit:_vg_read_precommit_file,
- vg_write:_vg_write_file,
- vg_remove:_vg_remove_file,
- vg_commit:_vg_commit_file
+ .vg_read = _vg_read_file,
+ .vg_read_precommit = _vg_read_precommit_file,
+ .vg_write = _vg_write_file,
+ .vg_remove = _vg_remove_file,
+ .vg_commit = _vg_commit_file
};
static struct metadata_area_ops _metadata_text_file_backup_ops = {
- vg_read:_vg_read_file,
- vg_write:_vg_write_file,
- vg_remove:_vg_remove_file,
- vg_commit:_vg_commit_file_backup
+ .vg_read = _vg_read_file,
+ .vg_write = _vg_write_file,
+ .vg_remove = _vg_remove_file,
+ .vg_commit = _vg_commit_file_backup
};
static struct metadata_area_ops _metadata_text_raw_ops = {
- vg_read:_vg_read_raw,
- vg_read_precommit:_vg_read_precommit_raw,
- vg_write:_vg_write_raw,
- vg_remove:_vg_remove_raw,
- vg_precommit:_vg_precommit_raw,
- vg_commit:_vg_commit_raw,
- vg_revert:_vg_revert_raw
+ .vg_read = _vg_read_raw,
+ .vg_read_precommit = _vg_read_precommit_raw,
+ .vg_write = _vg_write_raw,
+ .vg_remove = _vg_remove_raw,
+ .vg_precommit = _vg_precommit_raw,
+ .vg_commit = _vg_commit_raw,
+ .vg_revert = _vg_revert_raw
};
/* pvmetadatasize in sectors */
@@ -1656,15 +1656,15 @@ void *create_text_context(struct cmd_context *cmd, const char *path,
}
static struct format_handler _text_handler = {
- scan:_text_scan,
- pv_read:_text_pv_read,
- pv_setup:_text_pv_setup,
- pv_write:_text_pv_write,
- vg_setup:_text_vg_setup,
- lv_setup:_text_lv_setup,
- create_instance:_text_create_text_instance,
- destroy_instance:_text_destroy_instance,
- destroy:_text_destroy
+ .scan = _text_scan,
+ .pv_read = _text_pv_read,
+ .pv_setup = _text_pv_setup,
+ .pv_write = _text_pv_write,
+ .vg_setup = _text_vg_setup,
+ .lv_setup = _text_lv_setup,
+ .create_instance = _text_create_text_instance,
+ .destroy_instance = _text_destroy_instance,
+ .destroy = _text_destroy
};
static int _add_dir(const char *dir, struct list *dir_list)
@@ -1759,6 +1759,7 @@ struct format_type *create_text_format(struct cmd_context *cmd)
if (!(mda_lists = dm_malloc(sizeof(struct mda_lists)))) {
log_error("Failed to allocate dir_list");
+ dm_free(fmt);
return NULL;
}
@@ -1770,11 +1771,13 @@ struct format_type *create_text_format(struct cmd_context *cmd)
if (!(fmt->labeller = text_labeller_create(fmt))) {
log_error("Couldn't create text label handler.");
+ dm_free(fmt);
return NULL;
}
if (!(label_register_handler(FMT_TEXT_NAME, fmt->labeller))) {
log_error("Couldn't register text label handler.");
+ dm_free(fmt);
return NULL;
}
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index 9dc52c08..b3ea9679 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -370,7 +370,7 @@ int text_import_areas(struct lv_segment *seg, const struct config_node *sn,
} else {
log_error("Couldn't find volume '%s' "
"for segment '%s'.",
- cv->v.str ? cv->v.str : "NULL", seg_name);
+ cv->v.str ? : "NULL", seg_name);
return 0;
}
@@ -849,13 +849,13 @@ static const char *_read_vgname(const struct format_type *fmt,
}
static struct text_vg_version_ops _vsn1_ops = {
- check_version:_check_version,
- read_vg:_read_vg,
- read_desc:_read_desc,
- read_vgname:_read_vgname
+ .check_version = _check_version,
+ .read_vg = _read_vg,
+ .read_desc = _read_desc,
+ .read_vgname = _read_vgname,
};
struct text_vg_version_ops *text_vg_vsn1_init(void)
{
return &_vsn1_ops;
-};
+}
diff --git a/lib/format_text/layout.h b/lib/format_text/layout.h
index 2f8c9bce..40eae479 100644
--- a/lib/format_text/layout.h
+++ b/lib/format_text/layout.h
@@ -36,7 +36,7 @@ struct data_area_list {
/* Fields with the suffix _xl should be xlate'd wherever they appear */
/* On disk */
struct pv_header {
- uint8_t pv_uuid[ID_LEN];
+ int8_t pv_uuid[ID_LEN];
/* This size can be overridden if PV belongs to a VG */
uint64_t device_size_xl; /* Bytes */
@@ -58,7 +58,7 @@ struct raw_locn {
/* Structure size limited to one sector */
struct mda_header {
uint32_t checksum_xl; /* Checksum of rest of mda_header */
- uint8_t magic[16]; /* To aid scans for metadata */
+ int8_t magic[16]; /* To aid scans for metadata */
uint32_t version;
uint64_t start; /* Absolute start byte of mda_header */
uint64_t size; /* Size of metadata area */
@@ -83,6 +83,6 @@ struct mda_context {
#define FMTT_VERSION 1
#define MDA_HEADER_SIZE 512
#define LVM2_LABEL "LVM2 001"
-#define MDA_SIZE_MIN (8 * getpagesize())
+#define MDA_SIZE_MIN (8 * (unsigned) getpagesize())
#endif
diff --git a/lib/format_text/text_label.c b/lib/format_text/text_label.c
index 0da605ef..92f9e415 100644
--- a/lib/format_text/text_label.c
+++ b/lib/format_text/text_label.c
@@ -27,7 +27,7 @@ static int _text_can_handle(struct labeller *l, char *buf, uint64_t sector)
{
struct label_header *lh = (struct label_header *) buf;
- if (!strncmp(lh->type, LVM2_LABEL, sizeof(lh->type)))
+ if (!strncmp((char *)lh->type, LVM2_LABEL, sizeof(lh->type)))
return 1;
return 0;
@@ -46,7 +46,7 @@ static int _text_write(struct label *label, char *buf)
/* FIXME Move to where label is created */
strncpy(label->type, LVM2_LABEL, sizeof(label->type));
- strncpy(lh->type, label->type, sizeof(label->type));
+ strncpy((char *)lh->type, label->type, sizeof(label->type));
pvhdr = (struct pv_header *) ((void *) buf + xlate32(lh->offset_xl));
info = (struct lvmcache_info *) label->info;
@@ -203,7 +203,7 @@ static int _text_read(struct labeller *l, struct device *dev, char *buf,
pvhdr = (struct pv_header *) ((void *) buf + xlate32(lh->offset_xl));
- if (!(info = lvmcache_add(l, pvhdr->pv_uuid, dev, NULL, NULL, 0)))
+ if (!(info = lvmcache_add(l, (char *)pvhdr->pv_uuid, dev, NULL, NULL, 0)))
return_0;
*label = info->label;
@@ -264,13 +264,13 @@ static void _fmt_text_destroy(struct labeller *l)
}
struct label_ops _text_ops = {
- can_handle:_text_can_handle,
- write:_text_write,
- read:_text_read,
- verify:_text_can_handle,
- initialise_label:_text_initialise_label,
- destroy_label:_text_destroy_label,
- destroy:_fmt_text_destroy
+ .can_handle = _text_can_handle,
+ .write = _text_write,
+ .read = _text_read,
+ .verify = _text_can_handle,
+ .initialise_label = _text_initialise_label,
+ .destroy_label = _text_destroy_label,
+ .destroy = _fmt_text_destroy,
};
struct labeller *text_labeller_create(const struct format_type *fmt)
diff --git a/lib/label/label.c b/lib/label/label.c
index 3f7c2f65..3709e1cf 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -128,7 +128,7 @@ static struct labeller *_find_labeller(struct device *dev, char *buf,
lh = (struct label_header *) (readbuf +
(sector << SECTOR_SHIFT));
- if (!strncmp(lh->id, LABEL_ID, sizeof(lh->id))) {
+ if (!strncmp((char *)lh->id, LABEL_ID, sizeof(lh->id))) {
if (found) {
log_error("Ignoring additional label on %s at "
"sector %" PRIu64, dev_name(dev),
@@ -222,7 +222,7 @@ int label_remove(struct device *dev)
wipe = 0;
- if (!strncmp(lh->id, LABEL_ID, sizeof(lh->id))) {
+ if (!strncmp((char *)lh->id, LABEL_ID, sizeof(lh->id))) {
if (xlate64(lh->sector_xl) == sector)
wipe = 1;
} else {
@@ -307,7 +307,7 @@ int label_write(struct device *dev, struct label *label)
memset(buf, 0, LABEL_SIZE);
- strncpy(lh->id, LABEL_ID, sizeof(lh->id));
+ strncpy((char *)lh->id, LABEL_ID, sizeof(lh->id));
lh->sector_xl = xlate64(label->sector);
lh->offset_xl = xlate32(sizeof(*lh));
diff --git a/lib/label/label.h b/lib/label/label.h
index 99f1164d..bff3be1d 100644
--- a/lib/label/label.h
+++ b/lib/label/label.h
@@ -28,11 +28,11 @@ struct labeller;
/* On disk - 32 bytes */
struct label_header {
- uint8_t id[8]; /* LABELONE */
+ int8_t id[8]; /* LABELONE */
uint64_t sector_xl; /* Sector number of this label */
uint32_t crc_xl; /* From next field to end of sector */
uint32_t offset_xl; /* Offset from start of struct to contents */
- uint8_t type[8]; /* LVM2 001 */
+ int8_t type[8]; /* LVM2 001 */
} __attribute__ ((packed));
/* In core */
diff --git a/lib/locking/locking.h b/lib/locking/locking.h
index c01984f4..6281b36c 100644
--- a/lib/locking/locking.h
+++ b/lib/locking/locking.h
@@ -13,6 +13,9 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef _LVM_LOCKING_H
+#define _LVM_LOCKING_H
+
#include "uuid.h"
#include "config.h"
@@ -109,3 +112,4 @@ int suspend_lvs(struct cmd_context *cmd, struct list *lvs);
int resume_lvs(struct cmd_context *cmd, struct list *lvs);
int activate_lvs_excl(struct cmd_context *cmd, struct list *lvs);
+#endif
diff --git a/lib/metadata/lv_alloc.h b/lib/metadata/lv_alloc.h
index d7dd68a3..0957a26f 100644
--- a/lib/metadata/lv_alloc.h
+++ b/lib/metadata/lv_alloc.h
@@ -16,7 +16,7 @@
#ifndef _LVM_LV_ALLOC_H
struct lv_segment *alloc_lv_segment(struct dm_pool *mem,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
struct logical_volume *lv,
uint32_t le, uint32_t len,
uint32_t status,
@@ -44,7 +44,7 @@ void release_lv_segment_area(struct lv_segment *seg, uint32_t s,
struct alloc_handle;
struct alloc_handle *allocate_extents(struct volume_group *vg,
struct logical_volume *lv,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
uint32_t stripes,
uint32_t mirrors, uint32_t log_count,
uint32_t extents,
@@ -58,7 +58,7 @@ struct alloc_handle *allocate_extents(struct volume_group *vg,
int lv_add_segment(struct alloc_handle *ah,
uint32_t first_area, uint32_t num_areas,
struct logical_volume *lv,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
uint32_t stripe_size,
struct physical_volume *mirrored_pv,
uint32_t mirrored_pe,
@@ -68,12 +68,12 @@ int lv_add_segment(struct alloc_handle *ah,
int lv_add_log_segment(struct alloc_handle *ah, struct logical_volume *log_lv);
int lv_add_virtual_segment(struct logical_volume *lv, uint32_t status,
- uint32_t extents, struct segment_type *segtype);
+ uint32_t extents, const struct segment_type *segtype);
int lv_add_mirror_segment(struct alloc_handle *ah,
struct logical_volume *lv,
struct logical_volume **sub_lvs,
uint32_t mirrors,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
uint32_t status,
uint32_t region_size,
struct logical_volume *log_lv);
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index cf96cfd1..4217aa8c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -66,7 +66,7 @@ uint32_t find_free_lvnum(struct logical_volume *lv)
* All lv_segments get created here.
*/
struct lv_segment *alloc_lv_segment(struct dm_pool *mem,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
struct logical_volume *lv,
uint32_t le, uint32_t len,
uint32_t status,
@@ -124,7 +124,7 @@ struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv,
uint32_t status, uint32_t old_le_count)
{
struct lv_segment *seg;
- struct segment_type *segtype;
+ const struct segment_type *segtype;
segtype = get_segtype_from_string(lv->vg->cmd, "snapshot");
if (!segtype) {
@@ -418,7 +418,7 @@ struct alloc_handle {
* Preparation for a specific allocation attempt
*/
static struct alloc_handle *_alloc_init(struct dm_pool *mem,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
alloc_policy_t alloc,
uint32_t mirrors,
uint32_t stripes,
@@ -493,7 +493,7 @@ void alloc_destroy(struct alloc_handle *ah)
static int _setup_alloced_segment(struct logical_volume *lv, uint32_t status,
uint32_t area_count,
uint32_t stripe_size,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
struct alloced_area *aa,
struct physical_volume *mirrored_pv,
uint32_t mirrored_pe,
@@ -551,7 +551,7 @@ static int _setup_alloced_segments(struct logical_volume *lv,
uint32_t area_count,
uint32_t status,
uint32_t stripe_size,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
struct physical_volume *mirrored_pv,
uint32_t mirrored_pe,
uint32_t region_size,
@@ -823,7 +823,7 @@ static int _allocate(struct alloc_handle *ah,
uint32_t new_extents,
struct list *allocatable_pvs,
uint32_t stripes, uint32_t mirrors,
- struct segment_type *segtype)
+ const struct segment_type *segtype)
{
struct pv_area **areas;
uint32_t allocated = lv ? lv->le_count : 0;
@@ -925,7 +925,7 @@ static int _allocate(struct alloc_handle *ah,
}
int lv_add_virtual_segment(struct logical_volume *lv, uint32_t status,
- uint32_t extents, struct segment_type *segtype)
+ uint32_t extents, const struct segment_type *segtype)
{
struct lv_segment *seg;
@@ -951,7 +951,7 @@ int lv_add_virtual_segment(struct logical_volume *lv, uint32_t status,
*/
struct alloc_handle *allocate_extents(struct volume_group *vg,
struct logical_volume *lv,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
uint32_t stripes,
uint32_t mirrors, uint32_t log_count,
uint32_t extents,
@@ -1006,7 +1006,7 @@ struct alloc_handle *allocate_extents(struct volume_group *vg,
int lv_add_segment(struct alloc_handle *ah,
uint32_t first_area, uint32_t num_areas,
struct logical_volume *lv,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
uint32_t stripe_size,
struct physical_volume *mirrored_pv,
uint32_t mirrored_pe,
@@ -1094,7 +1094,7 @@ int lv_add_mirror_segment(struct alloc_handle *ah,
struct logical_volume *lv,
struct logical_volume **sub_lvs,
uint32_t mirrors,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
uint32_t status,
uint32_t region_size,
struct logical_volume *log_lv)
@@ -1175,7 +1175,7 @@ int lv_add_more_mirrored_areas(struct logical_volume *lv,
* Entry point for single-step LV allocation + extension.
*/
int lv_extend(struct logical_volume *lv,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
uint32_t stripes, uint32_t stripe_size,
uint32_t mirrors, uint32_t extents,
struct physical_volume *mirrored_pv, uint32_t mirrored_pe,
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index db707fc6..8a4b9b8b 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1142,7 +1142,7 @@ static struct volume_group *_vg_read_by_vgid(struct cmd_context *cmd,
vginfo->vgname && *vginfo->vgname) {
if ((vg = _vg_read(cmd, vginfo->vgname, vgid,
&consistent, precommitted)) &&
- !strncmp(vg->id.uuid, vgid, ID_LEN)) {
+ !strncmp((char *)vg->id.uuid, vgid, ID_LEN)) {
if (!consistent) {
log_error("Volume group %s metadata is "
"inconsistent", vginfo->vgname);
@@ -1173,7 +1173,7 @@ static struct volume_group *_vg_read_by_vgid(struct cmd_context *cmd,
consistent = 0;
if ((vg = _vg_read(cmd, vgname, vgid, &consistent,
precommitted)) &&
- !strncmp(vg->id.uuid, vgid, ID_LEN)) {
+ !strncmp((char *)vg->id.uuid, vgid, ID_LEN)) {
if (!consistent) {
log_error("Volume group %s metadata is "
"inconsistent", vgname);
@@ -1197,7 +1197,7 @@ struct logical_volume *lv_from_lvid(struct cmd_context *cmd, const char *lvid_s,
lvid = (const union lvid *) lvid_s;
log_very_verbose("Finding volume group for uuid %s", lvid_s);
- if (!(vg = _vg_read_by_vgid(cmd, lvid->id[0].uuid, precommitted))) {
+ if (!(vg = _vg_read_by_vgid(cmd, (char *)lvid->id[0].uuid, precommitted))) {
log_error("Volume group for uuid not found: %s", lvid_s);
return NULL;
}
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 81162025..1673fd83 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -26,10 +26,10 @@
#include "lvm-string.h"
#include "uuid.h"
-#define MAX_STRIPES 128
+#define MAX_STRIPES 128U
#define SECTOR_SHIFT 9L
#define SECTOR_SIZE ( 1L << SECTOR_SHIFT )
-#define STRIPE_SIZE_MIN ( getpagesize() >> SECTOR_SHIFT) /* PAGESIZE in sectors */
+#define STRIPE_SIZE_MIN ( (unsigned) getpagesize() >> SECTOR_SHIFT) /* PAGESIZE in sectors */
#define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */
#define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1)
#define PV_MIN_SIZE ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */
@@ -39,46 +39,46 @@
/* Various flags */
/* Note that the bits no longer necessarily correspond to LVM1 disk format */
-#define PARTIAL_VG 0x00000001 /* VG */
-#define EXPORTED_VG 0x00000002 /* VG PV */
-#define RESIZEABLE_VG 0x00000004 /* VG */
+#define PARTIAL_VG 0x00000001U /* VG */
+#define EXPORTED_VG 0x00000002U /* VG PV */
+#define RESIZEABLE_VG 0x00000004U /* VG */
/* May any free extents on this PV be used or must they be left free? */
-#define ALLOCATABLE_PV 0x00000008 /* PV */
+#define ALLOCATABLE_PV 0x00000008U /* PV */
-#define SPINDOWN_LV 0x00000010 /* LV */
-#define BADBLOCK_ON 0x00000020 /* LV */
-#define VISIBLE_LV 0x00000040 /* LV */
-#define FIXED_MINOR 0x00000080 /* LV */
+#define SPINDOWN_LV 0x00000010U /* LV */
+#define BADBLOCK_ON 0x00000020U /* LV */
+#define VISIBLE_LV 0x00000040U /* LV */
+#define FIXED_MINOR 0x00000080U /* LV */
/* FIXME Remove when metadata restructuring is completed */
-#define SNAPSHOT 0x00001000 /* LV - internal use only */
-#define PVMOVE 0x00002000 /* VG LV SEG */
-#define LOCKED 0x00004000 /* LV */
-#define MIRRORED 0x00008000 /* LV - internal use only */
-#define VIRTUAL 0x00010000 /* LV - internal use only */
-#define MIRROR_LOG 0x00020000 /* LV */
-#define MIRROR_IMAGE 0x00040000 /* LV */
-#define ACTIVATE_EXCL 0x00080000 /* LV - internal use only */
-#define PRECOMMITTED 0x00100000 /* VG - internal use only */
-
-#define LVM_READ 0x00000100 /* LV VG */
-#define LVM_WRITE 0x00000200 /* LV VG */
-#define CLUSTERED 0x00000400 /* VG */
-#define SHARED 0x00000800 /* VG */
+#define SNAPSHOT 0x00001000U /* LV - internal use only */
+#define PVMOVE 0x00002000U /* VG LV SEG */
+#define LOCKED 0x00004000U /* LV */
+#define MIRRORED 0x00008000U /* LV - internal use only */
+#define VIRTUAL 0x00010000U /* LV - internal use only */
+#define MIRROR_LOG 0x00020000U /* LV */
+#define MIRROR_IMAGE 0x00040000U /* LV */
+#define ACTIVATE_EXCL 0x00080000U /* LV - internal use only */
+#define PRECOMMITTED 0x00100000U /* VG - internal use only */
+
+#define LVM_READ 0x00000100U /* LV VG */
+#define LVM_WRITE 0x00000200U /* LV VG */
+#define CLUSTERED 0x00000400U /* VG */
+#define SHARED 0x00000800U /* VG */
/* Format features flags */
-#define FMT_SEGMENTS 0x00000001 /* Arbitrary segment params? */
-#define FMT_MDAS 0x00000002 /* Proper metadata areas? */
-#define FMT_TAGS 0x00000004 /* Tagging? */
-#define FMT_UNLIMITED_VOLS 0x00000008 /* Unlimited PVs/LVs? */
-#define FMT_RESTRICTED_LVIDS 0x00000010 /* LVID <= 255 */
-#define FMT_ORPHAN_ALLOCATABLE 0x00000020 /* Orphan PV allocatable? */
-#define FMT_PRECOMMIT 0x00000040 /* Supports pre-commit? */
-#define FMT_RESIZE_PV 0x00000080 /* Supports pvresize? */
-#define FMT_UNLIMITED_STRIPESIZE 0x00000100 /* Unlimited stripe size? */
+#define FMT_SEGMENTS 0x00000001U /* Arbitrary segment params? */
+#define FMT_MDAS 0x00000002U /* Proper metadata areas? */
+#define FMT_TAGS 0x00000004U /* Tagging? */
+#define FMT_UNLIMITED_VOLS 0x00000008U /* Unlimited PVs/LVs? */
+#define FMT_RESTRICTED_LVIDS 0x00000010U /* LVID <= 255 */
+#define FMT_ORPHAN_ALLOCATABLE 0x00000020U /* Orphan PV allocatable? */
+#define FMT_PRECOMMIT 0x00000040U /* Supports pre-commit? */
+#define FMT_RESIZE_PV 0x00000080U /* Supports pvresize? */
+#define FMT_UNLIMITED_STRIPESIZE 0x00000100U /* Unlimited stripe size? */
typedef enum {
- ALLOC_INVALID,
+ ALLOC_INVALID = 0,
ALLOC_INHERIT,
ALLOC_CONTIGUOUS,
ALLOC_NORMAL,
@@ -239,7 +239,7 @@ struct lv_segment {
struct list list;
struct logical_volume *lv;
- struct segment_type *segtype;
+ const struct segment_type *segtype;
uint32_t le;
uint32_t len;
@@ -378,7 +378,7 @@ struct format_handler {
* Check whether particular segment type is supported.
*/
int (*segtype_supported) (struct format_instance *fid,
- struct segment_type *segtype);
+ const struct segment_type *segtype);
/*
* Create format instance with a particular metadata area
@@ -463,7 +463,7 @@ int lv_empty(struct logical_volume *lv);
/* Entry point for all LV extent allocations */
int lv_extend(struct logical_volume *lv,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
uint32_t stripes, uint32_t stripe_size,
uint32_t mirrors, uint32_t extents,
struct physical_volume *mirrored_pv, uint32_t mirrored_pe,
@@ -568,7 +568,7 @@ int create_mirror_layers(struct alloc_handle *ah,
uint32_t first_area,
uint32_t num_mirrors,
struct logical_volume *lv,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
uint32_t status,
uint32_t region_size,
struct logical_volume *log_lv);
@@ -576,7 +576,7 @@ int add_mirror_layers(struct alloc_handle *ah,
uint32_t num_mirrors,
uint32_t existing_mirrors,
struct logical_volume *lv,
- struct segment_type *segtype);
+ const struct segment_type *segtype);
int remove_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
struct list *removable_pvs, int remove_log);
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index eeecedc8..84809d89 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -36,7 +36,7 @@ uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
{
uint32_t region_max;
- region_max = (1 << (ffs(extents) - 1)) * extent_size;
+ region_max = (1 << (ffs((int)extents) - 1)) * extent_size;
if (region_max < region_size) {
region_size = region_max;
@@ -234,7 +234,7 @@ static int _create_layers_for_mirror(struct alloc_handle *ah,
uint32_t first_area,
uint32_t num_mirrors,
struct logical_volume *lv,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
struct logical_volume **img_lvs)
{
uint32_t m;
@@ -284,7 +284,7 @@ int create_mirror_layers(struct alloc_handle *ah,
uint32_t first_area,
uint32_t num_mirrors,
struct logical_volume *lv,
- struct segment_type *segtype,
+ const struct segment_type *segtype,
uint32_t status,
uint32_t region_size,
struct logical_volume *log_lv)
@@ -328,7 +328,7 @@ int add_mirror_layers(struct alloc_handle *ah,
uint32_t num_mirrors,
uint32_t existing_mirrors,
struct logical_volume *lv,
- struct segment_type *segtype)
+ const struct segment_type *segtype)
{
struct logical_volume **img_lvs;
@@ -367,7 +367,7 @@ int insert_pvmove_mirrors(struct cmd_context *cmd,
uint32_t pe;
int lv_used = 0;
uint32_t s, start_le, extent_count = 0u;
- struct segment_type *segtype;
+ const struct segment_type *segtype;
struct pe_range *per;
uint32_t pe_start, pe_end, per_end, stripe_multiplier;
@@ -555,7 +555,7 @@ int remove_pvmove_mirrors(struct volume_group *vg,
return 0;
}
- release_lv_segment_area(mir_seg, !c, mir_seg->area_len);
+ release_lv_segment_area(mir_seg, c ? 0 : 1U, mir_seg->area_len);
/* Replace mirror with error segment */
if (!
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index 6c27a730..ca6ca3b5 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -136,8 +136,8 @@ int pv_split_segment(struct physical_volume *pv, uint32_t pe)
}
static struct pv_segment null_pv_segment = {
- pv: NULL,
- pe: 0
+ .pv = NULL,
+ .pe = 0,
};
struct pv_segment *assign_peg_to_lvseg(struct physical_volume *pv,
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index 608c6cda..42638407 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -25,13 +25,13 @@ struct config_node;
struct dev_manager;
/* Feature flags */
-#define SEG_CAN_SPLIT 0x00000001
-#define SEG_AREAS_STRIPED 0x00000002
-#define SEG_AREAS_MIRRORED 0x00000004
-#define SEG_SNAPSHOT 0x00000008
-#define SEG_FORMAT1_SUPPORT 0x00000010
-#define SEG_VIRTUAL 0x00000020
-#define SEG_CANNOT_BE_ZEROED 0x00000040
+#define SEG_CAN_SPLIT 0x00000001U
+#define SEG_AREAS_STRIPED 0x00000002U
+#define SEG_AREAS_MIRRORED 0x00000004U
+#define SEG_SNAPSHOT 0x00000008U
+#define SEG_FORMAT1_SUPPORT 0x00000010U
+#define SEG_VIRTUAL 0x00000020U
+#define SEG_CANNOT_BE_ZEROED 0x00000040U
#define seg_is_mirrored(seg) ((seg)->segtype->flags & SEG_AREAS_MIRRORED ? 1 : 0)
#define seg_is_striped(seg) ((seg)->segtype->flags & SEG_AREAS_STRIPED ? 1 : 0)
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index a056932f..cbd2427d 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -60,8 +60,7 @@ static void _mirrored_display(const struct lv_segment *seg)
if (seg->region_size) {
size = display_size(seg->lv->vg->cmd,
- (uint64_t) seg->region_size,
- SIZE_SHORT);
+ (uint64_t) seg->region_size);
log_print(" Mirror region size\t%s", size);
}
@@ -259,7 +258,7 @@ static int _mirrored_add_target_line(struct dev_manager *dm, struct dm_pool *mem
{
struct mirror_state *mirr_state;
uint32_t area_count = seg->area_count;
- int start_area = 0u;
+ unsigned start_area = 0u;
int mirror_status = MIRR_RUNNING;
uint32_t region_size, region_max;
int r;
@@ -299,7 +298,7 @@ static int _mirrored_add_target_line(struct dev_manager *dm, struct dm_pool *mem
region_size = seg->region_size;
} else {
/* Find largest power of 2 region size unit we can use */
- region_max = (1 << (ffs(seg->area_len) - 1)) *
+ region_max = (1 << (ffs((int)seg->area_len) - 1)) *
seg->lv->vg->extent_size;
region_size = mirr_state->default_region_size;
@@ -442,21 +441,21 @@ static void _mirrored_destroy(const struct segment_type *segtype)
}
static struct segtype_handler _mirrored_ops = {
- name:_mirrored_name,
- display:_mirrored_display,
- text_import_area_count:_mirrored_text_import_area_count,
- text_import:_mirrored_text_import,
- text_export:_mirrored_text_export,
+ .name = _mirrored_name,
+ .display = _mirrored_display,
+ .text_import_area_count = _mirrored_text_import_area_count,
+ .text_import = _mirrored_text_import,
+ .text_export = _mirrored_text_export,
#ifdef DEVMAPPER_SUPPORT
- add_target_line:_mirrored_add_target_line,
- target_percent:_mirrored_target_percent,
- target_present:_mirrored_target_present,
+ .add_target_line = _mirrored_add_target_line,
+ .target_percent = _mirrored_target_percent,
+ .target_present = _mirrored_target_present,
#ifdef DMEVENTD
- target_register_events:_target_register_events,
- target_unregister_events:_target_unregister_events,
+ .target_register_events = _target_register_events,
+ .target_unregister_events = _target_unregister_events,
#endif
#endif
- destroy:_mirrored_destroy,
+ .destroy = _mirrored_destroy,
};
#ifdef MIRRORED_INTERNAL
diff --git a/lib/misc/configure.h b/lib/misc/configure.h
new file mode 100644
index 00000000..4f3c1ee7
--- /dev/null
+++ b/lib/misc/configure.h
@@ -0,0 +1,430 @@
+/* lib/misc/configure.h. Generated by configure. */
+/* lib/misc/configure.h.in. Generated from configure.in by autoheader. */
+
+/* Define to 1 if the `closedir' function returns void instead of `int'. */
+/* #undef CLOSEDIR_VOID */
+
+/* Define to 1 to include built-in support for clustered LVM locking. */
+/* #undef CLUSTER_LOCKING_INTERNAL */
+
+/* Define to 1 to build the shared command library. */
+/* #undef CMDLIB */
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+ systems. This function is required for `alloca.c' support on those systems.
+ */
+/* #undef CRAY_STACKSEG_END */
+
+/* Define to 1 if using `alloca.c'. */
+/* #undef C_ALLOCA */
+
+/* Define to 1 to enable device-mapper interaction. */
+#define DEVMAPPER_SUPPORT 1
+
+/* Define to 1 to enable the device-mapper event daemon. */
+/* #undef DMEVENTD */
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#define HAVE_ALLOCA 1
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+ */
+#define HAVE_ALLOCA_H 1
+
+/* Define to 1 if you have the <asm/byteorder.h> header file. */
+/* #undef HAVE_ASM_BYTEORDER_H */
+
+/* Define to 1 if you have the <assert.h> header file. */
+#define HAVE_ASSERT_H 1
+
+/* Define to 1 if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+ */
+#define HAVE_DIRENT_H 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+/* #undef HAVE_DOPRNT */
+
+/* Define to 1 if you have the `dup2' function. */
+/* #undef HAVE_DUP2 */
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `fork' function. */
+#define HAVE_FORK 1
+
+/* Define to 1 if you have the <fstab.h> header file. */
+/* #undef HAVE_FSTAB_H */
+
+/* Define to 1 if you have the `gethostname' function. */
+#define HAVE_GETHOSTNAME 1
+
+/* Define to 1 if you have the `getmntent' function. */
+/* #undef HAVE_GETMNTENT */
+
+/* Define to 1 to if getopt_long is available. */
+#define HAVE_GETOPTLONG 1
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#define HAVE_GETOPT_H 1
+
+/* Define to 1 if you have the `getpagesize' function. */
+#define HAVE_GETPAGESIZE 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <libdevmapper.h> header file. */
+#define HAVE_LIBDEVMAPPER_H 1
+
+/* Define to 1 if dynamic libraries are available. */
+#define HAVE_LIBDL 1
+
+/* Define to 1 if you have the <libgen.h> header file. */
+#define HAVE_LIBGEN_H 1
+
+/* Define to 1 if you have the <libintl.h> header file. */
+/* #undef HAVE_LIBINTL_H */
+
+/* Define to 1 if you have the `readline' library (-lreadline). */
+/* #undef HAVE_LIBREADLINE */
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <linux/fs.h> header file. */
+/* #undef HAVE_LINUX_FS_H */
+
+/* Define to 1 if you have the <locale.h> header file. */
+#define HAVE_LOCALE_H 1
+
+/* Define to 1 if `lstat' has the bug that it succeeds when given the
+ zero-length file name argument. */
+/* #undef HAVE_LSTAT_EMPTY_STRING_BUG */
+
+/* Define to 1 if you have the <machine/endian.h> header file. */
+#define HAVE_MACHINE_ENDIAN_H 1
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+ to 0 otherwise. */
+#define HAVE_MALLOC 1
+
+/* Define to 1 if you have the <malloc.h> header file. */
+/* #undef HAVE_MALLOC_H */
+
+/* Define to 1 if you have the `memmove' function. */
+/* #undef HAVE_MEMMOVE */
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the `mkdir' function. */
+#define HAVE_MKDIR 1
+
+/* Define to 1 if you have a working `mmap' system call. */
+#define HAVE_MMAP 1
+
+/* Define to 1 if you have the <mntent.h> header file. */
+/* #undef HAVE_MNTENT_H */
+
+/* Define to 1 if you have the `munmap' function. */
+#define HAVE_MUNMAP 1
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+/* #undef HAVE_NDIR_H */
+
+/* Define to 1 if you have the <netdb.h> header file. */
+/* #undef HAVE_NETDB_H */
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+/* #undef HAVE_NETINET_IN_H */
+
+/* Define to 1 if you have the <pthread.h> header file. */
+/* #undef HAVE_PTHREAD_H */
+
+/* Define to 1 if you have the <readline/history.h> header file. */
+/* #undef HAVE_READLINE_HISTORY_H */
+
+/* Define to 1 if you have the <readline/readline.h> header file. */
+/* #undef HAVE_READLINE_READLINE_H */
+
+/* Define to 1 if rl_completion_matches() is available. */
+/* #undef HAVE_RL_COMPLETION_MATCHES */
+
+/* Define to 1 if you have the `rmdir' function. */
+#define HAVE_RMDIR 1
+
+/* Define to 1 if you have the <search.h> header file. */
+/* #undef HAVE_SEARCH_H */
+
+/* Define to 1 if you have the `select' function. */
+/* #undef HAVE_SELECT */
+
+/* Define to 1 to include support for selinux. */
+/* #undef HAVE_SELINUX */
+
+/* Define to 1 if you have the <selinux/selinux.h> header file. */
+/* #undef HAVE_SELINUX_SELINUX_H */
+
+/* Define to 1 if you have the `setlocale' function. */
+#define HAVE_SETLOCALE 1
+
+/* Define to 1 if you have the <signal.h> header file. */
+#define HAVE_SIGNAL_H 1
+
+/* Define to 1 if you have the `socket' function. */
+/* #undef HAVE_SOCKET */
+
+/* Define to 1 if `stat' has the bug that it succeeds when given the
+ zero-length file name argument. */
+/* #undef HAVE_STAT_EMPTY_STRING_BUG */
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#define HAVE_STRCASECMP 1
+
+/* Define to 1 if you have the `strchr' function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the `strdup' function. */
+#define HAVE_STRDUP 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strncasecmp' function. */
+#define HAVE_STRNCASECMP 1
+
+/* Define to 1 if you have the `strrchr' function. */
+#define HAVE_STRRCHR 1
+
+/* Define to 1 if you have the `strstr' function. */
+#define HAVE_STRSTR 1
+
+/* Define to 1 if you have the `strtol' function. */
+#define HAVE_STRTOL 1
+
+/* Define to 1 if you have the `strtoul' function. */
+#define HAVE_STRTOUL 1
+
+/* Define to 1 if `st_rdev' is member of `struct stat'. */
+#define HAVE_STRUCT_STAT_ST_RDEV 1
+
+/* Define to 1 if your `struct stat' has `st_rdev'. Deprecated, use
+ `HAVE_STRUCT_STAT_ST_RDEV' instead. */
+#define HAVE_ST_RDEV 1
+
+/* Define to 1 if you have the <syslog.h> header file. */
+#define HAVE_SYSLOG_H 1
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+ */
+/* #undef HAVE_SYS_DIR_H */
+
+/* Define to 1 if you have the <sys/disk.h> header file. */
+#define HAVE_SYS_DISK_H 1
+
+/* Define to 1 if you have the <sys/file.h> header file. */
+#define HAVE_SYS_FILE_H 1
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 1
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#define HAVE_SYS_MMAN_H 1
+
+/* Define to 1 if you have the <sys/mount.h> header file. */
+/* #undef HAVE_SYS_MOUNT_H */
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+ */
+/* #undef HAVE_SYS_NDIR_H */
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#define HAVE_SYS_PARAM_H 1
+
+/* Define to 1 if you have the <sys/resource.h> header file. */
+#define HAVE_SYS_RESOURCE_H 1
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+/* #undef HAVE_SYS_SELECT_H */
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+/* #undef HAVE_SYS_SOCKET_H */
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/uio.h> header file. */
+/* #undef HAVE_SYS_UIO_H */
+
+/* Define to 1 if you have the <sys/un.h> header file. */
+/* #undef HAVE_SYS_UN_H */
+
+/* Define to 1 if you have the <sys/utsname.h> header file. */
+#define HAVE_SYS_UTSNAME_H 1
+
+/* Define to 1 if you have the <sys/vfs.h> header file. */
+/* #undef HAVE_SYS_VFS_H */
+
+/* Define to 1 if you have the <sys/wait.h> header file. */
+#define HAVE_SYS_WAIT_H 1
+
+/* Define to 1 if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+
+/* Define to 1 if you have the `uname' function. */
+#define HAVE_UNAME 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the <utmpx.h> header file. */
+/* #undef HAVE_UTMPX_H */
+
+/* Define to 1 if you have the `vfork' function. */
+#define HAVE_VFORK 1
+
+/* Define to 1 if you have the <vfork.h> header file. */
+/* #undef HAVE_VFORK_H */
+
+/* Define to 1 if you have the `vprintf' function. */
+#define HAVE_VPRINTF 1
+
+/* Define to 1 if `fork' works. */
+#define HAVE_WORKING_FORK 1
+
+/* Define to 1 if `vfork' works. */
+#define HAVE_WORKING_VFORK 1
+
+/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
+ slash. */
+/* #undef LSTAT_FOLLOWS_SLASHED_SYMLINK */
+
+/* Define to 1 if 'lvm' should fall back to using LVM1 binaries if
+ device-mapper is missing from the kernel */
+/* #undef LVM1_FALLBACK */
+
+/* Define to 1 to include built-in support for LVM1 metadata. */
+#define LVM1_INTERNAL 1
+
+/* Define to 1 to include built-in support for mirrors. */
+#define MIRRORED_INTERNAL 1
+
+/* The path to 'modprobe', if available. */
+#define MODPROBE_CMD "/sbin/ifconfig"
+
+/* Define to 1 to enable O_DIRECT support. */
+/* #undef O_DIRECT_SUPPORT */
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME ""
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING ""
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION ""
+
+/* Define to 1 to include built-in support for GFS pool metadata. */
+#define POOL_INTERNAL 1
+
+/* Define to 1 to include the LVM readline shell. */
+/* #undef READLINE_SUPPORT */
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#define RETSIGTYPE void
+
+/* Define to the type of arg 1 for `select'. */
+/* #undef SELECT_TYPE_ARG1 */
+
+/* Define to the type of args 2, 3 and 4 for `select'. */
+/* #undef SELECT_TYPE_ARG234 */
+
+/* Define to the type of arg 5 for `select'. */
+/* #undef SELECT_TYPE_ARG5 */
+
+/* Define to 1 to include built-in support for snapshots. */
+#define SNAPSHOT_INTERNAL 1
+
+/* If using the C implementation of alloca, define if you know the
+ direction of stack growth for your system; otherwise it will be
+ automatically deduced at run-time.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown */
+/* #undef STACK_DIRECTION */
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#define TIME_WITH_SYS_TIME 1
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+/* #undef TM_IN_SYS_TIME */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
+
+/* Define to rpl_malloc if the replacement function should be used. */
+/* #undef malloc */
+
+/* Define to `int' if <sys/types.h> does not define. */
+/* #undef mode_t */
+
+/* Define to `long' if <sys/types.h> does not define. */
+/* #undef off_t */
+
+/* Define to `int' if <sys/types.h> does not define. */
+/* #undef pid_t */
+
+/* Define to `unsigned' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+/* Define as `fork' if `vfork' does not work. */
+/* #undef vfork */
diff --git a/lib/misc/configure.h.in b/lib/misc/configure.h.in
new file mode 100644
index 00000000..62871b4b
--- /dev/null
+++ b/lib/misc/configure.h.in
@@ -0,0 +1,429 @@
+/* lib/misc/configure.h.in. Generated from configure.in by autoheader. */
+
+/* Define to 1 if the `closedir' function returns void instead of `int'. */
+#undef CLOSEDIR_VOID
+
+/* Define to 1 to include built-in support for clustered LVM locking. */
+#undef CLUSTER_LOCKING_INTERNAL
+
+/* Define to 1 to build the shared command library. */
+#undef CMDLIB
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+ systems. This function is required for `alloca.c' support on those systems.
+ */
+#undef CRAY_STACKSEG_END
+
+/* Define to 1 if using `alloca.c'. */
+#undef C_ALLOCA
+
+/* Define to 1 to enable device-mapper interaction. */
+#undef DEVMAPPER_SUPPORT
+
+/* Define to 1 to enable the device-mapper event daemon. */
+#undef DMEVENTD
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#undef HAVE_ALLOCA
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+ */
+#undef HAVE_ALLOCA_H
+
+/* Define to 1 if you have the <asm/byteorder.h> header file. */
+#undef HAVE_ASM_BYTEORDER_H
+
+/* Define to 1 if you have the <assert.h> header file. */
+#undef HAVE_ASSERT_H
+
+/* Define to 1 if you have the <ctype.h> header file. */
+#undef HAVE_CTYPE_H
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_DIRENT_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+#undef HAVE_DOPRNT
+
+/* Define to 1 if you have the `dup2' function. */
+#undef HAVE_DUP2
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the `fork' function. */
+#undef HAVE_FORK
+
+/* Define to 1 if you have the <fstab.h> header file. */
+#undef HAVE_FSTAB_H
+
+/* Define to 1 if you have the `gethostname' function. */
+#undef HAVE_GETHOSTNAME
+
+/* Define to 1 if you have the `getmntent' function. */
+#undef HAVE_GETMNTENT
+
+/* Define to 1 to if getopt_long is available. */
+#undef HAVE_GETOPTLONG
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#undef HAVE_GETOPT_H
+
+/* Define to 1 if you have the `getpagesize' function. */
+#undef HAVE_GETPAGESIZE
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <libdevmapper.h> header file. */
+#undef HAVE_LIBDEVMAPPER_H
+
+/* Define to 1 if dynamic libraries are available. */
+#undef HAVE_LIBDL
+
+/* Define to 1 if you have the <libgen.h> header file. */
+#undef HAVE_LIBGEN_H
+
+/* Define to 1 if you have the <libintl.h> header file. */
+#undef HAVE_LIBINTL_H
+
+/* Define to 1 if you have the `readline' library (-lreadline). */
+#undef HAVE_LIBREADLINE
+
+/* Define to 1 if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* Define to 1 if you have the <linux/fs.h> header file. */
+#undef HAVE_LINUX_FS_H
+
+/* Define to 1 if you have the <locale.h> header file. */
+#undef HAVE_LOCALE_H
+
+/* Define to 1 if `lstat' has the bug that it succeeds when given the
+ zero-length file name argument. */
+#undef HAVE_LSTAT_EMPTY_STRING_BUG
+
+/* Define to 1 if you have the <machine/endian.h> header file. */
+#undef HAVE_MACHINE_ENDIAN_H
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+ to 0 otherwise. */
+#undef HAVE_MALLOC
+
+/* Define to 1 if you have the <malloc.h> header file. */
+#undef HAVE_MALLOC_H
+
+/* Define to 1 if you have the `memmove' function. */
+#undef HAVE_MEMMOVE
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#undef HAVE_MEMSET
+
+/* Define to 1 if you have the `mkdir' function. */
+#undef HAVE_MKDIR
+
+/* Define to 1 if you have a working `mmap' system call. */
+#undef HAVE_MMAP
+
+/* Define to 1 if you have the <mntent.h> header file. */
+#undef HAVE_MNTENT_H
+
+/* Define to 1 if you have the `munmap' function. */
+#undef HAVE_MUNMAP
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+#undef HAVE_NDIR_H
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#undef HAVE_NETDB_H
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#undef HAVE_NETINET_IN_H
+
+/* Define to 1 if you have the <pthread.h> header file. */
+#undef HAVE_PTHREAD_H
+
+/* Define to 1 if you have the <readline/history.h> header file. */
+#undef HAVE_READLINE_HISTORY_H
+
+/* Define to 1 if you have the <readline/readline.h> header file. */
+#undef HAVE_READLINE_READLINE_H
+
+/* Define to 1 if rl_completion_matches() is available. */
+#undef HAVE_RL_COMPLETION_MATCHES
+
+/* Define to 1 if you have the `rmdir' function. */
+#undef HAVE_RMDIR
+
+/* Define to 1 if you have the <search.h> header file. */
+#undef HAVE_SEARCH_H
+
+/* Define to 1 if you have the `select' function. */
+#undef HAVE_SELECT
+
+/* Define to 1 to include support for selinux. */
+#undef HAVE_SELINUX
+
+/* Define to 1 if you have the <selinux/selinux.h> header file. */
+#undef HAVE_SELINUX_SELINUX_H
+
+/* Define to 1 if you have the `setlocale' function. */
+#undef HAVE_SETLOCALE
+
+/* Define to 1 if you have the <signal.h> header file. */
+#undef HAVE_SIGNAL_H
+
+/* Define to 1 if you have the `socket' function. */
+#undef HAVE_SOCKET
+
+/* Define to 1 if `stat' has the bug that it succeeds when given the
+ zero-length file name argument. */
+#undef HAVE_STAT_EMPTY_STRING_BUG
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#undef HAVE_STDDEF_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#undef HAVE_STRCASECMP
+
+/* Define to 1 if you have the `strchr' function. */
+#undef HAVE_STRCHR
+
+/* Define to 1 if you have the `strdup' function. */
+#undef HAVE_STRDUP
+
+/* Define to 1 if you have the `strerror' function. */
+#undef HAVE_STRERROR
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strncasecmp' function. */
+#undef HAVE_STRNCASECMP
+
+/* Define to 1 if you have the `strrchr' function. */
+#undef HAVE_STRRCHR
+
+/* Define to 1 if you have the `strstr' function. */
+#undef HAVE_STRSTR
+
+/* Define to 1 if you have the `strtol' function. */
+#undef HAVE_STRTOL
+
+/* Define to 1 if you have the `strtoul' function. */
+#undef HAVE_STRTOUL
+
+/* Define to 1 if `st_rdev' is member of `struct stat'. */
+#undef HAVE_STRUCT_STAT_ST_RDEV
+
+/* Define to 1 if your `struct stat' has `st_rdev'. Deprecated, use
+ `HAVE_STRUCT_STAT_ST_RDEV' instead. */
+#undef HAVE_ST_RDEV
+
+/* Define to 1 if you have the <syslog.h> header file. */
+#undef HAVE_SYSLOG_H
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_DIR_H
+
+/* Define to 1 if you have the <sys/disk.h> header file. */
+#undef HAVE_SYS_DISK_H
+
+/* Define to 1 if you have the <sys/file.h> header file. */
+#undef HAVE_SYS_FILE_H
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#undef HAVE_SYS_IOCTL_H
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#undef HAVE_SYS_MMAN_H
+
+/* Define to 1 if you have the <sys/mount.h> header file. */
+#undef HAVE_SYS_MOUNT_H
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_NDIR_H
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
+/* Define to 1 if you have the <sys/resource.h> header file. */
+#undef HAVE_SYS_RESOURCE_H
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+#undef HAVE_SYS_SELECT_H
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#undef HAVE_SYS_SOCKET_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <sys/uio.h> header file. */
+#undef HAVE_SYS_UIO_H
+
+/* Define to 1 if you have the <sys/un.h> header file. */
+#undef HAVE_SYS_UN_H
+
+/* Define to 1 if you have the <sys/utsname.h> header file. */
+#undef HAVE_SYS_UTSNAME_H
+
+/* Define to 1 if you have the <sys/vfs.h> header file. */
+#undef HAVE_SYS_VFS_H
+
+/* Define to 1 if you have the <sys/wait.h> header file. */
+#undef HAVE_SYS_WAIT_H
+
+/* Define to 1 if you have the <time.h> header file. */
+#undef HAVE_TIME_H
+
+/* Define to 1 if you have the `uname' function. */
+#undef HAVE_UNAME
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the <utmpx.h> header file. */
+#undef HAVE_UTMPX_H
+
+/* Define to 1 if you have the `vfork' function. */
+#undef HAVE_VFORK
+
+/* Define to 1 if you have the <vfork.h> header file. */
+#undef HAVE_VFORK_H
+
+/* Define to 1 if you have the `vprintf' function. */
+#undef HAVE_VPRINTF
+
+/* Define to 1 if `fork' works. */
+#undef HAVE_WORKING_FORK
+
+/* Define to 1 if `vfork' works. */
+#undef HAVE_WORKING_VFORK
+
+/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
+ slash. */
+#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
+
+/* Define to 1 if 'lvm' should fall back to using LVM1 binaries if
+ device-mapper is missing from the kernel */
+#undef LVM1_FALLBACK
+
+/* Define to 1 to include built-in support for LVM1 metadata. */
+#undef LVM1_INTERNAL
+
+/* Define to 1 to include built-in support for mirrors. */
+#undef MIRRORED_INTERNAL
+
+/* The path to 'modprobe', if available. */
+#undef MODPROBE_CMD
+
+/* Define to 1 to enable O_DIRECT support. */
+#undef O_DIRECT_SUPPORT
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 to include built-in support for GFS pool metadata. */
+#undef POOL_INTERNAL
+
+/* Define to 1 to include the LVM readline shell. */
+#undef READLINE_SUPPORT
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#undef RETSIGTYPE
+
+/* Define to the type of arg 1 for `select'. */
+#undef SELECT_TYPE_ARG1
+
+/* Define to the type of args 2, 3 and 4 for `select'. */
+#undef SELECT_TYPE_ARG234
+
+/* Define to the type of arg 5 for `select'. */
+#undef SELECT_TYPE_ARG5
+
+/* Define to 1 to include built-in support for snapshots. */
+#undef SNAPSHOT_INTERNAL
+
+/* If using the C implementation of alloca, define if you know the
+ direction of stack growth for your system; otherwise it will be
+ automatically deduced at run-time.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown */
+#undef STACK_DIRECTION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+#undef TM_IN_SYS_TIME
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* Define to rpl_malloc if the replacement function should be used. */
+#undef malloc
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef mode_t
+
+/* Define to `long' if <sys/types.h> does not define. */
+#undef off_t
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef pid_t
+
+/* Define to `unsigned' if <sys/types.h> does not define. */
+#undef size_t
+
+/* Define as `fork' if `vfork' does not work. */
+#undef vfork
diff --git a/lib/misc/lib.h b/lib/misc/lib.h
index b5c55c1f..62c6fa88 100644
--- a/lib/misc/lib.h
+++ b/lib/misc/lib.h
@@ -19,6 +19,8 @@
#ifndef _LVM_LIB_H
#define _LVM_LIB_H
+#include <configure.h>
+
#define _REENTRANT
#define _GNU_SOURCE
#define _FILE_OFFSET_BITS 64
diff --git a/lib/misc/lvm-exec.h b/lib/misc/lvm-exec.h
index 9fbcdfec..282d1dcf 100644
--- a/lib/misc/lvm-exec.h
+++ b/lib/misc/lvm-exec.h
@@ -13,7 +13,11 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef _LVM_EXEC_H
+#define _LVM_EXEC_H
+
#include "lib.h"
int exec_cmd(const char *command, const char *fscmd, const char *lv_path,
const char *size);
+#endif
diff --git a/lib/misc/lvm-file.c b/lib/misc/lvm-file.c
index c92dbeba..6cc66d46 100644
--- a/lib/misc/lvm-file.c
+++ b/lib/misc/lvm-file.c
@@ -35,10 +35,10 @@ int create_temp_name(const char *dir, char *buffer, size_t len, int *fd)
pid_t pid;
char hostname[255];
struct flock lock = {
- l_type:F_WRLCK,
- l_whence:0,
- l_start:0,
- l_len:0
+ .l_type = F_WRLCK,
+ .l_whence = 0,
+ .l_start = 0,
+ .l_len = 0
};
num = rand();
diff --git a/lib/misc/lvm-file.h b/lib/misc/lvm-file.h
index b135d5da..b188568c 100644
--- a/lib/misc/lvm-file.h
+++ b/lib/misc/lvm-file.h
@@ -13,6 +13,9 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef _LVM_FILE_H
+#define _LVM_FILE_H
+
/*
* Create a temporary filename, and opens a descriptor to the file.
*/
@@ -44,3 +47,5 @@ int create_dir(const char *dir);
/* Sync directory changes */
void sync_dir(const char *file);
+
+#endif
diff --git a/lib/misc/sharedlib.c b/lib/misc/sharedlib.c
index 81bde247..b38ede7d 100644
--- a/lib/misc/sharedlib.c
+++ b/lib/misc/sharedlib.c
@@ -23,7 +23,7 @@
#include <dlfcn.h>
void get_shared_library_path(struct config_tree *cft, const char *libname,
- char *path, int path_len)
+ char *path, size_t path_len)
{
struct stat info;
const char *lib_dir;
diff --git a/lib/misc/sharedlib.h b/lib/misc/sharedlib.h
index 385c988e..3fa6afff 100644
--- a/lib/misc/sharedlib.h
+++ b/lib/misc/sharedlib.h
@@ -13,10 +13,15 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef _LVM_SHAREDLIB_H
+#define _LVM_SHAREDLIB_H
+
#include "config.h"
#include <dlfcn.h>
void get_shared_library_path(struct config_tree *cft, const char *libname,
- char *path, int path_len);
+ char *path, size_t path_len);
void *load_shared_library(struct config_tree *cf, const char *libname,
const char *what, int silent);
+
+#endif
diff --git a/lib/regex/matcher.c b/lib/regex/matcher.c
index 6058726d..a21e253e 100644
--- a/lib/regex/matcher.c
+++ b/lib/regex/matcher.c
@@ -196,17 +196,13 @@ static int _calc_states(struct matcher *m, struct rx_node *rx)
struct state_queue *h, *t, *tmp;
struct dfa_state *dfa, *ldfa;
int i, a, set_bits = 0, count = 0;
- dm_bitset_t bs = dm_bitset_create(m->scratch, m->num_nodes), dfa_bits;
+ dm_bitset_t bs, dfa_bits;
- if (!tt) {
- stack;
- return 0;
- }
+ if (!tt)
+ return_0;
- if (!bs) {
- stack;
- return 0;
- }
+ if (!(bs = dm_bitset_create(m->scratch, m->num_nodes)))
+ return_0;
/* create first state */
dfa = _create_dfa_state(m->mem);
@@ -284,6 +280,7 @@ struct matcher *matcher_create(struct dm_pool *mem, const char **patterns,
if (!(m = dm_pool_alloc(mem, sizeof(*m)))) {
stack;
+ dm_pool_destroy(scratch);
return NULL;
}
diff --git a/lib/report/report.c b/lib/report/report.c
index 6218d204..cc326961 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -578,7 +578,7 @@ static int _size32_disp(struct report_handle *rh, struct field *field,
const char *disp;
uint64_t *sortval;
- if (!*(disp = display_size(rh->cmd, (uint64_t) size, SIZE_UNIT))) {
+ if (!*(disp = display_size_units(rh->cmd, (uint64_t) size))) {
stack;
return 0;
}
@@ -606,7 +606,7 @@ static int _size64_disp(struct report_handle *rh, struct field *field,
const char *disp;
uint64_t *sortval;
- if (!*(disp = display_size(rh->cmd, size, SIZE_UNIT))) {
+ if (!*(disp = display_size_units(rh->cmd, size))) {
stack;
return 0;
}
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index 864ad1a3..f1733639 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -130,14 +130,14 @@ static void _snap_destroy(const struct segment_type *segtype)
}
static struct segtype_handler _snapshot_ops = {
- name:_snap_name,
- text_import:_snap_text_import,
- text_export:_snap_text_export,
+ .name = _snap_name,
+ .text_import = _snap_text_import,
+ .text_export = _snap_text_export,
#ifdef DEVMAPPER_SUPPORT
- target_percent:_snap_target_percent,
- target_present:_snap_target_present,
+ .target_percent = _snap_target_percent,
+ .target_present = _snap_target_present,
#endif
- destroy:_snap_destroy,
+ .destroy = _snap_destroy,
};
#ifdef SNAPSHOT_INTERNAL
diff --git a/lib/striped/striped.c b/lib/striped/striped.c
index 46cb1985..f7c2684b 100644
--- a/lib/striped/striped.c
+++ b/lib/striped/striped.c
@@ -193,17 +193,17 @@ static void _striped_destroy(const struct segment_type *segtype)
}
static struct segtype_handler _striped_ops = {
- name:_striped_name,
- display:_striped_display,
- text_import_area_count:_striped_text_import_area_count,
- text_import:_striped_text_import,
- text_export:_striped_text_export,
- merge_segments:_striped_merge_segments,
+ .name = _striped_name,
+ .display = _striped_display,
+ .text_import_area_count = _striped_text_import_area_count,
+ .text_import = _striped_text_import,
+ .text_export = _striped_text_export,
+ .merge_segments = _striped_merge_segments,
#ifdef DEVMAPPER_SUPPORT
- add_target_line:_striped_add_target_line,
- target_present:_striped_target_present,
+ .add_target_line = _striped_add_target_line,
+ .target_present = _striped_target_present,
#endif
- destroy:_striped_destroy,
+ .destroy = _striped_destroy,
};
struct segment_type *init_striped_segtype(struct cmd_context *cmd)
diff --git a/lib/uuid/uuid.c b/lib/uuid/uuid.c
index 61e78930..fb60a26c 100644
--- a/lib/uuid/uuid.c
+++ b/lib/uuid/uuid.c
@@ -20,11 +20,11 @@
#include <fcntl.h>
#include <unistd.h>
-static unsigned char _c[] =
+static char _c[] =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#";
static int _built_inverse;
-static unsigned char _inverse_c[256];
+static char _inverse_c[256];
int lvid_create(union lvid *lvid, struct id *vgid)
{
@@ -63,7 +63,7 @@ int lvid_from_lvnum(union lvid *lvid, struct id *vgid, uint32_t lv_num)
int lvnum_from_lvid(union lvid *lvid)
{
int i, lv_num = 0;
- unsigned char *c;
+ char *c;
for (i = 0; i < ID_LEN; i++) {
lv_num *= sizeof(_c) - 1;
@@ -76,7 +76,8 @@ int lvnum_from_lvid(union lvid *lvid)
int id_create(struct id *id)
{
- int randomfile, i;
+ int randomfile;
+ unsigned i;
size_t len = sizeof(id->uuid);
memset(id->uuid, 0, len);
@@ -85,7 +86,7 @@ int id_create(struct id *id)
return 0;
}
- if (read(randomfile, id->uuid, len) != len) {
+ if (read(randomfile, id->uuid, len) != (ssize_t) len) {
log_sys_error("read", "id_create: /dev/urandom");
if (close(randomfile))
stack;
diff --git a/lib/uuid/uuid.h b/lib/uuid/uuid.h
index fcef414b..1a327f8f 100644
--- a/lib/uuid/uuid.h
+++ b/lib/uuid/uuid.h
@@ -20,7 +20,7 @@
#define ID_LEN_S "32"
struct id {
- uint8_t uuid[ID_LEN];
+ int8_t uuid[ID_LEN];
};
/*
diff --git a/lib/zero/zero.c b/lib/zero/zero.c
index 6756a787..e791a2eb 100644
--- a/lib/zero/zero.c
+++ b/lib/zero/zero.c
@@ -38,11 +38,13 @@ static int _zero_merge_segments(struct lv_segment *seg1, struct lv_segment *seg2
}
#ifdef DEVMAPPER_SUPPORT
-static int _zero_add_target_line(struct dev_manager *dm, struct dm_pool *mem,
- struct config_tree *cft, void **target_state,
- struct lv_segment *seg,
- struct dm_tree_node *node, uint64_t len,
- uint32_t *pvmove_mirror_count)
+static int _zero_add_target_line(struct dev_manager *dm __attribute((unused)),
+ struct dm_pool *mem __attribute((unused)),
+ struct config_tree *cft __attribute((unused)),
+ void **target_state __attribute((unused)),
+ struct lv_segment *seg __attribute((unused)),
+ struct dm_tree_node *node,uint64_t len,
+ uint32_t *pvmove_mirror_count __attribute((unused)))
{
return dm_tree_node_add_zero_target(node, len);
}
@@ -67,13 +69,13 @@ static void _zero_destroy(const struct segment_type *segtype)
}
static struct segtype_handler _zero_ops = {
- name:_zero_name,
- merge_segments:_zero_merge_segments,
+ .name = _zero_name,
+ .merge_segments = _zero_merge_segments,
#ifdef DEVMAPPER_SUPPORT
- add_target_line:_zero_add_target_line,
- target_present:_zero_target_present,
+ .add_target_line = _zero_add_target_line,
+ .target_present = _zero_target_present,
#endif
- destroy:_zero_destroy,
+ .destroy = _zero_destroy,
};
struct segment_type *init_zero_segtype(struct cmd_context *cmd)