Added TRMM and TRSM clBLAS wrappers

Added TRMM and TRSM clBLAS wrappers

--- test/wrapper_clblas.h
+++ test/wrapper_clblas.h
@@ -76,33 +76,33 @@

 // Calls {clblasSgemv, clblasDgemv, clblasCgemv, clblasZgemv} with the arguments forwarded.
 clblasStatus clblasXgemv(
-  clblasOrder layout, clblasTranspose tran_a, size_t m, size_t n, float alpha,
+  clblasOrder layout, clblasTranspose a_transpose, size_t m, size_t n, float alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld,
   const cl_mem x_vec, size_t x_offset, size_t x_inc, float beta,
   const cl_mem y_vec, size_t y_offset, size_t y_inc,
   cl_uint num_queues, cl_command_queue *queues,
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
-    return clblasSgemv(layout, tran_a, m, n, alpha,
+    return clblasSgemv(layout, a_transpose, m, n, alpha,
                        a_mat, a_offset, a_ld,
                        x_vec, x_offset, static_cast<int>(x_inc), beta,
                        y_vec, y_offset, static_cast<int>(y_inc),
                        num_queues, queues, num_wait_events, wait_events, events);
 }
 clblasStatus clblasXgemv(
-  clblasOrder layout, clblasTranspose tran_a, size_t m, size_t n, double alpha,
+  clblasOrder layout, clblasTranspose a_transpose, size_t m, size_t n, double alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld,
   const cl_mem x_vec, size_t x_offset, size_t x_inc, double beta,
   const cl_mem y_vec, size_t y_offset, size_t y_inc,
   cl_uint num_queues, cl_command_queue *queues,
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
-    return clblasDgemv(layout, tran_a, m, n, alpha,
+    return clblasDgemv(layout, a_transpose, m, n, alpha,
                        a_mat, a_offset, a_ld,
                        x_vec, x_offset, static_cast<int>(x_inc), beta,
                        y_vec, y_offset, static_cast<int>(y_inc),
                        num_queues, queues, num_wait_events, wait_events, events);
 }
 clblasStatus clblasXgemv(
-  clblasOrder layout, clblasTranspose tran_a, size_t m, size_t n, float2 alpha,
+  clblasOrder layout, clblasTranspose a_transpose, size_t m, size_t n, float2 alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld,
   const cl_mem x_vec, size_t x_offset, size_t x_inc, float2 beta,
   const cl_mem y_vec, size_t y_offset, size_t y_inc,
@@ -110,14 +110,14 @@
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
     auto cl_alpha = cl_float2{{alpha.real(), alpha.imag()}};
     auto cl_beta = cl_float2{{beta.real(), beta.imag()}};
-    return clblasCgemv(layout, tran_a, m, n, cl_alpha,
+    return clblasCgemv(layout, a_transpose, m, n, cl_alpha,
                        a_mat, a_offset, a_ld,
                        x_vec, x_offset, static_cast<int>(x_inc), cl_beta,
                        y_vec, y_offset, static_cast<int>(y_inc),
                        num_queues, queues, num_wait_events, wait_events, events);
 }
 clblasStatus clblasXgemv(
-  clblasOrder layout, clblasTranspose tran_a, size_t m, size_t n, double2 alpha,
+  clblasOrder layout, clblasTranspose a_transpose, size_t m, size_t n, double2 alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld,
   const cl_mem x_vec, size_t x_offset, size_t x_inc, double2 beta,
   const cl_mem y_vec, size_t y_offset, size_t y_inc,
@@ -125,7 +125,7 @@
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
     auto cl_alpha = cl_double2{{alpha.real(), alpha.imag()}};
     auto cl_beta = cl_double2{{beta.real(), beta.imag()}};
-    return clblasZgemv(layout, tran_a, m, n, cl_alpha,
+    return clblasZgemv(layout, a_transpose, m, n, cl_alpha,
                        a_mat, a_offset, a_ld,
                        x_vec, x_offset, static_cast<int>(x_inc), cl_beta,
                        y_vec, y_offset, static_cast<int>(y_inc),
@@ -137,14 +137,14 @@

 // This calls {clblasSgemm, clblasDgemm, clblasCgemm, clblasZgemm} with the arguments forwarded.
 clblasStatus clblasXgemm(
-  clblasOrder layout, clblasTranspose tran_a, clblasTranspose tran_b,
+  clblasOrder layout, clblasTranspose a_transpose, clblasTranspose b_transpose,
   size_t m, size_t n, size_t k, float alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld,
   const cl_mem b_mat, size_t b_offset, size_t b_ld, float beta,
   cl_mem c_mat, size_t c_offset, size_t c_ld,
   cl_uint num_queues, cl_command_queue *queues,
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
-    return clblasSgemm(layout, tran_a, tran_b,
+    return clblasSgemm(layout, a_transpose, b_transpose,
                        m, n, k, alpha,
                        a_mat, a_offset, a_ld,
                        b_mat, b_offset, b_ld, beta,
@@ -152,14 +152,14 @@
                        num_queues, queues, num_wait_events, wait_events, events);
 }
 clblasStatus clblasXgemm(
-  clblasOrder layout, clblasTranspose tran_a, clblasTranspose tran_b,
+  clblasOrder layout, clblasTranspose a_transpose, clblasTranspose b_transpose,
   size_t m, size_t n, size_t k, double alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld,
   const cl_mem b_mat, size_t b_offset, size_t b_ld, double beta,
   cl_mem c_mat, size_t c_offset, size_t c_ld,
   cl_uint num_queues, cl_command_queue *queues,
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
-    return clblasDgemm(layout, tran_a, tran_b,
+    return clblasDgemm(layout, a_transpose, b_transpose,
                        m, n, k, alpha,
                        a_mat, a_offset, a_ld,
                        b_mat, b_offset, b_ld, beta,
@@ -167,7 +167,7 @@
                        num_queues, queues, num_wait_events, wait_events, events);
 }
 clblasStatus clblasXgemm(
-  clblasOrder layout, clblasTranspose tran_a, clblasTranspose tran_b,
+  clblasOrder layout, clblasTranspose a_transpose, clblasTranspose b_transpose,
   size_t m, size_t n, size_t k, float2 alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld,
   const cl_mem b_mat, size_t b_offset, size_t b_ld, float2 beta,
@@ -176,7 +176,7 @@
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
     auto cl_alpha = cl_float2{{alpha.real(), alpha.imag()}};
     auto cl_beta = cl_float2{{beta.real(), beta.imag()}};
-    return clblasCgemm(layout, tran_a, tran_b,
+    return clblasCgemm(layout, a_transpose, b_transpose,
                        m, n, k, cl_alpha,
                        a_mat, a_offset, a_ld,
                        b_mat, b_offset, b_ld, cl_beta,
@@ -184,7 +184,7 @@
                        num_queues, queues, num_wait_events, wait_events, events);
 }
 clblasStatus clblasXgemm(
-  clblasOrder layout, clblasTranspose tran_a, clblasTranspose tran_b,
+  clblasOrder layout, clblasTranspose a_transpose, clblasTranspose b_transpose,
   size_t m, size_t n, size_t k, double2 alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld,
   const cl_mem b_mat, size_t b_offset, size_t b_ld, double2 beta,
@@ -193,7 +193,7 @@
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
     auto cl_alpha = cl_double2{{alpha.real(), alpha.imag()}};
     auto cl_beta = cl_double2{{beta.real(), beta.imag()}};
-    return clblasZgemm(layout, tran_a, tran_b,
+    return clblasZgemm(layout, a_transpose, b_transpose,
                        m, n, k, cl_alpha,
                        a_mat, a_offset, a_ld,
                        b_mat, b_offset, b_ld, cl_beta,
@@ -269,33 +269,33 @@

 // This calls {clblasSsyrk, clblasDsyrk, clblasCsyrk, clblasZsyrk} with the arguments forwarded.
 clblasStatus clblasXsyrk(
-  clblasOrder layout, clblasUplo triangle, clblasTranspose tran_a,
+  clblasOrder layout, clblasUplo triangle, clblasTranspose a_transpose,
   size_t n, size_t k, float alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld, float beta,
   cl_mem c_mat, size_t c_offset, size_t c_ld,
   cl_uint num_queues, cl_command_queue *queues,
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
-    return clblasSsyrk(layout, triangle, tran_a,
+    return clblasSsyrk(layout, triangle, a_transpose,
                        n, k, alpha,
                        a_mat, a_offset, a_ld, beta,
                        c_mat, c_offset, c_ld,
                        num_queues, queues, num_wait_events, wait_events, events);
 }
 clblasStatus clblasXsyrk(
-  clblasOrder layout, clblasUplo triangle, clblasTranspose tran_a,
+  clblasOrder layout, clblasUplo triangle, clblasTranspose a_transpose,
   size_t n, size_t k, double alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld, double beta,
   cl_mem c_mat, size_t c_offset, size_t c_ld,
   cl_uint num_queues, cl_command_queue *queues,
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
-    return clblasDsyrk(layout, triangle, tran_a,
+    return clblasDsyrk(layout, triangle, a_transpose,
                        n, k, alpha,
                        a_mat, a_offset, a_ld, beta,
                        c_mat, c_offset, c_ld,
                        num_queues, queues, num_wait_events, wait_events, events);
 }
 clblasStatus clblasXsyrk(
-  clblasOrder layout, clblasUplo triangle, clblasTranspose tran_a,
+  clblasOrder layout, clblasUplo triangle, clblasTranspose a_transpose,
   size_t n, size_t k, float2 alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld, float2 beta,
   cl_mem c_mat, size_t c_offset, size_t c_ld,
@@ -303,14 +303,14 @@
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
     auto cl_alpha = cl_float2{{alpha.real(), alpha.imag()}};
     auto cl_beta = cl_float2{{beta.real(), beta.imag()}};
-    return clblasCsyrk(layout, triangle, tran_a,
+    return clblasCsyrk(layout, triangle, a_transpose,
                        n, k, cl_alpha,
                        a_mat, a_offset, a_ld, cl_beta,
                        c_mat, c_offset, c_ld,
                        num_queues, queues, num_wait_events, wait_events, events);
 }
 clblasStatus clblasXsyrk(
-  clblasOrder layout, clblasUplo triangle, clblasTranspose tran_a,
+  clblasOrder layout, clblasUplo triangle, clblasTranspose a_transpose,
   size_t n, size_t k, double2 alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld, double2 beta,
   cl_mem c_mat, size_t c_offset, size_t c_ld,
@@ -318,7 +318,7 @@
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
     auto cl_alpha = cl_double2{{alpha.real(), alpha.imag()}};
     auto cl_beta = cl_double2{{beta.real(), beta.imag()}};
-    return clblasZsyrk(layout, triangle, tran_a,
+    return clblasZsyrk(layout, triangle, a_transpose,
                        n, k, cl_alpha,
                        a_mat, a_offset, a_ld, cl_beta,
                        c_mat, c_offset, c_ld,
@@ -327,14 +327,14 @@

 // This calls {clblasSsyr2k, clblasDsyr2k, clblasCsyr2k, clblasZsyr2k} with the arguments forwarded.
 clblasStatus clblasXsyr2k(
-  clblasOrder layout, clblasUplo triangle, clblasTranspose tran_ab,
+  clblasOrder layout, clblasUplo triangle, clblasTranspose ab_transpose,
   size_t n, size_t k, float alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld,
   const cl_mem b_mat, size_t b_offset, size_t b_ld, float beta,
   cl_mem c_mat, size_t c_offset, size_t c_ld,
   cl_uint num_queues, cl_command_queue *queues,
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
-    return clblasSsyr2k(layout, triangle, tran_ab,
+    return clblasSsyr2k(layout, triangle, ab_transpose,
                         n, k, alpha,
                         a_mat, a_offset, a_ld,
                         b_mat, b_offset, b_ld, beta,
@@ -342,14 +342,14 @@
                         num_queues, queues, num_wait_events, wait_events, events);
 }
 clblasStatus clblasXsyr2k(
-  clblasOrder layout, clblasUplo triangle, clblasTranspose tran_ab,
+  clblasOrder layout, clblasUplo triangle, clblasTranspose ab_transpose,
   size_t n, size_t k, double alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld,
   const cl_mem b_mat, size_t b_offset, size_t b_ld, double beta,
   cl_mem c_mat, size_t c_offset, size_t c_ld,
   cl_uint num_queues, cl_command_queue *queues,
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
-    return clblasDsyr2k(layout, triangle, tran_ab,
+    return clblasDsyr2k(layout, triangle, ab_transpose,
                         n, k, alpha,
                         a_mat, a_offset, a_ld,
                         b_mat, b_offset, b_ld, beta,
@@ -357,7 +357,7 @@
                         num_queues, queues, num_wait_events, wait_events, events);
 }
 clblasStatus clblasXsyr2k(
-  clblasOrder layout, clblasUplo triangle, clblasTranspose tran_ab,
+  clblasOrder layout, clblasUplo triangle, clblasTranspose ab_transpose,
   size_t n, size_t k, float2 alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld,
   const cl_mem b_mat, size_t b_offset, size_t b_ld, float2 beta,
@@ -366,7 +366,7 @@
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
     auto cl_alpha = cl_float2{{alpha.real(), alpha.imag()}};
     auto cl_beta = cl_float2{{beta.real(), beta.imag()}};
-    return clblasCsyr2k(layout, triangle, tran_ab,
+    return clblasCsyr2k(layout, triangle, ab_transpose,
                         n, k, cl_alpha,
                         a_mat, a_offset, a_ld,
                         b_mat, b_offset, b_ld, cl_beta,
@@ -374,7 +374,7 @@
                         num_queues, queues, num_wait_events, wait_events, events);
 }
 clblasStatus clblasXsyr2k(
-  clblasOrder layout, clblasUplo triangle, clblasTranspose tran_ab,
+  clblasOrder layout, clblasUplo triangle, clblasTranspose ab_transpose,
   size_t n, size_t k, double2 alpha,
   const cl_mem a_mat, size_t a_offset, size_t a_ld,
   const cl_mem b_mat, size_t b_offset, size_t b_ld, double2 beta,
@@ -383,7 +383,7 @@
   cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
     auto cl_alpha = cl_double2{{alpha.real(), alpha.imag()}};
     auto cl_beta = cl_double2{{beta.real(), beta.imag()}};
-    return clblasZsyr2k(layout, triangle, tran_ab,
+    return clblasZsyr2k(layout, triangle, ab_transpose,
                         n, k, cl_alpha,
                         a_mat, a_offset, a_ld,
                         b_mat, b_offset, b_ld, cl_beta,
@@ -391,6 +391,126 @@
                         num_queues, queues, num_wait_events, wait_events, events);
 }

+// This calls {clblasStrmm, clblasDtrmm, clblasCtrmm, clblasZtrmm} with the arguments forwarded.
+clblasStatus clblasXtrmm(
+  clblasOrder layout, clblasSide side, clblasUplo triangle,
+  clblasTranspose a_transpose, clblasDiag diagonal,
+  size_t m, size_t n, float alpha,
+  const cl_mem a_mat, size_t a_offset, size_t a_ld,
+  const cl_mem b_mat, size_t b_offset, size_t b_ld,
+  cl_uint num_queues, cl_command_queue *queues,
+  cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
+    return clblasStrmm(layout, side, triangle, a_transpose, diagonal,
+                       m, n, alpha,
+                       a_mat, a_offset, a_ld,
+                       b_mat, b_offset, b_ld,
+                       num_queues, queues, num_wait_events, wait_events, events);
+}
+clblasStatus clblasXtrmm(
+  clblasOrder layout, clblasSide side, clblasUplo triangle,
+  clblasTranspose a_transpose, clblasDiag diagonal,
+  size_t m, size_t n, double alpha,
+  const cl_mem a_mat, size_t a_offset, size_t a_ld,
+  const cl_mem b_mat, size_t b_offset, size_t b_ld,
+  cl_uint num_queues, cl_command_queue *queues,
+  cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
+    return clblasDtrmm(layout, side, triangle, a_transpose, diagonal,
+                       m, n, alpha,
+                       a_mat, a_offset, a_ld,
+                       b_mat, b_offset, b_ld,
+                       num_queues, queues, num_wait_events, wait_events, events);
+}
+clblasStatus clblasXtrmm(
+  clblasOrder layout, clblasSide side, clblasUplo triangle,
+  clblasTranspose a_transpose, clblasDiag diagonal,
+  size_t m, size_t n, float2 alpha,
+  const cl_mem a_mat, size_t a_offset, size_t a_ld,
+  const cl_mem b_mat, size_t b_offset, size_t b_ld,
+  cl_uint num_queues, cl_command_queue *queues,
+  cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
+    auto cl_alpha = cl_float2{{alpha.real(), alpha.imag()}};
+    return clblasCtrmm(layout, side, triangle, a_transpose, diagonal,
+                       m, n, cl_alpha,
+                       a_mat, a_offset, a_ld,
+                       b_mat, b_offset, b_ld,
+                       num_queues, queues, num_wait_events, wait_events, events);
+}
+clblasStatus clblasXtrmm(
+  clblasOrder layout, clblasSide side, clblasUplo triangle,
+  clblasTranspose a_transpose, clblasDiag diagonal,
+  size_t m, size_t n, double2 alpha,
+  const cl_mem a_mat, size_t a_offset, size_t a_ld,
+  const cl_mem b_mat, size_t b_offset, size_t b_ld,
+  cl_uint num_queues, cl_command_queue *queues,
+  cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
+    auto cl_alpha = cl_double2{{alpha.real(), alpha.imag()}};
+    return clblasZtrmm(layout, side, triangle, a_transpose, diagonal,
+                       m, n, cl_alpha,
+                       a_mat, a_offset, a_ld,
+                       b_mat, b_offset, b_ld,
+                       num_queues, queues, num_wait_events, wait_events, events);
+}
+
+// This calls {clblasStrsm, clblasDtrsm, clblasCtrsm, clblasZtrsm} with the arguments forwarded.
+clblasStatus clblasXtrsm(
+  clblasOrder layout, clblasSide side, clblasUplo triangle,
+  clblasTranspose a_transpose, clblasDiag diagonal,
+  size_t m, size_t n, float alpha,
+  const cl_mem a_mat, size_t a_offset, size_t a_ld,
+  const cl_mem b_mat, size_t b_offset, size_t b_ld,
+  cl_uint num_queues, cl_command_queue *queues,
+  cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
+    return clblasStrsm(layout, side, triangle, a_transpose, diagonal,
+                       m, n, alpha,
+                       a_mat, a_offset, a_ld,
+                       b_mat, b_offset, b_ld,
+                       num_queues, queues, num_wait_events, wait_events, events);
+}
+clblasStatus clblasXtrsm(
+  clblasOrder layout, clblasSide side, clblasUplo triangle,
+  clblasTranspose a_transpose, clblasDiag diagonal,
+  size_t m, size_t n, double alpha,
+  const cl_mem a_mat, size_t a_offset, size_t a_ld,
+  const cl_mem b_mat, size_t b_offset, size_t b_ld,
+  cl_uint num_queues, cl_command_queue *queues,
+  cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
+    return clblasDtrsm(layout, side, triangle, a_transpose, diagonal,
+                       m, n, alpha,
+                       a_mat, a_offset, a_ld,
+                       b_mat, b_offset, b_ld,
+                       num_queues, queues, num_wait_events, wait_events, events);
+}
+clblasStatus clblasXtrsm(
+  clblasOrder layout, clblasSide side, clblasUplo triangle,
+  clblasTranspose a_transpose, clblasDiag diagonal,
+  size_t m, size_t n, float2 alpha,
+  const cl_mem a_mat, size_t a_offset, size_t a_ld,
+  const cl_mem b_mat, size_t b_offset, size_t b_ld,
+  cl_uint num_queues, cl_command_queue *queues,
+  cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
+    auto cl_alpha = cl_float2{{alpha.real(), alpha.imag()}};
+    return clblasCtrsm(layout, side, triangle, a_transpose, diagonal,
+                       m, n, cl_alpha,
+                       a_mat, a_offset, a_ld,
+                       b_mat, b_offset, b_ld,
+                       num_queues, queues, num_wait_events, wait_events, events);
+}
+clblasStatus clblasXtrsm(
+  clblasOrder layout, clblasSide side, clblasUplo triangle,
+  clblasTranspose a_transpose, clblasDiag diagonal,
+  size_t m, size_t n, double2 alpha,
+  const cl_mem a_mat, size_t a_offset, size_t a_ld,
+  const cl_mem b_mat, size_t b_offset, size_t b_ld,
+  cl_uint num_queues, cl_command_queue *queues,
+  cl_uint num_wait_events, const cl_event *wait_events, cl_event *events) {
+    auto cl_alpha = cl_double2{{alpha.real(), alpha.imag()}};
+    return clblasZtrsm(layout, side, triangle, a_transpose, diagonal,
+                       m, n, cl_alpha,
+                       a_mat, a_offset, a_ld,
+                       b_mat, b_offset, b_ld,
+                       num_queues, queues, num_wait_events, wait_events, events);
+}
+
 // =================================================================================================
 } // namespace clblast


Fix typo in comment.

Fix typo in comment.

--- tests/test_calendar.c
+++ tests/test_calendar.c
@@ -86,7 +86,7 @@
 	struct tm time, time2;
 	int i;

-	/* isleeapyear() and lastday() are OK by definition */
+	/* isleapyear() and lastday() are OK by definition */

 	/* century_offset(): check for every date if it matches */
 	time.tm_wday = 1; /* base_year-01-01 is a Monday */


removing re-declared or unused code

removing re-declared or unused code

--- src/qe.h
+++ src/qe.h
@@ -1197,27 +1197,11 @@

 void get_style(EditState *e, QEStyleDef *style, int style_index);

-/* dired.c */
-void do_dired(EditState *s);
-
-/* c_mode.c */
-void c_colorize_line(unsigned int *buf, int len,
-                     int *colorize_state_ptr, int state_only);
-
-/* xml.c */
-int xml_mode_probe(ModeProbeData *p1);
-
-/* html.c */
-extern ModeDef html_mode;

 int gxml_mode_init(EditState *s,
                    ModeSavedData *saved_data,
                    int is_html, const char *default_stylesheet);

-/* image.c */
-void fill_border(EditState *s, int x, int y, int w, int h, int color);
-int qe_bitmap_format_to_pix_fmt(int format);
-
 #define QASSERT(e)      do { if (!(e)) fprintf(stderr, "%s:%d: assertion failed: %s\n", __FILE__, __LINE__, #e); } while (0)

 #endif


display the server name (instead of its host) in the chans window

--- src/ui.c
+++ src/ui.c
@@ -260,7 +260,7 @@
     if (!server->current_chan)
         wattron(win, A_BOLD);

-    waddstr(win, server->host);
+    waddstr(win, server->name);

     if (!server->current_chan)
         wattroff(win, A_BOLD);


Added missing 'dashboard' on the overall stats header (terminal output).

--- src/ui.c
+++ src/ui.c
@@ -389,7 +389,7 @@
   };

   werase (win);
-  draw_header (win, T_HEAD, " %s", 0, 0, getmaxx (stdscr), 1, 0);
+  draw_header (win, T_DASH " - " T_HEAD, " %s", 0, 0, getmaxx (stdscr), 1, 0);

   if (!logger->piping && ifile != NULL) {
     size = filesize_str (file_size (ifile));


Removed win32 thread specific code from deprecated vm.c

--- src/vm.c
+++ src/vm.c
@@ -927,57 +927,6 @@
     return NULL; /* never reached */
 }

-#ifdef _WIN32
-/* Proxy structure to pass fnuc and arg to thread */
-typedef struct thread_params
-{
-    void *(*func)(void *);
-    void * arg;
-} thread_params;
-
-/* Proxy function by windows thread requirements */
-static unsigned __stdcall win32_proxy_threadproc(void *arg) {
-
-    thread_params *p = (thread_params *) arg;
-    p->func(p->arg);
-
-    /* Dealocate params */
-    zfree(p);
-
-    _endthreadex(0);
-	return 0;
-}
-
-int pthread_create(pthread_t *thread, const void *unused,
-		   void *(*start_routine)(void*), void *arg) {
-
-    REDIS_NOTUSED(unused);
-    HANDLE h;
-    thread_params *params = zmalloc(sizeof(thread_params));
-
-    params->func = start_routine;
-    params->arg  = arg;
-
-    /*  Arguments not supported in this port */
-    if (arg) exit(1);
-
-    REDIS_NOTUSED(arg);
-	h =(HANDLE) _beginthreadex(NULL,  /* Security not used */
-                               REDIS_THREAD_STACK_SIZE, /* Set custom stack size */
-                               win32_proxy_threadproc,  /* calls win32 stdcall proxy */
-                               params, /* real threadproc is passed as paremeter */
-                               STACK_SIZE_PARAM_IS_A_RESERVATION,  /* reserve stack */
-                               thread /* returned thread id */
-                );
-
-	if (!h)
-		return errno;
-
-    CloseHandle(h);
-	return 0;
-}
-#endif
-
 void spawnIOThread(void) {
     pthread_t thread;
     _sigset_t mask, omask;


Make input buffer const.

Make input buffer const.

--- src/xr.c
+++ src/xr.c
@@ -351,7 +351,7 @@

 	/* rotate wavefunction */
 	for (int lmo = 0; lmo < frag->n_lmo; lmo++) {
-		double *in = frag->lib->xr_wf + lmo * frag->xr_wf_size;
+		const double *in = frag->lib->xr_wf + lmo * frag->xr_wf_size;
 		double *out = frag->xr_wf + lmo * frag->xr_wf_size;

 		for (int i = 0, func = 0; frag->shells[i]; i++) {


sscall: Properly terminate threads

sscall: Properly terminate threads

Signed-off-by: Dimitris Papastamos <a91262282f71bb8488398dcc9202f777d0206664@opensource.wolfsonmicro.com>

--- sscall.c
+++ sscall.c
@@ -70,6 +70,18 @@
 /* Condition variable on which ao_play() blocks */
 static pthread_cond_t tx_pcm_cond;

+/* If set, output thread is killed */
+static int kill_output_pcm;
+/* If set, input thread is killed */
+static int kill_input_pcm;
+
+/* Lock that protects the setting of the
+ * kill_output_pcm variable */
+static pthread_mutex_t kill_output_pcm_lock;
+/* Lock that protects the setting of the
+ * kill_input_pcm variable */
+static pthread_mutex_t kill_input_pcm_lock;
+
 /* Set to 1 when SIGINT is received */
 static volatile int handle_sigint;

@@ -85,6 +97,14 @@
 		if (list_empty(&pcm_buf.list))
 			pthread_cond_wait(&tx_pcm_cond,
 					  &pcm_buf_lock);
+
+		pthread_mutex_lock(&kill_output_pcm_lock);
+		if (kill_output_pcm) {
+			pthread_mutex_unlock(&kill_output_pcm_lock);
+			break;
+		}
+		pthread_mutex_unlock(&kill_output_pcm_lock);
+
 		/* Dequeue and play buffers via libao */
 		list_for_each_safe(iter, q, &pcm_buf.list) {
 			pctx = list_entry(iter, struct pcm_buf,
@@ -97,6 +117,8 @@
 		pthread_mutex_unlock(&pcm_buf_lock);
 	} while (1);

+	pthread_exit(NULL);
+
 	return NULL;
 }

@@ -134,6 +156,13 @@
 	ssize_t bytes;

 	do {
+		pthread_mutex_lock(&kill_input_pcm_lock);
+		if (kill_input_pcm) {
+			pthread_mutex_unlock(&kill_input_pcm_lock);
+			break;
+		}
+		pthread_mutex_unlock(&kill_input_pcm_lock);
+
 		bytes = read(inp_pcm_priv.fd, buf, sizeof(buf));
 		if (bytes > 0) {
 			bytes = sendto(inp_pcm_priv.sockfd, buf,
@@ -145,6 +174,8 @@
 			usleep(UDELAY_SEND);
 		}
 	} while (1);
+
+	pthread_exit(NULL);

 	return NULL;
 }
@@ -328,6 +359,9 @@

 	pthread_mutex_init(&pcm_buf_lock, NULL);
 	pthread_cond_init(&tx_pcm_cond, NULL);
+
+	pthread_mutex_init(&kill_output_pcm_lock, NULL);
+	pthread_mutex_init(&kill_input_pcm_lock, NULL);

 	ret = pthread_create(&output_pcm_thread, NULL,
 			     output_pcm,
@@ -376,6 +410,28 @@
 		}
 	} while (1);

+	/* Prepare input thread to be killed */
+	pthread_mutex_lock(&kill_input_pcm_lock);
+	kill_input_pcm = 1;
+	pthread_mutex_unlock(&kill_input_pcm_lock);
+
+	/* Wait for it */
+	pthread_join(input_pcm_thread, NULL);
+
+	/* Wake up the output thread if it is
+	 * sleeping */
+	pthread_mutex_lock(&pcm_buf_lock);
+	pthread_cond_signal(&tx_pcm_cond);
+	pthread_mutex_unlock(&pcm_buf_lock);
+
+	/* Prepare output thread to be killed */
+	pthread_mutex_lock(&kill_output_pcm_lock);
+	kill_output_pcm = 1;
+	pthread_mutex_unlock(&kill_output_pcm_lock);
+
+	/* Wait for it */
+	pthread_join(output_pcm_thread, NULL);
+
 	ao_close(device);
 	ao_shutdown();


Improve test methods

Improve test methods

--- tests/TrieTestUtils.h
+++ tests/TrieTestUtils.h
@@ -8,7 +8,8 @@
 template <class Trie, class Map>
 void compare_containers(OP::utest::TestResult &tresult, const Trie& trie, const Map& map)
 {
-    tresult.assert_that<equals>(trie.size(), map.size(), "Size is wrong");
+    auto tsn = trie.size(), msn = map.size();
+    tresult.assert_that<equals>(tsn, msn, OP_CODE_DETAILS() << "Size is wrong, expected:" << msn << ", but: " << tsn);

     auto mi = std::begin(map);
     //for (auto xp : map)
@@ -51,3 +52,41 @@
         tresult.fail(OP_CODE_DETAILS() << os.str());
     }
 }
+template <class Trie, class Map>
+void compare_containers_relaxed_order(OP::utest::TestResult& tresult, const Trie& trie, Map map)
+{
+    auto tsn = trie.size(), msn = map.size();
+    tresult.assert_that<equals>(tsn, msn, OP_CODE_DETAILS() << "Size is wrong, expected:" << msn << ", but: " << tsn);
+
+    auto ti = trie.begin();
+    int n = 0;
+    //order relaxed
+    for (; trie.in_range(ti) && !map.empty(); trie.next(ti), ++n)
+    {
+        //print_hex(tresult.info() << "1)", ti.key());
+        //print_hex(tresult.info() << "2)", mi->first);
+        const auto& key = ti.key();
+        tresult.assert_that<equals>(1, map.erase(key),
+            OP_CODE_DETAILS() << "step#" << n << ", sample map has no key=" << (const char*)key.c_str());
+    }
+    if (!map.empty())
+    {
+        std::ostringstream os;
+        os << "sample map contains extra items:\n";
+        for (auto mi : map)
+        {
+            os << "{" << (const char*)mi.first.c_str() << ", " << mi.second << "}\n";
+        }
+        tresult.fail(OP_CODE_DETAILS() << os.str());
+    }
+    if (trie.in_range(ti))
+    {
+        std::ostringstream os;
+        os << "Compared range contains extra items:\n";
+        for (; trie.in_range(ti); trie.next(ti))
+        {
+            os << "{" << (const char*)ti.key().c_str() << "}\n";
+        }
+        tresult.fail(OP_CODE_DETAILS() << os.str());
+    }
+}


checkasm: cdef: Don't use uninitialized buffer contents for the test

This makes sure the test actually is deterministic based on the
seed value.

--- tests/checkasm/cdef.c
+++ tests/checkasm/cdef.c
@@ -53,9 +53,6 @@
     if (check_func(fn, "%s_%dbpc", name, BITDEPTH)) {
         for (int dir = 0; dir < 8; dir++) {
             for (enum CdefEdgeFlags edges = 0; edges <= 0xf; edges++) {
-                memcpy(a_src, src, (10 * 16 + 8) * sizeof(pixel));
-                memcpy(c_src, src, (10 * 16 + 8) * sizeof(pixel));
-
 #if BITDEPTH == 16
                 const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
 #else
@@ -65,6 +62,9 @@
                 init_tmp(src, 10 * 16 + 8, bitdepth_max);
                 init_tmp(top, 16 * 2 + 8, bitdepth_max);
                 init_tmp((pixel *) left,8 * 2, bitdepth_max);
+
+                memcpy(a_src, src, (10 * 16 + 8) * sizeof(pixel));
+                memcpy(c_src, src, (10 * 16 + 8) * sizeof(pixel));

                 const int lvl = 1 + (rnd() % 62);
                 const int damping = 3 + (rnd() & 3) + bitdepth_min_8;


Implemented the xml_reader#line_number() and #column_number() methods.

--- lib/xml_reader.h
+++ lib/xml_reader.h
@@ -148,6 +148,22 @@
     }

     /**
+     * Returns the line number of the current parsing point.
+     */
+    unsigned long line_number() const noexcept {
+      /* @see http://xmlsoft.org/html/libxml-xmlreader.html#xmlTextReaderGetParserLineNumber */
+      return xmlTextReaderGetParserLineNumber(_reader);
+    }
+
+    /**
+     * Returns the column number of the current parsing point.
+     */
+    unsigned long column_number() const noexcept {
+      /* @see http://xmlsoft.org/html/libxml-xmlreader.html#xmlTextReaderGetParserColumnNumber */
+      return xmlTextReaderGetParserColumnNumber(_reader);
+    }
+
+    /**
      * Retrieves all attributes of the current node.
      */
     std::map<std::string, std::string> attributes() {


build: skip qemu in tests when !WITH_QEMU

A mingw build (where the qemu driver is not built, so WITH_QEMU
is undefined) failed with:

In file included from ../../src/qemu/qemu_command.h:30:0,
                 from ../../tests/testutilsqemu.h:4,
                 from ../../tests/networkxml2xmltest.c:14:
../../src/qemu/qemu_conf.h:53:4: error: #error "Port me"

But since testutilsqemu.c is already conditional, the header
should be likewise.

* tests/testutilsqemu.h: Make content conditional.

Signed-off-by: Eric Blake <a9da18479c871fe903d9590822cfe2629c6a4d11@redhat.com>

--- tests/testutilsqemu.h
+++ tests/testutilsqemu.h
@@ -1,8 +1,10 @@
+#ifdef WITH_QEMU

-#include "capabilities.h"
-#include "domain_conf.h"
-#include "qemu/qemu_command.h"
+# include "capabilities.h"
+# include "domain_conf.h"
+# include "qemu/qemu_command.h"

 virCapsPtr testQemuCapsInit(void);
 virDomainXMLOptionPtr testQemuXMLConfInit(void);
 extern qemuBuildCommandLineCallbacks testCallbacks;
+#endif


Small cleanup for for() to array.

Small cleanup for for() to array.

--- tests/mem_functions.c
+++ tests/mem_functions.c
@@ -3130,11 +3130,10 @@

 static test_return_t  generate_pairs(memcached_st *memc __attribute__((unused)))
 {
-  unsigned long long x;
   global_pairs= pairs_generate(GLOBAL_COUNT, 400);
   global_count= GLOBAL_COUNT;

-  for (x= 0; x < global_count; x++)
+  for (size_t x= 0; x < global_count; x++)
   {
     global_keys[x]= global_pairs[x].key;
     global_keys_length[x]=  global_pairs[x].key_length;
@@ -3145,11 +3144,10 @@

 static test_return_t  generate_large_pairs(memcached_st *memc __attribute__((unused)))
 {
-  unsigned long long x;
   global_pairs= pairs_generate(GLOBAL2_COUNT, MEMCACHED_MAX_BUFFER+10);
   global_count= GLOBAL2_COUNT;

-  for (x= 0; x < global_count; x++)
+  for (size_t x= 0; x < global_count; x++)
   {
     global_keys[x]= global_pairs[x].key;
     global_keys_length[x]=  global_pairs[x].key_length;
@@ -3202,7 +3200,6 @@

 static test_return_t  get_read_count(memcached_st *memc)
 {
-  unsigned int x;
   memcached_return_t rc;
   memcached_st *memc_clone;

@@ -3217,7 +3214,7 @@
     uint32_t flags;
     uint32_t count;

-    for (x= count= 0; x < global_count; x++)
+    for (size_t x= count= 0; x < global_count; x++)
     {
       return_value= memcached_get(memc_clone, global_keys[x], global_keys_length[x],
                                   &return_value_length, &flags, &rc);
@@ -3237,7 +3234,6 @@

 static test_return_t  get_read(memcached_st *memc)
 {
-  unsigned int x;
   memcached_return_t rc;

   {
@@ -3245,7 +3241,7 @@
     size_t return_value_length;
     uint32_t flags;

-    for (x= 0; x < global_count; x++)
+    for (size_t x= 0; x < global_count; x++)
     {
       return_value= memcached_get(memc, global_keys[x], global_keys_length[x],
                                   &return_value_length, &flags, &rc);
@@ -3315,9 +3311,7 @@

 static test_return_t  delete_generate(memcached_st *memc)
 {
-  unsigned int x;
-
-  for (x= 0; x < global_count; x++)
+  for (size_t x= 0; x < global_count; x++)
   {
     (void)memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0);
   }
@@ -3342,7 +3336,6 @@

 static test_return_t  add_host_test1(memcached_st *memc)
 {
-  unsigned int x;
   memcached_return_t rc;
   char servername[]= "0.example.com";
   memcached_server_st *servers;
@@ -3351,11 +3344,11 @@
   test_truth(servers);
   test_truth(1 == memcached_server_list_count(servers));

-  for (x= 2; x < 20; x++)
+  for (size_t x= 2; x < 20; x++)
   {
     char buffer[SMALL_STRING_LEN];

-    snprintf(buffer, SMALL_STRING_LEN, "%u.example.com", 400+x);
+    snprintf(buffer, SMALL_STRING_LEN, "%zu.example.com", 400+x);
     servers= memcached_server_list_append_with_weight(servers, buffer, 401, 0,
                                      &rc);
     test_truth(rc == MEMCACHED_SUCCESS);
@@ -3924,10 +3917,10 @@

   for (int count=0; count < 5; ++count)
   {
-    for (int x=0; x < 100; ++x)
+    for (size_t x= 0; x < 100; ++x)
     {
       char key[10];
-      size_t len= (size_t)sprintf(key, "%d", x);
+      size_t len= (size_t)sprintf(key, "%zu", x);
       switch (count)
       {
       case 0:
@@ -3958,7 +3951,7 @@
     ** way it is supposed to do!!!!
     */
     int no_msg=0;
-    for (uint32_t x=0; x < memcached_server_count(memc); ++x)
+    for (size_t x= 0; x < memcached_server_count(memc); ++x)
     {
       memcached_server_instance_st *instance=
         memcached_server_instance_fetch(memc, x);
@@ -3971,10 +3964,11 @@
     /*
      ** Now validate that all items was set properly!
      */
-    for (int x=0; x < 100; ++x)
+    for (size_t x= 0; x < 100; ++x)
     {
       char key[10];
-      size_t len= (size_t)sprintf(key, "%d", x);
+
+      size_t len= (size_t)sprintf(key, "%zu", x);
       size_t length;
       uint32_t flags;
       char* value=memcached_get(memc, key, strlen(key),
@@ -4118,7 +4112,8 @@
   memcached_st* mmc[10];
   memcached_return_t rc;

-  for (int x= 0; x < 10; ++x) {
+  for (size_t x= 0; x < 10; ++x)
+  {
     mmc[x]= memcached_pool_pop(pool, false, &rc);
     test_truth(mmc[x] != NULL);
     test_truth(rc == MEMCACHED_SUCCESS);
@@ -4144,7 +4139,8 @@
   rc= memcached_set(mmc[0], key, keylen, "0", 1, 0, 0);
   test_truth(rc == MEMCACHED_SUCCESS);

-  for (unsigned int x= 0; x < 10; ++x) {
+  for (size_t x= 0; x < 10; ++x)
+  {
     uint64_t number_value;
     rc= memcached_increment(mmc[x], key, keylen, 1, &number_value);
     test_truth(rc == MEMCACHED_SUCCESS);
@@ -4152,8 +4148,10 @@
   }

   // Release them..
-  for (int x= 0; x < 10; ++x)
+  for (size_t x= 0; x < 10; ++x)
+  {
     test_truth(memcached_pool_push(pool, mmc[x]) == MEMCACHED_SUCCESS);
+  }

   /* verify that I can set behaviors on the pool when I don't have all
@@ -4274,7 +4272,7 @@
   const char *keys[]= { "bubba", "key1", "key2", "key3" };
   size_t len[]= { 5, 4, 4, 4 };

-  for (int x=0; x< 4; ++x)
+  for (size_t x= 0; x< 4; ++x)
   {
     rc= memcached_set(memc, keys[x], len[x], "0", 1, 0, 0);
     test_truth(rc == MEMCACHED_SUCCESS);
@@ -4354,7 +4352,8 @@

   memcached_quit(memc);

-  for (int x=0; x< 7; ++x) {
+  for (size_t x= 0; x< 7; ++x)
+  {
     const char key[2]= { [0]= (const char)x };

     rc= memcached_mget_by_key(memc_clone, key, 1, keys, len, 7);
@@ -4387,7 +4386,7 @@
   const char *keys[]= { "bubba", "key1", "key2", "key3" };
   size_t len[]= { 5, 4, 4, 4 };

-  for (int x=0; x< 4; ++x)
+  for (size_t x= 0; x< 4; ++x)
   {
     rc= memcached_delete_by_key(memc, keys[0], len[0], keys[x], len[x], 0);
     test_truth(rc == MEMCACHED_SUCCESS);
@@ -4399,7 +4398,7 @@
    * This is to verify correct behavior in the library
    */
   uint32_t hash= memcached_generate_hash(memc, keys[0], len[0]);
-  for (uint32_t x= 0; x < (repl + 1); ++x)
+  for (size_t x= 0; x < (repl + 1); ++x)
   {
     memcached_server_instance_st *instance=
       memcached_server_instance_fetch(memc_clone, x);
@@ -4412,7 +4411,7 @@
   memcached_result_st result_obj;
   for (uint32_t host= 0; host < memc_clone->number_of_hosts; ++host)
   {
-    for (int x= 'a'; x <= 'z'; ++x)
+    for (size_t x= 'a'; x <= 'z'; ++x)
     {
       const char key[2]= { [0]= (const char)x };

@@ -4447,9 +4446,8 @@
 {
   uint16_t *ids= malloc(sizeof(uint16_t) * memcached_server_count(memc));
   assert(ids != NULL);
-  unsigned int x;
-
-  for (x= 0; x < memcached_server_count(memc); x++)
+
+  for (size_t x= 0; x < memcached_server_count(memc); x++)
   {
     memcached_server_instance_st *instance=
       memcached_server_instance_fetch(memc, x);
@@ -4462,11 +4460,10 @@

 static test_return_t post_udp_op_check(memcached_st *memc, uint16_t *expected_req_ids)
 {
-  unsigned int x;
   memcached_server_st *cur_server = memcached_server_list(memc);
   uint16_t *cur_req_ids = get_udp_request_ids(memc);

-  for (x= 0; x < memcached_server_count(memc); x++)
+  for (size_t x= 0; x < memcached_server_count(memc); x++)
   {
     test_truth(cur_server[x].cursor_active == 0);
     test_truth(cur_req_ids[x] == expected_req_ids[x]);
@@ -4493,10 +4490,9 @@
     return TEST_SKIPPED;

   uint32_t num_hosts= memcached_server_count(memc);
-  unsigned int x= 0;
   memcached_server_st servers[num_hosts];
   memcpy(servers, memcached_server_list(memc), sizeof(memcached_server_st) * num_hosts);
-  for (x= 0; x < num_hosts; x++)
+  for (size_t x= 0; x < num_hosts; x++)
   {
     memcached_server_instance_st *set_instance=
       memcached_server_instance_fetch(memc, x);
@@ -4506,7 +4502,7 @@

   memc->number_of_hosts= 0;
   memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, 1);
-  for (x= 0; x < num_hosts; x++)
+  for (size_t x= 0; x < num_hosts; x++)
   {
     memcached_server_instance_st *set_instance=
       memcached_server_instance_fetch(memc, x);
@@ -4585,9 +4581,9 @@

 static test_return_t udp_set_test(memcached_st *memc)
 {
-  unsigned int x= 0;
   unsigned int num_iters= 1025; //request id rolls over at 1024
-  for (x= 0; x < num_iters;x++)
+
+  for (size_t x= 0; x < num_iters;x++)
   {
     memcached_return_t rc;
     const char *key= "foo";
@@ -4640,14 +4636,15 @@
                     value, MAX_UDP_DATAGRAM_LENGTH,
                     (time_t)0, (uint32_t)0);
   test_truth(rc == MEMCACHED_WRITE_FAILURE);
+
   return post_udp_op_check(memc,expected_ids);
 }

 static test_return_t udp_delete_test(memcached_st *memc)
 {
-  unsigned int x= 0;
   unsigned int num_iters= 1025; //request id rolls over at 1024
-  for (x= 0; x < num_iters;x++)
+
+  for (size_t x= 0; x < num_iters;x++)
   {
     memcached_return_t rc;
     const char *key= "foo";
@@ -4686,9 +4683,11 @@
 {
   memcached_return_t rc;
   uint16_t *expected_ids= get_udp_request_ids(memc);
-  unsigned int x;
-  for (x= 0; x < memcached_server_count(memc); x++)
+
+  for (size_t x= 0; x < memcached_server_count(memc); x++)
+  {
     increment_request_id(&expected_ids[x]);
+  }

   rc= memcached_verbosity(memc,3);
   test_truth(rc == MEMCACHED_SUCCESS);
@@ -4706,9 +4705,11 @@
 {
   memcached_return_t rc;
   uint16_t *expected_ids= get_udp_request_ids(memc);
-  unsigned int x;
-  for (x= 0; x < memcached_server_count(memc);x++)
+
+  for (size_t x= 0; x < memcached_server_count(memc); x++)
+  {
     increment_request_id(&expected_ids[x]);
+  }

   rc= memcached_flush(memc,0);
   test_truth(rc == MEMCACHED_SUCCESS);
@@ -4810,8 +4811,7 @@
     {"udp_version_test", 0,
       (test_callback_fn)udp_version_test}
   };
-  unsigned int x= 0;
-  for (x= 0; x < 500; x++)
+  for (size_t x= 0; x < 500; x++)
   {
     current_op= mixed_io_ops[random() % 9];
     test_truth(current_op.test_fn(memc) == TEST_SUCCESS);


vircgrouptest: add cgroup v2 tests

vircgrouptest: add cgroup v2 tests

Signed-off-by: Pavel Hrdina <d4772d05997b8abf035041e3b4f4996380ea7e7a@redhat.com>

--- tests/vircgrouptest.c
+++ tests/vircgrouptest.c
@@ -569,14 +569,35 @@
 static int testCgroupNewForSelfLogind(const void *args ATTRIBUTE_UNUSED)
 {
     virCgroupPtr cgroup = NULL;
+
+    if (virCgroupNewSelf(&cgroup) >= 0) {
+        fprintf(stderr, "Expected to fail, only systemd cgroup available.\n");
+        virCgroupFree(&cgroup);
+        return -1;
+    }
+
+    return 0;
+}
+
+
+static int testCgroupNewForSelfUnified(const void *args ATTRIBUTE_UNUSED)
+{
+    virCgroupPtr cgroup = NULL;
     int ret = -1;
-
-    if (virCgroupNewSelf(&cgroup) == 0) {
-        fprintf(stderr, "Expected cgroup creation to fail.\n");
-        goto cleanup;
-    }
-
-    ret = 0;
+    const char *empty[VIR_CGROUP_CONTROLLER_LAST] = { 0 };
+    unsigned int controllers =
+        (1 << VIR_CGROUP_CONTROLLER_CPU) |
+        (1 << VIR_CGROUP_CONTROLLER_CPUACCT) |
+        (1 << VIR_CGROUP_CONTROLLER_MEMORY) |
+        (1 << VIR_CGROUP_CONTROLLER_BLKIO);
+
+    if (virCgroupNewSelf(&cgroup) < 0) {
+        fprintf(stderr, "Cannot create cgroup for self\n");
+        goto cleanup;
+    }
+
+    ret = validateCgroup(cgroup, "", empty, empty, empty,
+                         "/not/really/sys/fs/cgroup", "/", controllers);
  cleanup:
     virCgroupFree(&cgroup);
     return ret;
@@ -993,7 +1014,14 @@
         ret = -1;
     cleanupFakeFS(fakerootdir);

-
+    /* cgroup unified */
+
+    fakerootdir = initFakeFS("unified", "unified");
+    if (virTestRun("New cgroup for self (unified)", testCgroupNewForSelfUnified, NULL) < 0)
+        ret = -1;
+    if (virTestRun("Cgroup available (unified)", testCgroupAvailable, (void*)0x1) < 0)
+        ret = -1;
+    cleanupFakeFS(fakerootdir);

     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }


Eliminate mem leak in dummy resolver when the server has to abort for a test.

--- tests/test-resolver.c
+++ tests/test-resolver.c
@@ -143,7 +143,8 @@
       res = g_simple_async_result_new_from_error (source, cb, data, error);

   g_simple_async_result_set_op_res_gpointer (res, addr, NULL);
-  g_simple_async_result_complete_in_idle (res);
+  g_simple_async_result_complete (res);
+  g_object_unref (res);
 }

 static GList *


clear handled errors in alert io test case.

--- tests/test_alert_io.c
+++ tests/test_alert_io.c
@@ -130,6 +130,7 @@

   if (err) {
     SLN_ASSERT(err->err == SELENE_EINVAL);
+    selene_error_clear(err);
   }
   else {
     /* TODO: more asserts */


tests/sequence: use the accessor methods and move the test sequence into the global variables

--- tests/test_sequence.c
+++ tests/test_sequence.c
@@ -38,11 +38,15 @@

 Sequence * seq;

+char * testIdentifier = "test_sequence";
+char * testDescription = "Test description";
+char * testSequence = "acgttgca";
+
 void setup (void) {
   seq = newSequence ();
-  setIdentifier (seq, "test_sequence");
-  setDescription (seq, "Test description");
-  setSequence (seq, "acgttgca");
+  setIdentifier (seq, testIdentifier);
+  setDescription (seq, testDescription);
+  setSequence (seq, testSequence);
 }

 void teardown (void) {
@@ -51,43 +55,43 @@

 START_TEST (test_seq_identifier) {
   ck_assert_str_eq (
-    seq->identifier,
-    "test_sequence"
+    getIdentifier (seq),
+    testIdentifier
   );
 } END_TEST

 START_TEST (test_seq_identifier_length) {
   ck_assert_int_eq (
-    seq->identifierLength,
-    13
+    getIdentifierLength (seq),
+    strlen (testIdentifier)
   );
 } END_TEST

 START_TEST (test_seq_description) {
   ck_assert_str_eq (
-    seq->description,
-    "Test description"
+    getDescription (seq),
+    testDescription
   );
 } END_TEST

 START_TEST (test_seq_description_length) {
   ck_assert_int_eq (
-    seq->descriptionLength,
-    16
+    getDescriptionLength (seq),
+    strlen (testDescription)
   );
 } END_TEST

 START_TEST (test_seq_sequence) {
   ck_assert_str_eq (
-    seq->sequence,
-    "acgttgca"
+    getSequence (seq),
+    testSequence
   );
 } END_TEST

 START_TEST (test_seq_sequence_length) {
   ck_assert_int_eq (
-    seq->sequenceLength,
-    8
+    getSequenceLength (seq),
+    strlen (testSequence)
   );
 } END_TEST


tests: gpioset: check the 'exit' mode explicitly

Duplicate the previous 'exit' mode test but pass the mode argument
explicitly to gpioset.

Signed-off-by: Bartosz Golaszewski <108de5fbc428215dc26df4468b48691526611148@gmail.com>

--- tests/tests-gpioset.c
+++ tests/tests-gpioset.c
@@ -51,6 +51,47 @@
 	    "tools: gpioset - set lines and exit",
 	    0, { 8, 8, 8 });

+static void gpioset_set_lines_and_exit_explicit_mode(void)
+{
+	unsigned int offsets[8];
+	int rv, values[8];
+
+	test_tool_run("gpioset", "--mode=exit", "gpiochip2",
+		      "0=0", "1=0", "2=1", "3=1",
+		      "4=1", "5=1", "6=0", "7=1", (char *)NULL);
+	test_tool_wait();
+
+	TEST_ASSERT(test_tool_exited());
+	TEST_ASSERT_RET_OK(test_tool_exit_status());
+	TEST_ASSERT_NULL(test_tool_stdout());
+	TEST_ASSERT_NULL(test_tool_stderr());
+
+	offsets[0] = 0;
+	offsets[1] = 1;
+	offsets[2] = 2;
+	offsets[3] = 3;
+	offsets[4] = 4;
+	offsets[5] = 5;
+	offsets[6] = 6;
+	offsets[7] = 7;
+
+	rv = gpiod_simple_get_value_multiple(TEST_CONSUMER, test_chip_name(2),
+					     offsets, values, 8, false);
+	TEST_ASSERT_RET_OK(rv);
+
+	TEST_ASSERT_EQ(values[0], 0);
+	TEST_ASSERT_EQ(values[1], 0);
+	TEST_ASSERT_EQ(values[2], 1);
+	TEST_ASSERT_EQ(values[3], 1);
+	TEST_ASSERT_EQ(values[4], 1);
+	TEST_ASSERT_EQ(values[5], 1);
+	TEST_ASSERT_EQ(values[6], 0);
+	TEST_ASSERT_EQ(values[7], 1);
+}
+TEST_DEFINE(gpioset_set_lines_and_exit_explicit_mode,
+	    "tools: gpioset - set lines and exit (explicit mode argument)",
+	    0, { 8, 8, 8 });
+
 static void gpioset_set_some_lines_and_wait_for_enter(void)
 {
 	unsigned int offsets[5];


func_detour(): Remove duplicated code.

func_detour(): Remove duplicated code.

--- thcrap/src/mempatch.c
+++ thcrap/src/mempatch.c
@@ -64,13 +64,7 @@
 /// ---------
 int func_detour(PIMAGE_THUNK_DATA pThunk, const void *new_ptr)
 {
-	MEMORY_BASIC_INFORMATION mbi;
-	DWORD oldProt;
-	VirtualQuery(&pThunk->u1.Function, &mbi, sizeof(MEMORY_BASIC_INFORMATION));
-	VirtualProtect(mbi.BaseAddress, mbi.RegionSize, PAGE_READWRITE, &oldProt);
-	pThunk->u1.Function = (DWORD)new_ptr;
-	VirtualProtect(mbi.BaseAddress, mbi.RegionSize, oldProt, &oldProt);
-	return 1;
+	return PatchRegion(&pThunk->u1.Function, NULL, &new_ptr, sizeof(new_ptr));
 }

 int func_detour_by_name(HMODULE hMod, PIMAGE_THUNK_DATA pOrigFirstThunk, PIMAGE_THUNK_DATA pImpFirstThunk, const iat_detour_t *detour)


Handle SIGINT properly.

Handle SIGINT properly.

--- src/xmms2-scrobbler.c
+++ src/xmms2-scrobbler.c
@@ -30,6 +30,7 @@
 #include <xmmsclient/xmmsclient.h>
 #include <pthread.h>
 #include <curl/curl.h>
+#include <signal.h>
 #include "queue.h"
 #include "submission.h"
 #include "md5.h"
@@ -56,6 +57,15 @@
 static bool need_handshake = true;
 static bool shutdown_thread = false;
 static bool keep_running = true;
+
+static struct sigaction sig;
+
+static void
+signal_handler (int sig)
+{
+	if (sig == SIGINT)
+		keep_running = false;
+}

 static size_t
 handle_handshake_reponse (void *rawptr, size_t size, size_t nmemb,
@@ -677,6 +687,9 @@
 	pthread_t thread;
 	int s;

+	sig.sa_handler = &signal_handler;
+	sigaction (SIGINT, &sig, 0);
+
 	if (!load_config ())
 		return EXIT_FAILURE;


added safegaurd for bad/corrupt messages

--- cxxutils/serializers.h
+++ cxxutils/serializers.h
@@ -36,10 +36,13 @@
   template<typename T>
   static inline bool deserialize(vqueue& data, T* arg, uint16_t length)
   {
-    if(data.pop<uint16_t>() != length)
+    if(data.pop<uint16_t>() != length)    // length mismatch
       return false;

-    if(data.pop<uint8_t>() != sizeof(T))
+    if(data.pop<uint8_t>() != sizeof(T))  // size mismatch
+      return false;
+
+    if(data.size() < length * sizeof(T))  // message is corrupt/buffer too short
       return false;

     for(size_t i = 0; i < length; ++i)


Terminate code-scan on S_NEXTCLAUSE

Terminate code-scan on S_NEXTCLAUSE

--- src/pl-lifegc.c
+++ src/pl-lifegc.c
@@ -171,6 +171,7 @@
   { op = decode(*PC++);

   again:
+    DEBUG(3, Sdprintf("\t%s\n", codeTable[op].name));
     COUNT(vm_scanned);
     if ( op == end )
     { PC--;
@@ -206,6 +207,7 @@
       case I_FREDO:
       case S_TRUSTME:			/* Consider supervisor handling! */
       case S_LIST:
+      case S_NEXTCLAUSE:
 	return PC-1;

       case C_JMP:			/* unconditional jump */


FIXED: We cannot wait on the underlying socket if there are multiple buffered filters between us and the socket, since there may be pending data which needs to be read from another layer but nothing pending on the socket

--- src/pl-stream.c
+++ src/pl-stream.c
@@ -457,7 +457,7 @@
 #ifdef HAVE_SELECT
   s->flags &= ~SIO_TIMEOUT;

-  if ( s->timeout >= 0 )
+  if ( s->timeout >= 0 && !s->downstream )
   { int fd = Sfileno(s);

     if ( fd >= 0 )
@@ -1393,6 +1393,10 @@
   { errno = EINVAL;
     return -1;
   }
+
+  if ( s->downstream != NULL &&
+       Sfeof(s->downstream))
+    return TRUE;

   if ( S__fillbuf(s) == -1 )
     return TRUE;


Copyright fix

Copyright fix

--- AnobiKit/Classes/AKMapping/AKObjectMapping.h
+++ AnobiKit/Classes/AKMapping/AKObjectMapping.h
@@ -3,6 +3,7 @@
 //  AnobiKit
 //
 //  Created by Stanislav Pletnev on 06.10.17.
+//  Copyright © 2017 Anobisoft. All rights reserved.
 //

 #import <Foundation/Foundation.h>


Cleanup unused LD

Cleanup unused LD

--- src/pl-thread.c
+++ src/pl-thread.c
@@ -723,9 +723,7 @@
   TLD_set_LD(&PL_local_data);

   PL_local_data.magic = LD_MAGIC;
-  { GET_LD
-
-    GD->thread.thread_max = 4;		/* see resizeThreadMax() */
+  { GD->thread.thread_max = 4;		/* see resizeThreadMax() */
     GD->thread.threads = allocHeapOrHalt(GD->thread.thread_max *
 				   sizeof(*GD->thread.threads));
     memset(GD->thread.threads, 0,


runtime: make raw channel functions private

Derived classes should now always use Handles to refer to channels,
not raw channel references.

--- oak/server/oak_node.h
+++ oak/server/oak_node.h
@@ -83,14 +83,6 @@
   OakStatus NodeCreate(Handle handle, const std::string& config_name,
                        const std::string& entrypoint_name);

-  // Return a borrowed reference to the channel half identified by the given
-  // handle (or nullptr if the handle is not recognized).  Caller is responsible
-  // for ensuring that the borrowed reference does not out-live the owned
-  // channel.
-  ChannelHalf* BorrowChannel(Handle handle) const LOCKS_EXCLUDED(mu_);
-  MessageChannelReadHalf* BorrowReadChannel(Handle handle) const LOCKS_EXCLUDED(mu_);
-  MessageChannelWriteHalf* BorrowWriteChannel(Handle handle) const LOCKS_EXCLUDED(mu_);
-
   // Wait on the given channel handles, modifying the contents of the passed-in
   // vector.  Returns a boolean indicating whether the wait finished due to a
   // channel being ready (true), or a failure (false, indicating either node
@@ -114,6 +106,14 @@

   Handle NextHandle() EXCLUSIVE_LOCKS_REQUIRED(mu_);

+  // Return a borrowed reference to the channel half identified by the given
+  // handle (or nullptr if the handle is not recognized).  Caller is responsible
+  // for ensuring that the borrowed reference does not out-live the owned
+  // channel.
+  ChannelHalf* BorrowChannel(Handle handle) const LOCKS_EXCLUDED(mu_);
+  MessageChannelReadHalf* BorrowReadChannel(Handle handle) const LOCKS_EXCLUDED(mu_);
+  MessageChannelWriteHalf* BorrowWriteChannel(Handle handle) const LOCKS_EXCLUDED(mu_);
+
   using ChannelHalfTable = std::unordered_map<Handle, std::unique_ptr<ChannelHalf>>;

   // Runtime instance that owns this Node.


neon: fix merge error

neon: fix merge error

--- orc/orcprogram.h
+++ orc/orcprogram.h
@@ -352,10 +352,7 @@
   int exec_reg;
   int gp_tmpreg;

-<<<<<<< HEAD:orc/orcprogram.h
   int insn_index;
-=======
->>>>>>> master:orc/orcprogram.h
   int need_mask_regs;
 };


MVRANGE may occur in all frames and RESPIC in all but B-frames

git-svn-id: a4d7c1866f8397a4106e0b57fc4fbf792bbdaaaf@5687 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

--- libavcodec/vc1.c
+++ libavcodec/vc1.c
@@ -1316,6 +1316,17 @@
     if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
         v->pquantizer = get_bits(gb, 1);
     v->dquantfrm = 0;
+    if (v->extended_mv == 1) v->mvrange = get_prefix(gb, 0, 3);
+    v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
+    v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
+    v->range_x = 1 << (v->k_x - 1);
+    v->range_y = 1 << (v->k_y - 1);
+    if (v->profile == PROFILE_ADVANCED)
+    {
+        if (v->postprocflag) v->postproc = get_bits(gb, 1);
+    }
+    else
+        if (v->multires && v->s.pict_type != B_TYPE) v->respic = get_bits(gb, 2);

 //av_log(v->s.avctx, AV_LOG_INFO, "%c Frame: QP=[%i]%i (+%i/2) %i\n",
 //        (v->s.pict_type == P_TYPE) ? 'P' : ((v->s.pict_type == I_TYPE) ? 'I' : 'B'), pqindex, v->pq, v->halfpq, v->rangeredfrm);
@@ -1327,17 +1338,6 @@
         else if(v->pq < 13) v->tt_index = 1;
         else v->tt_index = 2;

-        if (v->extended_mv == 1) v->mvrange = get_prefix(gb, 0, 3);
-        v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
-        v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
-        v->range_x = 1 << (v->k_x - 1);
-        v->range_y = 1 << (v->k_y - 1);
-        if (v->profile == PROFILE_ADVANCED)
-        {
-            if (v->postprocflag) v->postproc = get_bits(gb, 1);
-        }
-        else
-            if (v->multires) v->respic = get_bits(gb, 2);
         lowquant = (v->pq > 12) ? 0 : 1;
         v->mv_mode = mv_pmode_table[lowquant][get_prefix(gb, 1, 4)];
         if (v->mv_mode == MV_PMODE_INTENSITY_COMP)


O == X1

O == X1


Fix the label count for the join_any and join_none cases

--- tgt-vvp/vvp_process.c
+++ tgt-vvp/vvp_process.c
@@ -1489,6 +1489,10 @@
       unsigned out = transient_id++;
       unsigned id_base = transient_id;

+	/* Increment the number of IDs needed before the join count is
+	 * modified by the join_any or join_none code below. */
+      transient_id += join_count;
+
       switch (ivl_statement_type(net)) {
 	  case IVL_ST_FORK:
 	    break;
@@ -1508,8 +1512,6 @@

       if (scope==0)
 	    scope = sscope;
-
-      transient_id += join_count;

 	/* Draw a fork statement for all but one of the threads of the
 	   fork/join. Send the threads off to a bit of code where they


boot: Warning fixups after dual image XIP/ram-load

This change introduced a few warnings that weren't caught until enabling
simulator builds with these features enabled.  Add some simple
workarounds to avoid the warnings.

Signed-off-by: David Brown <0af22db655f3ade5845314d695c1f4910314b0cb@linaro.org>

--- boot/bootutil/src/loader.c
+++ boot/bootutil/src/loader.c
@@ -2242,6 +2242,8 @@
 {
     uint32_t active_slot;

+    (void)state;
+
     IMAGES_ITER(BOOT_CURR_IMG(state)) {
         active_slot = slot_usage[BOOT_CURR_IMG(state)].active_slot;

@@ -2354,6 +2356,9 @@
     uint32_t img_end_addr;
     uint32_t exec_ram_start;
     uint32_t exec_ram_size;
+
+    (void)state;
+
 #ifdef MULTIPLE_EXECUTABLE_RAM_REGIONS
     int      rc;

@@ -2582,11 +2587,13 @@
 boot_remove_image_from_sram(struct boot_loader_state *state,
                             struct slot_usage_t slot_usage[])
 {
+    (void)state;
+
     BOOT_LOG_INF("Removing image from SRAM at address 0x%x",
                  slot_usage[BOOT_CURR_IMG(state)].img_dst);

-    memset((void*)slot_usage[BOOT_CURR_IMG(state)].img_dst, 0,
-           slot_usage[BOOT_CURR_IMG(state)].img_sz);
+    memset((void*)(IMAGE_RAM_BASE + slot_usage[BOOT_CURR_IMG(state)].img_dst),
+           0, slot_usage[BOOT_CURR_IMG(state)].img_sz);

     slot_usage[BOOT_CURR_IMG(state)].img_dst = 0;
     slot_usage[BOOT_CURR_IMG(state)].img_sz = 0;
@@ -2608,6 +2615,8 @@
     int area_id;
     int rc;
     const struct flash_area *fap;
+
+    (void)state;

     BOOT_LOG_INF("Removing image %d slot %d from flash", BOOT_CURR_IMG(state),
                                                          slot);
@@ -2917,7 +2926,7 @@
 {
     struct slot_usage_t slot_usage[BOOT_IMAGE_NUMBER];
     int rc;
-    fih_int fih_rc;
+    fih_int fih_rc = fih_int_encode(0);

     memset(state, 0, sizeof(struct boot_loader_state));
     memset(slot_usage, 0, sizeof(struct slot_usage_t) * BOOT_IMAGE_NUMBER);


Add enormous switch block for properties

--- libcss-handler.c
+++ libcss-handler.c
@@ -275,7 +275,234 @@

 uint64_t get_property (css_stylesheet* sheet, const char* prop)
 {
-
+case CSS_PROP_AZIMUTH:
+break;
+case CSS_PROP_BACKGROUND_ATTACHMENT:
+break;
+case CSS_PROP_BACKGROUND_COLOR:
+break;
+case CSS_PROP_BACKGROUND_IMAGE:
+break;
+case CSS_PROP_BACKGROUND_POSITION:
+break;
+case CSS_PROP_BACKGROUND_REPEAT:
+break;
+case CSS_PROP_BORDER_COLLAPSE:
+break;
+case CSS_PROP_BORDER_SPACING:
+break;
+case CSS_PROP_BORDER_TOP_COLOR:
+break;
+case CSS_PROP_BORDER_RIGHT_COLOR:
+break;
+case CSS_PROP_BORDER_BOTTOM_COLOR:
+break;
+case CSS_PROP_BORDER_LEFT_COLOR:
+break;
+case CSS_PROP_BORDER_TOP_STYLE:
+break;
+case CSS_PROP_BORDER_RIGHT_STYLE:
+break;
+case CSS_PROP_BORDER_BOTTOM_STYLE:
+break;
+case CSS_PROP_BORDER_LEFT_STYLE:
+break;
+case CSS_PROP_BORDER_TOP_WIDTH:
+break;
+case CSS_PROP_BORDER_RIGHT_WIDTH:
+break;
+case CSS_PROP_BORDER_BOTTOM_WIDTH:
+break;
+case CSS_PROP_BORDER_LEFT_WIDTH:
+break;
+case CSS_PROP_BOTTOM:
+break;
+case CSS_PROP_CAPTION_SIDE:
+break;
+case CSS_PROP_CLEAR:
+break;
+case CSS_PROP_CLIP:
+break;
+case CSS_PROP_COLOR:
+break;
+case CSS_PROP_CONTENT:
+break;
+case CSS_PROP_COUNTER_INCREMENT:
+break;
+case CSS_PROP_COUNTER_RESET:
+break;
+case CSS_PROP_CUE_AFTER:
+break;
+case CSS_PROP_CUE_BEFORE:
+break;
+case CSS_PROP_CURSOR:
+break;
+case CSS_PROP_DIRECTION:
+break;
+case CSS_PROP_DISPLAY:
+break;
+case CSS_PROP_ELEVATION:
+break;
+case CSS_PROP_EMPTY_CELLS:
+break;
+case CSS_PROP_FLOAT:
+break;
+case CSS_PROP_FONT_FAMILY:
+break;
+case CSS_PROP_FONT_SIZE:
+break;
+case CSS_PROP_FONT_STYLE:
+break;
+case CSS_PROP_FONT_VARIANT:
+break;
+case CSS_PROP_FONT_WEIGHT:
+break;
+case CSS_PROP_HEIGHT:
+break;
+case CSS_PROP_LEFT:
+break;
+case CSS_PROP_LETTER_SPACING:
+break;
+case CSS_PROP_LINE_HEIGHT:
+break;
+case CSS_PROP_LIST_STYLE_IMAGE:
+break;
+case CSS_PROP_LIST_STYLE_POSITION:
+break;
+case CSS_PROP_LIST_STYLE_TYPE:
+break;
+case CSS_PROP_MARGIN_TOP:
+break;
+case CSS_PROP_MARGIN_RIGHT:
+break;
+case CSS_PROP_MARGIN_BOTTOM:
+break;
+case CSS_PROP_MARGIN_LEFT:
+break;
+case CSS_PROP_MAX_HEIGHT:
+break;
+case CSS_PROP_MAX_WIDTH:
+break;
+case CSS_PROP_MIN_HEIGHT:
+break;
+case CSS_PROP_MIN_WIDTH:
+break;
+case CSS_PROP_ORPHANS:
+break;
+case CSS_PROP_OUTLINE_COLOR:
+break;
+case CSS_PROP_OUTLINE_STYLE:
+break;
+case CSS_PROP_OUTLINE_WIDTH:
+break;
+case CSS_PROP_OVERFLOW_X:
+break;
+case CSS_PROP_PADDING_TOP:
+break;
+case CSS_PROP_PADDING_RIGHT:
+break;
+case CSS_PROP_PADDING_BOTTOM:
+break;
+case CSS_PROP_PADDING_LEFT:
+break;
+case CSS_PROP_PAGE_BREAK_AFTER:
+break;
+case CSS_PROP_PAGE_BREAK_BEFORE:
+break;
+case CSS_PROP_PAGE_BREAK_INSIDE:
+break;
+case CSS_PROP_PAUSE_AFTER:
+break;
+case CSS_PROP_PAUSE_BEFORE:
+break;
+case CSS_PROP_PITCH_RANGE:
+break;
+case CSS_PROP_PITCH:
+break;
+case CSS_PROP_PLAY_DURING:
+break;
+case CSS_PROP_POSITION:
+break;
+case CSS_PROP_QUOTES:
+break;
+case CSS_PROP_RICHNESS:
+break;
+case CSS_PROP_RIGHT:
+break;
+case CSS_PROP_SPEAK_HEADER:
+break;
+case CSS_PROP_SPEAK_NUMERAL:
+break;
+case CSS_PROP_SPEAK_PUNCTUATION:
+break;
+case CSS_PROP_SPEAK:
+break;
+case CSS_PROP_SPEECH_RATE:
+break;
+case CSS_PROP_STRESS:
+break;
+case CSS_PROP_TABLE_LAYOUT:
+break;
+case CSS_PROP_TEXT_ALIGN:
+break;
+case CSS_PROP_TEXT_DECORATION:
+break;
+case CSS_PROP_TEXT_INDENT:
+break;
+case CSS_PROP_TEXT_TRANSFORM:
+break;
+case CSS_PROP_TOP:
+break;
+case CSS_PROP_UNICODE_BIDI:
+break;
+case CSS_PROP_VERTICAL_ALIGN:
+break;
+case CSS_PROP_VISIBILITY:
+break;
+case CSS_PROP_VOICE_FAMILY:
+break;
+case CSS_PROP_VOLUME:
+break;
+case CSS_PROP_WHITE_SPACE:
+break;
+case CSS_PROP_WIDOWS:
+break;
+case CSS_PROP_WIDTH:
+break;
+case CSS_PROP_WORD_SPACING:
+break;
+case CSS_PROP_Z_INDEX:
+break;
+case CSS_PROP_OPACITY:
+break;
+case CSS_PROP_BREAK_AFTER:
+break;
+case CSS_PROP_BREAK_BEFORE:
+break;
+case CSS_PROP_BREAK_INSIDE:
+break;
+case CSS_PROP_COLUMN_COUNT:
+break;
+case CSS_PROP_COLUMN_FILL:
+break;
+case CSS_PROP_COLUMN_GAP:
+break;
+case CSS_PROP_COLUMN_RULE_COLOR:
+break;
+case CSS_PROP_COLUMN_RULE_STYLE:
+break;
+case CSS_PROP_COLUMN_RULE_WIDTH:
+break;
+case CSS_PROP_COLUMN_SPAN:
+break;
+case CSS_PROP_COLUMN_WIDTH:
+break;
+case CSS_PROP_WRITING_MODE:
+break;
+case CSS_PROP_OVERFLOW_Y:
+break;
+case CSS_PROP_BOX_SIZING:
+break;
 }

 const int UA_FONT_SIZE = js_ua_font_size();


Use sizeof() for snprintf() buffer length.

--- src/port/exec.c
+++ src/port/exec.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/port/exec.c,v 1.54 2007/01/29 20:17:40 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/port/exec.c,v 1.55 2007/01/29 20:22:35 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -590,7 +590,7 @@
 	{
 		char str[256];

-		snprintf(str, 256, "%d: %s", WTERMSIG(exitstatus),
+		snprintf(str, sizeof(str), "%d: %s", WTERMSIG(exitstatus),
 			  WTERMSIG(exitstatus) < NSIG ?
 			  sys_siglist[WTERMSIG(exitstatus)] : "(unknown)");
 		log_error(_("child process was terminated by signal %s"), str);


lib: add abs function to minimal libc

lib: add abs function to minimal libc

Add abs function to the minimal libc. This is present in
NEWLIB_LIBC, but adding it here avoid to make a dependency
with NEWLIB_LIBC.

Signed-off-by: Vincent Veron <d0437362c556ce51fce5edebef610c1693e26118@st.com>

--- lib/libc/minimal/include/stdlib.h
+++ lib/libc/minimal/include/stdlib.h
@@ -18,6 +18,8 @@
 long int strtol(const char *str, char **endptr, int base);
 int atoi(const char *s);

+#define abs(x) ((x) < 0 ? -(x) : (x))
+
 #ifdef __cplusplus
 }
 #endif


During an upgrade, if /boot/kernel.prev exists then the backup of
/boot/kernel can fail.  Try to remove /boot/kernel.prev and cope the
best we can if that fails.

PR:		bin/106376
Submitted by:	Nobuyuki Koganemaru
Approved by:	ru
MFC after:	2 weeks

--- usr.sbin/sysinstall/installUpgrade.c
+++ usr.sbin/sysinstall/installUpgrade.c
@@ -300,6 +300,15 @@
 	(void)vsystem("chflags -R noschg /bin /sbin /lib /libexec /usr/bin /usr/sbin /usr/lib /usr/libexec /var/empty /boot/kernel*");

 	if (directory_exists("/boot/kernel")) {
+	    if (directory_exists("/boot/kernel.prev")) {
+		msgNotify("Removing /boot/kernel.prev");
+		if (system("rm -fr /boot/kernel.prev")) {
+		    msgConfirm("NOTICE: I'm trying to back up /boot/kernel to\n"
+			       "/boot/kernel.prev, but /boot/kernel.prev exists and I\n"
+			       "can't remove it.  This means that the backup will, in\n"
+			       "all probability, fail.");
+		}
+	    }
 	    msgNotify("Moving old kernel to /boot/kernel.prev");
 	    if (system("mv /boot/kernel /boot/kernel.prev")) {
 		if (!msgYesNo("Hmmm!  I couldn't move the old kernel over!  Do you want to\n"
@@ -472,6 +481,15 @@
      *  crash and reboot.
      */
     if (directory_exists("/boot/kernel")) {
+	if (directory_exists("/boot/kernel.prev")) {
+	    msgNotify("Removing /boot/kernel.prev");
+	    if (system("rm -fr /boot/kernel.prev")) {
+		msgConfirm("NOTICE: I'm trying to back up /boot/kernel to\n"
+		    "/boot/kernel.prev, but /boot/kernel.prev exists and I\n"
+		    "can't remove it.  This means that the backup will, in\n"
+		    "all probability, fail.");
+	    }
+	}
 	msgNotify("Copying old kernel to /boot/kernel.prev");
 	vsystem("cp -Rp /boot/kernel /boot/kernel.prev");
     }


PHPC-284: Fix LogicException declaration

--- php_phongo_classes.h
+++ php_phongo_classes.h
@@ -226,6 +226,7 @@
 PHP_MINIT_FUNCTION(WriteResult);

 PHP_MINIT_FUNCTION(Exception);
+PHP_MINIT_FUNCTION(LogicException);
 PHP_MINIT_FUNCTION(RuntimeException);
 PHP_MINIT_FUNCTION(UnexpectedValueException);
 PHP_MINIT_FUNCTION(InvalidArgumentException);


Small cleanup for loop.

Small cleanup for loop.

--- libhashkit/fnv.c
+++ libhashkit/fnv.c
@@ -18,9 +18,8 @@
 {
   /* Thanks to pierre@demartines.com for the pointer */
   uint64_t hash= FNV_64_INIT;
-  size_t x= 0;

-  for (x= 0; x < key_length; x++)
+  for (size_t x= 0; x < key_length; x++)
   {
     hash *= FNV_64_PRIME;
     hash ^= (uint64_t)key[x];
@@ -32,9 +31,8 @@
 uint32_t hashkit_fnv1a_64(const char *key, size_t key_length)
 {
   uint32_t hash= (uint32_t) FNV_64_INIT;
-  size_t x= 0;

-  for (x= 0; x < key_length; x++)
+  for (size_t x= 0; x < key_length; x++)
   {
     uint32_t val= (uint32_t)key[x];
     hash ^= val;
@@ -47,9 +45,8 @@
 uint32_t hashkit_fnv1_32(const char *key, size_t key_length)
 {
   uint32_t hash= FNV_32_INIT;
-  size_t x= 0;

-  for (x= 0; x < key_length; x++)
+  for (size_t x= 0; x < key_length; x++)
   {
     uint32_t val= (uint32_t)key[x];
     hash *= FNV_32_PRIME;
@@ -62,9 +59,8 @@
 uint32_t hashkit_fnv1a_32(const char *key, size_t key_length)
 {
   uint32_t hash= FNV_32_INIT;
-  size_t x= 0;

-  for (x= 0; x < key_length; x++)
+  for (size_t x= 0; x < key_length; x++)
   {
     uint32_t val= (uint32_t)key[x];
     hash ^= val;


Made consistent with 'em_parser.h' and 'decl.h'

--- util/ceg/EM_parser/common/arg_type.h
+++ util/ceg/EM_parser/common/arg_type.h
@@ -1,3 +1,4 @@
 #define STRING		0
-#define ARITH		1
-#define INT		2
+#define LABEL		1
+#define ARITH		2
+#define INT		3


Fix documentation typo

Fix documentation typo

--- liblick/drives.h
+++ liblick/drives.h
@@ -11,7 +11,7 @@
  * the types of drives
  */
 enum DRIVE_TYPES {
-    // other
+    /// other
     DRV_UNKNOWN,
     /// an internal hard drive
     DRV_HDD,


Call new_file_transaction at the right place

--- lib/metalink/metalink_pstate_v4.c
+++ lib/metalink/metalink_pstate_v4.c
@@ -39,7 +39,29 @@
 				 const char* name, const char* ns_uri,
 				 const char** attrs)
 {
+  metalink_error_t r;
+
   if(strcmp("file", name) == 0) {
+    const char* fname;
+    metalink_file_t* file;
+
+    fname = get_attribute_value(attrs, "name");
+    if(!metalink_check_safe_path(fname)) {
+      metalink_pstm_enter_skip_state(stm);
+      return;
+    }
+
+    file = metalink_pctrl_new_file_transaction(stm->ctrl);
+    if(!file) {
+      error_handler(stm, METALINK_ERR_BAD_ALLOC);
+      return;
+    }
+    r = metalink_pctrl_file_set_name(stm->ctrl, fname);
+    if(r !=  0) {
+      error_handler(stm, r);
+      return;
+    }
+
     metalink_pstm_enter_file_state_v4(stm);
   } else if(strcmp("generator", name) == 0) {
     metalink_pstm_enter_generator_state(stm);
@@ -116,27 +138,7 @@
 {
   metalink_error_t r;

-  if(strcmp("file", name) == 0) {
-    const char* fname;
-    metalink_file_t* file;
-
-    fname = get_attribute_value(attrs, "name");
-    if(!metalink_check_safe_path(fname)) {
-      metalink_pstm_enter_skip_state(stm);
-      return;
-    }
-
-    file = metalink_pctrl_new_file_transaction(stm->ctrl);
-    if(!file) {
-      error_handler(stm, METALINK_ERR_BAD_ALLOC);
-      return;
-    }
-    r = metalink_pctrl_file_set_name(stm->ctrl, fname);
-    if(r !=  0) {
-      error_handler(stm, r);
-      return;
-    }
-  } else if(strcmp("url", name) == 0) {
+  if(strcmp("url", name) == 0) {
     const char* location;
     const char* value;
     long int priority = 0;


libmdnsd: fix port endian

libmdnsd: fix port endian

--- libmdnsd/mdnsd.c
+++ libmdnsd/mdnsd.c
@@ -948,7 +948,7 @@
 		INFO("Send Unicast Answer: Name: %s, Type: %d", u->r->rr.name, u->r->rr.type);

 		d->uanswers = u->next;
-		*port = u->port;
+		*port = htons(u->port);
 		*ip = u->to;
 		m->id = u->id;
 		message_qd(m, u->r->rr.name, u->r->rr.type, d->class);


Select AMS hash algorithm based on parameters to arc_message() rather than trying to divine it from the existing chain (which may not exist). Based on PR #48.

--- libopenarc/arc.c
+++ libopenarc/arc.c
@@ -2519,7 +2519,7 @@
 		htag = arc_param_get(h->hdr_data, "h");
 	}

-	if (strcmp(arc_param_get(h->hdr_data, "a"), "rsa-sha1") == 0)
+	if (msg->arc_signalg == ARC_SIGN_RSASHA1)
 		hashtype = ARC_HASHTYPE_SHA1;
 	else
 		hashtype = ARC_HASHTYPE_SHA256;


target: Cleanup pib_read/write() to make easier to read

Currently we change input parameter addr to have a different meaning
making the code hard to read.

This adds a new local variable target_addr to make it easier to read.

This also adds a pr_debug() to each so we can see whats happening.

Signed-off-by: Michael Neuling <7b0ab45a730e48a69239010b5b8fe5fa4e8eaac6@neuling.org>

--- libpdbg/target.c
+++ libpdbg/target.c
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdint.h>
+#include <inttypes.h>
 #include <assert.h>
 #include <ccan/list/list.h>
 #include <libfdt/libfdt.h>
@@ -112,28 +113,34 @@
 int pib_read(struct pdbg_target *pib_dt, uint64_t addr, uint64_t *data)
 {
 	struct pib *pib;
+	uint64_t target_addr = addr;
 	int rc;

-	pib_dt = get_class_target_addr(pib_dt, "pib", &addr);
+	pib_dt = get_class_target_addr(pib_dt, "pib", &target_addr);
 	pib = target_to_pib(pib_dt);
-	if (addr & PPC_BIT(0))
-		rc = pib_indirect_read(pib, addr, data);
+	if (target_addr & PPC_BIT(0))
+		rc = pib_indirect_read(pib, target_addr, data);
 	else
-		rc = pib->read(pib, addr, data);
+		rc = pib->read(pib, target_addr, data);
+	PR_DEBUG("addr:0x%08" PRIx64 " data:0x%016" PRIx64 "\n",
+		 target_addr, *data);
 	return rc;
 }

 int pib_write(struct pdbg_target *pib_dt, uint64_t addr, uint64_t data)
 {
 	struct pib *pib;
+	uint64_t target_addr = addr;
 	int rc;

-	pib_dt = get_class_target_addr(pib_dt, "pib", &addr);
+	pib_dt = get_class_target_addr(pib_dt, "pib", &target_addr);
 	pib = target_to_pib(pib_dt);
-	if (addr & PPC_BIT(0))
-		rc = pib_indirect_write(pib, addr, data);
+	PR_DEBUG("addr:0x%08" PRIx64 " data:0x%016" PRIx64 "\n",
+		 target_addr, data);
+	if (target_addr & PPC_BIT(0))
+		rc = pib_indirect_write(pib, target_addr, data);
 	else
-		rc = pib->write(pib, addr, data);
+		rc = pib->write(pib, target_addr, data);
 	return rc;
 }


Do not restore flags from the package if the used libarchive is 2.8.x it does not handle st_flags

--- libpkg/pkg_add.c
+++ libpkg/pkg_add.c
@@ -287,8 +287,11 @@
 				goto cleanup;
 			}
 #ifdef HAVE_CHFLAGS
-			/* Restore flags on the final file */
+			/* Restore flags on the final file exept on libarchive pre 3.x*/
+#if ARCHIVE_VERSION_NUMBER >= 3000002
 			chflags(pathname, aest->st_flags);
+#endif
+
 #endif
 		}


Return an error if trying to extract a file that does not belong to the
manifest

Reported by:	coverity
CID:		1355023

--- libpkg/pkg_add.c
+++ libpkg/pkg_add.c
@@ -318,6 +318,7 @@
 	f = pkg_get_file(pkg, path);
 	if (f == NULL) {
 		pkg_emit_error("File %s not specified in the manifest");
+		return (EPKG_FATAL);
 	}

 	if (!mkdirat_p(pkg->rootfd, bsd_dirname(path)))


Check shlib arch prior testing it.

Check shlib arch prior testing it.

--- libpkg/pkg_elf.c
+++ libpkg/pkg_elf.c
@@ -222,12 +222,14 @@
 	size_t sh_link = 0;
 	size_t dynidx;
 	const char *osname;
+	const char *myarch;
 	const char *shlib;

 	bool developer = false;
 	bool is_shlib = false;

 	developer = pkg_object_bool(pkg_config_get("DEVELOPER_MODE"));
+	myarch = pkg_object_string(pkg_config_get("ABI"));

 	int fd;

@@ -301,6 +303,11 @@
 	if (dynamic == NULL) {
 		ret = EPKG_END;
 		goto cleanup; /* not a dynamically linked elf: no results */
+	}
+
+	if (!shlib_valid_abi(&elfhdr, myarch)) {
+		ret = EPKG_END;
+		goto cleanup; /* Invalid ABI */
 	}

 	if (note != NULL) {


pkg {register, check -B}: Fix registering provided shlibs as required

--- libpkg/pkg_elf.c
+++ libpkg/pkg_elf.c
@@ -445,8 +445,10 @@
 pkg_analyse_files(struct pkgdb *db, struct pkg *pkg, const char *stage)
 {
 	struct pkg_file *file = NULL;
+	struct pkg_shlib *sh, *shtmp, *found;
 	int ret = EPKG_OK;
 	char fpath[MAXPATHLEN];
+	const char *origin;
 	bool developer = false;

 	developer = pkg_object_bool(pkg_config_get("DEVELOPER_MODE"));
@@ -477,6 +479,20 @@
 			if (ret != EPKG_OK && ret != EPKG_END)
 				goto cleanup;
 			analyse_fpath(pkg, fpath);
+		}
+	}
+
+	pkg_get(pkg, PKG_ORIGIN, &origin);
+	/*
+	 * Do not depend on libraries that a package provides itself
+	 */
+	HASH_ITER(hh, pkg->shlibs_required, sh, shtmp) {
+		HASH_FIND_STR(pkg->shlibs_provided, pkg_shlib_name(sh), found);
+		if (found != NULL) {
+			pkg_debug(2, "remove %s from required shlibs as the "
+			    "package %s provides this library itself",
+			    pkg_shlib_name(sh), origin);
+			HASH_DEL(pkg->shlibs_required, sh);
 		}
 	}


Add debug message to scripts

Add debug message to scripts

--- libpkg/scripts.c
+++ libpkg/scripts.c
@@ -116,6 +116,7 @@
 				argmax -= strlen(*ep) + 1 + sizeof(*ep);
 			argmax -= 1 + sizeof(*ep);

+			pkg_debug(3, "Scripts: executing\n--- BEGIN ---\n%s\nScripts: --- END ---", sbuf_get(script_cmd));
 			if (sbuf_len(script_cmd) > argmax) {
 				if (pipe(stdin_pipe) < 0) {
 					ret = EPKG_FATAL;


storage: Resolve resource leak using 'vol' buffer

--- src/storage/storage_backend_rbd.c
+++ src/storage/storage_backend_rbd.c
@@ -1,6 +1,7 @@
 /*
  * storage_backend_rbd.c: storage backend for RBD (RADOS Block Device) handling
  *
+ * Copyright (C) 2013 Red Hat, Inc.
  * Copyright (C) 2012 Wido den Hollander
  *
  * This library is free software; you can redistribute it and/or
@@ -319,26 +320,31 @@
     }

     for (i = 0, name = names; name < names + max_size; i++) {
+        virStorageVolDefPtr vol;
+
         if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count + 1) < 0) {
             virStoragePoolObjClearVols(pool);
             goto out_of_memory;
         }

-        virStorageVolDefPtr vol;
+        if (STREQ(name, ""))
+            break;
+
         if (VIR_ALLOC(vol) < 0)
             goto out_of_memory;

         vol->name = strdup(name);
-        if (vol->name == NULL)
+        if (vol->name == NULL) {
+            VIR_FREE(vol);
             goto out_of_memory;
-
-        if (STREQ(vol->name, ""))
-            break;
+        }

         name += strlen(name) + 1;

-        if (volStorageBackendRBDRefreshVolInfo(vol, pool, ptr) < 0)
-            goto cleanup;
+        if (volStorageBackendRBDRefreshVolInfo(vol, pool, ptr) < 0) {
+            virStorageVolDefFree(vol);
+            goto cleanup;
+        }

         pool->volumes.objs[pool->volumes.count++] = vol;
     }


Stream: the $bytes_received variable.

Stream: the $bytes_received variable.

The variable keeps the number of bytes received from the client.

--- src/stream/ngx_stream_variables.c
+++ src/stream/ngx_stream_variables.c
@@ -21,7 +21,7 @@
     ngx_stream_variable_value_t *v, uintptr_t data);
 static ngx_int_t ngx_stream_variable_server_port(ngx_stream_session_t *s,
     ngx_stream_variable_value_t *v, uintptr_t data);
-static ngx_int_t ngx_stream_variable_bytes_sent(ngx_stream_session_t *s,
+static ngx_int_t ngx_stream_variable_bytes(ngx_stream_session_t *s,
     ngx_stream_variable_value_t *v, uintptr_t data);
 static ngx_int_t ngx_stream_variable_connection(ngx_stream_session_t *s,
     ngx_stream_variable_value_t *v, uintptr_t data);
@@ -57,8 +57,11 @@
     { ngx_string("server_port"), NULL,
       ngx_stream_variable_server_port, 0, 0, 0 },

-    { ngx_string("bytes_sent"), NULL, ngx_stream_variable_bytes_sent,
+    { ngx_string("bytes_sent"), NULL, ngx_stream_variable_bytes,
       0, 0, 0 },
+
+    { ngx_string("bytes_received"), NULL, ngx_stream_variable_bytes,
+      1, 0, 0 },

     { ngx_string("connection"), NULL,
       ngx_stream_variable_connection, 0, 0, 0 },
@@ -461,7 +464,7 @@

 static ngx_int_t
-ngx_stream_variable_bytes_sent(ngx_stream_session_t *s,
+ngx_stream_variable_bytes(ngx_stream_session_t *s,
     ngx_stream_variable_value_t *v, uintptr_t data)
 {
     u_char  *p;
@@ -471,7 +474,13 @@
         return NGX_ERROR;
     }

-    v->len = ngx_sprintf(p, "%O", s->connection->sent) - p;
+    if (data == 1) {
+        v->len = ngx_sprintf(p, "%O", s->received) - p;
+
+    } else {
+        v->len = ngx_sprintf(p, "%O", s->connection->sent) - p;
+    }
+
     v->valid = 1;
     v->no_cacheable = 0;
     v->not_found = 0;


ppc64_cpu: make internal functions static

A cleanup before making future changes; make all the internal
functions (in this case, everything except main) and global variables
static.

Signed-off-by: Joel Stanley <4816dabf8db1bc6cac35b3a24cab2ff844b5b0c7@jms.id.au>

--- src/ppc64_cpu.c
+++ src/ppc64_cpu.c
@@ -50,11 +50,11 @@

 #endif

-int threads_per_cpu = 0;
-int cpus_in_system = 0;
-int threads_in_system = 0;
-
-int test_attr(char *path, char *perms)
+static int threads_per_cpu = 0;
+static int cpus_in_system = 0;
+static int threads_in_system = 0;
+
+static int test_attr(char *path, char *perms)
 {
 	FILE *fp;

@@ -71,17 +71,17 @@
 	return 0;
 }

-int attr_is_readable(char *path)
+static int attr_is_readable(char *path)
 {
 	return test_attr(path, "r");
 }

-int attr_is_writeable(char *path)
+static int attr_is_writeable(char *path)
 {
 	return test_attr(path, "w");
 }

-int test_sysattr(char *attribute, char *perms)
+static int test_sysattr(char *attribute, char *perms)
 {
 	char path[SYSFS_PATH_MAX];
 	int i;
@@ -95,17 +95,17 @@
 	return 1;
 }

-int sysattr_is_readable(char *attribute)
+static int sysattr_is_readable(char *attribute)
 {
 	return test_sysattr(attribute, "r");
 }

-int sysattr_is_writeable(char *attribute)
+static int sysattr_is_writeable(char *attribute)
 {
 	return test_sysattr(attribute, "w");
 }

-int get_attribute(char *path, const char *fmt, int *value)
+static int get_attribute(char *path, const char *fmt, int *value)
 {
 	FILE *fp;
 	int rc;
@@ -125,7 +125,7 @@
 	return 0;
 }

-int set_attribute(const char *path, const char *fmt, int value)
+static int set_attribute(const char *path, const char *fmt, int value)
 {
 	FILE *fp;

@@ -139,7 +139,7 @@
 	return 0;
 }

-int cpu_online(int thread)
+static int cpu_online(int thread)
 {
 	char path[SYSFS_PATH_MAX];
 	int rc, online;
@@ -152,7 +152,7 @@
 	return 1;
 }

-int get_system_attribute(char *attribute, const char *fmt, int *value,
+static int get_system_attribute(char *attribute, const char *fmt, int *value,
 			 int *inconsistent)
 {
 	char path[SYSFS_PATH_MAX];
@@ -179,7 +179,7 @@
 	return 0;
 }

-int set_system_attribute(char *attribute, const char *fmt, int state)
+static int set_system_attribute(char *attribute, const char *fmt, int state)
 {
 	char path[SYSFS_PATH_MAX];
 	int i, rc;
@@ -194,7 +194,7 @@
 	return 0;
 }

-int dscr_default_exists(void)
+static int dscr_default_exists(void)
 {
 	struct stat sb;

@@ -208,7 +208,7 @@
  * specific dscr value.  This is because the dscr value is now thread
  * specific.
  */
-int set_dscr(int state)
+static int set_dscr(int state)
 {
 	int rc;

@@ -231,7 +231,7 @@
 	return rc;
 }

-int get_dscr(int *value, int *inconsistent)
+static int get_dscr(int *value, int *inconsistent)
 {
 	int rc;

@@ -254,7 +254,7 @@
 	return rc;
 }

-int set_smt_snooze_delay(int delay)
+static int set_smt_snooze_delay(int delay)
 {
 	if (!sysattr_is_writeable("smt_snooze_delay")) {
 		perror("Cannot set smt snooze delay");
@@ -264,7 +264,7 @@
 	return set_system_attribute("smt_snooze_delay", "%d", delay);
 }

-int get_smt_snooze_delay(int *delay, int *inconsistent)
+static int get_smt_snooze_delay(int *delay, int *inconsistent)
 {
 	if (!sysattr_is_readable("smt_snooze_delay")) {
 		perror("Cannot retrieve smt snooze delay");
@@ -275,18 +275,18 @@
 				    inconsistent);
 }

-int online_thread(const char *path)
+static int online_thread(const char *path)
 {
 	return set_attribute(path, "%d", 1);
 }

-int offline_thread(const char *path)
+static int offline_thread(const char *path)
 {
 	return set_attribute(path, "%d", 0);
 }

-int get_cpu_info(void)
+static int get_cpu_info(void)
 {
 	DIR *d;
 	struct dirent *de;
@@ -320,7 +320,7 @@
 	return 0;
 }

-int is_smt_capable(void)
+static int is_smt_capable(void)
 {
 	struct stat sb;
 	char path[SYSFS_PATH_MAX];
@@ -336,7 +336,7 @@
 	return 0;
 }

-int get_one_smt_state(int primary_thread)
+static int get_one_smt_state(int primary_thread)
 {
 	int thread_state;
 	int smt_state = 0;
@@ -350,7 +350,7 @@
 	return smt_state ? smt_state : -1;
 }

-int get_smt_state(void)
+static int get_smt_state(void)
 {
 	int system_state = -1;
 	int i;
@@ -376,7 +376,7 @@
 	return system_state;
 }

-int set_one_smt_state(int thread, int online_threads)
+static int set_one_smt_state(int thread, int online_threads)
 {
 	char path[SYSFS_PATH_MAX];
 	int i, rc;
@@ -400,7 +400,7 @@
 	return rc;
 }

-int set_smt_state(int smt_state)
+static int set_smt_state(int smt_state)
 {
 	int i, rc;
 	int ssd, update_ssd = 1;
@@ -429,7 +429,7 @@
 	return rc;
 }

-int is_dscr_capable(void)
+static int is_dscr_capable(void)
 {
 	struct stat sb;
 	char path[SYSFS_PATH_MAX];
@@ -448,7 +448,7 @@
 	return 0;
 }

-int do_smt(char *state)
+static int do_smt(char *state)
 {
 	int rc = 0;
 	int smt_state;
@@ -493,7 +493,7 @@

 #define PTRACE_DSCR 44

-int do_dscr_pid(int dscr_state, pid_t pid)
+static int do_dscr_pid(int dscr_state, pid_t pid)
 {
 	int rc;

@@ -530,7 +530,7 @@
 	return rc;
 }

-int do_dscr(char *state, pid_t pid)
+static int do_dscr(char *state, pid_t pid)
 {
 	int rc = 0;
 	int dscr_state = 0;
@@ -564,7 +564,7 @@
 	return rc;
 }

-int do_smt_snooze_delay(char *state)
+static int do_smt_snooze_delay(char *state)
 {
 	int rc = 0;

@@ -598,7 +598,7 @@
 	return rc;
 }

-int do_run_mode(char *run_mode)
+static int do_run_mode(char *run_mode)
 {
 	char mode[3];
 	int rc;
@@ -753,7 +753,7 @@
 		; /* Do Nothing */
 }

-char *power_mode(uint64_t mode)
+static char *power_mode(uint64_t mode)
 {
 	switch (mode) {
 	case 0x0001:
@@ -769,7 +769,7 @@
 	}
 }

-void report_system_power_mode(void)
+static void report_system_power_mode(void)
 {
 	FILE *f;
 	char line[128];
@@ -820,7 +820,7 @@
 }

 /* We need an FD per CPU, with a few more for stdin/out/err etc */
-void setrlimit_open_files(void)
+static void setrlimit_open_files(void)
 {
 	struct rlimit old_rlim, new_rlim;
 	int new = threads_in_system + 8;
@@ -838,7 +838,7 @@

 #define freq_calc(cycles, time)	(1.0 * (cycles) / (time) / 1000000000ULL)

-int do_cpu_frequency(int sleep_time)
+static int do_cpu_frequency(int sleep_time)
 {
 	int i, rc;
 	unsigned long long min = -1ULL;
@@ -915,7 +915,7 @@

 #else

-int do_cpu_frequency(void)
+static int do_cpu_frequency(void)
 {
 	printf("CPU Frequency determination is not supported on this "
 	       "platfom.\n");
@@ -924,13 +924,13 @@

 #endif

-int do_cores_present(char * state)
+static int do_cores_present(char * state)
 {
 	printf("Number of cores present = %d\n", cpus_in_system);
 	return 0;
 }

-int set_all_threads_off(int cpu, int smt_state)
+static int set_all_threads_off(int cpu, int smt_state)
 {
 	int i;
 	char path[SYSFS_PATH_MAX];
@@ -946,7 +946,7 @@
 	return rc;
 }

-int set_one_core(int smt_state, int core, int state)
+static int set_one_core(int smt_state, int core, int state)
 {
 	int rc = 0;
 	int cpu = core * threads_per_cpu;
@@ -964,7 +964,7 @@
 	return rc;
 }

-int do_cores_online(char *state)
+static int do_cores_online(char *state)
 {
 	int smt_state;
 	int *core_state;
@@ -1045,7 +1045,7 @@
 	return 0;
 }

-void usage(void)
+static void usage(void)
 {
 	printf(
 "Usage: ppc64_cpu [command] [options]\n"


Comments + Enhancements in ip_ph.c

Comments + Enhancements in ip_ph.c

--- src/ppe/ip_ph.c
+++ src/ppe/ip_ph.c
@@ -1,7 +1,17 @@
+/*
+ * Copyright(C) 2015 Simon Schmidt
+ *
+ * This Source Code Form is subject to the terms of the
+ * Mozilla Public License, v. 2.0. If a copy of the MPL
+ * was not distributed with this file, You can obtain one at
+ * http://mozilla.org/MPL/2.0/.
+ */
 #include <ppe/ip_ph.h>
 #include <ppe/endianess.h>

 /*
+ *
+ *
  *             Figure 1: IPv4 pseudo header
  *
  *   0                   1                   2                   3
@@ -45,24 +55,57 @@
  */

-// TODO: Comments.
 uint64_t ppe_ipphChecksum(IPPH_Struct *ipph, uintptr_t size){
 	uint64_t checksum = 0;
 	uint16_t *ptr = 0;
-	int i;

+	/*
+	 * Check the IP Pseudoheader Type.
+	 * The only accepted values are
+	 *   IPPH_IPv4   and
+	 *   IPPH_IPv6
+	 * Everything else will be ignored, and 0 will be returned.
+	 *
+	 * As the checksum is just an addition of all 16-bit words,
+	 * the order doesn't matter anymore. So, if the source and destination
+	 * IP-addresses are swapped, the resulting checksum is still the same.
+	 */
 	switch(ipph->ipphType){
 	case IPPH_IPv4:
-		checksum += (ipph->ipv4.remote&0xffff) + ((ipph->ipv4.remote>>16)&0xffff);
-		checksum += (ipph->ipv4.local&0xffff) + ((ipph->ipv4.local>>16)&0xffff);
+
+		/*
+		 * Calculating the checksum of the IPv4 Pseudoheader.
+		 * See figure 1.
+		 */
+		checksum += (ipph->ipv4.remote & 0xffff) + ((ipph->ipv4.remote>>16) & 0xffff);
+		checksum += (ipph->ipv4.local  & 0xffff) + ((ipph->ipv4.local>>16)  & 0xffff);
 		checksum += encBE16(ipph->ipv4.protocol);
 		checksum += encBE16(size&0xffff);
 		break;
 	case IPPH_IPv6:
+
+		/*
+		 * Calculating the checksum of the IPv6 Pseudoheader.
+		 * See figure 2.
+		 */
 		ptr = (uint16_t*) ipph->ipv6.remote;
-		for(i = 0;i < 16; ++i) checksum += ptr[i];
+		checksum += ptr[0];
+		checksum += ptr[1];
+		checksum += ptr[2];
+		checksum += ptr[3];
+		checksum += ptr[4];
+		checksum += ptr[5];
+		checksum += ptr[6];
+		checksum += ptr[7];
 		ptr = (uint16_t*) ipph->ipv6.local;
-		for(i = 0;i < 16; ++i) checksum += ptr[i];
+		checksum += ptr[0];
+		checksum += ptr[1];
+		checksum += ptr[2];
+		checksum += ptr[3];
+		checksum += ptr[4];
+		checksum += ptr[5];
+		checksum += ptr[6];
+		checksum += ptr[7];
 		checksum += encBE16(size&0xffff);
 		checksum += encBE16((size>>16)&0xffff);
 		checksum += encBE16(ipph->ipv6.protocol);


- more optimisations on preloader.

- more optimisations on preloader.

--- src/preloader.c
+++ src/preloader.c
@@ -24,7 +24,12 @@
 static void update_square_layer(Layer *layer, GContext* ctx) {

     GRect bounds = layer_get_bounds(layer);
-    currentAngle += ANGLE_STEPS;
+
+    if (!preloader.isOn) {
+        currentAngle = 360;
+    } else {
+        currentAngle += ANGLE_STEPS;
+    }
     graphics_context_set_fill_color(ctx, THEME_COLOR_BACKGROUND_SECONDARY);
     graphics_fill_radial(ctx, bounds, GOvalScaleModeFillCircle, STROKE_SIZE, DEG_TO_TRIGANGLE(0), DEG_TO_TRIGANGLE(currentAngle));

@@ -50,10 +55,9 @@
     if (preloader.timer) {
         app_timer_cancel(preloader.timer);
     }
-
     preloader.timer = NULL;
     text_layer_destroy(preloader.statusText);
-
+    currentAngle = 0;
     //gbitmap_destroy(statusBarIcon);
     preloader.isOn = 1;
 }
@@ -69,10 +73,8 @@
     window_set_background_color(window, THEME_COLOR_BACKGROUND_PRIMARY);
     Layer *window_layer = window_get_root_layer(preloader.window);

-    int squareWidth = SQUARE_LENGTH;
-    int squareHeight = SQUARE_LENGTH;
     GRect bounds = layer_get_bounds(window_layer);
-    square_layer = layer_create(GRect((bounds.size.w - squareWidth) / 2, (bounds.size.h - squareHeight) / 2, squareWidth, squareHeight));
+    square_layer = layer_create(GRectCenterIn(SQUARE_LENGTH, SQUARE_LENGTH, bounds));

     layer_set_update_proc(square_layer, update_square_layer);
     layer_add_child(window_layer, square_layer);


Follow-up to r19845 which suppresses syntax errors in presence of a stack overflow.

ReportUnexpectedToken already calls Traits::ReportMessageAt. If we're in Parser,
that already suppresses the syntax error. If we're in PreParser, we don't need
to suppress the syntax error (preparser errors don't go through Isolate, and
having both stack overflow and a syntax error present is handled correctly by
PreParserApi::PreParse).

R=mstarzinger@chromium.org
BUG=

Review URL: https://codereview.chromium.org/197293003

git-svn-id: b158db1e4b4ab85d4c9e510fdef4b1e8c614b15b@19851 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

--- src/preparser.h
+++ src/preparser.h
@@ -1016,12 +1016,6 @@

 template<class Traits>
 void ParserBase<Traits>::ReportUnexpectedToken(Token::Value token) {
-  // We don't report stack overflows here, to avoid increasing the
-  // stack depth even further.  Instead we report it after parsing is
-  // over, in ParseProgram.
-  if (token == Token::ILLEGAL && stack_overflow()) {
-    return;
-  }
   Scanner::Location source_location = scanner()->location();

   // Four of the tokens are treated specially


refactor: Lift prevector default vals to the member declaration

This is a port of Core #14266

--- src/prevector.h
+++ src/prevector.h
@@ -245,7 +245,7 @@
     };

 private:
-    size_type _size;
+    size_type _size = 0;
     union direct_or_indirect {
         char direct[sizeof(T) * N];
         struct
@@ -253,7 +253,7 @@
             size_type capacity;
             char *indirect;
         };
-    } _union;
+    } _union = {};

     T *direct_ptr(difference_type pos) { return reinterpret_cast<T *>(_union.direct) + pos; }
     const T *direct_ptr(difference_type pos) const { return reinterpret_cast<const T *>(_union.direct) + pos; }
@@ -356,9 +356,9 @@
         fill(item_ptr(0), first, last);
     }

-    prevector() : _size(0), _union{{}} {}
-    explicit prevector(size_type n) : prevector() { resize(n); }
-    explicit prevector(size_type n, const T &val) : prevector()
+    prevector() {}
+    explicit prevector(size_type n) { resize(n); }
+    explicit prevector(size_type n, const T &val)
     {
         change_capacity(n);
         _size += n;
@@ -366,7 +366,7 @@
     }

     template <typename InputIterator>
-    prevector(InputIterator first, InputIterator last) : prevector()
+    prevector(InputIterator first, InputIterator last)
     {
         size_type n = last - first;
         change_capacity(n);
@@ -374,7 +374,7 @@
         fill(item_ptr(0), first, last);
     }

-    prevector(const prevector<N, T, Size, Diff> &other) : prevector()
+    prevector(const prevector<N, T, Size, Diff> &other)
     {
         size_type n = other.size();
         change_capacity(n);
@@ -382,7 +382,7 @@
         fill(item_ptr(0), other.begin(),  other.end());
     }

-    prevector(prevector<N, T, Size, Diff> &&other) : prevector() { swap(other); }
+    prevector(prevector<N, T, Size, Diff> &&other) { swap(other); }
     prevector &operator=(const prevector<N, T, Size, Diff> &other)
     {
         if (&other == this)