From: Petr Štetiar Date: Fri, 11 Oct 2019 13:07:17 +0000 (+0200) Subject: cgi-io: iron out extra compiler warnings X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=bb6cdb804cc4db12cca776f559baa6d989a992ec;p=feed%2Fpackages.git cgi-io: iron out extra compiler warnings Fixes following errors: main.c:458:37: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] main.c:463:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare] main.c:518:35: error: comparison of integer expressions of different signedness: ‘ssize_t’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] main.c:157:3: error: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Werror=unused-result] main.c:763:3: error: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Werror=unused-result] Signed-off-by: Petr Štetiar --- diff --git a/net/cgi-io/Makefile b/net/cgi-io/Makefile index 6bc906ec5f..92cca4fa07 100644 --- a/net/cgi-io/Makefile +++ b/net/cgi-io/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=cgi-io -PKG_RELEASE:=13 +PKG_RELEASE:=14 PKG_LICENSE:=GPL-2.0-or-later diff --git a/net/cgi-io/src/main.c b/net/cgi-io/src/main.c index e4d0b212f4..3530284c68 100644 --- a/net/cgi-io/src/main.c +++ b/net/cgi-io/src/main.c @@ -126,6 +126,7 @@ static char * checksum(const char *applet, size_t sumlen, const char *file) { pid_t pid; + int r; int fds[2]; static char chksum[65]; @@ -154,10 +155,14 @@ checksum(const char *applet, size_t sumlen, const char *file) default: memset(chksum, 0, sizeof(chksum)); - read(fds[0], chksum, sumlen); + r = read(fds[0], chksum, sumlen); + waitpid(pid, NULL, 0); close(fds[0]); close(fds[1]); + + if (r < 0) + return NULL; } return chksum; @@ -442,7 +447,7 @@ header_field(multipart_parser *p, const char *data, size_t len) static int header_value(multipart_parser *p, const char *data, size_t len) { - int i, j; + size_t i, j; if (!st.is_content_disposition) return 0; @@ -500,6 +505,8 @@ data_begin_cb(multipart_parser *p) static int data_cb(multipart_parser *p, const char *data, size_t len) { + int wlen = len; + switch (st.parttype) { case PART_SESSIONID: @@ -515,14 +522,14 @@ data_cb(multipart_parser *p, const char *data, size_t len) break; case PART_FILEDATA: - if (write(st.tempfd, data, len) != len) + if (write(st.tempfd, data, len) != wlen) { close(st.tempfd); return response(false, "I/O failure while writing temporary file"); } if (!st.filedata) - st.filedata = !!len; + st.filedata = !!wlen; break; @@ -734,6 +741,7 @@ main_backup(int argc, char **argv) { pid_t pid; time_t now; + int r; int len; int status; int fds[2]; @@ -760,7 +768,9 @@ main_backup(int argc, char **argv) close(fds[0]); close(fds[1]); - chdir("/"); + r = chdir("/"); + if (r < 0) + return failure(500, errno, "Failed chdir('/')"); execl("/sbin/sysupgrade", "/sbin/sysupgrade", "--create-backup", "-", NULL);