From 162c89ed497212859d748506209ffc1b88763ab2 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 3 Nov 2010 17:37:07 +0000 Subject: [PATCH] capitests: Use ftruncate instead of seek + write to create test files. --- generator/generator_capitests.ml | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/generator/generator_capitests.ml b/generator/generator_capitests.ml index 6f5f59c..325b37c 100644 --- a/generator/generator_capitests.ml +++ b/generator/generator_capitests.ml @@ -181,14 +181,8 @@ int main (int argc, char *argv[]) perror (filename); exit (EXIT_FAILURE); } - if (lseek (fd, %d, SEEK_SET) == -1) { - perror (\"lseek\"); - close (fd); - unlink (filename); - exit (EXIT_FAILURE); - } - if (write (fd, &c, 1) == -1) { - perror (\"write\"); + if (ftruncate (fd, %d) == -1) { + perror (\"ftruncate\"); close (fd); unlink (filename); exit (EXIT_FAILURE); @@ -209,14 +203,8 @@ int main (int argc, char *argv[]) perror (filename); exit (EXIT_FAILURE); } - if (lseek (fd, %d, SEEK_SET) == -1) { - perror (\"lseek\"); - close (fd); - unlink (filename); - exit (EXIT_FAILURE); - } - if (write (fd, &c, 1) == -1) { - perror (\"write\"); + if (ftruncate (fd, %d) == -1) { + perror (\"ftruncate\"); close (fd); unlink (filename); exit (EXIT_FAILURE); @@ -237,14 +225,8 @@ int main (int argc, char *argv[]) perror (filename); exit (EXIT_FAILURE); } - if (lseek (fd, %d, SEEK_SET) == -1) { - perror (\"lseek\"); - close (fd); - unlink (filename); - exit (EXIT_FAILURE); - } - if (write (fd, &c, 1) == -1) { - perror (\"write\"); + if (ftruncate (fd, %d) == -1) { + perror (\"ftruncate\"); close (fd); unlink (filename); exit (EXIT_FAILURE); -- 1.8.3.1