From 0ccdecf6ab27a71e98e802dc8414ed030871a70c Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Mon, 24 Jan 2011 11:59:25 +0100 Subject: [PATCH 4/5] Fix error codes in other_create_test() It was possible that other_create_test() returns EOK although an error occurred. The caller then falsely assumes that struct value_obj is allocated. This should fix Coverity issue 10078. --- ini/ini_valueobj_ut.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ini/ini_valueobj_ut.c b/ini/ini_valueobj_ut.c index fd7c6b8..82951e6 100644 --- a/ini/ini_valueobj_ut.c +++ b/ini/ini_valueobj_ut.c @@ -233,7 +233,7 @@ int other_create_test(FILE *ff, struct value_obj **vo) if (strncmp(fullstr, expected, strlen(expected) + 1) != 0) { printf("The expected value is different.\n%s\n", fullstr); value_destroy(new_vo); - return error; + return EINVAL; } /* Get value's origin */ @@ -247,7 +247,7 @@ int other_create_test(FILE *ff, struct value_obj **vo) if (origin != INI_VALUE_READ) { printf("The expected origin is different.\n%d\n", origin); value_destroy(new_vo); - return error; + return EINVAL; } /* Get value's line */ @@ -261,7 +261,7 @@ int other_create_test(FILE *ff, struct value_obj **vo) if (line != 1) { printf("The expected line is different.\n%d\n", origin); value_destroy(new_vo); - return error; + return EINVAL; } /* Get comment from the value */ @@ -276,7 +276,7 @@ int other_create_test(FILE *ff, struct value_obj **vo) if (ic == NULL) { printf("The expected comment to be there.\n"); value_destroy(new_vo); - return error; + return EINVAL; } VOOUT(ini_comment_print(ic, stdout)); @@ -300,7 +300,7 @@ int other_create_test(FILE *ff, struct value_obj **vo) /* But this should not happen anyways - * it will be coding error. */ - return error; + return EINVAL; } /* Put comment back */ -- 1.7.3.3