summaryrefslogtreecommitdiff
path: root/nuttx/fs
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-11-25 13:46:14 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-11-25 13:46:14 -0600
commitf28eff61aeb62c867249c8cb21162dbd3c60cc37 (patch)
treec1c8b6d68fb43d3ae59c3eb589e6a4c44acdcd57 /nuttx/fs
parent3b3fcf2bfa6015d890d42b5a528f7fe7476632f7 (diff)
downloadpx4-nuttx-f28eff61aeb62c867249c8cb21162dbd3c60cc37.tar.gz
px4-nuttx-f28eff61aeb62c867249c8cb21162dbd3c60cc37.tar.bz2
px4-nuttx-f28eff61aeb62c867249c8cb21162dbd3c60cc37.zip
More fixes to problems noted by cppcheck. Some are kind of risky; some are real bugs.
Diffstat (limited to 'nuttx/fs')
-rw-r--r--nuttx/fs/aio/aio_read.c2
-rw-r--r--nuttx/fs/aio/aio_write.c4
-rw-r--r--nuttx/fs/fat/fs_configfat.c2
-rw-r--r--nuttx/fs/nxffs/nxffs_dump.c2
-rw-r--r--nuttx/fs/nxffs/nxffs_initialize.c2
-rw-r--r--nuttx/fs/smartfs/smartfs_procfs.c10
-rw-r--r--nuttx/fs/smartfs/smartfs_smart.c24
7 files changed, 28 insertions, 18 deletions
diff --git a/nuttx/fs/aio/aio_read.c b/nuttx/fs/aio/aio_read.c
index 104895436..fd05edbc6 100644
--- a/nuttx/fs/aio/aio_read.c
+++ b/nuttx/fs/aio/aio_read.c
@@ -96,7 +96,7 @@ static void aio_read_worker(FAR void *arg)
#ifdef CONFIG_PRIORITY_INHERITANCE
uint8_t prio;
#endif
- ssize_t nread;
+ ssize_t nread = 0;
/* Get the information from the container, decant the AIO control block,
* and free the container before starting any I/O. That will minimize
diff --git a/nuttx/fs/aio/aio_write.c b/nuttx/fs/aio/aio_write.c
index f05e357c3..6b8903895 100644
--- a/nuttx/fs/aio/aio_write.c
+++ b/nuttx/fs/aio/aio_write.c
@@ -113,8 +113,10 @@ static void aio_write_worker(FAR void *arg)
#ifdef CONFIG_PRIORITY_INHERITANCE
uint8_t prio;
#endif
- ssize_t nwritten;
+ ssize_t nwritten = 0;
+#ifdef AIO_HAVE_FILEP
int oflags;
+#endif
/* Get the information from the container, decant the AIO control block,
* and free the container before starting any I/O. That will minimize
diff --git a/nuttx/fs/fat/fs_configfat.c b/nuttx/fs/fat/fs_configfat.c
index 5aff493c9..59e174ef5 100644
--- a/nuttx/fs/fat/fs_configfat.c
+++ b/nuttx/fs/fat/fs_configfat.c
@@ -950,7 +950,7 @@ int mkfatfs_configfatfs(FAR struct fat_format_s *fmt,
{
/* There must be reserved sectors in order to have a backup boot sector */
- if (fmt->ff_rsvdseccount > 0 && fmt->ff_rsvdseccount >= 2)
+ if (fmt->ff_rsvdseccount >= 2)
{
/* Sector 0 is the MBR; 1... ff_rsvdseccount are reserved. Try the next
* the last reserved sector.
diff --git a/nuttx/fs/nxffs/nxffs_dump.c b/nuttx/fs/nxffs/nxffs_dump.c
index 181aaaebe..19e4d4b5c 100644
--- a/nuttx/fs/nxffs/nxffs_dump.c
+++ b/nuttx/fs/nxffs/nxffs_dump.c
@@ -67,7 +67,9 @@ struct nxffs_blkinfo_s
off_t nblocks;
off_t block;
off_t offset;
+#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_FS)
bool verbose;
+#endif
};
/****************************************************************************
diff --git a/nuttx/fs/nxffs/nxffs_initialize.c b/nuttx/fs/nxffs/nxffs_initialize.c
index 3fb9e2b77..d7d55f077 100644
--- a/nuttx/fs/nxffs/nxffs_initialize.c
+++ b/nuttx/fs/nxffs/nxffs_initialize.c
@@ -410,7 +410,7 @@ int nxffs_limits(FAR struct nxffs_volume_s *volume)
if (!noinodes)
{
- while ((ret = nxffs_nextentry(volume, offset, &entry)) == OK)
+ while (nxffs_nextentry(volume, offset, &entry) == OK)
{
/* Discard the entry and guess the next offset. */
diff --git a/nuttx/fs/smartfs/smartfs_procfs.c b/nuttx/fs/smartfs/smartfs_procfs.c
index 2b56f366d..e74d65944 100644
--- a/nuttx/fs/smartfs/smartfs_procfs.c
+++ b/nuttx/fs/smartfs/smartfs_procfs.c
@@ -709,7 +709,9 @@ static size_t smartfs_status_read(FAR struct file *filep, FAR char *buffer,
FAR struct smartfs_file_s *priv;
int ret;
size_t len;
+#if 0 /* Not used */
int utilization;
+#endif
priv = (FAR struct smartfs_file_s *) filep->f_priv;
@@ -729,6 +731,7 @@ static size_t smartfs_status_read(FAR struct file *filep, FAR char *buffer,
if (ret == OK)
{
+#if 0 /* Not used */
/* Calculate the sector utilization percentage */
if (procfs_data.blockerases == 0)
@@ -741,6 +744,7 @@ static size_t smartfs_status_read(FAR struct file *filep, FAR char *buffer,
procfs_data.unusedsectors) / (procfs_data.blockerases *
procfs_data.sectorsperblk);
}
+#endif
/* Format and return data in the buffer */
@@ -756,8 +760,10 @@ static size_t smartfs_status_read(FAR struct file *filep, FAR char *buffer,
procfs_data.formatsector, procfs_data.dirsector,
procfs_data.freesectors, procfs_data.releasesectors,
procfs_data.sectorsperblk);
- //procfs_data.unusedsectors, procfs_data.blockerases,
- //procfs_data.sectorsperblk, utilization);
+#if 0 /* Not used */
+ procfs_data.unusedsectors, procfs_data.blockerases,
+ procfs_data.sectorsperblk, utilization);
+#endif
}
/* Indicate we have already provided all the data */
diff --git a/nuttx/fs/smartfs/smartfs_smart.c b/nuttx/fs/smartfs/smartfs_smart.c
index bcbda7de8..0b9a373b1 100644
--- a/nuttx/fs/smartfs/smartfs_smart.c
+++ b/nuttx/fs/smartfs/smartfs_smart.c
@@ -1441,7 +1441,7 @@ static int smartfs_unbind(void *handle, FAR struct inode **blkdriver)
static int smartfs_statfs(struct inode *mountpt, struct statfs *buf)
{
struct smartfs_mountpt_s *fs;
- int ret = OK;
+ int ret;
/* Sanity checks */
@@ -1483,11 +1483,11 @@ static int smartfs_statfs(struct inode *mountpt, struct statfs *buf)
static int smartfs_unlink(struct inode *mountpt, const char *relpath)
{
- struct smartfs_mountpt_s *fs;
- int ret = OK;
- struct smartfs_entry_s entry;
- const char *filename;
- uint16_t parentdirsector;
+ struct smartfs_mountpt_s *fs;
+ int ret;
+ struct smartfs_entry_s entry;
+ const char *filename;
+ uint16_t parentdirsector;
/* Sanity checks */
@@ -1627,11 +1627,11 @@ errout_with_semaphore:
int smartfs_rmdir(struct inode *mountpt, const char *relpath)
{
- struct smartfs_mountpt_s *fs;
- int ret = OK;
- struct smartfs_entry_s entry;
- const char *filename;
- uint16_t parentdirsector;
+ struct smartfs_mountpt_s *fs;
+ int ret;
+ struct smartfs_entry_s entry;
+ const char *filename;
+ uint16_t parentdirsector;
/* Sanity checks */
@@ -1916,7 +1916,7 @@ static int smartfs_stat(struct inode *mountpt, const char *relpath, struct stat
{
struct smartfs_mountpt_s *fs;
struct smartfs_entry_s entry;
- int ret = -ENOENT;
+ int ret;
uint16_t parentdirsector;
const char *filename;