refactor
Some checks are pending
BlockStorage/repertory/pipeline/head Build queued...

This commit is contained in:
Scott E. Graves 2024-09-27 14:01:26 -05:00
parent 739a1103f0
commit 35db1cd0c4

View File

@ -117,12 +117,13 @@ auto fuse_drive_base::check_and_perform(
return ret;
}
if ((ret = check_parent_access(api_path, parent_mask)) !=
api_error::success) {
ret = check_parent_access(api_path, parent_mask);
if (ret != api_error::success) {
return ret;
}
if ((ret = check_owner(meta)) != api_error::success) {
ret = check_owner(meta);
if (ret != api_error::success) {
return ret;
}
@ -131,7 +132,7 @@ auto fuse_drive_base::check_and_perform(
auto fuse_drive_base::check_open_flags(
int flags, int mask, const api_error &fail_error) -> api_error {
return ((flags & mask) ? fail_error : api_error::success);
return (((flags & mask) == 0) ? api_error::success : fail_error);
}
auto fuse_drive_base::check_owner(const std::string &api_path) const
@ -195,17 +196,17 @@ auto fuse_drive_base::check_readable(int flags,
auto fuse_drive_base::check_writeable(int flags, const api_error &fail_error)
-> api_error {
return ((flags & O_ACCMODE) ? api_error::success : fail_error);
return (((flags & O_ACCMODE) == 0) ? fail_error : api_error::success);
}
auto fuse_drive_base::get_current_gid() const -> gid_t {
auto *ctx = fuse_get_context();
return ctx ? ctx->gid : getgid();
return (ctx == nullptr) ? getgid() : ctx->gid;
}
auto fuse_drive_base::get_current_uid() const -> uid_t {
auto *ctx = fuse_get_context();
return ctx ? ctx->uid : getuid();
return (ctx == nullptr) ? getuid() : ctx->uid;
}
auto fuse_drive_base::get_effective_gid() const -> gid_t {
@ -235,8 +236,10 @@ void fuse_drive_base::get_timespec_from_meta(const api_meta_map &meta,
const std::string &name,
struct timespec &ts) {
auto meta_time = utils::string::to_uint64(meta.at(name));
ts.tv_nsec = meta_time % utils::time::NANOS_PER_SECOND;
ts.tv_sec = meta_time / utils::time::NANOS_PER_SECOND;
ts.tv_nsec =
static_cast<std::int64_t>(meta_time % utils::time::NANOS_PER_SECOND);
ts.tv_sec =
static_cast<std::int64_t>(meta_time / utils::time::NANOS_PER_SECOND);
}
auto fuse_drive_base::get_uid_from_meta(const api_meta_map &meta) -> uid_t {
@ -257,7 +260,7 @@ auto fuse_drive_base::parse_xattr_parameters(
return res;
}
if (not name) {
if (name == nullptr) {
return api_error::bad_address;
}
@ -292,8 +295,9 @@ auto fuse_drive_base::parse_xattr_parameters(
return res;
}
return (value ? api_error::success
: (size ? api_error::bad_address : api_error::success));
return (value == nullptr
? ((size == 0U) ? api_error::success : api_error::bad_address)
: api_error::success);
}
void fuse_drive_base::populate_stat(const std::string &api_path,
@ -343,8 +347,10 @@ void fuse_drive_base::set_timespec_from_meta(const api_meta_map &meta,
const std::string &name,
struct timespec &ts) {
auto meta_time = utils::string::to_uint64(meta.at(name));
ts.tv_nsec = meta_time % utils::time::NANOS_PER_SECOND;
ts.tv_sec = meta_time / utils::time::NANOS_PER_SECOND;
ts.tv_nsec =
static_cast<std::int64_t>(meta_time % utils::time::NANOS_PER_SECOND);
ts.tv_sec =
static_cast<std::int64_t>(meta_time / utils::time::NANOS_PER_SECOND);
}
} // namespace repertory