Changeset 0143f72 in mainline for uspace/srv


Ignore:
Timestamp:
2009-07-02T15:01:08Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bb8dc88
Parents:
271283b
Message:

Statically allocated stat structure will do.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/devfs/devfs_ops.c

    r271283b r0143f72  
    287287        size_t size;
    288288        if (!ipc_data_read_receive(&callid, &size) ||
    289             size < sizeof(struct stat)) {
     289            size != sizeof(struct stat)) {
    290290                ipc_answer_0(callid, EINVAL);
    291291                ipc_answer_0(rid, EINVAL);
     
    293293        }
    294294
    295         struct stat *stat = malloc(sizeof(struct stat));
    296         if (!stat) {
    297                 ipc_answer_0(callid, ENOMEM);
    298                 ipc_answer_0(rid, ENOMEM);
    299                 return;
    300         }
    301         memset(stat, 0, sizeof(struct stat));
    302 
    303         stat->fs_handle = devfs_reg.fs_handle;
    304         stat->dev_handle = dev_handle;
    305         stat->index = index;
    306         stat->lnkcnt = 1;
    307         stat->is_file = (index != 0);
    308         stat->size = 0;
     295        struct stat stat;
     296        memset(&stat, 0, sizeof(struct stat));
     297
     298        stat.fs_handle = devfs_reg.fs_handle;
     299        stat.dev_handle = dev_handle;
     300        stat.index = index;
     301        stat.lnkcnt = 1;
     302        stat.is_file = (index != 0);
     303        stat.size = 0;
    309304       
    310305        if (index != 0) {
     
    316311                link_t *lnk = hash_table_find(&devices, key);
    317312                if (lnk != NULL)
    318                         stat->devfs_stat.device = (dev_handle_t)index;
     313                        stat.devfs_stat.device = (dev_handle_t)index;
    319314                fibril_mutex_unlock(&devices_mutex);
    320315        }
    321316
    322         ipc_data_read_finalize(callid, stat, sizeof(struct stat));
     317        ipc_data_read_finalize(callid, &stat, sizeof(struct stat));
    323318        ipc_answer_0(rid, EOK);
    324 
    325         free(stat);
    326319}
    327320
Note: See TracChangeset for help on using the changeset viewer.