Wconversion: Fix warnings in digraph.c.

This commit is contained in:
Florian Walch
2014-11-18 16:02:42 +01:00
parent d2338ce397
commit 2b0d9bdeac
2 changed files with 8 additions and 4 deletions

View File

@@ -43,7 +43,6 @@ set(CONV_SOURCES
buffer.c buffer.c
charset.c charset.c
diff.c diff.c
digraph.c
edit.c edit.c
eval.c eval.c
ex_cmds2.c ex_cmds2.c

View File

@@ -2,7 +2,9 @@
/// ///
/// code for digraphs /// code for digraphs
#include <assert.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
#include <inttypes.h> #include <inttypes.h>
#include "nvim/vim.h" #include "nvim/vim.h"
@@ -1582,7 +1584,7 @@ int getdigraph(int char1, int char2, int meta_char)
/// @param str /// @param str
void putdigraph(char_u *str) void putdigraph(char_u *str)
{ {
int char1, char2, n; char_u char1, char2;
digr_T *dp; digr_T *dp;
while (*str != NUL) { while (*str != NUL) {
@@ -1609,7 +1611,9 @@ void putdigraph(char_u *str)
EMSG(_(e_number_exp)); EMSG(_(e_number_exp));
return; return;
} }
n = getdigits(&str); long digits = getdigits(&str);
assert(digits <= INT_MAX);
int n = (int)digits;
// If the digraph already exists, replace the result. // If the digraph already exists, replace the result.
dp = (digr_T *)user_digraphs.ga_data; dp = (digr_T *)user_digraphs.ga_data;
@@ -1711,7 +1715,8 @@ static void printdigraph(digr_T *dp)
if (char2cells(dp->result) == 1) { if (char2cells(dp->result) == 1) {
*p++ = ' '; *p++ = ' ';
} }
vim_snprintf((char *)p, sizeof(buf) - (p - buf), " %3d", dp->result); assert(p >= buf);
vim_snprintf((char *)p, sizeof(buf) - (size_t)(p - buf), " %3d", dp->result);
msg_outtrans(buf); msg_outtrans(buf);
} }
} }