aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-02-10 11:11:30 +0800
committerGitHub <noreply@github.com>2024-02-10 11:11:30 +0800
commitdcb11c1091416db04101dab3566563c74b47452b (patch)
treea166dcaccb7ce22864dcf3f151441e7cf85d8fbe
parent8e739af064dec28886694aa448f60a570acd2173 (diff)
downloadrneovim-dcb11c1091416db04101dab3566563c74b47452b.tar.gz
rneovim-dcb11c1091416db04101dab3566563c74b47452b.tar.bz2
rneovim-dcb11c1091416db04101dab3566563c74b47452b.zip
build(clint): don't allow INIT() in non-header files (#27407)
-rwxr-xr-xsrc/clint.py7
-rw-r--r--src/nvim/sign.c4
2 files changed, 9 insertions, 2 deletions
diff --git a/src/clint.py b/src/clint.py
index 78eabb698f..062901b43a 100755
--- a/src/clint.py
+++ b/src/clint.py
@@ -152,8 +152,10 @@ _ERROR_CATEGORIES = [
'build/endif_comment',
'build/header_guard',
'build/include_defs',
+ 'build/defs_header',
'build/printf_format',
'build/storage_class',
+ 'build/init_macro',
'readability/bool',
'readability/multiline_comment',
'readability/multiline_string',
@@ -2086,6 +2088,11 @@ def CheckLanguage(filename, clean_lines, linenum, error):
" named ('k' followed by CamelCase) compile-time constant for"
" the size.")
+ # INIT() macro should only be used in header files.
+ if not filename.endswith('.h') and Search(r' INIT\(', line):
+ error(filename, linenum, 'build/init_macro', 4,
+ 'INIT() macro should only be used in header files.')
+
# Detect TRUE and FALSE.
match = Search(r'\b(TRUE|FALSE)\b', line)
if match:
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index dc09bcc5a0..1cf91f273a 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -55,8 +55,8 @@
# include "sign.c.generated.h"
#endif
-static PMap(cstr_t) sign_map INIT( = MAP_INIT);
-static kvec_t(Integer) sign_ns INIT( = MAP_INIT);
+static PMap(cstr_t) sign_map = MAP_INIT;
+static kvec_t(Integer) sign_ns = KV_INITIAL_VALUE;
static char *cmds[] = {
"define",