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

SampleProducer: send signed char to unsigned char? #23

Open
eliosef opened this issue Apr 5, 2016 · 1 comment
Open

SampleProducer: send signed char to unsigned char? #23

eliosef opened this issue Apr 5, 2016 · 1 comment

Comments

@eliosef
Copy link

eliosef commented Apr 5, 2016

Under line 89:

`Message* createMessage(const char * value, const char *key)
{
// these will be updated as the message is prepared for production
const static int crc = 1001;
const static signed char magicByte = -1;
const static signed char attributes = 0; // last three bits must be zero to disable gzip compression

unsigned char *v = new unsigned char[strlen(value)];
memcpy(v, value, strlen(value));

unsigned char *k = new unsigned char[strlen(key)];
memcpy(k, key, strlen(key));

return new Message(crc, magicByte, attributes, strlen(key), (unsigned char *)k, strlen(value), (unsigned char *)v, 0, true);
}`

  1. Why are you sending the megicByte as signed char (with value -1) while the type supposed to be unsigned char?
  2. Why casting variables k and v to itself?
@DEvil0000
Copy link

  1. can't answer to the concrete protocol but maybe its because of this:
    signed -1 => unsigned "max value"
    unsigned int int_max = -1;

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

No branches or pull requests

2 participants