Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 13 additions & 13 deletions api/examples/glfsxmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,40 +48,40 @@ test_xattr(glfs_t *fs)

ret = glfs_getxattr(fs, filename, "user.testkey", buf, 512);
fprintf(stderr, "getxattr(%s): %d (%s)\n", filename, ret, strerror(errno));
if (ret < 0)
if (IS_ERROR(ret))
return -1;

ret = glfs_listxattr(fs, filename, buf, 512);
fprintf(stderr, "listxattr(%s): %d (%s)\n", filename, ret, strerror(errno));
if (ret < 0)
if (IS_ERROR(ret))
return -1;

ret = glfs_symlink(fs, "filename", linkfile);
fprintf(stderr, "symlink(%s %s): %s\n", filename, linkfile,
strerror(errno));
if (ret < 0)
if (IS_ERROR(ret))
return -1;

ret = glfs_readlink(fs, linkfile, buf, 512);
fprintf(stderr, "readlink(%s) : %d (%s)\n", filename, ret, strerror(errno));
if (ret < 0)
if (IS_ERROR(ret))
return -1;

ret = glfs_lsetxattr(fs, filename, "user.testkey3", "testval", 8, 0);
fprintf(stderr, "lsetxattr(%s) : %d (%s)\n", linkfile, ret,
strerror(errno));
if (ret < 0)
if (IS_ERROR(ret))
return -1;

ret = glfs_llistxattr(fs, linkfile, buf, 512);
fprintf(stderr, "llistxattr(%s): %d (%s)\n", filename, ret,
strerror(errno));
if (ret < 0)
if (IS_ERROR(ret))
return -1;

ret = glfs_lgetxattr(fs, filename, "user.testkey3", buf, 512);
fprintf(stderr, "lgetxattr(%s): %d (%s)\n", linkfile, ret, strerror(errno));
if (ret < 0)
if (IS_ERROR(ret))
return -1;

