summaryrefslogtreecommitdiffstats
path: root/29.patch
blob: fb4103cca24c6cc1e14ccbd407c9e2c7b3b38ab0 (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
From ba797b3c50e3746649cdd39f17a4f875227dff15 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Mon, 22 Jun 2020 12:46:30 +0200
Subject: [PATCH 1/3] hounours system CXXFLAGS

---
 config.m4 | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/config.m4 b/config.m4
index 5b3872c..d51d38e 100644
--- a/config.m4
+++ b/config.m4
@@ -18,8 +18,6 @@ dnl Make sure that the comment is aligned:
 [  --with-pdlib             Include pdlib support])
 
 if test "$PHP_PDLIB" != "no"; then
-  dnl using C++11
-  CXXFLAGS="-std=c++11"
   PHP_REQUIRE_CXX()
   PHP_ADD_LIBRARY(stdc++, 1, PDLIB_SHARED_LIBADD)
   PHP_SUBST(PDLIB_SHARED_LIBADD)
@@ -49,5 +47,6 @@ if test "$PHP_PDLIB" != "no"; then
   PHP_EVAL_LIBLINE($LIBDLIB_LIBDIR, PDLIB_SHARED_LIBADD)
   PHP_EVAL_INCLINE($LIBDLIB_CFLAGS)
 
-  PHP_NEW_EXTENSION(pdlib, $pdlib_src_files, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, cxx)
+  dnl using C++11
+  PHP_NEW_EXTENSION(pdlib, $pdlib_src_files, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -std=c++11, cxx)
 fi

From 8f424195e0ca1bd27c5d711f74d9357cd4a1a4bc Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Mon, 22 Jun 2020 12:47:43 +0200
Subject: [PATCH 2/3] fix unused variables

---
 pdlib.cc | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/pdlib.cc b/pdlib.cc
index 76bf514..b2afe4c 100644
--- a/pdlib.cc
+++ b/pdlib.cc
@@ -38,9 +38,6 @@ extern "C" {
 ZEND_DECLARE_MODULE_GLOBALS(pdlib)
 */
 
-/* True global resources - no need for thread safety here */
-static int le_pdlib;
-
 static zend_class_entry *cnn_face_detection_ce = nullptr;
 static zend_object_handlers cnn_face_detection_obj_handlers;
 
@@ -70,7 +67,7 @@ PHP_INI_END()
 PHP_FUNCTION(confirm_pdlib_compiled)
 {
 	char *arg = NULL;
-	size_t arg_len, len;
+	size_t arg_len;
 	zend_string *strg;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &arg, &arg_len) == FAILURE) {

From 912ab43641cb0d9530f2e501358c48e9fe1cf608 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Mon, 22 Jun 2020 12:54:12 +0200
Subject: [PATCH 3/3] fix [-Werror=format-security]

---
 src/chinese_whispers.cc        | 2 +-
 src/cnn_face_detection.cc      | 5 ++---
 src/face_landmark_detection.cc | 8 ++++----
 src/face_recognition.cc        | 4 ++--
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/chinese_whispers.cc b/src/chinese_whispers.cc
index 026ef13..0653f9b 100644
--- a/src/chinese_whispers.cc
+++ b/src/chinese_whispers.cc
@@ -97,7 +97,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
 		}
 	} catch (exception& e)
 	{
-		zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what());
+		zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
 		return;
 	}
 }
diff --git a/src/cnn_face_detection.cc b/src/cnn_face_detection.cc
index 83ea66f..a989e80 100644
--- a/src/cnn_face_detection.cc
+++ b/src/cnn_face_detection.cc
@@ -42,7 +42,7 @@ PHP_METHOD(CnnFaceDetection, __construct)
 		deserialize(cnn_face_detection_model_path) >> *pnet;
 		cfd->net = pnet;
 	} catch (exception& e) {
-		zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what());
+		zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
 		return;
 	}
 }
@@ -77,7 +77,6 @@ PHP_METHOD(CnnFaceDetection, detect)
 
 		net_type *pnet = cfd->net;
 		auto dets = (*pnet)(img);
-		int rect_count = 0;
 		array_init(return_value);
 
 		// Scale the detection locations back to the original image size
@@ -101,7 +100,7 @@ PHP_METHOD(CnnFaceDetection, detect)
 	}
 	catch (exception& e)
 	{
-		zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what());
+		zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
 		return;
 	}
 }
diff --git a/src/face_landmark_detection.cc b/src/face_landmark_detection.cc
index 8336964..51139f6 100644
--- a/src/face_landmark_detection.cc
+++ b/src/face_landmark_detection.cc
@@ -52,7 +52,7 @@ PHP_FUNCTION(dlib_face_landmark_detection)
 
             zval ARRAY_NAME_WITH_INDEX(face, j);
             array_init(&ARRAY_NAME_WITH_INDEX(face, j));
-            for (int k = 0; k < shape.num_parts(); k++) {
+            for (unsigned int k = 0; k < shape.num_parts(); k++) {
                 zval ARRAY_NAME_WITH_INDEX(part, k);
                 array_init(&ARRAY_NAME_WITH_INDEX(part, k));
                 dlib::point p = shape.part(k);
@@ -95,7 +95,7 @@ PHP_METHOD(FaceLandmarkDetection, __construct)
         fld->sp = new shape_predictor;
         deserialize(shape_predictor_file_path) >> *(fld->sp);
     } catch (exception& e) {
-        zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what());
+        zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
         return;
     }
 }
@@ -151,7 +151,7 @@ PHP_METHOD(FaceLandmarkDetection, detect)
         array_init(&rect_arr);
         array_init(&parts_arr);
 
-        for (int i = 0; i < shape.num_parts(); i++) {
+        for (unsigned int i = 0; i < shape.num_parts(); i++) {
             zval part;
             array_init(&part);
             dlib::point p = shape.part(i);
@@ -169,7 +169,7 @@ PHP_METHOD(FaceLandmarkDetection, detect)
         add_assoc_zval(return_value, "rect", &rect_arr);
         add_assoc_zval(return_value, "parts", &parts_arr);
     } catch (exception& e) {
-        zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what());
+        zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
         return;
     }
 }
diff --git a/src/face_recognition.cc b/src/face_recognition.cc
index 99a3d97..401e964 100644
--- a/src/face_recognition.cc
+++ b/src/face_recognition.cc
@@ -37,7 +37,7 @@ PHP_METHOD(FaceRecognition, __construct)
         fr->net = new anet_type;
         deserialize(face_recognition_model_path) >> *(fr->net);
     } catch (exception& e) {
-        zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what());
+        zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
         return;
     }
 }
@@ -183,7 +183,7 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
             add_next_index_double(return_value, d);
         }
     } catch (exception& e) {
-        zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what());
+        zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
         return;
     }
 }