Changeset b7fd2a0 in mainline for kernel/generic/src/log/log.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
  • kernel/generic/src/log/log.c

    r36f0738 rb7fd2a0  
    221221               
    222222                size_t buffer_offset = 0;
    223                 int rc = chr_encode(wstr[chars], buffer, &buffer_offset, 16);
     223                errno_t rc = chr_encode(wstr[chars], buffer, &buffer_offset, 16);
    224224                if (rc != EOK) {
    225225                        return EOF;
     
    293293 *
    294294 */
    295 sysarg_t sys_klog(sysarg_t operation, void *buf, size_t size,
     295sys_errno_t sys_klog(sysarg_t operation, void *buf, size_t size,
    296296    sysarg_t level, size_t *uspace_nread)
    297297{
    298298        char *data;
    299         int rc;
     299        errno_t rc;
    300300       
    301301        if (size > PAGE_SIZE)
    302                 return (sysarg_t) ELIMIT;
     302                return (sys_errno_t) ELIMIT;
    303303       
    304304        switch (operation) {
     
    306306                        data = (char *) malloc(size + 1, 0);
    307307                        if (!data)
    308                                 return (sysarg_t) ENOMEM;
     308                                return (sys_errno_t) ENOMEM;
    309309                       
    310310                        rc = copy_from_uspace(data, buf, size);
    311311                        if (rc) {
    312312                                free(data);
    313                                 return (sysarg_t) rc;
     313                                return (sys_errno_t) rc;
    314314                        }
    315315                        data[size] = 0;
     
    325325                        data = (char *) malloc(size, 0);
    326326                        if (!data)
    327                                 return (sysarg_t) ENOMEM;
     327                                return (sys_errno_t) ENOMEM;
    328328                       
    329329                        size_t entry_len = 0;
     
    366366                        if (rc != EOK) {
    367367                                free(data);
    368                                 return (sysarg_t) rc;
     368                                return (sys_errno_t) rc;
    369369                        }
    370370                       
     
    374374                       
    375375                        if (rc != EOK)
    376                                 return (sysarg_t) rc;
     376                                return (sys_errno_t) rc;
    377377                       
    378378                        return copy_to_uspace(uspace_nread, &copied, sizeof(copied));
    379379                        return EOK;
    380380                default:
    381                         return (sysarg_t) ENOTSUP;
     381                        return (sys_errno_t) ENOTSUP;
    382382        }
    383383}
Note: See TracChangeset for help on using the changeset viewer.