summaryrefslogtreecommitdiffstats
path: root/generator/nanopb_generator.py
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2016-10-23 14:01:10 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2016-10-23 14:02:06 +0300
commit6e22ecdebefa40d87723e46298a2d71329ab75da (patch)
treee038653f92a99e5c68f03a10bb619fc75214e678 /generator/nanopb_generator.py
parent599939a85dce96c78c357341b731ccc173885d5b (diff)
Fix missing warning with large bytes fields (issue #220)
Need to generate compile time check if the bytes field + size field might exceed 255 bytes. Also eliminated spurious checks generated for some callback fields.
Diffstat (limited to 'generator/nanopb_generator.py')
-rwxr-xr-xgenerator/nanopb_generator.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index 185a97bb..5c53a633 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -530,8 +530,8 @@ class Field:
'''Determine if this field needs 16bit or 32bit pb_field_t structure to compile properly.
Returns numeric value or a C-expression for assert.'''
check = []
- if self.pbtype == 'MESSAGE':
- if self.rules == 'REPEATED' and self.allocation == 'STATIC':
+ if self.pbtype == 'MESSAGE' and self.allocation == 'STATIC':
+ if self.rules == 'REPEATED':
check.append('pb_membersize(%s, %s[0])' % (self.struct_name, self.name))
elif self.rules == 'ONEOF':
if self.anonymous:
@@ -540,6 +540,9 @@ class Field:
check.append('pb_membersize(%s, %s.%s)' % (self.struct_name, self.union_name, self.name))
else:
check.append('pb_membersize(%s, %s)' % (self.struct_name, self.name))
+ elif self.pbtype == 'BYTES' and self.allocation == 'STATIC':
+ if self.max_size > 251:
+ check.append('pb_membersize(%s, %s)' % (self.struct_name, self.name))
return FieldMaxSize([self.tag, self.max_size, self.max_count],
check,