if (!info)
goto bad;
memset(info, 0, sizeof(struct vg_info));
- dm_hash_insert(s->vgid_to_info, uuid, (void*)info);
+ if (!dm_hash_insert(s->vgid_to_info, uuid, (void*)info))
+ goto bad;
}
info->external_version = new_version;
else
format_info();
out:
- close(fd);
+ if (close(fd))
+ log_error("failed to close dump socket %d", fd);
return rv;
}
cl->id, cl->pi, cl->fd);
/* assert cl->pi != -1 */
/* assert pollfd[pi].fd == FD_IGNORE */
- close(cl->fd);
+ if (close(cl->fd))
+ log_error("client close %d pi %d fd %d failed",
+ cl->id, cl->pi, cl->fd);
rem_pollfd(cl->pi);
cl->pi = -1;
cl->fd = -1;
cl->pi = -1;
cl->fd = -1;
cl->poll_ignore = 0;
- close(pollfd[i].fd);
+ if (close(pollfd[i].fd))
+ log_error("close fd %d failed", pollfd[i].fd);
pollfd[i].fd = POLL_FD_UNUSED;
pollfd[i].events = 0;
pollfd[i].revents = 0;
/* don't think this can happen */
log_error("no client for index %d fd %d",
i, pollfd[i].fd);
- close(pollfd[i].fd);
+ if (close(pollfd[i].fd))
+ log_error("close fd %d failed", pollfd[i].fd);
pollfd[i].fd = POLL_FD_UNUSED;
pollfd[i].events = 0;
pollfd[i].revents = 0;
static int read_cluster_name(char *clustername)
{
+ static const char close_error_msg[] = "read_cluster_name: close_error %d";
char *n;
int fd;
int rv;
rv = read(fd, clustername, MAX_ARGS - 1);
if (rv < 0) {
log_error("read_cluster_name: cluster name read error %d, check dlm_controld", fd);
- close(fd);
+ if (close(fd))
+ log_error(close_error_msg, fd);
return rv;
}
n = strstr(clustername, "\n");
if (n)
*n = '\0';
- close(fd);
+ if (close(fd))
+ log_error(close_error_msg, fd);
return 0;
}
continue;
if (!(ls = alloc_lockspace())) {
- closedir(ls_dir);
+ if (closedir(ls_dir))
+ log_error("lm_get_lockspace_dlm: closedir failed");
return -ENOMEM;
}
break;
}
}
- fclose(file);
+ if (fclose(file))
+ log_error("failed to close host id file %s", daemon_host_id_file);
out:
log_debug("host_id %d from %s", host_id, daemon_host_id_file);
return host_id;
return 0;
fail:
- close(lms->sock);
+ if (close(lms->sock))
+ log_error("failed to close sanlock daemon socket connection");
free(lms);
ls->lm_data = NULL;
return rv;
}
}
out:
- close(lms->sock);
+ if (close(lms->sock))
+ log_error("failed to close sanlock daemon socket connection");
free(lms);
ls->lm_data = NULL;
data->errpipe[0] = -1;
if (data->outpipe[0] >= 0)
- close(data->outpipe[0]);
+ (void) close(data->outpipe[0]);
if (data->outpipe[1] >= 0)
- close(data->outpipe[1]);
+ (void) close(data->outpipe[1]);
if (data->errpipe[0] >= 0)
- close(data->errpipe[0]);
+ (void) close(data->errpipe[0]);
if (data->errpipe[1] >= 0)
- close(data->errpipe[1]);
+ (void) close(data->errpipe[1]);
dm_free(data);
}
unsigned total_usecs_waited = 0;
unsigned max_remaining_sleep_times = 1;
unsigned wait_usecs;
+ int r;
retry:
req = daemon_request_make(id);
- if (_lvmetad_token)
- daemon_request_extend(req, "token = %s", _lvmetad_token, NULL);
+ if (_lvmetad_token && !daemon_request_extend(req, "token = %s", _lvmetad_token, NULL)) {
+ repl.error = ENOMEM;
+ return repl;
+ }
va_start(ap, id);
- daemon_request_extend_v(req, ap);
+ r = daemon_request_extend_v(req, ap);
va_end(ap);
+ if (!r) {
+ repl.error = ENOMEM;
+ return repl;
+ }
repl = daemon_send(_lvmetad, req);
if (!pvl->pv->dev)
continue;
- info = lvmcache_info_from_pvid((const char *)&pvl->pv->id, 0);
+ if (!(info = lvmcache_info_from_pvid((const char *)&pvl->pv->id, 0))) {
+ log_error("Failed to find cached info for PV %s.", pv_dev_name(pvl->pv));
+ return NULL;
+ }
baton.vg = NULL;
baton.fid = lvmcache_fmt(info)->ops->create_instance(lvmcache_fmt(info), &fic);
/*
* Opening the device RDWR should trigger a udev db update.
* FIXME: is there a better way to update the udev db than
- * doing an open/close of the device?
+ * doing an open/close of the device? - For example writing
+ * "change" to /sys/block/<device>/uevent?
*/
static void _update_pv_in_udev(struct cmd_context *cmd, dev_t devt)
{
return;
}
- if (!dev_open(dev))
+ if (!dev_open(dev)) {
+ stack;
return;
- dev_close(dev);
+ }
+
+ if (!dev_close(dev))
+ stack;
}
/*
log_debug("lockd start VG %s lock_type %s",
vg->name, vg->lock_type ? vg->lock_type : "empty");
+ if (!id_write_format(&vg->id, uuid, sizeof(uuid)))
+ return_0;
+
if (vg->lock_type && !strcmp(vg->lock_type, "sanlock")) {
/*
* This is the big difference between starting
host_id = find_config_tree_int(cmd, local_host_id_CFG, NULL);
}
- id_write_format(&vg->id, uuid, sizeof(uuid));
-
reply = _lockd_send("start_vg",
"pid = %d", getpid(),
"vg_name = %s", vg->name,
if (!_lvmlockd_connected)
return 0;
- id_write_format(lv_id, lv_uuid, sizeof(lv_uuid));
+ if (!id_write_format(lv_id, lv_uuid, sizeof(lv_uuid)))
+ return_0;
/*
* For lvchange/vgchange activation, def_mode is "sh" or "ex"
if (!_lvmlockd_connected)
return 0;
- id_write_format(lv_id, lv_uuid, sizeof(lv_uuid));
+ if (!id_write_format(lv_id, lv_uuid, sizeof(lv_uuid)))
+ return_0;
reply = _lockd_send("init_lv",
"pid = %d", getpid(),
if (!_lvmlockd_connected)
return 0;
- id_write_format(lv_id, lv_uuid, sizeof(lv_uuid));
+ if (!id_write_format(lv_id, lv_uuid, sizeof(lv_uuid)))
+ return_0;
reply = _lockd_send("free_lv",
"pid = %d", getpid(),
dm_pool_free(info->mem, info->ti_list);
info->ti_list = NULL;
- dm_snprintf(buf, sizeof(buf), "@%ld:@%ld", t1, t2);
+ if (dm_snprintf(buf, sizeof(buf), "@%ld:@%ld", t1, t2) == -1) {
+ log_error("_translate_time_items: dm_snprintf failed");
+ return 0;
+ }
+
if (!(*data_out = dm_pool_strdup(info->mem, buf))) {
log_error("_translate_time_items: dm_pool_strdup failed");
return 0;