aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-04-03 19:02:46 -0700
committerGravatar Kurtis Rader <krader@skepticism.us>2016-04-03 19:02:46 -0700
commit9dd6873e5855f69b01f2e3705a49a4231c992e71 (patch)
tree7fc073cc4780b381285567b1df1b6caf9966bb00
parent3f1fc332e7451187b1b9806f544bc8199fa412a8 (diff)
lint: remove or comment out unused functions
Cppcheck has identified a lot of unused functions. This removes funcs that are unlikely to ever be used. Others that might be useful for debugging I've commented out with "#if 0".
-rw-r--r--src/builtin.cpp4
-rw-r--r--src/common.cpp5
-rw-r--r--src/common.h3
-rw-r--r--src/expand.cpp56
-rw-r--r--src/expand.h1
-rw-r--r--src/fish_tests.cpp8
-rw-r--r--src/io.cpp4
-rw-r--r--src/io.h4
-rw-r--r--src/parser.cpp2
-rw-r--r--src/proc.cpp12
10 files changed, 25 insertions, 74 deletions
diff --git a/src/builtin.cpp b/src/builtin.cpp
index f4de72c7..dd67817a 100644
--- a/src/builtin.cpp
+++ b/src/builtin.cpp
@@ -3925,6 +3925,8 @@ static int builtin_history(parser_t &parser, io_streams_t &streams, wchar_t **ar
return STATUS_BUILTIN_ERROR;
}
+#if 0
+// Disabled for the 2.2.0 release: https://github.com/fish-shell/fish-shell/issues/1809.
int builtin_parse(parser_t &parser, io_streams_t &streams, wchar_t **argv)
{
struct sigaction act;
@@ -3966,6 +3968,7 @@ int builtin_parse(parser_t &parser, io_streams_t &streams, wchar_t **argv)
}
return STATUS_BUILTIN_OK;
}
+#endif
int builtin_true(parser_t &parser, io_streams_t &streams, wchar_t **argv)
{
@@ -3992,6 +3995,7 @@ static const builtin_data_t builtin_datas[]=
{
{ L"[", &builtin_test, N_(L"Test a condition") },
#if 0
+ // Disabled for the 2.2.0 release: https://github.com/fish-shell/fish-shell/issues/1809.
{ L"__fish_parse", &builtin_parse, N_(L"Try out the new parser") },
#endif
{ L"and", &builtin_generic, N_(L"Execute command if previous command suceeded") },
diff --git a/src/common.cpp b/src/common.cpp
index a796baca..84c3de65 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -689,11 +689,6 @@ void debug(int level, const char *msg, ...)
errno = errno_old;
}
-void print_stderr(const wcstring &str)
-{
- fprintf(stderr, "%ls\n", str.c_str());
-}
-
void read_ignore(int fd, void *buff, size_t count)
{
size_t ignore __attribute__((unused));
diff --git a/src/common.h b/src/common.h
index 74640988..d6eb0191 100644
--- a/src/common.h
+++ b/src/common.h
@@ -811,9 +811,6 @@ ssize_t read_loop(int fd, void *buff, size_t count);
void debug(int level, const char *msg, ...);
void debug(int level, const wchar_t *msg, ...);
-/** Writes a string to stderr, followed by a newline */
-void print_stderr(const wcstring &str);
-
/**
Replace special characters with backslash escape sequences. Newline is
replaced with \n, etc.
diff --git a/src/expand.cpp b/src/expand.cpp
index c2b4258c..de67ffa8 100644
--- a/src/expand.cpp
+++ b/src/expand.cpp
@@ -1998,62 +1998,6 @@ bool fish_xdm_login_hack_hack_hack_hack(std::vector<std::string> *cmds, int argc
return result;
}
-bool fish_openSUSE_dbus_hack_hack_hack_hack(std::vector<completion_t> *args)
-{
- static signed char isSUSE = -1;
- if (isSUSE == 0)
- return false;
-
- bool result = false;
- if (args && ! args->empty())
- {
- const wcstring &cmd = args->at(0).completion;
- if (cmd.find(L"DBUS_SESSION_BUS_") != wcstring::npos)
- {
- /* See if we are SUSE */
- if (isSUSE < 0)
- {
- struct stat buf = {};
- isSUSE = (0 == stat("/etc/SuSE-release", &buf));
- }
-
- if (isSUSE)
- {
- /* Look for an equal sign */
- size_t where = cmd.find(L'=');
- if (where != wcstring::npos)
- {
- /* Oh my. It's presumably of the form foo=bar; find the = and split */
- const wcstring key = wcstring(cmd, 0, where);
-
- /* Trim whitespace and semicolon */
- wcstring val = wcstring(cmd, where+1);
- size_t last_good = val.find_last_not_of(L"\n ;");
- if (last_good != wcstring::npos)
- val.resize(last_good + 1);
-
- args->clear();
- append_completion(args, L"set");
- if (key == L"DBUS_SESSION_BUS_ADDRESS")
- append_completion(args, L"-x");
- append_completion(args, key);
- append_completion(args, val);
- result = true;
- }
- else if (string_prefixes_string(L"export DBUS_SESSION_BUS_ADDRESS;", cmd))
- {
- /* Nothing, we already exported it */
- args->clear();
- append_completion(args, L"echo");
- append_completion(args, L"-n");
- result = true;
- }
- }
- }
- }
- return result;
-}
-
bool expand_abbreviation(const wcstring &src, wcstring *output)
{
if (src.empty())
diff --git a/src/expand.h b/src/expand.h
index 731acd71..6ae91cca 100644
--- a/src/expand.h
+++ b/src/expand.h
@@ -168,7 +168,6 @@ bool expand_abbreviation(const wcstring &src, wcstring *output);
/* Terrible hacks */
bool fish_xdm_login_hack_hack_hack_hack(std::vector<std::string> *cmds, int argc, const char * const *argv);
-bool fish_openSUSE_dbus_hack_hack_hack_hack(std::vector<completion_t> *args);
#endif
diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp
index 5bacab80..9afb4344 100644
--- a/src/fish_tests.cpp
+++ b/src/fish_tests.cpp
@@ -2887,8 +2887,7 @@ public:
static void test_history(void);
static void test_history_merge(void);
static void test_history_formats(void);
- static void test_history_speed(void);
-
+ // static void test_history_speed(void);
static void test_history_races(void);
static void test_history_races_pound_on_history();
};
@@ -3378,6 +3377,8 @@ void history_tests_t::test_history_formats(void)
}
}
+#if 0
+// This test isn't run at this time. It was added by commit b9283d48 but not actually enabled.
void history_tests_t::test_history_speed(void)
{
say(L"Testing history speed (pid is %d)", getpid());
@@ -3403,6 +3404,7 @@ void history_tests_t::test_history_speed(void)
hist->clear();
delete hist;
}
+#endif
static void test_new_parser_correctness(void)
{
@@ -4483,8 +4485,8 @@ int main(int argc, char **argv)
if (should_test_function("history_merge")) history_tests_t::test_history_merge();
if (should_test_function("history_races")) history_tests_t::test_history_races();
if (should_test_function("history_formats")) history_tests_t::test_history_formats();
- //history_tests_t::test_history_speed();
if (should_test_function("string")) test_string();
+ // history_tests_t::test_history_speed();
say(L"Encountered %d errors in low-level tests", err_count);
if (s_test_run_count == 0)
diff --git a/src/io.cpp b/src/io.cpp
index da326f55..61452830 100644
--- a/src/io.cpp
+++ b/src/io.cpp
@@ -183,6 +183,9 @@ void io_chain_t::append(const io_chain_t &chain)
this->insert(this->end(), chain.begin(), chain.end());
}
+#if 0
+// This isn't used so the lint tools were complaining about its presence. I'm keeping it in the
+// source because it could be useful for debugging.
void io_print(const io_chain_t &chain)
{
if (chain.empty())
@@ -206,6 +209,7 @@ void io_print(const io_chain_t &chain)
}
}
}
+#endif
/* If the given fd is used by the io chain, duplicates it repeatedly until an fd not used in the io chain is found, or we run out. If we return a new fd or an error, closes the old one. Any fd created is marked close-on-exec. Returns -1 on failure (in which case the given fd is still closed). */
static int move_fd_to_unused(int fd, const io_chain_t &io_chain)
diff --git a/src/io.h b/src/io.h
index adc59be1..181099ad 100644
--- a/src/io.h
+++ b/src/io.h
@@ -304,7 +304,9 @@ struct io_streams_t
}
};
-/** Print debug information about the specified IO redirection chain to stderr. */
+#if 0
+// Print debug information about the specified IO redirection chain to stderr.
void io_print(const io_chain_t &chain);
+#endif
#endif
diff --git a/src/parser.cpp b/src/parser.cpp
index 2097aecf..2862df60 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -842,8 +842,6 @@ int parser_t::eval_acquiring_tree(const wcstring &cmd, const io_chain_t &io, enu
return 0;
}
- //print_stderr(block_stack_description());
-
/* Determine the initial eval level. If this is the first context, it's -1; otherwise it's the eval level of the top context. This is sort of wonky because we're stitching together a global notion of eval level from these separate objects. A better approach would be some profile object that all contexts share, and that tracks the eval levels on its own. */
int exec_eval_level = (execution_contexts.empty() ? -1 : execution_contexts.back()->current_eval_level());
diff --git a/src/proc.cpp b/src/proc.cpp
index f5c833e2..1a0d6479 100644
--- a/src/proc.cpp
+++ b/src/proc.cpp
@@ -94,15 +94,21 @@ size_t job_iterator_t::count() const
return this->job_list->size();
}
+#if 0
+// This isn't used so the lint tools were complaining about its presence. I'm keeping it in the
+// source because it could be useful for debugging. However, it would probably be better to add a
+// verbose or debug option to the builtin `jobs` command.
void print_jobs(void)
{
job_iterator_t jobs;
job_t *j;
- while ((j = jobs.next()))
- {
- printf("%p -> %ls -> (foreground %d, complete %d, stopped %d, constructed %d)\n", j, j->command_wcstr(), job_get_flag(j, JOB_FOREGROUND), job_is_completed(j), job_is_stopped(j), job_get_flag(j, JOB_CONSTRUCTED));
+ while (j = jobs.next()) {
+ printf("%p -> %ls -> (foreground %d, complete %d, stopped %d, constructed %d)\n",
+ j, j->command_wcstr(), job_get_flag(j, JOB_FOREGROUND), job_is_completed(j),
+ job_is_stopped(j), job_get_flag(j, JOB_CONSTRUCTED));
}
}
+#endif
int is_interactive_session=0;
int is_subshell=0;