Use %d to parse them as int (since the variables for them as int)
instead of %u, even if they both need to be at least > 0.
--smp was already checked to be >= 1 while --memsize not, so check that
the specified memory size is not < 128 (which is semi-arbitrary, but
enough as a minimum threshold).
---
rescue/rescue.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/rescue/rescue.c b/rescue/rescue.c
index dc56d4b..1c556e5 100644
--- a/rescue/rescue.c
+++ b/rescue/rescue.c
@@ -157,7 +157,7 @@ main (int argc, char *argv[])
else
format = optarg;
} else if (STREQ (long_options[option_index].name, "smp")) {
- if (sscanf (optarg, "%u", &smp) != 1) {
+ if (sscanf (optarg, "%d", &smp) != 1) {
fprintf (stderr, _("%s: could not parse --smp parameter
'%s'\n"),
program_name, optarg);
exit (EXIT_FAILURE);
@@ -208,11 +208,19 @@ main (int argc, char *argv[])
break;
case 'm':
- if (sscanf (optarg, "%u", &memsize) != 1) {
+ if (sscanf (optarg, "%d", &memsize) != 1) {
fprintf (stderr, _("%s: could not parse memory size '%s'\n"),
program_name, optarg);
exit (EXIT_FAILURE);
}
+ /* Check with a semi-arbitrary value, but avoids too small values
+ * (including <= 0)
+ */
+ if (memsize < 128) {
+ fprintf (stderr, _("%s: memory size %d is too small\n"),
+ program_name, memsize);
+ exit (EXIT_FAILURE);
+ }
break;
case 'r':
--
1.9.3