This is normally not an issue since the tests which use mocked open() do
not create files. But once coverage build is enabled, gcov_open will use
O_CREATE and real_open will read random data rather than the actual mode
argument.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
{
int ret = -1;
char *newpath = NULL;
+ va_list ap;
+ mode_t mode = 0;
PATH_OVERRIDE(newpath, path);
- ret = real_open(newpath, flags);
+ /* The mode argument is mandatory when O_CREAT is set in flags,
+ * otherwise the argument is ignored.
+ */
+ if (flags & O_CREAT) {
+ va_start(ap, flags);
+ mode = va_arg(ap, mode_t);
+ va_end(ap);
+ }
+
+ ret = real_open(newpath, flags, mode);
VIR_FREE(newpath);
{
char *path;
int ret;
+ va_list ap;
+ mode_t mode = 0;
init_syms();
path = get_fake_path(pathname);
if (!path)
return -1;
- ret = realopen(path, flags);
+
+ /* The mode argument is mandatory when O_CREAT is set in flags,
+ * otherwise the argument is ignored.
+ */
+ if (flags & O_CREAT) {
+ va_start(ap, flags);
+ mode = va_arg(ap, mode_t);
+ va_end(ap);
+ }
+
+ ret = realopen(path, flags, mode);
+
VIR_FREE(path);
return ret;
}