summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-01-18 23:39:31 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-01-18 23:39:31 +0000
commit9ba0e55fc45986d42d40fbaa399c842321142a8b (patch)
treed38d27164eda19d0f79348473617838bf54b0104 /cpukit/libfs
parent2010-01-18 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-9ba0e55fc45986d42d40fbaa399c842321142a8b.tar.bz2
2010-01-18 Joel Sherrill <joel.sherrill@oarcorp.com>
Coverity Id 19 Coverity Id 20 Coverity Id 21 * libfs/src/imfs/imfs_link.c, libfs/src/imfs/imfs_load_tar.c, libfs/src/imfs/imfs_mknod.c: Add comment to explain allocation is for life of file, not scope of method.
Diffstat (limited to 'cpukit/libfs')
-rw-r--r--cpukit/libfs/src/imfs/imfs_link.c6
-rw-r--r--cpukit/libfs/src/imfs/imfs_load_tar.c58
-rw-r--r--cpukit/libfs/src/imfs/imfs_mknod.c7
3 files changed, 42 insertions, 29 deletions
diff --git a/cpukit/libfs/src/imfs/imfs_link.c b/cpukit/libfs/src/imfs/imfs_link.c
index db8659db75..b9bab7a520 100644
--- a/cpukit/libfs/src/imfs/imfs_link.c
+++ b/cpukit/libfs/src/imfs/imfs_link.c
@@ -5,7 +5,7 @@
* name given in name. The link node is set to point to the node at
* to_loc.
*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2010.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -51,6 +51,10 @@ int IMFS_link(
/*
* Create a new link node.
+ *
+ * NOTE: Coverity thinks this is a resource leak since a node
+ * is created but never deleted. The scope of the allocation
+ * is that of a file -- not this method. Coverity Id 19.
*/
new_node = IMFS_create_node(
diff --git a/cpukit/libfs/src/imfs/imfs_load_tar.c b/cpukit/libfs/src/imfs/imfs_load_tar.c
index 531359162e..4b9392e71a 100644
--- a/cpukit/libfs/src/imfs/imfs_load_tar.c
+++ b/cpukit/libfs/src/imfs/imfs_load_tar.c
@@ -1,4 +1,11 @@
/*
+ * COPYRIGHT (c) 1989-2010.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
* $Id$
*/
@@ -6,13 +13,13 @@
#include "config.h"
#endif
-/**************************************************************************
+/*
* This file implements the "mount" procedure for tar-based IMFS
* extensions. The TAR is not actually mounted under the IMFS.
* Directories from the TAR file are created as usual in the IMFS.
* File entries are created as IMFS_LINEAR_FILE nodes with their nods
* pointing to addresses in the TAR image.
- *************************************************************************/
+ */
#include <sys/types.h>
#include <sys/stat.h>
@@ -26,7 +33,7 @@
#include <rtems/untar.h>
#include <rtems/tar.h>
-/**************************************************************************
+/*
* TAR file format:
*
* Offset Length Contents
@@ -54,13 +61,13 @@
* sum = 0;
* for(i = 0; i < 512; i++)
* sum += 0xFF & header[i];
- *************************************************************************/
+ */
#define MAX_NAME_FIELD_SIZE 99
#define MIN(a,b) ((a)>(b)?(b):(a))
-/**************************************************************************
+/*
* rtems_tarfs_load
*
* Here we create the mountpoint directory and load the tarfs at
@@ -70,9 +77,8 @@
* needed.
* - For files, we make our own calls to IMFS eval_for_make and
* create_node.
- *************************************************************************/
-int
-rtems_tarfs_load(
+ */
+int rtems_tarfs_load(
char *mountpoint,
uint8_t *tar_image,
size_t tar_size
@@ -98,20 +104,19 @@ rtems_tarfs_load(
return(-1);
if (root_loc.ops != &IMFS_ops)
- return(-1);
+ return -1;
- /***********************************************************************
+ /*
* Create an IMFS node structure pointing to tar image memory.
- **********************************************************************/
+ */
offset = 0;
- while (1)
- {
+ while (1) {
if (offset + 512 > tar_size)
break;
- /******************************************************************
+ /*
* Read a header.
- ******************************************************************/
+ */
hdr_ptr = (char *) &tar_image[offset];
offset += 512;
if (strncmp(&hdr_ptr[257], "ustar ", 7))
@@ -128,30 +133,31 @@ rtems_tarfs_load(
if (_rtems_tar_header_checksum(hdr_ptr) != hdr_chksum)
break;
- /******************************************************************
+ /*
* Generate an IMFS node depending on the file type.
* - For directories, just create directories as usual. IMFS
* will take care of the rest.
* - For files, create a file node with special tarfs properties.
- *****************************************************************/
- if (linkflag == DIRTYPE)
- {
+ */
+ if (linkflag == DIRTYPE) {
strcpy(full_filename, mountpoint);
if (full_filename[strlen(full_filename)-1] != '/')
strcat(full_filename, "/");
strcat(full_filename, filename);
mkdir(full_filename, S_IRWXU | S_IRWXG | S_IRWXO);
}
- /******************************************************************
+ /*
* Create a LINEAR_FILE node
- *****************************************************************/
- else if (linkflag == REGTYPE)
- {
+ *
+ * NOTE: Coverity thinks this is a resource leak since a node
+ * is created but never deleted. The scope of the allocation
+ * is that of a file -- not this method. Coverity Id 20.
+ */
+ else if (linkflag == REGTYPE) {
const char *name;
loc = root_loc;
- if (IMFS_evaluate_for_make(filename, &loc, &name) == 0)
- {
+ if (IMFS_evaluate_for_make(filename, &loc, &name) == 0) {
node = IMFS_create_node(&loc,
IMFS_LINEAR_FILE, (char *)name,
(file_mode & (S_IRWXU | S_IRWXG | S_IRWXO)) | S_IFREG,
@@ -165,6 +171,6 @@ rtems_tarfs_load(
}
}
- return(status);
+ return status;
}
diff --git a/cpukit/libfs/src/imfs/imfs_mknod.c b/cpukit/libfs/src/imfs/imfs_mknod.c
index f7b8ac9998..fe852b6b0f 100644
--- a/cpukit/libfs/src/imfs/imfs_mknod.c
+++ b/cpukit/libfs/src/imfs/imfs_mknod.c
@@ -3,7 +3,7 @@
*
* Routine to create a node in the IMFS file system.
*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2010.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -63,8 +63,11 @@ int IMFS_mknod(
/*
* Allocate and fill in an IMFS jnode
+ *
+ * NOTE: Coverity thinks this is a resource leak since a node
+ * is created but never deleted. The scope of the allocation
+ * is that of a file -- not this method. Coverity Id 21.
*/
-
new_node = IMFS_create_node(
pathloc,
type,