Skip to content

Commit

Permalink
Don't add negative integers unnecessarily
Browse files Browse the repository at this point in the history
  • Loading branch information
andy5995 committed Nov 4, 2024
1 parent d88489e commit 214af8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,9 @@ Please check your configuration file and permissions\
int file_arg = 0;
for (file_arg = optind - 1; file_arg < argc; file_arg++)
{
r += restore(argv[file_arg], &st_time_var, &cli_user_options,
st_config_data.st_waste_folder_props_head);
if (restore(argv[file_arg], &st_time_var, &cli_user_options,
st_config_data.st_waste_folder_props_head) != 0)
r++;
}

dispose_waste(st_config_data.st_waste_folder_props_head);
Expand Down
11 changes: 6 additions & 5 deletions src/restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ restore_select(st_waste *waste_head, st_time *st_time_var,
const int start_line_bottom = 7;
const int min_lines_required = start_line_bottom + 3;
int c = 0;
int r = 0;
int restore_err_ctr = 0;
do
{
int n_choices = 0;
Expand Down Expand Up @@ -487,8 +487,8 @@ restore_select(st_waste *waste_head, st_time *st_time_var,
{
char *recover_file =
join_paths(waste_curr->files, item_name(items[i]));
r +=
restore(recover_file, st_time_var, cli_user_options, waste_head);
if (restore(recover_file, st_time_var, cli_user_options, waste_head) != 0)
restore_err_ctr++;
free(recover_file);
}
}
Expand Down Expand Up @@ -517,7 +517,7 @@ restore_select(st_waste *waste_head, st_time *st_time_var,
}
while (c != MENU_KEY_ESC && c != 'q' && c != MENU_KEY_ENTER);

return r;
return restore_err_ctr;
}
#endif

Expand All @@ -536,7 +536,8 @@ undo_last_rmw(st_time *st_time_var, const
while (line != NULL)
{
trim_whitespace(line);
r += restore(line, st_time_var, cli_user_options, waste_head);
if (restore(line, st_time_var, cli_user_options, waste_head) != 0)
r++;
line = strtok(NULL, "\n");
}

Expand Down

0 comments on commit 214af8e

Please sign in to comment.