[Asterisk-code-review] pbx.c: Include filesystem cache in free memory calculation (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Thu Jan 16 11:55:10 CST 2020


Richard Mudgett has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/13597 )

Change subject: pbx.c: Include filesystem cache in free memory calculation
......................................................................


Patch Set 2: Code-Review-1

(1 comment)

https://gerrit.asterisk.org/c/asterisk/+/13597/2/main/pbx.c 
File main/pbx.c:

https://gerrit.asterisk.org/c/asterisk/+/13597/2/main/pbx.c@4597 
PS2, Line 4597: (uint64_t) (sys_info.freeram + sys_info.bufferram)
I think you should put parentheses around this piece to ensure that the multiplication is done as a uint64_t and not casting the result of the entire computation after it has lost bits due to overflow.

Though you could avoid the need to cast entirely with explicit control over when operations are done by doing it this way:

curfreemem = sys_info.freeram + sys_info.bufferram;
curfreemem *= sys_info.mem_unit;
curfreemem /= 1024 * 1024;

Should also add a note that the calculation was done this way to avoid overflow problems.



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

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: Ief098bb6eb77378daeace8f97ba30701c8de55b8
Gerrit-Change-Number: 13597
Gerrit-PatchSet: 2
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Comment-Date: Thu, 16 Jan 2020 17:55: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/20200116/39acaaac/attachment.html>


More information about the asterisk-code-review mailing list