Changeset b7fd2a0 in mainline for uspace/lib/c/generic/async.c


Ignore:
Timestamp:
2018-01-13T03:10:29Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a53ed3a
Parents:
36f0738
Message:

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/async.c

    r36f0738 rb7fd2a0  
    205205        ipc_call_t *dataptr;
    206206       
    207         int retval;
     207        errno_t retval;
    208208} amsg_t;
    209209
     
    511511static FIBRIL_CONDVAR_INITIALIZE(avail_phone_cv);
    512512
    513 int async_create_port(iface_t iface, async_port_handler_t handler,
     513errno_t async_create_port(iface_t iface, async_port_handler_t handler,
    514514    void *data, port_id_t *port_id)
    515515{
     
    698698 *
    699699 */
    700 static int connection_fibril(void *arg)
     700static errno_t connection_fibril(void *arg)
    701701{
    702702        assert(arg);
     
    847847 *
    848848 */
    849 int async_create_callback_port(async_exch_t *exch, iface_t iface, sysarg_t arg1,
     849errno_t async_create_callback_port(async_exch_t *exch, iface_t iface, sysarg_t arg1,
    850850    sysarg_t arg2, async_port_handler_t handler, void *data, port_id_t *port_id)
    851851{
     
    860860            &answer);
    861861       
    862         int ret;
     862        errno_t ret;
    863863        async_wait_for(req, &ret);
    864864        if (ret != EOK)
    865                 return (int) ret;
     865                return (errno_t) ret;
    866866       
    867867        sysarg_t phone_hash = IPC_GET_ARG5(answer);
     
    10561056 *
    10571057 */
    1058 int async_irq_subscribe(int inr, async_notification_handler_t handler,
     1058errno_t async_irq_subscribe(int inr, async_notification_handler_t handler,
    10591059    void *data, const irq_code_t *ucode, cap_handle_t *handle)
    10601060{
     
    10781078       
    10791079        cap_handle_t cap;
    1080         int rc = ipc_irq_subscribe(inr, imethod, ucode, &cap);
     1080        errno_t rc = ipc_irq_subscribe(inr, imethod, ucode, &cap);
    10811081        if (rc == EOK && handle != NULL) {
    10821082                *handle = cap;
     
    10921092 *
    10931093 */
    1094 int async_irq_unsubscribe(int cap)
     1094errno_t async_irq_unsubscribe(int cap)
    10951095{
    10961096        // TODO: Remove entry from hash table
     
    11091109 *
    11101110 */
    1111 int async_event_subscribe(event_type_t evno,
     1111errno_t async_event_subscribe(event_type_t evno,
    11121112    async_notification_handler_t handler, void *data)
    11131113{
     
    11421142 *
    11431143 */
    1144 int async_event_task_subscribe(event_task_type_t evno,
     1144errno_t async_event_task_subscribe(event_task_type_t evno,
    11451145    async_notification_handler_t handler, void *data)
    11461146{
     
    11731173 *
    11741174 */
    1175 int async_event_unmask(event_type_t evno)
     1175errno_t async_event_unmask(event_type_t evno)
    11761176{
    11771177        return ipc_event_unmask(evno);
     
    11851185 *
    11861186 */
    1187 int async_event_task_unmask(event_task_type_t evno)
     1187errno_t async_event_task_unmask(event_task_type_t evno)
    11881188{
    11891189        return ipc_event_task_unmask(evno);
     
    14371437 *
    14381438 */
    1439 static int async_manager_worker(void)
     1439static errno_t async_manager_worker(void)
    14401440{
    14411441        while (true) {
     
    14891489               
    14901490                ipc_call_t call;
    1491                 int rc = ipc_wait_cycle(&call, timeout, flags);
     1491                errno_t rc = ipc_wait_cycle(&call, timeout, flags);
    14921492               
    14931493                atomic_dec(&threads_in_ipc_wait);
     
    15211521 *
    15221522 */
    1523 static int async_manager_fibril(void *arg)
     1523static errno_t async_manager_fibril(void *arg)
    15241524{
    15251525        futex_up(&async_futex);
     
    15971597 *
    15981598 */
    1599 void reply_received(void *arg, int retval, ipc_call_t *data)
     1599void reply_received(void *arg, errno_t retval, ipc_call_t *data)
    16001600{
    16011601        assert(arg);
     
    17091709 *
    17101710 */
    1711 void async_wait_for(aid_t amsgid, int *retval)
     1711void async_wait_for(aid_t amsgid, errno_t *retval)
    17121712{
    17131713        assert(amsgid);
     
    17551755 *
    17561756 */
    1757 int async_wait_timeout(aid_t amsgid, int *retval, suseconds_t timeout)
     1757errno_t async_wait_timeout(aid_t amsgid, errno_t *retval, suseconds_t timeout)
    17581758{
    17591759        assert(amsgid);
     
    19181918 *
    19191919 */
    1920 int async_req_fast(async_exch_t *exch, sysarg_t imethod, sysarg_t arg1,
     1920errno_t async_req_fast(async_exch_t *exch, sysarg_t imethod, sysarg_t arg1,
    19211921    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t *r1, sysarg_t *r2,
    19221922    sysarg_t *r3, sysarg_t *r4, sysarg_t *r5)
     
    19291929            &result);
    19301930       
    1931         int rc;
     1931        errno_t rc;
    19321932        async_wait_for(aid, &rc);
    19331933       
     
    19701970 *
    19711971 */
    1972 int async_req_slow(async_exch_t *exch, sysarg_t imethod, sysarg_t arg1,
     1972errno_t async_req_slow(async_exch_t *exch, sysarg_t imethod, sysarg_t arg1,
    19731973    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, sysarg_t *r1,
    19741974    sysarg_t *r2, sysarg_t *r3, sysarg_t *r4, sysarg_t *r5)
     
    19811981            &result);
    19821982       
    1983         int rc;
     1983        errno_t rc;
    19841984        async_wait_for(aid, &rc);
    19851985       
     
    20452045}
    20462046
    2047 int async_answer_0(cap_handle_t chandle, int retval)
     2047errno_t async_answer_0(cap_handle_t chandle, errno_t retval)
    20482048{
    20492049        return ipc_answer_0(chandle, retval);
    20502050}
    20512051
    2052 int async_answer_1(cap_handle_t chandle, int retval, sysarg_t arg1)
     2052errno_t async_answer_1(cap_handle_t chandle, errno_t retval, sysarg_t arg1)
    20532053{
    20542054        return ipc_answer_1(chandle, retval, arg1);
    20552055}
    20562056
    2057 int async_answer_2(cap_handle_t chandle, int retval, sysarg_t arg1,
     2057errno_t async_answer_2(cap_handle_t chandle, errno_t retval, sysarg_t arg1,
    20582058    sysarg_t arg2)
    20592059{
     
    20612061}
    20622062
    2063 int async_answer_3(cap_handle_t chandle, int retval, sysarg_t arg1,
     2063errno_t async_answer_3(cap_handle_t chandle, errno_t retval, sysarg_t arg1,
    20642064    sysarg_t arg2, sysarg_t arg3)
    20652065{
     
    20672067}
    20682068
    2069 int async_answer_4(cap_handle_t chandle, int retval, sysarg_t arg1,
     2069errno_t async_answer_4(cap_handle_t chandle, errno_t retval, sysarg_t arg1,
    20702070    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
    20712071{
     
    20732073}
    20742074
    2075 int async_answer_5(cap_handle_t chandle, int retval, sysarg_t arg1,
     2075errno_t async_answer_5(cap_handle_t chandle, errno_t retval, sysarg_t arg1,
    20762076    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5)
    20772077{
     
    20792079}
    20802080
    2081 int async_forward_fast(cap_handle_t chandle, async_exch_t *exch,
     2081errno_t async_forward_fast(cap_handle_t chandle, async_exch_t *exch,
    20822082    sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode)
    20832083{
     
    20882088}
    20892089
    2090 int async_forward_slow(cap_handle_t chandle, async_exch_t *exch,
     2090errno_t async_forward_slow(cap_handle_t chandle, async_exch_t *exch,
    20912091    sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,
    20922092    sysarg_t arg4, sysarg_t arg5, unsigned int mode)
     
    21112111 *
    21122112 */
    2113 int async_connect_to_me(async_exch_t *exch, sysarg_t arg1, sysarg_t arg2,
     2113errno_t async_connect_to_me(async_exch_t *exch, sysarg_t arg1, sysarg_t arg2,
    21142114    sysarg_t arg3)
    21152115{
     
    21212121            &answer);
    21222122       
    2123         int rc;
     2123        errno_t rc;
    21242124        async_wait_for(req, &rc);
    21252125        if (rc != EOK)
    2126                 return (int) rc;
     2126                return (errno_t) rc;
    21272127       
    21282128        return EOK;
    21292129}
    21302130
    2131 static int async_connect_me_to_internal(int phone, sysarg_t arg1, sysarg_t arg2,
     2131static errno_t async_connect_me_to_internal(int phone, sysarg_t arg1, sysarg_t arg2,
    21322132    sysarg_t arg3, sysarg_t arg4, int *out_phone)
    21332133{
     
    21482148            msg, reply_received);
    21492149       
    2150         int rc;
     2150        errno_t rc;
    21512151        async_wait_for((aid_t) msg, &rc);
    21522152       
     
    21862186       
    21872187        int phone;
    2188         int rc = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3,
     2188        errno_t rc = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3,
    21892189            0, &phone);
    21902190        if (rc != EOK) {
     
    22392239       
    22402240        int phone;
    2241         int rc = async_connect_me_to_internal(exch->phone, iface, arg2,
     2241        errno_t rc = async_connect_me_to_internal(exch->phone, iface, arg2,
    22422242            arg3, 0, &phone);
    22432243        if (rc != EOK) {
     
    23102310       
    23112311        int phone;
    2312         int rc = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3,
     2312        errno_t rc = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3,
    23132313            IPC_FLAG_BLOCKING, &phone);
    23142314       
     
    23642364       
    23652365        int phone;
    2366         int rc = async_connect_me_to_internal(exch->phone, iface, arg2,
     2366        errno_t rc = async_connect_me_to_internal(exch->phone, iface, arg2,
    23672367            arg3, IPC_FLAG_BLOCKING, &phone);
    23682368        if (rc != EOK) {
     
    24002400       
    24012401        cap_handle_t phone;
    2402         int rc = ipc_connect_kbox(id, &phone);
     2402        errno_t rc = ipc_connect_kbox(id, &phone);
    24032403        if (rc != EOK) {
    24042404                errno = rc;
     
    24242424}
    24252425
    2426 static int async_hangup_internal(int phone)
     2426static errno_t async_hangup_internal(int phone)
    24272427{
    24282428        return ipc_hangup(phone);
     
    24362436 *
    24372437 */
    2438 int async_hangup(async_sess_t *sess)
     2438errno_t async_hangup(async_sess_t *sess)
    24392439{
    24402440        async_exch_t *exch;
     
    24472447        fibril_mutex_lock(&async_sess_mutex);
    24482448       
    2449         int rc = async_hangup_internal(sess->phone);
     2449        errno_t rc = async_hangup_internal(sess->phone);
    24502450       
    24512451        while (!list_empty(&sess->exch_list)) {
     
    25192519                } else if (mgmt == EXCHANGE_PARALLEL) {
    25202520                        int phone;
    2521                         int rc;
     2521                        errno_t rc;
    25222522                       
    25232523                retry:
     
    26162616 *
    26172617 */
    2618 int async_share_in_start(async_exch_t *exch, size_t size, sysarg_t arg,
     2618errno_t async_share_in_start(async_exch_t *exch, size_t size, sysarg_t arg,
    26192619    unsigned int *flags, void **dst)
    26202620{
     
    26242624        sysarg_t _flags = 0;
    26252625        sysarg_t _dst = (sysarg_t) -1;
    2626         int res = async_req_2_4(exch, IPC_M_SHARE_IN, (sysarg_t) size,
     2626        errno_t res = async_req_2_4(exch, IPC_M_SHARE_IN, (sysarg_t) size,
    26272627            arg, NULL, &_flags, NULL, &_dst);
    26282628       
     
    26762676 *
    26772677 */
    2678 int async_share_in_finalize(cap_handle_t chandle, void *src, unsigned int flags)
     2678errno_t async_share_in_finalize(cap_handle_t chandle, void *src, unsigned int flags)
    26792679{
    26802680        return ipc_answer_3(chandle, EOK, (sysarg_t) src, (sysarg_t) flags,
     
    26912691 *
    26922692 */
    2693 int async_share_out_start(async_exch_t *exch, void *src, unsigned int flags)
     2693errno_t async_share_out_start(async_exch_t *exch, void *src, unsigned int flags)
    26942694{
    26952695        if (exch == NULL)
     
    27462746 *
    27472747 */
    2748 int async_share_out_finalize(cap_handle_t chandle, void **dst)
     2748errno_t async_share_out_finalize(cap_handle_t chandle, void **dst)
    27492749{
    27502750        return ipc_answer_2(chandle, EOK, (sysarg_t) __entry, (sysarg_t) dst);
     
    27772777 *
    27782778 */
    2779 int async_data_read_start(async_exch_t *exch, void *dst, size_t size)
     2779errno_t async_data_read_start(async_exch_t *exch, void *dst, size_t size)
    27802780{
    27812781        if (exch == NULL)
     
    28512851 *
    28522852 */
    2853 int async_data_read_finalize(cap_handle_t chandle, const void *src, size_t size)
     2853errno_t async_data_read_finalize(cap_handle_t chandle, const void *src, size_t size)
    28542854{
    28552855        return ipc_answer_2(chandle, EOK, (sysarg_t) src, (sysarg_t) size);
     
    28592859 *
    28602860 */
    2861 int async_data_read_forward_fast(async_exch_t *exch, sysarg_t imethod,
     2861errno_t async_data_read_forward_fast(async_exch_t *exch, sysarg_t imethod,
    28622862    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4,
    28632863    ipc_call_t *dataptr)
     
    28792879        }
    28802880       
    2881         int retval = ipc_forward_fast(chandle, exch->phone, 0, 0, 0,
     2881        errno_t retval = ipc_forward_fast(chandle, exch->phone, 0, 0, 0,
    28822882            IPC_FF_ROUTE_FROM_ME);
    28832883        if (retval != EOK) {
     
    28872887        }
    28882888       
    2889         int rc;
     2889        errno_t rc;
    28902890        async_wait_for(msg, &rc);
    28912891       
    2892         return (int) rc;
     2892        return (errno_t) rc;
    28932893}
    28942894
     
    29022902 *
    29032903 */
    2904 int async_data_write_start(async_exch_t *exch, const void *src, size_t size)
     2904errno_t async_data_write_start(async_exch_t *exch, const void *src, size_t size)
    29052905{
    29062906        if (exch == NULL)
     
    29762976 *
    29772977 */
    2978 int async_data_write_finalize(cap_handle_t chandle, void *dst, size_t size)
     2978errno_t async_data_write_finalize(cap_handle_t chandle, void *dst, size_t size)
    29792979{
    29802980        return ipc_answer_2(chandle, EOK, (sysarg_t) dst, (sysarg_t) size);
     
    30023002 *
    30033003 */
    3004 int async_data_write_accept(void **data, const bool nullterm,
     3004errno_t async_data_write_accept(void **data, const bool nullterm,
    30053005    const size_t min_size, const size_t max_size, const size_t granularity,
    30063006    size_t *received)
     
    30423042        }
    30433043       
    3044         int rc = async_data_write_finalize(chandle, arg_data, size);
     3044        errno_t rc = async_data_write_finalize(chandle, arg_data, size);
    30453045        if (rc != EOK) {
    30463046                free(arg_data);
     
    30653065 *
    30663066 */
    3067 void async_data_write_void(int retval)
     3067void async_data_write_void(errno_t retval)
    30683068{
    30693069        cap_handle_t chandle;
     
    30753075 *
    30763076 */
    3077 int async_data_write_forward_fast(async_exch_t *exch, sysarg_t imethod,
     3077errno_t async_data_write_forward_fast(async_exch_t *exch, sysarg_t imethod,
    30783078    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4,
    30793079    ipc_call_t *dataptr)
     
    30953095        }
    30963096       
    3097         int retval = ipc_forward_fast(chandle, exch->phone, 0, 0, 0,
     3097        errno_t retval = ipc_forward_fast(chandle, exch->phone, 0, 0, 0,
    30983098            IPC_FF_ROUTE_FROM_ME);
    30993099        if (retval != EOK) {
     
    31033103        }
    31043104       
    3105         int rc;
     3105        errno_t rc;
    31063106        async_wait_for(msg, &rc);
    31073107       
    3108         return (int) rc;
     3108        return (errno_t) rc;
    31093109}
    31103110
     
    32003200}
    32013201
    3202 int async_state_change_start(async_exch_t *exch, sysarg_t arg1, sysarg_t arg2,
     3202errno_t async_state_change_start(async_exch_t *exch, sysarg_t arg1, sysarg_t arg2,
    32033203    sysarg_t arg3, async_exch_t *other_exch)
    32043204{
     
    32283228}
    32293229
    3230 int async_state_change_finalize(cap_handle_t chandle, async_exch_t *other_exch)
     3230errno_t async_state_change_finalize(cap_handle_t chandle, async_exch_t *other_exch)
    32313231{
    32323232        return ipc_answer_1(chandle, EOK, other_exch->phone);
Note: See TracChangeset for help on using the changeset viewer.