Skip to content

Commit

Permalink
Merge pull request #2346 from natalie-lang/fix-gcc-14-warnings
Browse files Browse the repository at this point in the history
Initialize some variables that gcc 14 warns about
  • Loading branch information
seven1m authored Nov 23, 2024
2 parents 9946ffc + ee159e7 commit 36b37b5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/encoding_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Value EncodingObject::encode(Env *env, EncodingObject *orig_encoding, StringObje

auto source_codepoint = valid ? c : -1;

nat_int_t unicode_codepoint;
nat_int_t unicode_codepoint = -1;
if (source_codepoint == -1) {
switch (options.invalid_option) {
case EncodeInvalidOption::Raise:
Expand Down
8 changes: 4 additions & 4 deletions src/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ void Heap::collect() {

static auto is_profiled = NativeProfiler::the()->enabled();

NativeProfilerEvent *collect_profiler_event;
NativeProfilerEvent *mark_profiler_event;
NativeProfilerEvent *collect_profiler_event = nullptr;
NativeProfilerEvent *mark_profiler_event = nullptr;

if (is_profiled) {
collect_profiler_event = NativeProfilerEvent::named(NativeProfilerEvent::Type::GC, "GC_Collect")->start_now();
Expand Down Expand Up @@ -148,7 +148,7 @@ void Heap::collect() {

void Heap::sweep() {
static auto is_profiled = NativeProfiler::the()->enabled();
NativeProfilerEvent *profiler_event;
NativeProfilerEvent *profiler_event = nullptr;
if (is_profiled)
profiler_event = NativeProfilerEvent::named(NativeProfilerEvent::Type::GC, "GC_Sweep")->start_now();
Defer log_event([&]() {
Expand Down Expand Up @@ -177,7 +177,7 @@ void *Heap::allocate(size_t size) {
std::lock_guard<std::recursive_mutex> gc_lock(g_gc_recursive_mutex);

static auto is_profiled = NativeProfiler::the()->enabled();
NativeProfilerEvent *profiler_event;
NativeProfilerEvent *profiler_event = nullptr;
if (is_profiled)
profiler_event = NativeProfilerEvent::named(NativeProfilerEvent::Type::ALLOCATE, "Allocate")->start_now();
Defer log_event([&]() {
Expand Down
2 changes: 1 addition & 1 deletion src/thread_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ void ThreadObject::setup_interrupt_pipe(Env *env) {
}

void ThreadObject::interrupt() {
::write(s_interrupt_write_fileno, "!", 1);
assert(::write(s_interrupt_write_fileno, "!", 1) != -1);
}

void ThreadObject::clear_interrupt() {
Expand Down
2 changes: 1 addition & 1 deletion src/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Value Value::floatingpoint(double value) {

#define PROFILED_SEND(type) \
static auto is_profiled = NativeProfiler::the()->enabled(); \
NativeProfilerEvent *event; \
NativeProfilerEvent *event = nullptr; \
if (is_profiled) { \
auto classnameOf = [](Value val) -> String { \
if (val.m_type == Type::Integer) \
Expand Down

0 comments on commit 36b37b5

Please sign in to comment.