From d29d1a772623c7c0edbe6087e637b6be7a769272 Mon Sep 17 00:00:00 2001 From: cel Date: Sat, 5 Sep 2020 17:43:11 -0400 Subject: [PATCH] Reduce warnings --- zet.dpi.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/zet.dpi.c b/zet.dpi.c index f174734..f99355f 100644 --- a/zet.dpi.c +++ b/zet.dpi.c @@ -257,7 +257,7 @@ static int zet_has_links(const char *id) { int rc = fstat(fd, &st); if (rc < 0) goto error; char *buf = malloc(st.st_size+1); - rc = read_all(fd, buf, st.st_size); + rc = read_all(fd, (unsigned char *)buf, st.st_size); if (rc < 0) goto error; buf[st.st_size] = '\0'; char *str = buf; @@ -293,7 +293,7 @@ error: static char *zet_get_buf_title(const struct buf *link, char *buf, size_t len) { char id_buf[128]; - strncpy(id_buf, link->data, link->size); + strncpy(id_buf, (char *)link->data, link->size); id_buf[sizeof(id_buf)-1] = '\0'; return zet_get_title(id_buf + sigil_size, buf, len); } @@ -655,9 +655,9 @@ static int dpi_serve_zet_tails(int fd) { static void unescape(char *buf, size_t len, const char *str) { struct buf *ob = bufnew(1024); - houdini_unescape_url(ob, str, strlen(str)); + houdini_unescape_url(ob, (unsigned char *)str, strlen(str)); if (ob->size < len) len = ob->size; - strncpy(buf, ob->data, len); + strncpy(buf, (char *)ob->data, len); buf[len] = '\0'; bufrelease(ob); } @@ -814,7 +814,7 @@ md_rndr_link(struct buf *ob, const struct buf *link, const struct buf *title, co } static void put_link_truncated(struct buf *ob, const struct buf *link, int max_length) { - char *buf = link->data; + char *buf = (char *)link->data; size_t len = link->size; if (!strncmp(buf, "http", 4)) { @@ -827,9 +827,12 @@ static void put_link_truncated(struct buf *ob, const struct buf *link, int max_l len -= 8; } } - if (len < max_length) return houdini_escape_html0(ob, buf, len, 0); + if (len < (size_t)max_length) { + houdini_escape_html0(ob, (unsigned char *)buf, len, 0); + return; + } - houdini_escape_html0(ob, buf, max_length, 0); + houdini_escape_html0(ob, (unsigned char *)buf, max_length, 0); BUFPUTSL(ob, "…"); } @@ -867,7 +870,7 @@ md_rndr_autolink(struct buf *ob, const struct buf *link, enum mkd_autolink type, char *title = zet_get_buf_title(link, title_buf, sizeof(title_buf)); if (title != NULL) { BUFPUTSL(ob, "\" title=\""); - houdini_escape_html0(ob, title, strlen(title), 0); + houdini_escape_html0(ob, (unsigned char *)title, strlen(title), 0); } } @@ -1147,7 +1150,7 @@ static int parse_multipart(struct http_request *req) { if (!strcmp(name, "text")) { req->data = body; - req->len = end == NULL ? strlen(body) : end - body; + req->len = end == NULL ? strlen(body) : (size_t)end - (size_t)body; } } return 0;