Changeset b7fd2a0 in mainline for kernel/generic/src/proc


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.

Location:
kernel/generic/src/proc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/program.c

    r36f0738 rb7fd2a0  
    6969 *
    7070 */
    71 int program_create(as_t *as, uintptr_t entry_addr, char *name, program_t *prg)
     71errno_t program_create(as_t *as, uintptr_t entry_addr, char *name, program_t *prg)
    7272{
    7373        prg->loader_status = EE_OK;
     
    137137 *
    138138 */
    139 int program_create_from_image(void *image_addr, char *name, program_t *prg)
     139errno_t program_create_from_image(void *image_addr, char *name, program_t *prg)
    140140{
    141141        as_t *as = as_create(0);
     
    174174 *
    175175 */
    176 int program_create_loader(program_t *prg, char *name)
     176errno_t program_create_loader(program_t *prg, char *name)
    177177{
    178178        as_t *as = as_create(0);
     
    225225 *
    226226 */
    227 sysarg_t sys_program_spawn_loader(char *uspace_name, size_t name_len)
     227sys_errno_t sys_program_spawn_loader(char *uspace_name, size_t name_len)
    228228{
    229229        /* Cap length of name and copy it from userspace. */
     
    232232       
    233233        char namebuf[TASK_NAME_BUFLEN];
    234         int rc = copy_from_uspace(namebuf, uspace_name, name_len);
     234        errno_t rc = copy_from_uspace(namebuf, uspace_name, name_len);
    235235        if (rc != 0)
    236                 return (sysarg_t) rc;
     236                return (sys_errno_t) rc;
    237237       
    238238        namebuf[name_len] = 0;
  • kernel/generic/src/proc/task.c

    r36f0738 rb7fd2a0  
    8383/* Forward declarations. */
    8484static void task_kill_internal(task_t *);
    85 static int tsk_constructor(void *, unsigned int);
     85static errno_t tsk_constructor(void *, unsigned int);
    8686static size_t tsk_destructor(void *obj);
    8787
     
    158158}
    159159
    160 int tsk_constructor(void *obj, unsigned int kmflags)
     160errno_t tsk_constructor(void *obj, unsigned int kmflags)
    161161{
    162162        task_t *task = (task_t *) obj;
    163163
    164         int rc = caps_task_alloc(task);
     164        errno_t rc = caps_task_alloc(task);
    165165        if (rc != EOK)
    166166                return rc;
     
    246246            (container_check(ipc_phone_0->task->container, task->container))) {
    247247                cap_handle_t phone_handle;
    248                 int rc = phone_alloc(task, &phone_handle);
     248                errno_t rc = phone_alloc(task, &phone_handle);
    249249                if (rc != EOK) {
    250250                        task->as = NULL;
     
    345345 *
    346346 */
    347 sysarg_t sys_task_get_id(sysarg64_t *uspace_taskid)
     347sys_errno_t sys_task_get_id(sysarg64_t *uspace_taskid)
    348348{
    349349        /*
     
    351351         * the lifespan of the task.
    352352         */
    353         return (sysarg_t) copy_to_uspace(uspace_taskid, &TASK->taskid,
     353        return (sys_errno_t) copy_to_uspace(uspace_taskid, &TASK->taskid,
    354354            sizeof(TASK->taskid));
    355355}
     
    385385 *
    386386 */
    387 sysarg_t sys_task_set_name(const char *uspace_name, size_t name_len)
     387sys_errno_t sys_task_set_name(const char *uspace_name, size_t name_len)
    388388{
    389389        char namebuf[TASK_NAME_BUFLEN];
     
    393393                name_len = TASK_NAME_BUFLEN - 1;
    394394       
    395         int rc = copy_from_uspace(namebuf, uspace_name, name_len);
     395        errno_t rc = copy_from_uspace(namebuf, uspace_name, name_len);
    396396        if (rc != 0)
    397                 return (sysarg_t) rc;
     397                return (sys_errno_t) rc;
    398398       
    399399        namebuf[name_len] = '\0';
     
    426426 *
    427427 */
    428 sysarg_t sys_task_kill(task_id_t *uspace_taskid)
     428sys_errno_t sys_task_kill(task_id_t *uspace_taskid)
    429429{
    430430        task_id_t taskid;
    431         int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(taskid));
     431        errno_t rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(taskid));
    432432        if (rc != 0)
    433                 return (sysarg_t) rc;
    434        
    435         return (sysarg_t) task_kill(taskid);
     433                return (sys_errno_t) rc;
     434       
     435        return (sys_errno_t) task_kill(taskid);
    436436}
    437437
     
    539539 *
    540540 */
    541 int task_kill(task_id_t id)
     541errno_t task_kill(task_id_t id)
    542542{
    543543        if (id == 1)
     
    596596 *
    597597 */
    598 sysarg_t sys_task_exit(sysarg_t notify)
     598sys_errno_t sys_task_exit(sysarg_t notify)
    599599{
    600600        task_kill_self(notify);
  • kernel/generic/src/proc/thread.c

    r36f0738 rb7fd2a0  
    153153 *
    154154 */
    155 static int thr_constructor(void *obj, unsigned int kmflags)
     155static errno_t thr_constructor(void *obj, unsigned int kmflags)
    156156{
    157157        thread_t *thread = (thread_t *) obj;
     
    639639 *
    640640 */
    641 int thread_join_timeout(thread_t *thread, uint32_t usec, unsigned int flags)
     641errno_t thread_join_timeout(thread_t *thread, uint32_t usec, unsigned int flags)
    642642{
    643643        if (thread == THREAD)
     
    930930 *
    931931 */
    932 sysarg_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name,
     932sys_errno_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name,
    933933    size_t name_len, thread_id_t *uspace_thread_id)
    934934{
     
    937937       
    938938        char namebuf[THREAD_NAME_BUFLEN];
    939         int rc = copy_from_uspace(namebuf, uspace_name, name_len);
     939        errno_t rc = copy_from_uspace(namebuf, uspace_name, name_len);
    940940        if (rc != 0)
    941                 return (sysarg_t) rc;
     941                return (sys_errno_t) rc;
    942942       
    943943        namebuf[name_len] = 0;
     
    953953        if (rc != 0) {
    954954                free(kernel_uarg);
    955                 return (sysarg_t) rc;
     955                return (sys_errno_t) rc;
    956956        }
    957957       
     
    977977                                free(kernel_uarg);
    978978                               
    979                                 return (sysarg_t) rc;
     979                                return (sys_errno_t) rc;
    980980                         }
    981981                }
     
    999999                free(kernel_uarg);
    10001000       
    1001         return (sysarg_t) ENOMEM;
     1001        return (sys_errno_t) ENOMEM;
    10021002}
    10031003
     
    10051005 *
    10061006 */
    1007 sysarg_t sys_thread_exit(int uspace_status)
     1007sys_errno_t sys_thread_exit(int uspace_status)
    10081008{
    10091009        thread_exit();
     
    10181018 *
    10191019 */
    1020 sysarg_t sys_thread_get_id(thread_id_t *uspace_thread_id)
     1020sys_errno_t sys_thread_get_id(thread_id_t *uspace_thread_id)
    10211021{
    10221022        /*
     
    10251025         *
    10261026         */
    1027         return (sysarg_t) copy_to_uspace(uspace_thread_id, &THREAD->tid,
     1027        return (sys_errno_t) copy_to_uspace(uspace_thread_id, &THREAD->tid,
    10281028            sizeof(THREAD->tid));
    10291029}
    10301030
    10311031/** Syscall wrapper for sleeping. */
    1032 sysarg_t sys_thread_usleep(uint32_t usec)
     1032sys_errno_t sys_thread_usleep(uint32_t usec)
    10331033{
    10341034        thread_usleep(usec);
     
    10361036}
    10371037
    1038 sysarg_t sys_thread_udelay(uint32_t usec)
     1038sys_errno_t sys_thread_udelay(uint32_t usec)
    10391039{
    10401040        delay(usec);
Note: See TracChangeset for help on using the changeset viewer.