提交 55e8314e 编写于 作者: P Peter Krempa

tests: utils: Don't calculate file size in virTestLoadFile

The callers don't use it so don't waste a strlen(). Also fix the comment
for the function.
Reviewed-by: NEric Blake <eblake@redhat.com>
上级 29f771fd
...@@ -289,9 +289,17 @@ virTestRun(const char *title, ...@@ -289,9 +289,17 @@ virTestRun(const char *title,
return ret; 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 int
virTestLoadFile(const char *file, char **buf) virTestLoadFile(const char *file, char **buf)
{ {
...@@ -345,7 +353,7 @@ virTestLoadFile(const char *file, char **buf) ...@@ -345,7 +353,7 @@ virTestLoadFile(const char *file, char **buf)
} }
VIR_FORCE_FCLOSE(fp); VIR_FORCE_FCLOSE(fp);
return strlen(*buf); return 0;
} }
#ifndef WIN32 #ifndef WIN32
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册