mirror of
https://github.com/neovim/neovim.git
synced 2025-11-23 10:36:29 +00:00
MAKE: ask gnulikes to warn and be pedantic + fixes
It seems clang 3.4 thinks the codebase is in fantastic shape and gcc 4.9.0
has only minor niggles, which I fixed:
- fix uninitialized member warning:
In DEBUG mode the expr member doesn't get properly initialized to NULL.
- fix warnings about directive inside of macro's:
On some platforms/compilers, sprintf is a macro. Putting macro directives
inside of a macro is unportable and gcc 4.9 warns about that.
- fix signed vs. unsigned comparison warning:
The in-memory table will luckily not even come close to the limits imposed
by ssize_t. If it ever reaches that, we've got bigger problems.
This commit is contained in:
committed by
Thiago de Arruda
parent
6eece5895e
commit
3f29a02166
@@ -12,9 +12,9 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||||||
|
|
||||||
# If the C compiler is some GNU-alike, use the gnu99 standard and enable all warnings.
|
# If the C compiler is some GNU-alike, use the gnu99 standard and enable all warnings.
|
||||||
if(CMAKE_COMPILER_IS_GNUCC)
|
if(CMAKE_COMPILER_IS_GNUCC)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=gnu99")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -std=gnu99")
|
||||||
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=gnu99")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -std=gnu99")
|
||||||
endif(CMAKE_COMPILER_IS_GNUCC)
|
endif(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
|
||||||
add_definitions(-DHAVE_CONFIG_H)
|
add_definitions(-DHAVE_CONFIG_H)
|
||||||
|
|||||||
21
src/fileio.c
21
src/fileio.c
@@ -4209,15 +4209,14 @@ void msg_add_lines(int insert_space, long lnum, off_t nchars)
|
|||||||
|
|
||||||
if (insert_space)
|
if (insert_space)
|
||||||
*p++ = ' ';
|
*p++ = ' ';
|
||||||
if (shortmess(SHM_LINES))
|
if (shortmess(SHM_LINES)) {
|
||||||
sprintf((char *)p,
|
|
||||||
#ifdef LONG_LONG_OFF_T
|
#ifdef LONG_LONG_OFF_T
|
||||||
"%ldL, %lldC", lnum, nchars
|
sprintf((char *)p, "%ldL, %lldC", lnum, nchars);
|
||||||
#else
|
#else
|
||||||
/* Explicit typecast avoids warning on Mac OS X 10.6 */
|
/* Explicit typecast avoids warning on Mac OS X 10.6 */
|
||||||
"%ldL, %ldC", lnum, (long)nchars
|
sprintf((char *)p, "%ldL, %ldC", lnum, (long)nchars);
|
||||||
#endif
|
#endif
|
||||||
);
|
}
|
||||||
else {
|
else {
|
||||||
if (lnum == 1)
|
if (lnum == 1)
|
||||||
STRCPY(p, _("1 line, "));
|
STRCPY(p, _("1 line, "));
|
||||||
@@ -4226,15 +4225,13 @@ void msg_add_lines(int insert_space, long lnum, off_t nchars)
|
|||||||
p += STRLEN(p);
|
p += STRLEN(p);
|
||||||
if (nchars == 1)
|
if (nchars == 1)
|
||||||
STRCPY(p, _("1 character"));
|
STRCPY(p, _("1 character"));
|
||||||
else
|
else {
|
||||||
sprintf((char *)p,
|
|
||||||
#ifdef LONG_LONG_OFF_T
|
#ifdef LONG_LONG_OFF_T
|
||||||
_("%lld characters"), nchars
|
sprintf((char *)p, _("%lld characters"), nchars);
|
||||||
#else
|
#else
|
||||||
/* Explicit typecast avoids warning on Mac OS X 10.6 */
|
sprintf((char *)p, _("%ld characters"), (long)nchars);
|
||||||
_("%ld characters"), (long)nchars
|
|
||||||
#endif
|
#endif
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1407,9 +1407,9 @@ static void convert_ks_to_3(const char_u *src, int *fp, int *mp, int *lp)
|
|||||||
int low = *(src + 1);
|
int low = *(src + 1);
|
||||||
int c;
|
int c;
|
||||||
int i;
|
int i;
|
||||||
|
const ssize_t tablesize = sizeof(ks_table1) / sizeof(ks_table1[0]);
|
||||||
|
|
||||||
if ((i = han_index(h, low)) >= 0
|
if ((i = han_index(h, low)) >= 0 && i < tablesize) {
|
||||||
&& i < sizeof(ks_table1)/sizeof(ks_table1[0])) {
|
|
||||||
*fp = ks_table1[i][0];
|
*fp = ks_table1[i][0];
|
||||||
*mp = ks_table1[i][1];
|
*mp = ks_table1[i][1];
|
||||||
*lp = ks_table1[i][2];
|
*lp = ks_table1[i][2];
|
||||||
|
|||||||
@@ -6932,6 +6932,9 @@ static regengine_T bt_regengine =
|
|||||||
#ifdef REGEXP_DEBUG
|
#ifdef REGEXP_DEBUG
|
||||||
,(char_u *)""
|
,(char_u *)""
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef DEBUG
|
||||||
|
,NULL
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -6950,6 +6953,9 @@ static regengine_T nfa_regengine =
|
|||||||
#ifdef REGEXP_DEBUG
|
#ifdef REGEXP_DEBUG
|
||||||
,(char_u *)""
|
,(char_u *)""
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef DEBUG
|
||||||
|
, NULL
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Which regexp engine to use? Needed for vim_regcomp().
|
/* Which regexp engine to use? Needed for vim_regcomp().
|
||||||
|
|||||||
@@ -2225,12 +2225,14 @@ static void term_color(char_u *s, int n)
|
|||||||
&& (STRCMP(s + i + 1, "%p1%dm") == 0
|
&& (STRCMP(s + i + 1, "%p1%dm") == 0
|
||||||
|| STRCMP(s + i + 1, "%dm") == 0)
|
|| STRCMP(s + i + 1, "%dm") == 0)
|
||||||
&& (s[i] == '3' || s[i] == '4')) {
|
&& (s[i] == '3' || s[i] == '4')) {
|
||||||
sprintf(buf,
|
const char *fmt =
|
||||||
#ifdef TERMINFO
|
#ifdef TERMINFO
|
||||||
"%s%s%%p1%%dm",
|
"%s%s%%p1%%dm";
|
||||||
#else
|
#else
|
||||||
"%s%s%%dm",
|
"%s%s%%dm";
|
||||||
#endif
|
#endif
|
||||||
|
sprintf(buf,
|
||||||
|
fmt,
|
||||||
i == 2 ? IF_EB("\033[", ESC_STR "[") : "\233",
|
i == 2 ? IF_EB("\033[", ESC_STR "[") : "\233",
|
||||||
s[i] == '3' ? (n >= 16 ? "38;5;" : "9")
|
s[i] == '3' ? (n >= 16 ? "38;5;" : "9")
|
||||||
: (n >= 16 ? "48;5;" : "10"));
|
: (n >= 16 ? "48;5;" : "10"));
|
||||||
|
|||||||
Reference in New Issue
Block a user