aboutsummaryrefslogtreecommitdiffstats
path: root/src/wgtpkg-unit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wgtpkg-unit.c')
-rw-r--r--src/wgtpkg-unit.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/wgtpkg-unit.c b/src/wgtpkg-unit.c
index cca718f..9f14346 100644
--- a/src/wgtpkg-unit.c
+++ b/src/wgtpkg-unit.c
@@ -382,10 +382,14 @@ static int add_metadata(struct json_object *jdesc, const struct unitconf *conf)
n = json_object_array_length(targets);
for (i = 0 ; i < n ; i++) {
targ = json_object_array_get_idx(targets, i);
- port = conf->port();
- if (port < 0)
- return port;
- sprintf(portstr, "%d", port);
+ if (!conf->port)
+ strcpy(portstr, "0");
+ else {
+ port = conf->port ? conf->port() : 0;
+ if (port < 0)
+ return port;
+ sprintf(portstr, "%d", port);
+ }
if (!j_add_string_m(targ, "#metatarget.http-port", portstr))
return -1;
}