From e6e852b7e0279221c7474cc08359a9500530f1a5 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 7 Mar 2026 15:50:15 +0200 Subject: [PATCH] lib: improve error checking --- lib/mu-maildir.cc | 5 +++-- lib/mu-query-parser.cc | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/mu-maildir.cc b/lib/mu-maildir.cc index e93566a7..91a2e51d 100644 --- a/lib/mu-maildir.cc +++ b/lib/mu-maildir.cc @@ -101,7 +101,8 @@ create_noindex(const std::string& path) const auto noindexpath{join_paths(path, MU_MAILDIR_NOINDEX_FILE)}; /* note, if the 'close' failed, creation may still have succeeded...*/ - int fd = ::creat(noindexpath.c_str(), 0644); + // NO O_EXCL it's fine if it already exists + int fd = ::open(noindexpath.c_str(), O_WRONLY | O_CREAT, 0644); if (fd < 0 || ::close(fd) != 0) return Err(Error{Error::Code::File, "error creating .noindex: {}", g_strerror(errno)}); @@ -217,6 +218,7 @@ clear_links(const std::string& path, DIR* dir) if (!subdir) { mu_warning("error opening dir {}: {}", fullpath, g_strerror(errno)); res = false; + break; } if (!clear_links(fullpath, subdir)) res = false; @@ -321,7 +323,6 @@ Mu::maildir_move_message(const std::string& oldpath, return Ok(); // nothing to do. if (!assume_remote) { /* for testing */ - if (::rename(oldpath.c_str(), newpath.c_str()) == 0) /* seems it worked; double-check */ return msg_move_verify(oldpath, newpath); /* LCOV_EXCL_START*/ diff --git a/lib/mu-query-parser.cc b/lib/mu-query-parser.cc index 2928b995..3da4689f 100644 --- a/lib/mu-query-parser.cc +++ b/lib/mu-query-parser.cc @@ -148,11 +148,15 @@ matcher(Sexp& tokens, ParseContext& ctx) if (!fields.empty()) { Sexp vals{}; vals.add(or_sym); - for (auto&& field: fields) + for (auto&& field: fields) { + if (!second(val)) + continue; if (auto&& phrase{phrasify(field, *second(val))}; phrase) vals.add(std::move(*phrase)); else - vals.add(Sexp{Sexp::Symbol{field.name}, Sexp{*second(val)}}); + vals.add(Sexp{Sexp::Symbol{field.name}, + Sexp{*second(val)}}); + } val = std::move(vals); }