Prechádzať zdrojové kódy

vlib: Vect_hist_command() check return value of Vect_hist_write()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@63570 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 10 rokov pred
rodič
commit
094cda2a4e
1 zmenil súbory, kde vykonal 12 pridanie a 6 odobranie
  1. 12 6
      lib/vector/Vlib/hist.c

+ 12 - 6
lib/vector/Vlib/hist.c

@@ -28,22 +28,27 @@
  */
 int Vect_hist_command(struct Map_info *Map)
 {
-    char *cmd, buf[2000];
+    char *cmd, buf[GPATH_MAX];
 
     G_debug(3, "Vect_hist_command()");
 
     cmd = G_recreate_command();
 
-    Vect_hist_write(Map, "COMMAND: ");
-    Vect_hist_write(Map, cmd);
-    Vect_hist_write(Map, "\n");
+    if (0 > Vect_hist_write(Map, "COMMAND: "))
+        return -1;
+    if (0 > Vect_hist_write(Map, cmd))
+        return -1;
+    if (0 > Vect_hist_write(Map, "\n"))
+        return -1;
 
     sprintf(buf, "GISDBASE: %s\n", G_gisdbase());	/* Needed ? */
-    Vect_hist_write(Map, buf);
+    if (0 > Vect_hist_write(Map, buf))
+        return -1;
 
     sprintf(buf, "LOCATION: %s MAPSET: %s USER: %s DATE: %s\n",
 	    G_location(), G_mapset(), G_whoami(), G_date());	/* Needed ? */
-    Vect_hist_write(Map, buf);
+    if (0 > Vect_hist_write(Map, buf))
+        return -1;
 
     return 0;
 }
@@ -55,6 +60,7 @@ int Vect_hist_command(struct Map_info *Map)
    \param str string to write
 
    \return the number of characters printed
+   \return -1 on error
  */
 int Vect_hist_write(struct Map_info *Map, const char *str)
 {