]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: utils: Don't calculate file size in virTestLoadFile
authorPeter Krempa <pkrempa@redhat.com>
Tue, 25 Jul 2017 12:28:48 +0000 (14:28 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 27 Jul 2017 07:29:57 +0000 (09:29 +0200)
The callers don't use it so don't waste a strlen(). Also fix the comment
for the function.

Reviewed-by: Eric Blake <eblake@redhat.com>
tests/testutils.c

index ed01136a07c1ce8d1b7bbd2f39f3c369bc927fb5..7f1c4672b37bc524a0943eb5d3e2b528d66d7632 100644 (file)
@@ -289,9 +289,17 @@ virTestRun(const char *title,
     return ret;
 }
 
-/* Allocate BUF to the size of FILE. Read FILE into buffer BUF.
-   Upon any failure, diagnose it and return -1, but don't bother trying
-   to preserve errno. Otherwise, return the number of bytes copied into BUF. */
+
+/**
+ * virTestLoadFile:
+ * @file: name of the file to load
+ * @buf: buffer to load the file into
+ *
+ * Allocates @buf to the size of FILE. Reads FILE into buffer BUF.
+ * Upon any failure, error is printed to stderr and -1 is returned. 'errno' is
+ * not preserved. On success 0 is returned. Caller is responsible for freeing
+ * @buf.
+ */
 int
 virTestLoadFile(const char *file, char **buf)
 {
@@ -345,7 +353,7 @@ virTestLoadFile(const char *file, char **buf)
     }
 
     VIR_FORCE_FCLOSE(fp);
-    return strlen(*buf);
+    return 0;
 }
 
 #ifndef WIN32