changeset 197:3ddbc3fea5f0

encode_plmn_3bytes() error handling change in preparation for PLMN list reading addition
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 07 Mar 2021 02:36:27 +0000
parents c804f2f8c138
children 3bde063234aa
files libutil/plmncodes.c simtool/fplmn.c simtool/plmnsel.c
diffstat 3 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libutil/plmncodes.c	Sun Mar 07 01:56:02 2021 +0000
+++ b/libutil/plmncodes.c	Sun Mar 07 02:36:27 2021 +0000
@@ -32,10 +32,8 @@
 {
 	u_char mcc[3], mnc[3];
 
-	if (!isxdigit(asc[0]) || !isxdigit(asc[1]) || !isxdigit(asc[2])) {
-inv:		fprintf(stderr, "error: invalid MCC-MNC argument\n");
+	if (!isxdigit(asc[0]) || !isxdigit(asc[1]) || !isxdigit(asc[2]))
 		return(-1);
-	}
 	mcc[0] = decode_hex_digit(asc[0]);
 	mcc[1] = decode_hex_digit(asc[1]);
 	mcc[2] = decode_hex_digit(asc[2]);
@@ -43,7 +41,7 @@
 	if (*asc == '-')
 		asc++;
 	if (!isxdigit(asc[0]) || !isxdigit(asc[1]))
-		goto inv;
+		return(-1);
 	mnc[0] = decode_hex_digit(asc[0]);
 	mnc[1] = decode_hex_digit(asc[1]);
 	asc += 2;
@@ -52,7 +50,7 @@
 	else if (isxdigit(asc[0]) && asc[1] == '\0')
 		mnc[2] = decode_hex_digit(*asc);
 	else
-		goto inv;
+		return(-1);
 	bin[0] = (mcc[1] << 4) | mcc[0];
 	bin[1] = (mnc[2] << 4) | mcc[2];
 	bin[2] = (mnc[1] << 4) | mnc[0];
--- a/simtool/fplmn.c	Sun Mar 07 01:56:02 2021 +0000
+++ b/simtool/fplmn.c	Sun Mar 07 02:36:27 2021 +0000
@@ -83,8 +83,10 @@
 		return(-1);
 	}
 	rc = encode_plmn_3bytes(argv[2], rec);
-	if (rc < 0)
+	if (rc < 0) {
+		fprintf(stderr, "error: invalid MCC-MNC argument\n");
 		return(rc);
+	}
 	return update_bin_op(idx * 3, rec, 3);
 }
 
--- a/simtool/plmnsel.c	Sun Mar 07 01:56:02 2021 +0000
+++ b/simtool/plmnsel.c	Sun Mar 07 02:36:27 2021 +0000
@@ -110,8 +110,10 @@
 		return(-1);
 	}
 	rc = encode_plmn_3bytes(argv[2], rec);
-	if (rc < 0)
+	if (rc < 0) {
+		fprintf(stderr, "error: invalid MCC-MNC argument\n");
 		return(rc);
+	}
 	return update_bin_op(idx * 3, rec, 3);
 }