Skip to content

Commit

Permalink
janssonrpcc: cleanups (#2512)
Browse files Browse the repository at this point in the history
* janssonrpcc: Remove unused variable and redundant assignment

* janssonrpc: No need for copying options

The address stay valid until free_params is called. And before that
happens, mod_jsonrpc_request() makes its own copy.

(cherry picked from commit 61771b0)
  • Loading branch information
gaaf authored and miconda committed Oct 23, 2020
1 parent eae86ff commit 48df37a
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/modules/janssonrpcc/janssonrpc_funcs.c
Expand Up @@ -44,7 +44,6 @@ int jsonrpc_request(struct sip_msg* _m,
str params;
str options;
str route;
param_hooks_t phooks;
param_t* pit=NULL;
param_t* freeme=NULL;
int retry;
Expand Down Expand Up @@ -85,7 +84,7 @@ int jsonrpc_request(struct sip_msg* _m,
options.len--;
}

if (parse_params(&options, CLASS_ANY, &phooks, &pit)<0) {
if (parse_params(&options, CLASS_ANY, NULL, &pit)<0) {
ERR("failed parsing params value\n");
return -1;
}
Expand All @@ -95,8 +94,7 @@ int jsonrpc_request(struct sip_msg* _m,
for (; pit;pit=pit->next)
{
if PIT_MATCHES("route") {
pkg_str_dup(&route, &pit->body);
CHECK_MALLOC_GOTO(route.s, end);
route = pit->body;

} else if PIT_MATCHES("timeout") {
timeout = atoi(pit->body.s);
Expand All @@ -123,8 +121,6 @@ int jsonrpc_request(struct sip_msg* _m,
goto end;
}

retval = 0;

retval = mod_jsonrpc_request(
_m, /* sip_msg */
conn, /* connection group */
Expand All @@ -138,7 +134,6 @@ int jsonrpc_request(struct sip_msg* _m,

end:
if(freeme) free_params(freeme);
if(route.s) pkg_free(route.s);
return retval;
}

Expand Down

0 comments on commit 48df37a

Please sign in to comment.