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

Changeset fed5a9b in mainline


Ignore:
Timestamp:
2017-12-08T21:03:35Z (4 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master
Children:
125c09c
Parents:
a8c7a6d
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-08 03:29:45)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-08 21:03:35)
Message:

Fix error handling in libhound.

Location:
uspace/lib/hound
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/hound/include/hound/protocol.h

    ra8c7a6d rfed5a9b  
    5858typedef intptr_t hound_context_id_t;
    5959
    60 /**
    61  * Check context id for errors.
    62  * @param id Context id
    63  * @return Error code.
    64  */
    65 static inline int hound_context_id_err(hound_context_id_t id)
    66 {
    67         return id > 0 ? EOK : (id == 0 ? ENOENT : id);
    68 }
    69 
    7060hound_sess_t *hound_service_connect(const char *service);
    7161void hound_service_disconnect(hound_sess_t *sess);
    7262
    73 hound_context_id_t hound_service_register_context(hound_sess_t *sess,
    74     const char *name, bool record);
     63int hound_service_register_context(hound_sess_t *sess,
     64    const char *name, bool record, hound_context_id_t *id);
    7565int hound_service_unregister_context(hound_sess_t *sess, hound_context_id_t id);
    7666
  • uspace/lib/hound/src/client.c

    ra8c7a6d rfed5a9b  
    123123                        return NULL;
    124124                }
    125                 new_context->id = hound_service_register_context(
    126                     new_context->session, new_context->name, record);
    127                 if (hound_context_id_err(new_context->id) != EOK) {
     125                int rc = hound_service_register_context(
     126                    new_context->session, new_context->name, record,
     127                    &new_context->id);
     128                if (rc != EOK) {
    128129                        hound_service_disconnect(new_context->session);
    129130                        free(new_context->name);
  • uspace/lib/hound/src/protocol.c

    ra8c7a6d rfed5a9b  
    115115 * @param name Valid string identifier
    116116 * @param record True if the application context wishes to receive data.
    117  * @return Valid ID on success, Error code on failure.
    118  */
    119 hound_context_id_t hound_service_register_context(hound_sess_t *sess,
    120     const char *name, bool record)
     117 *
     118 * @param[out] id  Return context ID.
     119 *
     120 * @return EOK on success, Error code on failure.
     121 */
     122int hound_service_register_context(hound_sess_t *sess,
     123    const char *name, bool record, hound_context_id_t *id)
    121124{
    122125        assert(sess);
     
    126129        aid_t mid =
    127130            async_send_1(exch, IPC_M_HOUND_CONTEXT_REGISTER, record, &call);
    128         int ret = mid ? EOK : EPARTY;
     131        sysarg_t ret = mid ? EOK : EPARTY;
    129132
    130133        if (ret == EOK)
     
    134137
    135138        if (ret == EOK)
    136                 async_wait_for(mid, (sysarg_t *)&ret);
     139                async_wait_for(mid, &ret);
    137140
    138141        async_exchange_end(exch);
    139         return ret == EOK ? (hound_context_id_t)IPC_GET_ARG1(call) : ret;
     142        if (ret == EOK) {
     143                *id = (hound_context_id_t)IPC_GET_ARG1(call);
     144        }
     145
     146        return ret;
    140147}
    141148
     
    184191            (bool)connection, &res_call);
    185192
    186         int ret = EOK;
     193        sysarg_t ret = EOK;
    187194        if (mid && connection)
    188195                ret = async_data_write_start(exch, connection,
     
    190197
    191198        if (ret == EOK)
    192                 async_wait_for(mid, (sysarg_t*)&ret);
     199                async_wait_for(mid, &ret);
    193200
    194201        if (ret != EOK) {
     
    252259        ipc_call_t call;
    253260        aid_t id = async_send_0(exch, IPC_M_HOUND_CONNECT, &call);
    254         int ret = id ? EOK : EPARTY;
     261        sysarg_t ret = id ? EOK : EPARTY;
    255262        if (ret == EOK)
    256263                ret = async_data_write_start(exch, source, str_size(source));
    257264        if (ret == EOK)
    258265                ret = async_data_write_start(exch, sink, str_size(sink));
    259         async_wait_for(id, (sysarg_t*)&ret);
     266        async_wait_for(id, &ret);
    260267        async_exchange_end(exch);
    261268        return ret;
     
    278285        ipc_call_t call;
    279286        aid_t id = async_send_0(exch, IPC_M_HOUND_DISCONNECT, &call);
    280         int ret = id ? EOK : EPARTY;
     287        sysarg_t ret = id ? EOK : EPARTY;
    281288        if (ret == EOK)
    282289                ret = async_data_write_start(exch, source, str_size(source));
    283290        if (ret == EOK)
    284291                ret = async_data_write_start(exch, sink, str_size(sink));
    285         async_wait_for(id, (sysarg_t*)&ret);
     292        async_wait_for(id, &ret);
    286293        async_exchange_end(exch);
    287294        return ENOTSUP;
Note: See TracChangeset for help on using the changeset viewer.