Mark code that should be unreachable (#77)

Introduce a new [[noreturn]] unreachable() function that marks code as unreachable and throws a logic error if it is executed.
Fix build error due to Windows min/max macros.
Fix linker errors from referring to a non-constexpr extern from a constexpr.
Fix warnings about narrowing conversions.

Signed-off-by: Dan Rose <dan@digilabs.io>
This commit is contained in:
Dan Rose 2019-12-08 16:03:30 -06:00 committed by GitHub
parent 9b264c6480
commit c25f22e565
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 85 additions and 24 deletions

View file

@ -111,7 +111,10 @@ void * create_response_type_support(
static uint32_t serdata_rmw_size(const struct ddsi_serdata * dcmn)
{
return static_cast<const serdata_rmw *>(dcmn)->size();
size_t size = static_cast<const serdata_rmw *>(dcmn)->size();
uint32_t size_u32(size);
assert(size == size_u32);
return size_u32;
}
static void serdata_rmw_free(struct ddsi_serdata * dcmn)
@ -142,7 +145,7 @@ static struct ddsi_serdata * serdata_rmw_from_ser(
memcpy(cursor, src, n_bytes);
cursor = byte_offset(cursor, n_bytes);
off = fragchain->maxp1;
assert(off < size);
assert(off <= size);
}
fragchain = fragchain->nextfrag;
}
@ -491,7 +494,7 @@ struct sertopic_rmw * create_sertopic(
return st;
}
void serdata_rmw::resize(uint32_t requested_size)
void serdata_rmw::resize(size_t requested_size)
{
if (!requested_size) {
m_size = 0;