Change in libosmocore[master]: ctrl: Pre-calculate required size before allocating msgb

dexter gerrit-no-reply at lists.osmocom.org
Fri Jun 11 20:34:39 UTC 2021


dexter has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/24639 )

Change subject: ctrl: Pre-calculate required size before allocating msgb
......................................................................


Patch Set 1: Code-Review+1

(2 comments)

https://gerrit.osmocom.org/c/libosmocore/+/24639/1/tests/ctrl/ctrl_test.c 
File tests/ctrl/ctrl_test.c:

https://gerrit.osmocom.org/c/libosmocore/+/24639/1/tests/ctrl/ctrl_test.c@120 
PS1, Line 120: 
> It's not unrelated, I explain why is it related in the commit description. […]
I guess we can not simply do an msgb_put_u8 anymore to make sure that the string in sent_msg is terminated because the messages now are exactly as long as the string so we need to copy it into a buffer first. osmo_escape_str() would probably also not work, it has to store the terminating 0 also somewhere. I think this makes sense and it also means that this change is not unrelated. Maybe a comment about this may help to understand it better.


https://gerrit.osmocom.org/c/libosmocore/+/24639/1/tests/ctrl/ctrl_test.c@121 
PS1, Line 121: 		char *strbuf = talloc_size(sent_msg, msgb_l2len(sent_msg) + 1);
> (osmo style would want to declare char *strbuf above the OSMO_ASSERT)
Declaring variables in the middle of the code may not be supported by older compilers anyway. I would declare it at the top of the function... - but if gcc eats it - why not?



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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I0b8f370f7b08736207f9efed13a0663b5e482824
Gerrit-Change-Number: 24639
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: keith <keith at rhizomatica.org>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Comment-Date: Fri, 11 Jun 2021 20:34:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: neels <nhofmeyr at sysmocom.de>
Comment-In-Reply-To: pespin <pespin at sysmocom.de>
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210611/156392ad/attachment.htm>


More information about the gerrit-log mailing list