}
} else {
rc = cfs_trace_copyin_string(tmpstr, tmpstrlen, buffer, nob);
- if (rc < 0)
- return rc;
+ if (rc < 0) {
+ cfs_trace_free_string_buffer(tmpstr, tmpstrlen);
+ return rc;
+ }
rc = libcfs_debug_str2mask(mask, tmpstr, is_subsys);
/* Always print LBUG/LASSERT to console, so keep this mask */
ibits = MDS_INODELOCK_LAYOUT;
if (S_ISREG(md.body->mode) && sbi->ll_flags & LL_SBI_LAYOUT_LOCK &&
md.lsm != NULL && !ll_have_md_lock(*inode, &ibits, LCK_MINMODE)) {
+ char *fsname = ll_get_fsname(*inode);
CERROR("%s: inode "DFID" (%p) layout lock not granted.\n",
- ll_get_fsname(*inode), PFID(ll_inode2fid(*inode)),
+ fsname, PFID(ll_inode2fid(*inode)),
*inode);
+ if (fsname)
+ OBD_FREE(fsname, MGS_PARAM_MAXLEN);
}
out:
* cached all the time.
*/
obj = lmv_object_find_lock(obd, mid);
- if (obj == NULL)
- RETURN(-EALREADY);
+ if (obj == NULL) {
+ OBD_FREE_PTR(op_data);
+ RETURN(-EALREADY);
+ }
for (i = 0; i < obj->lo_objcount; i++) {
fid = obj->lo_stripes[i].ls_fid;
if (oa->o_seq > FID_SEQ_OST_MAX) {
CERROR("%s: invalid group number "LPU64" > MAX_CMD_GROUP %u\n",
exp->exp_obd->obd_name, oa->o_seq, FID_SEQ_OST_MAX);
+ OBDO_FREE(oa);
RETURN(-EINVAL);
}
if (rc <= 0) {
CERROR("%s: failed to parse CPT array %s: %d\n",
conf->psc_name, cconf->cc_pattern, rc);
+ if (cpts != NULL)
+ OBD_FREE(cpts, sizeof(*cpts) * ncpts);
RETURN(ERR_PTR(rc < 0 ? rc : -EINVAL));
}
ncpts = rc;
int fd;
int mount_with_flock = 0;
int error = 0;
+ int rc = 0;
if (argc != 5) {
t1_usage();
error = flock(fd, LOCK_EX);
} else {
t1_usage();
- return EXIT_FAILURE;
+ rc = EXIT_FAILURE;
+ goto out;
}
if (mount_with_flock)
- return((error == 0) ? EXIT_SUCCESS : EXIT_FAILURE);
+ rc = ((error == 0) ? EXIT_SUCCESS : EXIT_FAILURE);
else
- return((error == 0) ? EXIT_FAILURE : EXIT_SUCCESS);
+ rc = ((error == 0) ? EXIT_FAILURE : EXIT_SUCCESS);
+
+out:
+ if (fd >= 0)
+ close(fd);
+ return rc;
}
/** ===============================================================
rc = t_fcntl(fd, F_GETFL);
if ((rc & O_APPEND) == 0) {
fprintf(stderr, "error get flag: ret %x\n", rc);
- return EXIT_FAILURE;
+ rc = EXIT_FAILURE;
+ goto out;
}
ta.lock = &lock;
static int lfs_flushctx(int argc, char **argv)
{
int kdestroy = 0, c;
- FILE *proc;
+ FILE *proc = NULL;
char procline[PATH_MAX], *line;
int rc = 0;
fprintf(stderr, "%s: unexpected format in "
"/proc/mounts\n",
argv[0]);
- return -1;
+ rc = -1;
+ goto out;
}
if (strcmp(fs, "lustre") != 0)
}
}
+out:
+ if (proc != NULL)
+ fclose(proc);
return rc;
}
if (rc) {
fprintf(stderr, "can't get version for %s: %s\n", path,
strerror(errno = -rc));
- return rc;
- }
-
- printf(LPU64 "\n", data_version);
+ } else
+ printf(LPU64 "\n", data_version);
close(fd);
- return 0;
+ return rc;
}
int main(int argc, char **argv)
llapi_error(LLAPI_MSG_ERROR, rc,
"'%s' is not on a Lustre filesystem",
file_path);
+ if (fp != NULL)
+ fclose(fp);
return rc;
}
} else if (fsname) {
rc = -errno;
llapi_error(LLAPI_MSG_ERROR, rc,
"Error reading pool list for '%s'", name);
- return rc;
+ goto out;
} else if ((rc == 0) && (cookie == NULL)) {
/* end of directory */
break;
continue;
/* check output bounds */
- if (nb_entries >= list_size)
- return -EOVERFLOW;
+ if (nb_entries >= list_size) {
+ rc = -EOVERFLOW;
+ goto out;
+ }
/* +2 for '.' and final '\0' */
- if (used + strlen(pool.d_name) + strlen(fsname) + 2
- > buffer_size)
- return -EOVERFLOW;
+ if (used + strlen(pool.d_name) + strlen(fsname) + 2
+ > buffer_size) {
+ rc = -EOVERFLOW;
+ goto out;
+ }
sprintf(buffer + used, "%s.%s", fsname, pool.d_name);
poollist[nb_entries] = buffer + used;
nb_entries++;
}
+out:
closedir(dir);
- return nb_entries;
+ return ((rc != 0) ? rc : nb_entries);
}
/* wrapper for lfs.c and obd.c */
if (ret == -EOVERFLOW) {
uuids_temp = realloc(uuids, obdcount *
sizeof(struct obd_uuid));
- if (uuids_temp != NULL)
+ if (uuids_temp != NULL) {
+ uuids = uuids_temp;
goto retry_get_uuids;
+ }
else
ret = -ENOMEM;
}
{
FILE *fp;
struct mntent *mnt;
- int found = 0, fd, rc;
+ int found = 0, fd = 0, rc = 0;
fp = setmntent(MOUNTED, "r");
if (fp == NULL) {
if (!mnt)
break;
- if (!llapi_is_lustre_mnt(mnt))
+ if (!llapi_is_lustre_mnt(mnt))
continue;
fd = open(mnt->mnt_dir, O_RDONLY | O_DIRECTORY);
rc = -errno;
llapi_error(LLAPI_MSG_ERROR, rc,
"Can't open '%s'\n", mnt->mnt_dir);
- return rc;
+ goto out;
}
rc = ioctl(fd, LL_IOC_RMTACL, ops);
if (rc < 0) {
rc = -errno;
llapi_error(LLAPI_MSG_ERROR, rc, "ioctl %d\n", fd);
- return rc;
+ goto out;
}
found++;
}
+
+out:
endmntent(fp);
- return found;
+ if (fd >= 0)
+ close(fd);
+ return ((rc != 0) ? rc : found);
}
static char *next_token(char *p, int div)
struct timeval start_time;
unsigned long long total_bytes;
unsigned long long curr_bytes = 0;
+ int rc = 0;
#ifdef HAVE_EXT2FS_EXT2FS_H
if (!full && fsetflags(testdir, EXT2_TOPDIR_FL))
fflush(countfile) != 0) {
fprintf(stderr, "\n%s: writing %s failed :%s\n",
progname, filecount, strerror(errno));
- return 6;
+ rc = 6;
+ goto out;
}
/* calculate total bytes that need to be written */
if (total_bytes <= 0) {
fprintf(stderr, "\n%s: unable to calculate total bytes\n",
progname);
- return 7;
+ rc = 7;
+ goto out;
}
if (!full && (dir_num != 0))
fprintf(stderr, "\n%s: mkdir %s : %s\n",
progname, tempdir,
strerror(errno));
- return 1;
+ rc = 1;
+ goto out;
}
}
dir_num++;
time_st, inode_st, tempfile);
close(fd);
if (ret < 0) {
- if (ret != -ENOSPC)
- return 1;
+ if (ret != -ENOSPC) {
+ rc = 1;
+ goto out;
+ }
curr_bytes = total_bytes;
break;
}
progname, filecount, strerror(errno));
}
}
- fclose(countfile);
if (verbose) {
verbose++;
verbose--;
}
- return 0;
+out:
+ fclose(countfile);
+
+ return rc;
}
/*
{
void *changelog_priv;
struct lr_info *info;
- struct lr_info *ext;
+ struct lr_info *ext = NULL;
time_t start;
int xattr_not_supp;
int i;
if (rc) {
fprintf(stderr, "Source path is not a valid Lustre client "
"mountpoint.\n");
- return rc;
+ goto out;
}
if (status->ls_mdt_device[0] == '\0')
snprintf(status->ls_mdt_device, LR_NAME_MAXLEN, "%s%s",
status->ls_source_fs, DEFAULT_MDT);
ext = calloc(1, sizeof(struct lr_info));
- if (ext == NULL)
- return -ENOMEM;
+ if (ext == NULL) {
+ rc = -ENOMEM;
+ goto out;
+ }
for (i = 0, xattr_not_supp = 0; i < status->ls_num_targets; i++) {
snprintf(info->dest, PATH_MAX, "%s/%s", status->ls_targets[i],
if (rc == -1 && errno != EEXIST) {
fprintf(stderr, "Error writing to target path %s.\n",
status->ls_targets[i]);
- return -errno;
+ rc = -errno;
+ goto out;
}
rc = llistxattr(info->src, info->xlist, info->xsize);
if (rc == -1 && errno == ENOTSUP) {
if (rc < 0) {
fprintf(stderr, "Error opening changelog file for fs %s.\n",
status->ls_source_fs);
- return rc;
+ goto out;
}
while (!quit && lr_parse_line(changelog_priv, info) == 0) {
printf("Changelog records consumed: %lld\n", rec_count);
}
- return 0;
+ rc = 0;
+
+out:
+ if (info != NULL)
+ free(info);
+ if (ext != NULL)
+ free(ext);
+
+ return rc;
}
void
if (num < 1 && ferror(filep)) {
fprintf(stderr, "%s: Unable to write to file (%s): %s\n",
progname, filepnm, strerror(errno));
+ fclose(filep);
goto out_umnt;
}
fclose(filep);
return NULL;
if (devname[0] != '/') {
- if (getcwd(buf, sizeof(buf) - 1) == NULL)
+ if (getcwd(buf, sizeof(buf) - 1) == NULL) {
+ free(path);
return NULL;
+ }
strcat(buf, "/");
strcat(buf, devname);
} else {