Change in ...osmo-msc[master]: libmsc/msc_vty.c: do not abuse strlen() to check char buffers

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Jun 3 07:18:41 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-msc/+/14261 )

Change subject: libmsc/msc_vty.c: do not abuse strlen() to check char buffers
......................................................................

libmsc/msc_vty.c: do not abuse strlen() to check char buffers

In the most cases we need to check whether particular char buffer
is empty or not. Using strlen() for that involves more CPU power,
so let's just check the first character against '\0'.

Change-Id: I8728876b80c870e82247e6e56f719e10ed322a95
---
M src/libmsc/msc_vty.c
1 file changed, 3 insertions(+), 4 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  osmith: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/libmsc/msc_vty.c b/src/libmsc/msc_vty.c
index 5b0cfc4..8a976cb 100644
--- a/src/libmsc/msc_vty.c
+++ b/src/libmsc/msc_vty.c
@@ -793,11 +793,11 @@
 {
 	char buf[128];
 
-	if (strlen(vsub->name)) {
+	if (vsub->name[0] != '\0') {
 		MSC_VTY_DUMP(vty, offset, "Name: '%s'%s",
 			     vsub->name, VTY_NEWLINE);
 	}
-	if (strlen(vsub->msisdn)) {
+	if (vsub->msisdn[0] != '\0') {
 		MSC_VTY_DUMP(vty, offset, "MSISDN: %s%s",
 			     vsub->msisdn, VTY_NEWLINE);
 	}
@@ -873,8 +873,7 @@
 		     osmo_fsm_inst_state_name(vsub->sgs_fsm),
 		     VTY_NEWLINE);
 	MSC_VTY_DUMP(vty, offset, "SGs-MME: %s%s",
-		     strlen(vsub->sgs.mme_name) ?
-		             vsub->sgs.mme_name : "(none)",
+		     vsub->sgs.mme_name[0] != '\0' ? vsub->sgs.mme_name : "(none)",
 		     VTY_NEWLINE);
 
 	MSC_VTY_DUMP(vty, offset, "Use count total: %d%s",

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/14261
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: I8728876b80c870e82247e6e56f719e10ed322a95
Gerrit-Change-Number: 14261
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190603/994cdc37/attachment.html>


More information about the gerrit-log mailing list