Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c9fff17 in mainline


Ignore:
Timestamp:
2010-04-13T18:34:26Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
d3b3395
Parents:
75ebb5b6
Message:

Replace the still buggy GET_CHECK_PHONE() macro with a function.

File:
1 edited

Legend:

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

    r75ebb5b6 rc9fff17  
    5858#define DATA_XFER_LIMIT         (64 * 1024)
    5959
    60 #define GET_CHECK_PHONE(phone, phoneid, err) \
    61 { \
    62         if ((unative_t) (phoneid) >= IPC_MAX_PHONES) { \
    63                 err \
    64         } \
    65         phone = &TASK->phones[(phoneid)]; \
     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 */
     66static 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;
    6673}
    6774
     
    374381        case IPC_M_CONNECTION_CLONE: {
    375382                phone_t *cloned_phone;
    376                 GET_CHECK_PHONE(cloned_phone, IPC_GET_ARG1(call->data),
    377                     return ENOENT;);
     383
     384                if (phone_get(IPC_GET_ARG1(call->data), &cloned_phone) != EOK)
     385                        return ENOENT;
    378386                phones_lock(cloned_phone, phone);
     387
    379388                if ((cloned_phone->state != IPC_PHONE_CONNECTED) ||
    380389                    phone->state != IPC_PHONE_CONNECTED) {
     
    534543        int res;
    535544        int rc;
    536        
    537         GET_CHECK_PHONE(phone, phoneid, return ENOENT;);
     545
     546        if (phone_get(phoneid, &phone) != EOK)
     547                return ENOENT;
    538548
    539549        call = ipc_call_alloc(0);
     
    591601        int rc;
    592602
    593         GET_CHECK_PHONE(phone, phoneid, return ENOENT;);
     603        if (phone_get(phoneid, &phone) != EOK)
     604                return ENOENT;
    594605
    595606        call = ipc_call_alloc(0);
     
    666677                return IPC_CALLRET_TEMPORARY;
    667678
    668         GET_CHECK_PHONE(phone, phoneid, return IPC_CALLRET_FATAL;);
     679        if (phone_get(phoneid, &phone) != EOK)
     680                return IPC_CALLRET_FATAL;
    669681
    670682        call = ipc_call_alloc(0);
     
    705717                return IPC_CALLRET_TEMPORARY;
    706718
    707         GET_CHECK_PHONE(phone, phoneid, return IPC_CALLRET_FATAL;);
     719        if (phone_get(phoneid, &phone) != EOK)
     720                return IPC_CALLRET_FATAL;
    708721
    709722        call = ipc_call_alloc(0);
     
    755768        call->flags |= IPC_CALL_FORWARDED;
    756769
    757         GET_CHECK_PHONE(phone, phoneid, {
     770        if (phone_get(phoneid, &phone) != EOK) {
    758771                IPC_SET_RETVAL(call->data, EFORWARD);
    759772                ipc_answer(&TASK->answerbox, call);
    760773                return ENOENT;
    761         });
     774        }
    762775
    763776        if (!method_is_forwardable(IPC_GET_METHOD(call->data))) {
     
    960973        phone_t *phone;
    961974
    962         GET_CHECK_PHONE(phone, phoneid, return ENOENT;);
     975        if (phone_get(phoneid, &phone) != EOK)
     976                return ENOENT;
    963977
    964978        if (ipc_phone_hangup(phone))
Note: See TracChangeset for help on using the changeset viewer.