fix unused parameter error

The recent change to improve the behavior of the `bg` command (commit
3edb7d538) resulted in the `send_to_bg()` no longer using the `name`
parameter it was given. This rectifies that lint warning by removing
that parameter as it never served a useful purpose.
This commit is contained in:
Kurtis Rader 2017-04-12 22:48:32 -07:00
parent 095e04cb0d
commit c3584111d6

View file

@ -2994,7 +2994,7 @@ static int builtin_fg(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
} }
/// Helper function for builtin_bg(). /// Helper function for builtin_bg().
static int send_to_bg(parser_t &parser, io_streams_t &streams, job_t *j, const wchar_t *name) { static int send_to_bg(parser_t &parser, io_streams_t &streams, job_t *j) {
assert(j != NULL); assert(j != NULL);
if (!j->get_flag(JOB_CONTROL)) { if (!j->get_flag(JOB_CONTROL)) {
streams.err.append_format( streams.err.append_format(
@ -3016,7 +3016,8 @@ static int send_to_bg(parser_t &parser, io_streams_t &streams, job_t *j, const w
static int builtin_bg(parser_t &parser, io_streams_t &streams, wchar_t **argv) { static int builtin_bg(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
int res = STATUS_BUILTIN_OK; int res = STATUS_BUILTIN_OK;
if (argv[1] == 0) { if (!argv[1]) {
// No jobs were specified so use the most recent (i.e., last) job.
job_t *j; job_t *j;
job_iterator_t jobs; job_iterator_t jobs;
while ((j = jobs.next())) { while ((j = jobs.next())) {
@ -3029,9 +3030,13 @@ static int builtin_bg(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
streams.err.append_format(_(L"%ls: There are no suitable jobs\n"), argv[0]); streams.err.append_format(_(L"%ls: There are no suitable jobs\n"), argv[0]);
res = STATUS_BUILTIN_ERROR; res = STATUS_BUILTIN_ERROR;
} else { } else {
res = send_to_bg(parser, streams, j, _(L"(default)")); res = send_to_bg(parser, streams, j);
} }
} else {
return res;
}
// The user specified at least one job to be backgrounded.
std::vector<int> pids; std::vector<int> pids;
// If one argument is not a valid pid (i.e. integer >= 0), fail without backgrounding anything, // If one argument is not a valid pid (i.e. integer >= 0), fail without backgrounding anything,
@ -3039,25 +3044,24 @@ static int builtin_bg(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
for (int i = 1; argv[i]; i++) { for (int i = 1; argv[i]; i++) {
int pid = fish_wcstoi(argv[i]); int pid = fish_wcstoi(argv[i]);
if (errno || pid < 0) { if (errno || pid < 0) {
streams.err.append_format(_(L"%ls: '%ls' is not a valid job specifier\n"), argv[0], argv[i]); streams.err.append_format(_(L"%ls: '%ls' is not a valid job specifier\n"), L"bg",
argv[i]);
res = STATUS_BUILTIN_ERROR; res = STATUS_BUILTIN_ERROR;
} }
pids.push_back(pid); pids.push_back(pid);
} }
if (res == STATUS_BUILTIN_ERROR) {
return res; if (res == STATUS_BUILTIN_ERROR) return res;
}
// Background all existing jobs that match the pids. // Background all existing jobs that match the pids.
// Non-existent jobs aren't an error, but information about them is useful. // Non-existent jobs aren't an error, but information about them is useful.
for (auto p : pids) { for (auto p : pids) {
if (job_t* j = job_get_from_pid(p)) { if (job_t* j = job_get_from_pid(p)) {
res |= send_to_bg(parser, streams, j, *argv); res |= send_to_bg(parser, streams, j);
} else { } else {
streams.err.append_format(_(L"%ls: Could not find job '%d'\n"), argv[0], p); streams.err.append_format(_(L"%ls: Could not find job '%d'\n"), argv[0], p);
} }
} }
}
return res; return res;
} }