pnoltes commented on code in PR #470:
URL: https://github.com/apache/celix/pull/470#discussion_r1377963635
##########
bundles/remote_services/discovery_zeroconf/src/discovery_zeroconf_announcer.c:
##########
@@ -342,11 +342,9 @@ static void
discoveryZeroconfAnnouncer_revokeEndpoints(discovery_zeroconf_announ
static bool
discoveryZeroconfAnnouncer_copyPropertiesToTxtRecord(discovery_zeroconf_announcer_t
*announcer, celix_properties_iterator_t *propIter, TXTRecordRef *txtRecord,
uint16_t maxTxtLen, bool splitTxtRecord) {
const char *key;
const char *val;
- celix_properties_t *props;
- while (celix_propertiesIterator_hasNext(propIter)) {
- key = celix_propertiesIterator_nextKey(propIter);
- props = celix_propertiesIterator_properties(propIter);
- val = celix_properties_get(props, key, "");
+ while (!celix_propertiesIterator_isEnd(propIter)) {
+ key = propIter->key;
+ val = propIter->entry.value;
Review Comment:
val cannot be null. When adding a property with a string value if NULL, a
empty string ("") will be used instead using the celix_properties_createString
function:
```
char* celix_properties_createString(celix_properties_t* properties, const
char* str) {
if (str == NULL) {
return (char*)CELIX_PROPERTIES_EMPTY_STRVAL;
}
size_t len = strnlen(str, CELIX_UTILS_MAX_STRLEN) + 1;
size_t left = CELIX_SHORT_PROPERTIES_OPTIMIZATION_STRING_BUFFER_SIZE -
properties->currentStringBufferIndex;
char* result;
if (len < left) {
memcpy(&properties->stringBuffer[properties->currentStringBufferIndex], str,
len);
result =
&properties->stringBuffer[properties->currentStringBufferIndex];
properties->currentStringBufferIndex += (int)len;
} else {
result = celix_utils_strdup(str);
}
return result;
}
```
As result val cannot be NULL. I will update the properties iterator
documentation to make this more explicit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]