<p></p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/smititelu/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/smititelu">@smititelu</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pkuzak/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pkuzak">@pkuzak</a> - it is a misunderstanding of what $var() is supposed to do and how it acts. It is not only about an extra int field, it is about the concept behind $var().</p>
<p dir="auto">What <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/smititelu/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/smititelu">@smititelu</a> gave as an example is what the note in docs try to say and what I gave as an example above.</p>
<p dir="auto">It can create big problems no matter is with the warning or not in the C code, because it still keeps the value from previous assignment.</p>
<p dir="auto">Let's say you have this situation:</p>
<ul dir="auto">
<li>first request has SOME_HEADER (the variable is assigned, and by that no warning log)</li>
<li>the next request is without SOME_HEADER, but the var still has the value from first request and practically, during processing the 2nd request you use wrong value</li>
</ul>
<p dir="auto">Coming back to <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/smititelu/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/smititelu">@smititelu</a> example, you have to set var to a value that you can compare with, like:</p>
<pre class="notranslate"><code class="notranslate">$var(data)="";
if (is_present_hf("SOME_HEADER")) {
    $var(data) = _get_data_from_some_header_;
}
if ($var(data) != "") {
    _do_something_with_data_
}
</code></pre>
<p dir="auto">Which is same concept as with my <code class="notranslate">while</code> example above.</p>
<p dir="auto">Or use $x/avp() without setting a value and compare with $null.</p>
<p dir="auto">As I said, I don't see any benefit with the PR, irrelevant of being optional or not.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/pull/3114#issuecomment-1128906490">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZNNPORIKB2EWFFPOY3VKOQYTANCNFSM5WEMKM5Q">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/ABO7UZIHMDQTP5QOT542RFLVKOQYTA5CNFSM5WEMKM52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOINE356Q.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><kamailio/kamailio/pull/3114/c1128906490</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/pull/3114#issuecomment-1128906490",
"url": "https://github.com/kamailio/kamailio/pull/3114#issuecomment-1128906490",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>