dbLoadRecords with subs=NULL fails to expand macros with defaults

Bug #2052814 reported by Dirk Zimoch
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Confirmed
Undecided
Unassigned

Bug Description

A template file that only contains macros with default values can be loaded with `dbLoadRecords("file.db","")` but not with `dbLoadRecords("file.db",NULL)`. In particular, in the startup script, it cannot be loaded with `dbLoadRecords "file.db"` but only with `dbLoadRecords "file.db",""`. (VxWorks shell as well as iocsh.)

Using such a macro in a record name results in the error message:
ERROR: Bad character '$' in Record/Alias name "$(P=)Name"

Using macros with defaults in fields shows error messages like this:
ERRORName.PREC Has unexpanded macro
Can't set "Name.PREC" to "$(PREC=3)" : Bad Field value
ERRORERROR failed to load 'file.db'

(Unrelated: Someone please fix the missing blanks after ERROR and the ERRORERROR.)

The reason is that `dbReadCOM`, the function that does the real work, only creates a `macHandle` when `substitutions` is not `NULL`. Not having a `macHandle` prevents any macro substitution from working, even those which provide a default value.

In the old times, when macros could not have defaults, this was fine, but not any more. A macro handle should always be created, even if it stays empty when `substitutions` is `NULL`.

description: updated
Revision history for this message
Andrew Johnson (anj) wrote :

Hi Dirk, I know we probably haven’t changed the instructions somewhere (feel free to point out where if you know), but other than the emails that Launchpad sends out we don’t often look at bug reports on Launchpad now, please file new bugs EPICS Base on GitHub instead of here.

I saw this exact same issue myself a few weeks ago so I agree that it’s a bug that has a fairly easy fix (remove the conditional check and always call the macLib expansion routine). If you’d like to post a PR on GitHub that would be great; I might get around to it at some point if/when I look at the bugs here, but it’s a lower priority for me than my APS Upgrade project work, so I’d welcome your help.

Thanks,

- Andrew

Changed in epics-base:
status: New → Confirmed
Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :

Hi Andrew, no problem. Should we then „retire“ Launchpad and fully switch to GitHub? I find it confusing to have multiple bug trackers for the same project.

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.