lint cleanups

This commit is contained in:
Kurtis Rader 2017-02-10 18:47:02 -08:00
parent 52648acdc8
commit 4ffb0adb78
38 changed files with 103 additions and 67 deletions

View file

@ -9,6 +9,5 @@ varFuncNullUB
// warnings are false positives.
unmatchedSuppression
memleak:src/env_universal_common.cpp
flockSemanticsWarning:src/env_universal_common.cpp
flockSemanticsWarning:src/history.cpp

View file

@ -84,6 +84,7 @@
{ symbol: ["uid_t", "private", "<sys/types.h>", "public"] },
{ symbol: ["gid_t", "private", "<sys/types.h>", "public"] },
{ symbol: ["timeval", "private", "<sys/time.h>", "public"] },
{ symbol: ["__uint32_t", "private", "<sys/types.h>", "public"] },
{ symbol: ["uint32_t", "private", "<sys/types.h>", "public"] },
{ symbol: ["uint32_t", "private", "<stdint.h>", "public"] },
{ symbol: ["intptr_t", "private", "<stdint.h>", "public"] },

View file

@ -1,17 +1,16 @@
// The classes responsible for autoloading functions and completions.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <stddef.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include <wchar.h>
#include <algorithm>
#include <memory>
#include <set>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>

View file

@ -3,7 +3,6 @@
#define FISH_AUTOLOAD_H
#include <pthread.h>
#include <stddef.h>
#include <time.h>
#include <set>

View file

@ -3,10 +3,8 @@
#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
#include <wchar.h>
#include <cstring>
#include "builtin.h"
#include "common.h"

View file

@ -15,6 +15,7 @@
#include <wctype.h>
#include <algorithm>
#include <iterator>
#include <memory>
#include <string>
#include <vector>
@ -585,8 +586,7 @@ static int string_match(parser_t &parser, io_streams_t &streams, int argc, wchar
}
}
int rc = matcher->match_count() > 0 ? BUILTIN_STRING_OK : BUILTIN_STRING_NONE;
return rc;
return matcher->match_count() > 0 ? BUILTIN_STRING_OK : BUILTIN_STRING_NONE;
}
struct replace_options_t {
@ -819,8 +819,7 @@ static int string_replace(parser_t &parser, io_streams_t &streams, int argc, wch
}
}
int rc = replacer->replace_count() > 0 ? BUILTIN_STRING_OK : BUILTIN_STRING_NONE;
return rc;
return replacer->replace_count() > 0 ? BUILTIN_STRING_OK : BUILTIN_STRING_NONE;
}
/// Given iterators into a string (forward or reverse), splits the haystack iterators

View file

