Changeset b7fd2a0 in mainline for uspace/srv/audio/hound/hound.c


Ignore:
Timestamp:
2018-01-13T03:10:29Z (6 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/srv/audio/hound/hound.c

    r36f0738 rb7fd2a0  
    110110}
    111111
    112 static int hound_disconnect_internal(hound_t *hound, const char* source_name, const char* sink_name);
     112static errno_t hound_disconnect_internal(hound_t *hound, const char* source_name, const char* sink_name);
    113113
    114114/**
     
    162162 * @return Error code.
    163163 */
    164 int hound_init(hound_t *hound)
     164errno_t hound_init(hound_t *hound)
    165165{
    166166        assert(hound);
     
    180180 * @return Error code.
    181181 */
    182 int hound_add_ctx(hound_t *hound, hound_ctx_t *ctx)
     182errno_t hound_add_ctx(hound_t *hound, hound_ctx_t *ctx)
    183183{
    184184        log_info("Trying to add context %p", ctx);
     
    189189        list_append(&ctx->link, &hound->contexts);
    190190        fibril_mutex_unlock(&hound->list_guard);
    191         int ret = EOK;
     191        errno_t ret = EOK;
    192192        if (ret == EOK && ctx->source)
    193193                ret = hound_add_source(hound, ctx->source);
     
    208208 * @return Error code.
    209209 */
    210 int hound_remove_ctx(hound_t *hound, hound_ctx_t *ctx)
     210errno_t hound_remove_ctx(hound_t *hound, hound_ctx_t *ctx)
    211211{
    212212        assert(hound);
     
    254254 * @return Error code.
    255255 */
    256 int hound_add_device(hound_t *hound, service_id_t id, const char *name)
     256errno_t hound_add_device(hound_t *hound, service_id_t id, const char *name)
    257257{
    258258        log_verbose("Adding device \"%s\", service: %zu", name, id);
     
    283283        }
    284284
    285         const int ret = audio_device_init(dev, id, name);
     285        const errno_t ret = audio_device_init(dev, id, name);
    286286        if (ret != EOK) {
    287287                log_debug("Failed to initialize new audio device: %s",
     
    296296        audio_source_t *source = audio_device_get_source(dev);
    297297        if (source) {
    298                 const int ret = hound_add_source(hound, source);
     298                const errno_t ret = hound_add_source(hound, source);
    299299                if (ret != EOK) {
    300300                        log_debug("Failed to add device source: %s",
     
    308308        audio_sink_t *sink = audio_device_get_sink(dev);
    309309        if (sink) {
    310                 const int ret = hound_add_sink(hound, sink);
     310                const errno_t ret = hound_add_sink(hound, sink);
    311311                if (ret != EOK) {
    312312                        log_debug("Failed to add device sink: %s",
     
    330330 * @return Error code.
    331331 */
    332 int hound_add_source(hound_t *hound, audio_source_t *source)
     332errno_t hound_add_source(hound_t *hound, audio_source_t *source)
    333333{
    334334        assert(hound);
     
    354354 * @return Error code.
    355355 */
    356 int hound_add_sink(hound_t *hound, audio_sink_t *sink)
     356errno_t hound_add_sink(hound_t *hound, audio_sink_t *sink)
    357357{
    358358        assert(hound);
     
    378378 * @return Error code.
    379379 */
    380 int hound_remove_source(hound_t *hound, audio_source_t *source)
     380errno_t hound_remove_source(hound_t *hound, audio_source_t *source)
    381381{
    382382        assert(hound);
     
    395395 * @return Error code.
    396396 */
    397 int hound_remove_sink(hound_t *hound, audio_sink_t *sink)
     397errno_t hound_remove_sink(hound_t *hound, audio_sink_t *sink)
    398398{
    399399        assert(hound);
     
    413413 * @return Error code.
    414414 */
    415 int hound_list_sources(hound_t *hound, const char ***list, size_t *size)
     415errno_t hound_list_sources(hound_t *hound, const char ***list, size_t *size)
    416416{
    417417        assert(hound);
     
    428428        }
    429429        const char **names = calloc(count, sizeof(char *));
    430         int ret = names ? EOK : ENOMEM;
     430        errno_t ret = names ? EOK : ENOMEM;
    431431        for (unsigned long i = 0; i < count && ret == EOK; ++i) {
    432432                link_t *slink = list_nth(&hound->sources, i);
     
    455455 * @return Error code.
    456456 */
    457 int hound_list_sinks(hound_t *hound, const char ***list, size_t *size)
     457errno_t hound_list_sinks(hound_t *hound, const char ***list, size_t *size)
    458458{
    459459        assert(hound);
     
    470470        }
    471471        const char **names = calloc(count, sizeof(char *));
    472         int ret = names ? EOK : ENOMEM;
     472        errno_t ret = names ? EOK : ENOMEM;
    473473        for (size_t i = 0; i < count && ret == EOK; ++i) {
    474474                link_t *slink = list_nth(&hound->sinks, i);
     
    501501 * identifiers with the same index are connected.
    502502 */
    503 int hound_list_connections(hound_t *hound, const char ***sources,
     503errno_t hound_list_connections(hound_t *hound, const char ***sources,
    504504    const char ***sinks, size_t *size)
    505505{
     
    516516 * @return Error code.
    517517 */
    518 int hound_connect(hound_t *hound, const char* source_name, const char* sink_name)
     518errno_t hound_connect(hound_t *hound, const char* source_name, const char* sink_name)
    519519{
    520520        assert(hound);
     
    555555 * @return Error code.
    556556 */
    557 int hound_disconnect(hound_t *hound, const char* source_name, const char* sink_name)
    558 {
    559         assert(hound);
    560         fibril_mutex_lock(&hound->list_guard);
    561         const int ret = hound_disconnect_internal(hound, source_name, sink_name);
     557errno_t hound_disconnect(hound_t *hound, const char* source_name, const char* sink_name)
     558{
     559        assert(hound);
     560        fibril_mutex_lock(&hound->list_guard);
     561        const errno_t ret = hound_disconnect_internal(hound, source_name, sink_name);
    562562        fibril_mutex_unlock(&hound->list_guard);
    563563        return ret;
     
    573573 * This function has to be called with the list_guard lock held.
    574574 */
    575 static int hound_disconnect_internal(hound_t *hound, const char* source_name,
     575static errno_t hound_disconnect_internal(hound_t *hound, const char* source_name,
    576576    const char* sink_name)
    577577{
Note: See TracChangeset for help on using the changeset viewer.