[Devel] [PATCH vz10 14/15] selftests/uevent: fix -Wmaybe-uninitialized warning in uevent_filtering
Vasileios Almpanis
vasileios.almpanis at virtuozzo.com
Mon Mar 30 11:26:49 MSK 2026
Reviewed-by: Vasileios Almpanis <vasileios.almpanis at virtuozzo.com>
On 3/23/26 9:31 PM, Konstantin Khorenko wrote:
> uevent_filtering.c: In function 'trigger_uevent':
> uevent_filtering.c:217:16: warning: 'ret' may be used uninitialized [-Wmaybe-uninitialized]
> 217 | return ret;
> | ^~~
> uevent_filtering.c:197:17: note: 'ret' was declared here
> 197 | int fd, ret;
> | ^~~
>
> Initialize 'ret' to 0 in trigger_uevent(). If 'times' is 0, the for
> loop body is never entered and 'ret' would be returned uninitialized.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-127529
> Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
>
> Feature: fix selftests
> ---
> tools/testing/selftests/uevent/uevent_filtering.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/uevent/uevent_filtering.c b/tools/testing/selftests/uevent/uevent_filtering.c
> index dbe55f3a66f4..8062804ff759 100644
> --- a/tools/testing/selftests/uevent/uevent_filtering.c
> +++ b/tools/testing/selftests/uevent/uevent_filtering.c
> @@ -194,7 +194,7 @@ static int uevent_listener(unsigned long post_flags, bool expect_uevent,
>
> int trigger_uevent(unsigned int times)
> {
> - int fd, ret;
> + int fd, ret = 0;
> unsigned int i;
>
> fd = open(__DEV_FULL, O_RDWR | O_CLOEXEC);
More information about the Devel
mailing list