mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 15:04:10 +01:00
ircd: Apply branch expectation attributes to various case labels.
This commit is contained in:
parent
5e32f88b0d
commit
89e44ce8e9
8 changed files with 38 additions and 4 deletions
|
@ -56,12 +56,15 @@ ircd::allocator::allocate(const size_t alignment,
|
||||||
void *ret;
|
void *ret;
|
||||||
switch(int errc(::posix_memalign(&ret, alignment, size)); errc)
|
switch(int errc(::posix_memalign(&ret, alignment, size)); errc)
|
||||||
{
|
{
|
||||||
|
[[likely]]
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
[[unlikely]]
|
||||||
case int(std::errc::not_enough_memory):
|
case int(std::errc::not_enough_memory):
|
||||||
throw std::bad_alloc{};
|
throw std::bad_alloc{};
|
||||||
|
|
||||||
|
[[unlikely]]
|
||||||
default:
|
default:
|
||||||
throw_system_error();
|
throw_system_error();
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
|
@ -249,9 +252,11 @@ ircd::allocator::advise(const const_buffer &buf,
|
||||||
assert(aligned(data(buf), info::page_size));
|
assert(aligned(data(buf), info::page_size));
|
||||||
switch(const auto r(::madvise(mutable_cast(data(buf)), size(buf), advice)); r)
|
switch(const auto r(::madvise(mutable_cast(data(buf)), size(buf), advice)); r)
|
||||||
{
|
{
|
||||||
|
[[likely]]
|
||||||
case 0:
|
case 0:
|
||||||
return size(buf); // success
|
return size(buf); // success
|
||||||
|
|
||||||
|
[[unlikely]]
|
||||||
default:
|
default:
|
||||||
throw_system_error(r); // error
|
throw_system_error(r); // error
|
||||||
}
|
}
|
||||||
|
|
|
@ -4398,6 +4398,7 @@ ircd::db::throw_on_error::throw_on_error(const rocksdb::Status &status)
|
||||||
|
|
||||||
switch(status.code())
|
switch(status.code())
|
||||||
{
|
{
|
||||||
|
[[likely]]
|
||||||
case Status::kOk:
|
case Status::kOk:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -4412,6 +4413,7 @@ ircd::db::throw_on_error::throw_on_error(const rocksdb::Status &status)
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
[[unlikely]]
|
||||||
default:
|
default:
|
||||||
throw error
|
throw error
|
||||||
{
|
{
|
||||||
|
@ -4444,6 +4446,7 @@ ircd::db::error_to_status::error_to_status(const std::error_code &e)
|
||||||
|
|
||||||
switch(e.value())
|
switch(e.value())
|
||||||
{
|
{
|
||||||
|
[[likely]]
|
||||||
case 0:
|
case 0:
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
|
|
||||||
|
@ -4529,6 +4532,7 @@ ircd::db::append(rocksdb::WriteBatch &batch,
|
||||||
const auto v(slice(std::get<2>(delta)));
|
const auto v(slice(std::get<2>(delta)));
|
||||||
switch(std::get<0>(delta))
|
switch(std::get<0>(delta))
|
||||||
{
|
{
|
||||||
|
[[unlikely]]
|
||||||
case op::GET: assert(0); break;
|
case op::GET: assert(0); break;
|
||||||
case op::SET: batch.Put(c, k, v); break;
|
case op::SET: batch.Put(c, k, v); break;
|
||||||
case op::MERGE: batch.Merge(c, k, v); break;
|
case op::MERGE: batch.Merge(c, k, v); break;
|
||||||
|
@ -5120,11 +5124,13 @@ ircd::db::valid(const rocksdb::Iterator &it)
|
||||||
{
|
{
|
||||||
using rocksdb::Status;
|
using rocksdb::Status;
|
||||||
|
|
||||||
|
[[likely]]
|
||||||
case Status::kOk:
|
case Status::kOk:
|
||||||
case Status::kNotFound:
|
case Status::kNotFound:
|
||||||
case Status::kIncomplete:
|
case Status::kIncomplete:
|
||||||
return it.Valid();
|
return it.Valid();
|
||||||
|
|
||||||
|
[[unlikely]]
|
||||||
default:
|
default:
|
||||||
throw_on_error
|
throw_on_error
|
||||||
{
|
{
|
||||||
|
@ -5142,13 +5148,16 @@ ircd::db::valid(const rocksdb::Status &s)
|
||||||
{
|
{
|
||||||
using rocksdb::Status;
|
using rocksdb::Status;
|
||||||
|
|
||||||
|
[[likely]]
|
||||||
case Status::kOk:
|
case Status::kOk:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
[[likely]]
|
||||||
case Status::kNotFound:
|
case Status::kNotFound:
|
||||||
case Status::kIncomplete:
|
case Status::kIncomplete:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
[[unlikely]]
|
||||||
default:
|
default:
|
||||||
throw_on_error{s};
|
throw_on_error{s};
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
|
|
|
@ -523,7 +523,7 @@ ircd::db::loglevel(const database &d)
|
||||||
|
|
||||||
switch(level)
|
switch(level)
|
||||||
{
|
{
|
||||||
default:
|
[[unlikely]]
|
||||||
case rocksdb::NUM_INFO_LOG_LEVELS:
|
case rocksdb::NUM_INFO_LOG_LEVELS:
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|
||||||
|
@ -534,6 +534,9 @@ ircd::db::loglevel(const database &d)
|
||||||
case rocksdb::INFO_LEVEL: return log::level::INFO;
|
case rocksdb::INFO_LEVEL: return log::level::INFO;
|
||||||
case rocksdb::DEBUG_LEVEL: return log::level::DEBUG;
|
case rocksdb::DEBUG_LEVEL: return log::level::DEBUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(0);
|
||||||
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::db::options
|
ircd::db::options
|
||||||
|
|
|
@ -2332,8 +2332,13 @@ ircd::fs::advise(const fd &fd,
|
||||||
cnt = std::min(opts.offset + count - off, max_count);
|
cnt = std::min(opts.offset + count - off, max_count);
|
||||||
switch(const auto r(::posix_fadvise(fd, off, cnt, advice)); r)
|
switch(const auto r(::posix_fadvise(fd, off, cnt, advice)); r)
|
||||||
{
|
{
|
||||||
case 0: break;
|
[[likely]]
|
||||||
default: throw_system_error(r);
|
case 0:
|
||||||
|
break;
|
||||||
|
|
||||||
|
[[unlikely]]
|
||||||
|
default:
|
||||||
|
throw_system_error(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(off + cnt < opts.offset + count);
|
while(off + cnt < opts.offset + count);
|
||||||
|
|
|
@ -1671,6 +1671,7 @@ try
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
[[unlikely]]
|
||||||
default:
|
default:
|
||||||
throw ircd::not_implemented{};
|
throw ircd::not_implemented{};
|
||||||
}
|
}
|
||||||
|
@ -1760,7 +1761,9 @@ try
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: throw ircd::not_implemented{};
|
[[unlikely]]
|
||||||
|
default:
|
||||||
|
throw ircd::not_implemented{};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(const boost::system::system_error &e)
|
catch(const boost::system::system_error &e)
|
||||||
|
@ -2188,6 +2191,7 @@ noexcept try
|
||||||
}
|
}
|
||||||
|
|
||||||
// A cancelation means there was no timeout.
|
// A cancelation means there was no timeout.
|
||||||
|
[[likely]]
|
||||||
case int(std::errc::operation_canceled):
|
case int(std::errc::operation_canceled):
|
||||||
{
|
{
|
||||||
assert(ec.category() == std::system_category());
|
assert(ec.category() == std::system_category());
|
||||||
|
@ -2196,6 +2200,7 @@ noexcept try
|
||||||
}
|
}
|
||||||
|
|
||||||
// All other errors are unexpected, logged and ignored here.
|
// All other errors are unexpected, logged and ignored here.
|
||||||
|
[[unlikely]]
|
||||||
default: throw panic
|
default: throw panic
|
||||||
{
|
{
|
||||||
"socket(%p): unexpected :%s",
|
"socket(%p): unexpected :%s",
|
||||||
|
@ -2520,6 +2525,7 @@ noexcept try
|
||||||
|
|
||||||
if(!valid) switch(err)
|
if(!valid) switch(err)
|
||||||
{
|
{
|
||||||
|
[[unlikely]]
|
||||||
case X509_V_OK:
|
case X509_V_OK:
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|
||||||
|
|
|
@ -172,6 +172,7 @@ ircd::net::dns::resolver::make_query(const mutable_buffer &buf,
|
||||||
string_view hoststr;
|
string_view hoststr;
|
||||||
switch(tag.opts.qtype)
|
switch(tag.opts.qtype)
|
||||||
{
|
{
|
||||||
|
[[unlikely]]
|
||||||
case 0: throw error
|
case 0: throw error
|
||||||
{
|
{
|
||||||
"Query type is required to form a question."
|
"Query type is required to form a question."
|
||||||
|
@ -803,6 +804,7 @@ ircd::net::dns::resolver::handle_error(const header &header,
|
||||||
{
|
{
|
||||||
switch(header.rcode)
|
switch(header.rcode)
|
||||||
{
|
{
|
||||||
|
[[likely]]
|
||||||
case 0: // NoError; continue
|
case 0: // NoError; continue
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -1117,6 +1117,7 @@ try
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[unlikely]]
|
||||||
default: throw http::error
|
default: throw http::error
|
||||||
{
|
{
|
||||||
"Cannot send json::%s as response content",
|
"Cannot send json::%s as response content",
|
||||||
|
|
|
@ -1236,6 +1236,7 @@ ircd::server::peer::handle_error(link &link,
|
||||||
|
|
||||||
if(system_category(ec)) switch(ec.value())
|
if(system_category(ec)) switch(ec.value())
|
||||||
{
|
{
|
||||||
|
[[unlikely]]
|
||||||
case 0:
|
case 0:
|
||||||
assert(0);
|
assert(0);
|
||||||
break;
|
break;
|
||||||
|
@ -2414,6 +2415,7 @@ noexcept try
|
||||||
|
|
||||||
if(system_category(ec)) switch(ec.value())
|
if(system_category(ec)) switch(ec.value())
|
||||||
{
|
{
|
||||||
|
[[likely]]
|
||||||
case 0:
|
case 0:
|
||||||
handle_writable_success();
|
handle_writable_success();
|
||||||
return;
|
return;
|
||||||
|
@ -2601,6 +2603,7 @@ noexcept try
|
||||||
|
|
||||||
if(system_category(ec)) switch(ec.value())
|
if(system_category(ec)) switch(ec.value())
|
||||||
{
|
{
|
||||||
|
[[likely]]
|
||||||
case 0:
|
case 0:
|
||||||
handle_readable_success();
|
handle_readable_success();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue