diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-11-02 08:37:06 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-11-13 14:15:24 -0500 |
| commit | 051cc28c8f586eb3482e5fd9878b2307dbf98e38 (patch) | |
| tree | 09f3c9e167bf48c72e7058e3c707ff4593d933d2 /lib/json.h | |
| parent | 4df759fecf7cf2b6cd45e47789e8d06437ff7ca7 (diff) | |
lib: Add STREAM_GETX functions
Currently when stream reads fail, for any reason, we assert.
While a *great* debugging tool, Asserting on production code
is not a good thing. So this is the start of a conversion over
to a series of STREAM_GETX functions that do not assert and
allow the developer a way to program this gracefully and still
clean up.
Current code is something like this( taken from redistribute.c
because this is dead simple ):
afi = stream_getc(client->ibuf);
type = stream_getc(client->ibuf);
instance = stream_getw(client->ibuf);
This code has several issues:
1) There is no failure mode for the stream read other than assert.
if afi fails to be read the code stops.
2) stream_getX functions cannot be converted to a failure mode
because it is impossible to tell a failure from good data
with this api.
So this new code will convert to this:
STREAM_GETC(client->ibuf, afi);
STREAM_GETC(client->ibuf, type);
STREAM_GETW(client->ibuf, instance);
....
stream_failure:
return;
We've created a stream_getc2( which does not assert ),
but we need a way to allow clean failure mode handling.
This is done by macro'ing stream_getX2 functions with
the equivalent all uppercase STREAM_GETX functions that
include a goto.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/json.h')
0 files changed, 0 insertions, 0 deletions
