[sr-dev] [kamailio/kamailio] pv: log uninit $var() (PR #3114)

Daniel-Constantin Mierla notifications at github.com
Tue May 17 15:58:33 CEST 2022


@smititelu, @pkuzak - 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().

What @smititelu gave as an example is what the note in docs try to say and what I gave as an example above. 

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.

Let's say you have this situation:

- first request has SOME_HEADER (the variable is assigned, and by that no warning log)
- 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

Coming back to @smititelu example, you have to set var to a value that you can compare with, like:

```
$var(data)="";
if (is_present_hf("SOME_HEADER")) {
    $var(data) = _get_data_from_some_header_;
}
if ($var(data) != "") {
    _do_something_with_data_
}
```

Which is same concept as with my `while` example above.

Or use $x/avp() without setting a value and compare with $null.

As I said, I don't see any benefit with the PR, irrelevant of being optional or not.


-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/3114#issuecomment-1128906490
You are receiving this because you are subscribed to this thread.

Message ID: <kamailio/kamailio/pull/3114/c1128906490 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20220517/b57d141f/attachment.htm>


More information about the sr-dev mailing list