diff --git a/fs/procfs/fs_procfscpuload.c b/fs/procfs/fs_procfscpuload.c index 593c0c5281..11af96c34b 100644 --- a/fs/procfs/fs_procfscpuload.c +++ b/fs/procfs/fs_procfscpuload.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/procfs/fs_procfscpuload.c * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -333,10 +333,8 @@ static int cpuload_stat(const char *relpath, struct stat *buf) /* "cpuload" is the name for a read-only file */ - buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR; - buf->st_size = 0; - buf->st_blksize = 0; - buf->st_blocks = 0; + memset(buf, 0, sizeof(struct stat)); + buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR; return OK; } diff --git a/fs/procfs/fs_procfskmm.c b/fs/procfs/fs_procfskmm.c index ab0c6779ec..d3c8699d19 100644 --- a/fs/procfs/fs_procfskmm.c +++ b/fs/procfs/fs_procfskmm.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/procfs/fs_procfskmm.c * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2016-2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -312,10 +312,8 @@ static int kmm_stat(FAR const char *relpath, FAR struct stat *buf) /* "kmm" is the name for a read-only file */ - buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR; - buf->st_size = 0; - buf->st_blksize = 0; - buf->st_blocks = 0; + memset(buf, 0, sizeof(struct stat)); + buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR; return OK; } diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c index db426ee5ef..c8824b9ca0 100644 --- a/fs/procfs/fs_procfsproc.c +++ b/fs/procfs/fs_procfsproc.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/procfs/fs_procfsproc.c * - * Copyright (C) 2013-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -1552,6 +1552,7 @@ static int proc_stat(const char *relpath, struct stat *buf) /* Was the the final element of the path? */ + memset(buf, 0, sizeof(struct stat)); if (*ptr == '\0' || strcmp(ptr, "/") == 0) { /* Yes ... It's a read-only directory */ @@ -1601,11 +1602,6 @@ static int proc_stat(const char *relpath, struct stat *buf) } } - /* File/directory size, access block size */ - - buf->st_size = 0; - buf->st_blksize = 0; - buf->st_blocks = 0; return OK; } diff --git a/fs/procfs/fs_procfsuptime.c b/fs/procfs/fs_procfsuptime.c index 9a9f8de8ba..f9e76cb897 100644 --- a/fs/procfs/fs_procfsuptime.c +++ b/fs/procfs/fs_procfsuptime.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/procfs/fs_procfsuptime.c * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -346,10 +346,8 @@ static int uptime_stat(FAR const char *relpath, FAR struct stat *buf) /* "uptime" is the name for a read-only file */ - buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR; - buf->st_size = 0; - buf->st_blksize = 0; - buf->st_blocks = 0; + memset(buf, 0, sizeof(struct stat)); + buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR; return OK; } diff --git a/fs/procfs/fs_skeleton.c b/fs/procfs/fs_skeleton.c index 0a884e03be..fe7b2998be 100644 --- a/fs/procfs/fs_skeleton.c +++ b/fs/procfs/fs_skeleton.c @@ -1,6 +1,7 @@ /**************************************************************************** * fs/procfs/fs_skeleton.c * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Copyright (C) 2015 Ken Pettit. All rights reserved. * Author: Ken Pettit * @@ -438,7 +439,7 @@ static int skel_rewinddir(FAR struct fs_dirent_s *dir) * ****************************************************************************/ -static int skel_stat(FAR const char *relpath, FAR truct stat *buf) +static int skel_stat(FAR const char *relpath, FAR struct stat *buf) { int ret = -ENOENT; @@ -446,15 +447,13 @@ static int skel_stat(FAR const char *relpath, FAR truct stat *buf) * or a directory and set it's permissions. */ + memset(buf, 0, sizeof(struct stat)); buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR; + + /* Other 'struct buf' settings may be appropriate (optional) */ + ret = OK; - /* File/directory size, access block size */ - - buf->st_size = 0; - buf->st_blksize = 0; - buf->st_blocks = 0; - return ret; }