Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/sysipc.c

    rc9fff17 r20c7c40  
    5858#define DATA_XFER_LIMIT         (64 * 1024)
    5959
    60 /** Get phone from the current task by ID.
    61  *
    62  * @param phoneid       Phone ID.
    63  * @param phone         Place to store pointer to phone.
    64  * @return              EOK on success, EINVAL if ID is invalid.
    65  */
    66 static int phone_get(unative_t phoneid, phone_t **phone)
    67 {
    68         if (phoneid >= IPC_MAX_PHONES)
    69                 return EINVAL;
    70 
    71         *phone = &TASK->phones[phoneid];
    72         return EOK;
     60#define GET_CHECK_PHONE(phone, phoneid, err) \
     61{ \
     62        if (phoneid > IPC_MAX_PHONES) { \
     63                err \
     64        } \
     65        phone = &TASK->phones[phoneid]; \
    7366}
    7467
     
    381374        case IPC_M_CONNECTION_CLONE: {
    382375                phone_t *cloned_phone;
    383 
    384                 if (phone_get(IPC_GET_ARG1(call->data), &cloned_phone) != EOK)
    385                         return ENOENT;
     376                GET_CHECK_PHONE(cloned_phone, IPC_GET_ARG1(call->data),
     377                    return ENOENT;);
    386378                phones_lock(cloned_phone, phone);
    387 
    388379                if ((cloned_phone->state != IPC_PHONE_CONNECTED) ||
    389380                    phone->state != IPC_PHONE_CONNECTED) {
     
    543534        int res;
    544535        int rc;
    545 
    546         if (phone_get(phoneid, &phone) != EOK)
    547                 return ENOENT;
     536       
     537        GET_CHECK_PHONE(phone, phoneid, return ENOENT;);
    548538
    549539        call = ipc_call_alloc(0);
     
    601591        int rc;
    602592
    603         if (phone_get(phoneid, &phone) != EOK)
    604                 return ENOENT;
     593        GET_CHECK_PHONE(phone, phoneid, return ENOENT;);
    605594
    606595        call = ipc_call_alloc(0);
     
    677666                return IPC_CALLRET_TEMPORARY;
    678667
    679         if (phone_get(phoneid, &phone) != EOK)
    680                 return IPC_CALLRET_FATAL;
     668        GET_CHECK_PHONE(phone, phoneid, return IPC_CALLRET_FATAL;);
    681669
    682670        call = ipc_call_alloc(0);
     
    717705                return IPC_CALLRET_TEMPORARY;
    718706
    719         if (phone_get(phoneid, &phone) != EOK)
    720                 return IPC_CALLRET_FATAL;
     707        GET_CHECK_PHONE(phone, phoneid, return IPC_CALLRET_FATAL;);
    721708
    722709        call = ipc_call_alloc(0);
     
    768755        call->flags |= IPC_CALL_FORWARDED;
    769756
    770         if (phone_get(phoneid, &phone) != EOK) {
     757        GET_CHECK_PHONE(phone, phoneid, {
    771758                IPC_SET_RETVAL(call->data, EFORWARD);
    772759                ipc_answer(&TASK->answerbox, call);
    773760                return ENOENT;
    774         }
     761        });
    775762
    776763        if (!method_is_forwardable(IPC_GET_METHOD(call->data))) {
     
    969956 * @return              Return 0 on success or an error code.
    970957 */
    971 unative_t sys_ipc_hangup(unative_t phoneid)
     958unative_t sys_ipc_hangup(int phoneid)
    972959{
    973960        phone_t *phone;
    974961
    975         if (phone_get(phoneid, &phone) != EOK)
    976                 return ENOENT;
     962        GET_CHECK_PHONE(phone, phoneid, return ENOENT;);
    977963
    978964        if (ipc_phone_hangup(phone))
Note: See TracChangeset for help on using the changeset viewer.