From 91d06ae2fc6114d870ab76a05c1268a6ee417415 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 25 Jul 2020 02:17:48 +0300 Subject: libcamera: file: Use Flags<> class for open flags Use the newly introduced Flags<> class to store a bitfield of File::OpenMode in a type-safe way. The existing File::OpenMode enum is renamed to File::OpenModeFlag to free the File::OpenMode for the Flags<> type alias. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/libcamera/base/file.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libcamera/base/file.cpp b/src/libcamera/base/file.cpp index 944918f2..1c5879b3 100644 --- a/src/libcamera/base/file.cpp +++ b/src/libcamera/base/file.cpp @@ -58,7 +58,7 @@ LOG_DEFINE_CATEGORY(File) */ /** - * \enum File::OpenMode + * \enum File::OpenModeFlag * \brief Mode in which a file is opened * \var File::NotOpen * \brief The file is not open @@ -70,6 +70,11 @@ LOG_DEFINE_CATEGORY(File) * \brief The file is open for reading and writing */ +/** + * \typedef File::OpenMode + * \brief A bitwise combination of File::OpenModeFlag values + */ + /** * \brief Construct a File to represent the file \a name * \param[in] name The file name @@ -168,7 +173,7 @@ bool File::open(File::OpenMode mode) return false; } - int flags = (mode & ReadWrite) - 1; + int flags = static_cast(mode & ReadWrite) - 1; if (mode & WriteOnly) flags |= O_CREAT; -- cgit v1.2.1