Page MenuHomeFreeBSD

libkvm: fix warning issues post-r291406
ClosedPublic

Authored by ngie on Mar 21 2017, 4:53 AM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 7 2023, 10:38 AM
Unknown Object (File)
Sep 30 2023, 9:30 PM
Unknown Object (File)
Sep 5 2023, 3:52 AM
Unknown Object (File)
Aug 25 2023, 8:30 PM
Unknown Object (File)
Jun 27 2023, 7:09 AM
Unknown Object (File)
Jun 12 2023, 4:45 AM
Unknown Object (File)
May 29 2023, 7:05 PM
Unknown Object (File)
May 5 2023, 11:56 AM

Details

Summary

libkvm: fix warning issues post-r291406

  • Fix -Wunused warnings with *_native detection handlers by marking kd __unused, except with arm/mips, where a slightly more complicated scheme is required to handle the native case vs the non-native case.
  • Fix -Wmissing-variable-declarations warnings by marking struct kvm_arch objects static.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

Test Plan
  • clang 4.0.0, gcc 4.2.1, gcc 6.3.0 passed
  • make tinderbox running (most architectures have completed successfully; waiting for a few to finish).
  • cross-debugging test:
    • Did sysctl debug.kdb.enter=1
    • Did doadump to dump core.
    • Did c when complete to exit ddb and go back to userland.
    • Ran service savecore start to dump core from swap to /var/crash.
    • Put core/kernel over NFS, served up to amd64 VM.
    • Ran kgdb7121 as shown (which has cross-debugging support built in):
$ kgdb7121 ~/nfs/GENERIC-NODEBUG-r315659M-12.0-i386/kernel ~/nfs/vmcore-12.0-i386-r315659M
GNU gdb (GDB) 7.12.1 [GDB v7.12.1 for FreeBSD]
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd12.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/ngie/nfs/GENERIC-NODEBUG-r315659M-12.0-i386/kernel...(no debugging symbols found)...done.
warning: `/usr/local/lib/vmware-tools/modules/drivers/vmmemctl.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/usr/local/lib/vmware-tools/modules/drivers/vmxnet.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/usr/local/lib/vmware-tools/modules/drivers/vmblock.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/boot/kernel/nullfs.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/boot/modules/ctl.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/boot/kernel/geom_concat.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/boot/kernel/geom_eli.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/boot/kernel/geom_gate.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/boot/kernel/geom_mirror.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/boot/kernel/geom_nop.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/boot/kernel/geom_raid3.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/boot/kernel/geom_shsec.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/boot/kernel/geom_stripe.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/boot/kernel/geom_uzip.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/boot/kernel/tmpfs.ko': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
Reading symbols from /home/ngie/nfs/GENERIC-NODEBUG-r315659M-12.0-i386/fdescfs.ko...(no debugging symbols found)...done.
Reading symbols from /usr/local/lib/vmware-tools/modules/drivers/vmmemctl.ko...(no debugging symbols found)...done.
Reading symbols from /usr/local/lib/vmware-tools/modules/drivers/vmxnet.ko...(no debugging symbols found)...done.
Reading symbols from /usr/local/lib/vmware-tools/modules/drivers/vmblock.ko...(no debugging symbols found)...done.
Reading symbols from /boot/kernel/nullfs.ko...(no debugging symbols found)...done.
Reading symbols from /boot/modules/ctl.ko...(no debugging symbols found)...done.
Reading symbols from /boot/kernel/geom_concat.ko...(no debugging symbols found)...done.
Reading symbols from /boot/kernel/geom_eli.ko...(no debugging symbols found)...done.
Reading symbols from /boot/kernel/geom_gate.ko...(no debugging symbols found)...done.
Reading symbols from /boot/kernel/geom_mirror.ko...(no debugging symbols found)...done.
Reading symbols from /boot/kernel/geom_nop.ko...(no debugging symbols found)...done.
Reading symbols from /boot/kernel/geom_raid3.ko...(no debugging symbols found)...done.
Reading symbols from /boot/kernel/geom_shsec.ko...(no debugging symbols found)...done.
Reading symbols from /boot/kernel/geom_stripe.ko...(no debugging symbols found)...done.
Reading symbols from /boot/kernel/geom_uzip.ko...(no debugging symbols found)...done.
Reading symbols from /boot/kernel/tmpfs.ko...(no debugging symbols found)...done.
0xc0c5a0eb in doadump ()

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

vangyzen added inline comments.
lib/libkvm/kvm_arm.c
252 ↗(On Diff #26482)

The "slightly more complicated scheme" is also needed here.

262 ↗(On Diff #26482)

A widely used and very portable alternative is to put

(void) kd;

here, making the variable "used" in every case. While not as clean as __unused, it would avoid code duplication. I'm fine with it either way.

This revision is now accepted and ready to land.Mar 21 2017, 12:08 PM
ngie edited edge metadata.
  • Make the ifdef soup less complicated/correct for the arm (native) case
  • Make the ifdef soup less complicated for mips
This revision now requires review to proceed.Mar 21 2017, 7:27 PM
This revision is now accepted and ready to land.Mar 21 2017, 7:38 PM

This would actually seem to make the #ifdef soup more complicated rather than less complicated. Warnings for unused function arguments seem to be more harmful than helpful as I think I've only had to add '__unused' annotations to remove them but never had them actually find a real bug.

ngie edited edge metadata.
ngie marked 2 inline comments as done.

Per jhb: Restore #ifdef soup to the form it was in before. Instead, use #ifdef's
around the _native function headers for arm/mips to mark kd unused.

This revision now requires review to proceed.Mar 21 2017, 8:35 PM
In D10071#208497, @jhb wrote:

This would actually seem to make the #ifdef soup more complicated rather than less complicated. Warnings for unused function arguments seem to be more harmful than helpful as I think I've only had to add '__unused' annotations to remove them but never had them actually find a real bug.

You're right on the first part. Marking the values __unused gives the reader a better idea that the values are indeed unused in a particular case, etc, and IIRC gives the compiler explicit consent to optimize away the value.

This revision is now accepted and ready to land.Mar 21 2017, 8:47 PM
ngie edited the summary of this revision. (Show Details)
This revision was automatically updated to reflect the committed changes.