Enable -Wconversion: move.c.

This commit is contained in:
Eliseo Martínez 2015-03-23 20:16:18 +01:00
parent fa2fcf13aa
commit 402c6fd939
2 changed files with 30 additions and 23 deletions

View File

@ -66,7 +66,6 @@ set(CONV_SOURCES
menu.c menu.c
message.c message.c
misc1.c misc1.c
move.c
normal.c normal.c
ops.c ops.c
path.c path.c

View File

@ -16,6 +16,7 @@
* The 'scrolloff' option makes this a bit complicated. * The 'scrolloff' option makes this a bit complicated.
*/ */
#include <assert.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdbool.h> #include <stdbool.h>
@ -135,13 +136,13 @@ void update_topline(void)
{ {
long line_count; long line_count;
int halfheight; int halfheight;
int n; long n;
linenr_T old_topline; linenr_T old_topline;
int old_topfill; int old_topfill;
linenr_T lnum; linenr_T lnum;
int check_topline = FALSE; int check_topline = FALSE;
int check_botline = FALSE; int check_botline = FALSE;
int save_so = p_so; long save_so = p_so;
if (!screen_valid(TRUE)) if (!screen_valid(TRUE))
return; return;
@ -342,9 +343,9 @@ void update_topline_win(win_T* win)
*/ */
static int scrolljump_value(void) static int scrolljump_value(void)
{ {
if (p_sj >= 0) long result = p_sj >= 0 ? p_sj : (curwin->w_height * -p_sj) / 100;
return (int)p_sj; assert(result <= INT_MAX);
return (curwin->w_height * -p_sj) / 100; return (int)result;
} }
/* /*
@ -711,7 +712,7 @@ int win_col_off(win_T *wp)
{ {
return ((wp->w_p_nu || wp->w_p_rnu) ? number_width(wp) + 1 : 0) return ((wp->w_p_nu || wp->w_p_rnu) ? number_width(wp) + 1 : 0)
+ (cmdwin_type == 0 || wp != curwin ? 0 : 1) + (cmdwin_type == 0 || wp != curwin ? 0 : 1)
+ wp->w_p_fdc + (int)wp->w_p_fdc
+ (wp->w_buffer->b_signlist != NULL ? 2 : 0) + (wp->w_buffer->b_signlist != NULL ? 2 : 0)
; ;
} }
@ -831,9 +832,9 @@ curs_columns (
* If we get closer to the edge than 'sidescrolloff', scroll a little * If we get closer to the edge than 'sidescrolloff', scroll a little
* extra * extra
*/ */
off_left = (int)startcol - (int)curwin->w_leftcol - p_siso; assert(p_siso <= INT_MAX);
off_right = (int)endcol - (int)(curwin->w_leftcol + curwin->w_width off_left = startcol - curwin->w_leftcol - (int)p_siso;
- p_siso) + 1; off_right = endcol - curwin->w_leftcol - curwin->w_width + (int)p_siso + 1;
if (off_left < 0 || off_right > 0) { if (off_left < 0 || off_right > 0) {
if (off_left < 0) if (off_left < 0)
diff = -off_left; diff = -off_left;
@ -845,8 +846,10 @@ curs_columns (
if (p_ss == 0 || diff >= textwidth / 2 || off_right >= off_left) if (p_ss == 0 || diff >= textwidth / 2 || off_right >= off_left)
new_leftcol = curwin->w_wcol - extra - textwidth / 2; new_leftcol = curwin->w_wcol - extra - textwidth / 2;
else { else {
if (diff < p_ss) if (diff < p_ss) {
diff = p_ss; assert(p_ss <= INT_MAX);
diff = (int)p_ss;
}
if (off_left < 0) if (off_left < 0)
new_leftcol = curwin->w_leftcol - diff; new_leftcol = curwin->w_leftcol - diff;
else else
@ -902,8 +905,10 @@ curs_columns (
if (p_lines == 0) if (p_lines == 0)
p_lines = plines_win(curwin, curwin->w_cursor.lnum, FALSE); p_lines = plines_win(curwin, curwin->w_cursor.lnum, FALSE);
--p_lines; --p_lines;
if (p_lines > curwin->w_wrow + p_so) if (p_lines > curwin->w_wrow + p_so) {
n = curwin->w_wrow + p_so; assert(p_so <= INT_MAX);
n = curwin->w_wrow + (int)p_so;
}
else else
n = p_lines; n = p_lines;
if ((colnr_T)n >= curwin->w_height + curwin->w_skipcol / width) if ((colnr_T)n >= curwin->w_height + curwin->w_skipcol / width)
@ -922,7 +927,8 @@ curs_columns (
curwin->w_skipcol = n * width; curwin->w_skipcol = n * width;
} else if (extra == 1) { } else if (extra == 1) {
/* less then 'scrolloff' lines above, decrease skipcol */ /* less then 'scrolloff' lines above, decrease skipcol */
extra = (curwin->w_skipcol + p_so * width - curwin->w_virtcol assert(p_so <= INT_MAX);
extra = (curwin->w_skipcol + (int)p_so * width - curwin->w_virtcol
+ width - 1) / width; + width - 1) / width;
if (extra > 0) { if (extra > 0) {
if ((colnr_T)(extra * width) > curwin->w_skipcol) if ((colnr_T)(extra * width) > curwin->w_skipcol)
@ -974,7 +980,7 @@ scrolldown (
int byfold /* TRUE: count a closed fold as one line */ int byfold /* TRUE: count a closed fold as one line */
) )
{ {
long done = 0; /* total # of physical lines done */ int done = 0; /* total # of physical lines done */
int wrow; int wrow;
int moved = FALSE; int moved = FALSE;
@ -1331,7 +1337,8 @@ void scroll_cursor_top(int min_scroll, int always)
linenr_T old_topline = curwin->w_topline; linenr_T old_topline = curwin->w_topline;
linenr_T old_topfill = curwin->w_topfill; linenr_T old_topfill = curwin->w_topfill;
linenr_T new_topline; linenr_T new_topline;
int off = p_so; assert(p_so <= INT_MAX);
int off = (int)p_so;
if (mouse_dragging > 0) if (mouse_dragging > 0)
off = mouse_dragging - 1; off = mouse_dragging - 1;
@ -1472,7 +1479,7 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
int old_topfill = curwin->w_topfill; int old_topfill = curwin->w_topfill;
int fill_below_window; int fill_below_window;
linenr_T old_botline = curwin->w_botline; linenr_T old_botline = curwin->w_botline;
linenr_T old_valid = curwin->w_valid; int old_valid = curwin->w_valid;
int old_empty_rows = curwin->w_empty_rows; int old_empty_rows = curwin->w_empty_rows;
linenr_T cln; /* Cursor Line Number */ linenr_T cln; /* Cursor Line Number */
@ -1708,8 +1715,9 @@ void cursor_correct(void)
* How many lines we would like to have above/below the cursor depends on * How many lines we would like to have above/below the cursor depends on
* whether the first/last line of the file is on screen. * whether the first/last line of the file is on screen.
*/ */
above_wanted = p_so; assert(p_so <= INT_MAX);
below_wanted = p_so; above_wanted = (int)p_so;
below_wanted = (int)p_so;
if (mouse_dragging > 0) { if (mouse_dragging > 0) {
above_wanted = mouse_dragging - 1; above_wanted = mouse_dragging - 1;
below_wanted = mouse_dragging - 1; below_wanted = mouse_dragging - 1;
@ -2040,14 +2048,14 @@ void halfpage(bool flag, linenr_T Prenum)
{ {
long scrolled = 0; long scrolled = 0;
int i; int i;
int n;
int room; int room;
if (Prenum) if (Prenum)
curwin->w_p_scr = (Prenum > curwin->w_height) ? curwin->w_p_scr = (Prenum > curwin->w_height) ?
curwin->w_height : Prenum; curwin->w_height : Prenum;
n = (curwin->w_p_scr <= curwin->w_height) ? assert(curwin->w_p_scr <= INT_MAX);
curwin->w_p_scr : curwin->w_height; int n = curwin->w_p_scr <= curwin->w_height ? (int)curwin->w_p_scr
: curwin->w_height;
validate_botline(); validate_botline();
room = curwin->w_empty_rows; room = curwin->w_empty_rows;