[systemd-devel] [PATCH] shared: fix utf16_to_utf8() on big endian machines

Tom Gundersen teg at jklm.no
Wed Feb 18 05:34:29 PST 2015


On Wed, Feb 18, 2015 at 6:54 AM, Martin Pitt <martin.pitt at ubuntu.com> wrote:
> 219 shows a test failure in test-utf8 on big-endian machines (on
> Debian: powerpc, s390, mips):
>
> Assertion 'streq(a, utf8)' failed at src/test/test-utf8.c:103, function test_utf16_to_utf8(). Aborting.
>
> gdb shows that indeed the converted string is utter bogus. a is the
> converted string, utf8 the expected outcome:
>
> | Program received signal SIGABRT, Aborted.
> | 0x20319c48 in raise () from /lib/powerpc-linux-gnu/libc.so.6
> | (gdb) f 3
> | #3  0x204befbc in test_utf16_to_utf8 () at src/test/test-utf8.c:103
> | 103             assert_se(streq(a, utf8));
> | (gdb) p a
> | $1 = 0x204eb068 "\346\204\200\303\230\346\210\200\303\234\346\214\200\307\230\343\237\234"
> | (gdb) p utf8
> | $2 = "abc\360\220\220\267"
>
> Patch against master attached, tested on both little-endian (unchanged
> behaviour/code) and big-endian machine.
>
> CC'ing Tom for reviewing, as that was introduced in
> http://cgit.freedesktop.org/systemd/systemd/commit/?id=04166cb7d and
> he might still have the UTF-16 stuff in his head :-)

I think we want to assume that we only get UTF-16LE, so it looks like
it is the test that is buggy. That's what we agreed, right Lennart?

How about the attached patch?

Cheers,

Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-test-utf8-fix-utf16-tests-on-BE-machines.patch
Type: text/x-patch
Size: 921 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150218/56ec5f26/attachment.bin>


More information about the systemd-devel mailing list