summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/collection/collection.c7
-rw-r--r--common/collection/collection.h5
-rw-r--r--common/collection/collection_tools.c1
-rw-r--r--common/collection/collection_tools.h3
-rw-r--r--common/collection/collection_ut.c5
-rw-r--r--common/ini/ini_config.c15
-rw-r--r--common/ini/ini_config.h2
-rw-r--r--common/ini/ini_config_ut.c14
8 files changed, 22 insertions, 30 deletions
diff --git a/common/collection/collection.c b/common/collection/collection.c
index e393ae3d..4a5b5044 100644
--- a/common/collection/collection.c
+++ b/common/collection/collection.c
@@ -303,7 +303,7 @@ static struct collection_item *add_property(struct collection_item *collection,
int type,
int *error)
{
- struct collection_item *item;
+ struct collection_item *item = (struct collection_item *) NULL;
struct collection_item *acceptor = (struct collection_item *)(NULL);
TRACE_FLOW_STRING("add_property","Entry.");
@@ -734,7 +734,6 @@ static int find_item_and_do(struct collection_item *ci,
static int update_current_item(struct collection_item *current,
struct update_property *update_data)
{
- int error = EOK;
TRACE_FLOW_STRING("update_current_item","Entry");
/* If type is different or same but it is string or binary we need to replace the storage */
@@ -1468,7 +1467,6 @@ int get_reference_from_item(struct collection_item *ci,
{
struct collection_header *header;
struct collection_item *subcollection = (struct collection_item *)(NULL);
- int error = EOK;
TRACE_FLOW_STRING("get_reference_from_item","Entry.");
@@ -1878,8 +1876,6 @@ int modify_item(struct collection_item *item,
void *data,
int length)
{
- int error = EOK;
-
TRACE_FLOW_STRING("modify_item","Entry");
if((item == (struct collection_item *)(NULL)) ||
@@ -2054,7 +2050,6 @@ inline int modify_double_item(struct collection_item *item,
/* Grow iteration stack */
static int grow_stack(struct collection_iterator *iterator, unsigned desired)
{
- int error;
int grow_by = 0;
struct collection_item **temp;
diff --git a/common/collection/collection.h b/common/collection/collection.h
index 2a88f82c..bccf3e3c 100644
--- a/common/collection/collection.h
+++ b/common/collection/collection.h
@@ -105,7 +105,7 @@ struct collection_item;
struct collection_iterator;
#endif /* COLLECTION_PRIV_H */
-/* IMPORATNAT - the collection is a set of items of different types.
+/* IMPORTANT - the collection is a set of items of different types.
* There is always a header item in any collection that starts the collection.
* Most of the functions in the interface (unless it is explicitly mentioned
* otherwise) assume that the collection_item * argument points to the header element.
@@ -113,7 +113,7 @@ struct collection_iterator;
* that expect header elements is illegal. There might be not enough checking
* at the moment but this will be enforced in future versions of the library.
-/* IMPORTANT - To better understand how collections work imagine travel bags.
+ * IMPORTANT - To better understand how collections work imagine travel bags.
* They usually come in different sizes and one can put a bag in a bag when they put away
* to the shelf in a garage or closet. Collection is such bag except that you
* can put other bags into each other even if they are not empty.
@@ -144,6 +144,7 @@ struct collection_iterator;
* to destroy the collection after it is used.
* By extracting reference from an internal collection the caller gains access to the
* collection directly and thus has responsibility to destroy it after use.
+ */
/* Function that creates an named collection */
int create_collection(struct collection_item **ci,char *name,unsigned class);
diff --git a/common/collection/collection_tools.c b/common/collection/collection_tools.c
index 1c96f6f8..ed44707d 100644
--- a/common/collection/collection_tools.c
+++ b/common/collection/collection_tools.c
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <malloc.h>
#include <errno.h>
+#include <string.h>
#include "trace.h"
#include "collection_priv.h"
#include "collection.h"
diff --git a/common/collection/collection_tools.h b/common/collection/collection_tools.h
index 726f21c7..d2ae238f 100644
--- a/common/collection/collection_tools.h
+++ b/common/collection/collection_tools.h
@@ -91,6 +91,9 @@ int debug_collection(struct collection_item *handle,int flag);
/* Print the collection using default serialization */
int print_collection(struct collection_item *handle);
+/* Print the collection using iterator */
+int print_collection2(struct collection_item *handle);
+
/* Find and print one item using default serialization */
int print_item(struct collection_item *handle, char *name);
diff --git a/common/collection/collection_ut.c b/common/collection/collection_ut.c
index ec38d556..6d27db66 100644
--- a/common/collection/collection_ut.c
+++ b/common/collection/collection_ut.c
@@ -34,7 +34,6 @@ int ref_collection_test()
struct collection_item *peer;
struct collection_item *socket;
char binary_dump[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
- int found = 0;
int error = EOK;
@@ -169,7 +168,6 @@ int add_collection_test()
struct collection_item *peer;
struct collection_item *socket;
char binary_dump[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
- int found = 0;
int error = EOK;
@@ -227,12 +225,11 @@ int mixed_collection_test()
struct collection_item *peer;
struct collection_item *socket1;
struct collection_item *socket2;
- struct collection_item *packet;
struct collection_item *event;
struct collection_item *host;
char binary_dump[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
int found = 0;
- int class = 0;
+ unsigned int class = 0;
int error = EOK;
diff --git a/common/ini/ini_config.c b/common/ini/ini_config.c
index cf70c9c8..fafc565d 100644
--- a/common/ini/ini_config.c
+++ b/common/ini/ini_config.c
@@ -20,7 +20,7 @@
along with INI Library. If not, see <http://www.gnu.org/licenses/>.
*/
-
+#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <string.h>
@@ -94,6 +94,8 @@ inline const char *parsing_error_str(int parsing_error)
#endif
+int read_line(FILE *file,char **key,char **value, int *length, int *ext_error);
+
/* Add to collection or update - CONSIDER moving to the collection.c */
static int add_or_update(struct collection_item *current_section,
char *key,
@@ -137,7 +139,6 @@ static int ini_to_collection(const char *filename,
char *value = NULL;
struct collection_item *current_section = (struct collection_item *)(NULL);
int length;
- int type;
int ext_err = -1;
struct parse_error pe;
int line = 0;
@@ -349,7 +350,6 @@ int config_for_app(const char *application,
struct collection_item *error_list_specific = (struct collection_item *)(NULL);
struct collection_item **pass_common = (struct collection_item **)(NULL);
struct collection_item **pass_specific = (struct collection_item **)(NULL);
- struct collection_item *error_file_set = (struct collection_item *)(NULL);
int created = 0;
TRACE_FLOW_STRING("config_to_collection", "Entry");
@@ -480,7 +480,7 @@ int config_for_app(const char *application,
}
/* Reads a line from the file */
-int read_line(FILE *file,char **key,void **value, int *length, int *ext_error)
+int read_line(FILE *file,char **key,char **value, int *length, int *ext_error)
{
char *res = NULL;
@@ -488,7 +488,6 @@ int read_line(FILE *file,char **key,void **value, int *length, int *ext_error)
int len = 0;
char *buffer = NULL;
int i = 0;
- int status = RET_INVALID;
char *eq = NULL;
TRACE_FLOW_STRING("read_line","Entry");
@@ -639,9 +638,8 @@ void print_file_parsing_errors(FILE *file,
struct collection_iterator *iterator;
int error;
struct collection_item *item = (struct collection_item *)(NULL);
- struct collection_header *header;
struct parse_error *pe;
- int count;
+ unsigned int count;
TRACE_FLOW_STRING("print_file_parsing_errors", "Entry");
@@ -796,7 +794,7 @@ int get_config_item(const char *section,
return EINVAL;
}
- *item == (struct collection_item *)(NULL);
+ *item = (struct collection_item *)(NULL);
if(section == NULL) to_find = default_section;
else to_find = (char *)section;
@@ -1097,7 +1095,6 @@ char **get_string_config_array(struct collection_item *item, char *sep, int *siz
char defsep[] = ",";
char *copy = NULL;
char *dest = NULL;
- int total = 0;
int lensep;
char *buff;
int count = 0;
diff --git a/common/ini/ini_config.h b/common/ini/ini_config.h
index 8bf7373b..21b912b9 100644
--- a/common/ini/ini_config.h
+++ b/common/ini/ini_config.h
@@ -105,7 +105,7 @@ void print_config_parsing_errors(FILE *file, /* File t
int get_config_item(const char *section, /* Section. If NULL assumed default */
const char *name, /* Name of the property to look up */
struct collection_item *ini_config, /* Collection to search */
- struct collection_item **item); /* Item returned. Will be NULL is not found. /
+ struct collection_item **item); /* Item returned. Will be NULL is not found. */
/* Convertion functions for the configuration item.
* Sets error to EINVAL if the item is bad.
diff --git a/common/ini/ini_config_ut.c b/common/ini/ini_config_ut.c
index 2bb5517d..642f268b 100644
--- a/common/ini/ini_config_ut.c
+++ b/common/ini/ini_config_ut.c
@@ -19,6 +19,7 @@
along with INI Library. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#define TRACE_HOME
@@ -84,9 +85,8 @@ int single_file()
int negative_test()
{
int error;
- int count;
+ unsigned int count;
struct collection_item *ini_config = (struct collection_item *)(NULL);
- struct collection_item *error_set = (struct collection_item *)(NULL);
/* App name is null - expect failure */
error = config_for_app(NULL, NULL, NULL, NULL,INI_STOP_ON_NONE,NULL);
@@ -209,9 +209,7 @@ int get_test()
int error;
struct collection_item *ini_config = (struct collection_item *)(NULL);
struct collection_item *error_set = (struct collection_item *)(NULL);
- struct collection_iterator *iterator = (struct collection_iterator *)(NULL);
struct collection_item *item = (struct collection_item *)(NULL);
- int type;
int number;
long number_long;
double number_double;
@@ -449,7 +447,7 @@ int get_test()
return -1;
}
- printf("Expected 3 got %d\n", number_long);
+ printf("Expected 3 got %ld\n", number_long);
printf("Convert item to unsigned.\n");
@@ -489,7 +487,7 @@ int get_test()
return -1;
}
- printf("Expected 3 got %d\n", number_ulong);
+ printf("Expected 3 got %lu\n", number_ulong);
printf("Convert item to double.\n");
@@ -509,7 +507,7 @@ int get_test()
return -1;
}
- printf("Expected 3 got %d\n", number_double);
+ printf("Expected 3 got %e\n", number_double);
printf("Convert item to bool.\n");
@@ -675,7 +673,7 @@ int get_test()
}
/* Can be used with this cycle */
- for(i=0;i<size;i++) printf("%d\n",*(array + i));
+ for(i=0;i<size;i++) printf("%ld\n",*(array + i));
free_long_config_array(array);