Skip to content

Conversation

@aescolar
Copy link
Member

@aescolar aescolar commented Dec 9, 2025

gcc complains about the possibility of ret and gfn being used unitialized (with the input npages == 0).
Let's fix it by initializing ret to 0.

The warnings being:

      zephyr/CMakeFiles/zephyr.dir/drivers/xen/gnttab.c.obj
In file included from include/zephyr/logging/log.h:11,
                 from drivers/xen/gnttab.c:31:
include/zephyr/logging/log_core.h: In function 'gnttab_get_pages':
include/zephyr/logging/log_core.h:221:9: warning: 'gfn' may be used
uninitialized [-Wmaybe-uninitialized]
  221 |         z_log_minimal_printk("%c: " fmt "\n", \
      |         ^~~~~~~~~~~~~~~~~~~~
drivers/xen/gnttab.c:202:19: note: 'gfn' was declared here
  202 |         xen_pfn_t gfn;
      |                   ^~~
include/zephyr/logging/log_core.h:221:9: warning: 'ret' may be used
uninitialized [-Wmaybe-uninitialized]
  221 |         z_log_minimal_printk("%c: " fmt "\n", \
      |         ^~~~~~~~~~~~~~~~~~~~
drivers/xen/gnttab.c:199:13: note: 'ret' was declared here
  199 |         int ret;
      |             ^~~

Introduced in #95934
6 failures in weekly: https://github.com/zephyrproject-rtos/zephyr/actions/runs/19997797171
For example:
https://github.com/zephyrproject-rtos/zephyr/actions/runs/19997797171/job/57348088051#step:14:3364

gcc complains about the posibility of ret and gfn being used
unitialiazed (with the input npages == 0).
Let's fix it by initializing ret to 0.

The warnings being:
```
      zephyr/CMakeFiles/zephyr.dir/drivers/xen/gnttab.c.obj
In file included from include/zephyr/logging/log.h:11,
                 from drivers/xen/gnttab.c:31:
include/zephyr/logging/log_core.h: In function 'gnttab_get_pages':
include/zephyr/logging/log_core.h:221:9: warning: 'gfn' may be used
uninitialized [-Wmaybe-uninitialized]
  221 |         z_log_minimal_printk("%c: " fmt "\n", \
      |         ^~~~~~~~~~~~~~~~~~~~
drivers/xen/gnttab.c:202:19: note: 'gfn' was declared here
  202 |         xen_pfn_t gfn;
      |                   ^~~
include/zephyr/logging/log_core.h:221:9: warning: 'ret' may be used
uninitialized [-Wmaybe-uninitialized]
  221 |         z_log_minimal_printk("%c: " fmt "\n", \
      |         ^~~~~~~~~~~~~~~~~~~~
drivers/xen/gnttab.c:199:13: note: 'ret' was declared here
  199 |         int ret;
      |             ^~~
```

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
@aescolar aescolar marked this pull request as ready for review December 9, 2025 12:22
@aescolar aescolar requested a review from soburi December 9, 2025 12:24
@zephyrbot zephyrbot added area: Xen Platform size: XS A PR changing only a single line of code labels Dec 9, 2025
@aescolar aescolar added the backport v4.3-branch Request backport to the v4.3-branch label Dec 9, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 9, 2025

Copy link

@lorc lorc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like GCC bug for me. if npages==0, function exits at L205, without even accessing ret and gfn.

I think, this needs comment in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Xen Platform backport v4.3-branch Request backport to the v4.3-branch size: XS A PR changing only a single line of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants