diff options
author | Bram Moolenaar <bram@vim.org> | 2013-09-08 16:07:07 +0200 |
---|---|---|
committer | Bram Moolenaar <bram@vim.org> | 2013-09-08 16:07:07 +0200 |
commit | 55b893efd07d4c8b09ffa60035c9db8a1cb9394b (patch) | |
tree | da75542f40e2683399479bb5bd62d7a02e5de670 | |
parent | ead7d1b78fec9e4efa5c3154c44bce4d374bf45a (diff) | |
download | vim-55b893efd07d4c8b09ffa60035c9db8a1cb9394b.tar.gz |
Problem: Clang warning for int shift overflow.
Solution: Use unsigned and cast back to int. (Dominique Pelle)
-rw-r--r-- | src/misc2.c | 16 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/misc2.c b/src/misc2.c index 504cf0ae..b8655e84 100644 --- 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; } /* diff --git a/src/version.c b/src/version.c index ff4e3bb6..f875d013 100644 --- a/src/version.c +++ b/src/version.c @@ -739,6 +739,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 26, +/**/ 25, /**/ 24, |