Changeset b7fd2a0 in mainline for uspace/lib/c/include/io


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/c/include/io
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/io/chardev.h

    r36f0738 rb7fd2a0  
    4141} chardev_t;
    4242
    43 extern int chardev_open(async_sess_t *, chardev_t **);
     43extern errno_t chardev_open(async_sess_t *, chardev_t **);
    4444extern void chardev_close(chardev_t *);
    45 extern int chardev_read(chardev_t *, void *, size_t, size_t *);
    46 extern int chardev_write(chardev_t *, const void *, size_t, size_t *);
     45extern errno_t chardev_read(chardev_t *, void *, size_t, size_t *);
     46extern errno_t chardev_write(chardev_t *, const void *, size_t, size_t *);
    4747
    4848#endif
  • uspace/lib/c/include/io/chardev_srv.h

    r36f0738 rb7fd2a0  
    5757
    5858struct chardev_ops {
    59         int (*open)(chardev_srvs_t *, chardev_srv_t *);
    60         int (*close)(chardev_srv_t *);
    61         int (*read)(chardev_srv_t *, void *, size_t, size_t *);
    62         int (*write)(chardev_srv_t *, const void *, size_t, size_t *);
     59        errno_t (*open)(chardev_srvs_t *, chardev_srv_t *);
     60        errno_t (*close)(chardev_srv_t *);
     61        errno_t (*read)(chardev_srv_t *, void *, size_t, size_t *);
     62        errno_t (*write)(chardev_srv_t *, const void *, size_t, size_t *);
    6363        void (*def_handler)(chardev_srv_t *, ipc_callid_t, ipc_call_t *);
    6464};
     
    6666extern void chardev_srvs_init(chardev_srvs_t *);
    6767
    68 extern int chardev_conn(ipc_callid_t, ipc_call_t *, chardev_srvs_t *);
     68extern errno_t chardev_conn(ipc_callid_t, ipc_call_t *, chardev_srvs_t *);
    6969
    7070#endif
  • uspace/lib/c/include/io/con_srv.h

    r36f0738 rb7fd2a0  
    6767
    6868struct con_ops {
    69         int (*open)(con_srvs_t *, con_srv_t *);
    70         int (*close)(con_srv_t *);
    71         int (*read)(con_srv_t *, void *, size_t, size_t *);
    72         int (*write)(con_srv_t *, void *, size_t, size_t *);
     69        errno_t (*open)(con_srvs_t *, con_srv_t *);
     70        errno_t (*close)(con_srv_t *);
     71        errno_t (*read)(con_srv_t *, void *, size_t, size_t *);
     72        errno_t (*write)(con_srv_t *, void *, size_t, size_t *);
    7373        void (*sync)(con_srv_t *);
    7474        void (*clear)(con_srv_t *);
    7575        void (*set_pos)(con_srv_t *, sysarg_t col, sysarg_t row);
    76         int (*get_pos)(con_srv_t *, sysarg_t *, sysarg_t *);
    77         int (*get_size)(con_srv_t *, sysarg_t *, sysarg_t *);
    78         int (*get_color_cap)(con_srv_t *, console_caps_t *);
     76        errno_t (*get_pos)(con_srv_t *, sysarg_t *, sysarg_t *);
     77        errno_t (*get_size)(con_srv_t *, sysarg_t *, sysarg_t *);
     78        errno_t (*get_color_cap)(con_srv_t *, console_caps_t *);
    7979        void (*set_style)(con_srv_t *, console_style_t);
    8080        void (*set_color)(con_srv_t *, console_color_t, console_color_t,
     
    8282        void (*set_rgb_color)(con_srv_t *, pixel_t, pixel_t);
    8383        void (*set_cursor_visibility)(con_srv_t *, bool);
    84         int (*get_event)(con_srv_t *, cons_event_t *);
     84        errno_t (*get_event)(con_srv_t *, cons_event_t *);
    8585};
    8686
    8787extern void con_srvs_init(con_srvs_t *);
    8888
    89 extern int con_conn(ipc_callid_t, ipc_call_t *, con_srvs_t *);
     89extern errno_t con_conn(ipc_callid_t, ipc_call_t *, con_srvs_t *);
    9090
    9191#endif
  • uspace/lib/c/include/io/console.h

    r36f0738 rb7fd2a0  
    7373extern void console_clear(console_ctrl_t *);
    7474
    75 extern int console_get_size(console_ctrl_t *, sysarg_t *, sysarg_t *);
    76 extern int console_get_pos(console_ctrl_t *, sysarg_t *, sysarg_t *);
     75extern errno_t console_get_size(console_ctrl_t *, sysarg_t *, sysarg_t *);
     76extern errno_t console_get_pos(console_ctrl_t *, sysarg_t *, sysarg_t *);
    7777extern void console_set_pos(console_ctrl_t *, sysarg_t, sysarg_t);
    7878
     
    8282
    8383extern void console_cursor_visibility(console_ctrl_t *, bool);
    84 extern int console_get_color_cap(console_ctrl_t *, sysarg_t *);
     84extern errno_t console_get_color_cap(console_ctrl_t *, sysarg_t *);
    8585extern bool console_get_event(console_ctrl_t *, cons_event_t *);
    8686extern bool console_get_event_timeout(console_ctrl_t *, cons_event_t *,
  • uspace/lib/c/include/io/input.h

    r36f0738 rb7fd2a0  
    4848
    4949typedef struct input_ev_ops {
    50         int (*active)(input_t *);
    51         int (*deactive)(input_t *);
    52         int (*key)(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t);
    53         int (*move)(input_t *, int, int);
    54         int (*abs_move)(input_t *, unsigned, unsigned, unsigned, unsigned);
    55         int (*button)(input_t *, int, int);
     50        errno_t (*active)(input_t *);
     51        errno_t (*deactive)(input_t *);
     52        errno_t (*key)(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t);
     53        errno_t (*move)(input_t *, int, int);
     54        errno_t (*abs_move)(input_t *, unsigned, unsigned, unsigned, unsigned);
     55        errno_t (*button)(input_t *, int, int);
    5656} input_ev_ops_t;
    5757
    58 extern int input_open(async_sess_t *, input_ev_ops_t *, void *, input_t **);
     58extern errno_t input_open(async_sess_t *, input_ev_ops_t *, void *, input_t **);
    5959extern void input_close(input_t *);
    60 extern int input_activate(input_t *);
     60extern errno_t input_activate(input_t *);
    6161
    6262#endif
  • uspace/lib/c/include/io/kio.h

    r36f0738 rb7fd2a0  
    4040#include <io/verify.h>
    4141
    42 extern int kio_write(const void *, size_t, size_t *);
     42extern errno_t kio_write(const void *, size_t, size_t *);
    4343extern void kio_update(void);
    4444extern void kio_command(const void *, size_t);
  • uspace/lib/c/include/io/klog.h

    r36f0738 rb7fd2a0  
    4444#include <abi/log.h>
    4545
    46 extern int klog_write(log_level_t, const void *, size_t);
    47 extern int klog_read(void *, size_t, size_t *);
     46extern errno_t klog_write(log_level_t, const void *, size_t);
     47extern errno_t klog_read(void *, size_t, size_t *);
    4848
    4949#define KLOG_PRINTF(lvl, fmt, ...) ({ \
    5050        char *_s; \
    51         int _rc = ENOMEM; \
     51        errno_t _rc = ENOMEM; \
    5252        if (asprintf(&_s, fmt, ##__VA_ARGS__) >= 0) { \
    5353                _rc = klog_write((lvl), _s, str_size(_s)); \
  • uspace/lib/c/include/io/log.h

    r36f0738 rb7fd2a0  
    5454
    5555extern const char *log_level_str(log_level_t);
    56 extern int log_level_from_str(const char *, log_level_t *);
     56extern errno_t log_level_from_str(const char *, log_level_t *);
    5757
    58 extern int log_init(const char *);
     58extern errno_t log_init(const char *);
    5959extern log_t log_create(const char *, log_t);
    6060
  • uspace/lib/c/include/io/logctl.h

    r36f0738 rb7fd2a0  
    3636#include <io/log.h>
    3737
    38 extern int logctl_set_default_level(log_level_t);
    39 extern int logctl_set_log_level(const char *, log_level_t);
    40 extern int logctl_set_root(void);
     38extern errno_t logctl_set_default_level(log_level_t);
     39extern errno_t logctl_set_log_level(const char *, log_level_t);
     40extern errno_t logctl_set_root(void);
    4141
    4242#endif
  • uspace/lib/c/include/io/output.h

    r36f0738 rb7fd2a0  
    4040#include <io/console.h>
    4141
    42 extern int output_yield(async_sess_t *);
    43 extern int output_claim(async_sess_t *);
    44 extern int output_get_dimensions(async_sess_t *, sysarg_t *, sysarg_t *);
    45 extern int output_get_caps(async_sess_t *, console_caps_t *);
     42extern errno_t output_yield(async_sess_t *);
     43extern errno_t output_claim(async_sess_t *);
     44extern errno_t output_get_dimensions(async_sess_t *, sysarg_t *, sysarg_t *);
     45extern errno_t output_get_caps(async_sess_t *, console_caps_t *);
    4646
    4747extern frontbuf_handle_t output_frontbuf_create(async_sess_t *, chargrid_t *);
    4848
    49 extern int output_cursor_update(async_sess_t *, frontbuf_handle_t);
    50 extern int output_set_style(async_sess_t *, console_style_t);
     49extern errno_t output_cursor_update(async_sess_t *, frontbuf_handle_t);
     50extern errno_t output_set_style(async_sess_t *, console_style_t);
    5151
    52 extern int output_update(async_sess_t *, frontbuf_handle_t);
    53 extern int output_damage(async_sess_t *, frontbuf_handle_t,
     52extern errno_t output_update(async_sess_t *, frontbuf_handle_t);
     53extern errno_t output_damage(async_sess_t *, frontbuf_handle_t,
    5454    sysarg_t, sysarg_t, sysarg_t, sysarg_t);
    5555
  • uspace/lib/c/include/io/serial.h

    r36f0738 rb7fd2a0  
    4343} serial_t;
    4444
    45 extern int serial_open(async_sess_t *, serial_t **);
     45extern errno_t serial_open(async_sess_t *, serial_t **);
    4646extern void serial_close(serial_t *);
    47 extern int serial_set_comm_props(serial_t *, unsigned, serial_parity_t,
     47extern errno_t serial_set_comm_props(serial_t *, unsigned, serial_parity_t,
    4848    unsigned, unsigned);
    49 extern int serial_get_comm_props(serial_t *, unsigned *, serial_parity_t *,
     49extern errno_t serial_get_comm_props(serial_t *, unsigned *, serial_parity_t *,
    5050    unsigned *, unsigned *);
    5151
  • uspace/lib/c/include/io/table.h

    r36f0738 rb7fd2a0  
    8383        bool header_row;
    8484        /** Encountered error while writing to table */
    85         int error;
     85        errno_t error;
    8686        /** Table rows */
    8787        list_t rows; /* of table_row_t */
     
    9898} table_t;
    9999
    100 extern int table_create(table_t **);
     100extern errno_t table_create(table_t **);
    101101extern void table_destroy(table_t *);
    102 extern int table_print_out(table_t *, FILE *);
     102extern errno_t table_print_out(table_t *, FILE *);
    103103extern void table_header_row(table_t *);
    104 extern int table_printf(table_t *, const char *, ...);
    105 extern int table_get_error(table_t *);
     104extern errno_t table_printf(table_t *, const char *, ...);
     105extern errno_t table_get_error(table_t *);
    106106extern void table_set_margin_left(table_t *, size_t);
    107107
  • uspace/lib/c/include/io/visualizer.h

    r36f0738 rb7fd2a0  
    3939#include <io/mode.h>
    4040
    41 extern int visualizer_claim(async_sess_t *, sysarg_t);
    42 extern int visualizer_yield(async_sess_t *);
     41extern errno_t visualizer_claim(async_sess_t *, sysarg_t);
     42extern errno_t visualizer_yield(async_sess_t *);
    4343
    44 extern int visualizer_enumerate_modes(async_sess_t *, vslmode_t *, sysarg_t);
    45 extern int visualizer_get_default_mode(async_sess_t *, vslmode_t *);
    46 extern int visualizer_get_current_mode(async_sess_t *, vslmode_t *);
    47 extern int visualizer_get_mode(async_sess_t *, vslmode_t *, sysarg_t);
    48 extern int visualizer_set_mode(async_sess_t *, sysarg_t, sysarg_t, void *);
     44extern errno_t visualizer_enumerate_modes(async_sess_t *, vslmode_t *, sysarg_t);
     45extern errno_t visualizer_get_default_mode(async_sess_t *, vslmode_t *);
     46extern errno_t visualizer_get_current_mode(async_sess_t *, vslmode_t *);
     47extern errno_t visualizer_get_mode(async_sess_t *, vslmode_t *, sysarg_t);
     48extern errno_t visualizer_set_mode(async_sess_t *, sysarg_t, sysarg_t, void *);
    4949
    50 extern int visualizer_update_damaged_region(async_sess_t *,
     50extern errno_t visualizer_update_damaged_region(async_sess_t *,
    5151    sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
    5252
    53 extern int visualizer_suspend(async_sess_t *);
    54 extern int visualizer_wakeup(async_sess_t *);
     53extern errno_t visualizer_suspend(async_sess_t *);
     54extern errno_t visualizer_wakeup(async_sess_t *);
    5555
    5656#endif
  • uspace/lib/c/include/io/window.h

    r36f0738 rb7fd2a0  
    113113} window_event_t;
    114114
    115 extern int win_register(async_sess_t *, window_flags_t, service_id_t *,
     115extern errno_t win_register(async_sess_t *, window_flags_t, service_id_t *,
    116116    service_id_t *);
    117117
    118 extern int win_get_event(async_sess_t *, window_event_t *);
     118extern errno_t win_get_event(async_sess_t *, window_event_t *);
    119119
    120 extern int win_damage(async_sess_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
    121 extern int win_grab(async_sess_t *, sysarg_t, sysarg_t);
    122 extern int win_resize(async_sess_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     120extern errno_t win_damage(async_sess_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
     121extern errno_t win_grab(async_sess_t *, sysarg_t, sysarg_t);
     122extern errno_t win_resize(async_sess_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
    123123    window_placement_flags_t, void *);
    124 extern int win_close(async_sess_t *);
    125 extern int win_close_request(async_sess_t *);
     124extern errno_t win_close(async_sess_t *);
     125extern errno_t win_close_request(async_sess_t *);
    126126
    127127#endif
Note: See TracChangeset for help on using the changeset viewer.