summaryrefslogtreecommitdiffstats
path: root/pr3.patch
blob: 0fe4fe9360d9f75cedaaee012de462776ec0dc1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
From 8d05ae5257dba8e077063d0023bd5cdeabf463ac Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Fri, 9 Jul 2021 16:57:55 +0200
Subject: [PATCH] fix arginfo and build warnings

---
 utils.c            |  2 +-
 utils.h            |  2 +-
 xz.c               | 23 +++++++++++++----------
 xz_fopen_wrapper.c | 11 ++++++-----
 4 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/utils.c b/utils.c
index 45884a3..fd94186 100644
--- a/utils.c
+++ b/utils.c
@@ -20,7 +20,7 @@
 
 #include "php.h"
 
-void *memmerge(char *ptr1, char *ptr2, size_t len1, size_t len2) /* {{{ */
+void *memmerge(void *ptr1, void *ptr2, size_t len1, size_t len2) /* {{{ */
 {
 	if ((ptr2 == NULL) || (len2 < 1)) {
 		return ptr1;
diff --git a/utils.h b/utils.h
index f2ccdac..929f249 100644
--- a/utils.h
+++ b/utils.h
@@ -24,7 +24,7 @@
 /* Merges two memory fragments by reallocating the first one.
    Returns a pointer to the first memory segment or, if reallocated, to the new
    address. */
-void *memmerge(char *ptr1, char *ptr2, size_t len1, size_t len2);
+void *memmerge(void *ptr1, void *ptr2, size_t len1, size_t len2);
 
 #endif
 
diff --git a/xz.c b/xz.c
index 243167d..5c80ee2 100644
--- a/xz.c
+++ b/xz.c
@@ -38,15 +38,12 @@
 #endif
 
 /* {{{ arginfo */
-ZEND_BEGIN_ARG_INFO(arginfo_void, 0)
-ZEND_END_ARG_INFO()
-
 ZEND_BEGIN_ARG_INFO(arginfo_xzread, 0)
 	ZEND_ARG_INFO(0, fp)
 	ZEND_ARG_INFO(0, length)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO(arginfo_xzwrite, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xzwrite, 0, 0, 2)
 	ZEND_ARG_INFO(0, fp)
 	ZEND_ARG_INFO(0, str)
 	ZEND_ARG_INFO(0, length)
@@ -67,13 +64,19 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_INFO(arginfo_xzdecode, 0)
 	ZEND_ARG_INFO(0, str)
 ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xzopen, 0, 0, 2)
+	ZEND_ARG_INFO(0, filename)
+	ZEND_ARG_INFO(0, mode)
+	ZEND_ARG_INFO(0, compression_level)
+ZEND_END_ARG_INFO()
 /* }}} */
 
 /* {{{ xz_functions[] */
 static const zend_function_entry xz_functions[] = {
-	PHP_FE(xzdecode, arginfo_void)
-	PHP_FE(xzopen, arginfo_void)
-	PHP_FE(xzencode, arginfo_void)
+	PHP_FE(xzdecode, arginfo_xzdecode)
+	PHP_FE(xzopen, arginfo_xzopen)
+	PHP_FE(xzencode, arginfo_xzencode)
 	PHP_FALIAS(xzread, fread, arginfo_xzread)
 	PHP_FALIAS(xzwrite, fwrite, arginfo_xzwrite)
 	PHP_FALIAS(xzclose, fclose, arginfo_xzclose)
@@ -247,7 +250,7 @@ PHP_FUNCTION(xzencode)
 
 	lzma_end(&strm);
 
-	RETURN_STRINGL(out, out_len);
+	RETURN_STRINGL((char *)out, out_len);
 }
 /* }}} */
 
@@ -299,14 +302,14 @@ PHP_FUNCTION(xzdecode)
 			strm.next_out = buff;
 		}
 	}
-
+	(void)status; // avoid -Wunused-but-set-variable warning
 	/* Merging last fragment. */
 	out = memmerge(out, buff, out_len, XZ_BUFFER_SIZE - strm.avail_out);
 	out_len += XZ_BUFFER_SIZE - strm.avail_out;
 
 	lzma_end(&strm);
 
-	RETURN_STRINGL(out, out_len);
+	RETURN_STRINGL((char *)out, out_len);
 }
 /* }}} */
 
diff --git a/xz_fopen_wrapper.c b/xz_fopen_wrapper.c
index 8bd2843..4dc75a9 100644
--- a/xz_fopen_wrapper.c
+++ b/xz_fopen_wrapper.c
@@ -53,7 +53,7 @@ struct php_xz_stream_data_t {
 	int fd;
 
 	/* The type of access required. */
-	char mode[4];
+	char mode[64];
 
 	/* Compression level used. */
 	unsigned long level;
@@ -69,7 +69,7 @@ static int php_xz_decompress(struct php_xz_stream_data_t *self)
 
 	if (strm->avail_in == 0 && !php_stream_eof(self->stream)) {
 		strm->next_in = self->in_buf;
-		strm->avail_in = php_stream_read(self->stream, self->in_buf, self->in_buf_sz);
+		strm->avail_in = php_stream_read(self->stream, (char *)self->in_buf, self->in_buf_sz);
 	}
 
 	lzma_ret ret = lzma_code(strm, action);
@@ -92,14 +92,15 @@ static int php_xz_compress(struct php_xz_stream_data_t *self)
 {
 	lzma_stream *strm = &self->strm;
 	lzma_action action = LZMA_RUN;
-	int wrote = 0, to_write = strm->avail_in;
+	int to_write = strm->avail_in;
 
 	while (strm->avail_in > 0) {
 		lzma_ret ret = lzma_code(strm, action);
 		size_t len = self->out_buf_sz - strm->avail_out;
-		php_stream_write(self->stream, self->out_buf, len);
+		php_stream_write(self->stream, (char *)self->out_buf, len);
 		strm->next_out = self->out_buf;
 		strm->avail_out = self->out_buf_sz;
+		(void)ret;  // avoid -Wunused-but-set-variable warning
 	}
 
 	strm->next_in = self->in_buf;
@@ -266,7 +267,7 @@ static int php_xziop_close(php_stream *stream, int close_handle)
 
 			if (strm->avail_out < self->out_buf_sz) {
 				size_t write_size = self->out_buf_sz - strm->avail_out;
-				php_stream_write(self->stream, self->out_buf, write_size);
+				php_stream_write(self->stream, (char *)self->out_buf, write_size);
 				strm->next_out = self->out_buf;
 				strm->avail_out = self->out_buf_sz;
 			}