Removes possible assignment of a signed value
to an unsigned parameter. Also makes dictionary
an optional argument

Coverity issue: 490944
Fixes 568815516e88 (app/compress-perf: support dictionaries and PDCP
checksum)

Signed-off-by: Sameer Vaze <[email protected]>
---
 .../comp_perf_options_parse.c                 |  2 +-
 app/test-compress-perf/main.c                 | 19 +++++++++++++------
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/app/test-compress-perf/comp_perf_options_parse.c 
b/app/test-compress-perf/comp_perf_options_parse.c
index 49197dc290..16d31c7e90 100644
--- a/app/test-compress-perf/comp_perf_options_parse.c
+++ b/app/test-compress-perf/comp_perf_options_parse.c
@@ -660,7 +660,7 @@ static struct option lgopts[] = {
        { CPERF_LEVEL, required_argument, 0, 0 },
        { CPERF_WINDOW_SIZE, required_argument, 0, 0 },
        { CPERF_EXTERNAL_MBUFS, 0, 0, 0 },
-       { CPERF_DICTIONARY, required_argument, 0, 0 },
+       { CPERF_DICTIONARY, optional_argument, 0, 0 },
        { CPERF_CYCLECOUNT_DELAY_US, required_argument, 0, 0 },
        { NULL, 0, 0, 0 }
 };
diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c
index 11b016069c..59af073f12 100644
--- a/app/test-compress-perf/main.c
+++ b/app/test-compress-perf/main.c
@@ -355,16 +355,22 @@ comp_perf_dump_dictionary_data(struct comp_test_data 
*test_data)
                RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
                goto end;
        }
-       size_t actual_file_sz = ftell(f);
+       long file_sz = ftell(f);
        /* If extended input data size has not been set,
         * input data size = file size
         */
 
+       if (file_sz < 0) {
+               RTE_LOG(ERR, USER1, "Actual file size could not be 
determined\n");
+               goto end;
+       }
+
+       size_t actual_file_sz = (size_t)file_sz;
+
        if (test_data->dictionary_data_sz == 0)
                test_data->dictionary_data_sz = actual_file_sz;
 
-       if (test_data->dictionary_data_sz <= 0 || actual_file_sz <= 0 ||
-                       fseek(f, 0, SEEK_SET) != 0) {
+       if (fseek(f, 0, SEEK_SET) != 0) {
                RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
                goto end;
        }
@@ -386,11 +392,15 @@ comp_perf_dump_dictionary_data(struct comp_test_data 
*test_data)
 
                if (fread(data, data_to_read, 1, f) != 1) {
                        RTE_LOG(ERR, USER1, "Input file could not be read\n");
+                       if (test_data->dictionary_data)
+                               rte_free(test_data->dictionary_data);
                        goto end;
                }
                if (fseek(f, 0, SEEK_SET) != 0) {
                        RTE_LOG(ERR, USER1,
                                "Size of input could not be calculated\n");
+                       if (test_data->dictionary_data)
+                               rte_free(test_data->dictionary_data);
                        goto end;
                }
                remaining_data -= data_to_read;
@@ -414,9 +424,6 @@ comp_perf_dump_dictionary_data(struct comp_test_data 
*test_data)
        if (f)
                fclose(f);
 
-       if (test_data->dictionary_data)
-               rte_free(test_data->dictionary_data);
-
        return ret;
 }
 
-- 
2.31.1

Reply via email to