Mercurial > vim
changeset 5347:6bbb2ae990c9 v7.4.026
updated for version 7.4.026
Problem: Clang warning for int shift overflow.
Solution: Use unsigned and cast back to int. (Dominique Pelle)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 08 Sep 2013 16:07:07 +0200 |
parents | 3530261cb77b |
children | dfdc81191d2e |
files | src/misc2.c src/version.c |
diffstat | 2 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/misc2.c +++ b/src/misc2.c @@ -6496,13 +6496,15 @@ get3c(fd) get4c(fd) FILE *fd; { - int n; - - n = getc(fd); - n = (n << 8) + getc(fd); - n = (n << 8) + getc(fd); - n = (n << 8) + getc(fd); - return n; + /* Use unsigned rather than int otherwise result is undefined + * when left-shift sets the MSB. */ + unsigned n; + + n = (unsigned)getc(fd); + n = (n << 8) + (unsigned)getc(fd); + n = (n << 8) + (unsigned)getc(fd); + n = (n << 8) + (unsigned)getc(fd); + return (int)n; } /*