Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable -Wmissing-prototypes #10470

Closed
wants to merge 8 commits into from

Conversation

nivedita76
Copy link
Contributor

These changes are done to allow for enabling -Wmissing-prototypes (and -Wstrict-prototypes). It marks a bunch of functions static, removes dead code, and adds prototypes for what's left if they were not there before.

Motivation and Context

The original issue is fixed in the first patch of the series: libzpool/kernel.c had stub definitions for a couple of functions with bad prototypes, which wasn't caught because -Wmissing-prototypes isn't enabled. This series will help us avoid such issues in the future.

Description

The patch adding static should be fairly safe. The dead code removal patch should get some detailed review as we may want to retain some of these functions for debugging or in some cases to reduce divergence from wherever the code was originally pulled from. Eg there may be functions that would only be useful on Solaris that got deleted.

How Has This Been Tested?

Build-tested on linux/FreeBSD x86-64.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (a change to man pages or other documentation)

Checklist:

  • My code follows the ZFS on Linux code style requirements.
  • I have updated the documentation accordingly.
  • I have read the contributing document.
  • I have added tests to cover my changes.
  • I have run the ZFS Test Suite with this change applied.
  • All commit messages are properly formatted and contain Signed-off-by.

Commit
  ec21397 ("async zvol minor node creation interferes with receive")
replaced zvol_create_minors with zvol_create_minor and
zvol_create_minors_recursive, changing the prototype at the same time.

However the stub functions in libzpool/kernel.c were defined with the
old prototype. As the definitions are empty, this doesn't cause any
runtime issues, but an LTO build shows warnings because of the
mismatched prototypes.

Commit
  a0bd735 ("Add support for asynchronous zvol minor operations")
removed the real zvol_remove_minor, but for some reason added a stub
implementation in libzpool/kernel.c with no references. Delete this dead
code.

Commit
  196bee4 ("Remove deduplicated send/receive code")
removed zfs_onexit_del_cb and zfs_onexit_cb_data. Drop the stubs as
well.

Add zvol.h include to provide prototypes, and sort the include
directives.

Fixes: ec21397 ("async zvol minor node creation interferes with receive")
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
@ghost
Copy link

ghost commented Jun 17, 2020

I would expect for zfs_context.h being included before other headers to be generally important.
Most of this looks good, let's get it building now.

@codecov
Copy link

codecov bot commented Jun 17, 2020

Codecov Report

Merging #10470 into master will decrease coverage by 13.94%.
The diff coverage is 57.50%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #10470       +/-   ##
===========================================
- Coverage   79.24%   65.29%   -13.95%     
===========================================
  Files         393      309       -84     
  Lines      123859   106514    -17345     
===========================================
- Hits        98149    69552    -28597     
- Misses      25710    36962    +11252     
Flag Coverage Δ
#kernel ?
#user 65.29% <57.50%> (+0.95%) ⬆️
Impacted Files Coverage Δ
cmd/raidz_test/raidz_bench.c 0.00% <ø> (ø)
cmd/zed/agents/zfs_mod.c 78.21% <ø> (ø)
cmd/zed/zed_event.c 61.22% <ø> (ø)
cmd/zed/zed_exec.c 82.92% <ø> (ø)
cmd/zed/zed_file.c 33.80% <ø> (ø)
cmd/zed/zed_strings.c 81.25% <ø> (ø)
cmd/zfs/zfs_main.c 82.69% <ø> (+0.05%) ⬆️
cmd/zfs_ids_to_path/zfs_ids_to_path.c 60.00% <ø> (ø)
cmd/zinject/zinject.c 37.99% <ø> (ø)
cmd/zpool/zpool_main.c 80.94% <ø> (+0.10%) ⬆️
... and 296 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fccaea4...d7be42d. Read the comment docs.

@nivedita76
Copy link
Contributor Author

I would expect for zfs_context.h being included before other headers to be generally important.
Most of this looks good, let's get it building now.

I can take out the header resorting if that's safer. I started doing it then realized that would be a project on its own so its only done in a couple places.

@nivedita76 nivedita76 force-pushed the missing-prototypes branch 2 times, most recently from f45288a to f33878e Compare June 17, 2020 20:04
@behlendorf
Copy link
Contributor

Thanks for tackling this cleanup! When reviewing this all the changes looked reasonable though I realize you're still iterating on this to resolve the remaining build issues. Thanks for breaking it up in to multiple commits to make it easier to review. I'm happy to give it another look when it's building everywhere.

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Jun 17, 2020
module/zfs/zil.c Outdated Show resolved Hide resolved
@ghost
Copy link

