It may trigger the following warning:

xattr.c: In function ‘erofs_xattr_iter_inline.constprop’:
xattr.c:1349:13: error: ‘ret’ may be used uninitialized in this function 
[-Werror=maybe-uninitialized]
 1349 |         int ret;
      |             ^~~

'remaining' is always greater than 0. Switch to a do-while loop
to eliminate this false-positive warning.

Signed-off-by: Gao Xiang <[email protected]>
---
 lib/xattr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/xattr.c b/lib/xattr.c
index 86f2e45b09b2..565070a698dc 100644
--- a/lib/xattr.c
+++ b/lib/xattr.c
@@ -1358,7 +1358,7 @@ static int erofs_xattr_iter_inline(struct 
erofs_xattr_iter *it,
        erofs_init_metabuf(&it->buf, it->sbi, erofs_inode_in_metabox(vi));
        remaining = vi->xattr_isize - xattr_header_sz;
        it->pos = erofs_iloc(vi) + vi->inode_isize + xattr_header_sz;
-       while (remaining) {
+       do {
                it->kaddr = erofs_bread(&it->buf, it->pos, true);
                if (IS_ERR(it->kaddr))
                        return PTR_ERR(it->kaddr);
@@ -1380,7 +1380,7 @@ static int erofs_xattr_iter_inline(struct 
erofs_xattr_iter *it,
                        break;
 
                it->pos = next_pos;
-       }
+       } while (remaining);
        return ret;
 }
 
-- 
2.43.5


Reply via email to