for (ptr = buf; ptr < buf + ret; ptr++) {
Expand All @@ -105,7 +105,7 @@ test_xattr(glfs_t *fs)
ret = glfs_flistxattr(fd, buf, 512);
fprintf(stderr, "flistxattr(%s): %d (%s)\n", filename, ret,
strerror(errno));
if (ret < 0)
if (IS_ERROR(ret))
return -1;

for (ptr = buf; ptr < buf + ret; ptr++) {
Expand Down Expand Up @@ -963,7 +963,7 @@ void
assimilatetime(struct timespec *ts, struct timespec ts_st,
struct timespec ts_ed)
{
if ((ts_ed.tv_nsec - ts_st.tv_nsec) < 0) {
if (IS_ERROR((ts_ed.tv_nsec - ts_st.tv_nsec))) {
ts->tv_sec += ts_ed.tv_sec - ts_st.tv_sec - 1;
ts->tv_nsec += 1000000000 + ts_ed.tv_nsec - ts_st.tv_nsec;
} else {
Expand Down Expand Up @@ -1396,7 +1396,7 @@ test_handleops(int argc, char *argv[])
peek_stat(&sb);

ret = glfs_h_extract_handle(leaf, leaf_handle, GFAPI_HANDLE_LENGTH);
if (ret < 0) {
if (IS_ERROR(ret)) {
fprintf(stderr,
"glfs_h_extract_handle: error extracting handle of %s: %s\n",
full_leaf_name, strerror(errno));
Expand Down Expand Up @@ -1634,19 +1634,19 @@ test_write_apis(glfs_t *fs)
fprintf(stderr, "open(%s): (%p) %s\n", filename, fd, strerror(errno));

ret = glfs_writev(fd, &iov, 1, flags);
if (ret < 0) {
if (IS_ERROR(ret)) {
fprintf(stderr, "writev(%s): %d (%s)\n", filename, ret,
strerror(errno));
}

ret = glfs_pwrite(fd, buf, 10, 4, flags, NULL, NULL);
if (ret < 0) {
if (IS_ERROR(ret)) {
fprintf(stderr, "pwrite(%s): %d (%s)\n", filename, ret,
strerror(errno));
}

ret = glfs_pwritev(fd, &iov, 1, 4, flags);
if (ret < 0) {
if (IS_ERROR(ret)) {
fprintf(stderr, "pwritev(%s): %d (%s)\n", filename, ret,
strerror(errno));
}
Expand Down
54 changes: 27 additions & 27 deletions api/src/glfs-fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,11 +811,11 @@ pub_glfs_creat(struct glfs *fs, const char *path, int flags, mode_t mode)

ESTALE_RETRY(ret, errno, reval, &loc, retry);

if (ret == -1 && errno != ENOENT)
if (IS_ERROR(ret) && (errno != ENOENT))
/* Any other type of error is fatal */
goto out;

if (ret == -1 && errno == ENOENT && !loc.parent)
if (IS_ERROR(ret) && (errno == ENOENT) && !loc.parent)
/* The parent directory or an ancestor even
higher does not exist
*/
Expand All @@ -841,7 +841,7 @@ pub_glfs_creat(struct glfs *fs, const char *path, int flags, mode_t mode)
}
}

if (ret == -1 && errno == ENOENT) {
if (IS_ERROR(ret) && (errno == ENOENT)) {
loc.inode = inode_new(loc.parent->table);
if (!loc.inode) {
ret = -1;
Expand Down Expand Up @@ -943,7 +943,7 @@ glfs_seek(struct glfs_fd *glfd, off_t offset, int whence)
ret = syncop_seek(subvol, fd, offset, what, NULL, &off);
DECODE_SYNCOP_ERR(ret);

if (ret != -1)
if (IS_SUCCESS(ret))
glfd->offset = off;

done:
Expand Down Expand Up @@ -1003,7 +1003,7 @@ pub_glfs_lseek(struct glfs_fd *glfd, off_t offset, int whence)

__GLFS_EXIT_FS;

if (ret != -1)
if (IS_SUCCESS(ret))
off = glfd->offset;

return off;
Expand Down Expand Up @@ -1059,7 +1059,7 @@ glfs_preadv_common(struct glfs_fd *glfd, const struct iovec *iovec, int iovcnt,
fop_attr, NULL);
DECODE_SYNCOP_ERR(ret);

if (ret >= 0 && poststat)
if (IS_SUCCESS(ret) && poststat)
glfs_iatt_to_statx(glfd->fs, &iatt, poststat);

if (ret <= 0)
Expand Down Expand Up @@ -1552,7 +1552,7 @@ glfs_pwritev_common(struct glfs_fd *glfd, const struct iovec *iovec, int iovcnt,
&postiatt, fop_attr, NULL);
DECODE_SYNCOP_ERR(ret);

if (ret >= 0) {
if (IS_SUCCESS(ret)) {
if (prestat)
glfs_iatt_to_statx(glfd->fs, &preiatt, prestat);
if (poststat)
Expand Down Expand Up @@ -1673,7 +1673,7 @@ pub_glfs_copy_file_range(struct glfs_fd *glfd_in, off64_t *off_in,
NULL);
DECODE_SYNCOP_ERR(ret);

if (ret >= 0) {
if (IS_SUCCESS(ret)) {
pos_in += ret;
pos_out += ret;

Expand Down Expand Up @@ -2105,7 +2105,7 @@ glfs_fsync_common(struct glfs_fd *glfd, struct glfs_stat *prestat,
ret = syncop_fsync(subvol, fd, 0, &preiatt, &postiatt, fop_attr, NULL);
DECODE_SYNCOP_ERR(ret);

if (ret >= 0) {
if (IS_SUCCESS(ret)) {
if (prestat)
glfs_iatt_to_statx(glfd->fs, &preiatt, prestat);
if (poststat)
Expand Down Expand Up @@ -2302,7 +2302,7 @@ glfs_fdatasync_common(struct glfs_fd *glfd, struct glfs_stat *prestat,
ret = syncop_fsync(subvol, fd, 1, &preiatt, &postiatt, fop_attr, NULL);
DECODE_SYNCOP_ERR(ret);

if (ret >= 0) {
if (IS_SUCCESS(ret)) {
if (prestat)
glfs_iatt_to_statx(glfd->fs, &preiatt, prestat);
if (poststat)
Expand Down Expand Up @@ -2420,7 +2420,7 @@ glfs_ftruncate_common(struct glfs_fd *glfd, off_t offset,
NULL);
DECODE_SYNCOP_ERR(ret);

if (ret >= 0) {
if (IS_SUCCESS(ret)) {
if (prestat)
glfs_iatt_to_statx(glfd->fs, &preiatt, prestat);
if (poststat)
Expand Down Expand Up @@ -2714,17 +2714,17 @@ pub_glfs_symlink(struct glfs *fs, const char *data, const char *path)
goto out;
}

if (ret == -1 && errno != ENOENT)
if (IS_ERROR(ret) && errno != ENOENT)
/* Any other type of error is fatal */
goto out;

if (ret == -1 && errno == ENOENT && !loc.parent)
if (IS_ERROR(ret) && errno == ENOENT && !loc.parent)
/* The parent directory or an ancestor even
higher does not exist
*/
goto out;

/* ret == -1 && errno == ENOENT */
/* ret < 0 && errno == ENOENT */
loc.inode = inode_new(loc.parent->table);
if (!loc.inode) {
ret = -1;
Expand Down Expand Up @@ -2863,17 +2863,17 @@ pub_glfs_mknod(struct glfs *fs, const char *path, mode_t mode, dev_t dev)
goto out;
}

if (ret == -1 && errno != ENOENT)
if (IS_ERROR(ret) && errno != ENOENT)
/* Any other type of error is fatal */
goto out;

if (ret == -1 && errno == ENOENT && !loc.parent)
if (IS_ERROR(ret) && errno == ENOENT && !loc.parent)
/* The parent directory or an ancestor even
higher does not exist
*/
goto out;

/* ret == -1 && errno == ENOENT */
/* ret < 0 && errno == ENOENT */
loc.inode = inode_new(loc.parent->table);
if (!loc.inode) {
ret = -1;
Expand Down Expand Up @@ -2954,17 +2954,17 @@ pub_glfs_mkdir(struct glfs *fs, const char *path, mode_t mode)
goto out;
}

if (ret == -1 && errno != ENOENT)
if (IS_ERROR(ret) && errno != ENOENT)
/* Any other type of error is fatal */
goto out;

if (ret == -1 && errno == ENOENT && !loc.parent)
if (IS_ERROR(ret) && errno == ENOENT && !loc.parent)
/* The parent directory or an ancestor even
higher does not exist
*/
goto out;

/* ret == -1 && errno == ENOENT */
/* ret < 0 && errno == ENOENT */
loc.inode = inode_new(loc.parent->table);
if (!loc.inode) {
ret = -1;
Expand Down Expand Up @@ -3168,7 +3168,7 @@ pub_glfs_rename(struct glfs *fs, const char *oldpath, const char *newpath)
ret = syncop_rename(subvol, &oldloc, &newloc, NULL, NULL);
DECODE_SYNCOP_ERR(ret);

if (ret == -1 && errno == ESTALE) {
if (IS_ERROR(ret) && errno == ESTALE) {
if (reval < DEFAULT_REVAL_COUNT) {
reval++;
loc_wipe(&oldloc);
Expand Down Expand Up @@ -3262,7 +3262,7 @@ pub_glfs_link(struct glfs *fs, const char *oldpath, const char *newpath)
ret = syncop_link(subvol, &oldloc, &newloc, &newiatt, NULL, NULL);
DECODE_SYNCOP_ERR(ret);

if (ret == -1 && errno == ESTALE) {
if (IS_ERROR(ret) && errno == ESTALE) {
loc_wipe(&oldloc);
loc_wipe(&newloc);
if (reval--)
Expand Down Expand Up @@ -3707,7 +3707,7 @@ glfd_entry_refresh(struct glfs_fd *glfd, int plus)
ret = syncop_readdir(subvol, fd, 131072, glfd->offset, &entries, NULL,
NULL);
DECODE_SYNCOP_ERR(ret);
if (ret >= 0) {
if (IS_SUCCESS(ret)) {
if (plus) {
list_for_each_entry(entry, &entries.list, list)
{
Expand Down Expand Up @@ -3761,7 +3761,7 @@ glfd_entry_next(struct glfs_fd *glfd, int plus)

if (!glfd->offset || !glfd->next) {
ret = glfd_entry_refresh(glfd, plus);
if (ret < 0)
if (IS_ERROR(ret))
return NULL;
}

Expand Down Expand Up @@ -5169,7 +5169,7 @@ glfs_realpath_common(struct glfs *fs, const char *path, char *resolved_path,
out:
loc_wipe(&loc);

if (ret == -1) {
if (IS_ERROR(ret)) {
if (warn_deprecated && allocpath)
free(allocpath);
else if (allocpath)
Expand Down Expand Up @@ -5243,7 +5243,7 @@ pub_glfs_getcwd(struct glfs *fs, char *buf, size_t n)
__GLFS_EXIT_FS;

invalid_fs:
if (ret < 0)
if (IS_ERROR(ret))
return NULL;

return buf;
Expand Down Expand Up @@ -6322,7 +6322,7 @@ pub_glfs_xreaddirplus_r(struct glfs_fd *glfd, uint32_t flags,
out:
GF_REF_PUT(glfd);

if (ret < 0) {
if (IS_ERROR(ret)) {
gf_smsg(THIS->name, GF_LOG_WARNING, errno, API_MSG_XREADDIRP_R_FAILED,
"reason=%s", strerror(errno), NULL);

Expand Down
2 changes: 1 addition & 1 deletion api/src/glfs-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@

#define ESTALE_RETRY(ret, errno, reval, loc, label) \
do { \
if (ret == -1 && errno == ESTALE) { \
if (IS_ERROR(ret) && errno == ESTALE) { \
if (reval < DEFAULT_REVAL_COUNT) { \
reval++; \
loc_wipe(loc); \
Expand Down
Loading