More using FLOGF when formatting is needed

sed-patched, every time a "%" is used in a call to `FLOG`, we use
`FLOGF` instead.
This commit is contained in:
Fabian Homborg 2019-05-30 11:54:09 +02:00
parent 9d62d8e3fd
commit d73ee4d54b
17 changed files with 40 additions and 40 deletions

View file

@ -2435,10 +2435,10 @@ void redirect_tty_output() {
/// Display a failed assertion message, dump a stack trace if possible, then die. /// Display a failed assertion message, dump a stack trace if possible, then die.
[[noreturn]] void __fish_assert(const char *msg, const char *file, size_t line, int error) { [[noreturn]] void __fish_assert(const char *msg, const char *file, size_t line, int error) {
if (error) { if (error) {
FLOG(error, L"%s:%zu: failed assertion: %s: errno %d (%s)", file, line, msg, error, FLOGF(error, L"%s:%zu: failed assertion: %s: errno %d (%s)", file, line, msg, error,
std::strerror(error)); std::strerror(error));
} else { } else {
FLOG(error, L"%s:%zu: failed assertion: %s", file, line, msg); FLOGF(error, L"%s:%zu: failed assertion: %s", file, line, msg);
} }
show_stackframe(L'E', 99, 1); show_stackframe(L'E', 99, 1);
abort(); abort();

View file

@ -906,7 +906,7 @@ bool completer_t::complete_param(const wcstring &cmd_orig, const wcstring &popt,
} }
}; };
// FLOG(error, L"\nThinking about looking up completions for %ls\n", cmd.c_str()); // FLOGF(error, L"\nThinking about looking up completions for %ls\n", cmd.c_str());
bool head_exists = builtin_exists(cmd); bool head_exists = builtin_exists(cmd);
// Only reload environment variables if builtin_exists returned false, as an optimization // Only reload environment variables if builtin_exists returned false, as an optimization
if (head_exists == false) { if (head_exists == false) {

View file

@ -140,7 +140,7 @@ void fix_colon_delimited_var(const wcstring &var_name, env_stack_t &vars) {
std::replace(newstrs.begin(), newstrs.end(), empty, wcstring(L".")); std::replace(newstrs.begin(), newstrs.end(), empty, wcstring(L"."));
int retval = vars.set(var_name, ENV_DEFAULT | ENV_USER, std::move(newstrs)); int retval = vars.set(var_name, ENV_DEFAULT | ENV_USER, std::move(newstrs));
if (retval != ENV_OK) { if (retval != ENV_OK) {
FLOG(error, L"fix_colon_delimited_var failed unexpectedly with retval %d", retval); FLOGF(error, L"fix_colon_delimited_var failed unexpectedly with retval %d", retval);
} }
} }
} }
@ -1353,7 +1353,7 @@ wcstring env_get_runtime_path() {
if (!uname || check_runtime_path(tmpdir.c_str()) != 0) { if (!uname || check_runtime_path(tmpdir.c_str()) != 0) {
FLOG(error, L"Runtime path not available."); FLOG(error, L"Runtime path not available.");
FLOG(error, L"Try deleting the directory %s and restarting fish.", tmpdir.c_str()); FLOGF(error, L"Try deleting the directory %s and restarting fish.", tmpdir.c_str());
return result; return result;
} }

View file

@ -196,11 +196,11 @@ static bool append_file_entry(env_var_t::env_var_flags_t flags, const wcstring &
// Append variable name like "fish_color_cwd". // Append variable name like "fish_color_cwd".
if (!valid_var_name(key_in)) { if (!valid_var_name(key_in)) {
FLOG(error, L"Illegal variable name: '%ls'", key_in.c_str()); FLOGF(error, L"Illegal variable name: '%ls'", key_in.c_str());
success = false; success = false;
} }
if (success && !append_utf8(key_in, result, storage)) { if (success && !append_utf8(key_in, result, storage)) {
FLOG(error, L"Could not convert %ls to narrow character string", key_in.c_str()); FLOGF(error, L"Could not convert %ls to narrow character string", key_in.c_str());
success = false; success = false;
} }
@ -211,7 +211,7 @@ static bool append_file_entry(env_var_t::env_var_flags_t flags, const wcstring &
// Append value. // Append value.
if (success && !append_utf8(full_escape(val_in), result, storage)) { if (success && !append_utf8(full_escape(val_in), result, storage)) {
FLOG(error, L"Could not convert %ls to narrow character string", val_in.c_str()); FLOGF(error, L"Could not convert %ls to narrow character string", val_in.c_str());
success = false; success = false;
} }
@ -448,7 +448,7 @@ bool env_universal_t::write_to_fd(int fd, const wcstring &path) {
std::string contents = serialize_with_vars(vars); std::string contents = serialize_with_vars(vars);
if (write_loop(fd, contents.data(), contents.size()) < 0) { if (write_loop(fd, contents.data(), contents.size()) < 0) {
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
FLOG(error, _(L"Unable to write to universal variables file '%ls': %s"), path.c_str(), FLOGF(error, _(L"Unable to write to universal variables file '%ls': %s"), path.c_str(),
error); error);
success = false; success = false;
} }
@ -464,7 +464,7 @@ bool env_universal_t::move_new_vars_file_into_place(const wcstring &src, const w
int ret = wrename(src, dst); int ret = wrename(src, dst);
if (ret != 0) { if (ret != 0) {
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
FLOG(error, _(L"Unable to rename file from '%ls' to '%ls': %s"), src.c_str(), dst.c_str(), FLOGF(error, _(L"Unable to rename file from '%ls' to '%ls': %s"), src.c_str(), dst.c_str(),
error); error);
} }
return ret == 0; return ret == 0;
@ -527,7 +527,7 @@ bool env_universal_t::open_temporary_file(const wcstring &directory, wcstring *o
if (!success) { if (!success) {
const char *error = std::strerror(saved_errno); const char *error = std::strerror(saved_errno);
FLOG(error, _(L"Unable to open temporary file '%ls': %s"), out_path->c_str(), error); FLOGF(error, _(L"Unable to open temporary file '%ls': %s"), out_path->c_str(), error);
} }
return success; return success;
} }
@ -589,7 +589,7 @@ bool env_universal_t::open_and_acquire_lock(const wcstring &path, int *out_fd) {
} }
#endif #endif
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
FLOG(error, _(L"Unable to open universal variable file '%ls': %s"), path.c_str(), FLOGF(error, _(L"Unable to open universal variable file '%ls': %s"), path.c_str(),
error); error);
break; break;
} }
@ -1061,7 +1061,7 @@ class universal_notifier_shmem_poller_t : public universal_notifier_t {
int fd = shm_open(path, O_RDWR | O_CREAT, 0600); int fd = shm_open(path, O_RDWR | O_CREAT, 0600);
if (fd < 0) { if (fd < 0) {
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
FLOG(error, _(L"Unable to open shared memory with path '%s': %s"), path, error); FLOGF(error, _(L"Unable to open shared memory with path '%s': %s"), path, error);
errored = true; errored = true;
} }
@ -1071,7 +1071,7 @@ class universal_notifier_shmem_poller_t : public universal_notifier_t {
struct stat buf = {}; struct stat buf = {};
if (fstat(fd, &buf) < 0) { if (fstat(fd, &buf) < 0) {
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
FLOG(error, _(L"Unable to fstat shared memory object with path '%s': %s"), path, FLOGF(error, _(L"Unable to fstat shared memory object with path '%s': %s"), path,
error); error);
errored = true; errored = true;
} }
@ -1082,7 +1082,7 @@ class universal_notifier_shmem_poller_t : public universal_notifier_t {
bool set_size = !errored && size < (off_t)sizeof(universal_notifier_shmem_t); bool set_size = !errored && size < (off_t)sizeof(universal_notifier_shmem_t);
if (set_size && ftruncate(fd, sizeof(universal_notifier_shmem_t)) < 0) { if (set_size && ftruncate(fd, sizeof(universal_notifier_shmem_t)) < 0) {
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
FLOG(error, _(L"Unable to truncate shared memory object with path '%s': %s"), path, FLOGF(error, _(L"Unable to truncate shared memory object with path '%s': %s"), path,
error); error);
errored = true; errored = true;
} }
@ -1093,7 +1093,7 @@ class universal_notifier_shmem_poller_t : public universal_notifier_t {
MAP_SHARED, fd, 0); MAP_SHARED, fd, 0);
if (addr == MAP_FAILED) { if (addr == MAP_FAILED) {
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
FLOG(error, _(L"Unable to memory map shared memory object with path '%s': %s"), FLOGF(error, _(L"Unable to memory map shared memory object with path '%s': %s"),
path, error); path, error);
this->region = NULL; this->region = NULL;
} else { } else {

View file

@ -792,7 +792,7 @@ static bool exec_block_or_func_process(parser_t &parser, std::shared_ptr<job_t>
const wcstring func_name = p->argv0(); const wcstring func_name = p->argv0();
auto props = function_get_properties(func_name); auto props = function_get_properties(func_name);
if (!props) { if (!props) {
FLOG(error, _(L"Unknown function '%ls'"), p->argv0()); FLOGF(error, _(L"Unknown function '%ls'"), p->argv0());
return false; return false;
} }

View file

@ -224,7 +224,7 @@ static size_t parse_slice(const wchar_t *in, wchar_t **end_ptr, std::vector<long
} }
// debug( 0, L"Push range idx %d %d", i1, i2 ); // debug( 0, L"Push range idx %d %d", i1, i2 );
for (long jjj = i1; jjj * direction <= i2 * direction; jjj += direction) { for (long jjj = i1; jjj * direction <= i2 * direction; jjj += direction) {
// FLOG(error, L"Expand range [subst]: %i\n", jjj); // FLOGF(error, L"Expand range [subst]: %i\n", jjj);
idx.push_back(jjj); idx.push_back(jjj);
} }
continue; continue;

View file

@ -1238,7 +1238,7 @@ bool history_t::rewrite_to_temporary_file(int existing_fd, int dst_fd) const {
const history_item_t old_item = decode_item(*local_file, offset); const history_item_t old_item = decode_item(*local_file, offset);
if (old_item.empty() || deleted_items.count(old_item.str()) > 0) { if (old_item.empty() || deleted_items.count(old_item.str()) > 0) {
// FLOG(error, L"Item is deleted : %s\n", old_item.str().c_str()); // FLOGF(error, L"Item is deleted : %s\n", old_item.str().c_str());
continue; continue;
} }
// Add this old item. // Add this old item.

View file

@ -202,7 +202,7 @@ void iothread_service_completion() {
} else if (wakeup_byte == IO_SERVICE_RESULT_QUEUE) { } else if (wakeup_byte == IO_SERVICE_RESULT_QUEUE) {
iothread_service_result_queue(); iothread_service_result_queue();
} else { } else {
FLOG(error, "Unknown wakeup byte %02x in %s", wakeup_byte, __FUNCTION__); FLOGF(error, "Unknown wakeup byte %02x in %s", wakeup_byte, __FUNCTION__);
} }
} }

View file

@ -360,7 +360,7 @@ parse_execution_result_t parse_execution_context_t::run_block_statement(
} else if (auto header = bheader.try_get_child<g::begin_header, 0>()) { } else if (auto header = bheader.try_get_child<g::begin_header, 0>()) {
ret = run_begin_statement(contents); ret = run_begin_statement(contents);
} else { } else {
FLOG(error, L"Unexpected block header: %ls\n", bheader.node()->describe().c_str()); FLOGF(error, L"Unexpected block header: %ls\n", bheader.node()->describe().c_str());
PARSER_DIE(); PARSER_DIE();
} }
return ret; return ret;
@ -1078,7 +1078,7 @@ parse_execution_result_t parse_execution_context_t::populate_job_process(
break; break;
} }
default: { default: {
FLOG(error, L"'%ls' not handled by new parser yet.", FLOGF(error, L"'%ls' not handled by new parser yet.",
specific_statement.describe().c_str()); specific_statement.describe().c_str());
PARSER_DIE(); PARSER_DIE();
break; break;
@ -1382,7 +1382,7 @@ parse_execution_result_t parse_execution_context_t::eval_node(tnode_t<g::stateme
} else if (auto switchstat = statement.try_get_child<g::switch_statement, 0>()) { } else if (auto switchstat = statement.try_get_child<g::switch_statement, 0>()) {
status = this->run_switch_statement(switchstat); status = this->run_switch_statement(switchstat);
} else { } else {
FLOG(error, "Unexpected node %ls found in %s", statement.node()->describe().c_str(), FLOGF(error, "Unexpected node %ls found in %s", statement.node()->describe().c_str(),
__FUNCTION__); __FUNCTION__);
abort(); abort();
} }

View file

@ -403,7 +403,7 @@ const production_element_t *parse_productions::production_for_token(parse_token_
case parse_token_type_oror: case parse_token_type_oror:
case parse_token_type_end: case parse_token_type_end:
case parse_token_type_terminate: { case parse_token_type_terminate: {
FLOG(error, "Terminal token type %ls passed to %s", token_type_description(node_type), FLOGF(error, "Terminal token type %ls passed to %s", token_type_description(node_type),
__FUNCTION__); __FUNCTION__);
PARSER_DIE(); PARSER_DIE();
break; break;
@ -411,13 +411,13 @@ const production_element_t *parse_productions::production_for_token(parse_token_
case parse_special_type_parse_error: case parse_special_type_parse_error:
case parse_special_type_tokenizer_error: case parse_special_type_tokenizer_error:
case parse_special_type_comment: { case parse_special_type_comment: {
FLOG(error, "Special type %ls passed to %s\n", token_type_description(node_type), FLOGF(error, "Special type %ls passed to %s\n", token_type_description(node_type),
__FUNCTION__); __FUNCTION__);
PARSER_DIE(); PARSER_DIE();
break; break;
} }
case token_type_invalid: { case token_type_invalid: {
FLOG(error, "token_type_invalid passed to %s", __FUNCTION__); FLOGF(error, "token_type_invalid passed to %s", __FUNCTION__);
PARSER_DIE(); PARSER_DIE();
break; break;
} }

View file

@ -257,7 +257,7 @@ static inline parse_token_type_t parse_token_type_from_tokenizer_token(
case TOK_COMMENT: case TOK_COMMENT:
return parse_special_type_comment; return parse_special_type_comment;
} }
FLOG(error, "Bad token type %d passed to %s", (int)tokenizer_token_type, __FUNCTION__); FLOGF(error, "Bad token type %d passed to %s", (int)tokenizer_token_type, __FUNCTION__);
DIE("bad token type"); DIE("bad token type");
return token_type_invalid; return token_type_invalid;
} }

View file

@ -270,15 +270,15 @@ static void maybe_issue_path_warning(const wcstring &which_dir, const wcstring &
FLOG(error, custom_error_msg.c_str()); FLOG(error, custom_error_msg.c_str());
if (path.empty()) { if (path.empty()) {
FLOG(error, _(L"Unable to locate the %ls directory."), which_dir.c_str()); FLOGF(error, _(L"Unable to locate the %ls directory."), which_dir.c_str());
FLOG(error, _(L"Please set the %ls or HOME environment variable before starting fish."), FLOGF(error, _(L"Please set the %ls or HOME environment variable before starting fish."),
xdg_var.c_str()); xdg_var.c_str());
} else { } else {
const wchar_t *env_var = using_xdg ? xdg_var.c_str() : L"HOME"; const wchar_t *env_var = using_xdg ? xdg_var.c_str() : L"HOME";
FLOG(error, _(L"Unable to locate %ls directory derived from $%ls: '%ls'."), FLOGF(error, _(L"Unable to locate %ls directory derived from $%ls: '%ls'."),
which_dir.c_str(), env_var, path.c_str()); which_dir.c_str(), env_var, path.c_str());
FLOG(error, _(L"The error was '%s'."), std::strerror(saved_errno)); FLOGF(error, _(L"The error was '%s'."), std::strerror(saved_errno));
FLOG(error, _(L"Please set $%ls to a directory where you have write access."), env_var); FLOGF(error, _(L"Please set $%ls to a directory where you have write access."), env_var);
} }
ignore_result(write(STDERR_FILENO, "\n", 1)); ignore_result(write(STDERR_FILENO, "\n", 1));
} }

View file

@ -374,7 +374,7 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
const char *err = safe_strerror(errno); const char *err = safe_strerror(errno);
debug_safe(0, "exec: %s", err); debug_safe(0, "exec: %s", err);
// FLOG(error, L"The file '%ls' is marked as an executable but could not be run by the // FLOGF(error, L"The file '%ls' is marked as an executable but could not be run by the
// operating system.", p->actual_cmd); // operating system.", p->actual_cmd);
break; break;
} }

