Mercurial > dillo_port1.3
changeset 1200:6bdf6ea2637a
Removed compiler warnings for unused return values
author | Michal Nowak newman.x@gmail.com |
---|---|
date | Fri, 26 Jun 2009 22:41:45 -0400 |
parents | 81c2d1c2e0f0 |
children | cabde55d0e05 |
files | ChangeLog dpi/bookmarks.c dpi/cookies.c dpi/datauri.c dpi/ftp.c dpid/dpid.c src/IO/Makefile.am src/cookies.c src/nav.c |
diffstat | 9 files changed, 86 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Jun 26 18:04:03 2009 -0400 +++ b/ChangeLog Fri Jun 26 22:41:45 2009 -0400 @@ -12,8 +12,12 @@ - Added the "nop" keybinding (nop = NO_OPERATION; cancels a default hook). - Fixed segfault when URL is NULL and dpis can't be found. Patches: place (AKA corvid) ++- Reduced 'warning: ignoring return value of ...' + Patch: Michal Nowak, Jorge Arellano Cid +- Check chdir() return code in Paths::init. - Patch: Michal Nowak + - Removed return from a_Nav_unref_buf() + - Do not build proto.c (file is empty); GCC warning + Patches: Michal Nowak -----------------------------------------------------------------------------
--- a/dpi/bookmarks.c Fri Jun 26 18:04:03 2009 -0400 +++ b/dpi/bookmarks.c Fri Jun 26 22:41:45 2009 -0400 @@ -687,15 +687,29 @@ "grep -i \"href\" %s | " "sed -e 's/<li><A HREF=\"/s0 /' -e 's/\">/ /' -e 's/<.*$//' >> %s"; Dstr *dstr = dStr_new(""); + int rc; if (access(BmFile, F_OK) != 0) { OldBmFile = dStrconcat(dGethomedir(), "/.dillo/bookmarks.html", NULL); if (access(OldBmFile, F_OK) == 0) { dStr_sprintf(dstr, cmd1, BmFile); - system(dstr->str); + rc = system(dstr->str); + if (rc == 127) { + MSG("Bookmarks: /bin/sh could not be executed\n"); + } else if (rc == -1) { + MSG("Bookmarks: process creation failure: %s\n", + dStrerror(errno)); + } dStr_sprintf(dstr, cmd2, OldBmFile, BmFile); - system(dstr->str); + rc = system(dstr->str); + if (rc == 127) { + MSG("Bookmarks: /bin/sh could not be executed\n"); + } else if (rc == -1) { + MSG("Bookmarks: process creation failure: %s\n", + dStrerror(errno)); + } + dStr_free(dstr, TRUE); dFree(OldBmFile); }
--- a/dpi/cookies.c Fri Jun 26 18:04:03 2009 -0400 +++ b/dpi/cookies.c Fri Jun 26 22:41:45 2009 -0400 @@ -178,14 +178,19 @@ char *init_str) { FILE *F_in; - int fd; + int fd, rc; if ((F_in = fopen(filename, mode)) == NULL) { /* Create the file */ fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); if (fd != -1) { - if (init_str) - write(fd, init_str, strlen(init_str)); + if (init_str) { + rc = write(fd, init_str, strlen(init_str)); + if (rc == -1) { + MSG("Cookies: Could not write initial string to file %s: %s\n", + filename, dStrerror(errno)); + } + } close(fd); MSG("Created file: %s\n", filename); @@ -222,7 +227,7 @@ static void Cookies_init() { CookieData_t *cookie; - char *filename; + char *filename, *rc = NULL; char line[LINE_MAXLEN]; #ifndef HAVE_LOCKF struct flock lck; @@ -273,7 +278,12 @@ /* Get all lines in the file */ while (!feof(file_stream)) { line[0] = '\0'; - fgets(line, LINE_MAXLEN, file_stream); + rc = fgets(line, LINE_MAXLEN, file_stream); + if (!rc && ferror(file_stream)) { + MSG("Cookies1: Error while reading rule from cookiesrc: %s\n", + dStrerror(errno)); + break; /* bail out */ + } /* Remove leading and trailing whitespaces */ dStrstrip(line); @@ -338,7 +348,12 @@ /* Get all lines in the file */ while (!feof(old_cookies_file_stream)) { line[0] = '\0'; - fgets(line, LINE_MAXLEN, old_cookies_file_stream); + rc = fgets(line, LINE_MAXLEN, old_cookies_file_stream); + if (!rc && ferror(old_cookies_file_stream)) { + MSG("Cookies2: Error while reading rule from cookiesrc: %s\n", + dStrerror(errno)); + break; /* bail out */ + } /* Remove leading and trailing whitespaces */ dStrstrip(line); @@ -425,7 +440,8 @@ rewind(file_stream); fd = fileno(file_stream); - ftruncate(fd, 0); + if (ftruncate(fd, 0) == -1) + MSG("Cookies: Truncate file stream failed: %s\n", dStrerror(errno)); fprintf(file_stream, "%s", cookies_txt_header_str); /* Iterate cookies per domain, saving and freeing */ @@ -1213,7 +1229,7 @@ { CookieControl cc; FILE *stream; - char *filename; + char *filename, *rc; char line[LINE_MAXLEN]; char domain[LINE_MAXLEN]; char rule[LINE_MAXLEN]; @@ -1231,7 +1247,12 @@ /* Get all lines in the file */ while (!feof(stream)) { line[0] = '\0'; - fgets(line, LINE_MAXLEN, stream); + rc = fgets(line, LINE_MAXLEN, stream); + if (!rc && ferror(stream)) { + MSG("Cookies3: Error while reading rule from cookiesrc: %s\n", + dStrerror(errno)); + break; /* bail out */ + } /* Remove leading and trailing whitespaces */ dStrstrip(line);
--- a/dpi/datauri.c Fri Jun 26 18:04:03 2009 -0400 +++ b/dpi/datauri.c Fri Jun 26 22:41:45 2009 -0400 @@ -275,12 +275,17 @@ { char *dpip_tag = NULL, *cmd = NULL, *url = NULL, *mime_type; unsigned char *data; + int rc; size_t data_size = 0; /* Initialize the SockHandler */ sh = sock_handler_new(STDIN_FILENO, STDOUT_FILENO, 8*1024); - chdir("/tmp"); + rc = chdir("/tmp"); + if (rc == -1) { + MSG("paths: error changing directory to /tmp: %s\n", + dStrerror(errno)); + } /* Read the dpi command from STDIN */ dpip_tag = sock_handler_read(sh);
--- a/dpi/ftp.c Fri Jun 26 18:04:03 2009 -0400 +++ b/dpi/ftp.c Fri Jun 26 22:41:45 2009 -0400 @@ -266,7 +266,7 @@ int main(int argc, char **argv) { char *dpip_tag = NULL, *cmd = NULL, *url = NULL, *url2 = NULL; - int nb; + int nb, rc; char *p, *d_cmd; /* Debugging with a command line argument */ @@ -277,7 +277,11 @@ sh = sock_handler_new(STDIN_FILENO, STDOUT_FILENO, 8*1024); /* wget may need to write a temporary file... */ - chdir("/tmp"); + rc = chdir("/tmp"); + if (rc == -1) { + MSG("paths: error changing directory to /tmp: %s\n", + dStrerror(errno)); + } /* Read the dpi command from STDIN */ if (!dpip_tag)
--- a/dpid/dpid.c Fri Jun 26 18:04:03 2009 -0400 +++ b/dpid/dpid.c Fri Jun 26 22:41:45 2009 -0400 @@ -720,7 +720,7 @@ void stop_active_dpis(struct dp *dpi_attr_list, int numdpis) { static char *DpiBye_cmd = NULL; - int i, dpi_socket; + int i, dpi_socket, rc; struct sockaddr_un dpi_addr; struct sockaddr_un sa; size_t sun_path_len, addr_len; @@ -751,7 +751,11 @@ ERRMSG("stop_active_dpis", "connect", errno); MSG_ERR("%s\n", dpi_addr.sun_path); } - (void) write(dpi_socket, DpiBye_cmd, strlen(DpiBye_cmd)); + rc = write(dpi_socket, DpiBye_cmd, strlen(DpiBye_cmd)); + if (rc == -1) { + MSG("stop_active_dpis: Error on sending BYE command: %s\n", + dStrerror(errno)); + } a_Misc_close_fd(dpi_socket); } }
--- a/src/IO/Makefile.am Fri Jun 26 18:04:03 2009 -0400 +++ b/src/IO/Makefile.am Fri Jun 26 22:41:45 2009 -0400 @@ -8,7 +8,6 @@ mime.h \ about.c \ Url.h \ - proto.c \ http.c \ dpi.c \ IO.c \
--- a/src/cookies.c Fri Jun 26 18:04:03 2009 -0400 +++ b/src/cookies.c Fri Jun 26 22:41:45 2009 -0400 @@ -35,6 +35,7 @@ #include <stdlib.h> #include <stdio.h> #include <ctype.h> +#include <errno.h> #include "msg.h" #include "IO/Url.h" @@ -79,14 +80,19 @@ static FILE *Cookies_fopen(const char *filename, char *init_str) { FILE *F_in; - int fd; + int fd, rc; if ((F_in = fopen(filename, "r")) == NULL) { /* Create the file */ fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); if (fd != -1) { - if (init_str) - write(fd, init_str, strlen(init_str)); + if (init_str) { + rc = write(fd, init_str, strlen(init_str)); + if (rc == -1) { + MSG("Cookies: Could not write initial string to file %s: %s\n", + filename, dStrerror(errno)); + } + } close(fd); MSG("Cookies: Created file: %s\n", filename); @@ -227,7 +233,7 @@ { CookieControl cc; FILE *stream; - char *filename; + char *filename, *rc; char line[LINE_MAXLEN]; char domain[LINE_MAXLEN]; char rule[LINE_MAXLEN]; @@ -245,7 +251,12 @@ /* Get all lines in the file */ while (!feof(stream)) { line[0] = '\0'; - fgets(line, LINE_MAXLEN, stream); + rc = fgets(line, LINE_MAXLEN, stream); + if (!rc && ferror(stream)) { + MSG("Cookies1: Error while reading rule from cookiesrc: %s\n", + dStrerror(errno)); + return 2; /* bail out */ + } /* Remove leading and trailing whitespaces */ dStrstrip(line);