MT#62181 std::move updates

Avoid making needless copies

Change-Id: I51a2a6a05e25553dc55845fc03ce8ffee3c4287b
Warned-by: Coverity
mr13.5
Richard Fuchs 1 year ago
parent 80172e0652
commit b7abe78e5e

@ -171,7 +171,7 @@ DSMCondition* DSMCoreModule::getCondition(const string& from_str) {
DSMCondition* c = new DSMCondition();
c->name = "key pressed: " + params;
c->type = DSMCondition::Key;
c->params["key"] = params;
c->params["key"] = std::move(params);
return c;
}
@ -1046,7 +1046,7 @@ EXEC_ACTION_START(SCGetErrorCodePlaybackAction) {
string current_var = pair.substr(0, separator_pos);
string current_val = pair.substr(separator_pos + 1);
if (current_var == pattern) {
result = current_val;
result = std::move(current_val);
break;
}
}
@ -1054,7 +1054,7 @@ EXEC_ACTION_START(SCGetErrorCodePlaybackAction) {
}
/* rewrite only if we got something */
if (!result.empty())
sc_sess->var[destination_variable] = result;
sc_sess->var[std::move(destination_variable)] = std::move(result);
} EXEC_ACTION_END;
CONST_ACTION_2P(SCAppendAction,',', false);
@ -1616,7 +1616,7 @@ EXEC_ACTION_START(SCB2BGetHeaderReplyAction) {
/* write only if we got something */
if (!result.empty())
sc_sess->var[destination_variable] = result;
sc_sess->var[std::move(destination_variable)] = std::move(result);
else
DBG("No header with name '%s' found.\n", hdr_name.c_str());
} EXEC_ACTION_END;
@ -1632,7 +1632,7 @@ EXEC_ACTION_START(SCB2BGetHeaderParamReplyAction) {
sc_sess->B2BgetHeaderParamReply(hdr_name, param_name, result);
/* write only if we got something */
if (!result.empty())
sc_sess->var[destination_variable] = result;
sc_sess->var[std::move(destination_variable)] = std::move(result);
else
DBG("No header param with name '%s' found.\n", hdr_name.c_str());
} EXEC_ACTION_END;

