Code Review
/
apps
/
agl-service-can-low-level.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
review
|
tree
raw
|
patch
|
inline
| side by side (parent:
d56c4cc
)
Fix message length calculation for arrays of size 1 (issue #253)
author
Petteri Aimonen
<jpa@git.mail.kapsi.fi>
Tue, 28 Mar 2017 20:20:31 +0000
(23:20 +0300)
committer
Petteri Aimonen
<jpa@git.mail.kapsi.fi>
Tue, 28 Mar 2017 20:20:31 +0000
(23:20 +0300)
generator/nanopb_generator.py
patch
|
blob
|
history
diff --git
a/generator/nanopb_generator.py
b/generator/nanopb_generator.py
index
359e184
..
42669ac
100755
(executable)
--- a/
generator/nanopb_generator.py
+++ b/
generator/nanopb_generator.py
@@
-649,9
+649,14
@@
class Field:
if self.rules == 'REPEATED':
# Decoders must be always able to handle unpacked arrays.
# Therefore we have to reserve space for it, even though
if self.rules == 'REPEATED':
# Decoders must be always able to handle unpacked arrays.
# Therefore we have to reserve space for it, even though
- # we emit packed arrays ourselves.
+ # we emit packed arrays ourselves. For length of 1, packed
+ # arrays are larger however so we need to add allowance
+ # for the length byte.
encsize *= self.max_count
encsize *= self.max_count
+ if self.max_count == 1:
+ encsize += 1
+
return encsize
return encsize