Changeset b7fd2a0 in mainline for uspace/drv/hid/ps2mouse/ps2mouse.c


Ignore:
Timestamp:
2018-01-13T03:10:29Z (7 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/drv/hid/ps2mouse/ps2mouse.c

    r36f0738 rb7fd2a0  
    7777        uint8_t data = 0; \
    7878        size_t nread; \
    79         const int rc = chardev_read((mouse)->chardev, &data, 1, &nread); \
     79        const errno_t rc = chardev_read((mouse)->chardev, &data, 1, &nread); \
    8080        if (rc != EOK) { \
    8181                ddf_msg(LVL_ERROR, "Failed reading byte: %s", str_error_name(rc));\
     
    9494        uint8_t data = (value); \
    9595        size_t nwr; \
    96         const int rc = chardev_write((mouse)->chardev, &data, 1, &nwr); \
     96        const errno_t rc = chardev_write((mouse)->chardev, &data, 1, &nwr); \
    9797        if (rc != EOK) { \
    9898                ddf_msg(LVL_ERROR, "Failed writing byte: %s", str_error_name(rc)); \
     
    101101} while (0)
    102102
    103 static int polling_ps2(void *);
    104 static int polling_intellimouse(void *);
    105 static int probe_intellimouse(ps2_mouse_t *, bool);
     103static errno_t polling_ps2(void *);
     104static errno_t polling_intellimouse(void *);
     105static errno_t probe_intellimouse(ps2_mouse_t *, bool);
    106106static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
    107107
     
    120120 * @return EOK on success or non-zero error code
    121121 */
    122 int ps2_mouse_init(ps2_mouse_t *mouse, ddf_dev_t *dev)
     122errno_t ps2_mouse_init(ps2_mouse_t *mouse, ddf_dev_t *dev)
    123123{
    124124        async_sess_t *parent_sess;
    125125        bool bound = false;
    126         int rc;
     126        errno_t rc;
    127127
    128128        mouse->client_sess = NULL;
     
    165165
    166166        /* Probe IntelliMouse extensions. */
    167         int (*polling_f)(void*) = polling_ps2;
     167        errno_t (*polling_f)(void*) = polling_ps2;
    168168        if (probe_intellimouse(mouse, false) == EOK) {
    169169                ddf_msg(LVL_NOTE, "Enabled IntelliMouse extensions");
     
    223223 * @return EOK on success or non-zero error code
    224224 */
    225 static int ps2_mouse_read_packet(ps2_mouse_t *mouse, void *pbuf, size_t psize)
    226 {
    227         int rc;
     225static errno_t ps2_mouse_read_packet(ps2_mouse_t *mouse, void *pbuf, size_t psize)
     226{
     227        errno_t rc;
    228228        size_t pos;
    229229        size_t nread;
     
    248248 * @return Never.
    249249 */
    250 int polling_ps2(void *arg)
     250errno_t polling_ps2(void *arg)
    251251{
    252252        ps2_mouse_t *mouse = (ps2_mouse_t *) arg;
    253         int rc;
     253        errno_t rc;
    254254
    255255        bool buttons[PS2_BUTTON_COUNT] = {};
     
    300300 * @return Never.
    301301 */
    302 static int polling_intellimouse(void *arg)
     302static errno_t polling_intellimouse(void *arg)
    303303{
    304304        ps2_mouse_t *mouse = (ps2_mouse_t *) arg;
    305         int rc;
     305        errno_t rc;
    306306
    307307        bool buttons[INTELLIMOUSE_BUTTON_COUNT] = {};
     
    373373 * See http://www.computer-engineering.org/ps2mouse/ for details.
    374374 */
    375 static int probe_intellimouse(ps2_mouse_t *mouse, bool buttons)
     375static errno_t probe_intellimouse(ps2_mouse_t *mouse, bool buttons)
    376376{
    377377        MOUSE_WRITE_BYTE(mouse, PS2_MOUSE_SET_SAMPLE_RATE);
Note: See TracChangeset for help on using the changeset viewer.