Page MenuHomeFreeBSD

Fix gcc warnings
AbandonedPublic

Authored by ngie on Jul 7 2016, 4:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 20 2023, 6:41 AM
Unknown Object (File)
Nov 15 2023, 11:37 AM
Unknown Object (File)
Nov 11 2023, 2:30 AM
Unknown Object (File)
Nov 10 2023, 9:44 PM
Unknown Object (File)
Nov 8 2023, 10:57 PM
Unknown Object (File)
Nov 8 2023, 9:48 PM
Unknown Object (File)
Nov 8 2023, 4:22 PM
Unknown Object (File)
Nov 7 2023, 2:51 AM
Subscribers

Details

Reviewers
grehan
neel
Summary

Fix gcc warnings

  • KASSERTs are optimized out in !INVARIANTS cases, so don't test those variables in those cases to fix -Wunused-but-set-variable warnings.
  • Similarly, *CTR* are optimized out in the !KTR cases, so don't test those variables in those cases to fix -Wunused-but-set-variable warnings.
  • vintr_intercept_enabled(..) is only usable in the INVARIANTS case; only define/call it in that case.
  • Remove -Wunused-but-set-variable, func, in vmx_handle_cpuid(..).
  • alloc_memseg(..):
    • Explicitly save off the value of VM_MEMSEG_NAME(mseg) to namep and test for it being non-NULL to avoid a false positive error from gcc with passing the value in to copystr(..).
  • get_gla(..):
    • explicitly test error after KASSERTs to ensure less "bad things" happen if/when the code is run with !INVARIANTS kernels.
    • return error when setting fault to 1; both cases are tested in the calling function, so there's no adverse affect for doing that.
  • x86_emulate_cpuid(..):
    • Explicitly set logical_cpus/x2apic_id to sane values to fix -Wmaybe-uninitialized warnings.
    • Move width definition to CPUID_0000_000B case and initialize it to a sane value to fix a -Wmaybe-uninitialized warning.

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division

Test Plan
  • buildkernel with vmm compiled in to GENERIC/GENERIC-NODEBUG.
  • vmm(4) compiled as a module in both of the above cases.
  • Using bhyve from GENERIC/GENERIC-NODEBUG, like:

sudo /usr/src/svn/share/examples/bhyve/vmrun.sh -I ~/nfs/FreeBSD-10.3-RELEASE-i386-bootonly.iso ten_dot_3

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 4451
Build 4502: arc lint + arc unit

Event Timeline

ngie retitled this revision from to Fix gcc warnings.
ngie updated this object.
ngie edited the test plan for this revision. (Show Details)
ngie added reviewers: grehan, neel.
ngie added subscribers: markj, cem.
sys/conf/kern.mk
65 ↗(On Diff #18206)

This shouldn't be in the diff.

Remove kern.mk portion of diff [accidentally included in this CR]
which was committed as rS302403.

ngie marked an inline comment as done.Jul 7 2016, 10:49 PM

Try again after running svn up. The first attempt didn't work

The conditional code is a bit invasive - would it be better just to put an "__unused" attribute on the variables in question ?

The conditional code is a bit invasive - would it be better just to put an "__unused" attribute on the variables in question ?

Probably. It seems like a macro should be added for this that would add it in the !INVARIANTS case (and it should be generalized).

Abandoning revision due to lack of interest.

I emailed on 7/16/2016 asking for help on running gcc and didn't get a response.

I emailed on 7/16/2016 asking for help on running gcc and didn't get a response.

I meant submitter (me) interest. Sorry :(...

This should repro it with the latest gcc:

pkg install -fy amd64-gcc
(set -e; cd sys/modules/vmm; export CC=/usr/local/bin/x86_64-unknown-freebsd12.0-gcc MAKEFLAGS=-s; make obj; make depend; make all)

Thanks for the info. I'll see if I can move this forward under a different phab review.

Peter: This seems like a common case (idiom) that we should maybe solve without a huge number of #ifdef INVARIANTS, maybe by a new macro that does the right thing in the !INVARIANTS case?

That was mentioned in earlier review comments. Maybe something like a kassert_decl attribute (expanding to unused if INVARIANTS not defined) ?