refactor: remove the tr_error** idiom (#6198)

* refactor: remove the tr_error** idiom

* fix: tr_error::message() is only constexpr in c++20 and up

* chore: silence a couple of g++-12 Wshadow warnings
This commit is contained in:
Charles Kerr
2023-11-04 11:39:41 -05:00
committed by GitHub
parent 4d95aa5298
commit a952a0731f
75 changed files with 1162 additions and 1254 deletions

View File

@@ -245,12 +245,14 @@ int tr_main(int argc, char* argv[])
if (!tr_sys_path_exists(sz_download_dir))
{
tr_error* error = nullptr;
if (!tr_sys_dir_create(sz_download_dir, TR_SYS_DIR_CREATE_PARENTS, 0700, &error))
if (auto error = tr_error{}; !tr_sys_dir_create(sz_download_dir, TR_SYS_DIR_CREATE_PARENTS, 0700, &error) && error)
{
fprintf(stderr, "Unable to create download directory \"%s\": %s\n", sz_download_dir.c_str(), error->message);
tr_error_free(error);
auto const errmsg = fmt::format(
"Couldn't create '{path}': {error} ({error_code})",
fmt::arg("path", sz_download_dir),
fmt::arg("error", error.message()),
fmt::arg("error_code", error.code()));
fmt::print(stderr, "{:s}\n", errmsg);
return EXIT_FAILURE;
}
}