fix some lint warnings

This fixes some of the IWYU and cppcheck lint warnings. And only on
macOS (formerly OS X). Fixing these types of warnings on a broader set
of platforms should be done but this is a baby step to making `make
lint-all` have few, if any, warnings. This reduces the number of lines
in the `make lint-all` output on macOS by over 500 lines.
This commit is contained in:
Kurtis Rader 2016-11-14 21:31:51 -08:00
parent 708f80d855
commit 521546a986
20 changed files with 21 additions and 19 deletions

View file

@ -3,3 +3,8 @@
// because all the places we do this are valid and won't cause problems even
// on a ILP64 platform because we're careful about using NULL rather than 0.
varFuncNullUB
// Suppress the warning about unmatched suppressions. At the moment these
// warnings are emitted even when removing the suppression comment results in
// the warning being suppressed. In other words this unmatchedSuppression
// warnings are false positives.
unmatchedSuppression

View file

@ -114,7 +114,9 @@ if set -q c_files[1]
echo
echo ========================================
echo "Running `cppcheck --check-config` to identify missing includes similar problems"
echo 'Running `cppcheck --check-config` to identify missing includes similar problems.'
echo 'Ignore unmatchedSuppression warnings as they are probably false positives we'
echo 'cannot suppress.'
echo ========================================
cppcheck $cppcheck_args --check-config $c_files 2>&1
end

View file

@ -1,7 +1,6 @@
// 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>

View file

@ -28,7 +28,6 @@
#include <time.h>
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <map>
#include <memory>

View file

@ -54,7 +54,7 @@
#include <limits.h>
#include <locale.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <wchar.h>

View file

@ -3,7 +3,9 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>

View file

@ -720,8 +720,8 @@ bool regex_replacer_t::replace_matches(const wchar_t *arg) {
done = true;
} else {
bufsize = outlen;
// cppcheck-suppress memleakOnRealloc
output = (wchar_t *)realloc(output, sizeof(wchar_t) * bufsize);
wchar_t *new_output = (wchar_t *)realloc(output, sizeof(wchar_t) * bufsize);
if (new_output) output = new_output;
}
}

View file

@ -8,9 +8,7 @@
#include <pwd.h>
#include <stddef.h>
#include <stdlib.h>
#ifdef HAVE__NL_MSG_CAT_CNTR
#include <string.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>

View file

@ -17,7 +17,6 @@
#include <sys/types.h>
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
#include <string>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>

View file

@ -9,7 +9,6 @@
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wchar.h>

View file

@ -17,7 +17,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
@ -47,13 +46,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "function.h"
#include "history.h"
#include "input.h"
#include "input_common.h"
#include "io.h"
#include "parser.h"
#include "path.h"
#include "proc.h"
#include "reader.h"
#include "wildcard.h"
#include "wutil.h" // IWYU pragma: keep
// PATH_MAX may not exist.

View file

@ -1450,7 +1450,11 @@ static bool format_history_record(const history_item_t &item, const wchar_t *sho
streams.out.append(timestamp_string);
}
streams.out.append(item.str());
streams.out.append(null_terminate ? L'\0' : L'\n');
if (null_terminate) {
streams.out.append(L'\0');
} else {
streams.out.append(L'\n');
}
return true;
}

View file

@ -7,6 +7,7 @@
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include <wctype.h>
#include <deque>
#include <memory>
#include <set>

View file

@ -3,7 +3,6 @@
// IWYU pragma: no_include <cstddef>
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>
#include <map>

View file

@ -3,7 +3,6 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include <algorithm>
#include <memory>

View file

@ -31,7 +31,6 @@
#include <vector>
#include "common.h"
#include "env.h"
#include "fallback.h" // IWYU pragma: keep
#include "highlight.h"
#include "output.h"

View file

@ -14,7 +14,6 @@
#include "fallback.h" // IWYU pragma: keep
#include "proc.h"
#include "reader.h"
#include "signal.h"
#include "wutil.h" // IWYU pragma: keep
/// Struct describing an entry for the lookup table used to convert between signal names and signal

View file

@ -5,7 +5,6 @@
#include <assert.h>
#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>

View file

@ -16,6 +16,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
#include <map>
#include <memory>
#include <string>

View file

@ -3,6 +3,7 @@
#define FISH_WUTIL_H
#include <dirent.h>
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <time.h>