[Asterisk-code-review] config.c: Make ast_variable_retrieve return last match. (asterisk[master])

N A asteriskteam at digium.com
Thu Dec 22 07:43:54 CST 2022


Attention is currently required from: N A.

Hello Joshua Colp, Friendly Automation, 

I'd like you to reexamine a change. Please visit

    https://gerrit.asterisk.org/c/asterisk/+/19744

to look at the new patch set (#2).

Change subject: config.c: Make ast_variable_retrieve return last match.
......................................................................

config.c: Make ast_variable_retrieve return last match.

ast_variable_retrieve currently returns the first match
for a variable, as opposed to the last one. This is problematic
because modules that load config settings by explicitly
calling ast_variable_retrieve on a variable name (as opposed
to iterating through all the directives as specified) will
end up taking the first specified value, such as the default
value from the template rather than the actual effective value
in an individual config section, leading to the wrong config.

This fixes this by making ast_variable_retrieve return the last
match, or the most recently overridden one, as the effective setting.
This is similar to what the -1 index in the AST_CONFIG function does.

There is another function, ast_variable_find_last_in_list, that does
something similar. However, it's a slightly different API, and it
sees virtually no usage in Asterisk. ast_variable_retrieve is what
most things use so this is currently the relevant point of breakage.

ASTERISK-30370 #close

Change-Id: Ia681407275a557c1462f93832a4d45f31c580354
---
A doc/UPGRADE-staging/config_templates.txt
M main/config.c
2 files changed, 54 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/44/19744/2
-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19744
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ia681407275a557c1462f93832a4d45f31c580354
Gerrit-Change-Number: 19744
Gerrit-PatchSet: 2
Gerrit-Owner: N A <asterisk at phreaknet.org>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Attention: N A <asterisk at phreaknet.org>
Gerrit-MessageType: newpatchset
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221222/ef5af8f9/attachment.html>


More information about the asterisk-code-review mailing list