Attention is currently required from: fixeria, pespin, msuraev.
neels has posted comments on this change. (
https://gerrit.osmocom.org/c/libosmocore/+/28993 )
Change subject: Update multiaddr helper
......................................................................
Patch Set 13: Code-Review-1
(6 comments)
Commit Message:
https://gerrit.osmocom.org/c/libosmocore/+/28993/comment/1bd38237_d7fbe84d
PS13, Line 10: * properly handle OOM
OOM is not the responsibility of functions like snprintf(), the caller shall check rc <
len
File src/core/socket.c:
https://gerrit.osmocom.org/c/libosmocore/+/28993/comment/ac9b0dc0_7f1faa20
PS13, Line 229: const struct sockaddr *addr = &(*addrs)[i];
to conform with typical osmo style, suggest using struct osmo_sockaddr instead, and below
use addr.u.sas; and osmo_sockaddr_to_str_buf2() (s.b.)
https://gerrit.osmocom.org/c/libosmocore/+/28993/comment/e232e1d3_265fbe3b
PS13, Line 244: OSMO_STRBUF_PRINTF(*sb, "%s%s", oss->ip, after);
no need to use osmo_sockaddr_str here, instead do
OSMO_STRBUF_APPEND(sb, osmo_sockaddr_to_str_buf2, &addr);
OSMO_STRBUF_PRINTF(sb, "%s", after);
https://gerrit.osmocom.org/c/libosmocore/+/28993/comment/0b126cdc_9bb4fd8a
PS13, Line 252: return -ENOSPC;
do not size check!! this breaks the osmo_strbuf usage.
A foo_buf() function should always return sb.chars_needed, the nr of characters that
*would* have been written if the buffer were long enough, like snprintf() does. this
enables the caller to allocate enough buffer and call the function again (which
OSMO_NAME_C_IMPL() does). That is the entire idea behind the OSMO_STRBUF_* macros, which
never write past the buffer length and ensure terminating nul like snprintf(). Also same
as with snprintf(), it is the caller's responsibility to check that the returned len
is < the buffer len.
https://gerrit.osmocom.org/c/libosmocore/+/28993/comment/29a24887_23e643d7
PS13, Line 260:
just put the function block of multiaddr_strbuf() in here.
the typical pattern we have is foo_buf() and foo_c() functions, rather not open another
family of functions that pass osmo_strbuf around. OSMO_STRBUF_APPEND() is there to just
use the foo_buf() variant efficiently and avoid passing osmo_strbuf around. IOW an
osmo_strbuf should remain within a function body.
File src/socket.c:
https://gerrit.osmocom.org/c/libosmocore/+/28993/comment/2ef79e93_a505c1fb
PS9, Line 220:
Seems rather pointless to me: that's a static
function with only few invocations, not part of public […]
(assert()s also clarify
to the reader the intended usage, and to coverity what to expect. so it's a good thing
to add, but also not super critical)
--
To view, visit
https://gerrit.osmocom.org/c/libosmocore/+/28993
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Icef53fe4b6e51563d97a1bc48001d67679b3b6e9
Gerrit-Change-Number: 28993
Gerrit-PatchSet: 13
Gerrit-Owner: msuraev <msuraev(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: msuraev <msuraev(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 13 Feb 2023 02:07:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
Comment-In-Reply-To: msuraev <msuraev(a)sysmocom.de>
Gerrit-MessageType: comment