[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-ddrescue] [PATCH 5/7] [clang-tidy] Don't use else after a return st
From: |
Rosen Penev |
Subject: |
[Bug-ddrescue] [PATCH 5/7] [clang-tidy] Don't use else after a return statement |
Date: |
Mon, 14 Oct 2019 13:59:44 -0700 |
Found with readability-else-after-return
Signed-off-by: Rosen Penev <address@hidden>
---
arg_parser.cc | 4 ++--
command_mode.cc | 2 +-
ddrescuelog.cc | 10 +++++-----
fillbook.cc | 4 ++--
genbook.cc | 2 +-
mapfile.cc | 2 +-
rational.cc | 6 +++---
rescuebook.cc | 6 +++---
8 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/arg_parser.cc b/arg_parser.cc
index 7cdd708..4a62078 100644
--- a/arg_parser.cc
+++ b/arg_parser.cc
@@ -39,7 +39,7 @@ bool Arg_parser::parse_long_option( const char * const opt,
const char * const a
{
if( std::strlen( options[i].name ) == len ) // Exact match found
{ index = i; exact = true; break; }
- else if( index < 0 ) index = i; // First nonexact match found
+ if( index < 0 ) index = i; // First nonexact match found
else if( options[index].code != options[i].code ||
options[index].has_arg != options[i].has_arg )
ambig = true; // Second or later nonexact match found
@@ -157,7 +157,7 @@ Arg_parser::Arg_parser( const int argc, const char * const
argv[],
if( ch2 == '-' )
{
if( !argv[argind][2] ) { ++argind; break; } // we found "--"
- else if( !parse_long_option( opt, arg, options, argind ) ) break;
+ if( !parse_long_option( opt, arg, options, argind ) ) break;
}
else if( !parse_short_option( opt, arg, options, argind ) ) break;
}
diff --git a/command_mode.cc b/command_mode.cc
index 2120a80..46665e5 100644
--- a/command_mode.cc
+++ b/command_mode.cc
@@ -108,7 +108,7 @@ int Rescuebook::do_commands( const int ides, const int odes
)
while( true )
{
const int c = std::fgetc( stdin );
- if( c == '\n' ) { if( !command.empty() ) break; else continue; }
+ if( c == '\n' ) { if( !command.empty() ) break; continue; }
if( c == EOF ) { command = "f"; break; } // discard partial command
if( !std::isspace( c ) ) command += c;
else if( !command.empty() && !std::isspace( command[command.size()-1] ) )
diff --git a/ddrescuelog.cc b/ddrescuelog.cc
index e63d88d..43a47d2 100644
--- a/ddrescuelog.cc
+++ b/ddrescuelog.cc
@@ -112,7 +112,7 @@ void parse_types( const std::string & arg,
if( ch == ',' )
{
if( comma_found ) { error = true; break; }
- else { comma_found = true; p = &types2; continue; }
+ comma_found = true; p = &types2; continue;
}
if( !Sblock::isstatus( ch ) ) { error = true; break; }
*p += ch;
@@ -237,7 +237,7 @@ int change_types( Domain & domain, const char * const
mapname,
{
const Sblock & sb = mapfile.sblock( i );
if( !domain.includes( sb ) )
- { if( domain < sb ) break; else continue; }
+ { if( domain < sb ) break; continue; }
const unsigned j = types1.find( sb.status() );
if( j < types1.size() )
mapfile.change_sblock_status( i, Sblock::Status( types2[j] ) );
@@ -378,7 +378,7 @@ int test_if_done( Domain & domain, const char * const
mapname, const bool del )
{
const Sblock & sb = mapfile.sblock( i );
if( !domain.includes( sb ) )
- { if( domain < sb ) break; else continue; }
+ { if( domain < sb ) break; continue; }
if( sb.status() != Sblock::finished )
{
if( verbosity >= 1 )
@@ -440,7 +440,7 @@ int to_badblocks( const long long offset, Domain & domain,
{
const Sblock & sb = mapfile.sblock( i );
if( !domain.includes( sb ) )
- { if( domain < sb ) break; else continue; }
+ { if( domain < sb ) break; continue; }
if( blocktypes.find( sb.status() ) >= blocktypes.size() ) continue;
for( long long block = ( sb.pos() + offset ) / hardbs;
block * hardbs < sb.end() + offset; ++block )
@@ -477,7 +477,7 @@ int do_show_status( Domain & domain, const char * const
mapname,
{
const Sblock & sb = mapfile.sblock( i );
if( !domain.includes( sb ) )
- { if( domain < sb ) break; else continue; }
+ { if( domain < sb ) break; continue; }
switch( sb.status() )
{
case Sblock::non_tried: non_tried_size += sb.size();
diff --git a/fillbook.cc b/fillbook.cc
index 3a69836..3ee766c 100644
--- a/fillbook.cc
+++ b/fillbook.cc
@@ -71,7 +71,7 @@ int Fillbook::fill_areas()
for( long index = 0; index < sblocks(); ++index )
{
const Sblock & sb = sblock( index );
- if( !domain().includes( sb ) ) { if( domain() < sb ) break; else continue;
}
+ if( !domain().includes( sb ) ) { if( domain() < sb ) break; continue; }
if( sb.end() <= current_pos() ||
filltypes.find( sb.status() ) >= filltypes.size() ) continue;
Block b( sb.pos(), softbs() ); // fill the area a softbs at a time
@@ -162,7 +162,7 @@ int Fillbook::do_fill( const int odes )
for( long i = 0; i < sblocks(); ++i )
{
const Sblock & sb = sblock( i );
- if( !domain().includes( sb ) ) { if( domain() < sb ) break; else continue;
}
+ if( !domain().includes( sb ) ) { if( domain() < sb ) break; continue; }
if( filltypes.find( sb.status() ) >= filltypes.size() ) continue;
if( sb.end() <= current_pos() ) { ++filled_areas; filled_size +=
sb.size(); }
else if( sb.includes( current_pos() ) )
diff --git a/genbook.cc b/genbook.cc
index 7540216..d784c56 100644
--- a/genbook.cc
+++ b/genbook.cc
@@ -170,7 +170,7 @@ int Genbook::do_generate( const int odes )
{
const Sblock & sb = sblock( i );
if( !domain().includes( sb ) )
- { if( domain() < sb ) break; else continue; }
+ { if( domain() < sb ) break; continue; }
if( sb.status() == Sblock::finished ) finished_size += sb.size();
if( sb.status() != Sblock::non_tried ) gensize += sb.size();
}
diff --git a/mapfile.cc b/mapfile.cc
index ba4a4b8..ff1e55a 100644
--- a/mapfile.cc
+++ b/mapfile.cc
@@ -64,7 +64,7 @@ const char * my_fgets( FILE * const f, int & linenum )
}
}
if( len > 0 ) { buf[len] = 0; return buf; }
- else return 0;
+ return 0;
}
diff --git a/rational.cc b/rational.cc
index 3fdb29c..70ccb30 100644
--- a/rational.cc
+++ b/rational.cc
@@ -57,9 +57,9 @@ std::string overflow_string( const int n )
int overflow_value( const long long n, const bool negate = false )
{
if( negate )
- { if( n > 0 ) return -INT_MAX; if( n < 0 ) return INT_MAX; return 0; }
- else
- { if( n > 0 ) return INT_MAX; if( n < 0 ) return -INT_MAX; return 0; }
+ if( n > 0 ) return -INT_MAX; if( n < 0 ) return INT_MAX; return 0;
+
+ if( n > 0 ) return INT_MAX; if( n < 0 ) return -INT_MAX; return 0;
}
} // end namespace
diff --git a/rescuebook.cc b/rescuebook.cc
index 8674277..0c9b2a8 100644
--- a/rescuebook.cc
+++ b/rescuebook.cc
@@ -189,7 +189,7 @@ void Rescuebook::initialize_sizes()
{
const Sblock & sb = sblock( i );
if( !domain().includes( sb ) )
- { if( domain() < sb ) break; else { good = true; continue; } }
+ { if( domain() < sb ) break; good = true; continue; }
switch( sb.status() )
{
case Sblock::non_tried: non_tried_size += sb.size(); good = true;
break;
@@ -838,7 +838,7 @@ Rescuebook::Rescuebook( const long long offset, const long
long insize,
{
const Sblock & sb = sblock( index );
if( !domain().includes( sb ) )
- { if( domain() < sb ) break; else continue; }
+ { if( domain() < sb ) break; continue; }
if( sb.status() == Sblock::non_scraped ||
sb.status() == Sblock::bad_sector )
change_sblock_status( index, Sblock::non_trimmed );
@@ -848,7 +848,7 @@ Rescuebook::Rescuebook( const long long offset, const long
long insize,
{
const Sblock & sb = sblock( index );
if( !domain().includes( sb ) )
- { if( domain() < sb ) break; else continue; }
+ { if( domain() < sb ) break; continue; }
if( sb.status() == Sblock::non_scraped ||
sb.status() == Sblock::non_trimmed )
change_sblock_status( index, Sblock::non_tried );
--
2.17.1
[Bug-ddrescue] [PATCH 3/7] [clang-tidy] Remove const from superfluous locations, Rosen Penev, 2019/10/14