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

coverity: fix issues reported by coverity

This commit is contained in:
Peter Rajnoha 2014-06-24 14:58:53 +02:00
parent 29ca0573ba
commit 3208396ce5
7 changed files with 20 additions and 17 deletions

View File

@ -110,12 +110,12 @@ static void _cluster_init_completed(void)
clvmd_cluster_init_completed(); clvmd_cluster_init_completed();
} }
static int _get_main_cluster_fd() static int _get_main_cluster_fd(void)
{ {
return cman_get_fd(c_handle); return cman_get_fd(c_handle);
} }
static int _get_num_nodes() static int _get_num_nodes(void)
{ {
int i; int i;
int nnodes = 0; int nnodes = 0;
@ -243,7 +243,7 @@ static void _add_up_node(const char *csid)
DEBUGLOG("Added new node %d to updown list\n", nodeid); DEBUGLOG("Added new node %d to updown list\n", nodeid);
} }
static void _cluster_closedown() static void _cluster_closedown(void)
{ {
dlm_release_lockspace(LOCKSPACE_NAME, lockspace, 1); dlm_release_lockspace(LOCKSPACE_NAME, lockspace, 1);
cman_finish(c_handle); cman_finish(c_handle);
@ -282,7 +282,7 @@ static void count_clvmds_running(void)
} }
/* Get a list of active cluster members */ /* Get a list of active cluster members */
static void get_members() static void get_members(void)
{ {
int retnodes; int retnodes;
int status; int status;
@ -380,7 +380,7 @@ static int nodeid_from_csid(const char *csid)
return nodeid; return nodeid;
} }
static int _is_quorate() static int _is_quorate(void)
{ {
return cman_is_quorate(c_handle); return cman_is_quorate(c_handle);
} }

View File

@ -642,7 +642,10 @@ static int _init_profiles(struct cmd_context *cmd)
dm_list_init(&cmd->profile_params->profiles); dm_list_init(&cmd->profile_params->profiles);
} }
dm_strncpy(cmd->profile_params->dir, dir, sizeof(cmd->profile_params->dir)); if (!(dm_strncpy(cmd->profile_params->dir, dir, sizeof(cmd->profile_params->dir)))) {
log_error("_init_profiles: dm_strncpy failed");
return 0;
}
return 1; return 1;
} }

View File

@ -334,7 +334,7 @@ struct dm_config_tree *remove_config_tree_by_source(struct cmd_context *cmd,
struct cft_check_handle *get_config_tree_check_handle(struct cmd_context *cmd, struct cft_check_handle *get_config_tree_check_handle(struct cmd_context *cmd,
struct dm_config_tree *cft) struct dm_config_tree *cft)
{ {
struct config_source *cs = dm_config_get_custom(cft); struct config_source *cs;
if (!(cs = dm_config_get_custom(cft))) if (!(cs = dm_config_get_custom(cft)))
return NULL; return NULL;
@ -438,7 +438,6 @@ static int _override_config_tree_from_metadata_profile(struct cmd_context *cmd,
if (cs->type == CONFIG_PROFILE_COMMAND) { if (cs->type == CONFIG_PROFILE_COMMAND) {
cft_previous = cft; cft_previous = cft;
cft = cft->cascade; cft = cft->cascade;
cs = dm_config_get_custom(cft);
} }
cs = dm_config_get_custom(cft); cs = dm_config_get_custom(cft);

View File

@ -370,7 +370,7 @@ static int _move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
/* FIXME: handle tags */ /* FIXME: handle tags */
if (!(pvl = find_pv_in_vg(vg_from, pv_name))) { if (!(pvl = find_pv_in_vg(vg_from, pv_name))) {
if (!enforce_pv_from_source && if (!enforce_pv_from_source &&
(pvl = find_pv_in_vg(vg_to, pv_name))) find_pv_in_vg(vg_to, pv_name))
/* /*
* PV has already been moved. This can happen if an * PV has already been moved. This can happen if an
* LV is being moved that has multiple sub-LVs on the * LV is being moved that has multiple sub-LVs on the

View File

@ -865,7 +865,7 @@ static int _raid_extract_images(struct logical_volume *lv, uint32_t new_count,
(first_seg(seg_metalv(seg, s))->segtype != error_segtype)) (first_seg(seg_metalv(seg, s))->segtype != error_segtype))
continue; continue;
if (target_pvs && !dm_list_empty(target_pvs) && if (!dm_list_empty(target_pvs) &&
(target_pvs != &lv->vg->pvs)) { (target_pvs != &lv->vg->pvs)) {
/* /*
* User has supplied a list of PVs, but we * User has supplied a list of PVs, but we

View File

@ -497,7 +497,8 @@ static void reap(daemon_state s, int waiting)
while (ts) { while (ts) {
if (waiting || !ts->active) { if (waiting || !ts->active) {
pthread_join(ts->client.thread_id, &rv); if ((errno = pthread_join(ts->client.thread_id, &rv)))
ERROR(&s, "pthread_join failed: %s", strerror(errno));
last->next = ts->next; last->next = ts->next;
dm_free(ts); dm_free(ts);
} else } else

View File

@ -1050,14 +1050,14 @@ struct dm_report *dm_report_init(uint32_t *report_types,
struct dm_report *rh; struct dm_report *rh;
const struct dm_report_object_type *type; const struct dm_report_object_type *type;
if (_contains_reserved_report_type(types))
return_NULL;
if (!(rh = dm_zalloc(sizeof(*rh)))) { if (!(rh = dm_zalloc(sizeof(*rh)))) {
log_error("dm_report_init: dm_malloc failed"); log_error("dm_report_init: dm_malloc failed");
return 0; return NULL;
} }
if (_contains_reserved_report_type(types))
return_0;
/* /*
* rh->report_types is updated in _parse_fields() and _parse_keys() * rh->report_types is updated in _parse_fields() and _parse_keys()
* to contain all types corresponding to the fields specified by * to contain all types corresponding to the fields specified by
@ -1432,7 +1432,7 @@ int dm_report_object(struct dm_report *rh, void *object)
if (!rh) { if (!rh) {
log_error(INTERNAL_ERROR "dm_report handler is NULL."); log_error(INTERNAL_ERROR "dm_report handler is NULL.");
goto out; return 0;
} }
if (rh->flags & RH_ALREADY_REPORTED) if (rh->flags & RH_ALREADY_REPORTED)
@ -1440,7 +1440,7 @@ int dm_report_object(struct dm_report *rh, void *object)
if (!(row = dm_pool_zalloc(rh->mem, sizeof(*row)))) { if (!(row = dm_pool_zalloc(rh->mem, sizeof(*row)))) {
log_error("dm_report_object: struct row allocation failed"); log_error("dm_report_object: struct row allocation failed");
goto out; return 0;
} }
row->rh = rh; row->rh = rh;