aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliseo Martínez <eliseomarmol@gmail.com>2015-02-12 16:11:04 +0100
committerJustin M. Keyes <justinkz@gmail.com>2015-02-18 20:54:13 -0500
commit94db26edbdce5a2c147329fc8e8da580216d2a1c (patch)
treee3e2065023698e2dc73bd1cb4ec07e92eeacd89c
parent7dd48d7af08613255bc95b63f5b6b0f096a98d22 (diff)
downloadrneovim-94db26edbdce5a2c147329fc8e8da580216d2a1c.tar.gz
rneovim-94db26edbdce5a2c147329fc8e8da580216d2a1c.tar.bz2
rneovim-94db26edbdce5a2c147329fc8e8da580216d2a1c.zip
Enable -Wconversion: indent.c.
Note: Clint was failing because of recommending not to use long. But converting to long is the proper refactoring here, in as far as other longs exist. We could, then, disable clint rule, or remove this file from checking. We choose the former, as it's being discussed what to do with longs, but a decision has not been taken. So, it seems most reasonable to allow longs for now, to enable proper refactorings, and then, when a decision is taken, refactor all longs to some other thing.
-rwxr-xr-xclint.py2
-rw-r--r--src/nvim/CMakeLists.txt1
-rw-r--r--src/nvim/indent.c12
3 files changed, 9 insertions, 6 deletions
diff --git a/clint.py b/clint.py
index 5e0e5a1e2b..290abd2820 100755
--- a/clint.py
+++ b/clint.py
@@ -2776,7 +2776,7 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension,
# TODO(unknown): figure out if they're using default arguments in fn proto.
# Check if people are using the verboten C basic types.
- match = Search(r'\b(short|long(?! +double)|long long)\b', line)
+ match = Search(r'\b(short|long long)\b', line)
if match:
error(filename, linenum, 'runtime/int', 4,
'Use int16_t/int64_t/etc, rather than the C type %s'
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 795997c052..127dd7cfb7 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -63,7 +63,6 @@ set(CONV_SOURCES
fold.c
getchar.c
if_cscope.c
- indent.c
keymap.c
mbyte.c
memline.c
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index 075acc6c13..5711207933 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -1,3 +1,4 @@
+#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
@@ -198,7 +199,8 @@ int set_indent(int size, int flags)
// characters and allocate accordingly. We will fill the rest with spaces
// after the if (!curbuf->b_p_et) below.
if (orig_char_len != -1) {
- newline = xmalloc(orig_char_len + size - ind_done + line_len);
+ assert(orig_char_len + size - ind_done + line_len >= 0);
+ newline = xmalloc((size_t)(orig_char_len + size - ind_done + line_len));
todo = size - ind_done;
// Set total length of indent in characters, which may have been
@@ -219,7 +221,8 @@ int set_indent(int size, int flags)
}
} else {
todo = size;
- newline = xmalloc(ind_len + line_len);
+ assert(ind_len + line_len >= 0);
+ newline = xmalloc((size_t)(ind_len + line_len));
s = newline;
}
@@ -384,7 +387,8 @@ int copy_indent(int size, char_u *src)
// Allocate memory for the result: the copied indent, new indent
// and the rest of the line.
line_len = (int)STRLEN(get_cursor_line_ptr()) + 1;
- line = xmalloc(ind_len + line_len);
+ assert(ind_len + line_len >= 0);
+ line = xmalloc((size_t)(ind_len + line_len));
p = line;
}
}
@@ -449,7 +453,7 @@ int get_number_indent(linenr_T lnum)
*/
int get_breakindent_win(win_T *wp, char_u *line) {
static int prev_indent = 0; /* cached indent value */
- static int prev_ts = 0L; /* cached tabstop value */
+ static long prev_ts = 0; /* cached tabstop value */
static char_u *prev_line = NULL; /* cached pointer to line */
static int prev_tick = 0; // changedtick of cached value
int bri = 0;