1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

Fix test-strchr.c warnings for wide string testing.

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.

	* string/test-strchr.c [!WIDE] (L): New macro.
	[WIDE] (L): Likewise.
	(check1): Use CHAR instead of char.  Use L on string and character
	constants.
This commit is contained in:
Joseph Myers
2014-11-26 12:52:08 +00:00
parent 704f794714
commit 3b20fd5c0d
2 changed files with 12 additions and 3 deletions

View File

@ -1,3 +1,10 @@
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.
2014-11-26 Adhemerval Zanella <azanella@linux.ibm.com> 2014-11-26 Adhemerval Zanella <azanella@linux.ibm.com>
* csu/tst-atomic.c (do_test): Add atomic_exchange_and_add_{acq,rel} * csu/tst-atomic.c (do_test): Add atomic_exchange_and_add_{acq,rel}

View File

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