diff options
author | Alberto Ruiz <alberto.ruiz@codethink.co.uk> | 2011-10-04 02:42:31 +0100 |
---|---|---|
committer | Alberto Ruiz <alberto.ruiz@codethink.co.uk> | 2011-10-04 02:42:31 +0100 |
commit | c52f4ad8f9c725cbd7f4fcc2b672effcdd52b438 (patch) | |
tree | b693c8f211c8324cb7613cbd4a34eda9ef60331b | |
parent | 6b42caa7fd2b2215522df63eb96e9c3c18eceaf6 (diff) | |
download | tbdiff-c52f4ad8f9c725cbd7f4fcc2b672effcdd52b438.tar.gz |
Style fixes
-rw-r--r-- | libtbd_stat.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/libtbd_stat.c b/libtbd_stat.c index 87d4f02..b15d49a 100644 --- a/libtbd_stat.c +++ b/libtbd_stat.c @@ -45,8 +45,9 @@ _tbd_stat(const char *name, return NULL; ret->parent = NULL; + ret->size = 0; ret->name = (char*)((uintptr_t)ret + sizeof(tbd_stat_t)); - memcpy(ret->name, name, (nlen + 1)); + memcpy(ret->name, name, (nlen + 1)); if(S_ISREG(info.st_mode)) { ret->type = TBD_STAT_TYPE_FILE; @@ -59,8 +60,8 @@ _tbd_stat(const char *name, free(ret); return NULL; } - - ret->size = 0; + + /* FIXME: Remove the need for directory size? */ struct dirent *ds; for(ds = readdir(dp); ds != NULL; ds = readdir(dp)) { if((strcmp(ds->d_name, ".") == 0) @@ -70,22 +71,17 @@ _tbd_stat(const char *name, ret->size++; } closedir(dp); - } else if(S_ISLNK(info.st_mode)) { + } else if(S_ISLNK(info.st_mode)) ret->type = TBD_STAT_TYPE_SYMLINK; - ret->size = 0; - } else if(S_ISCHR(info.st_mode)) { + else if(S_ISCHR(info.st_mode)) ret->type = TBD_STAT_TYPE_CHRDEV; - ret->size = 0; - } else if(S_ISBLK(info.st_mode)) { + else if(S_ISBLK(info.st_mode)) ret->type = TBD_STAT_TYPE_BLKDEV; - ret->size = 0; - } else if(S_ISFIFO(info.st_mode)) { + else if(S_ISFIFO(info.st_mode)) ret->type = TBD_STAT_TYPE_FIFO; - ret->size = 0; - } else if(S_ISSOCK(info.st_mode)) { + else if(S_ISSOCK(info.st_mode)) ret->type = TBD_STAT_TYPE_SOCKET; - ret->size = 0; - } else { + else { free(ret); return NULL; } @@ -95,7 +91,6 @@ _tbd_stat(const char *name, ret->gid = (uint32_t)info.st_gid; ret->mode = (uint32_t)info.st_mode; ret->mtime = (uint32_t)info.st_mtime; - return ret; } |