]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_scrub: use proper UChar string iterators
authorDarrick J. Wong <djwong@kernel.org>
Mon, 29 Jul 2024 23:23:09 +0000 (16:23 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:08 +0000 (17:01 -0700)
For code that wants to examine a UChar string, use libicu's string
iterators to walk UChar strings, instead of the open-coded U16_NEXT*
macros that perform no typechecking.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
scrub/unicrash.c

index dd30164354e3da65f968cd4c1ff6075cb7ab5133..02a1b94efb4de4f4d81360b0867cac8442a83d0a 100644 (file)
@@ -330,13 +330,12 @@ name_entry_examine(
        struct name_entry       *entry,
        unsigned int            *badflags)
 {
+       UCharIterator           uiter;
        UChar32                 uchr;
-       int32_t                 i;
        uint8_t                 mask = 0;
 
-       for (i = 0; i < entry->normstrlen;) {
-               U16_NEXT_UNSAFE(entry->normstr, i, uchr);
-
+       uiter_setString(&uiter, entry->normstr, entry->normstrlen);
+       while ((uchr = uiter_next32(&uiter)) != U_SENTINEL) {
                /* zero width character sequences */
                switch (uchr) {
                case 0x200B:    /* zero width space */