@@ -697,22 +697,26 @@ static BMK_benchOutcome_t BMK_benchCLevel(const void* srcBuffer, size_t benchedS
697697 displayLevel , displayName , adv );
698698}
699699
700- BMK_benchOutcome_t BMK_syntheticTest (int cLevel , double compressibility ,
701- const ZSTD_compressionParameters * compressionParams ,
702- int displayLevel , const BMK_advancedParams_t * adv )
700+ int BMK_syntheticTest (int cLevel , double compressibility ,
701+ const ZSTD_compressionParameters * compressionParams ,
702+ int displayLevel , const BMK_advancedParams_t * adv )
703703{
704704 char name [20 ] = {0 };
705705 size_t const benchedSize = 10000000 ;
706706 void * srcBuffer ;
707707 BMK_benchOutcome_t res ;
708708
709709 if (cLevel > ZSTD_maxCLevel ()) {
710- RETURN_ERROR (15 , BMK_benchOutcome_t , "Invalid Compression Level" );
710+ DISPLAYLEVEL (1 , "Invalid Compression Level" );
711+ return 15 ;
711712 }
712713
713714 /* Memory allocation */
714715 srcBuffer = malloc (benchedSize );
715- if (!srcBuffer ) RETURN_ERROR (21 , BMK_benchOutcome_t , "not enough memory" );
716+ if (!srcBuffer ) {
717+ DISPLAYLEVEL (1 , "allocation error : not enough memory" );
718+ return 16 ;
719+ }
716720
717721 /* Fill input buffer */
718722 RDG_genBuffer (srcBuffer , benchedSize , compressibility , 0.0 , 0 );
@@ -728,7 +732,7 @@ BMK_benchOutcome_t BMK_syntheticTest(int cLevel, double compressibility,
728732 /* clean up */
729733 free (srcBuffer );
730734
731- return res ;
735+ return ! BMK_isSuccessful_benchOutcome ( res ) ;
732736}
733737
734738
@@ -790,7 +794,7 @@ static int BMK_loadFiles(void* buffer, size_t bufferSize,
790794 return 0 ;
791795}
792796
793- BMK_benchOutcome_t BMK_benchFilesAdvanced (
797+ int BMK_benchFilesAdvanced (
794798 const char * const * fileNamesTable , unsigned nbFiles ,
795799 const char * dictFileName , int cLevel ,
796800 const ZSTD_compressionParameters * compressionParams ,
@@ -805,38 +809,47 @@ BMK_benchOutcome_t BMK_benchFilesAdvanced(
805809 U64 const totalSizeToLoad = UTIL_getTotalFileSize (fileNamesTable , nbFiles );
806810
807811 if (!nbFiles ) {
808- RETURN_ERROR (14 , BMK_benchOutcome_t , "No Files to Benchmark" );
812+ DISPLAYLEVEL (1 , "No Files to Benchmark" );
813+ return 13 ;
809814 }
810815
811816 if (cLevel > ZSTD_maxCLevel ()) {
812- RETURN_ERROR (15 , BMK_benchOutcome_t , "Invalid Compression Level" );
817+ DISPLAYLEVEL (1 , "Invalid Compression Level" );
818+ return 14 ;
813819 }
814820
815821 if (totalSizeToLoad == UTIL_FILESIZE_UNKNOWN ) {
816- RETURN_ERROR (9 , BMK_benchOutcome_t , "Error loading files" );
822+ DISPLAYLEVEL (1 , "Error loading files" );
823+ return 15 ;
817824 }
818825
819826 fileSizes = (size_t * )calloc (nbFiles , sizeof (size_t ));
820- if (!fileSizes ) RETURN_ERROR (12 , BMK_benchOutcome_t , "not enough memory for fileSizes" );
827+ if (!fileSizes ) {
828+ DISPLAYLEVEL (1 , "not enough memory for fileSizes" );
829+ return 16 ;
830+ }
821831
822832 /* Load dictionary */
823833 if (dictFileName != NULL ) {
824834 U64 const dictFileSize = UTIL_getFileSize (dictFileName );
825835 if (dictFileSize == UTIL_FILESIZE_UNKNOWN ) {
826836 DISPLAYLEVEL (1 , "error loading %s : %s \n" , dictFileName , strerror (errno ));
827837 free (fileSizes );
828- RETURN_ERROR (9 , BMK_benchOutcome_t , "benchmark aborted" );
838+ DISPLAYLEVEL (1 , "benchmark aborted" );
839+ return 17 ;
829840 }
830841 if (dictFileSize > 64 MB ) {
831842 free (fileSizes );
832- RETURN_ERROR (10 , BMK_benchOutcome_t , "dictionary file %s too large" , dictFileName );
843+ DISPLAYLEVEL (1 , "dictionary file %s too large" , dictFileName );
844+ return 18 ;
833845 }
834846 dictBufferSize = (size_t )dictFileSize ;
835847 dictBuffer = malloc (dictBufferSize );
836848 if (dictBuffer == NULL ) {
837849 free (fileSizes );
838- RETURN_ERROR ( 11 , BMK_benchOutcome_t , "not enough memory for dictionary (%u bytes)" ,
850+ DISPLAYLEVEL ( 1 , "not enough memory for dictionary (%u bytes)" ,
839851 (unsigned )dictBufferSize );
852+ return 19 ;
840853 }
841854
842855 { int const errorCode = BMK_loadFiles (dictBuffer , dictBufferSize ,
@@ -858,7 +871,8 @@ BMK_benchOutcome_t BMK_benchFilesAdvanced(
858871 if (!srcBuffer ) {
859872 free (dictBuffer );
860873 free (fileSizes );
861- RETURN_ERROR (12 , BMK_benchOutcome_t , "not enough memory" );
874+ DISPLAYLEVEL (1 , "not enough memory for srcBuffer" );
875+ return 20 ;
862876 }
863877
864878 /* Load input buffer */
@@ -886,12 +900,11 @@ BMK_benchOutcome_t BMK_benchFilesAdvanced(
886900 free (srcBuffer );
887901 free (dictBuffer );
888902 free (fileSizes );
889- return res ;
903+ return ! BMK_isSuccessful_benchOutcome ( res ) ;
890904}
891905
892906
893- BMK_benchOutcome_t BMK_benchFiles (
894- const char * const * fileNamesTable , unsigned nbFiles ,
907+ int BMK_benchFiles (const char * const * fileNamesTable , unsigned nbFiles ,
895908 const char * dictFileName ,
896909 int cLevel , const ZSTD_compressionParameters * compressionParams ,
897910 int displayLevel )
0 commit comments