Changeset b7fd2a0 in mainline for uspace/lib/c/generic/clipboard.c


Ignore:
Timestamp:
2018-01-13T03:10:29Z (6 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/lib/c/generic/clipboard.c

    r36f0738 rb7fd2a0  
    5959{
    6060        service_id_t sid;
    61         int rc;
     61        errno_t rc;
    6262       
    6363        fibril_mutex_lock(&clip_mutex);
     
    9898 *
    9999 */
    100 int clipboard_put_str(const char *str)
     100errno_t clipboard_put_str(const char *str)
    101101{
    102102        size_t size = str_size(str);
     
    104104        if (size == 0) {
    105105                async_exch_t *exch = clip_exchange_begin();
    106                 int rc = async_req_1_0(exch, CLIPBOARD_PUT_DATA,
     106                errno_t rc = async_req_1_0(exch, CLIPBOARD_PUT_DATA,
    107107                    CLIPBOARD_TAG_NONE);
    108108                clip_exchange_end(exch);
    109109               
    110                 return (int) rc;
     110                return (errno_t) rc;
    111111        } else {
    112112                async_exch_t *exch = clip_exchange_begin();
    113113                aid_t req = async_send_1(exch, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_DATA,
    114114                    NULL);
    115                 int rc = async_data_write_start(exch, (void *) str, size);
     115                errno_t rc = async_data_write_start(exch, (void *) str, size);
    116116                clip_exchange_end(exch);
    117117               
    118118                if (rc != EOK) {
    119                         int rc_orig;
     119                        errno_t rc_orig;
    120120                        async_wait_for(req, &rc_orig);
    121121                        if (rc_orig == EOK)
    122                                 return (int) rc;
     122                                return (errno_t) rc;
    123123                        else
    124                                 return (int) rc_orig;
     124                                return (errno_t) rc_orig;
    125125                }
    126126               
    127127                async_wait_for(req, &rc);
    128128               
    129                 return (int) rc;
     129                return (errno_t) rc;
    130130        }
    131131}
     
    140140 *
    141141 */
    142 int clipboard_get_str(char **str)
     142errno_t clipboard_get_str(char **str)
    143143{
    144144        /* Loop until clipboard read succesful */
     
    148148                sysarg_t size;
    149149                sysarg_t tag;
    150                 int rc = async_req_0_2(exch, CLIPBOARD_CONTENT, &size, &tag);
     150                errno_t rc = async_req_0_2(exch, CLIPBOARD_CONTENT, &size, &tag);
    151151               
    152152                clip_exchange_end(exch);
    153153               
    154154                if (rc != EOK)
    155                         return (int) rc;
     155                        return (errno_t) rc;
    156156               
    157157                char *sbuf;
     
    176176                        clip_exchange_end(exch);
    177177                       
    178                         if ((int) rc == EOVERFLOW) {
     178                        if ((errno_t) rc == EOVERFLOW) {
    179179                                /*
    180180                                 * The data in the clipboard has changed since
     
    185185                       
    186186                        if (rc != EOK) {
    187                                 int rc_orig;
     187                                errno_t rc_orig;
    188188                                async_wait_for(req, &rc_orig);
    189189                                if (rc_orig == EOK)
    190                                         return (int) rc;
     190                                        return (errno_t) rc;
    191191                                else
    192                                         return (int) rc_orig;
     192                                        return (errno_t) rc_orig;
    193193                        }
    194194                       
Note: See TracChangeset for help on using the changeset viewer.