[Asterisk-code-review] func_math: Three new dialplan functions (asterisk[16])

Kevin Harwell asteriskteam at digium.com
Wed May 19 18:09:10 CDT 2021


Kevin Harwell has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/15906 )

Change subject: func_math: Three new dialplan functions
......................................................................


Patch Set 6: Code-Review-1

(6 comments)

https://gerrit.asterisk.org/c/asterisk/+/15906/6/funcs/func_math.c 
File funcs/func_math.c:

https://gerrit.asterisk.org/c/asterisk/+/15906/6/funcs/func_math.c@502 
PS6, Line 502: int1 = 0;
if num1 is not specified I think this should be set int2 (once parsed). As is this could result in min being 0 if num2 is positive when I'd expect it would be whatever num2 was set to.


https://gerrit.asterisk.org/c/asterisk/+/15906/6/funcs/func_math.c@500 
PS6, Line 500: 
             : 	if (ast_strlen_zero(args.num1) || sscanf(args.num1, "%30d", &int1) != 1) {
             : 		int1 = 0;
             : 	}
             : 
             : 	if (ast_strlen_zero(args.num2) || sscanf(args.num2, "%30d", &int2) != 1) {
             : 		int2 = int1;
             : 	}
Use ast_str_to_int (conversions.h) instead of sscanf.


https://gerrit.asterisk.org/c/asterisk/+/15906/6/funcs/func_math.c@528 
PS6, Line 528: 		int1 = 0;
Similar to the min situation but reversed. If num1 is not specified I think this should be set int2 (once parsed). As is this could result in max being 0 if num2 is negative when I'd expect it would be whatever num2 was set to.


https://gerrit.asterisk.org/c/asterisk/+/15906/6/funcs/func_math.c@527 
PS6, Line 527: 	if (ast_strlen_zero(args.num1) || sscanf(args.num1, "%30d", &int1) != 1) {
             : 		int1 = 0;
             : 	}
             : 
             : 	if (ast_strlen_zero(args.num2) || sscanf(args.num2, "%30d", &int2) != 1) {
             : 		int2 = int1;
             : 	}
Use ast_str_to_int (conversions.h) instead of sscanf.


https://gerrit.asterisk.org/c/asterisk/+/15906/6/funcs/func_math.c@552 
PS6, Line 552: 	if (ast_strlen_zero(args.num1) || sscanf(args.num1, "%30d", &int1) != 1) {
Use ast_str_to_int (conversions.h) instead of sscanf.


https://gerrit.asterisk.org/c/asterisk/+/15906/6/funcs/func_math.c@553 
PS6, Line 553: 		int1 = 0;
I wonder if this path (no number specified or error) should result in something like "NaN", or at least maybe a warning?



-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15906
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I2bda9269d18f9d54833c85e48e41fce0e0ce4d8d
Gerrit-Change-Number: 15906
Gerrit-PatchSet: 6
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-CC: Ivan Poddubny <ivan.poddubny at gmail.com>
Gerrit-Comment-Date: Wed, 19 May 2021 23:09:10 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210519/4da21d61/attachment.html>


More information about the asterisk-code-review mailing list