diff mbox series

Fix wide char format specifier in libio/tst-bz24153.c.

Message ID 254ace6c-4f93-7c75-cef5-f466e8360e06@linux.ibm.com
State New
Headers show
Series Fix wide char format specifier in libio/tst-bz24153.c. | expand

Commit Message

Stefan Liebler Feb. 6, 2019, 8:26 a.m. UTC
Hi,

on big endian systems the test fails with:
tst-bz24153.c:88: numeric comparison failure
    left: 1660944385 (0x63000001); from: ch
   right: 99 (0x63); from: L'c'
tst-bz24153.c:90: numeric comparison failure
    left: 1677721601 (0x64000001); from: ch
   right: 100 (0x64); from: L'd'
error: 2 test failures

One 'char' ("%c") is stored to the pointer 'wchar_t *':
ch = 0x00000001 | 0x63000000

This patch is using "%lc" as format specifier to read a wchar_t.

Okay to commit?

Bye,
Stefan

ChangeLog:

	* libio/tst-bz24153.c (wide): Use wide char format specifier.

Comments

Florian Weimer Feb. 6, 2019, 9:33 a.m. UTC | #1
* Stefan Liebler:

> 	* libio/tst-bz24153.c (wide): Use wide char format specifier.

Looks good.  Sorry about that.

Thanks,
Florian
Andreas Schwab Feb. 6, 2019, 9:34 a.m. UTC | #2
On Feb 06 2019, Stefan Liebler <stli@linux.ibm.com> wrote:

> 	* libio/tst-bz24153.c (wide): Use wide char format specifier.

Ok.

Btw., there is already GCC bug 38308 about implementing format checking
for wide strings.

Andreas.
Stefan Liebler Feb. 6, 2019, 11:33 a.m. UTC | #3
Committed.
Thanks for the review.
diff mbox series

Patch

commit 6e7024f01e6aa344dc560027bcc2bd6e0ee41e5b
Author: Stefan Liebler <stli@linux.ibm.com>
Date:   Tue Feb 5 16:55:00 2019 +0100

    Fix wide char format specifier in libio/tst-bz24153.c.
    
    On big endian systems the test fails with:
    tst-bz24153.c:88: numeric comparison failure
       left: 1660944385 (0x63000001); from: ch
      right: 99 (0x63); from: L'c'
    tst-bz24153.c:90: numeric comparison failure
       left: 1677721601 (0x64000001); from: ch
      right: 100 (0x64); from: L'd'
    error: 2 test failures
    
    One 'char' ("%c") is stored to the 'wchar_t *':
    ch = 0x00000001 | 0x63000000
    
    This patch is using "%lc" as format specifier to read a wchar_t.
    
    ChangeLog:
    
            * libio/tst-bz24153.c (wide): Use wide char format specifier.

diff --git a/libio/tst-bz24153.c b/libio/tst-bz24153.c
index 85ad1415df..be0e6bfcf1 100644
--- a/libio/tst-bz24153.c
+++ b/libio/tst-bz24153.c
@@ -84,9 +84,9 @@  wide (const char *path)
   TEST_COMPARE (getwchar (), L'a');
   TEST_COMPARE (getwchar_unlocked (), L'b');
   wchar_t ch = 1;
-  TEST_COMPARE (wscanf (L"%c", &ch), 1);
+  TEST_COMPARE (wscanf (L"%lc", &ch), 1);
   TEST_COMPARE (ch, L'c');
-  TEST_COMPARE (call_vwscanf (L"%c", &ch), 1);
+  TEST_COMPARE (call_vwscanf (L"%lc", &ch), 1);
   TEST_COMPARE (ch, L'd');
 
   fclose (stdin);