diff options
author | Michael Brown | 2016-04-12 12:51:05 +0200 |
---|---|---|
committer | Michael Brown | 2016-04-12 12:53:06 +0200 |
commit | cc8824ad4e9486b9fa64f1b1d078ff1963f71219 (patch) | |
tree | 2b170bde860ac5b91d44ddb9ad6a4fcbe605810b /src/tests | |
parent | [test] Update snprintf_ok() to use okx() (diff) | |
download | ipxe-cc8824ad4e9486b9fa64f1b1d078ff1963f71219.tar.gz ipxe-cc8824ad4e9486b9fa64f1b1d078ff1963f71219.tar.xz ipxe-cc8824ad4e9486b9fa64f1b1d078ff1963f71219.zip |
[libc] Print "<NULL>" for wide-character NULL strings
The existing code intends to print NULL strings as "<NULL>" (for the
sake of debug messages), but the logic is incorrect when handling
wide-character strings. Fix the logic and add applicable unit tests.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/vsprintf_test.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/tests/vsprintf_test.c b/src/tests/vsprintf_test.c index ad732a0d..f388b3de 100644 --- a/src/tests/vsprintf_test.c +++ b/src/tests/vsprintf_test.c @@ -108,6 +108,10 @@ static void vsprintf_test_exec ( void ) { snprintf_ok ( 64, "PCI 00:1f.3", "PCI %02x:%02x.%x", 0x00, 0x1f, 0x03 ); snprintf_ok ( 64, "Region [1000000,3f000000)", "Region [%llx,%llx)", 0x1000000ULL, 0x3f000000ULL ); + + /* Null string (used for debug messages) */ + snprintf_ok ( 16, "<NULL>", "%s", ( ( char * ) NULL ) ); + snprintf_ok ( 16, "<NULL>", "%ls", ( ( wchar_t * ) NULL ) ); } /** vsprintf() self-test */ |