@ -499,7 +499,7 @@ bool DSMStateEngine::runactions(vector<DSMElement*>::iterator from,
// restore the counter[s]
if (k_exists)
sc_sess->var[k_name] = k_save;
sc_sess->var[k_name] = std::move(k_save);
else
sc_sess->var.erase(k_name);

@ -339,7 +339,7 @@ EXEC_ACTION_START(DLGDialoutAction) {
string new_sess_tag = AmUAC::dialout(user, app_name, r_uri, from, from_uri, to, ltag, hdrs, sess_params);
if (!new_sess_tag.empty()) {
sc_sess->var[arrayname + "_ltag"] = new_sess_tag;
sc_sess->var[arrayname + "_ltag"] = std::move(new_sess_tag);
} else {
sc_sess->var[arrayname + "_ltag"] = "";
sc_sess->SET_ERRNO(DSM_ERRNO_GENERAL);

@ -309,7 +309,7 @@ EXEC_ACTION_START(SCPopenAction) {
res += string(buf, rlen);
}
sc_sess->var[dst_var] = res;
sc_sess->var[dst_var] = std::move(res);
int status = pclose(fp);
if (status==-1) {

@ -597,7 +597,7 @@ EXEC_ACTION_START(SCUSAddAction) {
DBG("setting var[%s] = %s + %s = %s\n",
varname.c_str(), n1.c_str(), n2.c_str(), res.c_str());
sc_sess->var[varname] = res;
sc_sess->var[std::move(varname)] = std::move(res);
} EXEC_ACTION_END;
@ -615,7 +615,7 @@ EXEC_ACTION_START(SCUSSubAction) {
DBG("setting var[%s] = %s - %s = %s\n",
varname.c_str(), n1.c_str(), n2.c_str(), res.c_str());
sc_sess->var[varname] = res;
sc_sess->var[std::move(varname)] = std::move(res);
} EXEC_ACTION_END;

@ -1539,7 +1539,7 @@ void CallLeg::replaceExistingLeg(const string &session_tag, const AmSipRequest &
return;
}
other_legs.push_back(b);
other_legs.push_back(std::move(b));
if (call_status == Disconnected) updateCallStatus(NoReply); // we are something like connected to another leg
}
@ -1573,7 +1573,7 @@ void CallLeg::replaceExistingLeg(const string &session_tag, const string &hdrs)
return;
}
other_legs.push_back(b);
other_legs.push_back(std::move(b));
if (call_status == Disconnected) updateCallStatus(NoReply); // we are something like connected to another leg
}

@ -83,10 +83,10 @@ bool readFilter(AmConfigReader& cfg, const char* cfg_key_filter, const char* cfg
for (vector<string>::iterator it=elems.begin(); it != elems.end(); it++) {
string c = *it;
std::transform(c.begin(), c.end(), c.begin(), ::tolower);
hf.filter_list.insert(c);
hf.filter_list.insert(std::move(c));
}
filter_list.push_back(hf);
filter_list.push_back(std::move(hf));
return true;
}

@ -50,7 +50,7 @@ int RegisterDialog::parseContacts(const string& contacts, vector<AmUriParser>& c
DBG("successfully parsed contact %s@%s\n",
contact.uri_user.c_str(),
contact.uri_host.c_str());
cv.push_back(contact);
cv.push_back(std::move(contact));
}
}
@ -333,7 +333,7 @@ int RegisterDialog::removeTransport(AmUriParser& uri)
}
free_gen_params(&uri_params);
uri.uri_param = new_params;
uri.uri_param = std::move(new_params);
return 0;
}
@ -485,7 +485,7 @@ void RegisterDialog::onSipReply(const AmSipRequest& req,
if(!orig_expires || (expires < orig_expires)) {
orig_expires = expires;
orig_expires_str = expires_str;
orig_expires_str = std::move(expires_str);
}
if(max_ua_expire && (orig_expires > max_ua_expire)) {
@ -498,7 +498,7 @@ void RegisterDialog::onSipReply(const AmSipRequest& req,
// -> use the original
// }
it->params["expires"] = orig_expires_str;
it->params["expires"] = std::move(orig_expires_str);
// Update global reg cache & alias map
// with new 'expire' value and new entries

@ -953,7 +953,7 @@ int SBCCallProfile::apply_a_routing(ParamReplacerCtx& ctx,
if (!aleg_outbound_proxy.empty()) {
string aleg_op =
ctx.replaceParameters(aleg_outbound_proxy, "aleg_outbound_proxy", req);
dlg.outbound_proxy = aleg_op;
dlg.outbound_proxy = std::move(aleg_op);
dlg.force_outbound_proxy = aleg_force_outbound_proxy;
}
@ -989,7 +989,7 @@ int SBCCallProfile::apply_b_routing(ParamReplacerCtx& ctx,
if (!outbound_proxy.empty()) {
string op = ctx.replaceParameters(outbound_proxy, "outbound_proxy", req);
dlg.outbound_proxy = op;
dlg.outbound_proxy = std::move(op);
dlg.force_outbound_proxy = force_outbound_proxy;
}
@ -1291,7 +1291,7 @@ string SBCCallProfile::retarget(const string& alias)
nh += ":" + int2str(alias_entry.source_port);
DBG("setting from registration cache: next_hop='%s'\n", nh.c_str());
next_hop = nh;
next_hop = std::move(nh);
// sticky interface
DBG("setting from registration cache: outbound_interface='%s'\n",

@ -196,7 +196,7 @@ bool retarget(const string& r_uri, const AmArg& values, SBCCallProfile* call_pro
string out_if = AmConfig::SIP_Ifs[alias_entry.local_if].name;
DBG("out_if = '%s'",out_if.c_str());
call_profile->outbound_interface = out_if;
call_profile->outbound_interface = std::move(out_if);
DBG("setting from registration cache: outbound_interface='%s'\n",
call_profile->outbound_interface.c_str());
}

@ -332,7 +332,7 @@ void SyslogCDR::end(const string& ltag, SBCCallProfile* call_profile,
AmArg* v = &var_it->second;
if (!prop.empty()) {
try {
v = &var_it->second[prop];
v = &var_it->second[std::move(prop)];
} catch(...) { }
}
if (isArgCStr((*v))) {

@ -1019,7 +1019,7 @@ static bool fillSysIntfList()
AmConfig::SysIfs.resize(sys_if_idx+1);
intf_it = AmConfig::SysIfs.begin() + sys_if_idx;
intf_it->name = iface_name;
intf_it->name = std::move(iface_name);
intf_it->flags = p_if->ifa_flags;
struct ifreq ifr;
@ -1195,7 +1195,7 @@ int AmConfig::finalizeIPConfig()
ERROR("could not determine default signaling IP.");
return -1;
}
SIP_Ifs.push_back(intf);
SIP_Ifs.push_back(std::move(intf));
SIP_If_names["default"] = 0;
}
@ -1206,7 +1206,7 @@ int AmConfig::finalizeIPConfig()
ERROR("could not determine default media IP.");
return -1;
}
RTP_Ifs.push_back(intf);
RTP_Ifs.push_back(std::move(intf));
RTP_If_names["default"] = 0;
}

@ -165,7 +165,7 @@ int AmConfigReader::loadFile(const string& path)
// small hack to make include work with right path
if (keyname == "plugin_config_path")
AmConfig::ModConfigPath = val;
AmConfig::ModConfigPath = std::move(val);
} else
goto syntax_error;
@ -321,7 +321,7 @@ int AmConfigReader::loadString(const char* cfg_lines, size_t cfg_len)
val.c_str());
}
keys[keyname] = val;
keys[std::move(keyname)] = std::move(val);
} else
goto syntax_error;
}

