(root)/
glibc-2.38/
misc/
tst-error1.c
       1  #include <error.h>
       2  #include <mcheck.h>
       3  #include <stdio.h>
       4  #include <string.h>
       5  #include <wchar.h>
       6  #include <libc-diag.h>
       7  
       8  #include <support/xstdio.h>
       9  
      10  static int
      11  do_test (int argc, char *argv[])
      12  {
      13    mtrace ();
      14    xfreopen (argc == 1 ? "/dev/stdout" : argv[1], "a", stderr);
      15    /* Orient the stream.  */
      16    fwprintf (stderr, L"hello world\n");
      17    char buf[20000];
      18    static const char str[] = "hello world! ";
      19    for (int i = 0; i < 1000; ++i)
      20      memcpy (&buf[i * (sizeof (str) - 1)], str, sizeof (str));
      21    error (0, 0, str);
      22  
      23    /* We're testing a large format string here and need to generate it
      24       to avoid this source file being ridiculous.  So disable the warning
      25       about a generated format string.  */
      26    DIAG_PUSH_NEEDS_COMMENT;
      27    DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat-security");
      28  
      29    error (0, 0, buf);
      30    error (0, 0, buf);
      31  
      32    DIAG_POP_NEEDS_COMMENT;
      33  
      34    error (0, 0, str);
      35    return 0;
      36  }
      37  
      38  #define TEST_FUNCTION do_test (argc, argv)
      39  #include "../test-skeleton.c"