mirror of
				https://sourceware.org/git/glibc.git
				synced 2025-10-31 22:10:34 +03:00 
			
		
		
		
	value. * stdio-common/tst-fmemopen2.c (do_test): Avoid fmt string warning if off_t is different rank from size_t. * sysdeps/generic/unwind-dw2.c (extract_cie_info, execute_cfa_program, uw_frame_state_for): Avoid type punning warnings. * sysdeps/generic/unwind-dw2-fde-glibc.c (_Unwind_IteratePhdrCallback): Likewise. * sysdeps/generic/unwind-dw2-fde.c (_Unwind_Find_FDE): Likewise. (binary_search_single_encoding_fdes, binary_search_mixed_encoding_fdes, get_cie_encoding, linear_search_fdes): Don't mix char and unsigned char pointers.
		
			
				
	
	
		
			69 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			69 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| #include <assert.h>
 | |
| #include <stdio.h>
 | |
| #include <string.h>
 | |
| #include <sys/types.h>
 | |
| 
 | |
| 
 | |
| static int
 | |
| do_test (void)
 | |
| {
 | |
|   int result = 0;
 | |
|   char buf[100];
 | |
|   FILE *fp = fmemopen (buf, sizeof (buf), "w");
 | |
|   if (fp == NULL)
 | |
|     {
 | |
|       puts ("fmemopen failed");
 | |
|       return 0;
 | |
|     }
 | |
|   static const char str[] = "hello world";
 | |
| #define nstr (sizeof (str) - 1)
 | |
|   fputs (str, fp);
 | |
|   off_t o = ftello (fp);
 | |
|   if (o != nstr)
 | |
|     {
 | |
|       printf ("first ftello returned %ld, expected %zu\n", o, nstr);
 | |
|       result = 1;
 | |
|     }
 | |
|   rewind (fp);
 | |
|   o = ftello (fp);
 | |
|   if (o != 0)
 | |
|     {
 | |
|       printf ("second ftello returned %ld, expected 0\n", o);
 | |
|       result = 1;
 | |
|     }
 | |
|   if (fseeko (fp, 0, SEEK_END) != 0)
 | |
|     {
 | |
|       puts ("fseeko failed");
 | |
|       return 1;
 | |
|     }
 | |
|   o = ftello (fp);
 | |
|   if (o != nstr)
 | |
|     {
 | |
|       printf ("third ftello returned %ld, expected %zu\n", o, nstr);
 | |
|       result = 1;
 | |
|     }
 | |
|   rewind (fp);
 | |
|   static const char str2[] = "just hello";
 | |
| #define nstr2 (sizeof (str2) - 1)
 | |
|   assert (nstr2 < nstr);
 | |
|   fputs (str2, fp);
 | |
|   o = ftello (fp);
 | |
|   if (o != nstr2)
 | |
|     {
 | |
|       printf ("fourth ftello returned %ld, expected %zu\n", o, nstr2);
 | |
|       result = 1;
 | |
|     }
 | |
|   fclose (fp);
 | |
|   static const char str3[] = "just hellod";
 | |
|   if (strcmp (buf, str3) != 0)
 | |
|     {
 | |
|       printf ("final string is \"%s\", expected \"%s\"\n",
 | |
|               buf, str3);
 | |
|       result = 1;
 | |
|     }
 | |
|   return result;
 | |
| }
 | |
| 
 | |
| #define TEST_FUNCTION do_test ()
 | |
| #include "../test-skeleton.c"
 |