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

Replace sprintf() with snprintf() to remove Xcode/clang warning. #4001

Closed
wants to merge 2 commits into from

Conversation

hyoklee
Copy link
Member

@hyoklee hyoklee commented Feb 9, 2024

Here's a typical warning message:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
188 | __deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.")

@@ -850,7 +850,7 @@ test_creating_groups_using_plugins(hid_t fid)
char *sp = subgroup_name;

sp += snprintf(subgroup_name, sizeof(subgroup_name), SUBGROUP_PREFIX);
sprintf(sp, "%d", i);
Copy link
Collaborator

@jhendersonHDF jhendersonHDF Feb 9, 2024

Choose a reason for hiding this comment

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

Based on a quick reading of the code, I think these two calls should just be combined into a single snprintf(subgroup_name, sizeof(subgroup_name), SUBGROUP_PREFIX "%d");
Doesn't seem like sp or the extra call to sprintf is needed here.

@byrnHDF byrnHDF added Priority - 1. High 🔼 These are important issues that should be resolved in the next release Component - Testing Code in test or testpar directories, GitHub workflows Type - Improvement Improvements that don't add a new feature or functionality labels Feb 12, 2024
@lrknox
Copy link
Collaborator

lrknox commented Feb 13, 2024

Changes in this PR were also included in #4003.

@lrknox lrknox closed this Feb 13, 2024
@hyoklee hyoklee deleted the hyoklee-hdf5-150 branch February 13, 2024 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Testing Code in test or testpar directories, GitHub workflows Priority - 1. High 🔼 These are important issues that should be resolved in the next release Type - Improvement Improvements that don't add a new feature or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants