Changeset b7fd2a0 in mainline for uspace/srv/vfs/vfs_file.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/srv/vfs/vfs_file.c

    r36f0738 rb7fd2a0  
    6464} vfs_boxed_handle_t;
    6565
    66 static int _vfs_fd_free(vfs_client_data_t *, int);
     66static errno_t _vfs_fd_free(vfs_client_data_t *, int);
    6767
    6868/** Initialize the table of open files. */
     
    133133
    134134/** Close the file in the endpoint FS server. */
    135 static int vfs_file_close_remote(vfs_file_t *file)
     135static errno_t vfs_file_close_remote(vfs_file_t *file)
    136136{
    137137        assert(!file->refcnt);
     
    145145        vfs_exchange_release(exch);
    146146       
    147         int rc;
     147        errno_t rc;
    148148        async_wait_for(msg, &rc);
    149149       
     
    168168 *                      decremented.
    169169 */
    170 static int vfs_file_delref(vfs_client_data_t *vfs_data, vfs_file_t *file)
    171 {
    172         int rc = EOK;
     170static errno_t vfs_file_delref(vfs_client_data_t *vfs_data, vfs_file_t *file)
     171{
     172        errno_t rc = EOK;
    173173
    174174        assert(fibril_mutex_is_locked(&vfs_data->lock));
     
    192192}
    193193
    194 static int _vfs_fd_alloc(vfs_client_data_t *vfs_data, vfs_file_t **file, bool desc, int *out_fd)
     194static errno_t _vfs_fd_alloc(vfs_client_data_t *vfs_data, vfs_file_t **file, bool desc, int *out_fd)
    195195{
    196196        if (!vfs_files_init(vfs_data))
     
    254254 * @return Error code.
    255255 */
    256 int vfs_fd_alloc(vfs_file_t **file, bool desc, int *out_fd)
     256errno_t vfs_fd_alloc(vfs_file_t **file, bool desc, int *out_fd)
    257257{
    258258        return _vfs_fd_alloc(VFS_DATA, file, desc, out_fd);
    259259}
    260260
    261 static int _vfs_fd_free_locked(vfs_client_data_t *vfs_data, int fd)
     261static errno_t _vfs_fd_free_locked(vfs_client_data_t *vfs_data, int fd)
    262262{
    263263        if ((fd < 0) || (fd >= MAX_OPEN_FILES) || !vfs_data->files[fd]) {
     
    265265        }
    266266
    267         int rc = vfs_file_delref(vfs_data, vfs_data->files[fd]);
     267        errno_t rc = vfs_file_delref(vfs_data, vfs_data->files[fd]);
    268268        vfs_data->files[fd] = NULL;
    269269        return rc;
    270270}
    271271
    272 static int _vfs_fd_free(vfs_client_data_t *vfs_data, int fd)
    273 {
    274         int rc;
     272static errno_t _vfs_fd_free(vfs_client_data_t *vfs_data, int fd)
     273{
     274        errno_t rc;
    275275
    276276        if (!vfs_files_init(vfs_data))
     
    291291 *                      descriptor.
    292292 */
    293 int vfs_fd_free(int fd)
     293errno_t vfs_fd_free(int fd)
    294294{
    295295        return _vfs_fd_free(VFS_DATA, fd);
     
    305305 *
    306306 */
    307 int vfs_fd_assign(vfs_file_t *file, int fd)
     307errno_t vfs_fd_assign(vfs_file_t *file, int fd)
    308308{
    309309        if (!vfs_files_init(VFS_DATA))
     
    429429}
    430430
    431 int vfs_wait_handle_internal(bool high_fd, int *out_fd)
     431errno_t vfs_wait_handle_internal(bool high_fd, int *out_fd)
    432432{
    433433        vfs_client_data_t *vfs_data = VFS_DATA;
     
    443443
    444444        vfs_file_t *file;
    445         int rc = _vfs_fd_alloc(vfs_data, &file, high_fd, out_fd);
     445        errno_t rc = _vfs_fd_alloc(vfs_data, &file, high_fd, out_fd);
    446446        if (rc != EOK) {
    447447                vfs_node_delref(bh->node);
Note: See TracChangeset for help on using the changeset viewer.