src/libpcp/pdu.c: refactor for locking improvement

Rework __pmRequestTimeout() to avoid previous lock nesting via the
call to __pmNotifyErr() on the error path.

--- src/libpcp/src/pdu.c
+++ src/libpcp/src/pdu.c
@@ -14,7 +14,7 @@
  *
  * Thread-safe notes:
  *
- * maxsize - monotonic increasing and rarely changes, so use global
+ * maxsize - monotonic increasing and rarely changes, so use pdu_lock
  * 	mutex to protect updates, but allow reads without locking
  * 	as seeing an unexpected newly updated value is benign
  *
@@ -99,6 +99,7 @@
     PM_LOCK(pdu_lock);
     if (!req_wait_done) {
 	req_wait_done = 1;
+	PM_UNLOCK(pdu_lock);
 	PM_LOCK(__pmLock_extcall);
 	timeout_str = getenv("PMCD_REQUEST_TIMEOUT");		/* THREADSAFE */
 	if (timeout_str != NULL)
@@ -117,6 +118,7 @@
 	}
 	else
 	    PM_UNLOCK(__pmLock_extcall);
+	PM_LOCK(pdu_lock);
     }
     timeout = __pmtimevalToReal(&req_wait);
     PM_UNLOCK(pdu_lock);


flacdec: use gst_adapter_copy() to avoid unnecessary buffer merges

gst_adapter_peek() will merge buffers as needed, which we can avoid
here since we're doing a memcpy anyway and then flush the copied
data from the adapter right away.

--- ext/flac/gstflacdec.c
+++ ext/flac/gstflacdec.c
@@ -809,7 +809,7 @@

   GST_LOG_OBJECT (dec, "feeding %u bytes to decoder (available=%u, bytes=%u)",
       len, gst_adapter_available (dec->adapter), (guint) * bytes);
-  memcpy (buffer, gst_adapter_peek (dec->adapter, len), len);
+  gst_adapter_copy (dec->adapter, buffer, 0, len);
   *bytes = len;

   gst_adapter_flush (dec->adapter, len);


Fix up the connection documentation to be more useful.

Signed-off-by: Chris Lalancette <60b62644009db6b194cc0445b64e9b27bb26433a@redhat.com>

--- ext/libvirt/connect.c
+++ ext/libvirt/connect.c
@@ -70,7 +70,8 @@
  * call-seq:
  *   conn.close -> nil
  *
- * Close the connection
+ * Call +virConnectClose+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectClose]
+ * to close the connection.
  */
 static VALUE libvirt_conn_close(VALUE s) {
     virConnectPtr conn;
@@ -86,7 +87,7 @@
  * call-seq:
  *   conn.closed? -> [True|False]
  *
- * Return +true+ if the connection is closed, +false+ if it is open
+ * Return +true+ if the connection is closed, +false+ if it is open.
  */
 static VALUE libvirt_conn_closed_p(VALUE s) {
     virConnectPtr conn;
@@ -100,6 +101,7 @@
  *   conn.type -> string
  *
  * Call +virConnectGetType+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetType]
+ * to retrieve the type of hypervisor for this connection.
  */
 static VALUE libvirt_conn_type(VALUE s) {
     gen_call_string(virConnectGetType, conn(s), 0, connect_get(s));
@@ -110,6 +112,7 @@
  *   conn.version -> fixnum
  *
  * Call +virConnectGetVersion+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetVersion]
+ * to retrieve the version of the hypervisor for this connection.
  */
 static VALUE libvirt_conn_version(VALUE s) {
     int r;
@@ -128,6 +131,7 @@
  *   conn.libversion -> fixnum
  *
  * Call +virConnectGetLibVersion+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetLibVersion]
+ * to retrieve the version of the libvirt library for this connection.
  */
 static VALUE libvirt_conn_libversion(VALUE s) {
     int r;
@@ -147,6 +151,7 @@
  *   conn.hostname -> string
  *
  * Call +virConnectGetHostname+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetHostname]
+ * to retrieve the hostname of the hypervisor for this connection.
  */
 static VALUE libvirt_conn_hostname(VALUE s) {
     gen_call_string(virConnectGetHostname, conn(s), 1, connect_get(s));
@@ -157,6 +162,7 @@
  *   conn.uri -> string
  *
  * Call +virConnectGetURI+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetURI]
+ * to retrieve the canonical URI for this connection.
  */
 static VALUE libvirt_conn_uri(VALUE s) {
     gen_call_string(virConnectGetURI, conn(s), 1, connect_get(s));
@@ -164,9 +170,11 @@

 /*
  * call-seq:
- *   conn.max_vcpus -> fixnum
+ *   conn.max_vcpus(type=nil) -> fixnum
  *
  * Call +virConnectGetMaxVcpus+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetMaxVcpus]
+ * to retrieve the maximum number of virtual cpus supported by the hypervisor
+ * for this connection.
  */
 static VALUE libvirt_conn_max_vcpus(int argc, VALUE *argv, VALUE s) {
     int result;
@@ -187,6 +195,7 @@
  *   conn.node_get_info -> Libvirt::Connect::Nodeinfo
  *
  * Call +virNodeGetInfo+[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetInfo]
+ * to retrieve information about the node for this connection.
  */
 static VALUE libvirt_conn_node_get_info(VALUE s) {
     int r;
@@ -215,6 +224,8 @@
  *   conn.node_free_memory -> fixnum
  *
  * Call +virNodeGetFreeMemory+[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetFreeMemory]
+ * to retrieve the amount of free memory available on the host for this
+ * connection.
  */
 static VALUE libvirt_conn_node_free_memory(VALUE s) {
     virConnectPtr conn = connect_get(s);
@@ -229,9 +240,11 @@

 /*
  * call-seq:
- *   conn.node_cells_free_memory -> list
+ *   conn.node_cells_free_memory(startCell=0, maxCells=#nodeCells) -> list
  *
  * Call +virNodeGetCellsFreeMemory+[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetCellsFreeMemory]
+ * to retrieve the amount of free memory in each NUMA cell on the host for
+ * this connection.
  */
 static VALUE libvirt_conn_node_cells_free_memory(int argc, VALUE *argv, VALUE s) {
     int r;
@@ -275,7 +288,8 @@
  * call-seq:
  *   conn.node_get_security_model -> Libvirt::Connect::NodeSecurityModel
  *
- * Call +virNodeGetSecurityInfo+[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetSecurityInfo]
+ * Call +virNodeGetSecurityModel+[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetSecurityModel]
+ * to retrieve the security model in use on the host for this connection.
  */
 static VALUE libvirt_conn_node_get_security_model(VALUE s) {
     virSecurityModel secmodel;
@@ -297,9 +311,10 @@
 #if HAVE_VIRCONNECTISENCRYPTED
 /*
  * call-seq:
- *   conn.encrypted?
+ *   conn.encrypted? -> [True|False]
  *
  * Call +virConnectIsEncrypted+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectIsEncrypted]
+ * to determine if the connection is encrypted.
  */
 static VALUE libvirt_conn_encrypted_p(VALUE s) {
     gen_call_truefalse(virConnectIsEncrypted, conn(s), connect_get(s));
@@ -309,9 +324,10 @@
 #if HAVE_VIRCONNECTISSECURE
 /*
  * call-seq:
- *   conn.secure?
- *
- * Call +virConnectIsEncrypted+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectIsEncrypted]
+ *   conn.secure? -> [True|False]
+ *
+ * Call +virConnectIsSecure+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectIsSecure]
+ * to determine if the connection is secure.
  */
 static VALUE libvirt_conn_secure_p(VALUE s) {
     gen_call_truefalse(virConnectIsSecure, conn(s), connect_get(s));
@@ -323,6 +339,7 @@
  *   conn.capabilities -> string
  *
  * Call +virConnectGetCapabilities+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetCapabilities]
+ * to retrieve the capabilities XML for this connection.
  */
 static VALUE libvirt_conn_capabilities(VALUE s) {
     gen_call_string(virConnectGetCapabilities, conn(s), 1, connect_get(s));
@@ -394,4 +411,5 @@
     //rb_define_method(c_connect, "baseline_cpu", libvirt_conn_baseline_cpu, -1);
     //rb_define_method(c_connect, "compare_cpu", libvirt_conn_compare_cpu, -1);
     //rb_define_method(c_connect, "event_register_impl", libvirt_conn_event_register_impl, -1);
-}
+    //rb_define_method(c_connect, "ref", libvirt_conn_ref, 0);
+}


map: be more careful with edge boundary

map: be more careful with edge boundary

--- gtksourceview/gtksourcemap.c
+++ gtksourceview/gtksourcemap.c
@@ -300,7 +300,11 @@
 	                        (gdouble)view_height *
 	                        (gdouble)child_height) +
 	                       iter_area.height;
-	scrubber_area.height = CLAMP (scrubber_area.height, 1, alloc.height);
+
+	if (scrubber_area.height > alloc.height)
+		scrubber_area.height = alloc.height;
+	else if (scrubber_area.height < 0)
+		scrubber_area.height = 1;

 	if (memcmp (&scrubber_area, &priv->scrubber_area, sizeof scrubber_area) != 0)
 	{


Updated

Updated

--- ext/mvc/model/query.c
+++ ext/mvc/model/query.c
@@ -4038,8 +4038,17 @@
 	/**
 	 * Get the model connection
 	 */
-	PHALCON_INIT_VAR(connection);
-	phalcon_call_method(connection, model, "getwriteconnection");
+	if (phalcon_method_exists_ex(model, SS("selectwriteconnection") TSRMLS_CC) == SUCCESS) {
+		PHALCON_INIT_VAR(connection);
+		phalcon_call_method_p3(connection, model, "selectwriteconnection", intermediate, bind_params, bind_types);
+		if (Z_TYPE_P(connection) != IS_OBJECT) {
+			PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "'selectWriteConnection' didn't returned a valid connection");
+			return;
+		}
+	} else {
+		PHALCON_INIT_VAR(connection);
+		phalcon_call_method(connection, model, "getwriteconnection");
+	}

 	PHALCON_OBS_VAR(meta_data);
 	phalcon_read_property_this(&meta_data, this_ptr, SL("_metaData"), PH_NOISY_CC);
@@ -4380,8 +4389,17 @@
 		phalcon_call_method_p1(model, manager, "load", model_name);
 	}

-	PHALCON_INIT_VAR(connection);
-	phalcon_call_method(connection, model, "getwriteconnection");
+	if (phalcon_method_exists_ex(model, SS("selectwriteconnection") TSRMLS_CC) == SUCCESS) {
+		PHALCON_INIT_VAR(connection);
+		phalcon_call_method_p3(connection, model, "selectwriteconnection", intermediate, bind_params, bind_types);
+		if (Z_TYPE_P(connection) != IS_OBJECT) {
+			PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "'selectWriteConnection' didn't returned a valid connection");
+			return;
+		}
+	} else {
+		PHALCON_INIT_VAR(connection);
+		phalcon_call_method(connection, model, "getwriteconnection");
+	}

 	PHALCON_INIT_VAR(dialect);
 	phalcon_call_method(dialect, connection, "getdialect");
@@ -4630,8 +4648,17 @@
 		RETURN_MM();
 	}

-	PHALCON_INIT_VAR(connection);
-	phalcon_call_method(connection, model, "getwriteconnection");
+	if (phalcon_method_exists_ex(model, SS("selectwriteconnection") TSRMLS_CC) == SUCCESS) {
+		PHALCON_INIT_VAR(connection);
+		phalcon_call_method_p3(connection, model, "selectwriteconnection", intermediate, bind_params, bind_types);
+		if (Z_TYPE_P(connection) != IS_OBJECT) {
+			PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "'selectWriteConnection' didn't returned a valid connection");
+			return;
+		}
+	} else {
+		PHALCON_INIT_VAR(connection);
+		phalcon_call_method(connection, model, "getwriteconnection");
+	}

 	/**
 	 * Create a transaction in the write connection


remove/add whitespace for coding convention

--- json-glib/tests/node.c
+++ json-glib/tests/node.c
@@ -54,7 +54,7 @@
   array = json_array_new ();
   node = json_node_init_array (json_node_alloc (), array);

-  json_node_init_int(node, 1);
+  json_node_init_int (node, 1);

   json_node_free (node);
   json_array_unref (array);
@@ -560,7 +560,6 @@
   g_test_trap_assert_failed ();
   g_test_trap_assert_stderr ("*Json-CRITICAL **: json_node_set_parent: *");
 }
-

 int
 main (int   argc,


making travis happy

making travis happy

--- src/server/ua_services_attribute.c
+++ src/server/ua_services_attribute.c
@@ -272,7 +272,7 @@
 		for(UA_Int32 i = 0;i < response->resultsSize;i++) {
 			expireArray[i] = UA_DateTime_now() + 20 * 100 * 1000 * 1000;
 		}
-		UA_UInt32 offset = 0;
+		size_t offset = 0;
 		str.data = UA_malloc(UA_Variant_calcSizeBinary(&variant));
 		str.length = UA_Variant_calcSizeBinary(&variant);
 		UA_Variant_encodeBinary(&variant, &str, &offset);


small fix in discovery service set

small fix in discovery service set

--- src/server/ua_services_discovery.c
+++ src/server/ua_services_discovery.c
@@ -5,6 +5,20 @@
 void Service_GetEndpoints(UA_Server                    *server,
                           const UA_GetEndpointsRequest *request,
                           UA_GetEndpointsResponse      *response) {
+    /* test if the supported binary profile shall be returned */
+    UA_Boolean returnBinary = request->profileUrisSize == 0;
+    for(UA_Int32 i=0;i<request->profileUrisSize;i++) {
+        if(UA_String_equal(&request->profileUris[i], &server->endpointDescriptions->transportProfileUri)) {
+            returnBinary = UA_TRUE;
+            break;
+        }
+    }
+
+    if(!returnBinary) {
+        response->endpointsSize = 0;
+        return;
+    }
+
     response->endpoints = UA_malloc(sizeof(UA_EndpointDescription));
     if(!response->endpoints) {
         response->responseHeader.serviceResult = UA_STATUSCODE_BADOUTOFMEMORY;


Bugzilla bug 256217: implement PR_GetLibraryFilePathname for FreeBSD, which can use the same implementation as Solaris and Linux.  The patch is contributed by Dale Jordan. r=wtc.

--- pr/src/linking/prlink.c
+++ pr/src/linking/prlink.c
@@ -1716,7 +1716,7 @@
 PR_IMPLEMENT(char *)
 PR_GetLibraryFilePathname(const char *name, PRFuncPtr addr)
 {
-#if defined(SOLARIS) || defined(LINUX)
+#if defined(SOLARIS) || defined(LINUX) || defined(FREEBSD)
     Dl_info dli;
     char *result;


proper terrain definition with 2 LOD's for the terrain funcs (one low def for shape, one high def for normals)

--- src/app_planet.h
+++ src/app_planet.h
@@ -5,6 +5,10 @@
 #include "noise_iq.h"
 #define noise(x) noise_iq(x)
 #include "fbm.h"
+
+// ----------------------------------------------------------------------------
+// Planet
+// ----------------------------------------------------------------------------

 _constant(sphere_t) planet = _begin(sphere_t)
 	vec3(0, 0, 0), 1., 0
@@ -60,12 +64,14 @@

 _mutable(cloud_drop_t) cloud;

+#define fbm_cloud fbm
+
 void clouds_map(
 	_inout(cloud_drop_t) cloud,
 	_in(float) t_step
 ){
 	float H = exp(cloud.h);
-	float dens = fbm(cloud.pos * 1.2343
+	float dens = fbm_cloud(cloud.pos * 1.2343
 		+ vec3(1.35, 3.35, 2.67), 2.9760);

 	const float coverage = .575675; // higher=less clouds
@@ -108,26 +114,40 @@
 	}
 }

-float terrain_map(
-	_in(vec3) pos
-){
-	float h = fbm(pos * 2., 2.);
+#define fbm_terr fbm
+DECL_FBM_FUNC(fbm_terr_nrm, 7, .5)
+
+float terrain_map(_in(vec3) pos)
+{
+	float h = fbm_terr(pos * 2., 2.012);
 	float hs = smoothstep(.35, 1., h);

 	return hs;
 }

-vec2 sdf_map(
-	_in(vec3) pos
-){
+vec2 sdf_map(_in(vec3) pos)
+{
 	float n = terrain_map(pos);
 	return vec2(length(pos) - planet.radius - n * max_height, n);
 }

-vec3 terrain_normal(
-	_in(vec3) p
-){
-#define F(t) sdf_map(t).x
+float terrain_map_nrm(_in(vec3) pos)
+{
+	float h = fbm_terr_nrm(pos * 2., 2.012);
+	float hs = smoothstep(.35, 1., h);
+
+	return hs;
+}
+
+vec2 sdf_map_nrm(_in(vec3) pos)
+{
+	float n = terrain_map_nrm(pos);
+	return vec2(length(pos) - planet.radius - n * max_height, n);
+}
+
+vec3 terrain_normal(_in(vec3) p)
+{
+#define F(t) sdf_map_nrm(t).x
 	vec3 dt = vec3(0.001, 0, 0);

 	return normalize(vec3(
@@ -136,23 +156,6 @@
 		F(p + dt.zzx) - F(p - dt.zzx)
 	));
 #undef F
-}
-
-vec3 illuminate(
-	_in(vec3) V,
-	_in(vec3) L,
-	_in(hit_t) hit,
-	_in(vec3) color
-){
-	vec3 diffuse = max(0., dot(L, hit.normal))
-		* color;
-
-	vec3 H = normalize(L + V);
-	vec3 specular = pow(
-		max(0., dot(H, hit.normal)),
-		50.) * vec3(1, 1, 1);
-
-	return diffuse + specular;
 }

 vec3 render_planet(
@@ -209,7 +212,9 @@
 			// limits TODO: vary with fbm
 			const float l_water = .05;
 			const float l_shore = .1;
-			const float l_rock = .11;
+			const float l_rock = .211;
+
+			const vec3 L = vec3(1, 0, 0);

 			vec3 rock = mix(
 				c_rock1, c_rock2,
@@ -218,30 +223,20 @@
 			rock = mix(
 				rock, c_snow,
 				smoothstep(.5, 1., hs));
+
 			vec3 shoreline = mix(
 				c_beach, rock,
-				smoothstep(l_shore, l_rock, hs));
+				smoothstep(l_shore, l_rock, hs));
+			shoreline *= max(0., dot(L, normal));
+
 			vec3 c = mix(
 				c_water, shoreline,
 				smoothstep (l_water, l_shore, hs));
-#if 0
-			hit_t impact = _begin(hit_t)
-				t, // ray length at impact
-				0, // material id
-				normal,
-				p // point of impact
-			_end;
-
-			c = illuminate(
-				eye.direction,
-				vec3(1, 0, 0),
-				impact,
-				c);
-#endif
+
 			return mix(c, cloud.C, cloud.alpha);
 		}

-		t += d.x *.7;
+		t += d.x *.67;
 	}

 	clouds_march(eye, cloud, max_dist);


pr_lab3: fix bug with 0xC

pr_lab3: fix bug with 0xC

--- pr_lab3_prim/solution.c
+++ pr_lab3_prim/solution.c
@@ -29,7 +29,9 @@
         fclose(file);
         return 0;
     }
-    prim(gr);
+    if (!gr->not_connectivity) {
+        prim(gr);
+    }
     fprint_min_tree(file, gr);
     fclose(file);
     return 0;


[neuron] better names

[neuron] better names

--- src/app_sample.h
+++ src/app_sample.h
@@ -30,7 +30,7 @@
 typedef enum {
   SNOOP_CMD_RESET = 0x00,
   SNOOP_CMD_PERF = 0x01,
-} snoop_command;
+} snoop_command_t;

 typedef struct snoop_request {
   short snoop_command;
@@ -40,11 +40,11 @@
 typedef enum {
   SNOOP_REPLY_SUCCESS = 0x00,
   SNOOP_REPLY_ERROR = 0x01,
-} snoop_reply_code;
+} snoop_reply_code_t;

 typedef struct snoop_reply {
   // return code
-  short reply_code;
+  short snoop_reply_code;
   // total number of requests that have been sent
   unsigned long num_of_reuqests;
   // tail latency of the sent requests microseconds


Fix memory buffer overrun issue & also reporting the wrong sized memory buffer needed.

--- src/b64-decode.c
+++ src/b64-decode.c
@@ -198,7 +198,7 @@

 #include "base64.h"

-static void decodeblock( const uint8_t *in, uint8_t *out );
+static void decodeblock( const uint8_t *in, uint8_t *out, int len );
 static size_t decode_core( const uint8_t *table, uint8_t start,
                            const uint8_t *input, const size_t input_size, uint8_t *output );

@@ -207,11 +207,17 @@
 **
 ** decode 4 '6-bit' characters into 3 8-bit binary bytes
 */
-static void decodeblock( const uint8_t *in, uint8_t *out )
+static void decodeblock( const uint8_t *in, uint8_t *out, int len  )
 {
-    out[ 0 ] = (uint8_t ) (in[0] << 2 | in[1] >> 4);
-    out[ 1 ] = (uint8_t ) (in[1] << 4 | in[2] >> 2);
-    out[ 2 ] = (uint8_t ) (((in[2] << 6) & 0xc0) | in[3]);
+    if( 0 < len ) {
+        out[ 0 ] = (uint8_t ) (in[0] << 2 | in[1] >> 4);
+        if( 1 < len ) {
+            out[ 1 ] = (uint8_t ) (in[1] << 4 | in[2] >> 2);
+            if( 2 < len ) {
+                out[ 2 ] = (uint8_t ) (((in[2] << 6) & 0xc0) | in[3]);
+            }
+        }
+    }
 }

 /**
@@ -241,7 +247,7 @@
         return 0;
     }

-    decoded_size = (encoded_size >> 2) * 3;
+    decoded_size = (encoded_size * 3) >> 2;
     return decoded_size;
 }

@@ -305,7 +311,7 @@
             }
         }
         if( len ) {
-            decodeblock( in, out );
+            decodeblock( in, out, len - 1 );
             out += len - 1;
         }
     }


Use adjustment accessor functions in KatzeScrolled

--- katze/katze-scrolled.c
+++ katze/katze-scrolled.c
@@ -17,6 +17,15 @@

 #include "katze-scrolled.h"
 #include "katze-utils.h"
+
+#if !GTK_CHECK_VERSION (2, 14, 0)
+    #define gtk_adjustment_get_page_size(adj) adj->page_size
+    #define gtk_adjustment_get_upper(adj) adj->upper
+    #define gtk_adjustment_get_lower(adj) adj->lower
+    #define gtk_adjustment_get_value(adj) adj->value
+    #define gtk_adjustment_get_page_size(adj) adj->page_size
+    #define gtk_adjustment_get_page_size(adj) adj->page_size
+#endif

 #define DEFAULT_INTERVAL 50
 #define DEFAULT_DECELERATION 0.7
@@ -305,18 +314,24 @@
 {
     KatzeScrolledPrivate* priv = scrolled->priv;
     GtkWidget* widget = GTK_WIDGET (scrolled);
+    gdouble page_size, upper, lower, value;
     gint x, y;
     gint size;
     double position;
     GtkWidget* window;

-    if (adjustment->page_size >= adjustment->upper - adjustment->lower)
+    page_size = gtk_adjustment_get_page_size (adjustment);
+    upper = gtk_adjustment_get_upper (adjustment);
+    lower = gtk_adjustment_get_lower (adjustment);
+    value = gtk_adjustment_get_value (adjustment);
+
+    if (page_size >= upper - lower)
     {
         *previous_size = 0;
         return FALSE;
     }

-    size = ((double)adjustment->page_size) / (adjustment->upper - adjustment->lower) * (horizontal
+    size = ((double)page_size) / (upper - lower) * (horizontal
         ? widget->allocation.height : widget->allocation.width);
     if (size != *previous_size)
     {
@@ -341,7 +356,7 @@
         }
     }

-    position = (adjustment->value - adjustment->lower) / (adjustment->upper - adjustment->lower);
+    position = (value - lower) / (upper - lower);
     window = gtk_widget_get_toplevel (widget);
     if (horizontal)
     {
@@ -418,35 +433,45 @@
     GtkScrolledWindow* gtk_scrolled = GTK_SCROLLED_WINDOW (scrolled);
     GtkAdjustment* hadjustment;
     GtkAdjustment* vadjustment;
-    gdouble hvalue;
-    gdouble vvalue;
+    gdouble hpage_size, hupper, hlower, hvalue, new_hvalue;
+    gdouble vpage_size, vupper, vlower, vvalue, new_vvalue;

     hadjustment = gtk_scrolled_window_get_hadjustment (gtk_scrolled);
-    vadjustment = gtk_scrolled_window_get_vadjustment (gtk_scrolled);
-    hvalue = calculate_timeout_scroll_values (hadjustment->value,
-        hadjustment->upper - hadjustment->page_size,
+    hpage_size = gtk_adjustment_get_page_size (hadjustment);
+    hupper = gtk_adjustment_get_upper (hadjustment);
+    hlower = gtk_adjustment_get_lower (hadjustment);
+    hvalue = gtk_adjustment_get_value (hadjustment);
+    new_hvalue = calculate_timeout_scroll_values (hvalue,
+        hupper - hpage_size,
         &priv->horizontal_speed,
         priv->horizontal_deceleration,
         &priv->vertical_deceleration,
         priv->deceleration);
-    vvalue = calculate_timeout_scroll_values (vadjustment->value,
-        vadjustment->upper - vadjustment->page_size,
+
+    vadjustment = gtk_scrolled_window_get_vadjustment (gtk_scrolled);
+    vpage_size = gtk_adjustment_get_page_size (vadjustment);
+    vupper = gtk_adjustment_get_upper (vadjustment);
+    vlower = gtk_adjustment_get_lower (vadjustment);
+    vvalue = gtk_adjustment_get_value (vadjustment);
+    new_vvalue = calculate_timeout_scroll_values (vvalue,
+        vupper - vpage_size,
         &priv->vertical_speed,
         priv->vertical_deceleration,
         &priv->horizontal_deceleration,
         priv->deceleration);
-    if (vvalue != vadjustment->value)
-    {
-        if (hvalue != hadjustment->value)
+
+    if (new_vvalue != vvalue)
+    {
+        if (new_hvalue != hvalue)
         {
             disable_hadjustment (scrolled);
-            gtk_adjustment_set_value (hadjustment, hvalue);
+            gtk_adjustment_set_value (hadjustment, new_hvalue);
             enable_hadjustment (scrolled);
         }
-        gtk_adjustment_set_value (vadjustment, vvalue);
-    }
-    else if (hvalue != hadjustment->value)
-        gtk_adjustment_set_value (hadjustment, hvalue);
+        gtk_adjustment_set_value (vadjustment, new_vvalue);
+    }
+    else if (new_hvalue != hvalue)
+        gtk_adjustment_set_value (hadjustment, new_hvalue);

     adjust_scrollbar (scrolled, priv->horizontal_scrollbar_window,
                      gtk_scrolled_window_get_hadjustment (gtk_scrolled),
@@ -510,13 +535,14 @@
                   guint32        timestamp)
 {
     KatzeScrolledPrivate* priv = scrolled->priv;
-    GtkAdjustment* hadjustment;
-    GtkAdjustment* vadjustment;
-    gdouble hvalue;
-    gdouble vvalue;

     if (priv->dragged || gtk_drag_check_threshold (widget, priv->start_x, priv->start_y, x, y))
     {
+        GtkAdjustment* hadjustment;
+        GtkAdjustment* vadjustment;
+        gdouble hpage_size, hupper, hvalue, new_hvalue;
+        gdouble vpage_size, vupper, vvalue, new_vvalue;
+
         if (timestamp - priv->previous_time > priv->dragging_stopped_delay || !priv->dragged)
         {
             priv->dragged = TRUE;
@@ -554,23 +580,26 @@
         }

         hadjustment = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (scrolled));
+        hvalue = gtk_adjustment_get_value (hadjustment);
+        new_hvalue = calculate_motion_scroll_values (hvalue,
+            hupper - hpage_size, x, priv->previous_x);
+
         vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled));
-        hvalue = calculate_motion_scroll_values (hadjustment->value,
-            hadjustment->upper - hadjustment->page_size, x, priv->previous_x);
-        vvalue = calculate_motion_scroll_values (vadjustment->value,
-            vadjustment->upper - vadjustment->page_size, y, priv->previous_y);
-        if (vvalue != vadjustment->value)
-        {
-            if (hvalue != hadjustment->value)
+        vvalue = gtk_adjustment_get_value (vadjustment);
+        new_vvalue = calculate_motion_scroll_values (vvalue,
+            vupper - vpage_size, y, priv->previous_y);
+        if (new_vvalue != vvalue)
+        {
+            if (new_hvalue != hvalue)
             {
                 disable_hadjustment (scrolled);
-                gtk_adjustment_set_value (hadjustment, hvalue);
+                gtk_adjustment_set_value (hadjustment, new_hvalue);
                 enable_hadjustment (scrolled);
             }
-            gtk_adjustment_set_value (vadjustment, vvalue);
-        }
-        else if (hvalue != hadjustment->value)
-            gtk_adjustment_set_value (hadjustment, hvalue);
+            gtk_adjustment_set_value (vadjustment, new_vvalue);
+        }
+        else if (new_hvalue != hvalue)
+            gtk_adjustment_set_value (hadjustment, new_hvalue);
     }

     priv->previous_y = y;


[i386/irq] Refactoring arch_irq_handling()

--- kernel/arch/i386/irq.c
+++ kernel/arch/i386/irq.c
@@ -75,6 +75,7 @@

 void init_irq_handling(void)
 {
+   ASSERT(!are_interrupts_enabled());
    pic_remap(32, 40);

    for (u8 i = 0; i < ARRAY_SIZE(irq_handlers_lists); i++) {
@@ -120,28 +121,21 @@
 {
    enum irq_action hret = IRQ_UNHANDLED;
    const int irq = r->int_num - 32;
+   struct irq_handler_node *pos;
+
+   ASSERT(!are_interrupts_enabled());
+   ASSERT(!is_preemption_enabled());

    if (pic_is_spur_irq(irq)) {
       spur_irq_count++;
       return;
    }

+   push_nested_interrupt(r->int_num);
    handle_irq_set_mask(irq);
-   push_nested_interrupt(r->int_num);
-   ASSERT(!are_interrupts_enabled());
-
-   /*
-    * We MUST send EOI to the PIC here, before starting the interrupt handler
-    * otherwise, the PIC will just not allow nested interrupts to happen.
-    * NOTE: we MUST send the EOI **before** re-enabling the interrupts,
-    * otherwise we'll start getting a lot of spurious interrupts!
-    */
    pic_send_eoi(irq);
    enable_interrupts_forced();
-
    {
-      struct irq_handler_node *pos;
-
       list_for_each_ro(pos, &irq_handlers_lists[irq], node) {

          hret = pos->handler(pos->context);
@@ -149,16 +143,13 @@
          if (hret != IRQ_UNHANDLED)
             break;
       }
+
+      if (hret == IRQ_UNHANDLED)
+         unhandled_irq_count[irq]++;
    }
-
-   if (hret == IRQ_UNHANDLED)
-      unhandled_irq_count[irq]++;
-
+   disable_interrupts_forced();
+   handle_irq_clear_mask(irq);
    pop_nested_interrupt();
-   handle_irq_clear_mask(irq);
-
-   /* Disable again the interrupts, keeping preemption disabled as well */
-   disable_interrupts_forced();
 }

 int get_irq_num(regs_t *context)


[process_mm] Cosmetic changes

[process_mm] Cosmetic changes

--- kernel/mm/process_mm.c
+++ kernel/mm/process_mm.c
@@ -29,7 +29,8 @@
 bool user_valloc_and_map_slow(uptr user_vaddr, size_t page_count)
 {
    pdir_t *pdir = get_curr_pdir();
-   uptr va = user_vaddr;
+   uptr pa, va = user_vaddr;
+   void *kernel_vaddr;

    for (size_t i = 0; i < page_count; i++, va += PAGE_SIZE) {

@@ -38,17 +39,14 @@
          return false;
       }

-      void *kernel_vaddr = kmalloc(PAGE_SIZE);
-
-      if (!kernel_vaddr) {
+      if (!(kernel_vaddr = kmalloc(PAGE_SIZE))) {
          user_vfree_and_unmap(user_vaddr, i);
          return false;
       }

-      uptr pa = KERNEL_VA_TO_PA(kernel_vaddr);
-      int rc = map_page(pdir, (void *)va, pa, true, true);
-
-      if (rc != 0) {
+      pa = KERNEL_VA_TO_PA(kernel_vaddr);
+
+      if (map_page(pdir, (void *)va, pa, true, true) != 0) {
          kfree2(kernel_vaddr, PAGE_SIZE);
          user_vfree_and_unmap(user_vaddr, i);
          return false;


The new border finding code is almost complete, but it works well.
Still #if'ed out for now.  Try it if you want.  Note, #if'ing it in will
run it AS WELL as the old code and print the times taken, so that
comparisons can be made.  The new code is the first time reported.

git-svn-id: 0f3f1c46c6da7ffd142db61e503a7ff63af3a195@26323 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/bin/e_apps.c
+++ src/bin/e_apps.c
@@ -86,6 +86,12 @@
    const char *path;
 };

+struct _E_App_Glob_List_Winner
+{
+   const char *path;
+   int         ok;
+};
+
 static Evas_Hash *_e_apps_border_ng_win_class = NULL,
                  *_e_apps_border_ng_win_title = NULL,
 		 *_e_apps_border_ng_win_name = NULL,
@@ -98,7 +104,7 @@
 static double border_setup_time = 0.0;
 static int    border_setup_count = 0, glob_count = 0;
 #endif
-static double border_time = 0.0;
+static double border_time = 0.0, border_clever_time = 0.0;
 static int    border_count = 0;

 #define EAP_MIN_WIDTH 8
@@ -313,6 +319,7 @@

    list = data;
    evas_list_free(list);
+   return 0;
 }
 #endif

@@ -1214,23 +1221,87 @@
 	int found = 0;

         /* Put it into the list in the non_glob hash. */
-	if (*non_glob)
-	   entry = evas_hash_find(*non_glob, text);
+        entry = evas_hash_find(*non_glob, text);
 	if (entry)
 	   found = 1;
 	entry = evas_list_append(entry, path);
 	if (entry)
 	  {
              if (found)
-	       {
-	           evas_hash_modify(*non_glob, text, entry);
-	       }
+	        evas_hash_modify(*non_glob, text, entry);
 	     else
-	       {
-	           (*non_glob) = evas_hash_direct_add(*non_glob, text, entry);
-	       }
-	  }
-     }
+	        (*non_glob) = evas_hash_direct_add(*non_glob, text, entry);
+	  }
+     }
+}
+
+
+static void
+_e_apps_winners_add(Evas_Hash **winners, const char *path, int addition)
+{
+   int *count = NULL;
+   int found = 0;
+
+   count = evas_hash_find((*winners), path);
+   if (count)
+      found = 1;
+   else
+      count = calloc(1, sizeof(int));  // FIXME: not very efficient, allocate a bunch of them in one go and point into the next available one.
+
+   if (count)
+     {
+        (*count) = (*count) + addition;
+        if (found)
+	   evas_hash_modify((*winners), path, count);
+	else
+	   (*winners) = evas_hash_direct_add((*winners), path, count);
+     }
+}
+
+static void
+_e_apps_winners_search(Evas_Hash *non_glob, Evas_List *glob, const char *text, Evas_Hash **winners, int addition)
+{
+   Evas_List *l, *entry = NULL;
+
+   entry = evas_hash_find(non_glob, text);
+   if (entry)
+     {
+        for (l = entry; l; l = l->next)
+          {
+	     const char *path;
+
+	     path = l->data;
+             _e_apps_winners_add(winners, path, addition);
+	  }
+     }
+   if (glob)
+     {
+        for (l = glob; l; l = l->next)
+          {
+             struct _E_App_Glob_List_Entry *glob;
+
+	     glob = l->data;
+	     if (e_util_glob_match(text, glob->path))
+                _e_apps_winners_add(winners, glob->path, addition);
+          }
+     }
+}
+
+static Evas_Bool
+_e_apps_winners_hash_cb_check_free(Evas_Hash *hash, const char *key, void *data, void *fdata)
+{
+   struct _E_App_Glob_List_Winner *winner;
+   int *count;
+
+   count = data;
+   winner = fdata;
+printf("%d %d %s\n", winner->ok, (*count), key);
+   if ((*count) > winner->ok)
+     {
+        winner->path = key;
+	winner->ok = (*count);
+     }
+   free(count);
 }
 #endif

@@ -1240,15 +1311,18 @@
 {
    Evas_List *l, *l_match = NULL;
    int ok, match = 0;
-   E_App *a, *a_match = NULL;
+   E_App *a = NULL, *a_match = NULL, *clever_match = NULL;
    char *title;
-   double begin, time;
-
+   double begin, time, clever_time = 0.0;
+
+   /* FIXME: Should that be (bd->client.netwm.name) or (!bd->client.netwm.name) like everything else ? */
    if ((!bd->client.icccm.name) && (!bd->client.icccm.class) &&
        (!bd->client.icccm.title) && (bd->client.netwm.name) &&
        (!bd->client.icccm.window_role) && (!bd->client.icccm.command.argv))
      return NULL;

+   title = bd->client.netwm.name;
+   if (!title) title = bd->client.icccm.title;
    begin = ecore_time_get();
 /* FIXME:
   Speed this up.
@@ -1291,6 +1365,8 @@
       first without calling e_app_fields_fill and skipping the unfilled ones
       if there is no winner
         only do the ones that need filling on the second pass
+	Actually, this seems fast enough that I think we can get away with just
+	running it on all after the fill.

     on each pass
       look up client strings in non-glob hashes
@@ -1300,16 +1376,63 @@
       go through temp hash, the hash entry with the highest count wins
 */
 #if CLEVER_BORDERS
+{
+   Evas_Hash *winners = NULL;
+   struct _E_App_Glob_List_Winner winner;
+
+   for (ok = 0; ok < 2; ok++)
+     {
+        winner.path = NULL;
+        winner.ok = 0;
+        if (ok)  /* Fill all E_Apps and try again. */
+	  {
+             for (l = _e_apps_all->subapps; l; l = l->next)
+               {
+	          a = l->data;
+                  E_OBJECT_CHECK_RETURN(a, NULL);
+                  E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
+                  if ((!a->idle_fill) && (!a->filled))
+		     e_app_fields_fill(a, a->path);
+	       }
+	  }
+        /* FIXME: +2 if class AND name match; +2 if class matches and there is no name. */
+        if ((bd->client.icccm.class))
+          {
+           _e_apps_winners_search(_e_apps_border_ng_win_class, _e_apps_border_g_win_class, bd->client.icccm.class, &winners, 2);
+          }
+
+        if ((bd->client.icccm.name))
+          {
+            _e_apps_winners_search(_e_apps_border_ng_win_name, _e_apps_border_g_win_name, bd->client.icccm.name, &winners, 2);
+          }
+
+        if ((title))
+           _e_apps_winners_search(_e_apps_border_ng_win_title, _e_apps_border_g_win_title, title, &winners, 1);
+        if ((bd->client.icccm.window_role))
+           _e_apps_winners_search(_e_apps_border_ng_win_role, _e_apps_border_g_win_role, bd->client.icccm.window_role, &winners, 1);
+        if ((bd->client.icccm.command.argv) && (bd->client.icccm.command.argv[0]))
+           _e_apps_winners_search(_e_apps_border_ng_exe, NULL, bd->client.icccm.command.argv[0], &winners, 1);
+
+        evas_hash_foreach(winners, _e_apps_winners_hash_cb_check_free, &winner);
+        if (winner.path)
+	  {
+              clever_match = e_app_path_find(winner.path);
+	      if (clever_match)
+	         break;
+	  }
+        evas_hash_free(winners);
+        winners = NULL;
+     }
+}
+   clever_time = ecore_time_get() - begin;
 #endif
-   title = bd->client.netwm.name;
-   if (!title) title = bd->client.icccm.title;
    for (l = _e_apps_all->subapps; l; l = l->next)
      {
 	a = l->data;
         E_OBJECT_CHECK_RETURN(a, NULL);
         E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
-        if (!a->filled) e_app_fields_fill(a, a->path);
-	if (!a->filled) continue;
+        if ((!a->idle_fill) && (!a->filled))   e_app_fields_fill(a, a->path);
+	if (!a->filled)   continue;
 	ok = 0;
 	if ((a->win_name) || (a->win_class) || (a->win_title) || (a->win_role) || (a->exe))
 	  {
@@ -1370,9 +1493,11 @@
 	_e_apps_all->subapps = evas_list_prepend(_e_apps_all->subapps, a_match);
      }
    time = ecore_time_get() - begin;
+   time -= clever_time;
    border_count++;
    border_time += time;
-   printf("APP BORDER SCAN %2.6f (average %2.6f) FOUND %s\n", time, border_time / border_count, ((a_match == NULL) ? "NOTHING" : a_match->path));
+   border_clever_time += clever_time;
+   printf("APP BORDER SCAN %2.6f, %2.6f (average %2.6f, %2.6f) FOUND %s AND %s\n", clever_time, time, border_clever_time / border_count, border_time / border_count, ((clever_match == NULL) ? "NOTHING" : clever_match->path), ((a_match == NULL) ? "NOTHING" : a_match->path));
    return a_match;
 }


Fix warning.

Fix warning.

--- src/bin/e_intl.c
+++ src/bin/e_intl.c
@@ -280,7 +280,7 @@
 	     dir_languages = evas_list_remove_list(dir_languages, dir_languages);

 	     if ((_e_intl_language_list_find(all_languages, language)) ||
-		 (strlen(language) > 2) && (!_e_intl_locale_validate(language)))
+		 ((strlen(language) > 2) && (!_e_intl_locale_validate(language))))
 	       {
 		  free(language);
 	       }


disable the test code!

git-svn-id: 0f3f1c46c6da7ffd142db61e503a7ff63af3a195@18321 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/bin/e_test.c
+++ src/bin/e_test.c
@@ -392,7 +392,7 @@
    tcon = con;
    _e_test_timer(NULL);
 }
-#elif 1
+#elif 0

 struct _tmp
 {


change severity of debug messages

change severity of debug messages

--- src/bin/events.c
+++ src/bin/events.c
@@ -125,7 +125,7 @@
         /* un-added contact with subscribe request */
         if (ev->type != SHOTGUN_PRESENCE_TYPE_SUBSCRIBE)
           {
-             ERR("Received message from non-contact '%s', probably a bug", jid);
+             DBG("Received message from non-contact '%s', probably a bug", jid);
              return ECORE_CALLBACK_RENEW;
           }
         c = do_something_with_user(cl, NULL, jid);
@@ -265,7 +265,7 @@
    c = eina_hash_find(cl->users, jid);
    if (!c)
      {
-        ERR("Received message from non-contact '%s', probably a bug", jid);
+        DBG("Received message from non-contact '%s', probably a bug", jid);
         return ECORE_CALLBACK_RENEW;
      }


termio: do nothing special when extracting text and .tab is set

--- src/bin/termio.c
+++ src/bin/termio.c
@@ -2130,12 +2130,6 @@
                        if (ty_sb_add(&sb, "\n", 1) < 0) goto err;
                     }
                   break;
-               }
-             else if (cells[x].att.tab)
-               {
-                  if (ty_sb_add(&sb, "\t", 1) < 0) goto err;
-                  x = ((x + 8) / 8) * 8;
-                  x--; /* counter the ++ of the for loop */
                }
              else if (cells[x].codepoint == 0)
                {


1 more bug nuked. we must convert \n to \r from copy & paste in terms. yay!

SVN revision: 73407

--- src/bin/termio.c
+++ src/bin/termio.c
@@ -896,7 +896,24 @@
    if (ev->format == ELM_SEL_FORMAT_TEXT)
      {
         if (ev->len > 0)
-          termpty_write(sd->pty, ev->data, ev->len - 1);
+          {
+             char *tmp, *s;
+             int i;
+
+             // apparently we have to convert \n into \r in terminal land.
+             tmp = malloc(ev->len);
+             if (tmp)
+               {
+                  s = ev->data;
+                  for (i = 0; i < ev->len; i++)
+                    {
+                       tmp[i] = s[i];
+                       if (tmp[i] == '\n') tmp[i] = '\r';
+                    }
+                  termpty_write(sd->pty, tmp, ev->len - 1);
+                  free(tmp);
+               }
+          }
      }
    return EINA_TRUE;
 }


remove debug

remove debug

--- src/bin/termio.c
+++ src/bin/termio.c
@@ -3987,7 +3987,6 @@
      {
         // adjust scroll position for added scrollback
         sd->scroll++;
-        ERR("scroll: %d", sd->scroll);
         if (sd->scroll > sd->pty->backscroll_num)
           sd->scroll = sd->pty->backscroll_num;
      }


route: drop unnecessary oo_clone() implementation from netconf

If the object has no complex data (pointers!), then the base
implementation using memcpy() is enough. No need to implement
oo_clone().

--- lib/route/netconf.c
+++ lib/route/netconf.c
@@ -72,16 +72,6 @@
 static struct rtnl_netconf *rtnl_netconf_alloc(void)
 {
 	return (struct rtnl_netconf *) nl_object_alloc(&netconf_obj_ops);
-}
-
-static int netconf_clone(struct nl_object *_dst, struct nl_object *_src)
-{
-	struct rtnl_netconf *dst = nl_object_priv(_dst);
-	struct rtnl_netconf *src = nl_object_priv(_src);
-
-	*dst = *src;
-
-	return 0;
 }

 static int netconf_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
@@ -528,7 +518,6 @@
 static struct nl_object_ops netconf_obj_ops = {
 	.oo_name		= "route/netconf",
 	.oo_size		= sizeof(struct rtnl_netconf),
-	.oo_clone		= netconf_clone,
 	.oo_dump = {
 	    [NL_DUMP_LINE] 	= netconf_dump_line,
 	    [NL_DUMP_DETAILS] 	= netconf_dump_line,


tcti_ldr: load a specific so version

tcti_ldr: load a specific so version

Use the so version suffix.

Signed-off-by: William Roberts <60148e894dabf0b83bde1d460768794cd453c455@intel.com>

--- lib/tpm2_tcti_ldr.c
+++ lib/tpm2_tcti_ldr.c
@@ -55,7 +55,7 @@
 bool tpm2_tcti_ldr_is_tcti_present(const char *name) {

     char path[PATH_MAX];
-    snprintf(path, sizeof(path), "libtss2-tcti-%s.so", name);
+    snprintf(path, sizeof(path), "libtss2-tcti-%s.so.0", name);

     void *handle = dlopen (path, RTLD_LAZY);
     if (handle) {


windows fix

windows fix

--- lib/virgo_lua_vfs.c
+++ lib/virgo_lua_vfs.c
@@ -125,11 +125,15 @@

 static int
 vfs_exists(lua_State *L) {
-  unzFile *zip = luaL_checkudata(L, 1, ZIPFILEHANDLE);
-  const char *name = luaL_checkstring(L, 2);
+  int rv;
+  unzFile *zip;
+  const char *name;
+
+  zip = luaL_checkudata(L, 1, ZIPFILEHANDLE);
+  name = luaL_checkstring(L, 2);
   if (name[0] == '/')
     name++;
-  int rv = unzLocateFile(*zip, name, 1);
+  rv = unzLocateFile(*zip, name, 1);
   if (rv == UNZ_OK) {
     lua_pushboolean(L, 1);
   } else {


Voodoo: Fixed fork bombing until child process accepted connection.

Also fixed zombies remaining.

--- lib/voodoo/server.c
+++ lib/voodoo/server.c
@@ -37,6 +37,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <sys/wait.h>

 #include <netinet/in.h>
 #include <netinet/tcp.h>
@@ -83,7 +84,7 @@

 /**************************************************************************************************/

-static DirectResult accept_connection( VoodooServer *server );
+static DirectResult accept_connection( VoodooServer *server, int fd );

 /**************************************************************************************************/

@@ -257,16 +258,31 @@
           }

           if (listener) {
+               int              fd;
+               struct sockaddr  addr;
+               socklen_t        addrlen = sizeof(addr);
+
                pf.fd     = server->fd;
                pf.events = POLLIN;

                switch (poll( &pf, 1, 200 )) {
                     default:
+                         fd = accept( server->fd, &addr, &addrlen );
+                         if (fd < 0) {
+                              D_PERROR( "Voodoo/Server: Could not accept() incoming connection!\n" );
+                              break;
+                         }
+
+#if 0
+                         accept_connection( server, fd );
+#else
                          switch (fork()) {
                               case 0:
                                    listener = false;

-                                   accept_connection( server );
+                                   close( server->fd );
+
+                                   accept_connection( server, fd );
                                    break;

                               case -1:
@@ -274,11 +290,15 @@
                                    break;

                               default:
+                                   close( fd );
                                    break;
                          }
+#endif
                          break;

                     case 0:
+                         waitpid( -1, NULL, WNOHANG );
+
                          D_DEBUG( "Voodoo/Server: Timeout during poll()\n" );
                          break;

@@ -325,11 +345,9 @@
 /**************************************************************************************************/

 static DirectResult
-accept_connection( VoodooServer *server )
+accept_connection( VoodooServer *server, int fd )
 {
      DirectResult     ret;
-     struct sockaddr  addr;
-     socklen_t        addrlen = sizeof(addr);
      Connection      *connection;

      connection = D_CALLOC( 1, sizeof(Connection) );
@@ -338,13 +356,7 @@
           return DR_NOLOCALMEMORY;
      }

-     connection->fd = accept( server->fd, &addr, &addrlen );
-     if (connection->fd < 0) {
-          ret = errno2result( errno );
-          D_PERROR( "Voodoo/Server: Could not accept() incoming connection!\n" );
-          D_FREE( connection );
-          return ret;
-     }
+     connection->fd = fd;

      D_INFO( "Voodoo/Server: Accepted connection.\n" );


If no bedfile is provided, default to full genome analysis for the vetting.

--- src/bmf_vetter.c
+++ src/bmf_vetter.c
@@ -214,6 +214,8 @@
 			bam_plp_destroy(pileup);
 		}
 	}
+	if(bcf_idx) hts_idx_destroy(bcf_idx);
+	if(vcf_idx) tbx_destroy(vcf_idx);
 	free(pass_values);
 	hts_idx_destroy(idx);
 	bcf_destroy(vrec);
@@ -272,8 +274,6 @@
 		LOG_INFO("Emitting to stdout as vcf.\n");
 		strcpy(vcf_wmode, "w");
 	}
-	if(!bed || !*bed)
-		vetter_error("Bed file required.\n", EXIT_FAILURE);
 	if(file_has_ext(outvcf, "bcf"))
 		strcpy(vcf_wmode, "wb");

@@ -284,12 +284,16 @@

 	// Open input vcf
 	if(!aux.header || aux.header->n_targets == 0) {LOG_ERROR("Could not read header from bam %s. Abort!\n", argv[optind + 1]);}
+	// if no bed provided, do whole genome.
+	if(!bed || !*bed) {
+		LOG_WARNING("No bed file provided. Defaulting to whole genome analysis.\n");
+		aux.bed = build_ref_hash(aux.header);
+	} else aux.bed = parse_bed_hash(bed, aux.header, padding);
 	aux.vcf_fp = vcf_open(argv[optind], "r");
 	if(!aux.vcf_fp) {LOG_ERROR("Could not open input [bv]cf %s. Abort!\n", argv[optind]);}
 	aux.vcf_header = vcf_hdr_read(aux.vcf_fp);
 	if(!aux.vcf_header) {LOG_ERROR("Could not read header from input [bv]cf %s. Abort!\n", argv[optind]);}
 	// Open bed file
-	aux.bed = parse_bed_hash(bed, aux.header, padding);

 	// Add lines to header
 	size_t n_header_lines = COUNT_OF(bmf_header_lines);


Added Cisco's vendor id , sent by 1131ag.

FossilOrigin-Name: 6c784c92408f8f26e9f4a216aa8e57a75b8c3b3eaddea9743c60c67f50138aaf

--- src/capwap/cw_ianavendoridtostr.c
+++ src/capwap/cw_ianavendoridtostr.c
@@ -8,6 +8,8 @@
 			return "ZyXEL Communications Corp.";
 		case 11591:
 			return "Free Software Foundation";
+		case 4232704:
+			return "Cisco";
 		default:
 			return "Unknown";
 	}


Try a different workaround for GCC 4.7.2 lambda capture bug. The previous
workaround took us from wrong-code to ICE.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@221754 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -4579,12 +4579,12 @@
 TreeTransform<Derived>::TransformFunctionProtoType(TypeLocBuilder &TLB,
                                                    FunctionProtoTypeLoc TL) {
   SmallVector<QualType, 4> ExceptionStorage;
+  TreeTransform *This = this; // Work around gcc.gnu.org/PR56135.
   return getDerived().TransformFunctionProtoType(
       TLB, TL, nullptr, 0,
-      // The explicit 'this' capture is a workaround for gcc.gnu.org/PR56135.
-      [&, this](FunctionProtoType::ExceptionSpecInfo & ESI, bool &Changed) {
-        return TransformExceptionSpec(TL.getBeginLoc(), ESI, ExceptionStorage,
-                                      Changed);
+      [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
+        return This->TransformExceptionSpec(TL.getBeginLoc(), ESI,
+                                            ExceptionStorage, Changed);
       });
 }

@@ -9152,11 +9152,12 @@

     TypeLocBuilder NewCallOpTLBuilder;
     SmallVector<QualType, 4> ExceptionStorage;
+    TreeTransform *This = this; // Work around gcc.gnu.org/PR56135.
     QualType NewCallOpType = TransformFunctionProtoType(
         NewCallOpTLBuilder, OldCallOpFPTL, nullptr, 0,
-        [&, this](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
-          return TransformExceptionSpec(OldCallOpFPTL.getBeginLoc(), ESI,
-                                        ExceptionStorage, Changed);
+        [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
+          return This->TransformExceptionSpec(OldCallOpFPTL.getBeginLoc(), ESI,
+                                              ExceptionStorage, Changed);
         });
     NewCallOpTSI = NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context,
                                                         NewCallOpType);


driver: check if a sending peer is monitor early

Do not even look at the message, if a monitor sends something
it is dropped and the monitor disconnected. A monitor should not
have any chance to affect the bus.

Signed-off-by: Tom Gundersen <7c8224529a7c718e876cb2496c973509fde1e50e@jklm.no>

--- src/bus/driver.c
+++ src/bus/driver.c
@@ -258,7 +258,6 @@
                 [DRIVER_E_INVALID_MESSAGE]                      = "Invalid message body",
                 [DRIVER_E_PEER_NOT_REGISTERED]                  = "Hello() was not the first method called",
                 [DRIVER_E_PEER_ALREADY_REGISTERED]              = "Hello() already called",
-                [DRIVER_E_PEER_IS_MONITOR]                      = "Monitors cannot send messages",
                 [DRIVER_E_PEER_NOT_PRIVILEGED]                  = "The caller does not have the necessary privileged to call this method",
                 [DRIVER_E_UNEXPECTED_MESSAGE_TYPE]              = "Unexpected message type",
                 [DRIVER_E_UNEXPECTED_PATH]                      = "Invalid object path",
@@ -1733,9 +1732,6 @@
         if (r)
                 return error_trace(r);

-        if (peer_is_monitor(peer))
-                return DRIVER_E_PEER_IS_MONITOR;
-
         if (_c_unlikely_(c_string_equal(message->metadata.fields.destination, "org.freedesktop.DBus"))) {
                 return error_trace(driver_dispatch_interface(peer,
                                                              message->metadata.header.serial,
@@ -1787,6 +1783,9 @@
 int driver_dispatch(Peer *peer, Message *message) {
         int r;

+        if (peer_is_monitor(peer))
+                return DRIVER_E_PROTOCOL_VIOLATION;
+
         r = message_parse_metadata(message);
         if (r > 0)
                 return DRIVER_E_PROTOCOL_VIOLATION;
@@ -1802,7 +1801,6 @@
                 if (r)
                         return error_trace(r);
                 /* fall through */
-        case DRIVER_E_PEER_IS_MONITOR:
         case DRIVER_E_INVALID_MESSAGE:
                 return DRIVER_E_PROTOCOL_VIOLATION;
         case DRIVER_E_PEER_ALREADY_REGISTERED:


Add class for decompress a block of bytes given a descriptor file in lz4_compressor.h

--- src/lz4_compressor.h
+++ src/lz4_compressor.h
@@ -166,6 +166,9 @@
 };

+/*
+ * Compress Data.
+ */
 class LZ4CompressData : public LZ4BlockStreaming<LZ4CompressData> {
 	LZ4_stream_t* const lz4Stream;

@@ -185,6 +188,9 @@
 };

+/*
+ * Compress a file.
+ */
 class LZ4CompressFile : public LZ4BlockStreaming<LZ4CompressFile> {
 	LZ4_stream_t* const lz4Stream;

@@ -202,6 +208,9 @@
 };

+/*
+ * Decompress Data.
+ */
 class LZ4DecompressData : public LZ4BlockStreaming<LZ4DecompressData> {
 	LZ4_streamDecode_t* const lz4StreamDecode;

@@ -221,6 +230,9 @@
 };

+/*
+ * Decompress a file.
+ */
 class LZ4DecompressFile : public LZ4BlockStreaming<LZ4DecompressFile> {
 	LZ4_streamDecode_t* const lz4StreamDecode;

@@ -240,3 +252,34 @@

 	~LZ4DecompressFile();
 };
+
+
+/*
+ * Decompress read_bytes of the descriptor file (fd) from the current position.
+ * Each time that call begin(), decompress read_bytes from the current position.
+ * For update read_bytes call set_read_bytes.
+ */
+class LZ4DecompressDescriptor : public LZ4BlockStreaming<LZ4DecompressDescriptor> {
+	LZ4_streamDecode_t* const lz4StreamDecode;
+
+	int& fd;
+	ssize_t read_bytes;
+
+	char* const data;
+	ssize_t data_size;
+	size_t data_offset;
+
+	std::string init();
+	std::string next();
+
+	friend class LZ4BlockStreaming<LZ4DecompressDescriptor>;
+
+public:
+	LZ4DecompressDescriptor(int& fildes);
+
+	~LZ4DecompressDescriptor();
+
+	inline void set_read_bytes(size_t read_bytes_) noexcept {
+		read_bytes = read_bytes_;
+	}
+};


ap_power: Refresh virtual wire signals when channel ready

When the ESPI VW channel is ready, refresh the VW signal values.

Depending on when the channel status was received, new values
for the VW signals may or may not have been received. If the
signals were received and then the channel status indicated not ready,
the signals were marked invalid (and the power sequence state
machine may be stalled waiting for the signals to become valid).
However once the channel status became ready, new signal values
may not be received (since the actual value may not have changed),
so the signals may remain (incorrectly) marked as invalid.

So when the VW channel status indicates ready, refresh the
VW signal values (allowing them to be marked valid), and update
the power sequence code via power_signal_interrupt(), which will
unblock the state machine, allowing the now valid VW signals to be
handled.

LOW_COVERAGE_REASON=ESPI emulator does not have API for channel setting
BUG=b:235429065
TEST=firmware_ECPowerButton passes
BRANCH=none

Signed-off-by: Andrew McRae <44ad1424cfc8411c96d9181798ca41ae55709dfb@google.com>
Change-Id: I547919e2d8c758878de9b6869ac223e4226a4f71
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3874582
Code-Coverage: Zoss <345cf107e82c70959d46f59d98bddc98ce458aff@prod.google.com>
Reviewed-by: Peter Marheine <ef0b2c492edde94778d7465bfbaeed52c5be6858@chromium.org>

--- zephyr/subsys/ap_pwrseq/signal_vw.c
+++ zephyr/subsys/ap_pwrseq/signal_vw.c
@@ -57,6 +57,36 @@

 BUILD_ASSERT(ARRAY_SIZE(vw_config) <= (sizeof(atomic_t) * 8));

+/*
+ * Set the value of the VW signal, and optionally
+ * call the power signal interrupt handling.
+ */
+static void vw_set(int index, int data, bool notify)
+{
+	bool value = vw_config[index].invert ? !data : !!data;
+
+	atomic_set_bit_to(&signal_data, index, value);
+	atomic_set_bit(&signal_valid, index);
+	if (notify) {
+		power_signal_interrupt(vw_config[index].signal, value);
+	}
+}
+
+/*
+ * Update all the VW signals.
+ */
+static void vw_update_all(bool notify)
+{
+	for (int i = 0; i < ARRAY_SIZE(vw_config); i++) {
+		uint8_t vw_value;
+
+		if (espi_receive_vwire(espi_dev, vw_config[i].espi_signal,
+				       &vw_value) == 0) {
+			vw_set(i, vw_value, notify);
+		}
+	}
+}
+
 void power_signal_espi_cb(const struct device *dev, struct espi_callback *cb,
 			  struct espi_event event)
 {
@@ -68,24 +98,22 @@
 		break;

 	case ESPI_BUS_EVENT_CHANNEL_READY:
-		/* Virtual wire channel is not ready, clear valid flag */
-		if (event.evt_details == ESPI_CHANNEL_VWIRE &&
-		    !event.evt_data) {
-			atomic_clear(&signal_valid);
+		/* Virtual wire channel status change */
+		if (event.evt_details == ESPI_CHANNEL_VWIRE) {
+			if (event.evt_data) {
+				/* If now ready, update all the signals */
+				vw_update_all(true);
+			} else {
+				/* If not ready, invalidate the signals */
+				atomic_clear(&signal_valid);
+			}
 		}
 		break;

 	case ESPI_BUS_EVENT_VWIRE_RECEIVED:
 		for (int i = 0; i < ARRAY_SIZE(vw_config); i++) {
 			if (event.evt_details == vw_config[i].espi_signal) {
-				bool value = vw_config[i].invert ?
-						     !event.evt_data :
-						     !!event.evt_data;
-
-				atomic_set_bit_to(&signal_data, i, value);
-				atomic_set_bit(&signal_valid, i);
-				power_signal_interrupt(vw_config[i].signal,
-						       value);
+				vw_set(i, event.evt_data, true);
 			}
 		}
 		break;
@@ -108,19 +136,7 @@
 	 * initialise the current values of the signals.
 	 */
 	if (espi_get_channel_status(espi_dev, ESPI_CHANNEL_VWIRE)) {
-		for (int i = 0; i < ARRAY_SIZE(vw_config); i++) {
-			uint8_t vw_value;
-
-			if (espi_receive_vwire(espi_dev,
-					       vw_config[i].espi_signal,
-					       &vw_value) == 0) {
-				atomic_set_bit_to(&signal_data, i,
-						  vw_config[i].invert ?
-							  !vw_value :
-							  !!vw_value);
-				atomic_set_bit(&signal_valid, i);
-			}
-		}
+		vw_update_all(false);
 	}
 }


Card: virtual destructor

Card: virtual destructor

Add virtual destructor so Card can be inherited.

Signed-off-by: Tomi Valkeinen <e1ca4dbb8be1acaf20734fecd2da10ed1d46a9bb@ti.com>

--- kms++/inc/kms++/card.h
+++ kms++/inc/kms++/card.h
@@ -15,7 +15,7 @@
 public:
 	Card();
 	Card(const std::string& device);
-	~Card();
+	virtual ~Card();

 	Card(const Card& other) = delete;
 	Card& operator=(const Card& other) = delete;


Improve our detection of floating-point that are integers

Turns out that we were relying on undefined behaviour when doing

    (uint64_t)fabs(val) == fabs(val)

This problem was noted when running our test data on an AArch64 build.

Signed-off-by: Thiago Macieira <0ed1648d92ca0373297a182b1dba1b974ad10d88@intel.com>

--- src/cborpretty.c
+++ src/cborpretty.c
@@ -149,6 +149,36 @@
  * \value CborPrettyDefaultFlags                Default conversion flags.
  */

+static inline bool convertToUint64(double v, uint64_t *absolute)
+{
+    v = fabs(v);
+
+    /* C11 standard section 6.3.1.4 "Real floating and integer" says:
+     *
+     *  1 When a finite value of real floating type is converted to an integer
+     *    type other than _Bool, the fractional part is discarded (i.e., the
+     *    value is truncated toward zero). If the value of the integral part
+     *    cannot be represented by the integer type, the behavior is undefined.
+     *
+     * So we must perform a range check that v <= UINT64_MAX, but we can't use
+     * UINT64_MAX + 1.0 because the standard continues:
+     *
+     *  2 When a value of integer type is converted to a real floating type, if
+     *    the value being converted can be represented exactly in the new type,
+     *    it is unchanged. If the value being converted is in the range of
+     *    values that can be represented but cannot be represented exactly, the
+     *    result is either the nearest higher or nearest lower representable
+     *    value, chosen in an implementation-defined manner.
+     */
+    double supremum = -2.0 * INT64_MIN;     /* -2 * (- 2^63) == 2^64 */
+    if (v >= supremum)
+        return false;
+
+    /* Now we can convert, these two conversions cannot be UB */
+    *absolute = v;
+    return *absolute == v;
+}
+
 static void printRecursionLimit(CborStreamFunction stream, void *out)
 {
     stream(out, "<nesting too deep, recursion stopped>");
@@ -489,8 +519,8 @@
                 suffix = "";
         }

-        uint64_t ival = (uint64_t)fabs(val);
-        if (ival == fabs(val)) {
+        uint64_t ival;
+        if (convertToUint64(val, &ival)) {
             /* this double value fits in a 64-bit integer, so show it as such
              * (followed by a floating point suffix, to disambiguate) */
             err = stream(out, "%s%" PRIu64 ".%s", val < 0 ? "-" : "", ival, suffix);


Turn warning into DEBUG()

Turn warning into DEBUG()

Also, rewrite the comment.

--- src/mcd-connection.c
+++ src/mcd-connection.c
@@ -1993,10 +1993,10 @@
 {
     McError mc_error_code;

-    g_warning ("Telepathy Error = %s", error->message);
-
-    /* TODO : Are there still more specific errors we need
-     * to distinguish?
+    DEBUG ("Telepathy Error = %s", error->message);
+
+    /* Some TP errors might be a bit too generic for the UIs.
+     * With some guesswork, we can add more precise error reporting here.
      */
     if (mcd_channel_get_channel_type_quark (channel) ==
 	TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA &&


tty: find_line_len fixed again (and may be not finally)

--- src/drivers/tty/tty.c
+++ src/drivers/tty/tty.c
@@ -190,10 +190,10 @@

 static size_t find_line_len(cc_t eol, cc_t eof,
 		const char *buff, ssize_t size, int *is_eof) {
-	int offset = -1;
+	size_t offset;

 	*is_eof = 0;
-	for (; offset < size; ++offset) {
+	for (offset = 0; offset < size; ++offset) {
 		char ch = buff[offset];
 		if (ch == '\n' || ch == eol || ch == eof) {
 			*is_eof = (ch == eof);


Fix get_value

Fix get_value

--- src/sql/midgard_sql_query_column.c
+++ src/sql/midgard_sql_query_column.c
@@ -241,8 +241,8 @@
 	g_value_take_string (
 		value,
 		g_strjoin(
+			".",
 			midgard_query_column_get_qualifier (MIDGARD_QUERY_COLUMN (self), NULL),
-			".",
 			midgard_query_column_get_name (MIDGARD_QUERY_COLUMN (self), NULL),
 			NULL
 		)


Rename auto-reconnection variable

Rename auto-reconnection variable

Also, change its type so it takes one bit only.

--- src/mcd-connection.c
+++ src/mcd-connection.c
@@ -99,7 +99,6 @@

     guint reconnect_timer; 	/* timer for reconnection */
     guint reconnect_interval;
-    gboolean reconnection_requested;

     /* Supported presences (values are McdPresenceInfo structs) */
     GHashTable *recognized_presences;
@@ -120,6 +119,8 @@

     /* FALSE until we got the first PresencesChanged for the self handle */
     guint got_presences_changed : 1;
+
+    guint auto_reconnect : 1;

     gchar *alias;

@@ -1092,7 +1093,7 @@
 	priv->capabilities_timer = 0;
     }

-    if (priv->reconnection_requested)
+    if (priv->auto_reconnect)
     {
         /* we were disconnected by a network error or by a connection manager
          * crash (in the latter case, we get NoneSpecified as a reason): don't
@@ -1860,7 +1861,7 @@
     priv->abort_reason = TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED;

     priv->reconnect_interval = 30 * 1000; /* 30 seconds */
-    priv->reconnection_requested = TRUE;
+    priv->auto_reconnect = TRUE;
 }

 /* Public methods */
@@ -2416,7 +2417,7 @@
     McdConnectionPrivate *priv = MCD_CONNECTION_PRIV (connection);

     g_debug ("%s called", G_STRFUNC);
-    priv->reconnection_requested = TRUE;
+    priv->auto_reconnect = TRUE;
     priv->reconnect_interval = 500; /* half a second */
     mcd_mission_disconnect (MCD_MISSION (connection));
     _mcd_connection_call_disconnect (connection);
@@ -2464,6 +2465,6 @@
 {
     g_return_if_fail (MCD_IS_CONNECTION (connection));

-    connection->priv->reconnection_requested = reconnect;
-}
-
+    connection->priv->auto_reconnect = reconnect;
+}
+


Initial commit

Initial commit

error: pathspec 'gpm/clock2.c' did not match any file(s) known to git

--- gpm/clock2.c
+++ gpm/clock2.c
@@ -0,0 +1,60 @@
+// clock2: TCP server that periodically writes the time.
+// This variation handles connections concurrently.
+// See chapter 8 in The Go Programming Language.
+#include <stdio.h>
+#include <libdill.h>
+#include <assert.h>
+#include <time.h>
+
+coroutine void handleConn(int s)
+{
+	assert(s >= 0);
+	printf("Connection on socket %d\n", s);
+
+	int rc;
+	time_t dt;
+	char buf[128];
+	int written;
+
+	while (1) {
+		time(&dt);
+		written = snprintf(buf, sizeof(buf), "%s",
+				asctime(localtime(&dt)));
+		assert(written > 0 && written < sizeof(buf));
+
+		rc = bsend(s, buf, written, -1);
+		if (rc != 0) break;
+
+		rc = msleep(now() + 1000);
+		assert(rc == 0);
+	}
+
+	rc = tcp_close(s, -1);
+	if (rc != 0 && errno != ECONNRESET)
+		perror("tcp_close");
+}
+
+int main()
+{
+	struct ipaddr addr;
+	int rc = ipaddr_local(&addr, NULL, 8000, 0);
+	assert(rc >= 0);
+
+	int ls = tcp_listen(&addr, 10);
+	assert(ls >= 0);
+
+	while (1) {
+		int s = tcp_accept(ls, NULL, -1);
+		assert(s >= 0);
+
+		// Handle each connection concurrently.
+		rc = go(handleConn(s));
+		assert(rc >= 0);
+	}
+
+	rc = tcp_close(ls, -1);
+	assert(rc == 0);
+
+	return 0;
+}
+


McdDispatcher: if an activatable Handler is running, call GetAll(HANDLER)

This will eventually be used to check whether it is handling any channels.

--- src/mcd-dispatcher.c
+++ src/mcd-dispatcher.c
@@ -1786,6 +1786,13 @@

         default:
             g_assert_not_reached ();
+    }
+
+    if (*client_filters != NULL)
+    {
+        g_list_foreach (*client_filters, (GFunc) g_hash_table_destroy, NULL);
+        g_list_free (*client_filters);
+        *client_filters = NULL;
     }

     for (i = 0 ; i < filters->len ; i++)
@@ -2283,7 +2290,26 @@
             NULL, G_OBJECT (dispatcher));
     }
     else
+    {
         client_add_interface_by_id (client);
+
+        if ((client->interfaces & MCD_CLIENT_HANDLER) != 0 &&
+            _mcd_client_proxy_is_active (proxy))
+        {
+            DEBUG ("%s is an active, activatable Handler", client->name);
+
+            /* We need to investigate whether it is handling any channels */
+
+            if (!dispatcher->priv->startup_completed)
+                dispatcher->priv->startup_lock++;
+
+            tp_cli_dbus_properties_call_get_all (client->proxy, -1,
+                                                 MC_IFACE_CLIENT_HANDLER,
+                                                 handler_get_all_cb,
+                                                 NULL, NULL,
+                                                 G_OBJECT (dispatcher));
+        }
+    }

 finally:
     /* paired with the lock taken when we made the McdClient */


minor fix in policy-io.c, seaudit - recent files, error checking on open files

2003/11/06 13:17:18-00:00 !mayerf
Fixed a couple of bugs relating to open options in libapol.

2003/10/15 19:24:50-00:00 !mayerf
Implemented changes to support optional policy load capabilities.

2003/10/10 18:23:23-00:00 !mayerf
Coomprehensive update that primarily implements the creation of two libseuser libs; one core C lib and one that adds the TCL support.  This required extensive changes to the seuser command line program, and the entire removal of the wrapper layer.  It also had ancillary impact on libapol, and on the make process for all tools.

2003/10/08 16:04:47-00:00 !mayerf
Added stubs for optionsal loading of pieces of policies.

2003/10/03 14:27:20-00:00 !mayerf
Added missing policy-io.* files.

(Logical change 1.3)

--- libapol/policy-io.c
+++ libapol/policy-io.c
@@ -0,0 +1,148 @@
+/* Copyright (C) 2001-2003 Tresys Technology, LLC
+ * see file 'COPYING' for use and warranty information */
+
+/*
+ * Author: mayerf@tresys.com
+ */
+
+/* policy-io.c
+ *
+ * Policy I/O functions
+ */
+
+#include "policy.h"
+#include "util.h"
+#include "stdio.h"
+#include "queue.h"
+#ifdef APOL_PERFORM_TEST
+#include <time.h>
+#endif
+
+/* externs mostly with yacc parser */
+extern policy_t *parse_policy; /* parser using a global policy which we must set here */
+extern unsigned int policydb_lineno;
+extern queue_t id_queue;
+extern FILE *yyin;
+extern int yyparse(void);
+extern void yyrestart(FILE *);
+extern unsigned int pass;
+
+int close_policy(policy_t *policy)
+{
+	return free_policy(&policy);
+}
+
+static int read_policy(policy_t *policy)
+{
+	parse_policy = policy; /* setting the parser's global parse policy */
+	/* assumed yyin is opened to policy file */
+	id_queue = queue_create();
+	if (!id_queue) {
+		fprintf(stderr, "out of memory\n");
+		queue_destroy(id_queue);
+		return -1;
+	}
+	policydb_lineno = 1;
+	pass = 1;
+	if (yyparse()) {
+		fprintf(stderr, "error(s) encountered while parsing configuration (first pass, line: %d)\n", policydb_lineno);
+		queue_destroy(id_queue);;
+		return -1;
+	}
+
+	/* If we don't need anything from pass 2, just return and save the time */
+	if(!(policy->opts & PLOPT_PASS_2 )) {
+		queue_destroy(id_queue);
+		return 0;
+	}
+
+	policydb_lineno = 1;
+	pass = 2;
+	rewind(yyin);
+	yyrestart(yyin);
+	if (yyparse()) {
+		fprintf(stderr, "error(s) encountered while parsing configuration (second pass, line: %d)\n", policydb_lineno);
+		queue_destroy(id_queue);
+		return -1;
+	}
+
+	queue_destroy(id_queue);
+	return 0;
+}
+
+/* checks for acceptable combinations, and adjusts the mask accordingly */
+unsigned int validate_policy_options(unsigned int options)
+{
+	unsigned int opts = options;
+
+	/* NOTE: The order of these is important */
+	if(POLOPT_TE_RULES & opts)
+		opts |= (POLOPT_OBJECTS|POLOPT_TYPES);
+	if(POLOPT_PERMS & opts)
+		opts |= POLOPT_CLASSES;
+	if(POLOPT_ROLE_RULES & opts)
+		opts |= (POLOPT_TYPES|POLOPT_ROLES|POLOPT_CLASSES);
+	if(POLOPT_USERS & opts)
+		opts |= POLOPT_ROLES;
+	if(POLOPT_ROLES & opts)
+		opts |= POLOPT_TYPES;
+
+	return opts;
+}
+
+/* returns:
+ *  0	success
+ *  1	invalid options combination
+ * -1	general error
+ */
+int open_partial_policy(const char* filename, unsigned int options, policy_t **policy)
+{
+	int rt;
+	unsigned int opts;
+
+	opts = validate_policy_options(options);
+
+	if(policy == NULL)
+		return -1;
+	*policy = NULL;
+	rt = init_policy(policy);
+	if(rt != 0) {
+		fprintf(stderr, "error initializing policy\n");
+		return -1;
+	}
+	(*policy)->opts = opts;
+	yyin = fopen(filename, "r");
+	if (yyin == NULL) {
+		fprintf(stderr, "Could not open policy!\n");
+		return -1;
+	}
+
+#ifdef APOL_PERFORM_TEST
+/*  test policy load performance; it's an undocumented feature only in test builds */
+	{
+	clock_t start,  stop;
+	double time;
+	start = clock();
+	rt = read_policy(*policy);
+	stop = clock();
+	time = ((double) (stop - start)) / CLOCKS_PER_SEC;
+	fprintf(stdout, "\nTime to load policy %s: %f\n\n", filename, time);
+	}
+#else
+	rt = read_policy(*policy);
+#endif
+	if(rt != 0) {
+		fprintf(stderr, "error reading policy\n");
+		fclose(yyin);
+		return -1;
+	}
+	fclose(yyin);
+	return 0;
+}
+
+/* opens the entire policy */
+int open_policy(const char* filename, policy_t **policy)
+{
+	return open_partial_policy(filename, POLOPT_ALL, policy);
+}
+


Update checkqueue.h

Update checkqueue.h

--- src/checkqueue.h
+++ src/checkqueue.h
@@ -67,7 +67,7 @@
         do {
             {
                 boost::unique_lock<boost::mutex> lock(mutex);
-                // first do the clean-up of the previous looper run (allowing us to do it in the same critsect)
+                // first do the clean-up of the previous loop run (allowing us to do it in the same critsect)
                 if (nNow) {
                     fAllOk &= fOk;
                     nTodo -= nNow;
@@ -78,7 +78,7 @@
                     // first iteration
                     nTotal++;
                 }
-                // logically, the do looper starts here
+                // logically, the do loop starts here
                 while (queue.empty()) {
                     if ((fMaster || fQuit) && nTodo == 0) {
                         nTotal--;


shaper: purge outdated comment

shaper: purge outdated comment

HarfBuzz has been able to disable fallback kerning since commit
038c98f6. Add some more useful docstrings instead.

--- libass/ass_shaper.c
+++ libass/ass_shaper.c
@@ -702,8 +702,8 @@

 /**
  * \brief Toggle kerning for HarfBuzz shaping.
- * NOTE: currently only works with OpenType fonts, the TrueType fallback *always*
- * kerns. It's a bug in HarfBuzz.
+ * \param shaper shaper instance
+ * \param kern toggle kerning
  */
 void ass_shaper_set_kerning(ASS_Shaper *shaper, int kern)
 {


ass_strtod: handle overflowing exponents

The exponent may overflow an integer, e. g. in
`14e888888888888888888888888888880000000000000000000000000000`
on a 32-bit platform. Correctly handle this, including the case
when the exponent overflows but the whole string still describes
a valid floating-point number, e. g. in
`1[4294967200 zeros]e-4294967300`.

This fixes libass#244. Buffer overflow was fixed in 67f647e, and
this ensures that the string is converted to the correct number.

--- libass/ass_strtod.c
+++ libass/ass_strtod.c
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 1988-1993 The Regents of the University of California.
  * Copyright (c) 1994 Sun Microsystems, Inc.
+ * Copyright (c) 2016 Oleg Oshmyan <chortos@inbox.lv>
  *
  * Permission to use, copy, modify, and distribute this
  * software and its documentation for any purpose and without
@@ -78,7 +79,7 @@
                              * address here. */
     )
 {
-    int sign, fracExpSign, expSign = 0;
+    int sign, fracExpSign, expSign;
     double fraction, dblExp, *d;
     register const char *p;
     register int c;
@@ -206,6 +207,14 @@

     p = pExp;
     if ((*p == 'E') || (*p == 'e')) {
+        size_t expLimit;    /* If exp > expLimit, appending another digit
+                             * to exp is guaranteed to make it too large.
+                             * If exp == expLimit, this may depend on
+                             * the exact digit, but in any case exp with
+                             * the digit appended and fracExp added will
+                             * still fit in size_t, even if it does
+                             * exceed maxExponent. */
+        int expWraparound = 0;
         p += 1;
         if (*p == '-') {
             expSign = 1;
@@ -216,17 +225,37 @@
             }
             expSign = 0;
         }
+        if (expSign == fracExpSign) {
+            if (maxExponent < fracExp) {
+                expLimit = 0;
+            } else {
+                expLimit = (maxExponent - fracExp) / 10;
+            }
+        } else {
+            expLimit = fracExp / 10 + (fracExp % 10 + maxExponent) / 10;
+        }
         while (ass_isdigit(*p)) {
+            if ((exp > expLimit) || expWraparound) {
+                do {
+                    p += 1;
+                } while (ass_isdigit(*p));
+                goto expOverflow;
+            } else if (exp > ((size_t) -1 - (*p - '0')) / 10) {
+                expWraparound = 1;
+            }
             exp = exp * 10 + (*p - '0');
             p += 1;
         }
-    }
-    if (expSign == fracExpSign) {
-        exp = fracExp + exp;
-    } else if (fracExp <= exp) {
-        exp = exp - fracExp;
-    } else {
-        exp = fracExp - exp;
+        if (expSign == fracExpSign) {
+            exp = fracExp + exp;
+        } else if ((fracExp <= exp) || expWraparound) {
+            exp = exp - fracExp;
+        } else {
+            exp = fracExp - exp;
+            expSign = fracExpSign;
+        }
+    } else {
+        exp = fracExp;
         expSign = fracExpSign;
     }

@@ -238,6 +267,7 @@
      */

     if (exp > maxExponent) {
+expOverflow:
         exp = maxExponent;
         if (fraction != 0.0) {
             errno = ERANGE;


*** empty log message ***

*** empty log message ***

git-svn-id: 29285e03eadf944384989fddbe8eccac9818e9d7@608 1a406e8e-add9-4483-a2c8-d8cac5b7c224

--- src/chxj_jhtml.c
+++ src/chxj_jhtml.c
@@ -1988,8 +1988,8 @@
 static char*
 s_jhtml_end_div_tag(jhtml_t* jhtml, Node* child)
 {
-  Doc* doc = jhtml->doc;
-  request_rec* r = doc->r;
+  Doc*         doc = jhtml->doc;
+  request_rec* r   = doc->r;

   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</div>\n", NULL);


simplify

simplify

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

--- libavcodec/ac3enc.c
+++ libavcodec/ac3enc.c
@@ -467,6 +467,9 @@
                      int frame_bits, int csnroffst, int fsnroffst)
 {
     int i, ch;
+    int snroffset;
+
+    snroffset = (((csnroffst - 15) << 4) + fsnroffst) << 2;

     /* compute size */
     for(i=0;i<NB_BLOCKS;i++) {
@@ -476,8 +479,7 @@
         for(ch=0;ch<s->nb_all_channels;ch++) {
             ff_ac3_bit_alloc_calc_bap(mask[i][ch], psd[i][ch],
                                           0, s->nb_coefs[ch],
-                                          (((csnroffst-15) << 4) +
-                                           fsnroffst) << 2,
+                                      snroffset,
                                       s->bit_alloc.floor, bap[i][ch]);
             frame_bits += compute_mantissa_size(s, bap[i][ch],
                                                  s->nb_coefs[ch]);


ahci_dma_pool.c: add missing header

ahci_dma_pool.c: add missing header

--- lib/ahci/ahci_dma_pool.c
+++ lib/ahci/ahci_dma_pool.c
@@ -11,6 +11,7 @@
 #include <ahci/ahci_dma_pool.h>
 #include <errors/errno.h>
 #include <string.h>
+#include <sys/types.h> /* for ssize_t */
 #include "ahci_debug.h"

 #define EIGHT_MEG 8388608


Stream: fixed handling of non-ssl sessions.

A missing check could cause ngx_stream_ssl_handler() to be applied
to a non-ssl session, which resulted in a null pointer dereference
if ssl_verify_client is enabled.

The bug had appeared in 1.11.8 (41cb1b64561d).

--- src/stream/ngx_stream_ssl_module.c
+++ src/stream/ngx_stream_ssl_module.c
@@ -287,11 +287,15 @@
     ngx_connection_t       *c;
     ngx_stream_ssl_conf_t  *sslcf;

+    if (!s->ssl) {
+        return NGX_OK;
+    }
+
     c = s->connection;

     sslcf = ngx_stream_get_module_srv_conf(s, ngx_stream_ssl_module);

-    if (s->ssl && c->ssl == NULL) {
+    if (c->ssl == NULL) {
         c->log->action = "SSL handshaking";

         if (sslcf->ssl.ctx == NULL) {


get sender and data

get sender and data

--- src/communication/communication.c
+++ src/communication/communication.c
@@ -62,6 +62,12 @@

 /**
  * TODO: Description here
+ *
+ * Example of pmessage reply:
+ * 0: pmessage
+ * 1: communication_client:*
+ * 2: communication_client:myLabel
+ * 3: {"from": "matei94_pie@wyliodrin.com/c16f6698", "data": "evrika"}
  */
 static void onMessage(redisAsyncContext *c, void *reply, void *privdata);

@@ -161,7 +167,20 @@

       for (i = 0; i < MAX_CONNECTIONS; i++) {
         if (connections[i].label != NULL && strcmp(connections[i].label, label) == 0) {
-          connections[i].handler_function("sender", label, 0, "data");
+          /* Get id value */
+          char *colon = strchr(r->element[3]->str, ':');
+          char *first_qm = strchr(colon, '\"');
+          char *second_qm = strchr(first_qm + 1, '\"');
+          char sender[second_qm - first_qm];
+          snprintf(sender, second_qm - first_qm - 1, "%s", first_qm + 1);
+          /* Get data value */
+          colon = strchr(second_qm, ':');
+          first_qm = strchr(colon, '\"');
+          second_qm = strchr(first_qm + 1, '\"');
+          char data[second_qm - first_qm];
+          snprintf(data, second_qm - first_qm - 1, "%s", first_qm + 1);
+
+          connections[i].handler_function(sender, label, 0, data);
           return;
         }
       }
@@ -179,7 +198,7 @@
   int conn_index;

   for (conn_index = 0; conn_index < MAX_CONNECTIONS; conn_index++) {
-    if (connections[conn_index].label != NULL) {
+    if (connections[conn_index].label == NULL) {
       break;
     }
   }


Use void* instead of caddr_t.

Use void* instead of caddr_t.

caddr_t is an old BSD-ism no longer used.

--- lab3/tstcrash_simple.c
+++ lab3/tstcrash_simple.c
@@ -18,7 +18,7 @@
 int main(int argc, char *argv[]){

   static char arr[20];
-  caddr_t highbreak, lowbreak;
+  void *highbreak, *lowbreak;
   int add = 0;
   char *p, *q, *r, *t;


*** empty log message ***

*** empty log message ***

git-svn-id: 941c396c0c997e7bb438e0bf88317cdf88a3ff60@563 1a406e8e-add9-4483-a2c8-d8cac5b7c224

--- src/chxj_jhtml.c
+++ src/chxj_jhtml.c
@@ -1350,8 +1350,7 @@
                     "\" ",
                     NULL);
   }
-  if (name != NULL)
-  {
+  if (name) {
     jhtml->out = apr_pstrcat(r->pool,
                     jhtml->out,
                     " name=\"",


added proper memory handling functions - fixed include paths

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

--- libavcodec/common.h
+++ libavcodec/common.h
@@ -17,18 +17,19 @@

 #ifdef HAVE_AV_CONFIG_H
 /* only include the following when compiling package */
-#include "../config.h"
+#include "config.h"

 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
+#include <math.h>

 #ifndef ENODATA
 #define ENODATA  61
 #endif

-#endif
+#endif /* HAVE_AV_CONFIG_H */

 #ifdef CONFIG_WIN32

@@ -121,7 +122,7 @@
 #define UINT64_C(c)    (c ## ULL)
 #endif

-#include "../bswap.h"
+#include "bswap.h"

 #ifdef USE_FASTMEMCPY
 #include "fastmemcpy.h"
@@ -897,7 +898,10 @@
 }

 /* memory */
+void *av_malloc(int size);
 void *av_mallocz(int size);
+void av_free(void *ptr);
+#define av_freep(p) do { av_free(*p); *p = NULL; } while (0)

 /* math */
 int ff_gcd(int a, int b);


time: nanosleep rewritten according to small time measurement issue

--- src/compat/posix/util/nanosleep.c
+++ src/compat/posix/util/nanosleep.c
@@ -3,32 +3,100 @@
  *
  * @date Sep 25, 2013
  * @author: Anton Bondarev
+ * @author: Alexander Kalmuk
  */
 #include <errno.h>
 #include <time.h>
+#include <stdlib.h>

 #include <kernel/time/ktime.h>
+#include <kernel/time/clock_source.h>
+#include <embox/unit.h>

+#define NANOSLEEP_DEBUG
+
+#ifdef NANOSLEEP_DEBUG
+#include <kernel/printk.h>
+#endif
+
+EMBOX_UNIT_INIT(nanosleep_calibrate);
+
+static int nanosleep_exec_time;
+
+/* I use busy-wait for small amount of time (< 1 ms), because overhead on calculation is very small. */
+static uint32_t cs_nano_diff(struct clock_source *cs, uint32_t old, uint32_t new) {
+	uint32_t load = cs->counter_device->cycle_hz / cs->event_device->event_hz - 1;
+	uint32_t ticks = new < old ? load - old + new : new - old;
+	return (((uint64_t) ticks * cs->counter_mult) >> cs->counter_shift);
+}
+
+static void cs_nanospin(struct clock_source *cs, uint32_t ns) {
+	uint32_t start = cs->counter_device->read();
+	while(cs_nano_diff(cs, start, cs->counter_device->read()) < ns);
+}
+
+/**
+ * Main logic:
+ * 1. Calculate execution time of ktime_get_ns (i.e. overhead)
+ * 2. Then we can calculate execution of nanosleep without going in ksleep and without spin (i.e. overhead).
+ * 3. When we get T ns as argument in nanosleep, we substitute overhead calculated in step 2 from T.
+ */
+static int nanosleep_calibrate(void) {
+	uint64_t t, m;
+	const struct timespec rqtp = { .tv_sec = 0, .tv_nsec = 1 };
+
+	/* calculate ktime_get_ns overhead  */
+	t = ktime_get_ns();
+	t = ktime_get_ns() - t;
+
+#ifdef NANOSLEEP_DEBUG
+	printk("ktime_get_ns execution ns: %d\n", (int)t);
+#endif
+
+	m = ktime_get_ns();
+	nanosleep(&rqtp, NULL); // calculate nanosleep overhead
+	m = ktime_get_ns() - m;
+	nanosleep_exec_time = m - t;
+
+#ifdef NANOSLEEP_DEBUG
+	printk("nanosleep execution ns: %d\n", nanosleep_exec_time);
+#endif
+
+	return 0;
+}
+
+/* XXX: nanosleep is irq sensetive, i.e. rqtp can be exceeded when irq occur
+ * after ksleep and before returning from nanosleep. */
 int nanosleep(const struct timespec *rqtp, struct timespec *rmtp) {
-	int res;
-	time64_t nsec;
-	struct timespec start_time;
+	time64_t rqtp_ns, start, tmp;
+	uint32_t ms;
+	int remaining_time;
+	struct clock_source *cs;

-	clock_gettime(0, &start_time);
+	start = ktime_get_ns();

-	nsec = timespec_to_ns(rqtp);
+	cs = clock_source_get_best(CS_WITH_IRQ);
+	rqtp_ns = timespec_to_ns(rqtp);

-	/* 10^-9 = nsec; 10^-3 = msec;
- 	 n * nsec = (n / 1_000_000) * msec */
-	res = ksleep(nsec / 1000000);
-	if (res < 0) {
-		if (NULL != rmtp) {
-			clock_gettime(0, rmtp);
-			*rmtp = timespec_sub(start_time, *rmtp);
-		}
-		SET_ERRNO(EINTR);
-		return -1;
+	if (rqtp_ns < nanosleep_exec_time) {
+		return ENOERR;
 	}
+	rqtp_ns -= nanosleep_exec_time;
+
+	ms = rqtp->tv_sec * 1000 + rqtp->tv_nsec / 1000000;
+	if (ms > 0) {
+		ksleep(ms);
+	}
+
+	tmp = ktime_get_ns();
+	/* remaining time < 2 ms */
+	remaining_time = rqtp_ns - (tmp - start);
+	if (remaining_time > 0) {
+		/* Split in two steps, because of cs_nanospins works only for times < 1 ms */
+		cs_nanospin(cs, remaining_time / 2); // < 1 ms
+		cs_nanospin(cs, remaining_time / 2); // < 1 ms
+	}
+
 	return ENOERR;
 }


Clarify get_ue_golomb_31() behavior with >31.

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

--- libavcodec/golomb.h
+++ libavcodec/golomb.h
@@ -75,7 +75,8 @@
 }

  /**
- * read unsigned exp golomb code, constraint to a max of 31
+ * read unsigned exp golomb code, constraint to a max of 31.
+ * the return value is undefined if the stored value exceeds 31.
  */
 static inline int get_ue_golomb_31(GetBitContext *gb){
     unsigned int buf;


works with old gcc versions too

works with old gcc versions too

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

--- libavcodec/wmadec.c
+++ libavcodec/wmadec.c
@@ -199,7 +199,7 @@

 #else

-#define trace(fmt, ...)
+#define trace(fmt, args...)

 #endif


sync with glibc and get a nice size shrinkage in the process

--- libc/stdio/tmpnam.c
+++ libc/stdio/tmpnam.c
@@ -1,20 +1,20 @@
-/* Copyright (C) 1991, 1993, 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1993,1996-1999,2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.

    The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.

    The GNU C Library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
+   Lesser General Public License for more details.

-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */

 #include <stdio.h>
 #include <string.h>
@@ -25,26 +25,31 @@
 static char tmpnam_buffer[L_tmpnam];

 /* Generate a unique filename in P_tmpdir.
-   This function is *not* thread safe when S == NULL!
-*/
-char * tmpnam (char *s)
+
+   This function is *not* thread safe!  */
+char *
+tmpnam (char *s)
 {
-    /* By using two buffers we manage to be thread safe in the case
-       where S != NULL.  */
-    char tmpbuf[L_tmpnam];
+  /* By using two buffers we manage to be thread safe in the case
+     where S != NULL.  */
+  char tmpbufmem[L_tmpnam];
+  char *tmpbuf = s ?: tmpbufmem;

-    /* In the following call we use the buffer pointed to by S if
-       non-NULL although we don't know the size.  But we limit the size
-       to L_tmpnam characters in any case.  */
-    if (__path_search (s ? : tmpbuf, L_tmpnam, NULL, NULL, 0))
-	return NULL;
+  /* In the following call we use the buffer pointed to by S if
+     non-NULL although we don't know the size.  But we limit the size
+     to L_tmpnam characters in any case.  */
+  if (__builtin_expect (__path_search (tmpbuf, L_tmpnam, NULL, NULL, 0),
+			0))
+    return NULL;

-    if (__gen_tempname (s ? : tmpbuf, __GT_NOCREATE))
-	return NULL;
+  if (__builtin_expect (__gen_tempname (tmpbuf, __GT_NOCREATE), 0))
+    return NULL;

-    if (s == NULL)
-	return (char *) memcpy (tmpnam_buffer, tmpbuf, L_tmpnam);
+  if (s == NULL)
+    return (char *) memcpy (tmpnam_buffer, tmpbuf, L_tmpnam);

-    return s;
+  return s;
 }

+link_warning (tmpnam,
+	      "the use of `tmpnam' is dangerous, better use `mkstemp'")


Checked for 0 window size in glk_window_move_cursor().

--- libchimara/window.c
+++ libchimara/window.c
@@ -1193,6 +1193,10 @@
 	VALID_WINDOW(win, return);
 	g_return_if_fail(win->type == wintype_TextGrid);

+	/* Don't do anything if the window is shrunk down to nothing */
+	if(win->width == 0 || win->height == 0)
+		return;
+
 	/* Calculate actual position if cursor is moved past the right edge */
 	if(xpos >= win->width)
 	{


pad: Check if new probes need to be called when adding/removing some

This allows blocking a pad, add a new blocking probe, removing
the first probe and then having the second probe called. Which
could then decide that data-flow should actually continue
instead of blocking now.

https://bugzilla.gnome.org/show_bug.cgi?id=721289

--- gst/gstpad.c
+++ gst/gstpad.c
@@ -1192,10 +1192,13 @@
     pad->num_blocked--;
     GST_DEBUG_OBJECT (pad, "remove blocking probe, now %d left",
         pad->num_blocked);
+
+    /* Might have new probes now that want to be called */
+    GST_PAD_BLOCK_BROADCAST (pad);
+
     if (pad->num_blocked == 0) {
       GST_DEBUG_OBJECT (pad, "last blocking probe removed, unblocking");
       GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_BLOCKED);
-      GST_PAD_BLOCK_BROADCAST (pad);
     }
   }
   g_hook_destroy_link (&pad->probes, hook);
@@ -1270,6 +1273,9 @@
     GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_BLOCKED);
     GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "added blocking probe, "
         "now %d blocking probes", pad->num_blocked);
+
+    /* Might have new probes now that want to be called */
+    GST_PAD_BLOCK_BROADCAST (pad);
   }

   /* call the callback if we need to be called for idle callbacks */
@@ -3225,6 +3231,14 @@
       GST_PAD_BLOCK_WAIT (pad);
       GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_BLOCKING);
       GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "We got unblocked");
+
+      /* if the list changed, call the new callbacks (they will not have their
+       * cookie set to data.cookie */
+      if (cookie != pad->priv->probe_list_cookie) {
+        GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad,
+            "probe list changed, restarting");
+        goto again;
+      }

       if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
         goto flushing;


replace MPI_File_seek and MPI_File_read with MPI_File_read_at_all

--- libdispatch/dfile.c
+++ libdispatch/dfile.c
@@ -2063,7 +2063,6 @@
     }
 #ifdef USE_PARALLEL
     if (file->use_parallel) {
-	MPI_Status mstatus;
 	int retval;
 	MPI_Offset size;
 	MPI_Comm comm = MPI_COMM_WORLD;
@@ -2137,12 +2136,8 @@
     if (file->use_parallel) {
 	MPI_Status mstatus;
 	int retval;
-	MPI_Offset offset;
-	offset = pos;
-	if((retval = MPI_File_seek(file->fh, offset, MPI_SEEK_SET)) != MPI_SUCCESS)
-	    {status = NC_EPARINIT; goto done;}
-	if((retval = MPI_File_read(file->fh, magic, MAGIC_NUMBER_LEN, MPI_CHAR,
-				 &mstatus)) != MPI_SUCCESS)
+	if((retval = MPI_File_read_at_all(file->fh, pos, magic,
+                     MAGIC_NUMBER_LEN, MPI_CHAR, &mstatus)) != MPI_SUCCESS)
 	    {status = NC_EPARINIT; goto done;}
 	goto done;
     }
@@ -2172,7 +2167,6 @@
     if(file->inmemory) goto done; /* noop*/
 #ifdef USE_PARALLEL
     if (file->use_parallel) {
-	MPI_Status mstatus;
 	int retval;
 	if((retval = MPI_File_close(&file->fh)) != MPI_SUCCESS)
 		{status = NC_EPARINIT; goto done;}


vdec: add support for chunks

vdec: add support for chunks

Incomplete frames.

Signed-off-by: Felipe Contreras <de77a8b9cd239b204c19c52ed62e48ab47243362@gmail.com>

--- gstav_vdec.c
+++ gstav_vdec.c
@@ -312,6 +312,7 @@
 	const GValue *codec_data;
 	GstBuffer *buf;
 	AVCodecContext *ctx;
+	bool chunks = false;

 	self = (struct obj *)((GstObject *)pad)->parent;
 	ctx = self->av_ctx;
@@ -321,8 +322,13 @@
 	name = gst_structure_get_name(in_struc);
 	if (strcmp(name, "video/x-h263") == 0)
 		codec_id = CODEC_ID_H263;
-	else if (strcmp(name, "video/x-h264") == 0)
+	else if (strcmp(name, "video/x-h264") == 0) {
+		const char *alignment;
+		alignment = gst_structure_get_string(in_struc, "alignment");
+		if (strcmp(alignment, "nal") == 0)
+			chunks = true;
 		codec_id = CODEC_ID_H264;
+	}
 	else if (strcmp(name, "video/mpeg") == 0) {
 		int version;
 		gst_structure_get_int(in_struc, "mpegversion", &version);
@@ -418,6 +424,8 @@
 	ctx->reget_buffer = reget_buffer;
 	ctx->opaque = self;
 	ctx->flags |= CODEC_FLAG_EMU_EDGE;
+	if (chunks)
+		ctx->flags2 |= CODEC_FLAG2_CHUNKS;

 	gst_structure_get_int(in_struc, "width", &ctx->width);
 	gst_structure_get_int(in_struc, "height", &ctx->height);
@@ -480,7 +488,6 @@
 	gst_caps_append_structure(caps, struc);

 	struc = gst_structure_new("video/x-h264",
-			"alignment", G_TYPE_STRING, "au",
 			NULL);

 	gst_caps_append_structure(caps, struc);


Add comments.

Add comments.

--- gstbdautil.h
+++ gstbdautil.h
@@ -27,28 +27,70 @@
 #include <qedit.h>
 #include "gstbdasrc.h"

+/**
+ * Returns a description for the specified BDA / DirectShow error code.
+ */
 std::string bda_err_to_str (HRESULT hr);

+/**
+ * Returns a friendly name for the specified BDA tuner device.
+ */
 std::string bda_get_tuner_name (IMoniker * tuner_moniker);

+/**
+ * Determines input device type from tuner's capabilities. FIXME: One device
+ * can probably support multiple input types (e.g. DVB-T and DVB-C), we don't
+ * currently support that.
+ */
 GstBdaInputType gst_bdasrc_get_input_type (GstBdaSrc * src);

+/**
+ * Maps our input type to BDA network type.
+ */
 BOOL gst_bdasrc_get_network_type (GstBdaInputType input_type,
     CLSID & network_type);

+/**
+ * Returns a BDA tuning space according to input device type. If a matching
+ * tuning space is found in system tuning spaces, it is returned. Otherwise
+ * a new one is created. FIXME: Use a more generic interface than
+ * IDVBTuningSpace.
+ * @return TRUE if tuning space was found or created successfully
+ */
 BOOL gst_bdasrc_create_tuning_space (GstBdaSrc * src,
     IDVBTuningSpacePtr & tuning_space);

+/**
+ * Initializes a tune request according to input device type. FIXME: Use a more
+ * generic interface than IDVBTuneRequest.
+ * @return TRUE if tune request was initialized successfully
+ */
 BOOL gst_bdasrc_tune_request (GstBdaSrc * src,
     IDVBTuneRequestPtr & tune_request);

+/**
+ * Connects the specified DirectShow filters. Enumerates filter pins and
+ * tries to connect any unconnected pins (upstream output pin -> downstream
+ * input pin).
+ * @return S_OK if filters were connected successfully, otherwise an error
+ */
 HRESULT gst_bdasrc_connect_filters (GstBdaSrc * src,
     IBaseFilter * filter_upstream, IBaseFilter * filter_downstream);

+/**
+ * Creates a filter with the specified CLSID and connects it to the specified
+ * upstream filter.
+ * @return S_OK if filter was created successfully, otherwise an error
+ */
 HRESULT gst_bdasrc_load_filter (GstBdaSrc * src, ICreateDevEnum * sys_dev_enum,
     REFCLSID clsid, IBaseFilter * upstream_filter,
     IBaseFilter ** downstream_filter);

+/**
+ * Creates a transport stream capture filter and connects it to our
+ * GstBdaGrabber.
+ * @return TRUE if capture filter was created successfully
+ */
 BOOL gst_bdasrc_create_ts_capture (GstBdaSrc * bda_src,
     ICreateDevEnum * sys_dev_enum, IBaseFilterPtr & ts_capture);


vdec: improve H.263 args

vdec: improve H.263 args

Signed-off-by: Juha Alanen <8ab7f425f2cbc5dd90719519dddbb1f53425a476@nokia.com>

--- gstdspvdec.c
+++ gstdspvdec.c
@@ -36,6 +36,7 @@
 enum {
 	GSTDSP_MPEG4VDEC,
 	GSTDSP_H264DEC,
+	GSTDSP_H263DEC,
 };

 static GstElementClass *parent_class;
@@ -159,6 +160,9 @@
 		.preroll = 0,
 		.display_width = 0,
 	};
+
+	if (base->alg == GSTDSP_H263DEC)
+		args.profile = 8;

 	struct foo_data *cb_data;

@@ -268,6 +272,7 @@

 	switch (base->alg) {
 		case GSTDSP_MPEG4VDEC:
+		case GSTDSP_H263DEC:
 			alg_uuid = &mp4v_dec_uuid;
 			alg_fn = "mp4vdec_sn.dll64P";
 			break;
@@ -302,6 +307,7 @@

 		switch (base->alg) {
 			case GSTDSP_MPEG4VDEC:
+			case GSTDSP_H263DEC:
 				if (base->width * base->height > 640 * 480)
 					attrs.profile_id = 4;
 				else if (base->width * base->height > 352 * 288)
@@ -385,6 +391,8 @@
 	name = gst_structure_get_name(in_struc);
 	if (strcmp(name, "video/x-h264") == 0)
 		base->alg = GSTDSP_H264DEC;
+	else if (strcmp(name, "video/x-h263") == 0)
+		base->alg = GSTDSP_H263DEC;
 	else
 		base->alg = GSTDSP_MPEG4VDEC;


dtlsdec: Send stream start event before caps

Since Gstreamer 1.2.3 update stream start is required before caps event

Change-Id: I3c5d2628b69f4e8ff56bc5276c9582625a60bc65

--- gstdtlsdec.c
+++ gstdtlsdec.c
@@ -158,6 +158,22 @@

     if (caps) {
       GstQuery *alloc_query;
+      gchar *stream_id;
+
+      stream_id = gst_pad_get_stream_id (base->srcpad);
+
+      if (stream_id == NULL) {
+        stream_id = gst_pad_get_stream_id (base->sinkpad);
+
+        if (stream_id == NULL) {
+          stream_id = gst_pad_create_stream_id (base->srcpad,
+                                                GST_ELEMENT (base), NULL);
+        }
+
+        gst_pad_push_event (base->srcpad, gst_event_new_stream_start(stream_id));
+      }
+
+      g_free (stream_id);

       if (!gst_pad_set_caps (base->srcpad, caps)) {
         gst_caps_unref (caps);


revised the treatment of strings in initialisations

--- lang/cem/cemcom/ival.c
+++ lang/cem/cemcom/ival.c
@@ -514,16 +514,23 @@
 	}
 	else {
 		arith dim = tp->tp_size / tp->tp_up->tp_size;
-
+		extern char options[];
+
+		if (length > dim) {
+			if (options['R'])
+				too_many_initialisers(ex);
+			else { /* don't take the null byte into account */
+				if (length > dim + 1)
+					expr_warning(ex,
+						"too many initialisers");
+				length = dim;
+			}
+		}
 		ntopad = align(dim, word_align) - length;
-		if (length > dim)
-			expr_error(ex,
-				"too many characters in initialiser string");
 	}
 	/* throw out the characters of the already prepared string	*/
-	do
+	while (length-- > 0)
 		C_con_ucon(long2str((long)*s++ & 0xFF, 10), (arith)1);
-	while (--length > 0);
 	/* pad the allocated memory (the alignment has been calculated)	*/
 	while (ntopad-- > 0)
 		con_nullbyte();


Update Ring VM - Threads Support - Better Code (Stop the Main Thread until we prepare the child thread for execution - Then Continue the Main Thread to run them together)

--- language/src/ring_vm.c
+++ language/src/ring_vm.c
@@ -1361,6 +1361,7 @@
 	pState->pVM->pFuncMutexDestroy = pVM->pFuncMutexDestroy ;
 	pState->pVM->pFuncMutexLock = pVM->pFuncMutexLock ;
 	pState->pVM->pFuncMutexUnlock = pVM->pFuncMutexUnlock ;
+	pVM->lStopThisThread = 1 ;
 	/* Share the global scope between threads */
 	pItem = pState->pVM->pMem->pFirst->pValue ;
 	pState->pVM->pMem->pFirst->pValue = pVM->pMem->pFirst->pValue ;
@@ -1401,12 +1402,15 @@
 	ring_vm_loadcode(pState->pVM);
 	/* Avoid the call to the main function */
 	pState->pVM->nCallMainFunction = 1 ;
+	pVM->lStopThisThread = 0 ;
 	ring_vm_mutexunlock(pVM);
 	/* Run the code */
 	ring_state_runcode(pState,cStr);
 	/* Return Memory Pool Items to the Main Thread */
 	ring_vm_mutexlock(pVM);
+	pVM->lStopThisThread = 1 ;
 	ring_poolmanager_deleteblockfromsubthread(pState,pVM->pRingState);
+	pVM->lStopThisThread = 0 ;
 	ring_vm_mutexunlock(pVM);
 	/* Delete Code List */
 	ring_list_delete_gc(pState,pState->pVM->pCode);


fix bond addition probability

fix bond addition probability

--- hoomd/hpmc/UpdaterClusters.h
+++ hoomd/hpmc/UpdaterClusters.h
@@ -965,17 +965,19 @@
                     unsigned int i = it_j->first.first;
                     unsigned int j = it_j->first.second;

-                    std::pair<unsigned int, unsigned int> p;
-
                     // consider each pair once
                     if (i >= j) continue;
+
+                    auto p = std::make_pair(i,j);

                     // add to energy
                     auto it = delta_U.find(p);
                     if (it != delta_U.end())
                         delU += it->second;

-                    // store new interaction energy
+                    // store new interaction energy for both permutations
+                    delta_U.insert(std::make_pair(p,delU));
+                    p = std::make_pair(j,i);
                     delta_U.insert(std::make_pair(p,delU));
                     }
                 }
@@ -988,13 +990,8 @@
                     unsigned int i = it_j->first.first;
                     unsigned int j = it_j->first.second;

-                    std::pair<unsigned int, unsigned int> p;
-
-                    // consider each unique pair
-                    if (i < j)
-                        p = std::make_pair(i,j);
-                    else
-                        p = std::make_pair(j,i);
+                    // consider each pair uniquely
+                    auto p = std::make_pair(i,j);

                     // add to energy
                     auto it = delta_U.find(p);