From d61829dd0694e442ae6794dbc415ea27f5585b75 Mon Sep 17 00:00:00 2001 From: Shane Iler Date: Mon, 30 Jun 2014 16:22:10 -0700 Subject: Enable and fix misc2.c -Wconversion warnings #907 --- src/nvim/misc2.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'src/nvim/misc2.c') 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; } /* -- cgit