Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code generated for default value checks for optional string elements (bytes) is incorrect #47

Open
GoogleCodeExporter opened this issue Jul 7, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Define a message with like:
  message CipherKeys {
    required bytes localKey = 1;
    required uint32 localKeyChkSum = 2;
    optional bytes groupKey = 3;
    optional uint32 groupKeyChkSum = 4;
  }

2. Look at the code generated for CipherKeys_write().  The code should be 
checking for empty string.  Code generate looks like:

/* Write the optional attribute only if it is different than the default value. 
*/
if(_CipherKeys->_groupKey_len != 1
 || _CipherKeys->_groupKey[0] != '0') {
    offset = write_raw_varint32((3<<3)+2, _buffer, offset);
    offset = write_raw_varint32(_CipherKeys->_groupKey_len, _buffer, offset);
    offset = write_raw_bytes(_CipherKeys->_groupKey, _CipherKeys->_groupKey_len, _buffer, offset);
  }
The check for length should be _CipherKeys->_groupKey_len != 0 and the check 
for a null string should be _CipherKeys->_groupKey[0] != '\0'

What version of the product are you using? On what operating system?
1.04M, host Windows XP, target IAR 5.51 MSP430


Original issue reported on code.google.com by [email protected] on 20 Aug 2013 at 1:35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant