• Nathan Chancellor's avatar
    io_uring: Ensure mask is initialized in io_arm_poll_handler · 8755d97a
    Nathan Chancellor authored
    Clang warns:
    
    fs/io_uring.c:4178:6: warning: variable 'mask' is used uninitialized
    whenever 'if' condition is false [-Wsometimes-uninitialized]
            if (def->pollin)
                ^~~~~~~~~~~
    fs/io_uring.c:4182:2: note: uninitialized use occurs here
            mask |= POLLERR | POLLPRI;
            ^~~~
    fs/io_uring.c:4178:2: note: remove the 'if' if its condition is always
    true
            if (def->pollin)
            ^~~~~~~~~~~~~~~~
    fs/io_uring.c:4154:15: note: initialize the variable 'mask' to silence
    this warning
            __poll_t mask, ret;
                         ^
                          = 0
    1 warning generated.
    
    io_op_defs has many definitions where pollin is not set so mask indeed
    might be uninitialized. Initialize it to zero and change the next
    assignment to |=, in case further masks are added in the future to avoid
    missing changing the assignment then.
    
    Fixes: d7718a9d ("io_uring: use poll driven retry for files that support it")
    Link: https://github.com/ClangBuiltLinux/linux/issues/916Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    8755d97a
io_uring.c 175 KB