t/zbd: avoid test case 31 failure with small devices
[fio.git] / lib / pattern.c
index 1ae05758f7684457ac1308db87e93e85593c56fe..9fca643e32e250ec80b4ae7233054f59f14f0c67 100644 (file)
@@ -47,7 +47,11 @@ static const char *parse_file(const char *beg, char *out,
        if (file == NULL)
                goto err_out;
 
+#ifdef _WIN32
+       fd = open(file, O_RDONLY | O_BINARY);
+#else
        fd = open(file, O_RDONLY);
+#endif
        if (fd < 0)
                goto err_free_out;
 
@@ -382,8 +386,9 @@ static int parse_and_fill_pattern(const char *in, unsigned int in_len,
                assert(filled);
                assert(filled <= out_len);
                out_len -= filled;
-               out     += filled;
                total   += filled;
+               if (out)
+                       out += filled;
 
        } while (in_len);