rmnetctl: Enhancements and bug fixes

This patch introduced a new variable (string len) for
rmnet_get_logical_ep_config as well as a new set of error
values which match the errors produced by rmnet_data.
Additionally, several fixes such as a memory leak and input
checks were applied.

CRs-Fixed: 599231
Change-Id: Ia662b4393d7de0bb1629fb7d3b45bc7c109a9866
diff --git a/rmnetctl/cli/rmnetcli.c b/rmnetctl/cli/rmnetcli.c
index f868836..f6b387e 100644
--- a/rmnetctl/cli/rmnetcli.c
+++ b/rmnetctl/cli/rmnetcli.c
@@ -203,7 +203,8 @@
 	printf(_2TABS" device node\n\n");
 }
 
-static void print_rmnetctl_lib_errors(uint16_t error_number)  {
+static void print_rmnetctl_lib_errors(uint16_t error_number)
+{
 	if ((error_number > RMNETCTL_API_SUCCESS) &&
 		(error_number < RMNETCTL_API_ERR_ENUM_LENGTH)) {
 		printf("%s", rmnetctl_error_code_text[error_number]);
@@ -228,16 +229,13 @@
 {
 	if (return_code == RMNETCTL_SUCCESS)
 		printf("SUCCESS\n");
-	else if (return_code == RMNETCTL_LIB_ERR)
+	else if (return_code == RMNETCTL_LIB_ERR) {
 		printf("LIBRARY ");
-	else if (return_code == RMNETCTL_KERNEL_ERR)
-		printf("KERNEL : Error code %u\n", error_number);
+		print_rmnetctl_lib_errors(error_number);
+	} else if (return_code == RMNETCTL_KERNEL_ERR)
+		printf("KERNEL %s", rmnetctl_error_code_text[error_number]);
 	else if (return_code == RMNETCTL_INVALID_ARG)
 		printf("INVALID_ARG\n");
-
-	if (return_code == RMNETCTL_LIB_ERR) {
-		print_rmnetctl_lib_errors(error_number);
-	}
 }
 
 /*!
@@ -358,7 +356,7 @@
 		}
 		return_code = rmnet_get_logical_ep_config(handle,
 		_STRTOI32(argv[1]), argv[2], &rmnet_mode,
-		&egress_dev_name, &error_number);
+		&egress_dev_name, RMNET_MAX_STR_LEN, &error_number);
 		if (return_code == RMNETCTL_SUCCESS) {
 			printf("rmnet_mode is %u\n", rmnet_mode);
 			printf("egress_dev_name is %s\n", egress_dev_name);