From 0b6ce3182d38e8d7d0fe30b67e1add4e8fb607d4 Mon Sep 17 00:00:00 2001 From: PartialVolume Date: Sun, 5 Jan 2020 21:10:50 +0000 Subject: [PATCH 1/2] Fix percentage calculation when rounds > 1 Update comment. --- src/method.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/method.c b/src/method.c index 04e54ff..53c73b6 100644 --- a/src/method.c +++ b/src/method.c @@ -684,7 +684,8 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns ) c->round_count = nwipe_options.rounds; /* Set the number of bytes that will be written across all rounds. */ - c->round_size = c->round_count * c->pass_size; + //c->round_size = c->round_count * c->pass_size; + c->round_size = c->pass_size; /* For the selected method, calculate the correct round_size value (for correct percentage calculation) */ calculate_round_size( c ); @@ -1036,10 +1037,12 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns ) void calculate_round_size( nwipe_context_t* c ) { /* This is where the round size is adjusted. round_size is used in the running percentage completion - * calculation. Adjustment the round size as pass_size and pass_count are not sufficient in - * always calculating round size correctly. To hopefully make this adjustment more - * understanable I have itemised the adjustments under each method. This should make it easier - * to add a new method here without breaking the calculations for other methods. + * calculation. round size is calculated based on pass_size, pass_count, number of rounds, blanking + * on/off and verification on/off + * + * To hopefully make this adjustment more understandable, I have presented each calculation + * under each method. This should make it easier to add a new method here without breaking the + * calculations for other methods. */ /* Don't change the order of these values as the case statements use their index in the array */ @@ -1199,6 +1202,10 @@ void calculate_round_size( nwipe_context_t* c ) } break; } + + /* Multiple the round_size by the number of rounds (times) the user wants to wipe the drive with this method. + */ + c->round_size *= c->round_count; } /* eof */ From d39427ae864a0947a9ca4f3714c9fbae6beef3a1 Mon Sep 17 00:00:00 2001 From: PartialVolume Date: Sun, 5 Jan 2020 21:21:05 +0000 Subject: [PATCH 2/2] clang-format -i -style=file src/method.c Check & correct style. --- src/method.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/method.c b/src/method.c index 53c73b6..9c971b3 100644 --- a/src/method.c +++ b/src/method.c @@ -683,8 +683,7 @@ int nwipe_runmethod( nwipe_context_t* c, nwipe_pattern_t* patterns ) /* Tell the parent the number of rounds that will be run. */ c->round_count = nwipe_options.rounds; - /* Set the number of bytes that will be written across all rounds. */ - //c->round_size = c->round_count * c->pass_size; + /* Set the initial number of bytes that will be written across all rounds. */ c->round_size = c->pass_size; /* For the selected method, calculate the correct round_size value (for correct percentage calculation) */ @@ -1039,7 +1038,7 @@ void calculate_round_size( nwipe_context_t* c ) /* This is where the round size is adjusted. round_size is used in the running percentage completion * calculation. round size is calculated based on pass_size, pass_count, number of rounds, blanking * on/off and verification on/off - * + * * To hopefully make this adjustment more understandable, I have presented each calculation * under each method. This should make it easier to add a new method here without breaking the * calculations for other methods. @@ -1202,7 +1201,7 @@ void calculate_round_size( nwipe_context_t* c ) } break; } - + /* Multiple the round_size by the number of rounds (times) the user wants to wipe the drive with this method. */ c->round_size *= c->round_count;