Skip to content

token.cpp: use snprintf() to fix -Wdeprecated-declarations AppleClang warning#7744

Merged
chrchr-github merged 1 commit intodanmar:mainfrom
firewave:sprintf
Aug 16, 2025
Merged

token.cpp: use snprintf() to fix -Wdeprecated-declarations AppleClang warning#7744
chrchr-github merged 1 commit intodanmar:mainfrom
firewave:sprintf

Conversation

@firewave
Copy link
Copy Markdown
Collaborator

/Users/runner/work/cppcheck/cppcheck/lib/token.cpp:1611:21: error: 'sprintf' is deprecated: 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. [-Werror,-Wdeprecated-declarations]
 1611 |                     sprintf(str, "\\x%02x", c);
      |                     ^
/Applications/Xcode_16.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:274:1: note: 'sprintf' has been explicitly marked deprecated here
  274 | __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.")
      | ^
/Applications/Xcode_16.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/sys/cdefs.h:218:48: note: expanded from macro '__deprecated_msg'
  218 |         #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
      |                                                       ^

…lang warning

```
/Users/runner/work/cppcheck/cppcheck/lib/token.cpp:1611:21: error: 'sprintf' is deprecated: 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. [-Werror,-Wdeprecated-declarations]
 1611 |                     sprintf(str, "\\x%02x", c);
      |                     ^
/Applications/Xcode_16.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:274:1: note: 'sprintf' has been explicitly marked deprecated here
  274 | __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.")
      | ^
/Applications/Xcode_16.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/sys/cdefs.h:218:48: note: expanded from macro '__deprecated_msg'
  218 |         #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
      |                                                       ^
```
@sonarqubecloud
Copy link
Copy Markdown

@chrchr-github chrchr-github merged commit 3122724 into danmar:main Aug 16, 2025
63 checks passed
@firewave firewave deleted the sprintf branch August 16, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants