From b6f5df81854f9afd9084066215a80a702649a405 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Sat, 19 Oct 2024 23:00:41 +0200 Subject: [PATCH] refactor(file_type): allow types wider than uint16_t --- include/dwarfs/file_type.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/dwarfs/file_type.h b/include/dwarfs/file_type.h index 3864f316..05046ab8 100644 --- a/include/dwarfs/file_type.h +++ b/include/dwarfs/file_type.h @@ -21,6 +21,7 @@ #pragma once +#include #include namespace dwarfs { @@ -38,7 +39,9 @@ struct posix_file_type { fifo = 0010000, }; - static constexpr value from_mode(uint16_t mode) { + static constexpr value from_mode(std::unsigned_integral auto mode) + requires(sizeof(mode) >= sizeof(uint16_t)) + { return static_cast(mode & mask); } };