diff options
author | Shane Iler <sriler@gmail.com> | 2014-06-30 16:22:10 -0700 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-07-11 18:11:20 -0400 |
commit | d61829dd0694e442ae6794dbc415ea27f5585b75 (patch) | |
tree | 47f68d9b00c2401af20b9397f0fe0647cc59ec0a /src/nvim/misc2.c | |
parent | fa1d9301f7f1c2b4ea426125e513d3724394df49 (diff) | |
download | rneovim-d61829dd0694e442ae6794dbc415ea27f5585b75.tar.gz rneovim-d61829dd0694e442ae6794dbc415ea27f5585b75.tar.bz2 rneovim-d61829dd0694e442ae6794dbc415ea27f5585b75.zip |
Enable and fix misc2.c -Wconversion warnings #907
Diffstat (limited to 'src/nvim/misc2.c')
-rw-r--r-- | src/nvim/misc2.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/nvim/misc2.c b/src/nvim/misc2.c index d2da6cbd65..3fe5f1a0ed 100644 --- a/src/nvim/misc2.c +++ b/src/nvim/misc2.c @@ -488,28 +488,20 @@ time_t get8ctime(FILE *fd) return n; } -/* - * Read a string of length "cnt" from "fd" into allocated memory. - * Returns NULL when unable to read that many bytes. - */ -char_u *read_string(FILE *fd, int cnt) +/// Reads a string of length "cnt" from "fd" into allocated memory. +/// @return pointer to the string or NULL when unable to read that many bytes. +char *read_string(FILE *fd, size_t cnt) { - int i; - int c; - - char_u *str = xmallocz(cnt); - /* Read the string. Quit when running into the EOF. */ - for (i = 0; i < cnt; ++i) { - c = getc(fd); + uint8_t *str = xmallocz(cnt); + for (size_t i = 0; i < cnt; i++) { + int c = getc(fd); if (c == EOF) { free(str); return NULL; } - str[i] = c; + str[i] = (uint8_t)c; } - str[i] = NUL; - - return str; + return (char *)str; } /* |