From 5bc3052dfbd51b44642eedbf640f94ed069e6380 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 4 Nov 2005 15:53:48 +0000 Subject: [PATCH] Fix off by one for last Slot of autochanger for label. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2539 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/ua_label.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bacula/src/dird/ua_label.c b/bacula/src/dird/ua_label.c index eb99e716c2..00889c90ac 100644 --- a/bacula/src/dird/ua_label.c +++ b/bacula/src/dird/ua_label.c @@ -66,11 +66,12 @@ static bool get_user_slot_list(UAContext *ua, char *slot_list, int num_slots) int i; const char *msg; + /* slots are numbered 1 to num_slots */ for (int i=0; i <= num_slots; i++) { slot_list[i] = 0; } i = find_arg_with_value(ua, "slots"); - if (i >= 0) { + if (i > 0) { /* scan slot list in ua->argv[i] */ char *p, *e, *h; int beg, end; @@ -117,7 +118,7 @@ static bool get_user_slot_list(UAContext *ua, char *slot_list, int num_slots) msg = _("Values must be be greater than zero.\n"); goto bail_out; } - if (end >= num_slots) { + if (end > num_slots) { msg = _("Slot too large.\n"); goto bail_out; } @@ -127,14 +128,14 @@ static bool get_user_slot_list(UAContext *ua, char *slot_list, int num_slots) } } else { /* Turn everything on */ - for (i=0; i <= num_slots; i++) { + for (i=1; i <= num_slots; i++) { slot_list[i] = 1; } } Dmsg0(100, "Slots turned on:\n"); for (i=1; i <= num_slots; i++) { if (slot_list[i]) { - Dmsg1(100, "%d\n", i); + Dmsg1(000, "%d\n", i); } } return true; -- 2.39.5