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

Silence some clang-tidy warnings #34222

Merged
merged 3 commits into from Sep 25, 2019
Merged

Conversation

kevingranade
Copy link
Member

Summary

SUMMARY: None

Purpose of change

Some Clang-tidy warnings cropped up after #34162

Describe the solution

Silence the warnings by shuffling some things around.

Warnings

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:27:24: error: Unnecessary initialization of 'new_pos'. 'tripoint' is zero-initialized by default. [cata-point-initialization,-warnings-as-errors]

    tripoint new_pos = tripoint_zero;

                       ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:89:9: error: Forming reference to null pointer [clang-analyzer-core.NonNullParamChecker,-warnings-as-errors]

        g->update_map( *p );

        ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:18:9: note: Assuming 'min_distance' is <= 'max_distance'

    if( min_distance > max_distance ) {

        ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:18:5: note: Taking false branch

    if( min_distance > max_distance ) {

    ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:23:25: note: Assuming the condition is true

    const bool c_is_u = &critter == &g->u;

                        ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:24:5: note: 'p' initialized here

    player *const p = critter.as_player();

    ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:34:14: note: Assuming the condition is false

    } while( g->m.impassable( new_pos ) && tries < 20 );

             ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:34:41: note: Left side of '&&' is false

    } while( g->m.impassable( new_pos ) && tries < 20 );

                                        ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:28:5: note: Loop condition is false.  Exiting loop

    do {

    ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:36:9: note: Assuming the condition is false

    if( g->m.impassable( new_pos ) ) {

        ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:36:5: note: Taking false branch

    if( g->m.impassable( new_pos ) ) {

    ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:52:25: note: Assuming 'poor_soul' is null

    if( Creature *const poor_soul = g->critter_at<Creature>( new_pos ) ) {

                        ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:52:5: note: Taking false branch

    if( Creature *const poor_soul = g->critter_at<Creature>( new_pos ) ) {

    ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:83:9: note: Assuming 'p' is null

    if( p ) {

        ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:83:5: note: Taking false branch

    if( p ) {

    ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:88:5: note: Taking true branch

    if( c_is_u ) {

    ^

/home/travis/build/CleverRaven/Cataclysm-DDA/src/teleport.cpp:89:9: note: Forming reference to null pointer

        g->update_map( *p );

        ^

src/teleport.cpp Outdated Show resolved Hide resolved
kevingranade and others added 2 commits September 24, 2019 18:26
Co-Authored-By: Jianxiang Wang (王健翔) <qrox@sina.com>
@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Code: Build Issues regarding different builds and build environments labels Sep 25, 2019
@ZhilkinSerg ZhilkinSerg merged commit 6af0db3 into master Sep 25, 2019
@kevingranade kevingranade deleted the kevingranade-quiet-clang-tidy branch October 7, 2019 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants