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

Loader: Use reinterpret_cast instead of C-style pointer casting #880

Merged
merged 1 commit into from Dec 18, 2021

Conversation

ma8ma
Copy link
Collaborator

@ma8ma ma8ma commented Dec 18, 2021

C言語スタイルのキャストを使っているとcppcheck 2.6.2に指摘されたため修正します。また、IPアドレスのデバッグプリントをIPv6に対応します。

参考文献
https://man7.org/linux/man-pages/man3/inet_ntop.3.html

cppcheckのレポート

src/jdlib/loader.cpp:1039:44: style: C-style pointer casting detected. C++ offers four different kinds of casts as
replacements: static_cast, const_cast, dynamic_cast and reinterpret_cast. A C-style cast could evaluate to any of
those automatically, thus it is considered safer if the programmer explicitly states which kind of cast is expected.
See also: https://www.securecoding.cert.org/confluence/display/cplusplus/EXP05-CPP.+Do+not+use+C-style+casts. [cstyleCast]
              << ", ip =" << inet_ntoa( (  ( sockaddr_in* )( res->ai_addr ) )->sin_addr ) << std::endl;
                                           ^

関連のpull request: #865

C言語スタイルのキャストを使っているとcppcheck 2.6.2に指摘されたため
修正します。また、IPアドレスのデバッグプリントをIPv6に対応します。

参考文献
https://man7.org/linux/man-pages/man3/inet_ntop.3.html

cppcheckのレポート
```
src/jdlib/loader.cpp:1039:44: style: C-style pointer casting detected. C++ offers four different kinds of casts as
replacements: static_cast, const_cast, dynamic_cast and reinterpret_cast. A C-style cast could evaluate to any of
those automatically, thus it is considered safer if the programmer explicitly states which kind of cast is expected.
See also: https://www.securecoding.cert.org/confluence/display/cplusplus/EXP05-CPP.+Do+not+use+C-style+casts. [cstyleCast]
              << ", ip =" << inet_ntoa( (  ( sockaddr_in* )( res->ai_addr ) )->sin_addr ) << std::endl;
                                           ^
```
@ma8ma ma8ma added the refactoring コードの整理 (バグ修正でも機能変更でもない) label Dec 18, 2021
@ma8ma ma8ma added this to In progress in State of JDim-v0.6.0+ via automation Dec 18, 2021
@ma8ma ma8ma merged commit ab27947 into JDimproved:master Dec 18, 2021
State of JDim-v0.6.0+ automation moved this from In progress to Done Dec 18, 2021
@ma8ma ma8ma deleted the loader-use-cpp-style-cast branch December 18, 2021 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring コードの整理 (バグ修正でも機能変更でもない)
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

1 participant