lint: long variable name

This commit is contained in:
Kurtis Rader 2016-11-02 21:54:57 -07:00
parent f05fe4e292
commit b7d910a941
6 changed files with 53 additions and 60 deletions

View file

@ -77,12 +77,10 @@ static int my_env_set(const wchar_t *key, const wcstring_list_t &val, int scope,
struct stat buff;
if (wstat(dir, &buff) == -1) {
error = true;
}
else if (!S_ISDIR(buff.st_mode)) {
} else if (!S_ISDIR(buff.st_mode)) {
error = true;
errno = ENOTDIR;
}
else if (waccess(dir, X_OK) == -1) {
} else if (waccess(dir, X_OK) == -1) {
error = true;
}
@ -90,7 +88,7 @@ static int my_env_set(const wchar_t *key, const wcstring_list_t &val, int scope,
any_success = true;
} else {
streams.err.append_format(_(BUILTIN_SET_PATH_ERROR), L"set", key, dir.c_str(),
strerror(errno));
strerror(errno));
const wchar_t *colon = wcschr(dir.c_str(), L':');
if (colon && *(colon + 1)) {
@ -338,7 +336,7 @@ int builtin_set(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
int erase = 0, list = 0, unexport = 0;
int universal = 0, query = 0;
bool shorten_ok = true;
bool preserve_incoming_failure_exit_status = true;
bool preserve_failure_exit_status = true;
const int incoming_exit_status = proc_get_last_status();
// Variables used for performing the actual work.
@ -364,12 +362,12 @@ int builtin_set(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
}
case 'e': {
erase = 1;
preserve_incoming_failure_exit_status = false;
preserve_failure_exit_status = false;
break;
}
case 'n': {
list = 1;
preserve_incoming_failure_exit_status = false;
preserve_failure_exit_status = false;
break;
}
case 'x': {
@ -398,7 +396,7 @@ int builtin_set(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
}
case 'q': {
query = 1;
preserve_incoming_failure_exit_status = false;
preserve_failure_exit_status = false;
break;
}
case 'h': {
@ -629,7 +627,7 @@ int builtin_set(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
free(dest);
if (retcode == STATUS_BUILTIN_OK && preserve_incoming_failure_exit_status)
if (retcode == STATUS_BUILTIN_OK && preserve_failure_exit_status)
retcode = incoming_exit_status;
return retcode;
}

View file

@ -43,7 +43,7 @@ struct termios shell_modes;
// Note we foolishly assume that pthread_t is just a primitive. But it might be a struct.
static pthread_t main_thread_id = 0;
static bool thread_assertions_configured_for_testing = false;
static bool thread_asserts_cfg_for_testing = false;
wchar_t ellipsis_char;
wchar_t omitted_newline_char;
@ -56,7 +56,7 @@ int debug_stack_frames = 0; // default number of stack frames to show on debug(
static pid_t initial_pid = 0;
/// Be able to restore the term's foreground process group.
static pid_t initial_foreground_process_group = -1;
static pid_t initial_fg_process_group = -1;
/// This struct maintains the current state of the terminal size. It is updated on demand after
/// receiving a SIGWINCH. Do not touch this struct directly, it's managed with a rwlock. Use
@ -1671,9 +1671,7 @@ __attribute__((noinline)) void debug_thread_error(void) {
void set_main_thread() { main_thread_id = pthread_self(); }
void configure_thread_assertions_for_testing(void) {
thread_assertions_configured_for_testing = true;
}
void configure_thread_assertions_for_testing(void) { thread_asserts_cfg_for_testing = true; }
bool is_forked_child(void) {
// Just bail if nobody's called setup_fork_guards, e.g. some of our tools.
@ -1693,14 +1691,14 @@ void setup_fork_guards(void) {
}
void save_term_foreground_process_group(void) {
initial_foreground_process_group = tcgetpgrp(STDIN_FILENO);
initial_fg_process_group = tcgetpgrp(STDIN_FILENO);
}
void restore_term_foreground_process_group(void) {
if (initial_foreground_process_group != -1) {
if (initial_fg_process_group != -1) {
// This is called during shutdown and from a signal handler. We don't bother to complain on
// failure.
tcsetpgrp(STDIN_FILENO, initial_foreground_process_group);
tcsetpgrp(STDIN_FILENO, initial_fg_process_group);
}
}
@ -1710,7 +1708,7 @@ bool is_main_thread() {
}
void assert_is_main_thread(const char *who) {
if (!is_main_thread() && !thread_assertions_configured_for_testing) {
if (!is_main_thread() && !thread_asserts_cfg_for_testing) {
fprintf(stderr,
"Warning: %s called off of main thread. Break on debug_thread_error to debug.\n",
who);
@ -1728,7 +1726,7 @@ void assert_is_not_forked_child(const char *who) {
}
void assert_is_background_thread(const char *who) {
if (is_main_thread() && !thread_assertions_configured_for_testing) {
if (is_main_thread() && !thread_asserts_cfg_for_testing) {
fprintf(stderr,
"Warning: %s called on the main thread (may block!). Break on debug_thread_error "
"to debug.\n",

View file

@ -56,8 +56,8 @@ struct input_mapping_t {
input_mapping_t(const wcstring &s, const std::vector<wcstring> &c,
const wcstring &m = DEFAULT_BIND_MODE, const wcstring &sm = DEFAULT_BIND_MODE)
: seq(s), commands(c), mode(m), sets_mode(sm) {
static unsigned int s_last_input_mapping_specification_order = 0;
specification_order = ++s_last_input_mapping_specification_order;
static unsigned int s_last_input_map_spec_order = 0;
specification_order = ++s_last_input_map_spec_order;
}
};

View file

@ -57,9 +57,9 @@ static pthread_mutex_t s_result_queue_lock;
static std::queue<SpawnRequest_t *> s_result_queue;
// "Do on main thread" support.
static pthread_mutex_t s_main_thread_performer_lock; // protects the main thread requests
static pthread_cond_t s_main_thread_performer_condition; // protects the main thread requests
static pthread_mutex_t s_main_thread_request_queue_lock; // protects the queue
static pthread_mutex_t s_main_thread_performer_lock; // protects the main thread requests
static pthread_cond_t s_main_thread_performer_cond; // protects the main thread requests
static pthread_mutex_t s_main_thread_request_q_lock; // protects the queue
static std::queue<MainThreadRequest_t *> s_main_thread_request_queue;
// Notifying pipes.
@ -73,9 +73,9 @@ static void iothread_init(void) {
// Initialize some locks.
VOMIT_ON_FAILURE(pthread_mutex_init(&s_spawn_queue_lock, NULL));
VOMIT_ON_FAILURE(pthread_mutex_init(&s_result_queue_lock, NULL));
VOMIT_ON_FAILURE(pthread_mutex_init(&s_main_thread_request_queue_lock, NULL));
VOMIT_ON_FAILURE(pthread_mutex_init(&s_main_thread_request_q_lock, NULL));
VOMIT_ON_FAILURE(pthread_mutex_init(&s_main_thread_performer_lock, NULL));
VOMIT_ON_FAILURE(pthread_cond_init(&s_main_thread_performer_condition, NULL));
VOMIT_ON_FAILURE(pthread_cond_init(&s_main_thread_performer_cond, NULL));
// Initialize the completion pipes.
int pipes[2] = {0, 0};
@ -287,7 +287,7 @@ static void iothread_service_main_thread_requests(void) {
// Move the queue to a local variable.
std::queue<MainThreadRequest_t *> request_queue;
{
scoped_lock queue_lock(s_main_thread_request_queue_lock);
scoped_lock queue_lock(s_main_thread_request_q_lock);
std::swap(request_queue, s_main_thread_request_queue);
}
@ -311,7 +311,7 @@ static void iothread_service_main_thread_requests(void) {
// Because the waiting thread performs step 1 under the lock, if we take the lock, we avoid
// posting before the waiting thread is waiting.
scoped_lock broadcast_lock(s_main_thread_performer_lock);
VOMIT_ON_FAILURE(pthread_cond_broadcast(&s_main_thread_performer_condition));
VOMIT_ON_FAILURE(pthread_cond_broadcast(&s_main_thread_performer_cond));
}
}
@ -351,7 +351,7 @@ int iothread_perform_on_main_base(int (*handler)(void *), void *context) {
// Append it. Do not delete the nested scope as it is crucial to the proper functioning of this
// code by virtue of the lock management.
{
scoped_lock queue_lock(s_main_thread_request_queue_lock);
scoped_lock queue_lock(s_main_thread_request_q_lock);
s_main_thread_request_queue.push(&req);
}
@ -365,7 +365,7 @@ int iothread_perform_on_main_base(int (*handler)(void *), void *context) {
// It would be nice to support checking for cancellation here, but the clients need a
// deterministic way to clean up to avoid leaks
VOMIT_ON_FAILURE(
pthread_cond_wait(&s_main_thread_performer_condition, &s_main_thread_performer_lock));
pthread_cond_wait(&s_main_thread_performer_cond, &s_main_thread_performer_lock));
}
// Ok, the request must now be done.

View file

@ -388,7 +388,7 @@ typedef unsigned int process_generation_count_t;
/// A static value tracking how many SIGCHLDs we have seen. This is only ever modified from within
/// the SIGCHLD signal handler, and therefore does not need atomics or locks.
static volatile process_generation_count_t s_sigchld_generation_count = 0;
static volatile process_generation_count_t s_sigchld_generation_cnt = 0;
/// If we have received a SIGCHLD signal, process any children. If await is false, this returns
/// immediately if no SIGCHLD has been received. If await is true, this waits for one. Returns true
@ -397,10 +397,10 @@ static int process_mark_finished_children(bool wants_await) {
ASSERT_IS_MAIN_THREAD();
// A static value tracking the SIGCHLD gen count at the time we last processed it. When this is
// different from s_sigchld_generation_count, it indicates there may be unreaped processes.
// different from s_sigchld_generation_cnt, it indicates there may be unreaped processes.
// There may not be if we reaped them via the other waitpid path. This is only ever modified
// from the main thread, and not from a signal handler.
static process_generation_count_t s_last_processed_sigchld_generation_count = 0;
static process_generation_count_t s_last_sigchld_generation_cnt = 0;
int processed_count = 0;
bool got_error = false;
@ -409,12 +409,12 @@ static int process_mark_finished_children(bool wants_await) {
// needs to be an atomic read (we'd use sig_atomic_t, if we knew that were unsigned -
// fortunately aligned unsigned int is atomic on pretty much any modern chip.) It also needs to
// occur before we start reaping, since the signal handler can be invoked at any point.
const process_generation_count_t local_count = s_sigchld_generation_count;
const process_generation_count_t local_count = s_sigchld_generation_cnt;
// Determine whether we have children to process. Note that we can't reliably use the difference
// because a single SIGCHLD may be delivered for multiple children - see #1768. Also if we are
// awaiting, we always process.
bool wants_waitpid = wants_await || local_count != s_last_processed_sigchld_generation_count;
bool wants_waitpid = wants_await || local_count != s_last_sigchld_generation_cnt;
if (wants_waitpid) {
for (;;) {
@ -448,7 +448,7 @@ static int process_mark_finished_children(bool wants_await) {
if (got_error) {
return -1;
}
s_last_processed_sigchld_generation_count = local_count;
s_last_sigchld_generation_cnt = local_count;
return processed_count;
}
@ -458,7 +458,7 @@ void job_handle_signal(int signal, siginfo_t *info, void *context) {
UNUSED(info);
UNUSED(context);
// This is the only place that this generation count is modified. It's OK if it overflows.
s_sigchld_generation_count += 1;
s_sigchld_generation_cnt += 1;
}
/// Given a command like "cat file", truncate it to a reasonable length.
@ -594,20 +594,17 @@ int job_reap(bool allow_interactive) {
const wcstring job_number_desc =
(job_count == 1) ? wcstring() : format_string(L"Job %d, ", j->job_id);
fwprintf(stdout, _(L"%ls: %ls\'%ls\' terminated by signal %ls (%ls)"),
program_name, job_number_desc.c_str(),
truncate_command(j->command()).c_str(),
sig2wcs(WTERMSIG(p->status)),
signal_get_desc(WTERMSIG(p->status)));
program_name, job_number_desc.c_str(),
truncate_command(j->command()).c_str(), sig2wcs(WTERMSIG(p->status)),
signal_get_desc(WTERMSIG(p->status)));
} else {
const wcstring job_number_desc =
(job_count == 1) ? wcstring()
: format_string(L"from job %d, ", j->job_id);
(job_count == 1) ? wcstring() : format_string(L"from job %d, ", j->job_id);
fwprintf(stdout, _(L"%ls: Process %d, \'%ls\' %ls\'%ls\' "
L"terminated by signal %ls (%ls)"),
program_name, p->pid, p->argv0(), job_number_desc.c_str(),
truncate_command(j->command()).c_str(),
sig2wcs(WTERMSIG(p->status)),
signal_get_desc(WTERMSIG(p->status)));
L"terminated by signal %ls (%ls)"),
program_name, p->pid, p->argv0(), job_number_desc.c_str(),
truncate_command(j->command()).c_str(), sig2wcs(WTERMSIG(p->status)),
signal_get_desc(WTERMSIG(p->status)));
}
if (cur_term != NULL) {

View file

@ -300,7 +300,7 @@ static wchar_t unescaped_quote(const wcstring &str, size_t pos);
static struct termios terminal_mode_on_startup;
/// Mode we use to execute programs.
static struct termios terminal_mode_for_executing_programs;
static struct termios tty_modes_for_external_cmds;
static void reader_super_highlight_me_plenty(int highlight_pos_adjust = 0, bool no_io = false);
@ -312,7 +312,7 @@ static void term_donate() {
set_color(rgb_color_t::normal(), rgb_color_t::normal());
while (1) {
if (tcsetattr(0, TCSANOW, &terminal_mode_for_executing_programs)) {
if (tcsetattr(0, TCSANOW, &tty_modes_for_external_cmds)) {
if (errno != EINTR) {
debug(1, _(L"Could not set terminal mode for new job"));
wperror(L"tcsetattr");
@ -773,10 +773,10 @@ void reader_init() {
tcgetattr(STDIN_FILENO, &terminal_mode_on_startup);
// Set the mode used for program execution, initialized to the current mode.
memcpy(&terminal_mode_for_executing_programs, &terminal_mode_on_startup,
sizeof terminal_mode_for_executing_programs);
terminal_mode_for_executing_programs.c_iflag &= ~IXON; // disable flow control
terminal_mode_for_executing_programs.c_iflag &= ~IXOFF; // disable flow control
memcpy(&tty_modes_for_external_cmds, &terminal_mode_on_startup,
sizeof tty_modes_for_external_cmds);
tty_modes_for_external_cmds.c_iflag &= ~IXON; // disable flow control
tty_modes_for_external_cmds.c_iflag &= ~IXOFF; // disable flow control
// Set the mode used for the terminal, initialized to the current mode.
memcpy(&shell_modes, &terminal_mode_on_startup, sizeof shell_modes);
@ -1362,12 +1362,12 @@ static fuzzy_match_type_t get_best_match_type(const std::vector<completion_t> &c
/// through the completions.
///
/// \param comp the list of completion strings
/// \param continue_after_prefix_insertion If we have a shared prefix, whether to print the list of
/// \param cont_after_prefix_insertion If we have a shared prefix, whether to print the list of
/// completions after inserting it.
///
/// Return true if we inserted text into the command line, false if we did not.
static bool handle_completions(const std::vector<completion_t> &comp,
bool continue_after_prefix_insertion) {
bool cont_after_prefix_insertion) {
bool done = false;
bool success = false;
const editable_line_t *el = &data->command_line;
@ -1486,7 +1486,7 @@ static bool handle_completions(const std::vector<completion_t> &comp,
}
}
if (!continue_after_prefix_insertion && use_prefix) {
if (!cont_after_prefix_insertion && use_prefix) {
return success;
}
@ -2624,8 +2624,8 @@ const wchar_t *reader_readline(int nchars) {
data->cycle_command_line = el->text;
data->cycle_cursor_pos = el->position;
bool continue_after_prefix_insertion = (c == R_COMPLETE_AND_SEARCH);
comp_empty = handle_completions(comp, continue_after_prefix_insertion);
bool cont_after_prefix_insertion = (c == R_COMPLETE_AND_SEARCH);
comp_empty = handle_completions(comp, cont_after_prefix_insertion);
// Show the search field if requested and if we printed a list of completions.
if (c == R_COMPLETE_AND_SEARCH && !comp_empty && !data->pager.empty()) {