Skip to content

Conversation

@github-actions
Copy link

@github-actions github-actions bot commented Dec 11, 2025

Backport 139b7c2 from #100737.

Fixes #101048

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 <[email protected]>
(cherry picked from commit 139b7c2)
@github-actions github-actions bot added the Backport Backport PR and backport failure issues label Dec 11, 2025
@github-project-automation github-project-automation bot moved this to To do in Backports Dec 11, 2025
@JarmouniA JarmouniA closed this Dec 11, 2025
@github-project-automation github-project-automation bot moved this from To do to Done in Backports Dec 11, 2025
@JarmouniA JarmouniA reopened this Dec 11, 2025
@github-project-automation github-project-automation bot moved this from Done to Needs more info in Backports Dec 11, 2025
@JarmouniA JarmouniA added this to the v4.3.1 milestone Dec 11, 2025
@zephyrbot zephyrbot added area: Xen Platform size: XS A PR changing only a single line of code labels Dec 11, 2025
@sonarqubecloud
Copy link

@jhedberg
Copy link
Member

@aescolar @firscity this needs a bug report

@jhedberg jhedberg moved this from Needs more info to Needs a bug report in Backports Dec 12, 2025
@firscity
Copy link
Contributor

@aescolar I'm a little bit confused by this, as I can see in #100737 and in logs CI was not happy with 2 variables uninitialized:

      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;
      |             ^~~

But the only ret was fixed by you. Is CI happy now?
I have doubts for both of them, current function flow has no chance to use them uninitialized, but still it is OK to initialize them on declaration. I just need to clarify if initialization of ret helped to fix the CI issue with gfn also. If so - it becomes much more odd...

@aescolar
Copy link
Member

aescolar commented Dec 15, 2025

@aescolar I'm a little bit confused by this, as I can see in #100737 and in logs CI was not happy with 2 variables uninitialized:
...
But the only ret was fixed by you. Is CI happy now?

Yes.
The warning for non-itialiazed gfn was in the 229-240 block, which depends on ret != 0.
The compiler seemed to be happy with either initializing ret to 0, or moving that block into line 224 just before the break.
It really seemed the compiler issue was with the possibility of the for loop being skipped. But if ret is initialized to 0, that lower if block is also skipped as it should.

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

Labels

area: Xen Platform Backport Backport PR and backport failure issues size: XS A PR changing only a single line of code

Projects

Status: Needs a bug report

Development

Successfully merging this pull request may close these issues.

6 participants