Improve: [CodeFactor] eliminate (some of) our C style casts#5355
Improve: [CodeFactor] eliminate (some of) our C style casts#5355SlySven merged 3 commits intoMudlet:developmentfrom
Conversation
These have no place in C++ code! Unfortunately there are some in third party bits which can't be fixed here but should be raised upstream. This should help with Mudlet#1650. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
|
Hey there! Thanks for helping Mudlet improve. 🌟 Test versionsYou can directly test the changes here:
No need to install anything - just unzip and run. |
src/TTrigger.cpp
Outdated
| return; | ||
| } | ||
| auto * filterSubject = (char*)malloc(capture.size() + 2048); | ||
| auto * filterSubject = reinterpret_cast<char*>(malloc(capture.size() + 2048)); |
There was a problem hiding this comment.
warning: do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast]
auto * filterSubject = reinterpret_cast<char*>(malloc(capture.size() + 2048));
^
src/TTrigger.cpp
Outdated
| return; | ||
| } | ||
| auto * filterSubject = (char*)malloc(capture.size() + 2048); | ||
| auto * filterSubject = reinterpret_cast<char*>(malloc(capture.size() + 2048)); |
There was a problem hiding this comment.
warning: do not manage memory manually; consider a container or a smart pointer [cppcoreguidelines-no-malloc]
auto * filterSubject = reinterpret_cast<char*>(malloc(capture.size() + 2048));
^
src/ctelnet.cpp
Outdated
|
|
||
| mZstream.avail_out = 100000; | ||
| mZstream.next_out = (Bytef*)out_buffer; | ||
| mZstream.next_out = reinterpret_cast<Bytef*>(out_buffer); |
There was a problem hiding this comment.
warning: do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast]
mZstream.next_out = reinterpret_cast<Bytef*>(out_buffer);
^|
@SlySven what should we do about this? |
I'll probably remove the ones that are still confusing me/the clang-tidy bot! |
There may be a better way - but it doesn't jump out at me - to deal with the outstanding ones. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
| return; | ||
| } | ||
| auto * filterSubject = (char*)malloc(capture.size() + 2048); | ||
| auto * filterSubject = static_cast<char*>(malloc(capture.size() + 2048)); |
There was a problem hiding this comment.
warning: do not manage memory manually; consider a container or a smart pointer [cppcoreguidelines-no-malloc]
auto * filterSubject = static_cast<char*>(malloc(capture.size() + 2048));
^There was a problem hiding this comment.
Good idea, but probably outside of the scope of this PR.
There was a problem hiding this comment.
Good idea, but probably outside of the scope of this PR.
You mean the "consider a container or a smart pointer [cppcoreguidelines-no-malloc]" is a good idea, right? - I guess it is - but since it is interfacing to a C library I'd be quite happy to leave it to someone else a different PR ...! 😜
|
Retitled to fit our recently discussed PR title patterning. 😀 |
These have no place in C++ code!
Unfortunately there are some in third party bits which can't be fixed here but should be raised upstream.
This should help with #1650.
Signed-off-by: Stephen Lyons slysven@virginmedia.com
Release post highlight
Probably none - I'm not sure that this is something that we want to make a song-and-dance about given that it doesn't totally eliminate the issue!