Changeset 46577995 in mainline for uspace/app/edit


Ignore:
Timestamp:
2018-01-04T20:50:52Z (8 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
e211ea04
Parents:
facacc71
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-04 20:47:53)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-04 20:50:52)
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.

After this commit, HelenOS is free of code that mixes error codes with non-error
values on the assumption that error codes are negative.

Location:
uspace/app/edit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/edit/edit.c

    rfacacc71 r46577995  
    132132static void pos_handle(pos_event_t *ev);
    133133
    134 static int file_save(char const *fname);
     134static errno_t file_save(char const *fname);
    135135static void file_save_as(void);
    136 static int file_insert(char *fname);
    137 static int file_save_range(char const *fname, spt_t const *spos,
     136static errno_t file_insert(char *fname);
     137static errno_t file_save_range(char const *fname, spt_t const *spos,
    138138    spt_t const *epos);
    139139static char *range_get_str(spt_t const *spos, spt_t const *epos);
     
    191191        cons_event_t ev;
    192192        bool new_file;
    193         int rc;
     193        errno_t rc;
    194194
    195195        con = console_init(stdin, stdout);
     
    578578
    579579/** Save the document. */
    580 static int file_save(char const *fname)
     580static errno_t file_save(char const *fname)
    581581{
    582582        spt_t sp, ep;
    583         int rc;
     583        errno_t rc;
    584584
    585585        status_display("Saving...");
     
    589589        rc = file_save_range(fname, &sp, &ep);
    590590
    591         switch (rc) {
    592         case EINVAL:
     591        switch ((case_errno_t) rc) {
     592        case (case_errno_t) EINVAL:
    593593                status_display("Error opening file!");
    594594                break;
    595         case EIO:
     595        case (case_errno_t) EIO:
    596596                status_display("Error writing data!");
    597597                break;
     
    616616        }
    617617
    618         int rc = file_save(fname);
     618        errno_t rc = file_save(fname);
    619619        if (rc != EOK)
    620620                return;
     
    697697 * of the caret.
    698698 */
    699 static int file_insert(char *fname)
     699static errno_t file_insert(char *fname)
    700700{
    701701        FILE *f;
     
    735735
    736736/** Save a range of text into a file. */
    737 static int file_save_range(char const *fname, spt_t const *spos,
     737static errno_t file_save_range(char const *fname, spt_t const *spos,
    738738    spt_t const *epos)
    739739{
     
    12831283
    12841284/* Search operations */
    1285 static int search_spt_producer(void *data, wchar_t *ret)
     1285static errno_t search_spt_producer(void *data, wchar_t *ret)
    12861286{
    12871287        assert(data != NULL);
     
    12921292}
    12931293
    1294 static int search_spt_reverse_producer(void *data, wchar_t *ret)
     1294static errno_t search_spt_reverse_producer(void *data, wchar_t *ret)
    12951295{
    12961296        assert(data != NULL);
     
    13011301}
    13021302
    1303 static int search_spt_mark(void *data, void **mark)
     1303static errno_t search_spt_mark(void *data, void **mark)
    13041304{
    13051305        assert(data != NULL);
     
    13971397       
    13981398        match_t match;
    1399         int rc = search_next_match(search, &match);
     1399        errno_t rc = search_next_match(search, &match);
    14001400        if (rc != EOK) {
    14011401                status_display("Failed searching.");
     
    15151515        size_t off;
    15161516        wchar_t c;
    1517         int rc;
     1517        errno_t rc;
    15181518
    15191519        rc = clipboard_get_str(&str);
  • uspace/app/edit/search.c

    rfacacc71 r46577995  
    105105}
    106106
    107 int search_next_match(search_t *s, match_t *match)
     107errno_t search_next_match(search_t *s, match_t *match)
    108108{
    109109        search_equals_fn eq = s->ops.equals;
    110110       
    111111        wchar_t cur_char;
    112         int rc = EOK;
     112        errno_t rc = EOK;
    113113        while ((rc = s->ops.producer(s->client_data, &cur_char)) == EOK && cur_char > 0) {
    114114                /* Deal with mismatches */
  • uspace/app/edit/search.h

    rfacacc71 r46577995  
    4343typedef struct search search_t;
    4444typedef bool (*search_equals_fn)(const wchar_t, const wchar_t);
    45 typedef int (*search_producer_fn)(void *, wchar_t *);
    46 typedef int (*search_mark_fn)(void *, void **);
     45typedef errno_t (*search_producer_fn)(void *, wchar_t *);
     46typedef errno_t (*search_mark_fn)(void *, void **);
    4747typedef void (*search_mark_free_fn)(void *);
    4848
     
    6161extern bool char_exact_equals(const wchar_t, const wchar_t);
    6262extern search_t *search_init(const char *, void *, search_ops_t, bool);
    63 extern int search_next_match(search_t *, match_t *);
     63extern errno_t search_next_match(search_t *, match_t *);
    6464extern void search_fini(search_t *);
    6565
  • uspace/app/edit/sheet.c

    rfacacc71 r46577995  
    6767
    6868/** Initialize an empty sheet. */
    69 int sheet_create(sheet_t **rsh)
     69errno_t sheet_create(sheet_t **rsh)
    7070{
    7171        sheet_t *sh;
     
    101101 *              and vice versa.
    102102 */
    103 int sheet_insert(sheet_t *sh, spt_t *pos, enum dir_spec dir, char *str)
     103errno_t sheet_insert(sheet_t *sh, spt_t *pos, enum dir_spec dir, char *str)
    104104{
    105105        char *ipp;
     
    147147 * @return      EOK on success or an error code.
    148148 **/
    149 int sheet_delete(sheet_t *sh, spt_t *spos, spt_t *epos)
     149errno_t sheet_delete(sheet_t *sh, spt_t *spos, spt_t *epos)
    150150{
    151151        char *spp;
  • uspace/app/edit/sheet.h

    rfacacc71 r46577995  
    9090} tag_t;
    9191
    92 extern int sheet_create(sheet_t **);
    93 extern int sheet_insert(sheet_t *, spt_t *, enum dir_spec, char *);
    94 extern int sheet_delete(sheet_t *, spt_t *, spt_t *);
     92extern errno_t sheet_create(sheet_t **);
     93extern errno_t sheet_insert(sheet_t *, spt_t *, enum dir_spec, char *);
     94extern errno_t sheet_delete(sheet_t *, spt_t *, spt_t *);
    9595extern void sheet_copy_out(sheet_t *, spt_t const *, spt_t const *, char *,
    9696    size_t, spt_t *);
Note: See TracChangeset for help on using the changeset viewer.