Changeset 984a9ba in mainline for uspace/lib/c/generic/io/input.c


Ignore:
Timestamp:
2018-07-05T09:34:09Z (6 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
63d46341
Parents:
76f566d
Message:

do not expose the call capability handler from the async framework

Keep the call capability handler encapsulated within the async framework
and do not expose it explicitly via its API. Use the pointer to
ipc_call_t as the sole object identifying an IPC call in the code that
uses the async framework.

This plugs a major leak in the abstraction and also simplifies both the
async framework (slightly) and all IPC servers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/input.c

    r76f566d r984a9ba  
    4343#include <stdlib.h>
    4444
    45 static void input_cb_conn(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg);
     45static void input_cb_conn(ipc_call_t *icall, void *arg);
    4646
    4747errno_t input_open(async_sess_t *sess, input_ev_ops_t *ev_ops,
     
    9292}
    9393
    94 static void input_ev_active(input_t *input, cap_call_handle_t chandle,
    95     ipc_call_t *call)
     94static void input_ev_active(input_t *input, ipc_call_t *call)
    9695{
    9796        errno_t rc = input->ev_ops->active(input);
    98         async_answer_0(chandle, rc);
    99 }
    100 
    101 static void input_ev_deactive(input_t *input, cap_call_handle_t chandle,
    102     ipc_call_t *call)
     97        async_answer_0(call, rc);
     98}
     99
     100static void input_ev_deactive(input_t *input, ipc_call_t *call)
    103101{
    104102        errno_t rc = input->ev_ops->deactive(input);
    105         async_answer_0(chandle, rc);
    106 }
    107 
    108 static void input_ev_key(input_t *input, cap_call_handle_t chandle,
    109     ipc_call_t *call)
     103        async_answer_0(call, rc);
     104}
     105
     106static void input_ev_key(input_t *input, ipc_call_t *call)
    110107{
    111108        kbd_event_type_t type;
     
    121118
    122119        rc = input->ev_ops->key(input, type, key, mods, c);
    123         async_answer_0(chandle, rc);
    124 }
    125 
    126 static void input_ev_move(input_t *input, cap_call_handle_t chandle,
    127     ipc_call_t *call)
     120        async_answer_0(call, rc);
     121}
     122
     123static void input_ev_move(input_t *input, ipc_call_t *call)
    128124{
    129125        int dx;
     
    135131
    136132        rc = input->ev_ops->move(input, dx, dy);
    137         async_answer_0(chandle, rc);
    138 }
    139 
    140 static void input_ev_abs_move(input_t *input, cap_call_handle_t chandle,
    141     ipc_call_t *call)
     133        async_answer_0(call, rc);
     134}
     135
     136static void input_ev_abs_move(input_t *input, ipc_call_t *call)
    142137{
    143138        unsigned x;
     
    153148
    154149        rc = input->ev_ops->abs_move(input, x, y, max_x, max_y);
    155         async_answer_0(chandle, rc);
    156 }
    157 
    158 static void input_ev_button(input_t *input, cap_call_handle_t chandle,
    159     ipc_call_t *call)
     150        async_answer_0(call, rc);
     151}
     152
     153static void input_ev_button(input_t *input, ipc_call_t *call)
    160154{
    161155        int bnum;
     
    167161
    168162        rc = input->ev_ops->button(input, bnum, press);
    169         async_answer_0(chandle, rc);
    170 }
    171 
    172 static void input_cb_conn(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
    173 {
    174         input_t *input = (input_t *)arg;
     163        async_answer_0(call, rc);
     164}
     165
     166static void input_cb_conn(ipc_call_t *icall, void *arg)
     167{
     168        input_t *input = (input_t *) arg;
    175169
    176170        while (true) {
    177171                ipc_call_t call;
    178                 cap_call_handle_t chandle = async_get_call(&call);
     172                async_get_call(&call);
    179173
    180174                if (!IPC_GET_IMETHOD(call)) {
     
    185179                switch (IPC_GET_IMETHOD(call)) {
    186180                case INPUT_EVENT_ACTIVE:
    187                         input_ev_active(input, chandle, &call);
     181                        input_ev_active(input, &call);
    188182                        break;
    189183                case INPUT_EVENT_DEACTIVE:
    190                         input_ev_deactive(input, chandle, &call);
     184                        input_ev_deactive(input, &call);
    191185                        break;
    192186                case INPUT_EVENT_KEY:
    193                         input_ev_key(input, chandle, &call);
     187                        input_ev_key(input, &call);
    194188                        break;
    195189                case INPUT_EVENT_MOVE:
    196                         input_ev_move(input, chandle, &call);
     190                        input_ev_move(input, &call);
    197191                        break;
    198192                case INPUT_EVENT_ABS_MOVE:
    199                         input_ev_abs_move(input, chandle, &call);
     193                        input_ev_abs_move(input, &call);
    200194                        break;
    201195                case INPUT_EVENT_BUTTON:
    202                         input_ev_button(input, chandle, &call);
     196                        input_ev_button(input, &call);
    203197                        break;
    204198                default:
    205                         async_answer_0(chandle, ENOTSUP);
     199                        async_answer_0(&call, ENOTSUP);
    206200                }
    207201        }
Note: See TracChangeset for help on using the changeset viewer.