diff options
author | Michael Dankov <tryagain@navit-project.org> | 2015-10-12 01:38:03 +0300 |
---|---|---|
committer | Michael Dankov <tryagain@navit-project.org> | 2015-10-12 01:38:03 +0300 |
commit | d2a6b3d97d91af4104e2e2bb091b69298ff26dea (patch) | |
tree | e1081e631f146ad20ab1a789a0651d90de47ce1d /navit/maptool | |
parent | 31d3cd58aa702a94d82aff5e56d5ee34690da6cd (diff) | |
download | navit-d2a6b3d97d91af4104e2e2bb091b69298ff26dea.tar.gz |
Check fwrite rc in maptoolR6301
Diffstat (limited to 'navit/maptool')
-rw-r--r-- | navit/maptool/buffer.c | 4 | ||||
-rw-r--r-- | navit/maptool/itembin.c | 4 | ||||
-rw-r--r-- | navit/maptool/maptool.c | 1 | ||||
-rw-r--r-- | navit/maptool/misc.c | 27 | ||||
-rw-r--r-- | navit/maptool/osm.c | 40 | ||||
-rw-r--r-- | navit/maptool/tile.c | 4 | ||||
-rw-r--r-- | navit/maptool/zip.c | 9 |
7 files changed, 46 insertions, 43 deletions
diff --git a/navit/maptool/buffer.c b/navit/maptool/buffer.c index 9cc2f995e..2907b0670 100644 --- a/navit/maptool/buffer.c +++ b/navit/maptool/buffer.c @@ -30,8 +30,8 @@ save_buffer(char *filename, struct buffer *b, long long offset) f=fopen(filename,"wb+"); dbg_assert(f != NULL); - fseeko(f, offset, SEEK_SET); - fwrite(b->base, b->size, 1, f); + dbg_assert(fseeko(f, offset, SEEK_SET)==0); + dbg_assert(fwrite(b->base, b->size, 1, f)==1); fclose(f); } diff --git a/navit/maptool/itembin.c b/navit/maptool/itembin.c index 4b5a09d7b..98b0c52a6 100644 --- a/navit/maptool/itembin.c +++ b/navit/maptool/itembin.c @@ -269,7 +269,7 @@ item_bin_add_attr_range(struct item_bin *ib, enum attr_type type, short min, sho void item_bin_write(struct item_bin *ib, FILE *out) { - fwrite(ib, (ib->len+1)*4, 1, out); + dbg_assert(fwrite(ib, (ib->len+1)*4, 1, out)==1); } struct item_bin * @@ -587,7 +587,7 @@ item_bin_sort_file(char *in_file, char *out_file, struct rect *r, int *size) for (j = 0 ; j < count ; j++) { ib=(struct item_bin *)(idx[j]); c=(struct coord *)(ib+1); - fwrite(ib, (ib->len+1)*4, 1, f); + dbg_assert(fwrite(ib, (ib->len+1)*4, 1, f)==1); if (r) { for (k = 0 ; k < ib->clen/2 ; k++) { if (rc) diff --git a/navit/maptool/maptool.c b/navit/maptool/maptool.c index 765d6abf7..815eb9fff 100644 --- a/navit/maptool/maptool.c +++ b/navit/maptool/maptool.c @@ -1014,7 +1014,6 @@ int main(int argc, char **argv) fclose(ways_split); } } - if (start_phase(&p,"generating coastlines")) { osm_process_coastlines(&p, suffix); } diff --git a/navit/maptool/misc.c b/navit/maptool/misc.c index a0816e120..d4ce6f169 100644 --- a/navit/maptool/misc.c +++ b/navit/maptool/misc.c @@ -347,20 +347,19 @@ process_slice(FILE **in, FILE **reference, int in_count, int with_range, long lo info.tilesdir_out=NULL; phase34(&info, zip_info, in, reference, in_count, with_range); - th=tile_head_root; - while (th) { - if (th->process) { - if (th->name[0]) { - if (th->total_size != th->total_size_used) { - fprintf(stderr,"Size error '%s': %d vs %d\n", th->name, th->total_size, th->total_size_used); - exit(1); - } - write_zipmember(zip_info, th->name, zip_get_maxnamelen(zip_info), th->zip_data, th->total_size); - zipfiles++; - } else - fwrite(th->zip_data, th->total_size, 1, zip_get_index(zip_info)); + for (th=tile_head_root;th;th=th->next) { + if (!th->process) + continue; + if (th->name[0]) { + if (th->total_size != th->total_size_used) { + fprintf(stderr,"Size error '%s': %d vs %d\n", th->name, th->total_size, th->total_size_used); + exit(1); + } + write_zipmember(zip_info, th->name, zip_get_maxnamelen(zip_info), th->zip_data, th->total_size); + zipfiles++; + } else { + dbg_assert(fwrite(th->zip_data, th->total_size, 1, zip_get_index(zip_info))==1); } - th=th->next; } free(slice_data); @@ -420,7 +419,7 @@ process_binfile(FILE *in, FILE *out) { struct item_bin *ib; while ((ib=read_item(in))) { - fwrite(ib, (ib->len+1)*4, 1, out); + item_bin_write(ib, out); } } diff --git a/navit/maptool/osm.c b/navit/maptool/osm.c index 9f251b136..37c0e7626 100644 --- a/navit/maptool/osm.c +++ b/navit/maptool/osm.c @@ -2977,6 +2977,23 @@ osm_add_nd(osmid ref) } static void +write_item_way_subsection_index(FILE *out, FILE *out_index, FILE *out_graph, struct item_bin *orig, long long *last_id) +{ + osmid idx[2]; + idx[0]=item_bin_get_wayid(orig); + idx[1]=ftello(out); + if (way_hash) { + if (!(g_hash_table_lookup_extended(way_hash, (gpointer)(long)idx[0], NULL, NULL))) + g_hash_table_insert(way_hash, (gpointer)(long)idx[0], (gpointer)(long)idx[1]); + } else { + if (!last_id || *last_id != idx[0]) + dbg_assert(fwrite(idx, sizeof(idx), 1, out_index)==1); + if (last_id) + *last_id=idx[0]; + } +} + +static void write_item_way_subsection(FILE *out, FILE *out_index, FILE *out_graph, struct item_bin *orig, int first, int last, long long *last_id) { struct item_bin new; @@ -2987,27 +3004,14 @@ write_item_way_subsection(FILE *out, FILE *out_index, FILE *out_graph, struct it new.type=orig->type; new.clen=(last-first+1)*2; new.len=new.clen+attr_len+2; - if (out_index) { - osmid idx[2]; - idx[0]=item_bin_get_wayid(orig); - idx[1]=ftello(out); - if (way_hash) { - if (!(g_hash_table_lookup_extended(way_hash, (gpointer)(long)idx[0], NULL, NULL))) - g_hash_table_insert(way_hash, (gpointer)(long)idx[0], (gpointer)(long)idx[1]); - } else { - if (!last_id || *last_id != idx[0]) - fwrite(idx, sizeof(idx), 1, out_index); - if (last_id) - *last_id=idx[0]; - } - - } + if (out_index) + write_item_way_subsection_index(out, out_index, out_graph, orig, last_id); #if 0 fprintf(stderr,"first %d last %d type 0x%x len %d clen %d attr_len %d\n", first, last, new.type, new.len, new.clen, attr_len); #endif - fwrite(&new, sizeof(new), 1, out); - fwrite(c+first, new.clen*4, 1, out); - fwrite(attr, attr_len*4, 1, out); + dbg_assert(fwrite(&new, sizeof(new), 1, out)==1); + dbg_assert(fwrite(c+first, new.clen*4, 1, out)==1); + dbg_assert(fwrite(attr, attr_len*4, 1, out)==1); #if 0 fwrite(&new, sizeof(new), 1, out_graph); fwrite(c+first, new.clen*4, 1, out_graph); diff --git a/navit/maptool/tile.c b/navit/maptool/tile.c index 68b837bc0..9d9f94145 100644 --- a/navit/maptool/tile.c +++ b/navit/maptool/tile.c @@ -336,8 +336,8 @@ write_item(char *tile, struct item_bin *ib, FILE *reference) } if (reference) { int offset=th->total_size_used/4; - fwrite(&th->zipnum, sizeof(th->zipnum), 1, reference); - fwrite(&offset, sizeof(th->total_size_used), 1, reference); + dbg_assert(fwrite(&th->zipnum, sizeof(th->zipnum), 1, reference)==1); + dbg_assert(fwrite(&offset, sizeof(th->total_size_used), 1, reference)==1); } if (th->zip_data) memcpy(th->zip_data+th->total_size_used, ib, size); diff --git a/navit/maptool/zip.c b/navit/maptool/zip.c index b75f1e3e7..f352e6353 100644 --- a/navit/maptool/zip.c +++ b/navit/maptool/zip.c @@ -20,6 +20,7 @@ #include <zlib.h> #include <string.h> #include <stdlib.h> +#include "debug.h" #include "maptool.h" #include "config.h" #include "zipfile.h" @@ -261,16 +262,16 @@ write_zipmember(struct zip_info *zip_info, char *name, int filelen, char *data, zip_info->offset+=sizeof(mac); } #endif - fwrite(&cd, sizeof(cd), 1, zip_info->dir); - fwrite(filename, filelen, 1, zip_info->dir); + dbg_assert(fwrite(&cd, sizeof(cd), 1, zip_info->dir)==1); + dbg_assert(fwrite(filename, filelen, 1, zip_info->dir)==1); zip_info->dir_size+=sizeof(cd)+filelen; if (zip_info->zip64) { - fwrite(&cd_ext, sizeof(cd_ext), 1, zip_info->dir); + dbg_assert(fwrite(&cd_ext, sizeof(cd_ext), 1, zip_info->dir)==1); zip_info->dir_size+=sizeof(cd_ext); } #ifdef HAVE_LIBCRYPTO if (zip_info->passwd) { - fwrite(&enc, sizeof(enc), 1, zip_info->dir); + dbg_assert(fwrite(&enc, sizeof(enc), 1, zip_info->dir)==1); zip_info->dir_size+=sizeof(enc); } #endif |