aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Hillegeer <nicolas@hillegeer.com>2014-02-27 18:57:17 +0100
committerThiago de Arruda <tpadilha84@gmail.com>2014-02-28 11:48:43 -0300
commit3f29a02166878bdbf32b0d638aa0e0c9d83a73cc (patch)
treea1f932447c6a657fff86b1a9823f37db282f2801
parent6eece5895e4f0c147ef21ebb4d170a54f8694182 (diff)
downloadrneovim-3f29a02166878bdbf32b0d638aa0e0c9d83a73cc.tar.gz
rneovim-3f29a02166878bdbf32b0d638aa0e0c9d83a73cc.tar.bz2
rneovim-3f29a02166878bdbf32b0d638aa0e0c9d83a73cc.zip
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.
-rw-r--r--CMakeLists.txt4
-rw-r--r--src/fileio.c21
-rw-r--r--src/hangulin.c4
-rw-r--r--src/regexp.c6
-rw-r--r--src/term.c8
5 files changed, 24 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index da001b7b57..363c03bdc4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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(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")
- 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)
add_definitions(-DHAVE_CONFIG_H)
diff --git a/src/fileio.c b/src/fileio.c
index 4e0f68af7e..3efddfe66d 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4209,15 +4209,14 @@ void msg_add_lines(int insert_space, long lnum, off_t nchars)
if (insert_space)
*p++ = ' ';
- if (shortmess(SHM_LINES))
- sprintf((char *)p,
+ if (shortmess(SHM_LINES)) {
#ifdef LONG_LONG_OFF_T
- "%ldL, %lldC", lnum, nchars
+ sprintf((char *)p, "%ldL, %lldC", lnum, nchars);
#else
- /* Explicit typecast avoids warning on Mac OS X 10.6 */
- "%ldL, %ldC", lnum, (long)nchars
+ /* Explicit typecast avoids warning on Mac OS X 10.6 */
+ sprintf((char *)p, "%ldL, %ldC", lnum, (long)nchars);
#endif
- );
+ }
else {
if (lnum == 1)
STRCPY(p, _("1 line, "));
@@ -4226,15 +4225,13 @@ void msg_add_lines(int insert_space, long lnum, off_t nchars)
p += STRLEN(p);
if (nchars == 1)
STRCPY(p, _("1 character"));
- else
- sprintf((char *)p,
+ else {
#ifdef LONG_LONG_OFF_T
- _("%lld characters"), nchars
+ sprintf((char *)p, _("%lld characters"), nchars);
#else
- /* Explicit typecast avoids warning on Mac OS X 10.6 */
- _("%ld characters"), (long)nchars
+ sprintf((char *)p, _("%ld characters"), (long)nchars);
#endif
- );
+ }
}
}
diff --git a/src/hangulin.c b/src/hangulin.c
index 185bf0a5bd..f7619ef0b3 100644
--- a/src/hangulin.c
+++ b/src/hangulin.c
@@ -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 c;
int i;
+ const ssize_t tablesize = sizeof(ks_table1) / sizeof(ks_table1[0]);
- if ((i = han_index(h, low)) >= 0
- && i < sizeof(ks_table1)/sizeof(ks_table1[0])) {
+ if ((i = han_index(h, low)) >= 0 && i < tablesize) {
*fp = ks_table1[i][0];
*mp = ks_table1[i][1];
*lp = ks_table1[i][2];
diff --git a/src/regexp.c b/src/regexp.c
index 54fe5940a7..7bcc69593c 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -6932,6 +6932,9 @@ static regengine_T bt_regengine =
#ifdef REGEXP_DEBUG
,(char_u *)""
#endif
+#ifdef DEBUG
+ ,NULL
+#endif
};
@@ -6950,6 +6953,9 @@ static regengine_T nfa_regengine =
#ifdef REGEXP_DEBUG
,(char_u *)""
#endif
+#ifdef DEBUG
+ , NULL
+#endif
};
/* Which regexp engine to use? Needed for vim_regcomp().
diff --git a/src/term.c b/src/term.c
index 5ce3e3ee96..fad1401c0e 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2225,12 +2225,14 @@ static void term_color(char_u *s, int n)
&& (STRCMP(s + i + 1, "%p1%dm") == 0
|| STRCMP(s + i + 1, "%dm") == 0)
&& (s[i] == '3' || s[i] == '4')) {
- sprintf(buf,
+ const char *fmt =
#ifdef TERMINFO
- "%s%s%%p1%%dm",
+ "%s%s%%p1%%dm";
#else
- "%s%s%%dm",
+ "%s%s%%dm";
#endif
+ sprintf(buf,
+ fmt,
i == 2 ? IF_EB("\033[", ESC_STR "[") : "\233",
s[i] == '3' ? (n >= 16 ? "38;5;" : "9")
: (n >= 16 ? "48;5;" : "10"));