summaryrefslogtreecommitdiff
path: root/src/libpiano
diff options
context:
space:
mode:
Diffstat (limited to 'src/libpiano')
-rw-r--r--src/libpiano/request.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libpiano/request.c b/src/libpiano/request.c
index 2e17872..7b73bc1 100644
--- a/src/libpiano/request.c
+++ b/src/libpiano/request.c
@@ -71,6 +71,7 @@ static const char *PianoAudioFormatToString (PianoAudioFormat_t format) {
*/
PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
PianoRequestType_t type) {
+ PianoReturn_t ret = PIANO_RET_OK;
const char *jsonSendBuf;
const char *method = NULL;
json_object *j = json_object_new_object ();
@@ -412,7 +413,6 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
case PIANO_REQUEST_RATE_SONG: {
/* love/ban song */
PianoRequestDataRateSong_t *reqData = req->data;
- PianoReturn_t pRet;
assert (reqData != NULL);
assert (reqData->song != NULL);
@@ -425,12 +425,12 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
req->data = &transformedReqData;
/* create request data (url, post data) */
- pRet = PianoRequest (ph, req, PIANO_REQUEST_ADD_FEEDBACK);
+ ret = PianoRequest (ph, req, PIANO_REQUEST_ADD_FEEDBACK);
/* and reset request type/data */
req->type = PIANO_REQUEST_RATE_SONG;
req->data = reqData;
- return pRet;
+ goto cleanup;
break;
}
@@ -438,7 +438,6 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
/* move song to a different station, needs two requests */
PianoRequestDataMoveSong_t *reqData = req->data;
PianoRequestDataAddFeedback_t transformedReqData;
- PianoReturn_t pRet;
assert (reqData != NULL);
assert (reqData->song != NULL);
@@ -462,12 +461,12 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
}
/* create request data (url, post data) */
- pRet = PianoRequest (ph, req, PIANO_REQUEST_ADD_FEEDBACK);
+ ret = PianoRequest (ph, req, PIANO_REQUEST_ADD_FEEDBACK);
/* and reset request type/data */
req->type = PIANO_REQUEST_MOVE_SONG;
req->data = reqData;
- return pRet;
+ goto cleanup;
break;
}
}
@@ -498,13 +497,15 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
if (encrypted) {
if ((req->postData = PianoEncryptString (ph->partner.out,
jsonSendBuf)) == NULL) {
- return PIANO_RET_OUT_OF_MEMORY;
+ ret = PIANO_RET_OUT_OF_MEMORY;
}
} else {
req->postData = strdup (jsonSendBuf);
}
+
+cleanup:
json_object_put (j);
- return PIANO_RET_OK;
+ return ret;
}