@ -430,7 +430,7 @@ void AmSdp::print(string& body) const
}
}
body = out_buf;
body = std::move(out_buf);
}
const SdpPayload* AmSdp::telephoneEventPayload() const
@ -1080,7 +1080,7 @@ static char* parse_sdp_attr(AmSdp* sdp_msg, char* s)
if(contains(s, line_end, '/')){
next = parse_until(attr_line, '/');
string enc_name(attr_line, int(next-attr_line)-1);
encoding_name = enc_name;
encoding_name = std::move(enc_name);
attr_line = next;
rtpmap_st = CLK_RATE;
break;
@ -1270,7 +1270,7 @@ static void parse_sdp_origin(AmSdp* sdp_msg, char* s)
break;
}
string user(origin_line, int(next-origin_line)-1);
origin.user = user;
origin.user = std::move(user);
origin_line = next;
origin_st = ID;
break;

@ -436,7 +436,7 @@ string AmUriParser::add_param_to_param_list(const string& param_name,
// if param_string empty - set it
if (list_of_params.empty()) {
list_of_params = param;
list_of_params = std::move(param);
}
else {
// check if parameter already exists; if yes - replace it

@ -1096,7 +1096,7 @@ std::vector<string> explode(const string& s, const string& delim,
subend = search(substart, s.end(), delim.begin(), delim.end());
string temp(substart, subend);
if (keep_empty || !temp.empty()) {
result.push_back(temp);
result.push_back(std::move(temp));
}
if (subend == s.end()) {
break;

@ -206,7 +206,7 @@ bool UACAuth::onSipReply(const AmSipRequest& req, const AmSipReply& reply,
}
if (hdrs == "\r\n" || hdrs == "\r" || hdrs == "\n")
hdrs = result;
hdrs = std::move(result);
else
hdrs += result;
@ -274,7 +274,7 @@ bool UACAuth::onSendRequest(AmSipRequest& req, int& flags)
req.method, dlg->getRemoteUri(), &req.body, result)) {
// add headers
if (req.hdrs == "\r\n" || req.hdrs == "\r" || req.hdrs == "\n")
req.hdrs = result;
req.hdrs = std::move(result);
else
req.hdrs += result;

@ -149,7 +149,7 @@ static void set_default_interface(const string& iface_name)
if(if_it == AmConfig::SIP_If_names.end()) {
AmConfig::SIP_interface intf;
intf.name = "default";
AmConfig::SIP_Ifs.push_back(intf);
AmConfig::SIP_Ifs.push_back(std::move(intf));
AmConfig::SIP_If_names["default"] = AmConfig::SIP_Ifs.size()-1;
idx = AmConfig::SIP_Ifs.size()-1;
}

Loading…
Cancel
Save