Fix overflow warnings

Fix new warnings generated by gcc-5 about potential overflows.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Andrew Gregory 2015-06-10 00:48:01 -04:00 committed by Allan McRae
parent a187fa4562
commit 2e5e496eb0
2 changed files with 5 additions and 6 deletions

View File

@ -99,7 +99,7 @@ static void fill_progress(const int bar_percent, const int disp_percent,
const int proglen) const int proglen)
{ {
/* 8 = 1 space + 1 [ + 1 ] + 5 for percent */ /* 8 = 1 space + 1 [ + 1 ] + 5 for percent */
const int hashlen = proglen - 8; const int hashlen = proglen > 8 ? proglen - 8 : 0;
const int hash = bar_percent * hashlen / 100; const int hash = bar_percent * hashlen / 100;
static int lasthash = 0, mouth = 0; static int lasthash = 0, mouth = 0;
int i; int i;
@ -580,7 +580,7 @@ void cb_progress(alpm_progress_t event, const char *pkgname, int percent,
int i = textlen - 3; int i = textlen - 3;
wchar_t *p = wcstr; wchar_t *p = wcstr;
/* grab the max number of char columns we can fill */ /* grab the max number of char columns we can fill */
while(i > 0 && wcwidth(*p) < i) { while(i - wcwidth(*p) > 0) {
i -= wcwidth(*p); i -= wcwidth(*p);
p++; p++;
} }

View File

@ -1363,13 +1363,12 @@ static int multiselect_parse(char *array, int count, char *response)
if(!ends) { if(!ends) {
array[start - 1] = include; array[start - 1] = include;
} else { } else {
int d;
if(parseindex(ends, &end, start, count) != 0) { if(parseindex(ends, &end, start, count) != 0) {
return -1; return -1;
} }
for(d = start; d <= end; d++) { do {
array[d - 1] = include; array[start - 1] = include;
} } while(start++ < end);
} }
} }