From d36a387aca39402b1da7ca9fb26c538f07d0a8b6 Mon Sep 17 00:00:00 2001 From: Larry Doolittle Date: Thu, 7 Nov 2024 19:49:25 -0800 Subject: [PATCH 1/2] kernel/drivertools.h: avoid maybe-uninitialized compile warnings Initialize "unsigned int inner" in hash() functions Includes a log_assert() that might help catch corrupted data structures or future incomplete modification of DriveType definition --- kernel/drivertools.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/drivertools.h b/kernel/drivertools.h index 079701c35..21b5505d8 100644 --- a/kernel/drivertools.h +++ b/kernel/drivertools.h @@ -364,7 +364,7 @@ public: unsigned int hash() const { - unsigned int inner; + unsigned int inner = 0; switch (type_) { case DriveType::NONE: @@ -385,6 +385,9 @@ public: case DriveType::MULTIPLE: inner = multiple_.hash(); break; + default: + log_assert(0); + break; } return mkhash((unsigned int)type_, inner); } @@ -912,7 +915,7 @@ public: unsigned int hash() const { - unsigned int inner; + unsigned int inner = 0; switch (type_) { case DriveType::NONE: @@ -933,6 +936,9 @@ public: case DriveType::MULTIPLE: inner = multiple_.hash(); break; + default: + log_assert(0); + break; } return mkhash((unsigned int)type_, inner); } From 3ae9ca7c2ba8cca30df6829aee4d4e3d4fb24c7a Mon Sep 17 00:00:00 2001 From: Larry Doolittle Date: Fri, 8 Nov 2024 10:30:11 -0800 Subject: [PATCH 2/2] drivertools.h: switch from log_assert(0) to log_abort() for new feature --- kernel/drivertools.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/drivertools.h b/kernel/drivertools.h index 21b5505d8..8929c3426 100644 --- a/kernel/drivertools.h +++ b/kernel/drivertools.h @@ -386,7 +386,7 @@ public: inner = multiple_.hash(); break; default: - log_assert(0); + log_abort(); break; } return mkhash((unsigned int)type_, inner); @@ -937,7 +937,7 @@ public: inner = multiple_.hash(); break; default: - log_assert(0); + log_abort(); break; } return mkhash((unsigned int)type_, inner);