ghost commented Jun 17, 2020

Things all look good on the FreeBSD side. I only skimmed Linux-specific code.

Mark functions used only in the same translation unit as static. This
only includes functions that do not have a prototype in a header file
either.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Delete unused functions.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Include the header with prototypes in the file that provides definitions
as well, to catch any mismatch between prototype and definition.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Add prototypes/move prototypes to header files.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Turn the generic versions into inline functions and avoid
SKEIN_PORT_CODE trickery.

Also drop the PLATFORM_MUST_ALIGN check for using the fast bcopy
variants. bcopy doesn't assume alignment, and the userspace version is
currently different because the _ALIGNMENT_REQUIRED macro is only
defined by the kernelspace headers.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
spl-generic.c defines some of the libgcc integer library functions on
32-bit. Don't bother checking -Wmissing-prototypes since nothing should
directly call these functions from C code.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Switch on warning flags to detect mismatch between declaration and
definition.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
@nivedita76
Copy link
Contributor Author

nivedita76 commented Jun 18, 2020

@behlendorf builds are finally working now.

Let me know if I should rebase it.

Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Linux bits look good too. I don't think there's a need to rebase this since it's only behind by six commits. I can verify it still builds cleanly locally which applied to master, and if that looks good I'll get it merged.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Jun 18, 2020
@nivedita76
Copy link
Contributor Author

The Linux bits look good too. I don't think there's a need to rebase this since it's only behind by six commits. I can verify it still builds cleanly locally which applied to master, and if that looks good I'll get it merged.

Ok thanks.

behlendorf pushed a commit that referenced this pull request Jun 18, 2020
Mark functions used only in the same translation unit as static. This
only includes functions that do not have a prototype in a header file
either.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
behlendorf pushed a commit that referenced this pull request Jun 18, 2020
Delete unused functions.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
behlendorf pushed a commit that referenced this pull request Jun 18, 2020
Include the header with prototypes in the file that provides definitions
as well, to catch any mismatch between prototype and definition.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
behlendorf pushed a commit that referenced this pull request Jun 18, 2020
Add prototypes/move prototypes to header files.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
behlendorf pushed a commit that referenced this pull request Jun 18, 2020
Turn the generic versions into inline functions and avoid
SKEIN_PORT_CODE trickery.

Also drop the PLATFORM_MUST_ALIGN check for using the fast bcopy
variants. bcopy doesn't assume alignment, and the userspace version is
currently different because the _ALIGNMENT_REQUIRED macro is only
defined by the kernelspace headers.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
behlendorf pushed a commit that referenced this pull request Jun 18, 2020
spl-generic.c defines some of the libgcc integer library functions on
32-bit. Don't bother checking -Wmissing-prototypes since nothing should
directly call these functions from C code.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
behlendorf pushed a commit that referenced this pull request Jun 18, 2020
Switch on warning flags to detect mismatch between declaration and
definition.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
lundman referenced this pull request in openzfsonosx/openzfs Jun 19, 2020
Commit
  ec21397 ("async zvol minor node creation interferes with receive")
replaced zvol_create_minors with zvol_create_minor and
zvol_create_minors_recursive, changing the prototype at the same time.

However the stub functions in libzpool/kernel.c were defined with the
old prototype. As the definitions are empty, this doesn't cause any
runtime issues, but an LTO build shows warnings because of the
mismatched prototypes.

Commit
  a0bd735 ("Add support for asynchronous zvol minor operations")
removed the real zvol_remove_minor, but for some reason added a stub
implementation in libzpool/kernel.c with no references. Delete this dead
code.

Commit
  196bee4 ("Remove deduplicated send/receive code")
removed zfs_onexit_del_cb and zfs_onexit_cb_data. Drop the stubs as
well.

Add zvol.h include to provide prototypes, and sort the include
directives.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
lundman referenced this pull request in openzfsonosx/openzfs Jun 19, 2020
Mark functions used only in the same translation unit as static. This
only includes functions that do not have a prototype in a header file
either.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
lundman referenced this pull request in openzfsonosx/openzfs Jun 19, 2020
Delete unused functions.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
lundman referenced this pull request in openzfsonosx/openzfs Jun 19, 2020
Include the header with prototypes in the file that provides definitions
as well, to catch any mismatch between prototype and definition.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
lundman referenced this pull request in openzfsonosx/openzfs Jun 19, 2020
Add prototypes/move prototypes to header files.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
lundman referenced this pull request in openzfsonosx/openzfs Jun 19, 2020
Turn the generic versions into inline functions and avoid
SKEIN_PORT_CODE trickery.

