diff options
author | Michal Nowak newman x <Michal Nowak newman.x@gmail.com> | 2009-06-26 22:41:45 -0400 |
---|---|---|
committer | Michal Nowak newman x <Michal Nowak newman.x@gmail.com> | 2009-06-26 22:41:45 -0400 |
commit | 04923c8eb783a099e07e831bc6ce1a010d4cb69a (patch) | |
tree | f3ed14f7db5965c3e35059d986bf494a92548218 | |
parent | d56c2d5edcf109ef1544002d8a78e518f71db06c (diff) |
Removed compiler warnings for unused return values
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | dpi/bookmarks.c | 18 | ||||
-rw-r--r-- | dpi/cookies.c | 39 | ||||
-rw-r--r-- | dpi/datauri.c | 7 | ||||
-rw-r--r-- | dpi/ftp.c | 8 | ||||
-rw-r--r-- | dpid/dpid.c | 8 | ||||
-rw-r--r-- | src/IO/Makefile.am | 1 | ||||
-rw-r--r-- | src/cookies.c | 21 | ||||
-rw-r--r-- | src/nav.c | 2 |
9 files changed, 86 insertions, 24 deletions
@@ -12,8 +12,12 @@ dillo-2.2 [??, 2009] - 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 ----------------------------------------------------------------------------- diff --git a/dpi/bookmarks.c b/dpi/bookmarks.c index dca12248..da4f422a 100644 --- a/dpi/bookmarks.c +++ b/dpi/bookmarks.c @@ -687,15 +687,29 @@ static void Bms_check_import(void) "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); } diff --git a/dpi/cookies.c b/dpi/cookies.c index 44b1a9be..0bb6ee09 100644 --- a/dpi/cookies.c +++ b/dpi/cookies.c @@ -178,14 +178,19 @@ static FILE *Cookies_fopen(const char *filename, const char *mode, 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_free_cookie(CookieData_t *cookie) 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 @@ static void Cookies_init() /* 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 @@ static void Cookies_init() /* 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 @@ static void Cookies_save_and_free() 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 @@ static int Cookie_control_init(void) { 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 @@ static int Cookie_control_init(void) /* 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); diff --git a/dpi/datauri.c b/dpi/datauri.c index 9d8fbcb7..dd0dbf7f 100644 --- a/dpi/datauri.c +++ b/dpi/datauri.c @@ -275,12 +275,17 @@ int main(void) { 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); @@ -266,7 +266,7 @@ static int try_ftp_transfer(char *url) 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 @@ int main(int argc, char **argv) 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) diff --git a/dpid/dpid.c b/dpid/dpid.c index bdfc21db..a21dcf9f 100644 --- a/dpid/dpid.c +++ b/dpid/dpid.c @@ -720,7 +720,7 @@ void est_dpi_sigchld(void) 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 @@ void stop_active_dpis(struct dp *dpi_attr_list, int numdpis) 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); } } diff --git a/src/IO/Makefile.am b/src/IO/Makefile.am index bc2dea7e..98d8d43a 100644 --- a/src/IO/Makefile.am +++ b/src/IO/Makefile.am @@ -8,7 +8,6 @@ libDiof_a_SOURCES = \ mime.h \ about.c \ Url.h \ - proto.c \ http.c \ dpi.c \ IO.c \ diff --git a/src/cookies.c b/src/cookies.c index 493f0e3f..396f7126 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -35,6 +35,7 @@ void a_Cookies_init(void) #include <stdlib.h> #include <stdio.h> #include <ctype.h> +#include <errno.h> #include "msg.h" #include "IO/Url.h" @@ -79,14 +80,19 @@ static int Cookie_control_init(void); 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 @@ static int Cookie_control_init(void) { 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 @@ static int Cookie_control_init(void) /* 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); @@ -597,5 +597,5 @@ int a_Nav_get_buf(const DilloUrl *Url, char **PBuf, int *BufSize) */ void a_Nav_unref_buf(const DilloUrl *Url) { - return a_Capi_unref_buf(Url); + a_Capi_unref_buf(Url); } |