about summary refs log tree commit diff
path: root/debug/tst-chk1.c
diff options
context:
space:
mode:
Diffstat (limited to 'debug/tst-chk1.c')
-rw-r--r--debug/tst-chk1.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index 26ace28970..78a61be53b 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -49,7 +49,7 @@ do_prepare (void)
     }
 
   const char *strs = "abcdefgh\nABCDEFGHI\nabcdefghij\nABCDEFGHIJ";
-  if (write (temp_fd, strs, strlen (strs)) != strlen (strs))
+  if ((size_t) write (temp_fd, strs, strlen (strs)) != strlen (strs))
     {
       puts ("could not write test strings into file");
       unlink (temp_filename);
@@ -102,7 +102,7 @@ int num2 = 987654;
       chk_fail_ok = 0;				\
       FAIL ();					\
     }
-#if __USE_FORTIFY_LEVEL >= 2
+#if __USE_FORTIFY_LEVEL >= 2 && (!defined __cplusplus || defined __va_arg_pack)
 #define CHK_FAIL2_START CHK_FAIL_START
 #define CHK_FAIL2_END CHK_FAIL_END
 #else
@@ -142,6 +142,12 @@ do_test (void)
 #endif
 	  );
 
+#if defined __USE_FORTIFY_LEVEL && !defined __extern_always_inline
+  printf ("Test skipped");
+  if (l0 == 0)
+    return 0;
+#endif
+
   /* These ops can be done without runtime checking of object size.  */
   memcpy (buf, "abcdefghij", 10);
   memmove (buf + 1, buf, 9);
@@ -280,7 +286,7 @@ do_test (void)
   CHK_FAIL_END
 
   CHK_FAIL_START
-  p = mempcpy (buf + 6, "abcde", l0 + 5);
+  p = (char *) mempcpy (buf + 6, "abcde", l0 + 5);
   CHK_FAIL_END
 
   CHK_FAIL_START
@@ -303,6 +309,7 @@ do_test (void)
   stpncpy (buf + 6, "cd", l0 + 5);
   CHK_FAIL_END
 
+# if !defined __cplusplus || defined __va_arg_pack
   CHK_FAIL_START
   sprintf (buf + 8, "%d", num1);
   CHK_FAIL_END
@@ -310,6 +317,7 @@ do_test (void)
   CHK_FAIL_START
   snprintf (buf + 8, l0 + 3, "%d", num2);
   CHK_FAIL_END
+# endif
 
   memcpy (buf, str1 + 2, l0 + 9);
   CHK_FAIL_START
@@ -330,18 +338,18 @@ do_test (void)
   CHK_FAIL_END
 
   CHK_FAIL_START
-  p = mempcpy (a.buf1 + 6, "abcde", l0 + 5);
+  p = (char *) mempcpy (a.buf1 + 6, "abcde", l0 + 5);
   CHK_FAIL_END
 
   CHK_FAIL_START
   memset (a.buf1 + 9, 'j', l0 + 2);
   CHK_FAIL_END
 
-#if __USE_FORTIFY_LEVEL >= 2
-# define O 0
-#else
-# define O 1
-#endif
+# if __USE_FORTIFY_LEVEL >= 2
+#  define O 0
+# else
+#  define O 1
+# endif
 
   CHK_FAIL_START
   strcpy (a.buf1 + (O + 4), str1 + 5);
@@ -355,6 +363,7 @@ do_test (void)
   strncpy (a.buf1 + (O + 6), "X", l0 + 4);
   CHK_FAIL_END
 
+# if !defined __cplusplus || defined __va_arg_pack
   CHK_FAIL_START
   sprintf (a.buf1 + (O + 7), "%d", num1);
   CHK_FAIL_END
@@ -362,6 +371,7 @@ do_test (void)
   CHK_FAIL_START
   snprintf (a.buf1 + (O + 7), l0 + 3, "%d", num2);
   CHK_FAIL_END
+# endif
 
   memcpy (a.buf1, str1 + (3 - O), l0 + 8 + O);
   CHK_FAIL_START
@@ -919,7 +929,8 @@ do_test (void)
   else
     {
       const char *sendstr = "abcdefgh\nABCDEFGH\n0123456789\n";
-      if (send (sp[0], sendstr, strlen (sendstr), 0) != strlen (sendstr))
+      if ((size_t) send (sp[0], sendstr, strlen (sendstr), 0)
+	  != strlen (sendstr))
 	FAIL ();
 
       char recvbuf[12];
@@ -951,29 +962,30 @@ do_test (void)
       struct sockaddr_un sa_un;
 
       sl = sizeof (sa_un);
-      if (recvfrom (sp[1], recvbuf, sizeof recvbuf, MSG_PEEK, &sa_un, &sl)
+      if (recvfrom (sp[1], recvbuf, sizeof recvbuf, MSG_PEEK,
+		    (struct sockaddr *) &sa_un, &sl)
 	  != sizeof recvbuf
 	  || memcmp (recvbuf, sendstr, sizeof recvbuf) != 0)
 	FAIL ();
 
       sl = sizeof (sa_un);
       if (recvfrom (sp[1], recvbuf + 6, l0 + sizeof recvbuf - 7, MSG_PEEK,
-	  &sa_un, &sl) != sizeof recvbuf - 7
+		    (struct sockaddr *) &sa_un, &sl) != sizeof recvbuf - 7
 	  || memcmp (recvbuf + 6, sendstr, sizeof recvbuf - 7) != 0)
 	FAIL ();
 
 #if __USE_FORTIFY_LEVEL >= 1
       CHK_FAIL_START
       sl = sizeof (sa_un);
-      if (recvfrom (sp[1], recvbuf + 1, sizeof recvbuf, MSG_PEEK, &sa_un, &sl)
-	  != sizeof recvbuf)
+      if (recvfrom (sp[1], recvbuf + 1, sizeof recvbuf, MSG_PEEK,
+		    (struct sockaddr *) &sa_un, &sl) != sizeof recvbuf)
 	FAIL ();
       CHK_FAIL_END
 
       CHK_FAIL_START
       sl = sizeof (sa_un);
       if (recvfrom (sp[1], recvbuf + 4, l0 + sizeof recvbuf - 3, MSG_PEEK,
-	  &sa_un, &sl) != sizeof recvbuf - 3)
+		    (struct sockaddr *) &sa_un, &sl) != sizeof recvbuf - 3)
 	FAIL ();
       CHK_FAIL_END
 #endif