ipc: mach_complete_[a]sync avoid 'ret' set but not used warning

The variable 'ret' is set but not used.   As the value is ignored
remove it.  Restructure the initialization of 'replyinCnt', 'replyout',
and 'replyoutCnt' such that a failure of vm_read() results in a
properly initialized reply structure.
This commit is contained in:
Jeffrey Altman
2022-09-16 13:59:35 -04:00
parent de7b452dcb
commit 88eb44fd8b

View File

@@ -122,26 +122,19 @@ mach_complete_sync(heim_sipc_call ctx, int returnvalue, heim_idata *reply)
{
struct mach_call_ctx *s = (struct mach_call_ctx *)ctx;
heim_ipc_message_inband_t replyin;
mach_msg_type_number_t replyinCnt;
heim_ipc_message_outband_t replyout;
mach_msg_type_number_t replyoutCnt;
kern_return_t kr;
mach_msg_type_number_t replyinCnt = 0;
heim_ipc_message_outband_t replyout = 0;
mach_msg_type_number_t replyoutCnt = 0;
if (returnvalue) {
/* on error, no reply */
replyinCnt = 0;
replyout = 0; replyoutCnt = 0;
kr = KERN_SUCCESS;
} else if (reply->length < 2048) {
replyinCnt = reply->length;
memcpy(replyin, reply->data, replyinCnt);
replyout = 0; replyoutCnt = 0;
kr = KERN_SUCCESS;
} else {
replyinCnt = 0;
kr = vm_read(mach_task_self(),
(vm_address_t)reply->data, reply->length,
(vm_address_t *)&replyout, &replyoutCnt);
vm_read(mach_task_self(),
(vm_address_t)reply->data, reply->length,
(vm_address_t *)&replyout, &replyoutCnt);
}
mheim_ripc_call_reply(s->reply_port, returnvalue,
@@ -159,31 +152,24 @@ mach_complete_async(heim_sipc_call ctx, int returnvalue, heim_idata *reply)
{
struct mach_call_ctx *s = (struct mach_call_ctx *)ctx;
heim_ipc_message_inband_t replyin;
mach_msg_type_number_t replyinCnt;
heim_ipc_message_outband_t replyout;
mach_msg_type_number_t replyoutCnt;
kern_return_t kr;
mach_msg_type_number_t replyinCnt = 0;
heim_ipc_message_outband_t replyout = 0;
mach_msg_type_number_t replyoutCnt = 0;
if (returnvalue) {
/* on error, no reply */
replyinCnt = 0;
replyout = 0; replyoutCnt = 0;
kr = KERN_SUCCESS;
} else if (reply->length < 2048) {
replyinCnt = reply->length;
memcpy(replyin, reply->data, replyinCnt);
replyout = 0; replyoutCnt = 0;
kr = KERN_SUCCESS;
} else {
replyinCnt = 0;
kr = vm_read(mach_task_self(),
(vm_address_t)reply->data, reply->length,
(vm_address_t *)&replyout, &replyoutCnt);
vm_read(mach_task_self(),
(vm_address_t)reply->data, reply->length,
(vm_address_t *)&replyout, &replyoutCnt);
}
kr = mheim_aipc_acall_reply(s->reply_port, returnvalue,
replyin, replyinCnt,
replyout, replyoutCnt);
mheim_aipc_acall_reply(s->reply_port, returnvalue,
replyin, replyinCnt,
replyout, replyoutCnt);
heim_ipc_free_cred(s->cred);
free(s->req.data);
free(s);
@@ -1383,4 +1369,3 @@ heim_ipc_main(void)
process_loop();
#endif
}