@@ -70,61 +70,38 @@ int main(int argc, const char** argv)
7070 char * buffer = (char * )malloc (bufferSize );
7171 void * out = malloc (outSize );
7272 void * roundtrip = malloc (dataSize );
73+ int _exit_code = 1 ;
7374 (void )argc ;
7475 (void )argv ;
75- int _exit_code = 0 ;
7676
7777 if (!buffer || !out || !roundtrip || !cctx || !dctx ) {
7878 fprintf (stderr , "Allocation failure\n" );
79- _exit_code = 1 ;
80- goto _cleanup ;
79+ goto cleanup ;
8180 }
8281
83- if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_windowLog , 31 ))) {
84- _exit_code = 1 ;
85- goto _cleanup ;
86- }
87- if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_nbWorkers , 1 ))) {
88- _exit_code = 1 ;
89- goto _cleanup ;
90- }
91- if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_overlapLog , 9 ))) {
92- _exit_code = 1 ;
93- goto _cleanup ;
94- }
95- if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_checksumFlag , 1 ))) {
96- _exit_code = 1 ;
97- goto _cleanup ;
98- }
99- if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_strategy , ZSTD_btopt ))) {
100- _exit_code = 1 ;
101- goto _cleanup ;
102- }
103- if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_targetLength , 7 ))) {
104- _exit_code = 1 ;
105- goto _cleanup ;
106- }
107- if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_minMatch , 7 ))) {
108- _exit_code = 1 ;
109- goto _cleanup ;
110- }
111- if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_searchLog , 1 ))) {
112- _exit_code = 1 ;
113- goto _cleanup ;
114- }
115- if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_hashLog , 10 ))) {
116- _exit_code = 1 ;
117- goto _cleanup ;
118- }
119- if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_chainLog , 10 ))) {
120- _exit_code = 1 ;
121- goto _cleanup ;
122- }
82+ if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_windowLog , 31 )))
83+ goto cleanup ;
84+ if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_nbWorkers , 1 )))
85+ goto cleanup ;
86+ if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_overlapLog , 9 )))
87+ goto cleanup ;
88+ if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_checksumFlag , 1 )))
89+ goto cleanup ;
90+ if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_strategy , ZSTD_btopt )))
91+ goto cleanup ;
92+ if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_targetLength , 7 )))
93+ goto cleanup ;
94+ if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_minMatch , 7 )))
95+ goto cleanup ;
96+ if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_searchLog , 1 )))
97+ goto cleanup ;
98+ if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_hashLog , 10 )))
99+ goto cleanup ;
100+ if (ZSTD_isError (ZSTD_CCtx_setParameter (cctx , ZSTD_c_chainLog , 10 )))
101+ goto cleanup ;
123102
124- if (ZSTD_isError (ZSTD_DCtx_setParameter (dctx , ZSTD_d_windowLogMax , 31 ))) {
125- _exit_code = 1 ;
126- goto _cleanup ;
127- }
103+ if (ZSTD_isError (ZSTD_DCtx_setParameter (dctx , ZSTD_d_windowLogMax , 31 )))
104+ goto cleanup ;
128105
129106 RDG_genBuffer (buffer , bufferSize , 1.0 , 0.0 , 0xbeefcafe );
130107
@@ -133,21 +110,18 @@ int main(int argc, const char** argv)
133110 int i ;
134111 for (i = 0 ; i < 10 ; ++ i ) {
135112 fprintf (stderr , "Compressing 1 GB\n" );
136- if (compress (cctx , dctx , out , outSize , buffer , dataSize , roundtrip , ZSTD_e_continue )) {
137- _exit_code = 1 ;
138- goto _cleanup ;
139- }
113+ if (compress (cctx , dctx , out , outSize , buffer , dataSize , roundtrip , ZSTD_e_continue ))
114+ goto cleanup ;
140115 }
141116 }
142117 fprintf (stderr , "Compressing 1 GB\n" );
143- if (compress (cctx , dctx , out , outSize , buffer , dataSize , roundtrip , ZSTD_e_end )) {
144- _exit_code = 1 ;
145- goto _cleanup ;
146- }
118+ if (compress (cctx , dctx , out , outSize , buffer , dataSize , roundtrip , ZSTD_e_end ))
119+ goto cleanup ;
147120
121+ _exit_code = 0 ;
148122 fprintf (stderr , "Success!\n" );
149123
150- _cleanup :
124+ cleanup :
151125 free (roundtrip );
152126 free (out );
153127 free (buffer );
0 commit comments