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

Improve coding style #543

Merged
merged 1 commit into from Feb 23, 2021
Merged

Improve coding style #543

merged 1 commit into from Feb 23, 2021

Conversation

qleisan
Copy link

@qleisan qleisan commented Feb 22, 2021

Make explicit comparison with NULL to address reported issue #499. Not a bug

Closes #499

Make explicit comparison with NULL to address reported issue eclipse-wakaama#499. Not a bug.

Signed-off-by: Leif Sandstrom <leif.sandstrom@husqvarnagroup.com>
@qleisan
Copy link
Author

qleisan commented Feb 22, 2021

(forgot to sign off commit first time)

@@ -276,7 +276,7 @@ static bool prv_convertValue(_record_t * recordP,
{
size_t stringLen;
uint8_t *string = (uint8_t *)lwm2m_malloc(recordP->valueLen);
if (!string) return false;
if (string == NULL) return false;
stringLen = json_unescapeString(string, recordP->value, recordP->valueLen);
if (stringLen)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a NULL comparison for string is added, shouldn't there also be a comparison to 0 for stringLen?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No check is really added, only rewritten if(!string) <=> if (string == NULL) to accommodate #499 concern about "using string as a boolean". I felt it was right to align to the dominating coding style of comparing with NULL.

I see your point but the coding style in the code is more explicit when checking pointers, I believe. Your input on #513 is appreciated

@sbernard31 sbernard31 merged commit 7df7d80 into eclipse-wakaama:master Feb 23, 2021
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

Successfully merging this pull request may close these issues.

prv_parseItem() in json.c use string as a boolean
4 participants