X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwgtpkg-unit.c;fp=src%2Fwgtpkg-unit.c;h=9f143469fc2ca3530fa1f83683f01bca3e6910b5;hb=765d08087bf422c821556400a68e1fb4868f85f3;hp=cca718f32db911a298921be134572d89fd05cca8;hpb=d0cb2a7a1e068a38b4a0c3216ccdbce0e33ecffb;p=src%2Fapp-framework-main.git 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; }