summaryrefslogtreecommitdiffstats
path: root/protocolbuffers-pr40.patch
blob: 845a55b449192c1bb99b6cc4a2a0f391775dedd3 (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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
From 9940a6576a89717a02e09d41a6cb5adf66577b70 Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Mon, 14 Apr 2014 10:45:13 +0200
Subject: [PATCH 1/2] fix various build warning (cause test failure on x86_64)

---
 json_serializer.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/json_serializer.c b/json_serializer.c
index b05e913..4f6d90d 100644
--- a/json_serializer.c
+++ b/json_serializer.c
@@ -156,7 +156,7 @@ static int _json_serializer_sint64(
 }
 
 static int _json_serializer_fixed64(
-	int64_t value,
+	uint64_t value,
 	php_protocolbuffers_scheme *scheme,
 	php_protocolbuffers_scheme_container *container,
 	void *opaque TSRMLS_DC
@@ -403,7 +403,7 @@ static php_protocolbuffers_serializer2 json_serializer = {
 };
 
 
-static const char* php_protocolbuffers_get_property_name(php_protocolbuffers_scheme_container *container, php_protocolbuffers_scheme *scheme, size_t *name_len)
+static const char* php_protocolbuffers_get_property_name(php_protocolbuffers_scheme_container *container, php_protocolbuffers_scheme *scheme, int *name_len)
 {
 	const char *name;
 	if (container->use_single_property < 1) {
@@ -634,7 +634,7 @@ static int php_protocolbuffers_json_encode_value(zval **element, php_protocolbuf
 			int32_t v;
 
 			zval_copy_ctor(&value_copy);
-			convert_to_int64(&value_copy, &v);
+			convert_to_int32(&value_copy, &v);
 			ser->serialize_sfixed32(v, scheme, container, outer TSRMLS_CC);
 			zval_dtor(&value_copy);
 			break;
@@ -751,13 +751,13 @@ int php_protocolbuffers_fetch_element2(php_protocolbuffers_scheme_container *con
 
 	if (zend_hash_find(hash, name, name_len, (void **)&tmp) == SUCCESS) {
 		*output = *tmp;
-		return 0;
 	} else {
 		if (scheme->required > 0) {
 			php_protocolbuffers_raise_error_or_exception(php_protocol_buffers_invalid_protocolbuffers_exception_class_entry, E_WARNING, 0, "the class does not declared required property `%s`. probably you missed declaration", scheme->name);
 			return 1;
 		}
 	}
+	return 0;
 }
 
 
@@ -768,7 +768,6 @@ int php_protocolbuffers_encode_jsonserialize(zval *klass, php_protocolbuffers_sc
 	HashTable *hash = NULL;
 	zval **c = NULL;
 	zval *target = *result;
-	php_protocolbuffers_serializer2 *ser = &json_serializer;
 
 	if (container->use_single_property < 1) {
 		hash = Z_OBJPROP_P(klass);
-- 
1.9.1


From 38b24cce0ebce9485149fb611e00338b0a48b670 Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Mon, 14 Apr 2014 11:05:24 +0200
Subject: [PATCH 2/2] fix more build warnings

---
 enum.c                    | 6 +++---
 enum_descriptor_builder.c | 2 +-
 helper.c                  | 6 +++---
 message.c                 | 2 --
 serializer.c              | 2 +-
 unknown_field_set.c       | 2 +-
 6 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/enum.c b/enum.c
index 96c1005..058ebbd 100644
--- a/enum.c
+++ b/enum.c
@@ -26,7 +26,7 @@ PHP_METHOD(protocolbuffers_enum, isValid)
 	return;
 #else
 	long value;
-	zval *result, *result2;
+	zval *result;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
 		"l", &value) == FAILURE) {
@@ -71,7 +71,7 @@ PHP_METHOD(protocolbuffers_enum, getName)
 	return;
 #else
 	long value;
-	zval *result, *result2;
+	zval *result;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
 		"l", &value) == FAILURE) {
@@ -79,7 +79,7 @@ PHP_METHOD(protocolbuffers_enum, getName)
 	}
 
 	if (zend_call_method_with_0_params(NULL, EG(called_scope), NULL, "getenumdescriptor", &result)) {
-		zval *values, **entry, **key;
+		zval *values, **entry;
 		HashPosition pos;
 
 		if (!instanceof_function_ex(Z_OBJCE_P(result), php_protocol_buffers_enum_descriptor_class_entry, 0 TSRMLS_CC)) {
diff --git a/enum_descriptor_builder.c b/enum_descriptor_builder.c
index 5207ab8..5f556b4 100644
--- a/enum_descriptor_builder.c
+++ b/enum_descriptor_builder.c
@@ -27,7 +27,7 @@ PHP_METHOD(protocolbuffers_enum_descriptor_builder, __construct)
 PHP_METHOD(protocolbuffers_enum_descriptor_builder, addValue)
 {
 	zval *instance = getThis();
-	zval *value, **fields, *name, *value2;
+	zval *value, **fields, *name;
 	zend_bool force = 0;
 	char *property;
 	int property_len;
diff --git a/helper.c b/helper.c
index 3daaf8d..1b89b97 100644
--- a/helper.c
+++ b/helper.c
@@ -35,7 +35,7 @@ static void php_protocolbuffers_helper_debug_zval(zval **value TSRMLS_DC)
 	zval *val = *value;
 
 	php_printf("{\n");
-	php_printf("  address: 0x%x,\n", (unsigned int)val);
+	php_printf("  address: 0x%lx,\n", (unsigned long)val);
 	php_printf("  type: %d,\n", val->type);
 	php_printf("  is_ref: %d,\n", PZVAL_IS_REF(val));
 	php_printf("  refcount: %d,\n", Z_REFCOUNT_PP(value));
@@ -44,14 +44,14 @@ static void php_protocolbuffers_helper_debug_zval(zval **value TSRMLS_DC)
 	php_printf("    double: %f,\n", val->value.dval);
 	if (val->type == 4) {
 		php_printf("    ht: {\n");
-		php_printf("      address: 0x%x,\n", (unsigned int)val->value.ht);
+		php_printf("      address: 0x%lx,\n", (unsigned long)val->value.ht);
 		php_printf("      num_of_elements: %d,\n", (unsigned int)val->value.ht->nNumOfElements);
 		php_printf("      next_free_elements: %d,\n", (unsigned int)val->value.ht->nNextFreeElement);
 		php_printf("    },\n");
 	}
 	php_printf("    object: {\n");
 	php_printf("      handle: 0x%x,\n", val->value.obj.handle);
-	php_printf("      handlers: 0x%x,\n", (unsigned int)val->value.obj.handlers);
+	php_printf("      handlers: 0x%lx,\n", (unsigned long)val->value.obj.handlers);
 	php_printf("    },\n");
 	php_printf("  }\n");
 	php_printf("}\n");
diff --git a/message.c b/message.c
index 58b38dc..d051963 100644
--- a/message.c
+++ b/message.c
@@ -1571,7 +1571,6 @@ PHP_METHOD(protocolbuffers_message, clearExtension)
 
 	if (zend_hash_find(htt, n, n_len, (void **)&e) == SUCCESS) {
 		zval *tmp;
-		ulong hval;
 		if (is_mangled) {
 			efree(n);
 		}
@@ -1676,7 +1675,6 @@ PHP_METHOD(protocolbuffers_message, jsonSerialize)
 PHP_METHOD(protocolbuffers_message, toArray)
 {
 	zval *instance = getThis(), *result = NULL;
-	zend_class_entry **json;
 
 	if (php_protocolbuffers_jsonserialize(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1, Z_OBJCE_P(instance), instance, &result) == 0) {
 		RETURN_ZVAL(result, 0, 1);
diff --git a/serializer.c b/serializer.c
index 83cdebc..75dfaf8 100644
--- a/serializer.c
+++ b/serializer.c
@@ -723,13 +723,13 @@ int php_protocolbuffers_fetch_element(INTERNAL_FUNCTION_PARAMETERS, php_protocol
 
 	if (zend_hash_find(hash, name, name_len, (void **)&tmp) == SUCCESS) {
 		*output = *tmp;
-		return 0;
 	} else {
 		if (scheme->required > 0) {
 			zend_throw_exception_ex(php_protocol_buffers_invalid_protocolbuffers_exception_class_entry, 0 TSRMLS_CC, "the class does not declared required property `%s`. probably you missed declaration", scheme->name);
 			return 1;
 		}
 	}
+	return 0;
 }
 
 int php_protocolbuffers_encode_message(INTERNAL_FUNCTION_PARAMETERS, zval *klass, php_protocolbuffers_scheme_container *container, php_protocolbuffers_serializer **serializer)
diff --git a/unknown_field_set.c b/unknown_field_set.c
index c437524..7cf2e9c 100644
--- a/unknown_field_set.c
+++ b/unknown_field_set.c
@@ -66,7 +66,7 @@ void php_protocolbuffers_unknown_field_set_properties_init(zval *object TSRMLS_D
 
 void php_protocolbuffers_unknown_field_clear(INTERNAL_FUNCTION_PARAMETERS, zval *instance)
 {
-	zval *fields = NULL, **prior_fields = NULL;
+	zval *fields = NULL;
 	char *name = {0};
 	int name_len = 0;
 
-- 
1.9.1