iamandi / nanopb

Automatically exported from code.google.com/p/nanopb
zlib License
0 stars 0 forks source link

Optional Callback has_field offset #70

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi all,

pb.h:
When I have optional callback it contain "has" field in struct but in field 
there is not valid size offset record.
This could be fixed simply:

#define PB_OPTIONAL_CALLBACK(tag, st, m, pm, ltype, ptr) \
    {tag, PB_ATYPE_CALLBACK | PB_HTYPE_OPTIONAL | ltype, \
    pb_delta_end(st, m, pm), \
    pb_delta(st, has_ ## m, m), \
    pb_membersize(st, m), 0, ptr}

Also decoding function could do if there was optional callback and it was 
called and return true, then fill "has" field to true.

So after decoding I could simply check if the optional field is present or not.

Original issue reported on code.google.com by P.Sta...@gmail.com on 2 Apr 2013 at 3:58

GoogleCodeExporter commented 9 years ago
Ah, it is a bug indeed. Will fix has_ field to work like you said.

Original comment by Petteri.Aimonen on 2 Apr 2013 at 4:01

GoogleCodeExporter commented 9 years ago
Hmm, nanopb-0.1.x does not generate has_ fields for callbacks. It was 
accidentally added in nanopb-0.2.0.

If issue 69 is fixed, would you be ok with there being no has_ field for 
callbacks?

Original comment by Petteri.Aimonen on 2 Apr 2013 at 4:16

GoogleCodeExporter commented 9 years ago
This issue was updated by revision 384e686fe6d7.

Original comment by Petteri.Aimonen on 2 Apr 2013 at 5:02

GoogleCodeExporter commented 9 years ago
Hi,
Yes, It will be OK when there will be no has_ field. After fix in issue #69 
there is still possibility have NULL in arg to detect not filled optional field 
and to have any stored pointer in it to detect processed field. (or also some 
flags inside *arg)

Original comment by P.Sta...@gmail.com on 2 Apr 2013 at 9:57

GoogleCodeExporter commented 9 years ago
Fix released in 0.2.1

Original comment by Petteri.Aimonen on 14 Apr 2013 at 7:19