public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Fix test-strchr.c warnings for wide string testing
@ 2014-11-26  0:17 Joseph Myers
  2014-11-26  9:39 ` Will Newton
  2014-11-26 10:17 ` Andreas Schwab
  0 siblings, 2 replies; 3+ messages in thread
From: Joseph Myers @ 2014-11-26  0:17 UTC (permalink / raw)
  To: libc-alpha

string/test-strchr.c is used for both wide and narrow string testing,
but produces a series of warnings for wide string testing because of
hardcoded use of narrow characters in the function check1.  This patch
fixes that function to use macros abstracting away the wide / narrow
string choice, adding a new such macro to handle the string and
character constants.

Tested for x86_64.

2014-11-26  Joseph Myers  <joseph@codesourcery.com>

	* string/test-strchr.c [!WIDE] (L): New macro.
	[WIDE] (L): Likewise.
	(check1): Use CHAR instead of char.  Use L on string and character
	constants.

diff --git a/string/test-strchr.c b/string/test-strchr.c
index 12cd9d8..fe2dfd2 100644
--- a/string/test-strchr.c
+++ b/string/test-strchr.c
@@ -44,6 +44,7 @@
 # define MIDDLE_CHAR 127
 # define SMALL_CHAR 23
 # define UCHAR unsigned char
+# define L(s) s
 #else
 # include <wchar.h>
 # define STRCHR wcschr
@@ -53,6 +54,7 @@
 # define MIDDLE_CHAR 1121
 # define SMALL_CHAR 851
 # define UCHAR wchar_t
+# define L(s) L ## s
 #endif
 
 #ifdef USE_FOR_STRCHRNUL
@@ -219,9 +221,9 @@ do_random_tests (void)
 static void
 check1 (void)
 {
-  char s[] __attribute__((aligned(16))) = "\xff";
-  char c = '\xfe';
-  char *exp_result = stupid_STRCHR (s, c);
+  CHAR s[] __attribute__((aligned(16))) = L ("\xff");
+  CHAR c = L ('\xfe');
+  CHAR *exp_result = stupid_STRCHR (s, c);
 
   FOR_EACH_IMPL (impl, 0)
     check_result (impl, s, c, exp_result);

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-26 10:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-26  0:17 Fix test-strchr.c warnings for wide string testing Joseph Myers
2014-11-26  9:39 ` Will Newton
2014-11-26 10:17 ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).