Change in osmo-hlr[master]: vty: show subscriber: change format of 'last LU seen'

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Fri May 1 14:37:37 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/15359 )

Change subject: vty: show subscriber: change format of 'last LU seen'
......................................................................

vty: show subscriber: change format of 'last LU seen'

So far, the time string format comes from ctime_r, and we manually add "UTC" to it.

The ctime_r format is wildly chaotic IMHO, mixing weekday, day-of-month and
hour and year in very unsorted ways.

Adding "UTC" to it is non-standard.

Instead use an ISO-8601 standardized time string via strftime().

Change-Id: I6731968f05050399f4dd43b241290186e0c59e1a
---
M src/hlr_vty_subscr.c
1 file changed, 7 insertions(+), 11 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve



diff --git a/src/hlr_vty_subscr.c b/src/hlr_vty_subscr.c
index 14a37f2..8079d10 100644
--- a/src/hlr_vty_subscr.c
+++ b/src/hlr_vty_subscr.c
@@ -36,25 +36,21 @@
 
 #define hexdump_buf(buf) osmo_hexdump_nospc((void*)buf, sizeof(buf))
 
-static char *
-get_datestr(const time_t *t, char *datebuf)
+static char *get_datestr(const time_t *t, char *buf, size_t bufsize)
 {
-	char *p, *s = ctime_r(t, datebuf);
-
-	/* Strip trailing newline. */
-	p = strchr(s, '\n');
-	if (p)
-		*p = '\0';
-	return s;
+	struct tm tm;
+	gmtime_r(t, &tm);
+	strftime(buf, bufsize, "%FT%T+00:00", &tm);
+	return buf;
 }
 
 static void dump_last_lu_seen(struct vty *vty, const char *domain_label, time_t last_lu_seen)
 {
 	uint32_t age;
-	char datebuf[26]; /* for ctime_r(3) */
+	char datebuf[32];
 	if (!last_lu_seen)
 		return;
-	vty_out(vty, "    last LU seen on %s: %s UTC", domain_label, get_datestr(&last_lu_seen, datebuf));
+	vty_out(vty, "    last LU seen on %s: %s", domain_label, get_datestr(&last_lu_seen, datebuf, sizeof(datebuf)));
 	if (!timestamp_age(&last_lu_seen, &age))
 		vty_out(vty, " (invalid timestamp)%s", VTY_NEWLINE);
 	else

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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I6731968f05050399f4dd43b241290186e0c59e1a
Gerrit-Change-Number: 15359
Gerrit-PatchSet: 29
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-CC: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200501/f4ab1d89/attachment.htm>


More information about the gerrit-log mailing list