Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,36 @@ include(GoogleTest)
include_directories(include)
include_directories(src)

# Stricter implicit-conversion warnings for first-party code only. Placed after
# all contrib add_subdirectory() calls so third-party sources (librseq,
# libbacktrace, liburing, etc.) keep compiling under their own assumptions;
# add_compile_options only affects targets created later in this scope. Catches
# silent value-altering conversions: integer narrowing (uint64_t -> uint32_t),
# float-to-int truncation, and float-precision loss.
# None of these are enabled by -Wall/-Wextra.
# Third-party headers we include (e.g. liburing) are marked SYSTEM so their
# inline functions do not trip these here.
add_compile_options(
# Integer narrowing. Already includes the -Wshorten-64-to-32 subgroup, so
# that 64->32 flag would be redundant here.
-Wimplicit-int-conversion

# float/double -> int truncation.
-Wfloat-conversion

# double -> float narrowing, and int -> float precision loss
# (-Wimplicit-float-conversion includes the -Wimplicit-int-float-conversion
# subgroup). Also bit noisy
# -Wimplicit-float-conversion

# Signed <-> unsigned changes. Correct in principle but very noisy on
# existing code; enable once the tree is clean.
# -Wsign-conversion

# This catches all types of implicit conversations. But currently too noisy
# -Wconversion
)

add_subdirectory(src/util)
add_subdirectory(src/fibers)
add_subdirectory(src/gdb)
Expand Down
2 changes: 1 addition & 1 deletion contrib/liburing-cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ add_library(liburing STATIC

# LIBURING_BIN must come before LIBURING_SRC/src/include so the generated
# liburing/compat.h and liburing/io_uring_version.h shadow the absent originals.
target_include_directories(liburing PUBLIC ${LIBURING_BIN} ${LIBURING_SRC}/src/include)
target_include_directories(liburing SYSTEM PUBLIC ${LIBURING_BIN} ${LIBURING_SRC}/src/include)

target_compile_definitions(liburing PRIVATE
_GNU_SOURCE
Expand Down
2 changes: 1 addition & 1 deletion src/fibers/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static int readSysfsUint32(const char * path, uint32_t * out) noexcept
buf[n] = '\0';

char * end;
uint32_t val = ::strtoul(buf, &end, 10);
uint32_t val = static_cast<uint32_t>(::strtoul(buf, &end, 10));
if (end == buf)
{
return EINVAL;
Expand Down
6 changes: 3 additions & 3 deletions src/fibers/fiber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ struct FiberScheduler::ProcessorState
void FiberScheduler::ProcessorState::initialize(uint32_t cpu) noexcept
{
SILK_ASSERT(cpu < INVALID_PROCESSOR_NUMBER);
number = cpu;
number = static_cast<uint16_t>(cpu);

readyQueue.initialize(options.readyQueueCapacity);

Expand Down Expand Up @@ -1041,7 +1041,7 @@ void FiberScheduler::initialize(const Options * userOptions) noexcept
if (CPU_ISSET(cpu, &processCpuSet))
{
ProcessorState * processor = &scheduler->processorState[cpu];
processor->number = cpu;
processor->number = static_cast<uint16_t>(cpu);
}
}

Expand Down Expand Up @@ -1266,7 +1266,7 @@ void FiberScheduler::enqueueReady(Fiber * fiber) noexcept
{
if (fiber->processorNumber == INVALID_PROCESSOR_NUMBER)
{
fiber->processorNumber = getCurrentProcessor();
fiber->processorNumber = static_cast<uint16_t>(getCurrentProcessor());
}

ProcessorState * processor = &scheduler->processorState[fiber->processorNumber];
Expand Down
2 changes: 1 addition & 1 deletion src/util/benchmarks/bounded-queue-bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class BoundedQueueBench : public benchmark::Fixture
{
for (uint64_t i = 0; i < CAPACITY; ++i)
{
bool b = queue.enqueue(i);
bool b = queue.enqueue(static_cast<int>(i));
SILK_ASSERT(b);
}
}
Expand Down
Loading