From c1ca7e46a5ea5e1fc959fc9dcd374df24c98ca49 Mon Sep 17 00:00:00 2001 From: John Hood Date: Wed, 11 May 2016 00:03:37 -0400 Subject: [PATCH] Coverity fixes: do { ...; continue; ... } while (false) This is more stylistic than substantial, but it's bad enough style to be worth fixing. --- src/terminal/terminaldisplay.cc | 39 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/terminal/terminaldisplay.cc b/src/terminal/terminaldisplay.cc index 3d7b29d..0298f2a 100644 --- a/src/terminal/terminaldisplay.cc +++ b/src/terminal/terminaldisplay.cc @@ -475,28 +475,27 @@ void FrameState::append_silent_move( int y, int x ) void FrameState::append_move( int y, int x ) { - do { - // If cursor pos is unknown, of course we can't optimize - if ( cursor_x != -1 && cursor_y != -1 ) { - // Can we use CR and/or LF? They're cheap and easier to trace. - if ( x == 0 && y - cursor_y >= 0 && y - cursor_y < 5 ) { - if ( cursor_x != 0 ) { - append( '\r' ); - } - append( y - cursor_y, '\n' ); - continue; + // Only optimize if cursor pos is known + if ( cursor_x != -1 && cursor_y != -1 ) { + // Can we use CR and/or LF? They're cheap and easier to trace. + if ( x == 0 && y - cursor_y >= 0 && y - cursor_y < 5 ) { + if ( cursor_x != 0 ) { + append( '\r' ); } - // Backspaces are good too. - if ( y == cursor_y && x - cursor_x < 0 && x - cursor_x > -5 ) { - append( cursor_x - x, '\b' ); - continue; - } - // More optimizations are possible. + append( y - cursor_y, '\n' ); + goto positioned; } - char tmp[ 64 ]; - snprintf( tmp, 64, "\033[%d;%dH", y + 1, x + 1 ); - append( tmp ); - } while( 0 ); + // Backspaces are good too. + if ( y == cursor_y && x - cursor_x < 0 && x - cursor_x > -5 ) { + append( cursor_x - x, '\b' ); + goto positioned; + } + // More optimizations are possible. + } + char tmp[ 64 ]; + snprintf( tmp, 64, "\033[%d;%dH", y + 1, x + 1 ); + append( tmp ); + positioned: cursor_x = x; cursor_y = y; }