PengZheng opened a new issue, #593:
URL: https://github.com/apache/celix/issues/593
The following code snippet triggers "declaration shadows a local variable"
warning:
```C
static void rsaShm_overlayProperties(celix_properties_t
*additionalProperties, celix_properties_t *serviceProperties) {
/*The property keys of a service are case-insensitive,while the property
keys of the specified additional properties map are case sensitive.
* A property key in the additional properties map must therefore
override any case variant property key in the properties of the specified
Service Reference.*/
const char *additionalPropKey = NULL;
const char *servicePropKey = NULL;
PROPERTIES_FOR_EACH(additionalProperties, additionalPropKey) {
if (strcmp(additionalPropKey,(char*) OSGI_FRAMEWORK_OBJECTCLASS) != 0
&& strcmp(additionalPropKey,(char*)
OSGI_FRAMEWORK_SERVICE_ID) != 0) {
bool propKeyCaseEqual = false;
PROPERTIES_FOR_EACH(serviceProperties, servicePropKey) {
if (strcasecmp(additionalPropKey,servicePropKey) == 0) {
const char* val =
celix_properties_get(additionalProperties,additionalPropKey,NULL);
celix_properties_set(serviceProperties,servicePropKey,val);
propKeyCaseEqual = true;
break;
}
}
if (!propKeyCaseEqual) {
const char* val =
celix_properties_get(additionalProperties,additionalPropKey,NULL);
celix_properties_set(serviceProperties,additionalPropKey,val);
}
}
}
return;
}
```
A closer look reveals that the `iter` of the inner loop hides that of the
outer loop.
```C
#define PROPERTIES_FOR_EACH(props, key) \
for(hash_map_iterator_t iter = hashMapIterator_construct(props); \
hashMapIterator_hasNext(&iter), (key) = (const
char*)hashMapIterator_nextKey(&iter);)
```
--
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]