Opened 8 years ago

Closed 8 years ago

#6299 closed defect (fixed)

Logic error in GNMGenericNetwork::LoadGraph()

Reported by: Even Rouault Owned by: bishop
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords: gnm
Cc:

Description (last modified by Even Rouault)

Coverity Scan raises that the following tests in GNMGenericNetwork::LoadGraph() can only evaluate to FALSE since they are in a block controlled by if(bIsBlock) but "bool bIsBlock = GNM_BLOCK_NONE == nBlockState;"

            if(nBlockState & GNM_BLOCK_SRC)
                m_oGraph.ChangeBlockState(nSrcFID, bIsBlock);
            if(nBlockState & GNM_BLOCK_TGT)
                m_oGraph.ChangeBlockState(nTgtFID, bIsBlock);
            if(nBlockState & GNM_BLOCK_CONN)
                m_oGraph.ChangeBlockState(nConFID, bIsBlock);

The warning (KS 138329 Logically dead code) looks justified.

Change History (4)

comment:1 by Even Rouault, 8 years ago

Description: modified (diff)

comment:2 by Bishop, 8 years ago

There is an logical error (fixed in r32914) as bIsBlock should be true if nBlockState != GNM_BLOCK_NONE.

bool bIsBlock = GNM_BLOCK_NONE != nBlockState;

But nBlockState can take different values or combination of values:

#define GNM_BLOCK_NONE 0x0000  // no blocking (vertex or edge)
#define GNM_BLOCK_SRC  0x0001  // the source vertex is blocked
#define GNM_BLOCK_TGT  0x0002  // the target vertext is blocked
#define GNM_BLOCK_CONN 0x0004  // the connection edge is blocked
#define GNM_BLOCK_ALL GNM_BLOCK_SRC | GNM_BLOCK_TGT | GNM_BLOCK_CONN

So bIsBlock is not always FALSE.

comment:3 by Even Rouault, 8 years ago

Any reason to keep the ticket opened ? r32914 seems like the appropriate fix.

comment:4 by Bishop, 8 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.