Also drop the PLATFORM_MUST_ALIGN check for using the fast bcopy
variants. bcopy doesn't assume alignment, and the userspace version is
currently different because the _ALIGNMENT_REQUIRED macro is only
defined by the kernelspace headers.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
lundman referenced this pull request in openzfsonosx/openzfs Jun 19, 2020
spl-generic.c defines some of the libgcc integer library functions on
32-bit. Don't bother checking -Wmissing-prototypes since nothing should
directly call these functions from C code.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
lundman referenced this pull request in openzfsonosx/openzfs Jun 19, 2020
Switch on warning flags to detect mismatch between declaration and
definition.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
@nivedita76 nivedita76 deleted the missing-prototypes branch June 25, 2020 01:48
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Sep 15, 2020
spl-generic.c defines some of the libgcc integer library functions on
32-bit. Don't bother checking -Wmissing-prototypes since nothing should
directly call these functions from C code.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
Commit
  ec21397 ("async zvol minor node creation interferes with receive")
replaced zvol_create_minors with zvol_create_minor and
zvol_create_minors_recursive, changing the prototype at the same time.

However the stub functions in libzpool/kernel.c were defined with the
old prototype. As the definitions are empty, this doesn't cause any
runtime issues, but an LTO build shows warnings because of the
mismatched prototypes.

Commit
  a0bd735 ("Add support for asynchronous zvol minor operations")
removed the real zvol_remove_minor, but for some reason added a stub
implementation in libzpool/kernel.c with no references. Delete this dead
code.

Commit
  196bee4 ("Remove deduplicated send/receive code")
removed zfs_onexit_del_cb and zfs_onexit_cb_data. Drop the stubs as
well.

Add zvol.h include to provide prototypes, and sort the include
directives.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
Mark functions used only in the same translation unit as static. This
only includes functions that do not have a prototype in a header file
either.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
Delete unused functions.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
Include the header with prototypes in the file that provides definitions
as well, to catch any mismatch between prototype and definition.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
Add prototypes/move prototypes to header files.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
Turn the generic versions into inline functions and avoid
SKEIN_PORT_CODE trickery.

Also drop the PLATFORM_MUST_ALIGN check for using the fast bcopy
variants. bcopy doesn't assume alignment, and the userspace version is
currently different because the _ALIGNMENT_REQUIRED macro is only
defined by the kernelspace headers.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
spl-generic.c defines some of the libgcc integer library functions on
32-bit. Don't bother checking -Wmissing-prototypes since nothing should
directly call these functions from C code.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
Switch on warning flags to detect mismatch between declaration and
definition.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
Commit
  ec21397 ("async zvol minor node creation interferes with receive")
replaced zvol_create_minors with zvol_create_minor and
zvol_create_minors_recursive, changing the prototype at the same time.

However the stub functions in libzpool/kernel.c were defined with the
old prototype. As the definitions are empty, this doesn't cause any
runtime issues, but an LTO build shows warnings because of the
mismatched prototypes.

Commit
  a0bd735 ("Add support for asynchronous zvol minor operations")
removed the real zvol_remove_minor, but for some reason added a stub
implementation in libzpool/kernel.c with no references. Delete this dead
code.

Commit
  196bee4 ("Remove deduplicated send/receive code")
removed zfs_onexit_del_cb and zfs_onexit_cb_data. Drop the stubs as
well.

Add zvol.h include to provide prototypes, and sort the include
directives.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
Mark functions used only in the same translation unit as static. This
only includes functions that do not have a prototype in a header file
either.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
Delete unused functions.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
Include the header with prototypes in the file that provides definitions
as well, to catch any mismatch between prototype and definition.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
Add prototypes/move prototypes to header files.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
Turn the generic versions into inline functions and avoid
SKEIN_PORT_CODE trickery.

Also drop the PLATFORM_MUST_ALIGN check for using the fast bcopy
variants. bcopy doesn't assume alignment, and the userspace version is
currently different because the _ALIGNMENT_REQUIRED macro is only
defined by the kernelspace headers.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
spl-generic.c defines some of the libgcc integer library functions on
32-bit. Don't bother checking -Wmissing-prototypes since nothing should
directly call these functions from C code.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
Switch on warning flags to detect mismatch between declaration and
definition.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants