Page MenuHomeFreeBSD

Fix warnings with gcc 4.2/4.9/5.0
ClosedPublic

Authored by ngie on Jul 5 2016, 7:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 19, 10:20 PM
Unknown Object (File)
Tue, Nov 5, 10:37 AM
Unknown Object (File)
Oct 1 2024, 5:47 AM
Unknown Object (File)
Sep 10 2024, 7:40 PM
Unknown Object (File)
Sep 7 2024, 2:16 PM
Unknown Object (File)
Aug 21 2024, 7:06 PM
Unknown Object (File)
Aug 13 2024, 10:51 PM
Unknown Object (File)
Aug 10 2024, 12:07 AM
Subscribers

Details

Reviewers
grehan
neel
ngie
Summary

Fix warnings with gcc 4.2/4.9/5.0

  • Remove unused variables; cast (void) where necessary to appease the compiler with unchecked returns.
  • Remove unused functions.
  • Put some variables under appropriate #define checks to
  • Use generic method for determining whether or not SSE4.2 is enabled as the previous method would fail with !clang.
  • Consolidate CTASSERTs and add __unused to appease gcc.
  • Add more ellipses to appease warning from gcc about putting additional parentheses when using bitwise-or statements.

Tested with: clang 3.8.1, gcc, gcc 4.9, gcc 5.0
Sponsored by: EMC / Isilon Storage Division

Diff Detail

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

Event Timeline

ngie retitled this revision from to Fix warnings with gcc 4.2/4.9/5.0.
ngie updated this object.
ngie edited the test plan for this revision. (Show Details)
ngie added reviewers: grehan, neel.
ngie added subscribers: dim, markj.

I still need to test out the change. I'll break down the issues in to separate commits for clarity. I'm just submitting a single CR to streamline the review -> commit process.

usr.sbin/bhyve/rfb.c
858

The first argument is wrong. It needs to be the instruction number.

ngie marked an inline comment as done.Jul 5 2016, 7:56 PM
ngie added inline comments.
usr.sbin/bhyve/rfb.c
858

Nevermind. After reviewing some related source code from sys/x86/x86/identcpu.c first argument was correct:

1415         do_cpuid(1, regs);
1416         cpu_id = regs[0];
1417         cpu_procinfo = regs[1];
1418         cpu_feature = regs[3];
1419         cpu_feature2 = regs[2];
1420 #endif
ngie marked 2 inline comments as done.Jul 5 2016, 7:56 PM

Thanks for doing this. I'd started on it but hadn't made a lot of progress (couldn't get a complete full build with the amd64_gcc port - blew up in the loader).

usr.sbin/bhyve/pci_emul.c
759

Hmmm, does this show up elsewhere in the source base ? Seems like the fix could possibly go into sys/systm.h

usr.sbin/bhyve/pci_passthru.c
419–420

This might need some error handling but that can wait for a future commit.

usr.sbin/bhyve/rfb.c
197–198

I left these without the (void) cast - there are some other instances like this in the file. Don't really mind either way. I'll talk to Leon about maybe some better error handling when the stream functions return an error.

862

Thanks - better solution than what I had (#ifndef bit_SSE42 then #define bit_SSE42)

ngie marked 3 inline comments as done.Jul 5 2016, 10:56 PM
ngie added inline comments.
usr.sbin/bhyve/pci_emul.c
759

Maybe. I do find it annoying how gcc 4.9 warns about this being unused... I'm not sure if it would compile out the check TBH, making it unusable.

usr.sbin/bhyve/rfb.c
197–198

Sounds good. This is dealing with -Wunused-but-set-variable warnings from gcc 4.8+.

ngie marked 3 inline comments as done.Jul 5 2016, 10:57 PM
grehan edited edge metadata.

All fine by me.

This revision is now accepted and ready to land.Jul 5 2016, 11:00 PM
ngie marked an inline comment as done.Jul 5 2016, 11:53 PM
  • I booted 10.3-RELEASE (i386) successfully.
  • I double-checked the SSE 4.2 instruction to make sure it was sane.
usr.sbin/bhyve/rfb.c
862

This needs to be SSE42, not SSE41. Almost missed that typo.

usr.sbin/bhyve/rfb.c
862

I confirmed that this works and is correct:

 static int
-sse42_supported()
+sse42_supported(void)
 {
-       unsigned int eax, ebx, ecx, edx;
- 
-       __get_cpuid(1, &eax, &ebx, &ecx, &edx);
- 
-       return ((ecx & bit_SSE42) != 0);
+       u_int cpu_registers[4], ecx;
+
+       do_cpuid(1, cpu_registers);
+
+       ecx = cpu_registers[2];
+
+       return ((ecx & CPUID2_SSE42) != 0);
 }
 
 int
ngie marked 2 inline comments as done.Jul 5 2016, 11:58 PM
ngie edited edge metadata.

Fix typo (CPUID2_SSE41 -> CPUID2_SSE42) for completeness.

This revision now requires review to proceed.Jul 6 2016, 12:38 AM
ngie added a reviewer: ngie.
This revision is now accepted and ready to land.Jul 6 2016, 5:18 AM