if (pos >= mirror_end || !src) {
rc = llapi_mirror_find(layout, pos, end,
&mirror_end);
- if (rc < 0)
+ if (rc < 0) {
+ free(buf);
return rc;
+ }
src = rc;
/* restrict mirror end by resync end */
mirror_end = MIN(end, mirror_end);
int rc = 0;
dirpath = strdup(dname);
- namepath = strdup(dname);
- if (!dirpath || !namepath)
+ if (!dirpath)
return -ENOMEM;
+ namepath = strdup(dname);
+ if (!namepath) {
+ rc = -ENOMEM;
+ goto out_dirpath;
+ }
+
filename = basename(namepath);
dir = dirname(dirpath);
"error on ioctl %#lx for '%s' (%d)",
(long)LL_IOC_LMV_SETSTRIPE, filename, fd);
out:
- free(dirpath);
+ close(fd);
free(namepath);
- if (fd != -1)
- close(fd);
+out_dirpath:
+ free(dirpath);
return rc;
#else
return -EOPNOTSUPP;
"Can't fdopen the snapshot config file %s: %s\n",
conf_name, strerror(errno));
rc = -1;
- goto out;
+ goto out_fd;
}
while (snapshot_fgets(fp, buf, MAX_BUF_SIZE) != NULL) {
out:
if (fd >= 0) {
- if (rc < 0) {
+ if (rc < 0)
flock(fd, LOCK_UN);
- close(fd);
- } else {
+ else
si->si_conf_fd = fd;
- }
}
-
+ /* fclose() closes any associated underlying file descriptor.
+ * explicit close(fd) not required
+ */
+ fclose(fp);
+ return rc;
+out_fd:
+ close(fd);
return rc;
}
rc = scnprintf(cmd + len, size - len - 1,
"-o %s=\"%s\" ", buf, ptr);
- if (rc <= 0)
+ if (rc <= 0) {
+ pclose(fp);
return -EOVERFLOW;
+ }
len += rc;
}
char *ostname = data;
char ost_filter[MAX_STRING_SIZE] = {'\0'};
char *add_osc, *del_osc, *setup, *cleanup;
+ int rc = 0;
add_osc = get_event_filter(LCFG_LOV_ADD_OBD);
del_osc = get_event_filter(LCFG_LOV_DEL_OBD);
setup = get_event_filter(LCFG_SETUP);
cleanup = get_event_filter(LCFG_CLEANUP);
- if (!add_osc || !del_osc || !setup || !cleanup)
- return -ENOMEM;
+ if (!add_osc || !del_osc || !setup || !cleanup) {
+ rc = -ENOMEM;
+ goto out;
+ }
if (ostname && ostname[0])
snprintf(ost_filter, sizeof(ost_filter), " %s,", ostname);
if (strstr(record, ost_filter)) {
- if (strstr(record, add_osc) || strstr(record, setup))
- return 1;
- if (strstr(record, del_osc) || strstr(record, cleanup))
- return -ENOENT;
+ if (strstr(record, add_osc) || strstr(record, setup)) {
+ rc = 1;
+ goto out_setup;
+ }
+ if (strstr(record, del_osc) || strstr(record, cleanup)) {
+ rc = -ENOENT;
+ goto out_setup;
+ }
}
-
- free(add_osc);
- free(del_osc);
- free(setup);
+out_setup:
free(cleanup);
-
- return 0;
+ free(setup);
+ free(del_osc);
+ free(add_osc);
+out:
+ return rc;
}
/**
name = strstr(record, type);
/* 2 bytes for " }" */
name_len = strlen(name) - type_len - 2;
- if (name_len <= 0 || name_len > sizeof(tmp->lpn_name))
- return -EINVAL;
+ if (name_len <= 0 || name_len > sizeof(tmp->lpn_name)) {
+ rc = -EINVAL;
+ goto out;
+ }
tmp = malloc(sizeof(struct llog_pool_name));
if (!tmp) {
rc = -ENOMEM;