X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/ef9f0fccbc1edb18ec49db524e9f7a05519be496..5e4cce8f309867bee2f16bc463e0f0b461d19ecf:/src/download.c diff --git a/src/download.c b/src/download.c index e928a74b..328f60c6 100644 --- a/src/download.c +++ b/src/download.c @@ -61,10 +61,12 @@ static gboolean check_file_first_line(FILE* f, gchar *patterns[]) size_t nr; memset(buf, 0, sizeof(buf)); - fgetpos(f, &pos); + if ( !fgetpos(f, &pos) ) + return FALSE; rewind(f); nr = fread(buf, 1, sizeof(buf) - 1, f); - fsetpos(f, &pos); + if ( !fgetpos(f, &pos) ) + return FALSE; for (bp = buf; (bp < (buf + sizeof(buf) - 1)) && (nr > (bp - buf)); bp++) { if (!(isspace(*bp))) break; @@ -278,7 +280,7 @@ static DownloadResult_t download( const char *hostname, const char *uri, const c time_t tile_age = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "download_tile_age")->u; /* Get the modified time of this file */ struct stat buf; - g_stat ( fn, &buf ); + (void)g_stat ( fn, &buf ); time_t file_time = buf.st_mtime; if ( (time(NULL) - file_time) < tile_age ) { /* File cache is too recent, so return */ @@ -306,7 +308,8 @@ static DownloadResult_t download( const char *hostname, const char *uri, const c } else { gchar *dir = g_path_get_dirname ( fn ); - g_mkdir_with_parents ( dir , 0777 ); + if ( g_mkdir_with_parents ( dir , 0777 ) != 0) + g_warning ("%s: Failed to mkdir %s", __FUNCTION__, dir ); g_free ( dir ); } @@ -375,7 +378,7 @@ static DownloadResult_t download( const char *hostname, const char *uri, const c } if (ret == CURL_DOWNLOAD_NO_NEWER_FILE) { - g_remove ( tmpfilename ); + (void)g_remove ( tmpfilename ); #if GLIB_CHECK_VERSION(2,18,0) g_utime ( fn, NULL ); /* update mtime of local copy */ #else @@ -447,7 +450,7 @@ gchar *a_download_uri_to_tmp_file ( const gchar *uri, DownloadMapOptions *option if ( curl_download_uri ( uri, tmp_file, options, NULL, NULL ) ) { // error fclose ( tmp_file ); - g_remove ( tmpname ); + (void)g_remove ( tmpname ); g_free ( tmpname ); return NULL; }