From c9157709ba226761a9a40eed628359fb3d0e98cc Mon Sep 17 00:00:00 2001
From: Steven Murray <steven.murray@cern.ch>
Date: Wed, 20 Nov 2013 19:30:01 +0100
Subject: [PATCH] Fixed some bugs in the rmc client library so that the
 unittests now pass.

---
 mediachanger/castorrmc/rmc/rmc_get_acs_drive_id.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/mediachanger/castorrmc/rmc/rmc_get_acs_drive_id.c b/mediachanger/castorrmc/rmc/rmc_get_acs_drive_id.c
index dc78a44a94..0196a8f864 100644
--- a/mediachanger/castorrmc/rmc/rmc_get_acs_drive_id.c
+++ b/mediachanger/castorrmc/rmc/rmc_get_acs_drive_id.c
@@ -36,7 +36,6 @@
 static int rmc_buf2uint(const char *const buf, int buflen) {
 	int i = 0;
 	int value = 0;
-	int multipler = 1;
 
 	/* Fail conversion if there is nothing to convert */
 	if(NULL == buf || 0 == buflen) {
@@ -50,10 +49,8 @@ static int rmc_buf2uint(const char *const buf, int buflen) {
 		if(c < '0' || c > '9') {
 			return -1;
 		}
-		value *= multipler;
+		value *= 10;
 		value += (c - '0');
-
-		multipler *= 10;
 	}
 	return value;
 }
@@ -107,11 +104,11 @@ int rmc_get_acs_drive_id(const char *const drive,
 
 	/* Try to convert the 4 drive id numbers to integers */
 	drive_id->acs = rmc_buf2uint(drive + commaIndex[0] + 1,
-		commaIndex[1] - commaIndex[0]);
+		commaIndex[1] - commaIndex[0] - 1);
 	drive_id->lsm = rmc_buf2uint(drive + commaIndex[1] + 1,
-		commaIndex[2] - commaIndex[1]);
+		commaIndex[2] - commaIndex[1] - 1);
 	drive_id->panel = rmc_buf2uint(drive + commaIndex[2] + 1,
-		commaIndex[3] - commaIndex[2]);
+		commaIndex[3] - commaIndex[2] - 1);
 	drive_id->transport = rmc_buf2uint(drive + commaIndex[3] + 1,
 		str_len - 1 - commaIndex[3]);
 
-- 
GitLab