summaryrefslogtreecommitdiffstats
path: root/usr.bin/ctfconv/parse.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2017-08-11 16:28:29 +0000
committermpi <mpi@openbsd.org>2017-08-11 16:28:29 +0000
commit72c906afffc1ef4d38dcc929b6f444ecf0af2671 (patch)
tree40190c16c8ab306e391dc33d2dde60e427baa6ae /usr.bin/ctfconv/parse.c
parentdisplay MRU each sessions in npppctl session command (diff)
downloadwireguard-openbsd-72c906afffc1ef4d38dcc929b6f444ecf0af2671.tar.xz
wireguard-openbsd-72c906afffc1ef4d38dcc929b6f444ecf0af2671.zip
Do not insert random name for anonymous member.
Diffstat (limited to 'usr.bin/ctfconv/parse.c')
-rw-r--r--usr.bin/ctfconv/parse.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/usr.bin/ctfconv/parse.c b/usr.bin/ctfconv/parse.c
index 3cfa227a387..5ce2f275105 100644
--- a/usr.bin/ctfconv/parse.c
+++ b/usr.bin/ctfconv/parse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.c,v 1.2 2017/08/11 14:58:56 jasper Exp $ */
+/* $OpenBSD: parse.c,v 1.3 2017/08/11 16:28:30 mpi Exp $ */
/*
* Copyright (c) 2016-2017 Martin Pieuchot
@@ -233,7 +233,7 @@ it_dup(struct itype *it)
copit->it_nelems = it->it_nelems;
TAILQ_FOREACH(im, &it->it_members, im_next) {
- copim = im_new(im->im_name, im->im_ref, im->im_off);
+ copim = im_new(im_name(im), im->im_ref, im->im_off);
copim->im_refp = im->im_refp;
TAILQ_INSERT_TAIL(&copit->it_members, copim, im_next);
}
@@ -367,7 +367,7 @@ im_new(const char *name, size_t ref, size_t off)
im->im_off = off;
im->im_refp = NULL;
if (name == NULL) {
- im->im_flags = ITM_ANON;
+ im->im_flags = IMF_ANON;
} else {
size_t n;
@@ -381,6 +381,15 @@ im_new(const char *name, size_t ref, size_t off)
return im;
}
+const char *
+im_name(struct imember *im)
+{
+ if (!(im->im_flags & IMF_ANON))
+ return im->im_name;
+
+ return NULL;
+}
+
void
cu_stat(void)
{
@@ -436,10 +445,9 @@ cu_resolve(struct dwcu *dcu, struct itype_queue *cutq, struct ioff_tree *cuot)
if (toresolve)
printf(": %d members", toresolve);
TAILQ_FOREACH(im, &it->it_members, im_next) {
- if (im->im_refp == NULL) {
- printf("\n%zu: %s", im->im_ref,
- im->im_name);
- }
+ if (im->im_refp != NULL)
+ continue;
+ printf("\n%zu: %s", im->im_ref, im_name(im));
}
printf("\n");
}