aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-11-21 08:53:17 -0800
committerDamjan Marion <dmarion@me.com>2018-11-23 13:35:05 +0000
commit3b4c64e13386e7419f109cd02af4f67e2d6bf55e (patch)
tree034cc12e9143d495d84a910cc734d61ea5ea3a56 /src
parente0152461cbc84d6d4df3f05dddabe992c1c59052 (diff)
session: fix coverity app name warning
Change-Id: I1bbad8716b9be3f2413aaebd400887c1e2aa3c7a Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/session/application_interface.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/vnet/session/application_interface.c b/src/vnet/session/application_interface.c
index 2a09909dbef..f0722d6af19 100644
--- a/src/vnet/session/application_interface.c
+++ b/src/vnet/session/application_interface.c
@@ -481,6 +481,19 @@ app_validate_namespace (u8 * namespace_id, u64 secret, u32 * app_ns_index)
return 0;
}
+static u8 *
+app_name_from_api_index (u32 api_client_index)
+{
+ vl_api_registration_t *regp;
+ regp = vl_api_client_index_to_registration (api_client_index);
+ if (regp)
+ return format (0, "%s%c", regp->name, 0);
+
+ clib_warning ("api client index %u does not have an api registration!",
+ api_client_index);
+ return format (0, "unknown%c", 0);
+}
+
/**
* Attach application to vpp
*
@@ -501,16 +514,7 @@ vnet_application_attach (vnet_app_attach_args_t * a)
int rv;
if (a->api_client_index != APP_INVALID_INDEX)
- {
- app = application_lookup (a->api_client_index);
- if (!app)
- {
- vl_api_registration_t *regp;
- regp = vl_api_client_index_to_registration (a->api_client_index);
- app_name = format (0, "%s%c", regp->name, 0);
- a->name = app_name;
- }
- }
+ app = application_lookup (a->api_client_index);
else if (a->name)
app = application_lookup_name (a->name);
else
@@ -521,6 +525,12 @@ vnet_application_attach (vnet_app_attach_args_t * a)
return clib_error_return_code (0, VNET_API_ERROR_APP_ALREADY_ATTACHED, 0,
"app already attached");
+ if (a->api_client_index != APP_INVALID_INDEX)
+ {
+ app_name = app_name_from_api_index (a->api_client_index);
+ a->name = app_name;
+ }
+
secret = a->options[APP_OPTIONS_NAMESPACE_SECRET];
if ((rv = app_validate_namespace (a->namespace_id, secret, &app_ns_index)))
return clib_error_return_code (0, rv, 0, "namespace validation: %d", rv);