revisit some calls of strtol(), stroul(), strtoull()

Replace some with atoi(), where the VTY has already validated correct
range of the argument.

Replace others with the new osmo_str_to_int() or osmo_str_to_int64()
functions, possibly covering more detection of invalid number strings.

Leave those strtol() callers that depend on endptr to provide the next
string token.

Related: SYS#5542
Change-Id: I0ebb06e751c28f7d1cdf328de29cd227a2449391
diff --git a/src/gsm/gsm23003.c b/src/gsm/gsm23003.c
index c2b3de8..f3c0123 100644
--- a/src/gsm/gsm23003.c
+++ b/src/gsm/gsm23003.c
@@ -487,22 +487,23 @@
  */
 int osmo_mnc_from_str(const char *mnc_str, uint16_t *mnc, bool *mnc_3_digits)
 {
-	long int _mnc = 0;
+	int _mnc = 0;
 	bool _mnc_3_digits = false;
-	char *endptr;
 	int rc = 0;
 
 	if (!mnc_str || !isdigit((unsigned char)mnc_str[0]) || strlen(mnc_str) > 3)
 		return -EINVAL;
 
-	errno = 0;
-	_mnc = strtol(mnc_str, &endptr, 10);
-	if (errno)
-		rc = -errno;
-	else if (*endptr)
+	rc = osmo_str_to_int(&_mnc, mnc_str, 10, 0, 999);
+	/* Heed the API definition to return -EINVAL in case of surplus chars */
+	if (rc == -E2BIG)
 		return -EINVAL;
-	if (_mnc < 0 || _mnc > 999)
-		return -ERANGE;
+	/* Heed the API definition to always return negative errno */
+	if (rc > 0)
+		return -rc;
+	if (rc < 0)
+		return rc;
+
 	_mnc_3_digits = strlen(mnc_str) > 2;
 
 	if (mnc)