Changeset d5c1051 in mainline for uspace/app


Ignore:
Timestamp:
2017-12-20T22:25:34Z (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:
39b54fe
Parents:
8610c2c
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-20 22:22:29)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-20 22:25:34)
Message:

"Obviously harmless" error handling tweaks.

Location:
uspace/app
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/builtins/batch/batch.c

    r8610c2c rd5c1051  
    8585        }
    8686
    87         int rc = 0;
     87        int rc = EOK;
    8888        FILE *batch = fopen(argv[1], "r");
    8989        if (batch == NULL) {
     
    104104                                if (cur == fusr.line) {
    105105                                        /* skip empty line */
    106                                         rc = 0;
     106                                        rc = EOK;
    107107                                        free(cur);
    108108                                } else {
  • uspace/app/bdsh/cmds/builtins/cd/cd.c

    r8610c2c rd5c1051  
    8585int cmd_cd(char **argv, cliuser_t *usr)
    8686{
    87         int argc, rc = 0;
     87        int argc;
     88        int rc = EOK;
    8889
    8990        argc = cli_count_args(argv);
  • uspace/app/bdsh/cmds/modules/mkdir/mkdir.c

    r8610c2c rd5c1051  
    9494
    9595        int ret = 0;
     96        int rc;
    9697
    9798        if (!create_parents) {
    98                 ret = vfs_link_path(path, KIND_DIRECTORY, NULL);
    99                 if (ret != EOK) {
     99                rc = vfs_link_path(path, KIND_DIRECTORY, NULL);
     100                if (rc != EOK) {
    100101                        cli_error(CL_EFAIL, "%s: could not create %s (%s)",
    101                             cmdname, path, str_error(ret));
     102                            cmdname, path, str_error(rc));
    102103                        ret = 1;
    103104                }
     
    135136                        path[prev_off] = 0;
    136137
    137                         ret = vfs_link_path(path, KIND_DIRECTORY, NULL);
    138                         if (ret != EOK && ret != EEXIST) {
     138                        rc = vfs_link_path(path, KIND_DIRECTORY, NULL);
     139                        if (rc != EOK && rc != EEXIST) {
    139140                                cli_error(CL_EFAIL, "%s: could not create %s (%s)",
    140                                     cmdname, path, str_error(ret));
     141                                    cmdname, path, str_error(rc));
    141142                                ret = 1;
    142143                                goto leave;
     
    146147                }
    147148                /* Create the final directory. */
    148                 ret = vfs_link_path(path, KIND_DIRECTORY, NULL);
    149                 if (ret != EOK) {
     149                rc = vfs_link_path(path, KIND_DIRECTORY, NULL);
     150                if (rc != EOK) {
    150151                        cli_error(CL_EFAIL, "%s: could not create %s (%s)",
    151                             cmdname, path, str_error(ret));
     152                            cmdname, path, str_error(rc));
    152153                        ret = 1;
    153154                }
  • uspace/app/bdsh/cmds/modules/mkfile/mkfile.c

    r8610c2c rd5c1051  
    202202        free(buffer);
    203203
    204         if (vfs_put(fd) < 0)
     204        if (vfs_put(fd) != EOK)
    205205                goto error;
    206206
  • uspace/app/bdsh/cmds/modules/mount/mount.c

    r8610c2c rd5c1051  
    132132        const char *mopts = "";
    133133        const char *dev = "";
    134         int rc, c, opt_ind;
     134        int rc;
     135        int c, opt_ind;
    135136        unsigned int instance = 0;
    136137        bool instance_set = false;
  • uspace/app/bdsh/cmds/modules/rm/rm.c

    r8610c2c rd5c1051  
    209209        rc = vfs_unlink_path(path);
    210210        if (rc == EOK)
    211                 return EOK;
     211                return 0;
    212212
    213213        cli_error(CL_ENOTSUP, "Can not remove %s", path);
  • uspace/app/bdsh/exec.c

    r8610c2c rd5c1051  
    9898        task_exit_t texit;
    9999        char *tmp;
    100         int rc, retval, i;
     100        int rc;
     101        int retval, i;
    101102        int file_handles[3] = { -1, -1, -1 };
    102103        FILE *files[3];
  • uspace/app/bdsh/test/toktest.c

    r8610c2c rd5c1051  
    4747
    4848        int rc = tok_init(&tokenizer, input_buffer, tokens, MAX_TOKENS);
    49         PCUT_ASSERT_INT_EQUALS(EOK, rc);
     49        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    5050
    5151        size_t token_count;
    5252        rc = tok_tokenize(&tokenizer, &token_count);
    53         PCUT_ASSERT_INT_EQUALS(EOK, rc);
     53        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    5454
    5555
  • uspace/app/blkdump/blkdump.c

    r8610c2c rd5c1051  
    161161        printf("Device %s has %" PRIuOFF64 " blocks, %" PRIuOFF64 " bytes each\n", dev_path, dev_nblocks, (aoff64_t) block_size);
    162162
     163        int ret;
    163164        if (toc)
    164                 rc = print_toc();
     165                ret = print_toc();
    165166        else
    166                 rc = print_blocks(block_offset, block_count, block_size);
     167                ret = print_blocks(block_offset, block_count, block_size);
    167168
    168169        block_fini(service_id);
    169170
    170         return rc;
     171        return ret;
    171172}
    172173
  • uspace/app/date/date.c

    r8610c2c rd5c1051  
    5151main(int argc, char **argv)
    5252{
    53         int rc, c;
     53        int rc;
     54        int c;
    5455        category_id_t cat_id;
    5556        size_t        svc_cnt;
  • uspace/app/download/main.c

    r8610c2c rd5c1051  
    7474        http_t *http = NULL;
    7575        int rc;
     76        int ret;
    7677
    7778        if (argc < 2) {
     
    155156                }
    156157        } else {
    157                 rc = asprintf(&server_path, "%s?%s", path, uri->query);
    158                 if (rc < 0) {
     158                ret = asprintf(&server_path, "%s?%s", path, uri->query);
     159                if (ret < 0) {
    159160                        fprintf(stderr, "Failed allocating path\n");
    160161                        rc = ENOMEM;
  • uspace/app/edit/edit.c

    r8610c2c rd5c1051  
    761761        } while (!spt_equal(&bep, epos));
    762762
    763         if (fclose(f) != EOK)
     763        if (fclose(f) < 0)
    764764                return EIO;
    765765
  • uspace/app/fdisk/fdisk.c

    r8610c2c rd5c1051  
    210210                }
    211211
    212                 rc = asprintf(&dtext, "%s (%s)", svcname, scap);
    213                 if (rc < 0) {
     212                int ret = asprintf(&dtext, "%s (%s)", svcname, scap);
     213                if (ret < 0) {
    214214                        rc = ENOMEM;
    215215                        printf("Out of memory.\n");
     
    615615                                label = "(No name)";
    616616
    617                         rc = asprintf(&sdesc, "%s %s, %s, %s", label,
     617                        int ret = asprintf(&sdesc, "%s %s, %s, %s", label,
    618618                            scap, spkind, sfstype);
    619                         if (rc < 0) {
     619                        if (ret < 0) {
    620620                                rc = ENOMEM;
    621621                                goto error;
     
    623623
    624624                } else {
    625                         rc = asprintf(&sdesc, "%s, %s", scap, spkind);
    626                         if (rc < 0) {
     625                        int ret = asprintf(&sdesc, "%s, %s", scap, spkind);
     626                        if (ret < 0) {
    627627                                rc = ENOMEM;
    628628                                goto error;
  • uspace/app/gunzip/gunzip.c

    r8610c2c rd5c1051  
    5858        }
    5959
    60         rc = fseek(f, 0, SEEK_END);
    61         if (rc != 0) {
     60        if (fseek(f, 0, SEEK_END) < 0) {
    6261                printf("Error determining size of '%s'\n", argv[1]);
    6362                fclose(f);
     
    7271        }
    7372
    74         rc = fseek(f, 0, SEEK_SET);
    75         if (rc != 0) {
     73        if (fseek(f, 0, SEEK_SET) < 0) {
    7674                printf ("Error rewinding '%s'\n", argv[1]);
    7775                fclose(f);
  • uspace/app/mkexfat/mkexfat.c

    r8610c2c rd5c1051  
    351351{
    352352        uint32_t *ebs = calloc(cfg->sector_size, sizeof(uint8_t));
    353         int i, rc;
     353        int i;
     354        int rc;
    354355
    355356        if (!ebs)
     
    757758        char *dev_path;
    758759        service_id_t service_id;
    759         int rc, c, opt_ind;
     760        int rc;
     761        int c, opt_ind;
    760762        aoff64_t user_fs_size = 0;
    761763
  • uspace/app/mkmfs/mkmfs.c

    r8610c2c rd5c1051  
    109109int main (int argc, char **argv)
    110110{
    111         int rc, c, opt_ind;
     111        int rc;
     112        int c, opt_ind;
    112113        char *device_name;
    113114        size_t devblock_size;
  • uspace/app/ping/ping.c

    r8610c2c rd5c1051  
    290290        }
    291291       
    292         rc = asprintf(&sdest, "%s (%s)", host, adest);
    293         if (rc < 0) {
     292        if (asprintf(&sdest, "%s (%s)", host, adest) < 0) {
    294293                printf("Out of memory.\n");
    295294                goto error;
  • uspace/app/pkg/pkg.c

    r8610c2c rd5c1051  
    107107        char *fnunpack;
    108108        int rc;
     109        int ret;
    109110
    110111        if (argc != 3) {
     
    115116        pkg_name = argv[2];
    116117
    117         rc = asprintf(&src_uri, "http://ci.helenos.org/latest/" STRING(UARCH)
     118        ret = asprintf(&src_uri, "http://ci.helenos.org/latest/" STRING(UARCH)
    118119            "/%s-for-helenos-" STRING(UARCH) ".tar.gz",
    119120            pkg_name);
    120         if (rc < 0) {
     121        if (ret < 0) {
    121122                printf("Out of memory.\n");
    122123                return ENOMEM;
    123124        }
    124125
    125         rc = asprintf(&fname, "/tmp/%s-for-helenos-" STRING(UARCH)
     126        ret = asprintf(&fname, "/tmp/%s-for-helenos-" STRING(UARCH)
    126127            ".tar.gz", pkg_name);
    127         if (rc < 0) {
     128        if (ret < 0) {
    128129                printf("Out of memory.\n");
    129130                return ENOMEM;
    130131        }
    131132
    132         rc = asprintf(&fnunpack, "/tmp/%s-for-helenos-" STRING(UARCH) ".tar",
     133        ret = asprintf(&fnunpack, "/tmp/%s-for-helenos-" STRING(UARCH) ".tar",
    133134            pkg_name);
    134         if (rc < 0) {
     135        if (ret < 0) {
    135136                printf("Out of memory.\n");
    136137                return ENOMEM;
  • uspace/app/sbi/src/os/helenos.c

    r8610c2c rd5c1051  
    252252        task_wait_t twait;
    253253        task_exit_t texit;
    254         int rc, retval;
     254        int rc;
     255        int retval;
    255256
    256257        rc = task_spawnv(&tid, &twait, cmd[0], (char const * const *) cmd);
  • uspace/app/sysinst/sysinst.c

    r8610c2c rd5c1051  
    142142
    143143        /* XXX libfdisk should give us the service name */
    144         rc = asprintf(pdev, "%sp1", dev);
    145         if (rc < 0)
     144        if (asprintf(pdev, "%sp1", dev) < 0)
    146145                return ENOMEM;
    147146
  • uspace/app/taskdump/elf_core.c

    r8610c2c rd5c1051  
    307307                to_copy = min(area->size - total, BUFFER_SIZE);
    308308                rc = udebug_mem_read(sess, buffer, addr, to_copy);
    309                 if (rc < 0) {
     309                if (rc != EOK) {
    310310                        printf("Failed reading task memory.\n");
    311311                        return EIO;
  • uspace/app/taskdump/taskdump.c

    r8610c2c rd5c1051  
    9292
    9393        rc = connect_task(task_id);
    94         if (rc < 0) {
     94        if (rc != EOK) {
    9595                printf("Failed connecting to task %" PRIu64 ".\n", task_id);
    9696                return 1;
     
    105105
    106106        rc = threads_dump();
    107         if (rc < 0)
     107        if (rc != EOK)
    108108                printf("Failed dumping threads.\n");
    109109
    110110        rc = areas_dump();
    111         if (rc < 0)
     111        if (rc != EOK)
    112112                printf("Failed dumping address space areas.\n");
    113113
    114114        rc = fibrils_dump(app_symtab, sess);
    115         if (rc < 0)
     115        if (rc != EOK)
    116116                printf("Failed dumping fibrils.\n");
    117117
     
    141141       
    142142        int rc = udebug_begin(ksess);
    143         if (rc < 0) {
     143        if (rc != EOK) {
    144144                printf("udebug_begin() -> %s\n", str_error_name(rc));
    145145                return rc;
     
    223223        /* TODO: See why NULL does not work. */
    224224        rc = udebug_thread_read(sess, &dummy_buf, 0, &copied, &needed);
    225         if (rc < 0) {
     225        if (rc != EOK) {
    226226                printf("udebug_thread_read() -> %s\n", str_error_name(rc));
    227227                return rc;
     
    237237
    238238        rc = udebug_thread_read(sess, thash_buf, buf_size, &copied, &needed);
    239         if (rc < 0) {
     239        if (rc != EOK) {
    240240                printf("udebug_thread_read() -> %s\n", str_error_name(rc));
    241241                return rc;
     
    272272
    273273        rc = udebug_areas_read(sess, &dummy_buf, 0, &copied, &needed);
    274         if (rc < 0) {
     274        if (rc != EOK) {
    275275                printf("udebug_areas_read() -> %s\n", str_error_name(rc));
    276276                return rc;
     
    281281
    282282        rc = udebug_areas_read(sess, ainfo_buf, buf_size, &copied, &needed);
    283         if (rc < 0) {
     283        if (rc != EOK) {
    284284                printf("udebug_areas_read() -> %s\n", str_error_name(rc));
    285285                return rc;
     
    357357
    358358        rc = udebug_regs_read(sess, thash, &istate);
    359         if (rc < 0) {
     359        if (rc != EOK) {
    360360                printf("Failed reading registers: %s.\n", str_error_name(rc));
    361361                return EIO;
     
    386386
    387387        rc = udebug_mem_read(sess, &data, addr, sizeof(data));
    388         if (rc < 0) {
     388        if (rc != EOK) {
    389389                printf("Warning: udebug_mem_read() failed.\n");
    390390                return rc;
     
    400400        char *file_name;
    401401        int rc;
     402        int ret;
    402403
    403404        assert(app_name != NULL);
    404405        assert(app_symtab == NULL);
    405406
    406         rc = asprintf(&file_name, "/app/%s", app_name);
    407         if (rc < 0) {
     407        ret = asprintf(&file_name, "/app/%s", app_name);
     408        if (ret < 0) {
    408409                printf("Memory allocation failure.\n");
    409410                exit(1);
     
    419420        free(file_name);
    420421
    421         rc = asprintf(&file_name, "/srv/%s", app_name);
    422         if (rc < 0) {
     422        ret = asprintf(&file_name, "/srv/%s", app_name);
     423        if (ret < 0) {
    423424                printf("Memory allocation failure.\n");
    424425                exit(1);
     
    432433        }
    433434
    434         rc = asprintf(&file_name, "/drv/%s/%s", app_name, app_name);
    435         if (rc < 0) {
     435        ret = asprintf(&file_name, "/drv/%s/%s", app_name, app_name);
     436        if (ret < 0) {
    436437                printf("Memory allocation failure.\n");
    437438                exit(1);
     
    457458
    458459        rc = udebug_name_read(sess, &dummy_buf, 0, &copied, &needed);
    459         if (rc < 0)
     460        if (rc != EOK)
    460461                return NULL;
    461462
     
    463464        name = malloc(name_size + 1);
    464465        rc = udebug_name_read(sess, name, name_size, &copied, &needed);
    465         if (rc < 0) {
     466        if (rc != EOK) {
    466467                free(name);
    467468                return NULL;
     
    488489        size_t offs;
    489490        int rc;
     491        int ret;
    490492        char *str;
    491493
     
    497499
    498500        if (rc == EOK) {
    499                 rc = asprintf(&str, "%p (%s+%zu)", (void *) addr, name, offs);
     501                ret = asprintf(&str, "%p (%s+%zu)", (void *) addr, name, offs);
    500502        } else {
    501                 rc = asprintf(&str, "%p", (void *) addr);
    502         }
    503 
    504         if (rc < 0) {
     503                ret = asprintf(&str, "%p", (void *) addr);
     504        }
     505
     506        if (ret < 0) {
    505507                printf("Memory allocation error.\n");
    506508                exit(1);
  • uspace/app/tester/float/float1.c

    r8610c2c rd5c1051  
    2828 */
    2929
     30#include <errno.h>
    3031#include <stdio.h>
    3132#include <stdlib.h>
     
    7576        TPRINTF("Creating threads");
    7677        for (unsigned int i = 0; i < THREADS; i++) {
    77                 if (thread_create(e, NULL, "e", NULL) < 0) {
     78                if (thread_create(e, NULL, "e", NULL) != EOK) {
    7879                        TPRINTF("\nCould not create thread %u\n", i);
    7980                        break;
  • uspace/app/tester/thread/thread1.c

    r8610c2c rd5c1051  
    3232
    3333#include <atomic.h>
     34#include <errno.h>
    3435#include <thread.h>
    3536#include <stdio.h>
     
    6162        TPRINTF("Creating threads");
    6263        for (i = 0; i < THREADS; i++) {
    63                 if (thread_create(threadtest, NULL, "threadtest", NULL) < 0) {
     64                if (thread_create(threadtest, NULL, "threadtest", NULL) != EOK) {
    6465                        TPRINTF("\nCould not create thread %u\n", i);
    6566                        break;
  • uspace/app/trace/trace.c

    r8610c2c rd5c1051  
    162162       
    163163        int rc = udebug_begin(ksess);
    164         if (rc < 0) {
     164        if (rc != EOK) {
    165165                printf("udebug_begin() -> %s\n", str_error_name(rc));
    166166                return rc;
     
    168168       
    169169        rc = udebug_set_evmask(ksess, UDEBUG_EM_ALL);
    170         if (rc < 0) {
     170        if (rc != EOK) {
    171171                printf("udebug_set_evmask(0x%x) -> %s\n ", UDEBUG_EM_ALL, str_error_name(rc));
    172172                return rc;
     
    186186        rc = udebug_thread_read(sess, thread_hash_buf,
    187187                THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed);
    188         if (rc < 0) {
     188        if (rc != EOK) {
    189189                printf("udebug_thread_read() -> %s\n", str_error_name(rc));
    190190                return rc;
     
    325325        rc = udebug_mem_read(sess, &call, sc_args[0], sizeof(call));
    326326       
    327         if (rc >= 0)
     327        if (rc == EOK)
    328328                ipcp_call_in(&call, sc_rc);
    329329}
     
    338338        rc = udebug_args_read(sess, thread_hash, sc_args);
    339339
    340         if (rc < 0) {
     340        if (rc != EOK) {
    341341                printf("error\n");
    342342                return;
     
    368368//      printf("[%d] ", thread_id);
    369369
    370         if (rc < 0) {
     370        if (rc != EOK) {
    371371                printf("error\n");
    372372                return;
     
    445445                }
    446446
    447                 if (rc >= 0) {
     447                if (rc == EOK) {
    448448                        switch (ev_type) {
    449449                        case UDEBUG_EVENT_SYSCALL_B:
     
    603603
    604604        rc = get_thread_list();
    605         if (rc < 0) {
     605        if (rc != EOK) {
    606606                printf("Failed to get thread list (%s)\n", str_error(rc));
    607607                return;
     
    859859
    860860        rc = connect_task(task_id);
    861         if (rc < 0) {
     861        if (rc != EOK) {
    862862                printf("Failed connecting to task %" PRIu64 ".\n", task_id);
    863863                return 1;
  • uspace/app/wavplay/dplay.c

    r8610c2c rd5c1051  
    329329 * @param device The device.
    330330 * @param file The file.
    331  * @return Error code.
     331 * @return 0 on success, non-zero on failure.
    332332 */
    333333int dplay(const char *device, const char *file)
  • uspace/app/wavplay/drec.c

    r8610c2c rd5c1051  
    170170 * @param device The device.
    171171 * @param file The file.
    172  * @return Error code.
     172 * @return 0 on succes, non-zero on failure.
    173173 */
    174174int drecord(const char *device, const char *file)
  • uspace/app/websrv/websrv.c

    r8610c2c rd5c1051  
    259259                uri = "/index.html";
    260260       
    261         rc = asprintf(&fname, "%s%s", WEB_ROOT, uri);
    262         if (rc < 0) {
     261        if (asprintf(&fname, "%s%s", WEB_ROOT, uri) < 0) {
    263262                rc = ENOMEM;
    264263                goto out;
Note: See TracChangeset for help on using the changeset viewer.