Dear Denial: In function: bool codegen_response_acknowledged(struct response...

George Chow Answered 2 answers
Question by George Chow 2 years ago

Question

Dear Denial:

In function:
bool codegen_response_acknowledged(struct response* res)
{
return res && res->flags && RESPONSE_FLAG_ACKNOWLEDGED;
or
return res && res->flags & RESPONSE_FLAG_ACKNOWLEDGED;
}

I
Is it a bug of return statement? Which one is correct?

Answers

Answered by Daniel McCarthy

Instructor

Hi,
You should use the bitwise one res && res->flags & RESPONSE_FLAG_ACKNOWLEDGED; . This issue has already been reported . If you encounter any problems please check here: https://github.com/nibblebits/PeachCompiler/issues and if theirs no issue filed then file one and I will fix it.

Regarding people who didnt correct the bitwise logic in this question, it is not a problem because I was able to complete the whole course without noticing it so it did not impact the development work. However you should correct it to: "return res && res->flags & RESPONSE_FLAG_ACKNOWLEDGED; " to avoid any potential issues if you build on your work later on.

Thanks George and anything else please let me know

Follow-up by George Chow

Question author

Got it, thank you, daniel.