diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2015-06-10 00:48:01 -0400 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2015-07-12 16:23:18 +1000 |
commit | 2e5e496eb0936cae7ea8d2b38417feae3ba56881 (patch) | |
tree | 9f1e481e36523953fa8cdcf0e1c343171033a321 /src/pacman/callback.c | |
parent | a187fa4562dc2f43f10134092056c2a9a6862d59 (diff) |
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>
Diffstat (limited to 'src/pacman/callback.c')
-rw-r--r-- | src/pacman/callback.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/pacman/callback.c b/src/pacman/callback.c index 17c3d7a8..1f086755 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -99,7 +99,7 @@ static void fill_progress(const int bar_percent, const int disp_percent, const int proglen) { /* 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; static int lasthash = 0, mouth = 0; int i; @@ -580,7 +580,7 @@ void cb_progress(alpm_progress_t event, const char *pkgname, int percent, int i = textlen - 3; wchar_t *p = wcstr; /* grab the max number of char columns we can fill */ - while(i > 0 && wcwidth(*p) < i) { + while(i - wcwidth(*p) > 0) { i -= wcwidth(*p); p++; } |