Skip to content

Commit 29cd566

Browse files
committed
fix arginfo and build warnings
1 parent 84e8742 commit 29cd566

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

utils.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include "php.h"
2222

23-
void *memmerge(char *ptr1, char *ptr2, size_t len1, size_t len2) /* {{{ */
23+
void *memmerge(void *ptr1, void *ptr2, size_t len1, size_t len2) /* {{{ */
2424
{
2525
if ((ptr2 == NULL) || (len2 < 1)) {
2626
return ptr1;
@@ -29,7 +29,7 @@ void *memmerge(char *ptr1, char *ptr2, size_t len1, size_t len2) /* {{{ */
2929
if (ptr1 == NULL) {
3030
return NULL;
3131
}
32-
memcpy(ptr1 + len1, ptr2, len2);
32+
memcpy((char *)ptr1 + len1, ptr2, len2);
3333
return ptr1;
3434
}
3535
/* }}} */

utils.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/* Merges two memory fragments by reallocating the first one.
2525
Returns a pointer to the first memory segment or, if reallocated, to the new
2626
address. */
27-
void *memmerge(char *ptr1, char *ptr2, size_t len1, size_t len2);
27+
void *memmerge(void *ptr1, void *ptr2, size_t len1, size_t len2);
2828

2929
#endif
3030

xz.c

+13-10
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,12 @@
3838
#endif
3939

4040
/* {{{ arginfo */
41-
ZEND_BEGIN_ARG_INFO(arginfo_void, 0)
42-
ZEND_END_ARG_INFO()
43-
4441
ZEND_BEGIN_ARG_INFO(arginfo_xzread, 0)
4542
ZEND_ARG_INFO(0, fp)
4643
ZEND_ARG_INFO(0, length)
4744
ZEND_END_ARG_INFO()
4845

49-
ZEND_BEGIN_ARG_INFO(arginfo_xzwrite, 0)
46+
ZEND_BEGIN_ARG_INFO_EX(arginfo_xzwrite, 0, 0, 2)
5047
ZEND_ARG_INFO(0, fp)
5148
ZEND_ARG_INFO(0, str)
5249
ZEND_ARG_INFO(0, length)
@@ -67,13 +64,19 @@ ZEND_END_ARG_INFO()
6764
ZEND_BEGIN_ARG_INFO(arginfo_xzdecode, 0)
6865
ZEND_ARG_INFO(0, str)
6966
ZEND_END_ARG_INFO()
67+
68+
ZEND_BEGIN_ARG_INFO_EX(arginfo_xzopen, 0, 0, 2)
69+
ZEND_ARG_INFO(0, filename)
70+
ZEND_ARG_INFO(0, mode)
71+
ZEND_ARG_INFO(0, compression_level)
72+
ZEND_END_ARG_INFO()
7073
/* }}} */
7174

7275
/* {{{ xz_functions[] */
7376
static const zend_function_entry xz_functions[] = {
74-
PHP_FE(xzdecode, arginfo_void)
75-
PHP_FE(xzopen, arginfo_void)
76-
PHP_FE(xzencode, arginfo_void)
77+
PHP_FE(xzdecode, arginfo_xzdecode)
78+
PHP_FE(xzopen, arginfo_xzopen)
79+
PHP_FE(xzencode, arginfo_xzencode)
7780
PHP_FALIAS(xzread, fread, arginfo_xzread)
7881
PHP_FALIAS(xzwrite, fwrite, arginfo_xzwrite)
7982
PHP_FALIAS(xzclose, fclose, arginfo_xzclose)
@@ -247,7 +250,7 @@ PHP_FUNCTION(xzencode)
247250

248251
lzma_end(&strm);
249252

250-
RETURN_STRINGL(out, out_len);
253+
RETURN_STRINGL((char *)out, out_len);
251254
}
252255
/* }}} */
253256

@@ -299,14 +302,14 @@ PHP_FUNCTION(xzdecode)
299302
strm.next_out = buff;
300303
}
301304
}
302-
305+
(void)status; // avoid -Wunused-but-set-variable warning
303306
/* Merging last fragment. */
304307
out = memmerge(out, buff, out_len, XZ_BUFFER_SIZE - strm.avail_out);
305308
out_len += XZ_BUFFER_SIZE - strm.avail_out;
306309

307310
lzma_end(&strm);
308311

309-
RETURN_STRINGL(out, out_len);
312+
RETURN_STRINGL((char *)out, out_len);
310313
}
311314
/* }}} */
312315

xz_fopen_wrapper.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct php_xz_stream_data_t {
5353
int fd;
5454

5555
/* The type of access required. */
56-
char mode[4];
56+
char mode[64];
5757

5858
/* Compression level used. */
5959
unsigned long level;
@@ -69,7 +69,7 @@ static int php_xz_decompress(struct php_xz_stream_data_t *self)
6969

7070
if (strm->avail_in == 0 && !php_stream_eof(self->stream)) {
7171
strm->next_in = self->in_buf;
72-
strm->avail_in = php_stream_read(self->stream, self->in_buf, self->in_buf_sz);
72+
strm->avail_in = php_stream_read(self->stream, (char *)self->in_buf, self->in_buf_sz);
7373
}
7474

7575
lzma_ret ret = lzma_code(strm, action);
@@ -92,14 +92,15 @@ static int php_xz_compress(struct php_xz_stream_data_t *self)
9292
{
9393
lzma_stream *strm = &self->strm;
9494
lzma_action action = LZMA_RUN;
95-
int wrote = 0, to_write = strm->avail_in;
95+
int to_write = strm->avail_in;
9696

9797
while (strm->avail_in > 0) {
9898
lzma_ret ret = lzma_code(strm, action);
9999
size_t len = self->out_buf_sz - strm->avail_out;
100-
php_stream_write(self->stream, self->out_buf, len);
100+
php_stream_write(self->stream, (char *)self->out_buf, len);
101101
strm->next_out = self->out_buf;
102102
strm->avail_out = self->out_buf_sz;
103+
(void)ret; // avoid -Wunused-but-set-variable warning
103104
}
104105

105106
strm->next_in = self->in_buf;
@@ -266,7 +267,7 @@ static int php_xziop_close(php_stream *stream, int close_handle)
266267

267268
if (strm->avail_out < self->out_buf_sz) {
268269
size_t write_size = self->out_buf_sz - strm->avail_out;
269-
php_stream_write(self->stream, self->out_buf, write_size);
270+
php_stream_write(self->stream, (char *)self->out_buf, write_size);
270271
strm->next_out = self->out_buf;
271272
strm->avail_out = self->out_buf_sz;
272273
}

0 commit comments

Comments
 (0)