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

Upstream: Replace sprintf()->snprintf() strcpy()->strlcpy() #10400

Merged
merged 1 commit into from
Jun 7, 2020

Conversation

lundman
Copy link
Contributor

@lundman lundman commented Jun 4, 2020

strcpy() and sprintf() are deprecated on some platforms.

Care is needed to ensure correct size is used.

Motivation and Context

Unfortunately, compiling stops with error when attempting to use deprecated
functions on macOS.

Description

If other platforms miss snprintf, we should add a #define to
sprintf, likewise strlcpy().

Biggest change is adding another size parameter to zfs_id_to_fuidstr().

The various *_impl_get() functions have been taken out for macOS, using
#ifdefs as the string is passed to ZFS from the Linux kernel. I am unsure of its size. If someone with Linux background knows the size, I can update the PR. (It will not even compile using strcpy).

Did git just eat part of the commit message? Oh heh, '#' is comment.

How Has This Been Tested?

Extensive testing of zfs-test on macOS. Other platforms unknown.

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.

module/icp/os/modhash.c Outdated Show resolved Hide resolved
module/lua/lstrlib.c Outdated Show resolved Hide resolved
module/zfs/dsl_dataset.c Outdated Show resolved Hide resolved
Copy link
Contributor

@kithrup kithrup left a comment

Choose a reason for hiding this comment

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

Looks sane, my minor complaints notwithstanding.

@lundman
Copy link
Contributor Author

lundman commented Jun 4, 2020

Threw some of the repeated math into a local variable, hopefully that is a little more readable.

@lundman
Copy link
Contributor Author

lundman commented Jun 4, 2020

Corrected the #ifdefs around the _set_impl functions. But could get rid of them entirely if there is a solution for the strcpy(). Is the linux kernel passed string length well known?

@codecov
Copy link

codecov bot commented Jun 4, 2020

Codecov Report

Merging #10400 into master will decrease coverage by 0.19%.
The diff coverage is 90.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10400      +/-   ##
==========================================
- Coverage   79.56%   79.36%   -0.20%     
==========================================
  Files         391      391              
  Lines      123624   123628       +4     
==========================================
- Hits        98357    98123     -234     
- Misses      25267    25505     +238     
Flag Coverage Δ
#kernel 79.92% <89.09%> (-0.04%) ⬇️
#user 65.54% <36.95%> (-0.35%) ⬇️
Impacted Files Coverage Δ
module/os/linux/zfs/zfs_vfsops.c 78.46% <ø> (ø)
module/zfs/dsl_prop.c 89.32% <0.00%> (ø)
module/zfs/zcp_get.c 84.66% <75.00%> (ø)
module/lua/lstrlib.c 84.87% <83.33%> (ø)
module/icp/algs/aes/aes_impl.c 64.06% <100.00%> (ø)
module/icp/algs/modes/gcm.c 81.46% <100.00%> (ø)
module/icp/os/modhash.c 42.74% <100.00%> (+0.23%) ⬆️
module/zfs/ddt.c 87.86% <100.00%> (-0.39%) ⬇️
module/zfs/dmu_objset.c 91.62% <100.00%> (ø)
module/zfs/dmu_send.c 84.55% <100.00%> (ø)
... and 66 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 c0eb5c3...86fcb00. Read the comment docs.

module/icp/algs/aes/aes_impl.c Outdated Show resolved Hide resolved
module/icp/algs/modes/gcm.c Outdated Show resolved Hide resolved
module/icp/algs/aes/aes_impl.c Outdated Show resolved Hide resolved
module/icp/algs/modes/gcm.c Outdated Show resolved Hide resolved
module/lua/lstrlib.c Outdated Show resolved Hide resolved
module/zfs/dsl_dataset.c Outdated Show resolved Hide resolved
module/zfs/dsl_dataset.c Outdated Show resolved Hide resolved
module/zfs/dsl_dir.c Outdated Show resolved Hide resolved
module/zfs/spa.c Outdated Show resolved Hide resolved
module/zfs/zcp_get.c Outdated Show resolved Hide resolved
@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Jun 4, 2020
@lundman lundman force-pushed the macOS_pr3 branch 2 times, most recently from 4434ec2 to a19fd0f Compare June 5, 2020 00:40
@behlendorf
Copy link
Contributor

