<p> Attention is currently required from: Kevin Harwell. </p>
<p><a href="https://gerrit.asterisk.org/c/asterisk/+/17792">View Change</a></p><p>2 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="null">File main/pbx_variables.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/c/asterisk/+/17792/comment/9313359e_c3bdadbc">Patch Set #1, Line 116:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">static struct varshead systemvars = AST_LIST_HEAD_NOLOCK_INIT_VALUE;<br>static struct varshead specialchanvars = AST_LIST_HEAD_NOLOCK_INIT_VALUE;<br>static struct varshead modvars = AST_LIST_HEAD_NOLOCK_INIT_VALUE;<br>static struct varshead modeditvars = AST_LIST_HEAD_NOLOCK_INIT_VALUE;<br></pre></blockquote></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">Unless there are 10's of thousands or more you probably don't have to worry much about performance o […]</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">I'll look into the vector approach. Yes, things would really only be added whenever modules load, so more or less when Asterisk starts. I think we should optimize for fast search since this could be used a LOT during runtime (read only), but if adding things is a little bit slower, that wouldn't be a big deal, as it's more or less read-only after modules are loaded.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/c/asterisk/+/17792/comment/3fed393a_ce7d9847">Patch Set #1, Line 155:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">int ast_varname_reserved(const char *name)<br>{<br> char *tmp = (char*) name;<br> /* Asterisk broadly reserves all uppercase + underscore var names for use by Asterisk */<br> while (*tmp) {<br> if (tmp[0] != '_' && !isupper(tmp[0])) {<br> return 0;<br> }<br> tmp++;<br> }<br> return 1;<br>}<br></pre></blockquote></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">I misread the code a bit here. But now I see it appears to return 0 (i.e. […]</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Hmm... it seemed this was a longstanding unofficial "rule" but maybe it's more legendary myth at this point than an established policy.</p><p style="white-space: pre-wrap; word-wrap: break-word;">For instance, from p. 97 of Asterisk: The Definitive Guide 5th ed.: "Note that variable names are case-sensitive. A variable named SOME DIGITS is different from a variable named SomeDigits. You should also be aware that any variables set by Asterisk will be uppercase. Some variables, such as CHANNEL and EXTEN, are reserved by Asterisk".</p><p style="white-space: pre-wrap; word-wrap: break-word;">So Asterisk is reserved to using only variable names consisting solely of uppercase letters and underscores.</p><p style="white-space: pre-wrap; word-wrap: break-word;">When I started with Asterisk, I used a few all uppercase var names for globals and was quickly scolded by someone who'd been using it for 20+ years now:<br>"Variable names. Any Variable name which does not include at least ONE lower-case letter is reserved for use by the Asterisk developers. You should never use variable names that are all upper case, because you might run into something that gets added in the future or is undocumented."</p><p style="white-space: pre-wrap; word-wrap: break-word;">So somehow or another, this seems to have become entrenched amongst the user base and is at least implicitly observed by developers.</p><p style="white-space: pre-wrap; word-wrap: break-word;">A good example of the latter point is some of the internal variables that aren't documented anywhere in individual modules, such as in app_while how it stores information in variables for its own use. These variables wouldn't get registered since they're not user-facing, and a user could happen to use the same name and wonder why things are getting messed up. But this is probably an edge case.</p><p style="white-space: pre-wrap; word-wrap: break-word;">All this said, and that last point aside, the upside of variable registration is if there is truly a conflict, we can find it and warn about it, so maybe it's not necessary to warn about a possible conflict at large, unless we've established that a conflict in fact exists. So I can probably take out this part either way.</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17792">change 17792</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/17792"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Iad3b8d9833c7d9debe04aca59260d7316c3ad28c </div>
<div style="display:none"> Gerrit-Change-Number: 17792 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Attention: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Fri, 14 Jan 2022 01:11:47 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Comment-In-Reply-To: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Comment-In-Reply-To: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: comment </div>