1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
diff --git a/apps/codecs.c b/apps/codecs.c
index 4d97baa..72d6b59 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -83,7 +83,7 @@ static int open(const char* pathname, int flags, ...)
     {
         va_list ap;
         va_start(ap, flags);
-        fd = sim_open(pathname, flags, va_arg(ap, mode_t));
+        fd = sim_open(pathname, flags, va_arg(ap, int));
         va_end(ap);
     }
     else
diff --git a/apps/plugin.c b/apps/plugin.c
index 8a32a15..1d1dbb3 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -987,8 +987,7 @@ static int open_wrapper(const char* pathname, int flags, ...)
     {
         va_list ap;
         va_start(ap, flags);
-        int fd;
-        fd = sim_open(pathname, flags, va_arg(ap, mode_t));
+        fd = sim_open(pathname, flags, va_arg(ap, int));
         va_end(ap);
     }
     else
diff --git a/apps/plugins/doom/rockdoom.c b/apps/plugins/doom/rockdoom.c
index 1383a2b..f6fa831 100644
--- a/apps/plugins/doom/rockdoom.c
+++ b/apps/plugins/doom/rockdoom.c
@@ -72,7 +72,7 @@ int my_open(const char *file, int flags, ...)
    {
       va_list ap;
       va_start(ap, flags);
-      filearray[fpoint]=rb->open(file, flags, va_arg(ap, mode_t));
+      filearray[fpoint]=rb->open(file, flags, va_arg(ap, int));
       va_end(ap);
    }
    else
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 937c710..10c7492 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -340,11 +340,13 @@ int sim_open(const char *name, int o, ...)
     if (num_openfiles >= MAX_OPEN_FILES)
         return -2;

-    if (o & O_CREAT)
+    if (opts & O_CREAT)
     {
         va_list ap;
+        int mode;
         va_start(ap, o);
-        ret = OPEN(get_sim_pathname(name), opts, va_arg(ap, mode_t));
+        mode_t mode = va_arg(ap, int);
+        ret = OPEN(get_sim_pathname(name), opts, mode);
         va_end(ap);
     }
     else