aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.ci/clint.sh2
-rw-r--r--Makefile8
-rw-r--r--clint-files.txt59
-rw-r--r--clint-ignored-files.txt135
-rw-r--r--cmake/RunLint.cmake21
-rw-r--r--src/nvim/os/fs.c3
-rw-r--r--src/nvim/os/fs_defs.h2
-rw-r--r--src/nvim/os/os_defs.h2
-rw-r--r--src/nvim/os/unix_defs.h6
-rw-r--r--src/nvim/os/users.c4
-rw-r--r--src/nvim/os/win_defs.h6
-rw-r--r--src/nvim/os_unix_defs.h6
12 files changed, 179 insertions, 75 deletions
diff --git a/.ci/clint.sh b/.ci/clint.sh
index 5fe10211c4..53769a2552 100755
--- a/.ci/clint.sh
+++ b/.ci/clint.sh
@@ -1,3 +1,3 @@
#!/bin/sh
-./clint.py $(cat clint-files.txt)
+make lint
diff --git a/Makefile b/Makefile
index 7a37e9ba4b..9390463762 100644
--- a/Makefile
+++ b/Makefile
@@ -98,4 +98,10 @@ distclean: clean
install: | nvim
+$(BUILD_CMD) -C build install
-.PHONY: test functionaltest unittest clean distclean nvim libnvim cmake deps install
+lint:
+ cmake -DLINT_PRG=./clint.py \
+ -DLINT_DIR=src \
+ -DLINT_IGNORE_FILE=clint-ignored-files.txt \
+ -P cmake/RunLint.cmake
+
+.PHONY: test functionaltest unittest lint clean distclean nvim libnvim cmake deps install
diff --git a/clint-files.txt b/clint-files.txt
deleted file mode 100644
index 6f4a293205..0000000000
--- a/clint-files.txt
+++ /dev/null
@@ -1,59 +0,0 @@
-src/nvim/api/buffer.c
-src/nvim/api/buffer.h
-src/nvim/api/private/defs.h
-src/nvim/api/private/handle.c
-src/nvim/api/private/handle.h
-src/nvim/api/private/helpers.c
-src/nvim/api/private/helpers.h
-src/nvim/api/tabpage.c
-src/nvim/api/tabpage.h
-src/nvim/api/vim.c
-src/nvim/api/vim.h
-src/nvim/api/window.c
-src/nvim/api/window.h
-src/nvim/cursor.c
-src/nvim/cursor.h
-src/nvim/hashtab.c
-src/nvim/hashtab.h
-src/nvim/indent.c
-src/nvim/indent.h
-src/nvim/log.c
-src/nvim/log.h
-src/nvim/map.c
-src/nvim/map.h
-src/nvim/map_defs.h
-src/nvim/memfile.c
-src/nvim/memfile.h
-src/nvim/memfile_defs.h
-src/nvim/mouse.c
-src/nvim/mouse.h
-src/nvim/msgpack_rpc/channel.c
-src/nvim/msgpack_rpc/channel.h
-src/nvim/msgpack_rpc/helpers.c
-src/nvim/msgpack_rpc/helpers.h
-src/nvim/msgpack_rpc/server.c
-src/nvim/msgpack_rpc/server.h
-src/nvim/os/env.c
-src/nvim/os/event.c
-src/nvim/os/event.h
-src/nvim/os/event_defs.h
-src/nvim/os/input.c
-src/nvim/os/input.h
-src/nvim/os/job.c
-src/nvim/os/job.h
-src/nvim/os/job_defs.h
-src/nvim/os/mem.c
-src/nvim/os/os.h
-src/nvim/os/rstream.c
-src/nvim/os/rstream.h
-src/nvim/os/rstream_defs.h
-src/nvim/os/shell.c
-src/nvim/os/shell.h
-src/nvim/os/signal.c
-src/nvim/os/signal.h
-src/nvim/os/time.c
-src/nvim/os/time.h
-src/nvim/profile.c
-src/nvim/profile.h
-src/nvim/tempfile.c
-src/nvim/tempfile.h
diff --git a/clint-ignored-files.txt b/clint-ignored-files.txt
new file mode 100644
index 0000000000..078337b777
--- /dev/null
+++ b/clint-ignored-files.txt
@@ -0,0 +1,135 @@
+src/nvim/arabic.c
+src/nvim/arabic.h
+src/nvim/ascii.h
+src/nvim/assert.h
+src/nvim/buffer.c
+src/nvim/buffer.h
+src/nvim/buffer_defs.h
+src/nvim/charset.c
+src/nvim/charset.h
+src/nvim/cursor_shape.c
+src/nvim/cursor_shape.h
+src/nvim/diff.c
+src/nvim/diff.h
+src/nvim/digraph.c
+src/nvim/digraph.h
+src/nvim/edit.c
+src/nvim/edit.h
+src/nvim/eval.c
+src/nvim/eval.h
+src/nvim/eval_defs.h
+src/nvim/ex_cmds.c
+src/nvim/ex_cmds.h
+src/nvim/ex_cmds.lua
+src/nvim/ex_cmds2.c
+src/nvim/ex_cmds2.h
+src/nvim/ex_cmds_defs.h
+src/nvim/ex_docmd.c
+src/nvim/ex_docmd.h
+src/nvim/ex_eval.c
+src/nvim/ex_eval.h
+src/nvim/ex_getln.c
+src/nvim/ex_getln.h
+src/nvim/farsi.c
+src/nvim/farsi.h
+src/nvim/file_search.c
+src/nvim/file_search.h
+src/nvim/fileio.c
+src/nvim/fileio.h
+src/nvim/fold.c
+src/nvim/fold.h
+src/nvim/func_attr.h
+src/nvim/garray.c
+src/nvim/garray.h
+src/nvim/getchar.c
+src/nvim/getchar.h
+src/nvim/globals.h
+src/nvim/hardcopy.c
+src/nvim/hardcopy.h
+src/nvim/iconv.h
+src/nvim/if_cscope.c
+src/nvim/if_cscope.h
+src/nvim/if_cscope_defs.h
+src/nvim/indent_c.c
+src/nvim/indent_c.h
+src/nvim/keymap.c
+src/nvim/keymap.h
+src/nvim/lib/khash.h
+src/nvim/lib/klist.h
+src/nvim/lib/kvec.h
+src/nvim/macros.h
+src/nvim/main.c
+src/nvim/main.h
+src/nvim/mark.c
+src/nvim/mark.h
+src/nvim/mark_defs.h
+src/nvim/mbyte.c
+src/nvim/mbyte.h
+src/nvim/memline.c
+src/nvim/memline.h
+src/nvim/memline_defs.h
+src/nvim/memory.c
+src/nvim/memory.h
+src/nvim/menu.c
+src/nvim/menu.h
+src/nvim/message.c
+src/nvim/message.h
+src/nvim/misc1.c
+src/nvim/misc1.h
+src/nvim/misc2.c
+src/nvim/misc2.h
+src/nvim/move.c
+src/nvim/move.h
+src/nvim/normal.c
+src/nvim/normal.h
+src/nvim/ops.c
+src/nvim/ops.h
+src/nvim/option.c
+src/nvim/option.h
+src/nvim/option_defs.h
+src/nvim/os_unix.c
+src/nvim/os_unix.h
+src/nvim/os_unix_defs.h
+src/nvim/path.c
+src/nvim/path.h
+src/nvim/po/sjiscorr.c
+src/nvim/popupmnu.c
+src/nvim/popupmnu.h
+src/nvim/pos.h
+src/nvim/quickfix.c
+src/nvim/quickfix.h
+src/nvim/regexp.c
+src/nvim/regexp.h
+src/nvim/regexp_defs.h
+src/nvim/regexp_nfa.c
+src/nvim/screen.c
+src/nvim/screen.h
+src/nvim/search.c
+src/nvim/search.h
+src/nvim/sha256.c
+src/nvim/sha256.h
+src/nvim/sign_defs.h
+src/nvim/spell.c
+src/nvim/spell.h
+src/nvim/strings.c
+src/nvim/strings.h
+src/nvim/syntax.c
+src/nvim/syntax.h
+src/nvim/syntax_defs.h
+src/nvim/tag.c
+src/nvim/tag.h
+src/nvim/term.c
+src/nvim/term.h
+src/nvim/term_defs.h
+src/nvim/types.h
+src/nvim/ui.c
+src/nvim/ui.h
+src/nvim/undo.c
+src/nvim/undo.h
+src/nvim/undo_defs.h
+src/nvim/version.c
+src/nvim/version.h
+src/nvim/version_defs.h
+src/nvim/vim.h
+src/nvim/window.c
+src/nvim/window.h
diff --git a/cmake/RunLint.cmake b/cmake/RunLint.cmake
new file mode 100644
index 0000000000..35d3f942aa
--- /dev/null
+++ b/cmake/RunLint.cmake
@@ -0,0 +1,21 @@
+get_filename_component(LINT_DIR ${LINT_DIR} ABSOLUTE)
+get_filename_component(LINT_PREFIX ${LINT_DIR} PATH)
+file(GLOB_RECURSE LINT_FILES ${LINT_DIR}/*.c ${LINT_DIR}/*.h)
+
+if(LINT_IGNORE_FILE)
+ file(READ ${LINT_IGNORE_FILE} LINT_IGNORED_FILES)
+ string(REPLACE "\n" ";" LINT_IGNORED_FILES ${LINT_IGNORED_FILES})
+ message(STATUS "Ignoring the following files for linting:")
+ foreach(ignore_file ${LINT_IGNORED_FILES})
+ message(STATUS "${ignore_file}")
+ list(REMOVE_ITEM LINT_FILES "${LINT_PREFIX}/${ignore_file}")
+ endforeach()
+endif()
+
+execute_process(
+ COMMAND ${LINT_PRG} ${LINT_FILES}
+ RESULT_VARIABLE res)
+
+if(NOT res EQUAL 0)
+ message(FATAL_ERROR "Linting failed: ${res}.")
+endif()
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index bdaf9ecdda..242f8fb461 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -4,6 +4,7 @@
#include <assert.h>
#include "nvim/os/os.h"
+#include "nvim/os/os_defs.h"
#include "nvim/ascii.h"
#include "nvim/memory.h"
#include "nvim/message.h"
@@ -331,7 +332,7 @@ int os_mkdtemp(const char *template, char *path)
uv_fs_t request;
int result = uv_fs_mkdtemp(uv_default_loop(), &request, template, NULL);
if (result == kLibuvSuccess) {
- strcpy(path, request.path);
+ STRNCPY(path, request.path, TEMP_FILE_PATH_MAXLEN);
}
uv_fs_req_cleanup(&request);
return result;
diff --git a/src/nvim/os/fs_defs.h b/src/nvim/os/fs_defs.h
index ab4c05b965..e4d79aab66 100644
--- a/src/nvim/os/fs_defs.h
+++ b/src/nvim/os/fs_defs.h
@@ -14,6 +14,6 @@ typedef struct {
uint64_t device_id; ///< @private The id of the device containing the file
} FileID;
-#define FILE_ID_EMPTY (FileID){.inode = 0, .device_id = 0}
+#define FILE_ID_EMPTY (FileID) {.inode = 0, .device_id = 0}
#endif // NVIM_OS_FS_DEFS_H
diff --git a/src/nvim/os/os_defs.h b/src/nvim/os/os_defs.h
index aa6c5bccc3..ec94324df4 100644
--- a/src/nvim/os/os_defs.h
+++ b/src/nvim/os/os_defs.h
@@ -7,4 +7,4 @@
# include "nvim/os/unix_defs.h"
#endif
-#endif // NVIM_OS_DEFS_H
+#endif // NVIM_OS_OS_DEFS_H
diff --git a/src/nvim/os/unix_defs.h b/src/nvim/os/unix_defs.h
index 197a87bcc5..e518ac67e5 100644
--- a/src/nvim/os/unix_defs.h
+++ b/src/nvim/os/unix_defs.h
@@ -1,7 +1,7 @@
-#ifndef NEOVIM_OS_UNIX_DEFS_H
-#define NEOVIM_OS_UNIX_DEFS_H
+#ifndef NVIM_OS_UNIX_DEFS_H
+#define NVIM_OS_UNIX_DEFS_H
#define TEMP_DIR_NAMES {"$TMPDIR", "/tmp", ".", "$HOME"}
#define TEMP_FILE_PATH_MAXLEN 256
-#endif // NEOVIM_OS_UNIX_DEFS_H
+#endif // NVIM_OS_UNIX_DEFS_H
diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c
index 99479b0bae..a57ba41af1 100644
--- a/src/nvim/os/users.c
+++ b/src/nvim/os/users.c
@@ -52,7 +52,7 @@ int os_get_uname(uid_t uid, char *s, size_t len)
#if defined(HAVE_PWD_H) && defined(HAVE_GETPWUID)
struct passwd *pw;
- if ((pw = getpwuid(uid)) != NULL
+ if ((pw = getpwuid(uid)) != NULL // NOLINT(runtime/threadsafe_fn)
&& pw->pw_name != NULL && *(pw->pw_name) != NUL) {
STRLCPY(s, pw->pw_name, len);
return OK;
@@ -72,7 +72,7 @@ char *os_get_user_directory(const char *name)
if (name == NULL) {
return NULL;
}
- pw = getpwnam(name);
+ pw = getpwnam(name); // NOLINT(runtime/threadsafe_fn)
if (pw != NULL) {
// save the string from the static passwd entry into malloced memory
return xstrdup(pw->pw_dir);
diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h
index 49fcb64777..bea147ad2d 100644
--- a/src/nvim/os/win_defs.h
+++ b/src/nvim/os/win_defs.h
@@ -1,9 +1,9 @@
-#ifndef NEOVIM_OS_WIN_DEFS_H
-#define NEOVIM_OS_WIN_DEFS_H
+#ifndef NVIM_OS_WIN_DEFS_H
+#define NVIM_OS_WIN_DEFS_H
#include <windows.h>
#define TEMP_DIR_NAMES {"$TMP", "$TEMP", "$USERPROFILE", ""}
#define TEMP_FILE_PATH_MAXLEN _MAX_PATH
-#endif // NEOVIM_OS_WIN_DEFS_H
+#endif // NVIM_OS_WIN_DEFS_H
diff --git a/src/nvim/os_unix_defs.h b/src/nvim/os_unix_defs.h
index ebea86ebcf..adea2ad22f 100644
--- a/src/nvim/os_unix_defs.h
+++ b/src/nvim/os_unix_defs.h
@@ -1,5 +1,5 @@
-#ifndef NVIM_OS_UNIX_DEFS_H
-#define NVIM_OS_UNIX_DEFS_H
+#ifndef NVIM_OS_UNIX_DEFS_LEGACY_H
+#define NVIM_OS_UNIX_DEFS_LEGACY_H
/*
* VIM - Vi IMproved by Bram Moolenaar
@@ -253,4 +253,4 @@
/* We have three kinds of ACL support. */
#define HAVE_ACL (HAVE_POSIX_ACL || HAVE_SOLARIS_ACL || HAVE_AIX_ACL)
-#endif // NVIM_OS_UNIX_DEFS_H
+#endif // NVIM_OS_UNIX_DEFS_LEGACY_H