On Mon, Dec 30, 2019 at 11:57:39PM +0100, Klemens Nanni wrote: > No functional change, just a tiny hoisting in the parser I'd like to > better reflect the order in which we parse the tokens. > > If the given domain was already specified, don't bother allocating and > initializing it. > > Drop the obvious comment while here. Simple batch that does not require LDOM specific knowledge, but parse.y friends are welcome :)
I want to commit this soon to reduce churn and avoid shuffling around other diffs in my tree. OK? Index: parse.y =================================================================== RCS file: /cvs/src/usr.sbin/ldomctl/parse.y,v retrieving revision 1.13 diff -u -p -r1.13 parse.y --- parse.y 28 Nov 2019 18:40:42 -0000 1.13 +++ parse.y 7 Jan 2020 23:47:05 -0000 @@ -110,6 +110,12 @@ grammar : /* empty */ ; domain : DOMAIN STRING optnl '{' optnl { + struct domain *odomain; + SIMPLEQ_FOREACH(odomain, &conf->domain_list, entry) + if (strcmp(odomain->name, $2) == 0) { + yyerror("duplicate domain name: %s", $2); + YYERROR; + } domain = xzalloc(sizeof(struct domain)); domain->name = $2; SIMPLEQ_INIT(&domain->vdisk_list); @@ -118,13 +124,6 @@ domain : DOMAIN STRING optnl '{' optnl SIMPLEQ_INIT(&domain->iodev_list); } domainopts_l '}' { - /* domain names need to be unique. */ - struct domain *odomain; - SIMPLEQ_FOREACH(odomain, &conf->domain_list, entry) - if (strcmp(odomain->name, $2) == 0) { - yyerror("duplicate domain name: %s", $2); - YYERROR; - } SIMPLEQ_INSERT_TAIL(&conf->domain_list, domain, entry); domain = NULL; }