]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - libiberty/testsuite/test-expandargv.c
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / libiberty / testsuite / test-expandargv.c
index 57b96b3ff9773ec4c53df925d77b29740ec7a946..56c170f9ec628e4ea6e019d903c77e0dade8981e 100644 (file)
@@ -1,5 +1,5 @@
 /* expandargv test program,
-   Copyright (C) 2006 Free Software Foundation, Inc.
+   Copyright (C) 2006-2021 Free Software Foundation, Inc.
    Written by Carlos O'Donell <carlos@codesourcery.com>
 
    This file is part of the libiberty library, which is part of GCC.
@@ -40,6 +40,9 @@
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 #ifndef EXIT_SUCCESS
 #define EXIT_SUCCESS 0
@@ -189,7 +192,7 @@ writeout_test (int test, const char * test_data)
 {
   char filename[256];
   FILE *fd;
-  size_t len;
+  size_t len, sys_fwrite;
   char * parse;
 
   /* Unique filename per test */
@@ -208,7 +211,10 @@ writeout_test (int test, const char * test_data)
   /* Run all possible replaces */
   run_replaces (parse);
 
-  fwrite (parse, len, sizeof (char), fd);
+  sys_fwrite = fwrite (parse, sizeof (char), len, fd);
+  if (sys_fwrite != len)
+    fatal_error (__LINE__, "Failed to write to test file.", errno);
+
   free (parse);
   fclose (fd);
 }