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
5 changes: 3 additions & 2 deletions deps/lest/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
}:
stdenv.mkDerivation rec {
pname = "lest";
version = "1.35.2";
version = "1.36.0";

meta = {
description = "A tiny C++11 test framework – lest errors escape testing.";
Expand All @@ -14,7 +14,8 @@ stdenv.mkDerivation rec {

src = fetchGit {
url = "https://github.com/martinmoene/lest.git";
rev = "1eda2f7c33941617fc368ce764b5fbeffccb59bc";
ref = "refs/tags/v${version}";
rev = "57197f32f2c7d3f3d3664a9010d3ff181a40f6ca";
};

cmakeBuildType = "Debug";
Expand Down
5 changes: 5 additions & 0 deletions lib/LiveUpdate/src/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,14 @@ void LiveUpdate::exec(const buffer_t& blob, void* location)
#ifdef PLATFORM_x86_solo5
solo5_exec(blob.data(), blob.size());
throw std::runtime_error("solo5_exec returned");
(void) found_kernel_start;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this code 😅 what does it do

Copy link
Copy Markdown
Contributor Author

@mazunki mazunki Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(void) anything; just casts it to nothing. It's an explicit way of marking a variable used without actually doing anything with it at runtime.

I would have added [[maybe_unused]] to it at the top level, but I am not sure if found_kernel_start makes sense on systems other than x86. If new architectures are added, it should be up to them to mark it as irrelevant for the corresponding subsystems.

I added these void-casts under the assumption that the previous code here actually is correct in ignoring it. That could be wrong.

# elif defined(PLATFORM_UNITTEST)
throw liveupdate_exec_success();
(void) found_kernel_start;
# elif defined(USERSPACE_KERNEL)
hotswap(phys_base, bin_data, bin_len, (void*) (uintptr_t) start_offset, sr_data);
throw liveupdate_exec_success();
(void) found_kernel_start;
# elif defined(ARCH_x86_64)
// change to simple pagetable
__x86_init_paging((void*) 0x1000);
Expand All @@ -270,6 +273,8 @@ void LiveUpdate::exec(const buffer_t& blob, void* location)
((decltype(&hotswap64)) HOTSWAP_AREA)(phys_base, bin_data, bin_len, start_offset, sr_data, nullptr);
}
}
#else
(void) found_kernel_start;
# endif
// copy hotswapping function to sweet spot
memcpy(HOTSWAP_AREA, (void*) &hotswap, &__hotswap_length - (char*) &hotswap);
Expand Down
2 changes: 1 addition & 1 deletion src/arch/i686/paging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void __arch_init_paging()
namespace os {
namespace mem {
__attribute__((weak))
Map map(Map m, const char* name) {
Map map(Map m, const char* name) { // FIXME: use params, remove or mark unused
return {};
}

Expand Down
2 changes: 1 addition & 1 deletion src/crt/c_abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int __vsprintf_chk(char* s, int flag, size_t slen, const char* format, va_list a
__assert ((size_t) res < slen);
return res;
}
int __vsnprintf_chk (char *s, size_t maxlen, int flags, size_t slen,
int __vsnprintf_chk (char *s, [[maybe_unused]] size_t maxlen, int flags, size_t slen,
const char *format, va_list args)
{
assert (slen < maxlen);
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/vmxnet3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ vmxnet3::vmxnet3(hw::PCI_Device& d, const uint16_t mtu) :
assert(this->ptbase);

// verify and select version
bool ok = check_version();
[[maybe_unused]] bool ok = check_version();
assert(ok);

// reset device
Expand Down
2 changes: 1 addition & 1 deletion src/hw/ps2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ namespace hw

// self-test (port1)
write_port1(0xFF);
const uint8_t selftest = read_data();
[[maybe_unused]] const uint8_t selftest = read_data();
assert(selftest == 0xAA && "PS/2 controller self-test");

write_port1(DEV_IDENTIFY);
Expand Down
4 changes: 3 additions & 1 deletion src/kernel/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
//#define DEBUG_SMP

static SMP::Array<Events> managers;
#ifdef INCLUDEOS_SMP_ENABLE
static Spinlock em_lock_;
#endif

Events& Events::get(int cpuid)
{
Expand All @@ -39,7 +41,7 @@ Events& Events::get(int cpuid)
Events& Events::get()
{
#ifdef INCLUDEOS_SMP_ENABLE
static Spinlock lock;
static Spinlock lock; // FIXME: this seems unused.
std::lock_guard<Spinlock> guard(em_lock_);
#endif
return PER_CPU(managers);
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/liveupdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void kernel::setup_liveupdate()
kernel::state().liveupdate_loc = kernel::state().liveupdate_phys;
#endif

const size_t size = kernel::state().liveupdate_size;
[[maybe_unused]] const size_t size = kernel::state().liveupdate_size;
PRATTLE("Setting up LiveUpdate from %p to %p, %zx\n",
(void*) kernel::state().liveupdate_phys,
(void*) kernel::state().liveupdate_loc, size);
Expand Down
2 changes: 1 addition & 1 deletion src/musl/getrandom.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "common.hpp"
#include <kernel/rng.hpp>

// TODO Flags are ignored.
// TODO: flags are ignored.
static long sys_getrandom(void* buf, size_t len, unsigned int flags)
{
rng_absorb(buf, len);
Expand Down
2 changes: 1 addition & 1 deletion src/net/dhcp/dh4client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace net {
{
// default timed out handler spams logs
this->on_config(
[this] (bool timed_out)
[&] (bool timed_out)
{
if (timed_out)
MYINFO("Negotiation timed out (%s)", this->stack.ifname().c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/net/https/openssl_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace http
const std::string& key)
{
fs::memdisk().init_fs(
[] (fs::error_t err, fs::File_system&) {
[] ([[maybe_unused]] fs::error_t err, fs::File_system&) {
assert(!err);
});
/** INIT OPENSSL **/
Expand Down
2 changes: 1 addition & 1 deletion src/net/ip6/slaac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace net
{
// default timed out handler spams logs
this->on_config(
[this] (bool completed)
[&] (bool completed)
{
if (completed) {
INFO("SLAAC", "Autoconf completed for (%s)",
Expand Down
6 changes: 3 additions & 3 deletions src/net/openssl/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tls_load_from_memory(X509_STORE* store,
auto* cbio = BIO_new_mem_buf(cert_buffer.data(), cert_buffer.size());
auto* cert = PEM_read_bio_X509(cbio, NULL, 0, NULL);
assert(cert != NULL && "Invalid certificate");
int res = X509_STORE_add_cert(store, cert);
[[maybe_unused]] int res = X509_STORE_add_cert(store, cert);
assert(res == 1 && "The X509 store did not accept the certificate");
BIO_free(cbio);
}
Expand All @@ -46,7 +46,7 @@ tls_private_key_for_ctx(SSL_CTX* ctx, int bits = 2048)
RSA* rsa = RSA_new();

// TODO: -Wdeprecated-declarations
int ret = RSA_generate_key_ex(rsa, bits, bne, NULL);
[[maybe_unused]] int ret = RSA_generate_key_ex(rsa, bits, bne, NULL);
assert(ret == 1);

// TODO: -Wdeprecated-declarations
Expand All @@ -63,7 +63,7 @@ tls_init_client(fs::List ents)
auto* ctx = SSL_CTX_new(meth);
if (!ctx) throw std::runtime_error("SSL_CTX_new()");

int res = SSL_CTX_set_cipher_list(ctx, "AES256-SHA");
[[maybe_unused]] int res = SSL_CTX_set_cipher_list(ctx, "AES256-SHA");
assert(res == 1);

X509_STORE* store = X509_STORE_new();
Expand Down
2 changes: 1 addition & 1 deletion src/net/openssl/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace openssl
void verify_rng()
{
int random_value = 0;
int rc = RAND_bytes((uint8_t*) &random_value, sizeof(random_value));
[[maybe_unused]] int rc = RAND_bytes((uint8_t*) &random_value, sizeof(random_value));
assert(rc == 0 || rc == 1);
}

Expand Down
2 changes: 1 addition & 1 deletion src/net/openssl/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace openssl
auto* ctx = SSL_CTX_new(TLSv1_2_method());
if (!ctx) throw std::runtime_error("SSL_CTX_new()");

int res = SSL_CTX_set_cipher_list(ctx, "AES256-SHA");
[[maybe_unused]] int res = SSL_CTX_set_cipher_list(ctx, "AES256-SHA");
assert(res == 1);

#ifdef LOAD_FROM_MEMDISK
Expand Down
2 changes: 1 addition & 1 deletion src/platform/x86_nano/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static void platform_init()
x86::idt_initialize_for_cpu(0);
}

void kernel::start(uint32_t boot_magic, uint32_t boot_addr)
void kernel::start([[maybe_unused]] uint32_t boot_magic, uint32_t boot_addr)
{
assert(boot_magic == MULTIBOOT_BOOTLOADER_MAGIC);
kernel::multiboot(boot_addr);
Expand Down
2 changes: 1 addition & 1 deletion src/platform/x86_pc/acpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ namespace x86 {

auto dsdt_addr = (uintptr_t) facp->DSDT;
// verify DSDT
constexpr uint32_t DSDT_t = bake('D', 'S', 'D', 'T');
[[maybe_unused]] constexpr uint32_t DSDT_t = bake('D', 'S', 'D', 'T');
assert(*(uint32_t*) dsdt_addr == DSDT_t);

/// big thanks to kaworu from OSdev.org forums for algo
Expand Down
6 changes: 3 additions & 3 deletions src/platform/x86_pc/apic_revenant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,20 @@ static void revenant_task_handler()
void revenant_main(int cpu)
{
uintptr_t this_stack = smp_main.stack_base + cpu * smp_main.stack_size;
uintptr_t this_stack_end = this_stack - smp_main.stack_size;
[[maybe_unused]] uintptr_t this_stack_end = this_stack - smp_main.stack_size;
// enable Local APIC
x86::APIC::get().smp_enable();
// setup GDT & per-cpu feature
x86::initialize_cpu_tables_for_cpu(cpu);
// show we are online, and verify CPU ID is correct
SMP::global_lock();
auto stack = (uintptr_t) get_cpu_esp();
[[maybe_unused]] auto stack = (uintptr_t) get_cpu_esp();
INFO2("AP %d started at %p", SMP::cpu_id(), (void*) this_stack);
SMP::global_unlock();
// initialize exceptions before asserts
x86::idt_initialize_for_cpu(cpu);
assert(cpu == SMP::cpu_id());
assert(stack >= this_stack_end && stack < this_stack);
assert(stack >= this_stack_end && stack < this_stack); // relates to [[maybe_unused]]

static Spinlock lock;
{
Expand Down
9 changes: 5 additions & 4 deletions vmbuild/elf_syms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ static const char* syms_file = "_elf_symbols.bin";

static int prune_elf_symbols(char*);

int main(int argc, const char** args)
int main(int argc, const char* args[])
{
assert(argc > 1);
if (!(argc > 1)) {
return -1;
};
FILE* f = fopen(args[1], "r");
assert(f);

Expand All @@ -32,8 +34,7 @@ int main(int argc, const char** args)

rewind(f);

[[ maybe_unused ]]
int res = fread(fdata, sizeof(char), size, f);
[[maybe_unused]] int res = fread(fdata, sizeof(char), size, f);
assert(res == size);
fclose(f);

Expand Down