@ -6,13 +6,13 @@
#include <assert.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <wchar.h>
#include <memory>
#include <string>
#include <type_traits>
#include "builtin.h"
#include "common.h"
@ -234,7 +234,7 @@ class combining_expression : public expression {
combining_expression(token_t tok, range_t where, std::vector<unique_ptr<expression>> exprs,
std::vector<token_t> combs)
: expression(tok, where), subjects(move(exprs)), combiners(move(combs)) {
: expression(tok, where), subjects(std::move(exprs)), combiners(std::move(combs)) {
// We should have one more subject than combiner.
assert(subjects.size() == combiners.size() + 1);
}

View file

@ -15,6 +15,7 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
#include <wchar.h>
@ -30,6 +31,7 @@
#endif
#include <algorithm>
#include <memory> // IWYU pragma: keep
#include <type_traits>
#include "common.h"
#include "env.h"
@ -1783,12 +1785,11 @@ void save_term_foreground_process_group(void) {
}
void restore_term_foreground_process_group(void) {
if (initial_fg_process_group != -1) {
// This is called during shutdown and from a signal handler. We don't bother to complain on
// failure.
if (tcsetpgrp(STDIN_FILENO, initial_fg_process_group) == -1 && errno == ENOTTY) {
redirect_tty_output();
}
if (initial_fg_process_group == -1) return;
// This is called during shutdown and from a signal handler. We don't bother to complain on
// failure because doing so is unlikely to be noticed.
if (tcsetpgrp(STDIN_FILENO, initial_fg_process_group) == -1 && errno == ENOTTY) {
redirect_tty_output();
}
}

View file

@ -15,6 +15,7 @@
#include <memory>
#include <sstream>
#include <string>
#include <type_traits>
#include <vector>
#include "fallback.h" // IWYU pragma: keep

View file

@ -12,11 +12,13 @@
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <functional>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <type_traits>
#include <utility>
#include "autoload.h"

View file

@ -24,6 +24,7 @@
#include <algorithm>
#include <map>
#include <set>
#include <type_traits>
#include <utility>
#include <vector>
@ -189,7 +190,6 @@ void var_stack_t::pop() {
assert(this->top && old_top && !old_top->next);
assert(this->top != NULL);
var_table_t::iterator iter;
for (const auto &entry_pair : old_top->env) {
const var_entry_t &entry = entry_pair.second;
if (entry.exportv) {

View file

@ -5,9 +5,16 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
// We need the sys/file.h for the flock() declaration on Linux but not OS X.
#include <sys/file.h> // IWYU pragma: keep
// We need the ioctl.h header so we can check if SIOCGIFHWADDR is defined by it so we know if we're
// on a Linux system.
#include <sys/ioctl.h> // IWYU pragma: keep
#include <limits.h>
#include <netinet/in.h> // IWYU pragma: keep
#if !defined(__APPLE__) && !defined(__CYGWIN__)
#include <pwd.h>
#endif
#include <stdlib.h>
#include <string.h>
#ifdef __CYGWIN__
@ -18,16 +25,14 @@
#endif
#include <sys/stat.h>
#include <sys/time.h> // IWYU pragma: keep
// We need the sys/file.h for the flock() declaration on Linux but not OS X.
#include <sys/file.h> // IWYU pragma: keep
// We need the ioctl.h header so we can check if SIOCGIFHWADDR is defined by it so we know if we're
// on a Linux system.
#include <sys/ioctl.h> // IWYU pragma: keep
#include <sys/types.h> // IWYU pragma: keep
#include <unistd.h>
#include <wchar.h>
#include <atomic>
#include <map>
#include <string>
#include <type_traits>
#include <utility>
#include "common.h"

View file

@ -1,12 +1,14 @@
// Functions for handling event triggers.
#include "config.h" // IWYU pragma: keep
#include <assert.h>
#include <signal.h>
#include <unistd.h>
#include <algorithm>
#include <functional>
#include <memory>
#include <string>
#include <type_traits>
#include "common.h"
#include "event.h"

View file

@ -7,21 +7,23 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <algorithm>
#include <vector>
#ifdef HAVE_SPAWN_H
#include <spawn.h>
#endif
#include <map>
#include <memory>
#include <string>
#ifdef HAVE_SIGINFO_H
#include <siginfo.h>
#endif
#include <signal.h>
#ifdef HAVE_SPAWN_H
#include <spawn.h>
#endif
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <memory>
#include <string>
#include <type_traits>
#include <vector>
#include "builtin.h"
#include "common.h"

View file

@ -2,6 +2,7 @@
// IWYU pragma: no_include <cstddef>
#include "config.h"
#include <assert.h>
#include <errno.h>
#include <pwd.h>
#include <stdarg.h>
@ -11,17 +12,13 @@
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#ifdef HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h> // IWYU pragma: keep
#endif
#include <assert.h>
#include <vector>
#ifdef SunOS
#include <procfs.h>
#endif
#include <stdio.h>
#include <memory> // IWYU pragma: keep
#if __APPLE__
#include <sys/proc.h>
#else
@ -29,6 +26,12 @@
#include <sys/stat.h>
#endif
#include <algorithm>
#include <functional>
#include <memory> // IWYU pragma: keep
#include <type_traits>
#include <vector>
#include "common.h"
#include "complete.h"
#include "env.h"

View file

@ -24,12 +24,15 @@
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <array>
#include <atomic>
#include <functional>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "builtin.h"
@ -1653,9 +1656,9 @@ struct pager_layout_testcase_t {
size_t width;
const wchar_t *expected;
// Run ourselves as a test case
// Set our data on the pager, and then check the rendering
// We should have one line, and it should have our expected text
// Run ourselves as a test case.
// Set our data on the pager, and then check the rendering.
// We should have one line, and it should have our expected text.
void run(pager_t &pager) const {
pager.set_term_size(this->width, 24);
page_rendering_t rendering = pager.render();

View file

@ -7,11 +7,13 @@
#include <sys/stat.h>
#include <unistd.h>
#include <wchar.h>
#include <algorithm>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <type_traits>
#include <utility>
#include "builtin.h"

View file

@ -63,7 +63,6 @@ inline highlight_spec_t highlight_make_background(highlight_spec_t val) {
}
class history_item_t;
struct file_detection_context_t;
/// Perform syntax highlighting for the shell commands in buff. The result is stored in the color
/// array as a color_code from the HIGHLIGHT_ enum for each character in buff.

View file

@ -17,12 +17,15 @@
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <atomic>
#include <cwchar>
#include <functional>
#include <iterator>
#include <map>
#include <numeric>
#include <type_traits>
#include "common.h"
#include "env.h"

View file

@ -1,6 +1,7 @@
// Functions for reading a character of input from stdin.
#include "config.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>

View file

@ -4,10 +4,6 @@
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <deque>
#include <list>
#include <queue>
#include <utility>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
@ -16,7 +12,11 @@
#include <sys/time.h>
#include <sys/types.h>
#include <wchar.h>
#include <deque>
#include <list>
#include <memory>
#include <type_traits>
#include "common.h"
#include "env.h"

View file

@ -1,7 +1,6 @@
// Library for pooling common strings.
#include "config.h" // IWYU pragma: keep
#include <pthread.h>
#include <stddef.h>
#include <wchar.h>
#include <algorithm>

View file

@ -2,7 +2,6 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <pthread.h>
#include <signal.h>

View file

@ -3,6 +3,7 @@
#define FISH_IOTHREAD_H
#include <functional>
#include <type_traits>
/// Runs a command on a thread.
///

View file

@ -322,6 +322,7 @@ class lru_cache_t {
// Count iterators
size_t iter_dist = 0;
for (const auto &p : *this) {
UNUSED(p);
iter_dist++;
}
if (iter_dist != count) {

View file

@ -5,6 +5,8 @@
#include <stddef.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <map>
#include <numeric>
#include <vector>
@ -43,7 +45,7 @@ static size_t divide_round_up(size_t numer, size_t denom) {
if (numer == 0) return 0;
assert(denom > 0);
bool has_rem = (numer % denom) > 0;
bool has_rem = (numer % denom) != 0;
return numer / denom + (has_rem ? 1 : 0);
}
@ -368,9 +370,7 @@ void pager_t::set_completions(const completion_list_t &raw_completions) {
void pager_t::set_prefix(const wcstring &pref) { prefix = pref; }
void pager_t::set_term_size(int w, int h) {
assert(w > 0);
assert(h > 0);
void pager_t::set_term_size(size_t w, size_t h) {
available_term_width = w;
available_term_height = h;
}
@ -426,7 +426,6 @@ bool pager_t::completion_try_print(size_t cols, const wcstring &prefix, const co
}
bool print;
assert(cols >= 1);
// Force fit if one column.
if (cols == 1) {
width_by_column[0] = std::min(width_by_column[0], term_width);

View file

@ -131,7 +131,7 @@ class pager_t {
void set_prefix(const wcstring &pref);
// Sets the terminal width and height.
void set_term_size(int w, int h);
void set_term_size(size_t w, size_t h);
// Changes the selected completion in the given direction according to the layout of the given
// rendering. Returns true if the selection changed.

View file

@ -21,6 +21,7 @@
#include <algorithm>
#include <memory>
#include <string>
#include <type_traits>
#include <vector>
#include "builtin.h"

View file

@ -6,9 +6,10 @@
#include <stddef.h>
#include <stdio.h>
#include <wchar.h>
#include <algorithm>
#include <cwchar>
#include <string>
#include <type_traits>
#include <vector>
#include "common.h"

View file

@ -9,8 +9,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include <memory>
#include <string>
#include <type_traits>
#include "builtin.h"
#include "common.h"

View file

@ -3,7 +3,11 @@
#define FISH_PARSER_H
#include <stddef.h>
#include <csignal>
#include <list>
#include <memory>
#include <type_traits>
#include <vector>
#include "common.h"

View file

@ -12,6 +12,7 @@
#include <wchar.h>
#include <string>
#include <type_traits>
#include <vector>
#include "common.h"

View file

@ -7,7 +7,6 @@
#include "config.h"
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <sys/wait.h>

View file

@ -11,7 +11,10 @@
#include <sys/time.h> // IWYU pragma: keep
#include <termios.h>
#include <unistd.h>
#include <list>
#include <memory>
#include <vector>
#include "common.h"
#include "io.h"

View file

@ -37,6 +37,8 @@
#include <wctype.h>
#include <algorithm>
#include <csignal>
#include <functional>
#include <memory>
#include <stack>
@ -791,13 +793,13 @@ void reader_init() {
void reader_destroy() { pthread_key_delete(generation_count_key); }
/// Restore the term mode if we own the terminal. It's important we do this before
/// restore_foreground_process_group, otherwise we won't think we own the terminal.
void restore_term_mode() {
// Restore the term mode if we own the terminal. It's important we do this before
// restore_foreground_process_group, otherwise we won't think we own the terminal.
if (getpid() == tcgetpgrp(STDIN_FILENO)) {
if (tcsetattr(STDIN_FILENO, TCSANOW, &terminal_mode_on_startup) == -1 && errno == EIO) {
redirect_tty_output();
}
if (getpid() != tcgetpgrp(STDIN_FILENO)) return;
if (tcsetattr(STDIN_FILENO, TCSANOW, &terminal_mode_on_startup) == -1 && errno == EIO) {
redirect_tty_output();
}
}

View file

@ -12,7 +12,10 @@
#include <assert.h>
#include <stddef.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <algorithm>
#include <map>
#include <memory>
#include <set>
#include <vector>

View file

@ -8,7 +8,9 @@
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
#include <string>
#include <type_traits>
#include "common.h"
#include "fallback.h" // IWYU pragma: keep

View file

@ -17,8 +17,8 @@
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
#include <map>
#include <memory>
#include <string>
#include "common.h"