View file

@ -923,7 +923,7 @@ void proc_sanity_check(const parser_t &parser) {
// More than one foreground job? // More than one foreground job?
if (j->is_foreground() && !(j->is_stopped() || j->is_completed())) { if (j->is_foreground() && !(j->is_stopped() || j->is_completed())) {
if (fg_job) { if (fg_job) {
FLOG(error, _(L"More than one job in foreground: job 1: '%ls' job 2: '%ls'"), FLOGF(error, _(L"More than one job in foreground: job 1: '%ls' job 2: '%ls'"),
fg_job->command_wcstr(), j->command_wcstr()); fg_job->command_wcstr(), j->command_wcstr());
sanity_lose(); sanity_lose();
} }
@ -937,13 +937,13 @@ void proc_sanity_check(const parser_t &parser) {
validate_pointer(p->argv0(), _(L"Process name"), null_ok); validate_pointer(p->argv0(), _(L"Process name"), null_ok);
if ((p->stopped & (~0x00000001)) != 0) { if ((p->stopped & (~0x00000001)) != 0) {
FLOG(error, _(L"Job '%ls', process '%ls' has inconsistent state \'stopped\'=%d"), FLOGF(error, _(L"Job '%ls', process '%ls' has inconsistent state \'stopped\'=%d"),
j->command_wcstr(), p->argv0(), p->stopped); j->command_wcstr(), p->argv0(), p->stopped);
sanity_lose(); sanity_lose();
} }
if ((p->completed & (~0x00000001)) != 0) { if ((p->completed & (~0x00000001)) != 0) {
FLOG(error, _(L"Job '%ls', process '%ls' has inconsistent state \'completed\'=%d"), FLOGF(error, _(L"Job '%ls', process '%ls' has inconsistent state \'completed\'=%d"),
j->command_wcstr(), p->argv0(), p->completed); j->command_wcstr(), p->argv0(), p->completed);
sanity_lose(); sanity_lose();
} }

View file

@ -24,12 +24,12 @@ void sanity_lose() {
void validate_pointer(const void *ptr, const wchar_t *err, int null_ok) { void validate_pointer(const void *ptr, const wchar_t *err, int null_ok) {
// Test if the pointer data crosses a segment boundary. // Test if the pointer data crosses a segment boundary.
if ((0x00000003l & (intptr_t)ptr) != 0) { if ((0x00000003l & (intptr_t)ptr) != 0) {
FLOG(error, _(L"The pointer '%ls' is invalid"), err); FLOGF(error, _(L"The pointer '%ls' is invalid"), err);
sanity_lose(); sanity_lose();
} }
if ((!null_ok) && (ptr == 0)) { if ((!null_ok) && (ptr == 0)) {
FLOG(error, _(L"The pointer '%ls' is null"), err); FLOGF(error, _(L"The pointer '%ls' is null"), err);
sanity_lose(); sanity_lose();
} }
} }

View file

@ -243,7 +243,7 @@ tok_t tokenizer_t::read_string() {
} else { } else {
msg.push_back(L'\n'); msg.push_back(L'\n');
} }
FLOG(error, msg.c_str(), c, c, int(mode_begin), int(mode)); FLOGF(error, msg.c_str(), c, c, int(mode_begin), int(mode));
#endif #endif
this->buff++; this->buff++;

View file

@ -131,7 +131,7 @@ const wcstring wgetcwd() {
return str2wcstring(res); return str2wcstring(res);
} }
FLOG(error, _(L"getcwd() failed with errno %d/%s"), errno, std::strerror(errno)); FLOGF(error, _(L"getcwd() failed with errno %d/%s"), errno, std::strerror(errno));
return wcstring(); return wcstring();
} }