From bee00658ae652af8cb6d52f1aa06ba726c28f848 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sun, 21 Feb 2021 17:13:44 -0600 Subject: [PATCH] Limit auto-declaration of record types to regRecDevDrv only Allowing this while expanding DBD files for IOCs can insert other device supports before of the Base "Soft Channel" ones, making the other type the default. Adds a note that DBD file order matters. Fixes lp: #1908305 --- .../database/src/template/top/exampleApp/src/xxxSupport.dbd | 2 +- modules/database/src/tools/DBD/Parser.pm | 6 +++++- modules/database/src/tools/registerRecordDeviceDriver.pl | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/database/src/template/top/exampleApp/src/xxxSupport.dbd b/modules/database/src/template/top/exampleApp/src/xxxSupport.dbd index 8094bdda6..64f2e3842 100644 --- a/modules/database/src/template/top/exampleApp/src/xxxSupport.dbd +++ b/modules/database/src/template/top/exampleApp/src/xxxSupport.dbd @@ -1,2 +1,2 @@ include "xxxRecord.dbd" -device(xxx,CONSTANT,devXxxSoft,"SoftChannel") +device(xxx,CONSTANT,devXxxSoft,"Soft Channel") diff --git a/modules/database/src/tools/DBD/Parser.pm b/modules/database/src/tools/DBD/Parser.pm index d7e16ff52..cb046e062 100644 --- a/modules/database/src/tools/DBD/Parser.pm +++ b/modules/database/src/tools/DBD/Parser.pm @@ -29,6 +29,7 @@ use DBD::Function; use DBD::Variable; our $debug=0; +our $allowAutoDeclarations=0; sub ParseDBD { (my $dbd, $_) = @_; @@ -102,8 +103,11 @@ sub ParseDBD { unquote($1, $2, $3, $4); my $rtyp = $dbd->recordtype($record_type); if (!defined $rtyp) { + my $msg = "Device '$choice' defined for unknown record type '$record_type'."; + dieContext($msg, "DBD files must be added in the correct order.") + unless $allowAutoDeclarations; + warn "$msg\nRecord type '$record_type' declared.\n"; $rtyp = DBD::Recordtype->new($record_type); - warn "Device using unknown record type '$record_type', declaration created\n"; $dbd->add($rtyp); } $rtyp->add_device(DBD::Device->new($link_type, $dset, $choice)); diff --git a/modules/database/src/tools/registerRecordDeviceDriver.pl b/modules/database/src/tools/registerRecordDeviceDriver.pl index 74b518a66..8d6bcd1ea 100644 --- a/modules/database/src/tools/registerRecordDeviceDriver.pl +++ b/modules/database/src/tools/registerRecordDeviceDriver.pl @@ -31,6 +31,9 @@ my @path = map { split /[:;]/ } @opt_I; # FIXME: Broken on Win32? my ($file, $subname, $bldTop) = @ARGV; +# Permit auto-declaration of record types for building runtime-loadable modules +$DBD::Parser::allowAutoDeclarations = 1; + my $dbd = DBD->new(); ParseDBD($dbd, Readfile($file, "", \@path));