diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2009-02-15 15:02:29 +0000 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2009-02-15 15:02:29 +0000 |
commit | 84b134a22dfb0290852a1dfe5cf9a91f508231d1 (patch) | |
tree | d2fb6769a0f2be77357b1a40c9547263c032d96a /gtk | |
parent | 5c5f14fe49c8f22b04305774cec71ae8ff1f8dd6 (diff) |
Compiling on Ubuntu 8.10 gives a warning when not checking the return value
from fwrite, so added a check. Also use size_t for nbytes.
svn path=/trunk/; revision=27451
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/hostlist_table.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gtk/hostlist_table.c b/gtk/hostlist_table.c index a0f84d9af2..5186e68b03 100644 --- a/gtk/hostlist_table.c +++ b/gtk/hostlist_table.c @@ -718,7 +718,7 @@ open_as_map_cb(GtkWindow *copy_bt, gpointer data _U_) char * dst_file_path; FILE * src_file; FILE * dst_file; - int nbytes; + size_t nbytes; char buf[256]; src_file_path = get_datafile_path("ipmap.html"); @@ -732,7 +732,12 @@ open_as_map_cb(GtkWindow *copy_bt, gpointer data _U_) do { nbytes = fread(buf, 1, sizeof(buf)-1, src_file); - fwrite(buf, 1, nbytes, dst_file); + if (fwrite(buf, 1, nbytes, dst_file) != nbytes) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Couldn't write %zu bytes to \"%s\"", nbytes, dst_file_path); + fclose(src_file); + fclose(dst_file); + return; + } } while(nbytes == sizeof(buf)-1); fclose(src_file); |