summaryrefslogtreecommitdiff
path: root/src/shred.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shred.c')
-rw-r--r--src/shred.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/src/shred.c b/src/shred.c
index b235b29ae..2e5719914 100644
--- a/src/shred.c
+++ b/src/shred.c
@@ -86,7 +86,7 @@
#include "system.h"
#include "argmatch.h"
-#include "xstrtol.h"
+#include "xdectoint.h"
#include "error.h"
#include "fcntl--.h"
#include "human.h"
@@ -1228,16 +1228,10 @@ main (int argc, char **argv)
break;
case 'n':
- {
- uintmax_t tmp;
- if (xstrtoumax (optarg, NULL, 10, &tmp, NULL) != LONGINT_OK
- || MIN (ULONG_MAX, SIZE_MAX / sizeof (int)) <= tmp)
- {
- error (EXIT_FAILURE, 0, _("%s: invalid number of passes"),
- quotearg_colon (optarg));
- }
- flags.n_iterations = tmp;
- }
+ flags.n_iterations = xdectoumax (optarg, 0,
+ MIN (ULONG_MAX,
+ SIZE_MAX / sizeof (int)), "",
+ _("invalid number of passes"), 0);
break;
case RANDOM_SOURCE_OPTION:
@@ -1255,17 +1249,8 @@ main (int argc, char **argv)
break;
case 's':
- {
- uintmax_t tmp;
- if ((xstrtoumax (optarg, NULL, 0, &tmp, "cbBkKMGTPEZY0")
- != LONGINT_OK)
- || OFF_T_MAX < tmp)
- {
- error (EXIT_FAILURE, 0, _("%s: invalid file size"),
- quotearg_colon (optarg));
- }
- flags.size = tmp;
- }
+ flags.size = xnumtoumax (optarg, 0, 0, OFF_T_MAX, "cbBkKMGTPEZY0",
+ _("invalid file size"), 0);
break;
case 'v':