summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2010-12-21 16:53:06 -0500
committerStephen Gallagher <sgallagh@redhat.com>2011-01-03 13:51:37 -0500
commit5a0d623a03f47448177dfba6628381f35e8cfc95 (patch)
tree166bfd596bed65940894312437a9022051ac2a9e
parentd83a94bc34b995789e038174a3b878c2f28e694d (diff)
downloadding-libs-5a0d623a03f47448177dfba6628381f35e8cfc95.tar.gz
ding-libs-5a0d623a03f47448177dfba6628381f35e8cfc95.tar.xz
ding-libs-5a0d623a03f47448177dfba6628381f35e8cfc95.zip
Coverity issues 10071 & 10072
The unit tests we actually not executed due to wrong initialization. Also the pointers were not correctly dereferenced in the string array test.
-rw-r--r--refarray/ref_array_ut.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/refarray/ref_array_ut.c b/refarray/ref_array_ut.c
index 5347634..fc9b557 100644
--- a/refarray/ref_array_ut.c
+++ b/refarray/ref_array_ut.c
@@ -586,7 +586,7 @@ int ref_array_copy_test(void)
struct ref_array *ra;
struct ref_array *ra2;
int error = EOK;
- uint32_t len = 0;
+ uint32_t len = 6;
char text[] = "Deleting: ";
error = ref_array_create(&ra, sizeof(char *), 1, NULL, NULL);
@@ -661,13 +661,13 @@ int ref_array_copy_test(void)
}
for (i = 0; i < len; i++) {
- if (strcmp(ref_array_get(ra, i, NULL),
- ref_array_get(ra2, i, NULL)) != 0) {
+ if (strcmp(*((char **)ref_array_get(ra, i, NULL)),
+ *((char **)ref_array_get(ra2, i, NULL))) != 0) {
printf("\nRetrieved strings were expected to be same,\n");
printf("but they are not:\n");
printf("First:[%s]\nSecond:[%s]\n",
- (char *)ref_array_get(ra, i, NULL),
- (char *)ref_array_get(ra2, i, NULL));
+ *((char **)ref_array_get(ra, i, NULL)),
+ *((char **)ref_array_get(ra2, i, NULL)));
ref_array_destroy(ra);
ref_array_destroy(ra2);
return EFAULT;
@@ -693,7 +693,7 @@ int ref_array_copy_num_test(void)
struct ref_array *ra;
struct ref_array *ra2;
int error = EOK;
- uint32_t len = 0;
+ uint32_t len = 5;
error = ref_array_create(&ra, sizeof(uint32_t), 1, NULL, NULL);
if (error) {
@@ -703,7 +703,7 @@ int ref_array_copy_num_test(void)
RAOUT(ref_array_debug(ra, 1));
- for (i=0; i<5; i++) {
+ for (i = 0; i < len; i++) {
error = ref_array_append(ra, &i);
if (error) {
ref_array_destroy(ra);