Skip to content

Commit 5968729

Browse files
committed
change: error message
1 parent 147b93d commit 5968729

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

zstd.c

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ ZEND_FUNCTION(zstd_uncompress)
225225

226226
if (ZSTD_IS_ERROR(result)) {
227227
zend_string_efree(output);
228-
ZSTD_WARNING("can not decompress stream");
228+
ZSTD_WARNING("%s", ZSTD_getErrorName(result));
229229
RETURN_FALSE;
230230
}
231231

@@ -237,15 +237,15 @@ ZEND_FUNCTION(zstd_uncompress)
237237
stream = ZSTD_createDStream();
238238
if (stream == NULL) {
239239
zend_string_efree(output);
240-
ZSTD_WARNING("can not create stream");
240+
ZSTD_WARNING("failed to create decompress context");
241241
RETURN_FALSE;
242242
}
243243

244244
result = ZSTD_initDStream(stream);
245245
if (ZSTD_IS_ERROR(result)) {
246246
zend_string_efree(output);
247247
ZSTD_freeDStream(stream);
248-
ZSTD_WARNING("can not init stream");
248+
ZSTD_WARNING("%s", ZSTD_getErrorName(result));
249249
RETURN_FALSE;
250250
}
251251

@@ -268,7 +268,7 @@ ZEND_FUNCTION(zstd_uncompress)
268268
if (ZSTD_IS_ERROR(result)) {
269269
zend_string_efree(output);
270270
ZSTD_freeDStream(stream);
271-
ZSTD_WARNING("can not decompress stream");
271+
ZSTD_WARNING("%s", ZSTD_getErrorName(result));
272272
RETURN_FALSE;
273273
}
274274

@@ -308,14 +308,14 @@ ZEND_FUNCTION(zstd_compress_dict)
308308

309309
cctx = ZSTD_createCCtx();
310310
if (cctx == NULL) {
311-
ZSTD_WARNING("ZSTD_createCCtx() error");
311+
ZSTD_WARNING("failed to create compress context");
312312
RETURN_FALSE;
313313
}
314314

315315
cdict = ZSTD_createCDict(dict, dict_len, (int) level);
316316
if (!cdict) {
317317
ZSTD_freeCStream(cctx);
318-
ZSTD_WARNING("ZSTD_createCDict() error");
318+
ZSTD_WARNING("failed to load dictionary");
319319
RETURN_FALSE;
320320
}
321321

@@ -366,7 +366,7 @@ ZEND_FUNCTION(zstd_uncompress_dict)
366366

367367
ddict = ZSTD_createDDict(dict, dict_len);
368368
if (!ddict) {
369-
ZSTD_WARNING("ZSTD_createDDict() error");
369+
ZSTD_WARNING("failed to load dictionary");
370370
RETURN_FALSE;
371371
}
372372

@@ -376,7 +376,7 @@ ZEND_FUNCTION(zstd_uncompress_dict)
376376
if (dctx == NULL) {
377377
zend_string_efree(output);
378378
ZSTD_freeDDict(ddict);
379-
ZSTD_WARNING("ZSTD_createDCtx() error");
379+
ZSTD_WARNING("failed to create decompress context");
380380
RETURN_FALSE;
381381
}
382382

@@ -496,8 +496,7 @@ static int php_zstd_comp_flush_or_end(php_zstd_stream_data *self, int end)
496496
res = ZSTD_compressStream2(self->cctx, &self->output, &in,
497497
end ? ZSTD_e_end : ZSTD_e_flush);
498498
if (ZSTD_isError(res)) {
499-
php_error_docref(NULL, E_WARNING,
500-
"libzstd error %s\n", ZSTD_getErrorName(res));
499+
ZSTD_WARNING("zstd: %s\n", ZSTD_getErrorName(res));
501500
ret = EOF;
502501
}
503502
php_stream_write(self->stream, self->output.dst, self->output.pos);
@@ -578,8 +577,7 @@ static ssize_t php_zstd_decomp_read(php_stream *stream, char *buf, size_t count)
578577
res = ZSTD_decompressStream(self->dctx,
579578
&self->output, &self->input);
580579
if (ZSTD_IS_ERROR(res)) {
581-
php_error_docref(NULL, E_WARNING,
582-
"libzstd error %s\n", ZSTD_getErrorName(res));
580+
ZSTD_WARNING("zstd: %s\n", ZSTD_getErrorName(res));
583581
#if PHP_VERSION_ID >= 70400
584582
return -1;
585583
#endif
@@ -619,8 +617,7 @@ php_zstd_comp_write(php_stream *stream, const char *buf, size_t count)
619617
res = ZSTD_compressStream2(self->cctx, &self->output,
620618
&in, ZSTD_e_continue);
621619
if (ZSTD_isError(res)) {
622-
php_error_docref(NULL, E_WARNING,
623-
"libzstd error %s\n", ZSTD_getErrorName(res));
620+
ZSTD_WARNING("zstd: %s\n", ZSTD_getErrorName(res));
624621
#if PHP_VERSION_ID >= 70400
625622
return -1;
626623
#endif
@@ -717,9 +714,8 @@ php_stream_zstd_opener(
717714
}
718715

719716
if (level > ZSTD_maxCLevel()) {
720-
php_error_docref(NULL, E_WARNING,
721-
"zstd: compression level (%d) must be less than %d",
722-
level, ZSTD_maxCLevel());
717+
ZSTD_WARNING("zstd: compression level (%d) must be less than %d",
718+
level, ZSTD_maxCLevel());
723719
level = ZSTD_maxCLevel();
724720
}
725721

@@ -736,8 +732,7 @@ php_stream_zstd_opener(
736732
self->dctx = NULL;
737733
self->cctx = ZSTD_createCCtx();
738734
if (!self->cctx) {
739-
php_error_docref(NULL, E_WARNING,
740-
"zstd: compression context failed");
735+
ZSTD_WARNING("zstd: compression context failed");
741736
php_stream_close(self->stream);
742737
efree(self);
743738
return NULL;
@@ -755,8 +750,7 @@ php_stream_zstd_opener(
755750
} else {
756751
self->dctx = ZSTD_createDCtx();
757752
if (!self->dctx) {
758-
php_error_docref(NULL, E_WARNING,
759-
"zstd: compression context failed");
753+
ZSTD_WARNING("zstd: compression context failed");
760754
php_stream_close(self->stream);
761755
efree(self);
762756
return NULL;
@@ -941,7 +935,7 @@ php_zstd_output_handler_load_dict(php_zstd_context *ctx, int level)
941935
REPORT_ERRORS, // | USE_PATH
942936
NULL, context);
943937
if (!stream) {
944-
ZSTD_WARNING("could not open dictionary stream: %s", dict);
938+
ZSTD_WARNING("failed to open dictionary stream: %s", dict);
945939
return;
946940
}
947941

0 commit comments

Comments
 (0)