Remove goto statements in aws_iot_shadow_subscription.c
/* Shadow internal include. */
#include "private/aws_iot_shadow_internal.h"
-/* Error handling include. */
-#include "iot_error.h"
-
/* Platform layer includes. */
#include "platform/iot_threads.h"
@@ -270,7 +267,7 @@ AwsIotShadowError_t _AwsIotShadow_IncrementReferences( _shadowOperation_t * pOpe
uint16_t operationTopicLength,
AwsIotMqttCallbackFunction_t callback )
{
- IOT_FUNCTION_ENTRY( AwsIotShadowError_t, AWS_IOT_SHADOW_SUCCESS );
+ AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS;
const _shadowOperationType_t type = pOperation->type;
_shadowSubscription_t * pSubscription = pOperation->pSubscription;
IotMqttError_t subscriptionStatus = IOT_MQTT_STATUS_PENDING;
@@ -284,10 +281,9 @@ AwsIotShadowError_t _AwsIotShadow_IncrementReferences( _shadowOperation_t * pOpe
_pAwsIotShadowOperationNames[ type ],
pSubscription->thingNameLength,
pSubscription->pThingName );
-
- IOT_GOTO_CLEANUP();
}
-
+ else
+ {
/* When persistent subscriptions are not present, the reference count must
* not be negative. */
AwsIotShadow_Assert( pSubscription->references[ type ] >= 0 );
@@ -307,13 +303,10 @@ AwsIotShadowError_t _AwsIotShadow_IncrementReferences( _shadowOperation_t * pOpe
/* Convert MQTT return code to Shadow return code. */
status = SHADOW_CONVERT_STATUS_CODE_MQTT_TO_SHADOW( subscriptionStatus );
-
- if( status != AWS_IOT_SHADOW_SUCCESS )
- {
- IOT_GOTO_CLEANUP();
- }
}
+ if( status == AWS_IOT_SHADOW_SUCCESS )
+ {
/* Increment the number of subscription references for this operation when
* the keep subscriptions flag is not set. */
if( ( pOperation->flags & AWS_IOT_SHADOW_FLAG_KEEP_SUBSCRIPTIONS ) == 0 )
@@ -336,8 +329,10 @@ AwsIotShadowError_t _AwsIotShadow_IncrementReferences( _shadowOperation_t * pOpe
pSubscription->thingNameLength,
pSubscription->pThingName );
}
+ }
+ }
- IOT_FUNCTION_EXIT_NO_CLEANUP();
+ return status;
}
/*-----------------------------------------------------------*/
