Changeset 0143f72 in mainline for uspace/lib/libfs/libfs.c


Ignore:
Timestamp:
2009-07-02T15:01:08Z (15 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/lib/libfs/libfs.c

    r271283b r0143f72  
    440440        size_t size;
    441441        if (!ipc_data_read_receive(&callid, &size) ||
    442             size < sizeof(struct stat)) {
     442            size != sizeof(struct stat)) {
    443443                ipc_answer_0(callid, EINVAL);
    444444                ipc_answer_0(rid, EINVAL);
     
    446446        }
    447447
    448         struct stat *stat = malloc(sizeof(struct stat));
    449         if (!stat) {
    450                 ipc_answer_0(callid, ENOMEM);
    451                 ipc_answer_0(rid, ENOMEM);
    452                 return;
    453         }
    454         memset(stat, 0, sizeof(struct stat));
    455        
    456         stat->fs_handle = fs_handle;
    457         stat->dev_handle = dev_handle;
    458         stat->index = index;
    459         stat->lnkcnt = ops->lnkcnt_get(fn);
    460         stat->is_file = ops->is_file(fn);
    461         stat->size = ops->size_get(fn);
    462 
    463         ipc_data_read_finalize(callid, stat, sizeof(struct stat));
     448        struct stat stat;
     449        memset(&stat, 0, sizeof(struct stat));
     450       
     451        stat.fs_handle = fs_handle;
     452        stat.dev_handle = dev_handle;
     453        stat.index = index;
     454        stat.lnkcnt = ops->lnkcnt_get(fn);
     455        stat.is_file = ops->is_file(fn);
     456        stat.size = ops->size_get(fn);
     457
     458        ipc_data_read_finalize(callid, &stat, sizeof(struct stat));
    464459        ipc_answer_0(rid, EOK);
    465 
    466         free(stat);
    467460}
    468461
Note: See TracChangeset for help on using the changeset viewer.