Look's like some cstyle warnings. Aside from that, this looks good to me. We had a CI glitch so I went and resubmitted the unexpected failed builds to see if there were real issues.

If other platforms miss snprintf, we should add a #define to
sprintf, likewise strlcpy().

Biggest change is adding another size parameter to zfs_id_to_fuidstr().

The various *_impl_get() functions have been taken out for macOS, using
I am unsure of its size. If someone with Linux background knows the
size, I can update the PR. (It will not even compile using strcpy).

Signed-off-by: Jorgen Lundman <lundman@lundman.net>
@lundman
Copy link
Contributor Author

lundman commented Jun 7, 2020

cstyle corrected, also, it seems module/os/linux/zfs/zfs_vfsops.c got swept up in the excitement, I don't compile anything in os/linux, so I shouldn't be changing anything in there. Let me know if I should take it out.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Jun 7, 2020
@behlendorf behlendorf merged commit c9e319f into openzfs:master Jun 7, 2020
BrainSlayer pushed a commit to BrainSlayer/zfs that referenced this pull request Jun 10, 2020
The strcpy() and sprintf() functions are deprecated on some platforms.
Care is needed to ensure correct size is used.  If some platforms
miss snprintf, we can add a #define to sprintf, likewise strlcpy().

The biggest change is adding a size parameter to zfs_id_to_fuidstr().

The various *_impl_get() functions are only used on linux and have
not yet been updated.

Reviewed by: Sean Eric Fagan <sef@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jorgen Lundman <lundman@lundman.net>
Closes openzfs#10400
lundman referenced this pull request in openzfsonosx/openzfs Jun 12, 2020
The strcpy() and sprintf() functions are deprecated on some platforms.
Care is needed to ensure correct size is used.  If some platforms
miss snprintf, we can add a #define to sprintf, likewise strlcpy().

The biggest change is adding a size parameter to zfs_id_to_fuidstr().

The various *_impl_get() functions are only used on linux and have
not yet been updated.

Reviewed by: Sean Eric Fagan <sef@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jorgen Lundman <lundman@lundman.net>
Closes #10400
as-com pushed a commit to as-com/zfs that referenced this pull request Jun 20, 2020
The strcpy() and sprintf() functions are deprecated on some platforms.
Care is needed to ensure correct size is used.  If some platforms
miss snprintf, we can add a #define to sprintf, likewise strlcpy().

The biggest change is adding a size parameter to zfs_id_to_fuidstr().

The various *_impl_get() functions are only used on linux and have
not yet been updated.

Reviewed by: Sean Eric Fagan <sef@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jorgen Lundman <lundman@lundman.net>
Closes openzfs#10400 
(cherry picked from commit c9e319f)
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
The strcpy() and sprintf() functions are deprecated on some platforms.
Care is needed to ensure correct size is used.  If some platforms
miss snprintf, we can add a #define to sprintf, likewise strlcpy().

The biggest change is adding a size parameter to zfs_id_to_fuidstr().

The various *_impl_get() functions are only used on linux and have
not yet been updated.

Reviewed by: Sean Eric Fagan <sef@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jorgen Lundman <lundman@lundman.net>
Closes openzfs#10400
@lundman lundman deleted the macOS_pr3 branch May 28, 2021 05:21
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
The strcpy() and sprintf() functions are deprecated on some platforms.
Care is needed to ensure correct size is used.  If some platforms
miss snprintf, we can add a #define to sprintf, likewise strlcpy().

The biggest change is adding a size parameter to zfs_id_to_fuidstr().

The various *_impl_get() functions are only used on linux and have
not yet been updated.

Reviewed by: Sean Eric Fagan <sef@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jorgen Lundman <lundman@lundman.net>
Closes openzfs#10400
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.

3 participants