The branch main has been updated by rlibby: URL: https://cgit.FreeBSD.org/src/commit/?id=2e33355ee2bfa0b6d7b61aeca66d9b2b2b7b9e56
commit 2e33355ee2bfa0b6d7b61aeca66d9b2b2b7b9e56 Author: Ryan Libby <[email protected]> AuthorDate: 2026-09-05 22:45:39 +0000 Commit: Ryan Libby <[email protected]> CommitDate: 2026-09-06 00:58:36 +0000 pmc: avoid illegal flexible array member Remove struct pmchdr_cpuidinfo which was just a wrapper around a flexible array member of uint32_t. Flexible array members are non-standard in C++, and even in C are not allowed as the only member of a struct. GCC errored out on pmchdr_cpuidinfo, but did not complain about pmchdr_pmcinfo, so I left it alone here, though it is also non-standard. Fixes: 93da997ef759 ("pmc: new pmc log processing framework") Reviewed by: Ali Mashtizadeh <[email protected]> Differential Revision: https://reviews.freebsd.org/D59355 --- usr.sbin/pmc/headers.hh | 5 ----- usr.sbin/pmc/view.cc | 14 +++++++------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/usr.sbin/pmc/headers.hh b/usr.sbin/pmc/headers.hh index 6bdabc4fbe6c..175954d3dcaf 100644 --- a/usr.sbin/pmc/headers.hh +++ b/usr.sbin/pmc/headers.hh @@ -74,10 +74,5 @@ struct pmchdr_pmcinfo char pmc[]; }; -struct pmchdr_cpuidinfo -{ - uint32_t cpuid[]; -}; - #endif diff --git a/usr.sbin/pmc/view.cc b/usr.sbin/pmc/view.cc index f3585ac75043..d633b6737e34 100644 --- a/usr.sbin/pmc/view.cc +++ b/usr.sbin/pmc/view.cc @@ -177,12 +177,12 @@ int pmcview::process_cpuidinfo(int logfd, const pmchdr_infohdr &infohdr) { int status; - pmchdr_cpuidinfo *cpuidinfo; + uint32_t *cpuidinfo; int offset, len; uint32_t root, maxleaf, count; len = infohdr.length / 4; - cpuidinfo = (pmchdr_cpuidinfo *)new uint32_t[len]; + cpuidinfo = new uint32_t[len]; status = readlog(logfd, cpuidinfo, infohdr.length); if (status < 0 || status != infohdr.length) @@ -191,7 +191,7 @@ pmcview::process_cpuidinfo(int logfd, const pmchdr_infohdr &infohdr) offset = 0; while (offset < len) { - maxleaf = cpuidinfo->cpuid[offset]; + maxleaf = cpuidinfo[offset]; /* * In x86 the roots contains the maximum leaf number present. @@ -200,10 +200,10 @@ pmcview::process_cpuidinfo(int logfd, const pmchdr_infohdr &infohdr) count = maxleaf & 0x0000FFFF; for (uint32_t i = 0; i <= count; i++) { - cpuid[root + i] = { cpuidinfo->cpuid[4 * i + offset], - cpuidinfo->cpuid[4 * i + 1 + offset], - cpuidinfo->cpuid[4 * i + 2 + offset], - cpuidinfo->cpuid[4 * i + 3 + offset] }; + cpuid[root + i] = { cpuidinfo[4 * i + offset], + cpuidinfo[4 * i + 1 + offset], + cpuidinfo[4 * i + 2 + offset], + cpuidinfo[4 * i + 3 + offset] }; } offset += 4 * (count + 1);
