app/compress-perf: fix coverity issue
PATCH 1/1 app/compress-perf: fix coverity issue
Removes possible assignment of a signed value
to an unsigned parameter. Also makes dictionary
an optional argument
--- .../comp_perf_options_parse.c | 2 +- app/test-compress-perf/main.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-)
app/test-compress-perf/comp_perf_options_parse.c +1 -1
@@ -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 } };
app/test-compress-perf/main.c +13 -6
@@ -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; }
Signature · 1 line
2.31.1
Recheck-request: rebase=main, github-robot, iol-sample-apps-testing, iol-compile-amd64-testing
________________________________
From: Sameer Vaze <[email protected]>
Sent: Friday, October 24, 2025 12:47 PM
Cc: [email protected] <[email protected]>; Sameer Vaze <[email protected]>
Subject: [PATCH] app/compress-perf: fix coverity issue
Removes possible assignment of a signed value
to an unsigned parameter. Also makes dictionary
an optional argument
--- .../comp_perf_options_parse.c | 2 +- app/test-compress-perf/main.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-)
app/test-compress-perf/comp_perf_options_parse.c +1 -1
@@ -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 } };
app/test-compress-perf/main.c +13 -6
@@ -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
Recheck-request: github-robot
________________________________
From: Sameer Vaze <[email protected]>
Sent: Tuesday, October 28, 2025 11:20 AM
Cc: [email protected] <[email protected]>; Sameer Vaze <[email protected]>
Subject: Re: [PATCH] app/compress-perf: fix coverity issue
Recheck-request: rebase=main, github-robot, iol-sample-apps-testing, iol-compile-amd64-testing
________________________________
From: Sameer Vaze <[email protected]>
Sent: Friday, October 24, 2025 12:47 PM
Cc: [email protected] <[email protected]>; Sameer Vaze <[email protected]>
Subject: [PATCH] app/compress-perf: fix coverity issue
Removes possible assignment of a signed value
to an unsigned parameter. Also makes dictionary
an optional argument
--- .../comp_perf_options_parse.c | 2 +- app/test-compress-perf/main.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-)
app/test-compress-perf/comp_perf_options_parse.c +1 -1
@@ -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 } };
app/test-compress-perf/main.c +13 -6
@@ -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