Changeset b7fd2a0 in mainline for uspace/lib/hound/src


Ignore:
Timestamp:
2018-01-13T03:10:29Z (8 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.

Location:
uspace/lib/hound/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/hound/src/client.c

    r36f0738 rb7fd2a0  
    123123                        return NULL;
    124124                }
    125                 int rc = hound_service_register_context(
     125                errno_t rc = hound_service_register_context(
    126126                    new_context->session, new_context->name, record,
    127127                    &new_context->id);
     
    195195 * The function will return deice sinks or source based on the context type.
    196196 */
    197 int hound_context_get_available_targets(hound_context_t *hound,
     197errno_t hound_context_get_available_targets(hound_context_t *hound,
    198198    const char ***names, size_t *count)
    199199{
     
    212212 * @return Error code.
    213213 */
    214 int hound_context_get_connected_targets(hound_context_t *hound,
     214errno_t hound_context_get_connected_targets(hound_context_t *hound,
    215215    const char ***names, size_t *count)
    216216{
     
    232232 * connect to the first possible target if it is passed this value.
    233233 */
    234 int hound_context_connect_target(hound_context_t *hound, const char* target)
     234errno_t hound_context_connect_target(hound_context_t *hound, const char* target)
    235235{
    236236        assert(hound);
     
    239239        const char **tgt = NULL;
    240240        size_t count = 1;
    241         int ret = EOK;
     241        errno_t ret = EOK;
    242242        if (str_cmp(target, HOUND_DEFAULT_TARGET) == 0) {
    243243                ret = hound_context_get_available_targets(hound, &tgt, &count);
     
    269269 * @return Error code.
    270270 */
    271 int hound_context_disconnect_target(hound_context_t *hound, const char* target)
     271errno_t hound_context_disconnect_target(hound_context_t *hound, const char* target)
    272272{
    273273        assert(hound);
     
    305305                new_stream->context = hound;
    306306                new_stream->flags = flags;
    307                 const int ret = hound_service_stream_enter(new_stream->exch,
     307                const errno_t ret = hound_service_stream_enter(new_stream->exch,
    308308                    hound->id, flags, format, bsize);
    309309                if (ret != EOK) {
     
    343343 * @return error code.
    344344 */
    345 int hound_stream_write(hound_stream_t *stream, const void *data, size_t size)
     345errno_t hound_stream_write(hound_stream_t *stream, const void *data, size_t size)
    346346{
    347347        assert(stream);
     
    358358 * @return error code.
    359359 */
    360 int hound_stream_read(hound_stream_t *stream, void *data, size_t size)
     360errno_t hound_stream_read(hound_stream_t *stream, void *data, size_t size)
    361361{
    362362        assert(stream);
     
    371371 * @return Error code.
    372372 */
    373 int hound_stream_drain(hound_stream_t *stream)
     373errno_t hound_stream_drain(hound_stream_t *stream)
    374374{
    375375        assert(stream);
     
    402402 * @return error code.
    403403 */
    404 int hound_write_main_stream(hound_context_t *hound,
     404errno_t hound_write_main_stream(hound_context_t *hound,
    405405    const void *data, size_t size)
    406406{
     
    422422 * @return error code.
    423423 */
    424 int hound_read_main_stream(hound_context_t *hound, void *data, size_t size)
     424errno_t hound_read_main_stream(hound_context_t *hound, void *data, size_t size)
    425425{
    426426        assert(hound);
     
    442442 * NOT IMPLEMENTED
    443443 */
    444 int hound_write_replace_main_stream(hound_context_t *hound,
     444errno_t hound_write_replace_main_stream(hound_context_t *hound,
    445445    const void *data, size_t size)
    446446{
     
    460460 * NOT IMPLEMENTED
    461461 */
    462 int hound_context_set_main_stream_params(hound_context_t *hound,
     462errno_t hound_context_set_main_stream_params(hound_context_t *hound,
    463463    pcm_format_t format, size_t bsize)
    464464{
     
    479479 * to drain and destroys it before returning.
    480480 */
    481 int hound_write_immediate(hound_context_t *hound, pcm_format_t format,
     481errno_t hound_write_immediate(hound_context_t *hound, pcm_format_t format,
    482482    const void *data, size_t size)
    483483{
     
    488488        if (!tmpstream)
    489489                return ENOMEM;
    490         const int ret = hound_stream_write(tmpstream, data, size);
     490        const errno_t ret = hound_stream_write(tmpstream, data, size);
    491491        if (ret == EOK) {
    492492                //TODO drain?
  • uspace/lib/hound/src/protocol.c

    r36f0738 rb7fd2a0  
    9393{
    9494        service_id_t id = 0;
    95         const int ret =
     95        const errno_t ret =
    9696            loc_service_get_id(service, &id, IPC_FLAG_BLOCKING);
    9797        if (ret != EOK)
     
    120120 * @return EOK on success, Error code on failure.
    121121 */
    122 int hound_service_register_context(hound_sess_t *sess,
     122errno_t hound_service_register_context(hound_sess_t *sess,
    123123    const char *name, bool record, hound_context_id_t *id)
    124124{
     
    129129        aid_t mid =
    130130            async_send_1(exch, IPC_M_HOUND_CONTEXT_REGISTER, record, &call);
    131         int ret = mid ? EOK : EPARTY;
     131        errno_t ret = mid ? EOK : EPARTY;
    132132
    133133        if (ret == EOK)
     
    153153 * @return Error code.
    154154 */
    155 int hound_service_unregister_context(hound_sess_t *sess, hound_context_id_t id)
     155errno_t hound_service_unregister_context(hound_sess_t *sess, hound_context_id_t id)
    156156{
    157157        assert(sess);
    158158        async_exch_t *exch = async_exchange_begin(sess);
    159         const int ret =
     159        const errno_t ret =
    160160            async_req_1_0(exch, IPC_M_HOUND_CONTEXT_UNREGISTER, id);
    161161        async_exchange_end(exch);
     
    173173 * @retval Error code.
    174174 */
    175 int hound_service_get_list(hound_sess_t *sess, const char ***ids, size_t *count,
     175errno_t hound_service_get_list(hound_sess_t *sess, const char ***ids, size_t *count,
    176176    int flags, const char *connection)
    177177{
     
    191191            connection != NULL, &res_call);
    192192
    193         int ret = EOK;
     193        errno_t ret = EOK;
    194194        if (mid && connection)
    195195                ret = async_data_write_start(exch, connection,
     
    247247 * @return Error code.
    248248 */
    249 int hound_service_connect_source_sink(hound_sess_t *sess, const char *source,
     249errno_t hound_service_connect_source_sink(hound_sess_t *sess, const char *source,
    250250    const char *sink)
    251251{
     
    259259        ipc_call_t call;
    260260        aid_t id = async_send_0(exch, IPC_M_HOUND_CONNECT, &call);
    261         int ret = id ? EOK : EPARTY;
     261        errno_t ret = id ? EOK : EPARTY;
    262262        if (ret == EOK)
    263263                ret = async_data_write_start(exch, source, str_size(source));
     
    276276 * @return Error code.
    277277 */
    278 int hound_service_disconnect_source_sink(hound_sess_t *sess, const char *source,
     278errno_t hound_service_disconnect_source_sink(hound_sess_t *sess, const char *source,
    279279    const char *sink)
    280280{
     
    285285        ipc_call_t call;
    286286        aid_t id = async_send_0(exch, IPC_M_HOUND_DISCONNECT, &call);
    287         int ret = id ? EOK : EPARTY;
     287        errno_t ret = id ? EOK : EPARTY;
    288288        if (ret == EOK)
    289289                ret = async_data_write_start(exch, source, str_size(source));
     
    304304 * @return Error code.
    305305 */
    306 int hound_service_stream_enter(async_exch_t *exch, hound_context_id_t id,
     306errno_t hound_service_stream_enter(async_exch_t *exch, hound_context_id_t id,
    307307    int flags, pcm_format_t format, size_t bsize)
    308308{
     
    321321 * @return Error code.
    322322 */
    323 int hound_service_stream_exit(async_exch_t *exch)
     323errno_t hound_service_stream_exit(async_exch_t *exch)
    324324{
    325325        return async_req_0_0(exch, IPC_M_HOUND_STREAM_EXIT);
     
    331331 * @return Error code.
    332332 */
    333 int hound_service_stream_drain(async_exch_t *exch)
     333errno_t hound_service_stream_drain(async_exch_t *exch)
    334334{
    335335        return async_req_0_0(exch, IPC_M_HOUND_STREAM_DRAIN);
     
    343343 * @return Error code.
    344344 */
    345 int hound_service_stream_write(async_exch_t *exch, const void *data, size_t size)
     345errno_t hound_service_stream_write(async_exch_t *exch, const void *data, size_t size)
    346346{
    347347        return async_data_write_start(exch, data, size);
     
    355355 * @return Error code.
    356356 */
    357 int hound_service_stream_read(async_exch_t *exch, void *data, size_t size)
     357errno_t hound_service_stream_read(async_exch_t *exch, void *data, size_t size)
    358358{
    359359        return async_data_read_start(exch, data, size);
     
    407407
    408408                        /* Get context name */
    409                         int ret =
     409                        errno_t ret =
    410410                            async_data_write_accept(&name, true, 0, 0, 0, 0);
    411411                        if (ret != EOK) {
     
    434434                        /* get id, 1st param */
    435435                        hound_context_id_t id = IPC_GET_ARG1(call);
    436                         const int ret =
     436                        const errno_t ret =
    437437                            server_iface->rem_context(server_iface->server, id);
    438438                        async_answer_0(callid, ret);
     
    451451                        const bool conn = IPC_GET_ARG3(call);
    452452                        char *conn_name = NULL;
    453                         int ret = EOK;
     453                        errno_t ret = EOK;
    454454
    455455                        /* get connected actor name if provided */
     
    513513
    514514                        /* read source name */
    515                         int ret =
     515                        errno_t ret =
    516516                            async_data_write_accept(&source, true, 0, 0, 0, 0);
    517517                        /* read sink name */
     
    539539
    540540                        /* read source name */
    541                         int ret =
     541                        errno_t ret =
    542542                            async_data_write_accept(&source, true, 0, 0, 0, 0);
    543543                        /*read sink name */
     
    574574
    575575                        void *stream;
    576                         int ret = server_iface->add_stream(server_iface->server,
     576                        errno_t ret = server_iface->add_stream(server_iface->server,
    577577                            id, flags, f, bsize, &stream);
    578578                        if (ret != EOK) {
     
    626626        ipc_call_t call;
    627627        size_t size = 0;
    628         int ret_answer = EOK;
     628        errno_t ret_answer = EOK;
    629629        /* accept data write or drain */
    630630        while (async_data_write_receive_call(&callid, &call, &size)
     
    632632                /* check drain first */
    633633                if (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN) {
    634                         int ret = ENOTSUP;
     634                        errno_t ret = ENOTSUP;
    635635                        if (server_iface->drain_stream)
    636636                                ret = server_iface->drain_stream(stream);
     
    650650                        continue;
    651651                }
    652                 const int ret = async_data_write_finalize(callid, buffer, size);
     652                const errno_t ret = async_data_write_finalize(callid, buffer, size);
    653653                if (ret == EOK) {
    654654                        /* push data to stream */
     
    657657                }
    658658        }
    659         const int ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT
     659        const errno_t ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT
    660660            ? EOK : EINVAL;
    661661
     
    673673        ipc_call_t call;
    674674        size_t size = 0;
    675         int ret_answer = EOK;
     675        errno_t ret_answer = EOK;
    676676        /* accept data read and drain */
    677677        while (async_data_read_receive_call(&callid, &call, &size)
     
    679679                /* drain does not make much sense but it is allowed */
    680680                if (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN) {
    681                         int ret = ENOTSUP;
     681                        errno_t ret = ENOTSUP;
    682682                        if (server_iface->drain_stream)
    683683                                ret = server_iface->drain_stream(stream);
     
    695695                        continue;
    696696                }
    697                 int ret = server_iface->stream_data_read(stream, buffer, size);
     697                errno_t ret = server_iface->stream_data_read(stream, buffer, size);
    698698                if (ret == EOK) {
    699699                        ret_answer =
     
    701701                }
    702702        }
    703         const int ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT
     703        const errno_t ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT
    704704            ? EOK : EINVAL;
    705705
     
    718718 * @return Error code.
    719719 */
    720 int hound_server_register(const char *name, service_id_t *id)
     720errno_t hound_server_register(const char *name, service_id_t *id)
    721721{
    722722        if (!name || !id)
    723723                return EINVAL;
    724724
    725         int ret = loc_server_register(name);
     725        errno_t ret = loc_server_register(name);
    726726        if (ret != EOK)
    727727                return ret;
     
    744744 * @return Error code.
    745745 */
    746 int hound_server_set_device_change_callback(dev_change_callback_t cb)
     746errno_t hound_server_set_device_change_callback(dev_change_callback_t cb)
    747747{
    748748        return loc_register_cat_change_cb(cb);
     
    754754 * @return Error code.
    755755 */
    756 int hound_server_devices_iterate(device_callback_t callback)
     756errno_t hound_server_devices_iterate(device_callback_t callback)
    757757{
    758758        if (!callback)
     
    762762
    763763        if (!resolved) {
    764                 const int ret = loc_category_get_id("audio-pcm", &cat_id,
     764                const errno_t ret = loc_category_get_id("audio-pcm", &cat_id,
    765765                    IPC_FLAG_BLOCKING);
    766766                if (ret != EOK)
     
    771771        service_id_t *svcs = NULL;
    772772        size_t count = 0;
    773         const int ret = loc_category_get_svcs(cat_id, &svcs, &count);
     773        const errno_t ret = loc_category_get_svcs(cat_id, &svcs, &count);
    774774        if (ret != EOK)
    775775                return ret;
Note: See TracChangeset for help on using the changeset viewer.