examples/qos_sched: fix build with LTO
PATCH 1/1 examples/qos_sched: fix build with LTO
rte_cfgfile_section_num_entries() returns -1 on error, which is used unchecked as a VLA size. With LTO gcc inlines the library call, sees the -1 path and fails with -Wvla-larger-than.
Return error if the entry count is negative.
--- examples/qos_sched/cfg_file.c | 3 +++ 1 file changed, 3 insertions(+)
examples/qos_sched/cfg_file.c +3 -0
@@ -438,6 +438,9 @@ cfg_load_subport(struct rte_cfgfile *cfg) }int n_entries =rte_cfgfile_section_num_entries (cfg, sec_name); +if (n_entries <0 ) +return -1 ; +struct rte_cfgfile_entry entries[n_entries];rte_cfgfile_section_entries (cfg, sec_name, entries, n_entries);
Signature · 1 line
2.53.0
Quoted 19 lines · Stephen Hemminger
rte_cfgfile_section_num_entries()returns -1 on error, which is used unchecked as a VLA size. With LTO gcc inlines the library call, sees the -1 path and fails with -Wvla-larger-than.Return error if the entry count is negative.
Fixes db935d0171dd ("examples/qos_sched: use librte_cfgfile")Signed-off-by Stephen Hemminger <[email protected]>--- examples/qos_sched/cfg_file.c | 3 +++ 1 file changed, 3 insertions(+)examples/qos_sched/cfg_file.c +0
-0
examples/qos_sched/cfg_file.c cfg_load_subport(struct rte_cfgfile *cfg) · line 444
Quoted 7 lines
examples/qos_sched/cfg_file.c +3
-0@@ -438,6 +438,9 @@ cfg_load_subport(struct rte_cfgfile *cfg) }int n_entries =rte_cfgfile_section_num_entries (cfg, sec_name); +if (n_entries <0 ) +return -1 ; +struct rte_cfgfile_entry entries[n_entries];
In practice I don't think that error case can occur, since an earlier check verifies that the section exists. However, the check is harmless and not on a fast-path.
Thomas Monjalon
Applied10/11/2026 10:05, Bruce Richardson:
Quoted 5 lines · Stephen Hemminger
Quoted 4 lines
rte_cfgfile_section_num_entries()returns -1 on error, which is used unchecked as a VLA size. With LTO gcc inlines the library call, sees the -1 path and fails with -Wvla-larger-than.
Quoted 8 lines
Quoted 6 lines
Return error if the entry count is negative.
Fixes db935d0171dd ("examples/qos_sched: use librte_cfgfile")Signed-off-by Stephen Hemminger <[email protected]>Acked-by Bruce Richardson <[email protected]>
Applied, thanks.