libosmo-netif[master]: osmux: Re-write osmux_snprintf

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Holger Freyther gerrit-no-reply at lists.osmocom.org
Mon Aug 21 13:35:53 UTC 2017


Patch Set 1:

> SOrry, I mean: If you want to retain snprintf semantics, ie. return
 > the number of bytes that would have been written, then you need to
 > keep  'len' and offset, because offset should not ever go over the
 > boundary.
 > 
 > But 'len' may indeed go over the boundary, since it expresses this
 > "number of byte that would have been written".
 > 
 > Under normal circumstances, this stands true: len == offset.
 > 
 > If the buffer is too small, then len > offset.

I see your point. But taking a step back (and I am not the one working on this code right now so my opinion should not be the deciding one). What semantic do we want? snprintf is quite powerful but from what I can see we only want:

* Not have a buffer overrun
* Know when formatting failed
(and optionally help us to see how and where it failed)

The first two items bring us closer to the streaming API Jacob did in the gbproxy. Only the last might be an argument for sprintf (and macro).

-- 
To view, visit https://gerrit.osmocom.org/3537
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I695771d099833842db37a415b636035d17f1bba7
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pablo Neira Ayuso <pablo at gnumonks.org>
Gerrit-HasComments: No



More information about the gerrit-log mailing list