From 0d7f51098de9f6f1815e9c3b164e3036ca8832da Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 13 Feb 2016 13:52:13 +0100 Subject: [PATCH] Rewrite switch on wxTextBufferOpenMode to be exhaustive Get rid of the default clause to allow the compiler to warn us if ever add new elements to this enum. No real changes. --- src/common/textfile.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/common/textfile.cpp b/src/common/textfile.cpp index f1c16b16f8..0b15083a7f 100644 --- a/src/common/textfile.cpp +++ b/src/common/textfile.cpp @@ -58,23 +58,26 @@ bool wxTextFile::OnExists() const bool wxTextFile::OnOpen(const wxString &strBufferName, wxTextBufferOpenMode openMode) { - wxFile::OpenMode fileOpenMode; + wxFile::OpenMode fileOpenMode = wxFile::read_write; switch ( openMode ) { - default: - wxFAIL_MSG( wxT("unknown open mode in wxTextFile::Open") ); - wxFALLTHROUGH; - - case ReadAccess : + case ReadAccess: fileOpenMode = wxFile::read; break; - case WriteAccess : + case WriteAccess: fileOpenMode = wxFile::write; break; } + if ( fileOpenMode == wxFile::read_write ) + { + // This must mean it hasn't been initialized in the switch above. + wxFAIL_MSG( wxT("unknown open mode in wxTextFile::Open") ); + return false; + } + return m_file.Open(strBufferName, fileOpenMode); }