|
From: Hans F. <han...@er...> - 2014-05-14 10:24:50
|
> -----Original Message-----
> From: Ramesh Betham [mailto:ram...@or...]
> Sent: den 14 maj 2014 12:05
> To: Hans Feldt
> Cc: Anders Widell; ope...@li...
> Subject: Re: libcore additions?
>
> Yes, can do that.
> Even though it is very unlikely.. good to check the return ptr-value of
> `encode_reserve_space`. If `NULL` log the error and return FAILURE.
[Hans] my understanding is that the decode/encode functions cannot/should not fail. That is why encode_reserve_space looks like:
static uint8_t *encode_reserve_space(NCS_UBAID *ub, int32_t count)
{
uint8_t *p = ncs_enc_reserve_space(ub, count);
osafassert(p);
return p;
}
This simplifies use and logic in client programs. Immsv does the same thing in the IMMSV_RSRV_SPACE_ASSERT macro.
OK then I can create a ticket and add this in a new file under core.
Thanks,
Hans
>
> Regards,
> Ramesh.
>
> On 5/14/2014 2:01 PM, Hans Feldt wrote:
> > Hi,
> >
> > While looking at removing(reducing) use of EDU from AMF I found that other services end up in creating their own support.
> > Services not using EDU is IMM, CLM, NTF and SMF meaning they end up duplicating the same logic again and again due to missing
> good support.
> >
> > So my question is can we put something like the below in a common new utility contained in core?
> >
> > I did some functions that looks like this:
> > void encode_uint8(NCS_UBAID *ub, uint8_t value);
> > void decode_uint8(NCS_UBAID *ub, uint8_t *to);
> > void encode_uint16(NCS_UBAID *ub, uint16_t value);
> > void decode_uint16(NCS_UBAID *ub, uint16_t *to);
> > void encode_uint32(NCS_UBAID *ub, uint32_t value);
> > void decode_uint32(NCS_UBAID *ub, uint32_t *to);
> > void encode_uint64(NCS_UBAID *ub, uint64_t value);
> > void decode_uint64(NCS_UBAID *ub, uint64_t *to);
> > void encode_sanamet(NCS_UBAID *ub, const SaNameT *name);
> > void decode_sanamet(NCS_UBAID *ub, SaNameT *name);
> > void encode_satimet(NCS_UBAID *ub, SaTimeT time);
> > void decode_satimet(NCS_UBAID *ub, SaTimeT *time);
> > void encode_bool(NCS_UBAID *ub, bool value);
> > void decode_bool(NCS_UBAID *ub, uint32_t *to);
> >
> > where for example encode_uint32 look like:
> >
> > void encode_uint32(NCS_UBAID *ub, uint32_t value)
> > {
> > uint8_t *p8 = encode_reserve_space(ub, 4);
> > ncs_encode_32bit(&p8, value);
> > ncs_enc_claim_space(ub, 4);
> > }
> >
> > This equals what immsv_evt.c is doing in many places (duplication):
> > IMMSV_RSRV_SPACE_ASSERT(p8, o_ub, 4);
> > ncs_encode_32bit(&p8, os->size);
> > ncs_enc_claim_space(o_ub, 4);
> >
|