Changeset bad8d41 in mainline


Ignore:
Timestamp:
2017-12-21T20:24:54Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Parents:
f04b5b3
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-21 18:24:59)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-21 20:24:54)
Message:

The "not-so-obvious" error handling tweaks.

Location:
uspace
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/cmp/cmp.c

    rf04b5b3 rbad8d41  
    101101                    memcmp(buffer[0], buffer[1], offset[0]) != 0) {
    102102                        printf("Return 1\n");
    103                         rc = 1;
     103                        rc = EBUSY;
    104104                        goto end;
    105105                }
  • uspace/app/bdsh/cmds/modules/cp/cp.c

    rf04b5b3 rbad8d41  
    266266
    267267                /* call copy_file and exit */
    268                 rc = (copy_file(src, dest_path, blen, vb) < 0);
     268                if (copy_file(src, dest_path, blen, vb) < 0) {
     269                        rc = EIO;
     270                }
    269271
    270272        } else if (src_type == TYPE_DIR) {
     
    434436        if (rc != EOK) {
    435437                printf("\nError copying %s: %s\n", src, str_error(rc));
    436                 return rc;
     438                return -1;
    437439        }
    438440
     
    442444        if (buff)
    443445                free(buff);
    444         return rc;
     446        if (rc != EOK) {
     447                return -1;
     448        } else {
     449                return 0;
     450        }
    445451}
    446452
     
    473479        int force = 0, interactive = 0;
    474480        int c, opt_ind;
    475         int64_t ret;
     481        int ret;
    476482
    477483        con = console_init(stdin, stdout);
  • uspace/app/bdsh/input.c

    rf04b5b3 rbad8d41  
    7373       
    7474        char *cmd[WORD_MAX];
    75         int rc = 0;
     75        int rc = EOK;
    7676        tokenizer_t tok;
    7777        unsigned int i, pipe_count, processed_pipes;
     
    8282        if (usr->line == NULL) {
    8383                free(tokens_buf);
    84                 return CL_EFAIL;
     84                return EINVAL;
    8585        }
    8686
     
    198198        }
    199199
    200         rc = run_command(cmd, usr, &new_iostate);
     200        if (run_command(cmd, usr, &new_iostate) == 0) {
     201                rc = EOK;
     202        } else {
     203                rc = EINVAL;
     204        }
    201205       
    202206finit_with_files:
  • uspace/app/fontviewer/fontviewer.c

    rf04b5b3 rbad8d41  
    149149        va_end(args);
    150150       
    151         if (ret <= 0)
    152                 return ret;
    153        
    154         drawctx_set_source(drawctx, source);
    155         drawctx_set_font(drawctx, font);
    156         drawctx_print(drawctx, str, x, y);
    157        
    158         free(str);
     151        if (ret >= 0) {
     152                drawctx_set_source(drawctx, source);
     153                drawctx_set_font(drawctx, font);
     154                drawctx_print(drawctx, str, x, y);
     155
     156                free(str);
     157        }
    159158       
    160159        return ret;
  • uspace/app/init/init.c

    rf04b5b3 rbad8d41  
    208208                    path, retval);
    209209       
    210         return retval;
     210        return retval == 0 ? EOK : EPARTY;
    211211}
    212212
  • uspace/app/pkg/pkg.c

    rf04b5b3 rbad8d41  
    9696        }
    9797
    98         return retval;
     98        return retval == 0 ? EOK : EPARTY;
    9999}
    100100
  • uspace/app/trace/ipcp.c

    rf04b5b3 rbad8d41  
    281281                        if (oper->rv_type != V_VOID) {
    282282                                putchar(' ');
    283                                 val_print(retval, oper->rv_type);
     283                                val_print((sysarg_t) retval, oper->rv_type);
    284284                        }
    285285                       
  • uspace/app/trace/trace.c

    rf04b5b3 rbad8d41  
    260260
    261261
    262 static void print_sc_retval(int retval, val_type_t val_type)
     262static void print_sc_retval(sysarg_t retval, val_type_t val_type)
    263263{
    264264        printf(" -> ");
     
    296296        IPC_SET_ARG5(call, 0);
    297297
    298         ipcp_call_out(phoneid, &call, sc_rc);
    299 }
    300 
    301 static void sc_ipc_call_async_slow(sysarg_t *sc_args, sysarg_t sc_rc)
     298        ipcp_call_out(phoneid, &call, 0);
     299}
     300
     301static void sc_ipc_call_async_slow(sysarg_t *sc_args, int sc_rc)
    302302{
    303303        ipc_call_t call;
    304304        int rc;
    305305
    306         if (sc_rc != (sysarg_t) EOK)
     306        if (sc_rc != EOK)
    307307                return;
    308308
     
    310310        rc = udebug_mem_read(sess, &call.args, sc_args[1], sizeof(call.args));
    311311
    312         if (rc >= 0) {
    313                 ipcp_call_out(sc_args[0], &call, sc_rc);
     312        if (rc == EOK) {
     313                ipcp_call_out(sc_args[0], &call, 0);
    314314        }
    315315}
     
    581581               
    582582                if (!console_get_event(console, &event))
    583                         return -1;
     583                        return EINVAL;
    584584               
    585585                if (event.type == CEV_KEY) {
  • uspace/drv/platform/msim/msim.c

    rf04b5b3 rbad8d41  
    156156        /* Nothing to do. */
    157157
    158         return true;
     158        return EOK;
    159159}
    160160
  • uspace/drv/platform/sun4v/sun4v.c

    rf04b5b3 rbad8d41  
    116116static int sun4v_enable_interrupt(ddf_fun_t *fun, int irq)
    117117{
    118         return true;
     118        return EOK;
    119119}
    120120
  • uspace/lib/c/include/io/klog.h

    rf04b5b3 rbad8d41  
    4949#define KLOG_PRINTF(lvl, fmt, ...) ({ \
    5050        char *_s; \
    51         int _c = asprintf(&_s, fmt, ##__VA_ARGS__); \
    52         if (_c >= 0) { \
    53                 _c = klog_write((lvl), _s, str_size(_s)); \
     51        int _rc = ENOMEM; \
     52        if (asprintf(&_s, fmt, ##__VA_ARGS__) >= 0) { \
     53                _rc = klog_write((lvl), _s, str_size(_s)); \
    5454                free(_s); \
    5555        }; \
    56         (_c >= 0); \
     56        (_rc != EOK); \
    5757})
    5858
  • uspace/lib/http/src/request.c

    rf04b5b3 rbad8d41  
    9696        ssize_t meth_size = http_encode_method(NULL, 0, req->method, req->path);
    9797        if (meth_size < 0)
    98                 return meth_size;
     98                return EINVAL;
    9999        size_t size = meth_size;
    100100       
     
    102102                ssize_t header_size = http_header_encode(header, NULL, 0);
    103103                if (header_size < 0)
    104                         return header_size;
     104                        return EINVAL;
    105105                size += header_size;
    106106        }
     
    116116        if (written < 0) {
    117117                free(buf);
    118                 return written;
     118                return EINVAL;
    119119        }
    120120        pos += written;
     
    125125                if (written < 0) {
    126126                        free(buf);
    127                         return written;
     127                        return EINVAL;
    128128                }
    129129                pos += written;
  • uspace/lib/usbdev/src/recognise.c

    rf04b5b3 rbad8d41  
    8888                char *str = NULL; \
    8989                int __rc = asprintf(&str, format, ##__VA_ARGS__); \
    90                 if (__rc > 0) { \
    91                         __rc = usb_add_match_id((match_ids), (score), str); \
    92                 } \
    93                 if (__rc != EOK) { \
    94                         free(str); \
    95                         return __rc; \
     90                if (__rc >= 0) { \
     91                        int __rc = usb_add_match_id((match_ids), (score), str); \
     92                        if (__rc != EOK) { \
     93                                free(str); \
     94                                return __rc; \
     95                        } \
     96                } else { \
     97                        return ENOMEM; \
    9698                } \
    9799        } while (0)
  • uspace/srv/devman/devtree.c

    rf04b5b3 rbad8d41  
    198198        dev_node_t *rdev = tree->root_node->child;
    199199        dev_add_ref(rdev);
    200         int rc = assign_driver(rdev, drivers_list, tree);
     200        bool rc = assign_driver(rdev, drivers_list, tree);
    201201        dev_del_ref(rdev);
    202202       
  • uspace/srv/fs/mfs/mfs.c

    rf04b5b3 rbad8d41  
    6868                else {
    6969                        printf(NAME " Unrecognized parameters");
    70                         rc = -1;
     70                        rc = EINVAL;
    7171                        goto err;
    7272                }
     
    7878        if (!vfs_sess) {
    7979                printf(NAME ": failed to connect to VFS\n");
    80                 return -1;
     80                rc = errno;
     81                goto err;
    8182        }
    8283
  • uspace/srv/fs/mfs/mfs_balloc.c

    rf04b5b3 rbad8d41  
    246246                        printf(NAME ": Error! Trying to free beyond the "
    247247                            "bitmap max size\n");
    248                         return -1;
     248                        return EIO;
    249249                }
    250250        } else {
     
    254254                        printf(NAME ": Error! Trying to free beyond the "
    255255                            "bitmap max size\n");
    256                         return -1;
     256                        return EIO;
    257257                }
    258258        }
     
    303303        unsigned *search, i, start_block;
    304304        unsigned bits_per_block;
    305         int r, freebit;
     305        int r;
     306        int freebit;
    306307
    307308        sbi = inst->sbi;
  • uspace/srv/hid/input/ctl/stty.c

    rf04b5b3 rbad8d41  
    243243
    244244        gsp_init(&sp);
    245         return gsp_insert_defs(&sp, seq_defs);
     245        if (gsp_insert_defs(&sp, seq_defs) < 0) {
     246                return EINVAL;
     247        }
     248        return EOK;
    246249}
    247250
  • uspace/srv/hid/rfb/rfb.c

    rf04b5b3 rbad8d41  
    435435}
    436436
    437 static size_t rfb_tile_encode_solid(rfb_t *rfb, cpixel_ctx_t *cpixel,
     437static int rfb_tile_encode_solid(rfb_t *rfb, cpixel_ctx_t *cpixel,
    438438    rfb_rectangle_t *tile, void *buf, size_t *size)
    439439{
  • uspace/srv/loader/main.c

    rf04b5b3 rbad8d41  
    300300        pcb.inbox_entries = inbox_entries;
    301301       
    302         async_answer_0(rid, rc);
     302        async_answer_0(rid, EOK);
    303303        return 0;
    304304}
  • uspace/srv/volsrv/mkfs.c

    rf04b5b3 rbad8d41  
    9898        }
    9999
    100         return retval;
     100        return retval == 0 ? EOK : EPARTY;
    101101}
    102102
Note: See TracChangeset for help on using the changeset viewer.