Cleanup

Cleanup

--- src/netinet/sctp_usrreq.c
+++ src/netinet/sctp_usrreq.c
@@ -1751,7 +1751,7 @@
                        size_t limit,
                        struct sockaddr *addr)
 {
-	size_t size = 0;
+	size_t size;
 #ifdef SCTP_MVRF
 	uint32_t id;
 #endif
@@ -1763,6 +1763,7 @@
  * in more than one VRF.
  */
 	/* fill up addresses for all VRFs on the endpoint */
+	size = 0;
 	for (id = 0; (id < inp->num_vrfs) && (size < limit); id++) {
 		size += sctp_fill_up_addresses_vrf(inp, stcb, limit, addr,
 		                                   inp->m_vrf_ids[id]);
@@ -1777,17 +1778,17 @@
 	return (size);
 }

-static int
-sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id)
+static size_t
+sctp_max_size_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id)
 {
-	int cnt = 0;
-	struct sctp_vrf *vrf = NULL;
+	struct sctp_vrf *vrf;
+	size_t size;

 	/*
-	 * In both sub-set bound an bound_all cases we return the MAXIMUM
-	 * number of addresses that you COULD get. In reality the sub-set
-	 * bound may have an exclusion list for a given TCB OR in the
-	 * bound-all case a TCB may NOT include the loopback or other
+	 * In both sub-set bound an bound_all cases we return the size of
+	 * the maximum number of addresses that you could get. In reality
+	 * the sub-set bound may have an exclusion list for a given TCB or
+	 * in the bound-all case a TCB may NOT include the loopback or other
 	 * addresses as well.
 	 */
 	SCTP_IPI_ADDR_LOCK_ASSERT();
@@ -1795,6 +1796,7 @@
 	if (vrf == NULL) {
 		return (0);
 	}
+	size = 0;
 	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
 		struct sctp_ifn *sctp_ifn;
 		struct sctp_ifa *sctp_ifa;
@@ -1807,22 +1809,22 @@
 				case AF_INET:
 #ifdef INET6
 					if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4))
-						cnt += sizeof(struct sockaddr_in6);
+						size += sizeof(struct sockaddr_in6);
 					else
-						cnt += sizeof(struct sockaddr_in);
+						size += sizeof(struct sockaddr_in);
 #else
-					cnt += sizeof(struct sockaddr_in);
+					size += sizeof(struct sockaddr_in);
 #endif
 					break;
 #endif
 #ifdef INET6
 				case AF_INET6:
-					cnt += sizeof(struct sockaddr_in6);
+					size += sizeof(struct sockaddr_in6);
 					break;
 #endif
 #if defined(__Userspace__)
 				case AF_CONN:
-					cnt += sizeof(struct sockaddr_conn);
+					size += sizeof(struct sockaddr_conn);
 					break;
 #endif
 				default:
@@ -1839,22 +1841,22 @@
 			case AF_INET:
 #ifdef INET6
 				if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4))
-					cnt += sizeof(struct sockaddr_in6);
+					size += sizeof(struct sockaddr_in6);
 				else
-					cnt += sizeof(struct sockaddr_in);
+					size += sizeof(struct sockaddr_in);
 #else
-				cnt += sizeof(struct sockaddr_in);
+				size += sizeof(struct sockaddr_in);
 #endif
 				break;
 #endif
 #ifdef INET6
 			case AF_INET6:
-				cnt += sizeof(struct sockaddr_in6);
+				size += sizeof(struct sockaddr_in6);
 				break;
 #endif
 #if defined(__Userspace__)
 			case AF_CONN:
-				cnt += sizeof(struct sockaddr_conn);
+				size += sizeof(struct sockaddr_conn);
 				break;
 #endif
 			default:
@@ -1862,13 +1864,13 @@
 			}
 		}
 	}
-	return (cnt);
+	return (size);
 }

-static int
-sctp_count_max_addresses(struct sctp_inpcb *inp)
+static size_t
+sctp_max_size_addresses(struct sctp_inpcb *inp)
 {
-	int cnt = 0;
+	size_t size;
 #ifdef SCTP_MVRF
 	int id;
 #endif
@@ -1879,16 +1881,17 @@
  * FIX ME: ?? this WILL count duplicate addresses if they appear
  * in more than one VRF.
  */
-	/* count addresses for all VRFs on the endpoint */
+	/* Maximum size of all addresses for all VRFs on the endpoint */
+	size = 0;
 	for (id = 0; id < inp->num_vrfs; id++) {
-		cnt += sctp_count_max_addresses_vrf(inp, inp->m_vrf_ids[id]);
+		size += sctp_max_size_addresses_vrf(inp, inp->m_vrf_ids[id]);
 	}
 #else
-	/* count addresses for the endpoint's default VRF */
-	cnt = sctp_count_max_addresses_vrf(inp, inp->def_vrf_id);
+	/* Maximum size of all addresses for the endpoint's default VRF */
+	size = sctp_max_size_addresses_vrf(inp, inp->def_vrf_id);
 #endif
 	SCTP_IPI_ADDR_RUNLOCK();
-	return (cnt);
+	return (size);
 }

 static int
@@ -2729,7 +2732,7 @@

 		SCTP_CHECK_AND_CAST(value, optval, uint32_t, *optsize);
 		SCTP_INP_RLOCK(inp);
-		*value = sctp_count_max_addresses(inp);
+		*value = (uint32_t)sctp_max_size_addresses(inp);
 		SCTP_INP_RUNLOCK(inp);
 		*optsize = sizeof(uint32_t);
 		break;
@@ -2737,14 +2740,14 @@
 	case SCTP_GET_REMOTE_ADDR_SIZE:
 	{
 		uint32_t *value;
+		struct sctp_nets *net;
 		size_t size;
-		struct sctp_nets *net;

 		SCTP_CHECK_AND_CAST(value, optval, uint32_t, *optsize);
 		/* FIXME MT: change to sctp_assoc_value? */
-		SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t) *value);
-
-		if (stcb) {
+		SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t)*value);
+
+		if (stcb != NULL) {
 			size = 0;
 			/* Count the sizes */
 			TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
@@ -2777,7 +2780,7 @@
 				}
 			}
 			SCTP_TCB_UNLOCK(stcb);
-			*value = (uint32_t) size;
+			*value = (uint32_t)size;
 			*optsize = sizeof(uint32_t);
 		} else {
 			SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTCONN);
@@ -2799,7 +2802,7 @@
 		SCTP_CHECK_AND_CAST(saddr, optval, struct sctp_getaddresses, *optsize);
 		SCTP_FIND_STCB(inp, stcb, saddr->sget_assoc_id);

-		if (stcb) {
+		if (stcb != NULL) {
 			left = *optsize - offsetof(struct sctp_getaddresses, addr);
 			*optsize = offsetof(struct sctp_getaddresses, addr);
 			addr = &saddr->addr[0].sa;
@@ -2875,7 +2878,7 @@

 		limit = *optsize - offsetof(struct sctp_getaddresses, addr);
 		actual = sctp_fill_up_addresses(inp, stcb, limit, &saddr->addr[0].sa);
-		if (stcb) {
+		if (stcb != NULL) {
 			SCTP_TCB_UNLOCK(stcb);
 		}
 		*optsize = offsetof(struct sctp_getaddresses, addr) + actual;


Added check for results in example selectors_low_level https://github.com/lexborisov/Modest/issues/5

--- examples/selectors/selectors_low_level.c
+++ examples/selectors/selectors_low_level.c
@@ -93,12 +93,19 @@
     mycss_selectors_serialization_list(mycss_entry_selectors(css_entry), list, serialization_callback, NULL);
     fprintf(stdout, "\n");

-    printf("\nFound result:\n");
-    for(size_t i = 0; i < collection->length; i++) {
-        fprintf(stdout, "\t");
-        myhtml_tree_print_node(html_tree, collection->list[i], stdout);
+    if(collection) {
+        printf("\nFound result:\n");
+
+        for(size_t i = 0; i < collection->length; i++) {
+            fprintf(stdout, "\t");
+            myhtml_tree_print_node(html_tree, collection->list[i], stdout);
+        }
+
+        fprintf(stdout, "\n");
     }
-    fprintf(stdout, "\n");
+    else {
+        printf("\nFound result: empty\n");
+    }

     // destroy all
     mycss_selectors_list_destroy(mycss_entry_selectors(css_entry), list, true);


Some minor refactoring of our file manager [ci skip].

--- src/plugins/miscellaneous/Core/src/filemanager.h
+++ src/plugins/miscellaneous/Core/src/filemanager.h
@@ -116,7 +116,6 @@
     bool isModified(const QString &pFileName) const;
     bool isNewOrModified(const QString &pFileName) const;

-    void setNew(const QString &pFileName, const bool &pNew);
     void setModified(const QString &pFileName, const bool &pModified);

     bool isReadable(const QString &pFileName) const;


handle other errors for bad send

handle other errors for bad send

--- src/ngx_http_zmq_module.c
+++ src/ngx_http_zmq_module.c
@@ -141,6 +141,16 @@
   return ngx_http_send_header(r);
 }

+static void zmq_err_reply(ngx_http_request_t *r, unsigned char ** string)
+{
+  r->headers_out.status = NGX_HTTP_BAD_GATEWAY;
+  r->header_only = 0;
+  r->headers_out.content_length_n = strlen(zmq_strerror(zmq_errno()));
+  ngx_http_send_header(r);
+  *string = ngx_pcalloc(r->pool, strlen(zmq_strerror(zmq_errno())));
+  ngx_memcpy(*string, zmq_strerror(zmq_errno()), strlen(zmq_strerror(zmq_errno())));
+}
+
 /* Module Handler
 	ngx_http__handler
 */
@@ -177,6 +187,7 @@
     ngx_memcpy(it, c1->buf->pos, (c1->buf->last - c1->buf->pos));
     it += (c1->buf->last - c1->buf->pos);
   }
+
   /* ----------- ZMQ LOOPY THING -------------- */
   conn* con = get_conn(zmq_config->m_cpool);
   void* sock = con->m_sock;
@@ -185,60 +196,60 @@
   do
   {
     zrc = zmq_send(sock, input , (int)r->headers_in.content_length_n, ZMQ_NOBLOCK);
-  } while (to_ms(clock() - start) < to && zmq_errno() == EAGAIN);
-  if (zrc == -1 && zmq_errno() == EAGAIN)
+  } while (to_ms(clock() - start) < to && zrc == -1 && zmq_errno() == EAGAIN);
+
+  if (zrc == -1) /* send errored for some reason */
   {
     free_conn(&con);
-    return header_err(r, NGX_HTTP_BAD_GATEWAY);
-  }
-  zmq_msg_init(&msg);
-  do
-  {
-    zrc = zmq_msg_recv(&msg, sock, ZMQ_NOBLOCK);
-  } while (to_ms(clock() - start) < to && zmq_errno() == EAGAIN);
-  if (zrc == -1 && zmq_errno() == EAGAIN)
-  {
     if (zmq_errno() == EAGAIN)
+      return header_err(r, NGX_HTTP_BAD_GATEWAY);
+    else
+      zmq_err_reply(r, &string);
+  }
+  else
+  {
+    zmq_msg_init(&msg);
+    do
+    {
+      zrc = zmq_msg_recv(&msg, sock, ZMQ_NOBLOCK);
+    } while (to_ms(clock() - start) < to && zmq_errno() == EAGAIN);
+    if (zrc == -1 && zmq_errno() == EAGAIN)
     {
       free_conn(&con);
-      return header_err(r, NGX_HTTP_GATEWAY_TIME_OUT);
+      if (zmq_errno() == EAGAIN)
+	return header_err(r, NGX_HTTP_GATEWAY_TIME_OUT);
+      else
+        zmq_err_reply(r, &string);
     }
-
-    free_conn(&con);
-    r->headers_out.status = NGX_HTTP_BAD_GATEWAY;
-    r->header_only = 0;
-    r->headers_out.content_length_n = strlen(zmq_strerror(zmq_errno()));
-    ngx_http_send_header(r);
-    string = ngx_pcalloc(r->pool, strlen(zmq_strerror(zmq_errno())));
-    ngx_memcpy(string, zmq_strerror(zmq_errno()), strlen(zmq_strerror(zmq_errno())));
-  }
-  else
-  {
-    mlen = zmq_msg_size(&msg);
-    string = ngx_pcalloc(r->pool, mlen+1);
-    ngx_memcpy(string, zmq_msg_data(&msg), mlen);
-
-    zmq_msg_close(&msg);
-    rel_conn(zmq_config->m_cpool, &con);
-    /* ----------- END ZMQ LOOPY THING -----------*/
-
-  /* --------------- END MAGIC ------------------------- */
-
-    rc = ngx_http_discard_request_body(r);
-
-    r->headers_out.status = NGX_HTTP_OK;
-    r->headers_out.content_length_n = mlen;
-    r->headers_out.content_type.len = sizeof("text/html") - 1;
-    r->headers_out.content_type.data = (u_char *) "text/html";
-
-    if (r->method == NGX_HTTP_HEAD)
-    {
-	rc = ngx_http_send_header(r);
-	if (rc == NGX_ERROR || rc > NGX_OK || r->header_only)
-	    return rc;
+    else
+    {
+      rel_conn(zmq_config->m_cpool, &con);
+
+      mlen = zmq_msg_size(&msg);
+      string = ngx_pcalloc(r->pool, mlen+1);
+      ngx_memcpy(string, zmq_msg_data(&msg), mlen);
+
+      zmq_msg_close(&msg);
+
+      /* ----------- END ZMQ LOOPY THING -----------*/
+
+    /* --------------- END MAGIC ------------------------- */
+
+      rc = ngx_http_discard_request_body(r);
+
+      r->headers_out.status = NGX_HTTP_OK;
+      r->headers_out.content_length_n = mlen;
+      r->headers_out.content_type.len = sizeof("text/plain") - 1;
+      r->headers_out.content_type.data = (u_char *) "text/plain";
+
+      if (r->method == NGX_HTTP_HEAD)
+      {
+	  rc = ngx_http_send_header(r);
+	  if (rc == NGX_ERROR || rc > NGX_OK || r->header_only)
+	      return rc;
+      }
     }
   }
-
   b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));

   if (b == NULL)


Space

Space

--- src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.c
+++ src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.c
@@ -1372,7 +1372,7 @@
                     ribs = r[i + b] << b;
                     cmp = r[i] + ribs;
                     if (cmp <= 15) {
-                        r[i] = cmp;
+                        r[i] = cmp;
                         r[i + b] = 0;
                     } else {
                         cmp = r[i] - ribs;


documentation updates.

documentation updates.

removed some print support function declarations; made static to rbt.c.

--- lib/dns/include/dns/rbt.h
+++ lib/dns/include/dns/rbt.h
@@ -72,6 +72,35 @@

 typedef struct dns_rbtnodechain dns_rbtnodechain_t;

+dns_result_t dns_rbt_create(isc_mem_t *mctx, void (*deleter)(void *, void *),
+			    void *deleter_arg, dns_rbt_t **rbtp);
+/*
+ * Initialize a red-black tree of trees.
+ *
+ * Notes:
+ *	The deleter argument, if non-null, points to a function that is
+ *	responsible for cleaning up any memory associated with the data
+ *	pointer of a node when the node is deleted.  It is passed the
+ *	deleted node's data pointer as its first argument and deleter_arg
+ *	as its second argument.
+ *
+ * Requires:
+ * 	mctx is a pointer to a valid memory context.
+ *	rbtp != NULL && *rbtp == NULL
+ *	arg == NULL iff deleter == NULL
+ *
+ * Ensures:
+ *	If result is DNS_R_SUCCESS:
+ *		*rbtp points to a valid red-black tree manager
+ *
+ *	If result is failure:
+ *		*rbtp does not point to a valid red-black tree manager.
+ *
+ * Returns:
+ *	DNS_R_SUCCESS	Success
+ *	DNS_R_NOMEMORY	Resource limit: Out of Memory
+ */
+
 dns_result_t dns_rbt_addname(dns_rbt_t *rbt, dns_name_t *name, void *data);
 /*
  * Add 'name' to the tree of trees, associated with 'data'.
@@ -79,34 +108,172 @@
  * Notes:
  *	'data' is never required to be non-NULL, but specifying it
  *	when the name is added is faster than searching for 'name'
- *	again and then setting the data pointer.
- *
- * Requires:
- *	rbt is a valid rbt structure.
- *	dns_name_isabsolute(name) == TRUE
- *
- * Ensures:
- *
+ *	again and then setting the data pointer.  The lack of a data pointer
+ *	for a node also has other ramifications regarding whether
+ *	dns_rbt_findname considers a node to exist, or dns_rbt_deletename
+ *	joins nodes.
+ *
+ * Requires:
+ *	rbt is a valid rbt manager.
+ *	dns_name_isabsolute(name) == TRUE
+ *
+ * Ensures:
  *	'name' is not altered in any way.
  *
+ *	Any external references to nodes in the tree are unaffected by
+ *	node splits that are necessary to insert the new name.
+ *
  *	If result is DNS_R_SUCCESS:
  *		'name' is findable in the red/black tree of trees in O(log N).
  *
- * Returns:
- *	Success
- *	Resource Limit: Out of Memory
- */
+ *		The data pointer of the node for 'name' is set to 'data'.
+ *
+ *	If result is DNS_R_EXISTS:
+ *		The tree of trees is unaltered.
+ *
+ *	If result is DNS_R_NOMEMORY:
+ *		No guarantees.
+ *
+ * Returns:
+ *	DNS_R_SUCCESS	Success
+ *	DNS_R_EXISTS	The name already exists with associated data.
+ *	DNS_R_NOMEMORY	Resource Limit: Out of Memory
+ */
+

 dns_result_t dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name,
 			    dns_rbtnode_t **nodep);
-/*
- * Just like dns_rbt_addname, but return the address of the added node,
- * even when the node already existed.
+
+/*
+ * Just like dns_rbt_addname, but returns the address of the node.
  *
  * Requires:
  *	rbt is a valid rbt structure.
  *	dns_name_isabsolute(name) == TRUE
  *	nodep != NULL && *nodep == NULL
+ *
+ * Ensures:
+ *	'name' is not altered in any way.
+ *
+ *	Any external references to nodes in the tree are unaffected by
+ *	node splits that are necessary to insert the new name.
+ *
+ *	If result is DNS_R_SUCCESS:
+ *		'name' is findable in the red/black tree of trees in O(log N).
+ *
+ *		*nodep is the node that was added for 'name'.
+ *
+ *	If result is DNS_R_EXISTS:
+ *		The tree of trees is unaltered.
+ *
+ *		*nodep is the existing node for 'name'.
+ *
+ *	If result is DNS_R_NOMEMORY:
+ *		No guarantees.
+ *
+ * Returns:
+ *	DNS_R_SUCCESS	Success
+ *	DNS_R_EXISTS	The name already exists, possibly without data.
+ *	DNS_R_NOMEMORY	Resource Limit: Out of Memory
+ */
+
+dns_result_t dns_rbt_findname(dns_rbt_t *rbt, dns_name_t *name, void **data);
+/*
+ * Get the data pointer associated with 'name'.
+ *
+ * Notes:
+ *	A node that has no data is considered not to exist for this function.
+ *
+ * Requires:
+ *	rbt is a valid rbt manager.
+ *	dns_name_isabsolute(name) == TRUE
+ *	data != NULL && *data == NULL
+ *
+ * Ensures:
+ *	'name' and the tree are not altered in any way.
+ *
+ *	If result is DNS_R_SUCCESS:
+ *		*data is the data associated with 'name'.
+ *
+ *	If result is DNS_R_PARTIALMATCH:
+ *		*data is the data associated with the deepest superdomain
+ * 		of 'name' which has data.
+ *
+ *	If result is DNS_R_NOTFOUND:
+ *		Neither the name nor a superdomain was found with data.
+ *
+ * Returns:
+ *	DNS_R_SUCCESS		Success
+ *	DNS_R_PARTIALMATCH	Superdomain found with data
+ *	DNS_R_NOTFOUND		No match
+ */
+
+dns_result_t dns_rbt_findnode(dns_rbt_t *rbt, dns_name_t *name,
+			       dns_rbtnode_t **node,
+			       dns_rbtnodechain_t *chain);
+/*
+ * Find the node for 'name'.
+ *
+ * Notes:
+ *	It is _not_ required that the node associated with 'name'
+ *	has a non-NULL data pointer for an exact match.  A partial
+ *	match must have associated data; this requirement could be
+ *	lifted by adding another parameter to the function, or perhaps
+ *	by using the chain argument (see "If result is DNS_R_PARTIALMATCH").
+ *
+ *	If the chain parameter is non-NULL, then the path to the found
+ *	node is maintained.  Within the structure, 'ancestors' will point
+ *	to each successive node encountered in the search, with the root
+ *	of each level searched indicated by a NULL.  ancestor_count
+ *	indicates how many node pointers are in the ancestor list.  The
+ *	'levels' member of the structure holds the root node of each level
+ *	except the first; it corresponds with the NULL pointers in
+ *	'ancestors' (except the first).  That is, for the [n+1]'th NULL
+ *	'ancestors' pointer, the [n]'th 'levels' pointer is the node with
+ *	the down pointer to the next level.  That node is not stored
+ *	at all in the 'ancestors' list.
+ *
+ *	If any space was allocated to hold 'ancestors' in the chain,
+ *	the 'ancestor_maxitems' member will indicate how many ancestors
+ *	could have been stored; the amount to be freed from the rbt->mctx
+ *	is ancestor_maxitems * sizeof(dns_rbtnode_t *).
+ *
+ * Requires:
+ *	rbt is a valid rbt manager.
+ *	dns_name_isabsolute(name) == TRUE
+ *	node != NULL && *NULL == NULL
+ *
+ * Ensures:
+ *	'name' and the tree are not altered in any way.
+ *
+ *	If result is DNS_R_SUCCESS:
+ *		*node is the terminal node for 'name'.
+ *
+ * 	If result is DNS_R_PARTIALMATCH:
+ *		*node is the data associated with the deepest superdomain
+ * 		of 'name' which has data.
+ *
+ *		chain does not necessarily terminate at *node; it continues
+ *		as deep as the search went.  levels[level_count - 1] is the
+ *		deepest superdomain, with or without data.
+ *
+ *	If result is DNS_R_NOTFOUND:
+ *		Neither the name nore a superdomain was found.
+ *
+ *		If the chain's level_count > 0, levels[level_count - 1]
+ *		is the deepest partial match.
+ *
+ *	If result is DNS_R_NOMEMORY:
+ *		The function could not complete because memory could not
+ *		be allocated to maintain the chain.  However, it
+ *		is possible that some memory was allocated;
+ *		the chain's ancestor_maxitems will be non-zero if so.
+ *
+ * Returns:
+ *	DNS_R_SUCCESS		Success
+ *	DNS_R_PARTIALMATCH	Superdomain found with data
+ *	DNS_R_NOTFOUND		No match, or superdomain with no data
+ *	DNS_R_NOMEMORY		Resource Limit: Out of Memory building chain
  */

 dns_result_t dns_rbt_deletename(dns_rbt_t *rbt, dns_name_t *name,
@@ -115,21 +282,35 @@
  * Delete 'name' from the tree of trees.
  *
  * Notes:
- *	When 'name' is removed, if recurse is TRUE then all of its
+ *	When 'name' is removed, if recurse is ISC_TRUE then all of its
  *      subnames are removed too.
  *
  * Requires:
- *	dns_name_isabsolute(name) == TRUE
- *
- * Ensures:
- *
+ *	rbt is a valid rbt manager.
+ *	dns_name_isabsolute(name) == TRUE
+ *
+ * Ensures:
  *	'name' is not altered in any way.
  *
- *	'name' does not appear in the tree.
- *
- * Returns:
- *	Success
- *	Bad Form: Not Found
+ *	Does NOT ensure that any external references to nodes in the tree
+ *	are unaffected by node joins.
+ *
+ *	If result is DNS_R_SUCCESS:
+ *		'name' does not appear in the tree with data; however,
+ *		the node for the name might still exist which can be
+ *		found with dns_rbt_findnode (but not dns_rbt_findname).
+ *
+ *	If result is DNS_R_NOTFOUND:
+ *		'name' does not appear in the tree with data, because
+ *		it did not appear in the tree before the function was called.
+ *
+ *	If result is DNS_R_NOMEMORY:
+ *		'name' remains in the tree, if it was there to begin with.
+ *
+ * Returns:
+ *	DNS_R_SUCCESS	Success
+ *	DNS_R_NOTFOUND	No match
+ *	DNS_R_NOMEMORY	Resource Limit: Out of Memory
  */

 void dns_rbt_namefromnode(dns_rbtnode_t *node, dns_name_t *name);
@@ -137,40 +318,50 @@
  * Convert the sequence of labels stored at 'node' into a 'name'.
  *
  * Notes:
+ *	This function does not return the full name, from the root, but
+ *	just the labels at the indicated node.
+ *
  *	The name data pointed to by 'name' is the information stored
  *	in the node, not a copy.  Altering the data at this pointer
  *	will likely cause grief.
  *
- */
-
-dns_result_t dns_rbt_findnode(dns_rbt_t *rbt, dns_name_t *name,
-			       dns_rbtnode_t **node,
-			       dns_rbtnodechain_t *chain);
-/*
- * Find the node for 'name'.
- *
- * Notes:
- *	It is _not_ required that the node associated with 'name'
- *	has a non-NULL data pointer.
- */
-
-dns_result_t dns_rbt_findname(dns_rbt_t *rbt, dns_name_t *name, void **data);
-/*
- * Return the data pointer associated with 'name'.
- *
- * Notes:
- *	Returns NULL if either the name could not be found, or
- *	if the name is found but has a NULL data pointer.
- */
-
-void dns_rbt_indent(int depth);
-void dns_rbt_printnodename(dns_rbtnode_t *node);
-void dns_rbt_printtree(dns_rbtnode_t *root, dns_rbtnode_t *parent, int depth);
+ * Requires:
+ *	name->offsets == NULL
+ *
+ * Ensures:
+ *	'name' is DNS_NAMEATTR_READONLY.
+ *
+ *	'name' will point directly to the labels stored after the
+ *	dns_rbtnode_t struct.
+ *
+ *	'name' will have offsets that also point to the information stored
+ *	as part of the node.
+ */
+
+void dns_rbt_destroy(dns_rbt_t **rbtp);
+/*
+ * Stop working with a red-black tree of trees.
+ *
+ * Requires:
+ * 	*rbt is a valid rbt manager.
+ *
+ * Ensures:
+ *	All space allocated by the RBT library has been returned.
+ *
+ *	*rbt is invalidated as an rbt manager.
+ */
+
 void dns_rbt_printall(dns_rbt_t *rbt);
-
-dns_result_t dns_rbt_create(isc_mem_t *mctx, void (*deleter)(void *, void *),
-			    void *arg, dns_rbt_t **rbtp);
-void dns_rbt_destroy(dns_rbt_t **rbtp);
+/*
+ * Print an ASCII representation of the internal structure of the red-black
+ * tree of trees.
+ *
+ * Notes:
+ *	The name stored at each node, along with the node's color, is printed.
+ *	Then the down pointer, left and right pointers are displayed
+ *	recursively in turn.  NULL down pointers are silently omitted;
+ *	NULL left and right pointers are printed.
+ */

 ISC_LANG_ENDDECLS


android/pan: Free device after sending diconnected notification

--- android/pan.c
+++ android/pan.c
@@ -103,6 +103,8 @@

 	ipc_send_notif(HAL_SERVICE_ID_PAN, HAL_EV_PAN_CONN_STATE, sizeof(ev),
 									&ev);
+	if (dev->conn_state == HAL_PAN_STATE_DISCONNECTED)
+		pan_device_free(dev);
 }

 static void bt_pan_notify_ctrl_state(struct pan_device *dev, uint8_t state)
@@ -131,7 +133,6 @@
 	bnep_if_down(dev->iface);
 	bnep_conndel(&dev->dst);
 	bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
-	pan_device_free(dev);

 	return FALSE;
 }
@@ -146,7 +147,6 @@
 		error("bnep connect req failed: %s", strerror(-err));
 		bnep_conndel(&dev->dst);
 		bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
-		pan_device_free(dev);
 		return;
 	}

@@ -190,7 +190,6 @@

 fail:
 	bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
-	pan_device_free(dev);
 }

 static void bt_pan_connect(const void *buf, uint16_t len)
@@ -284,7 +283,6 @@
 	}

 	dev = l->data;
-
 	if (dev->watch) {
 		g_source_remove(dev->watch);
 		dev->watch = 0;
@@ -292,10 +290,7 @@

 	bnep_if_down(dev->iface);
 	bnep_conndel(&dst);
-
 	bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
-	pan_device_free(dev);
-
 	status = HAL_STATUS_SUCCESS;

 failed:


execute async. refs gh-168

execute async. refs gh-168

--- src/sql/midgard_sql_content_manager_job_create.c
+++ src/sql/midgard_sql_content_manager_job_create.c
@@ -23,6 +23,7 @@
 #include "../midgard_executable.h"
 #include "../midgard_job.h"
 #include "../midgard_object.h"
+#include "../midgard_core_object.h"

 static void
 _midgard_sql_content_manager_job_create_executable_iface_execute (MidgardExecutable *iface, GError **error)
@@ -61,13 +62,43 @@
 	midgard_executable_execution_end (iface);
 }

+static gboolean
+execution_end_func (gpointer data)
+{
+	MidgardExecutable *executable = (MidgardExecutable *) data;
+	g_signal_emit_by_name (executable, "execution-end", 0);
+	g_object_unref (executable);
+	return FALSE;
+}
+
 static void
 _midgard_sql_content_manager_job_create_executable_iface_execute_async (MidgardExecutable *iface, GError **error)
 {
-		g_set_error (error,
-				MIDGARD_EXECUTION_ERROR,
-				MIDGARD_EXECUTION_ERROR_INTERNAL,
-				"NOT IMPLEMENTED");
+	GError *err = NULL;
+
+	/* Validate */
+	MidgardValidable *validable = MIDGARD_VALIDABLE (iface);
+	if (!midgard_validable_is_valid (validable)) {
+		midgard_validable_validate (validable, &err);
+		if (err) {
+			g_propagate_error (error, err);
+			return;
+		}
+	}
+
+	/* Get content object, it should be validated already */
+	MidgardContentManagerJob *job = MIDGARD_CONTENT_MANAGER_JOB (iface);
+	MidgardObject *content_object = (MidgardObject *) midgard_content_manager_job_get_content_object (job, &err);
+
+	/* Get connection, it should be validated already */
+	MidgardSqlContentManagerJob *job_sql = MIDGARD_SQL_CONTENT_MANAGER_JOB (iface);
+	MidgardConnection *mgd = midgard_sql_content_manager_job_get_connection (job_sql, NULL);
+
+	/* Create object */
+	gboolean rv =  _midgard_object_create(content_object, NULL, OBJECT_UPDATE_NONE);
+
+	/* signal emission idle */
+	g_idle_add_full (G_PRIORITY_HIGH_IDLE, (GSourceFunc) execution_end_func, g_object_ref (iface), NULL);
 }

 /* GOBJECT ROUTINES */


Make assertions more readable

Make assertions more readable

--- test/default/randombytes.c
+++ test/default/randombytes.c
@@ -32,9 +32,9 @@
     uint32_t     n;

 #ifdef __EMSCRIPTEN__
-    assert(strcmp(randombytes_implementation_name(), "sysrandom"));
+    assert(strcmp(randombytes_implementation_name(), "js") == 0);
 #else
-    assert(strcmp(randombytes_implementation_name(), "js"));
+    assert(strcmp(randombytes_implementation_name(), "sysrandom") == 0);
 #endif
     randombytes(x, 1U);
     do {


キー入力の表示

キー入力の表示

--- bootpack.c
+++ bootpack.c
@@ -122,7 +122,7 @@

   init_screen8(buf_back, binfo->scrnx, binfo->scrny);
   init_mouse_cursor8(buf_mouse, 99); /* 背景色は99 */
-  make_window8(buf_win, 160, 52, "counter");
+  make_window8(buf_win, 160, 52, "window");

   sheet_slide(sht_back, 0, 0);
   mx = (binfo->scrnx - 16) / 2;	/* 画面中央になるように座標計算 */
@@ -143,9 +143,6 @@
   sheet_refresh(sht_back, 0, 0, binfo->scrnx, 48);

   for (;;) {
-    sprintk(s, "%010d", timerctl.count);
-    putfonts8_asc_sht(sht_win, 40, 28, COL8_000000, COL8_C6C6C6, s, 10);
-
     io_cli();
     if (fifo32_status(&fifo) == 0) {
       io_sti();
@@ -153,9 +150,12 @@
       i = fifo32_get(&fifo);
       io_sti();

-      if (256 <= i && i <= 511) {
+      if (256 <= i && i <= 511) { /* キーボード・データ */
 	sprintk(s, "%02X", i - 256);
 	putfonts8_asc_sht(sht_back, 0, 16, COL8_FFFFFF, COL8_008484, s, 2);
+	if (i == 0x1e + 256) {
+	  putfonts8_asc_sht(sht_win, 40, 28, COL8_000000, COL8_C6C6C6, "A", 1);
+	}
       } else if (512 <= i && i <= 767) {
 	if (mouse_decode(&mdec, i - 512) != 0) {
 	  /* データが3バイト揃ったので表示 */
@@ -191,11 +191,9 @@
 	  sheet_slide(sht_mouse, mx, my); /* sheet_refreshを含む */
 	}
       } else if (i == 10) {
-	putfonts8_asc(buf_back, binfo->scrnx, 0, 64, COL8_FFFFFF, "10[sec]");
-	sheet_refresh(sht_back, 0, 64, 56, 80);
+	putfonts8_asc_sht(sht_back, 0, 64, COL8_FFFFFF, COL8_008484, "10[sec]", 7);
       } else if (i == 3) {
-	putfonts8_asc(buf_back, binfo->scrnx, 0, 80, COL8_FFFFFF, "3[sec]");
-	sheet_refresh(sht_back, 0, 80, 56, 96);
+	putfonts8_asc_sht(sht_back, 0, 80, COL8_FFFFFF, COL8_008484, "3[sec]", 6);
       } else if (i == 1) {
 	timer_init(timer3, &fifo, 0); /* 次は0を */
 	boxfill8(buf_back, binfo->scrnx, COL8_FFFFFF, 8, 96, 15, 111);


Use CRYPTO_ctr128_encrypt

Use CRYPTO_ctr128_encrypt

AES_ctr128_encrypt doesn't exist anymore in OpenSSL 1.1

--- haicrypt/hc_openssl_aes.c
+++ haicrypt/hc_openssl_aes.c
@@ -33,6 +33,7 @@
 #include <string.h>
 #include <openssl/evp.h>	/* PKCS5_xxx() */
 #include <openssl/aes.h>	/* AES_xxx() */
+#include <openssl/modes.h>	/* CRYPTO_xxx() */
 #include <openssl/rand.h>
 #include <openssl/err.h>

@@ -264,8 +265,14 @@
 			hcrypt_SetCtrIV((unsigned char *)&pki, ctx->salt, iv);

 			/* Encrypt packet payload in output message buffer */
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+			CRYPTO_ctr128_encrypt(in_data[0].payload, &out_msg[pfx_len],
+				in_data[0].len, aes_key, iv, ctr, &blk_ofs, (block128_f) AES_encrypt);
+#else
 			AES_ctr128_encrypt(in_data[0].payload, &out_msg[pfx_len],
 				in_data[0].len, aes_key, iv, ctr, &blk_ofs);
+#endif
+

 			/* Prepend packet prefix (clear text) in output buffer */
 			memcpy(out_msg, in_data[0].pfx, pfx_len);
@@ -396,8 +403,13 @@
 			hcrypt_SetCtrIV((unsigned char *)&pki, ctx->salt, iv);

 			/* Decrypt message (same as encrypt for CTR mode) */
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+			CRYPTO_ctr128_encrypt(in_data[0].payload, out_txt,
+				in_data[0].len, aes_key, iv, ctr, &blk_ofs, (block128_f) AES_encrypt);
+#else
 			AES_ctr128_encrypt(in_data[0].payload, out_txt,
 				in_data[0].len, aes_key, iv, ctr, &blk_ofs);
+#endif
 			out_len = in_data[0].len;
 			break;
 		}


Unbreak pututxline() on 32-bit architectures.

I forgot to cast the size_t's back to off_t before negating them,
causing all sorts of artifacts where the log files would grow to 2^32 -
197 bytes.

Reported by:	ume

--- lib/libc/gen/pututxline.c
+++ lib/libc/gen/pututxline.c
@@ -87,7 +87,7 @@
 		case DEAD_PROCESS:
 			/* Overwrite when ut_id matches. */
 			if (memcmp(fu->fu_id, fe.fu_id, sizeof fe.fu_id) == 0) {
-				fseeko(fp, -sizeof fe, SEEK_CUR);
+				fseeko(fp, -(off_t)sizeof fe, SEEK_CUR);
 				goto exact;
 			}
 			if (fe.fu_type != DEAD_PROCESS)
@@ -96,7 +96,7 @@
 		default:
 			/* Allow us to overwrite unused records. */
 			if (partial == -1)
-				partial = ftello(fp) - sizeof fe;
+				partial = ftello(fp) - (off_t)sizeof fe;
 			break;
 		}
 	}
@@ -140,7 +140,7 @@
 				fu->fu_tv = fe.fu_tv;

 			/* Terminate session. */
-			fseeko(fp, -sizeof fe, SEEK_CUR);
+			fseeko(fp, -(off_t)sizeof fe, SEEK_CUR);
 			fwrite(fu, sizeof *fu, 1, fp);
 			fclose(fp);
 			return (0);
@@ -181,7 +181,7 @@
 			goto done;

 		/* Found a previous lastlogin entry for this user. */
-		fseeko(fp, -sizeof fe, SEEK_CUR);
+		fseeko(fp, -(off_t)sizeof fe, SEEK_CUR);
 		break;
 	}
 	fwrite(fu, sizeof *fu, 1, fp);


Do not check whether a pointer is NULL, since free(3) already takes care of
this case.

Reviewed by:	ume

--- lib/libc/net/getservent.c
+++ lib/libc/net/getservent.c
@@ -67,10 +67,8 @@
 		sed->fp = NULL;
 	}
 #ifdef YP
-	if (sed->key) {
-		free(sed->key);
-		sed->key = NULL;
-	}
+	free(sed->key);
+	sed->key = NULL;
 #endif
 }

@@ -201,8 +199,7 @@
 	}

 	if (!sed->stepping_yp) {
-		if (sed->key)
-			free(sed->key);
+		free(sed->key);
 		rv = yp_first(sed->yp_domain, "services.byname", &sed->key,
 		    &sed->keylen, &result, &resultlen);
 		if (rv) {


Treat '+' as special only when in compat mode, and simplify
the logic bit.

MFC after:	2 weeks

--- lib/libc/net/getservent.c
+++ lib/libc/net/getservent.c
@@ -315,28 +315,8 @@
 				break;
 			}

-			if (*line=='+') {
-				if (serv_mdata->compat_mode != 0)
-					st->compat_mode_active = 1;
-			} else {
-				if (bufsize <= linesize + _ALIGNBYTES +
-				    sizeof(char *)) {
-					*errnop = ERANGE;
-					rv = NS_RETURN;
-					break;
-				}
-				aliases = (char **)_ALIGN(&buffer[linesize+1]);
-				aliases_size = (buffer + bufsize -
-				    (char *)aliases) / sizeof(char *);
-				if (aliases_size < 1) {
-					*errnop = ERANGE;
-					rv = NS_RETURN;
-					break;
-				}
-
-				memcpy(buffer, line, linesize);
-				buffer[linesize] = '\0';
-			}
+			if (*line=='+' && serv_mdata->compat_mode != 0)
+				st->compat_mode_active = 1;
 		}

 		if (st->compat_mode_active != 0) {
@@ -366,6 +346,23 @@

 			continue;
 		}
+
+		if (bufsize <= linesize + _ALIGNBYTES + sizeof(char *)) {
+			*errnop = ERANGE;
+			rv = NS_RETURN;
+			break;
+		}
+		aliases = (char **)_ALIGN(&buffer[linesize + 1]);
+		aliases_size = (buffer + bufsize -
+		    (char *)aliases) / sizeof(char *);
+		if (aliases_size < 1) {
+			*errnop = ERANGE;
+			rv = NS_RETURN;
+			break;
+		}
+
+		memcpy(buffer, line, linesize);
+		buffer[linesize] = '\0';

 		rv = servent_unpack(buffer, serv, aliases, aliases_size,
 		    errnop);


The previous commit changed the behavior of nsdispatch() in the
case where an /etc/nsswitch.conf file was present, but could not
be opened (e.g. due to permissions).  Previously, the open failure
condition was suppressed, and the built-in defaults were used.  In
revision 1.11, however, propagated the open failure causing all
nsdispatch() invocations to return NS_UNAVAIL, and thus many APIs
including getpwnam and gethostbyname unconditionally failed.

This commit restores the previous behavior.

Pointy hat:	nectar  (+1 for obstinance; ache had to use clue bat)
Reported by:	ache

--- lib/libc/net/nsdispatch.c
+++ lib/libc/net/nsdispatch.c
@@ -343,10 +343,8 @@
 		    goto fin2;
 	}
 	_nsyyin = fopen(path, "r");
-	if (_nsyyin == NULL) {
-		result = errno;
+	if (_nsyyin == NULL)
 		goto fin;
-	}
 	VECTOR_FREE(_nsmap, &_nsmapsize, sizeof(*_nsmap),
 	    (vector_free_elem)ns_dbt_free);
 	VECTOR_FREE(_nsmod, &_nsmodsize, sizeof(*_nsmod),


Remove extra slash from pty slave device name returned by ptsname.

--- lib/libc/stdlib/grantpt.c
+++ lib/libc/stdlib/grantpt.c
@@ -58,7 +58,7 @@

 #define PTM_PREFIX	"pty"	/* pseudo tty master naming convention */
 #define PTS_PREFIX	"tty"	/* pseudo tty slave naming convention */
-#define NEWPTS_PREFIX	"pts/"
+#define NEWPTS_PREFIX	"pts"
 #define PTMX		"ptmx"

 /*


Minor bug in clientimpl_status.c causes
some compilers to complain.

#endif statement had some define following.

* clientimpl_status.c

--- subversion/bindings/java/jni/clientimpl_status.c
+++ subversion/bindings/java/jni/clientimpl_status.c
@@ -264,7 +264,7 @@
                     fprintf(stderr, "apr_hash_next(");
                     SVN_JNI__DEBUG_PTR(index);
                     fprintf(stderr, ")...");
-#endif SVN_JNI__VERBOSE
+#endif

                     /* proceed to the next iteration */
                     apr_hash_next(index);


Simplify code

Simplify code

--- src/appleseed/foundation/utility/alignedvector.h
+++ src/appleseed/foundation/utility/alignedvector.h
@@ -135,15 +135,10 @@
     {
     }

-#if (defined __GNUC__ && defined __GXX_EXPERIMENTAL_CXX0X__) || \
-    (defined _MSC_VER && _MSC_VER >= 1600)
-
     AlignedVector(Base&& rhs)
       : Base(rhs)
     {
     }
-
-#endif
 };

 #undef ALIGNED_VECTOR_BASE


extmod/modbluetooth: Fix handling of optional data/uuid args.

For the following 3 functions, previously the code relied on whether the
arg was passed at all, to make it optional.  Now it allows them to be
explicitly `None` to indicate they are not used:

- gatts_notify(..., [data])
- gattc_discover_services(..., [uuid])
- gattc_discover_characteristics(..., [uuid])

Also ensure that the uuid arguments are actually instances of the uuid
type, and fix handling of the 5th arg in gattc_discover_characteristics().

--- extmod/modbluetooth.c
+++ extmod/modbluetooth.c
@@ -679,7 +679,7 @@
     mp_int_t conn_handle = mp_obj_get_int(args[1]);
     mp_int_t value_handle = mp_obj_get_int(args[2]);

-    if (n_args == 4) {
+    if (n_args == 4 && args[3] != mp_const_none) {
         mp_buffer_info_t bufinfo = {0};
         mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_READ);
         int err = mp_bluetooth_gatts_notify_send(conn_handle, value_handle, bufinfo.buf, bufinfo.len);
@@ -719,7 +719,10 @@
 STATIC mp_obj_t bluetooth_ble_gattc_discover_services(size_t n_args, const mp_obj_t *args) {
     mp_int_t conn_handle = mp_obj_get_int(args[1]);
     mp_obj_bluetooth_uuid_t *uuid = NULL;
-    if (n_args == 3) {
+    if (n_args == 3 && args[2] != mp_const_none) {
+        if (!mp_obj_is_type(args[2], &bluetooth_uuid_type)) {
+            mp_raise_TypeError(MP_ERROR_TEXT("UUID"));
+        }
         uuid = MP_OBJ_TO_PTR(args[2]);
     }
     return bluetooth_handle_errno(mp_bluetooth_gattc_discover_primary_services(conn_handle, uuid));
@@ -731,7 +734,10 @@
     mp_int_t start_handle = mp_obj_get_int(args[2]);
     mp_int_t end_handle = mp_obj_get_int(args[3]);
     mp_obj_bluetooth_uuid_t *uuid = NULL;
-    if (n_args == 3) {
+    if (n_args == 5 && args[4] != mp_const_none) {
+        if (!mp_obj_is_type(args[4], &bluetooth_uuid_type)) {
+            mp_raise_TypeError(MP_ERROR_TEXT("UUID"));
+        }
         uuid = MP_OBJ_TO_PTR(args[4]);
     }
     return bluetooth_handle_errno(mp_bluetooth_gattc_discover_characteristics(conn_handle, start_handle, end_handle, uuid));


minor, if p + f.off_min points to before the string, try the beginning of the string

Signed-off-by: Sebastian Freundt <b09d9bb16bf9b69282010dd0632eda7cd40aa71d@fresse.org>

--- src/date-io.h
+++ src/date-io.h
@@ -359,13 +359,16 @@
 		while (*np++ == *p) {
 			const struct grpatm_payload_s f = *fp++;
 			const char *fmt = f.fmt;
-
-			if (p + f.off_min < str /*|| p + f.off_max > ?*/) {
-				continue;
-			}
-			for (int8_t i = f.off_min; i <= f.off_max; i++) {
-				if ((d = dt_strpd(p + i, fmt, ep)).typ) {
-					p += i;
+			const char *q;
+
+			if (UNLIKELY((p + f.off_min) <= str)) {
+				q = str;
+			} else {
+				q = p + f.off_min;
+			}
+			for (const char *r = p + f.off_max; *q && q <= r; q++) {
+				if ((d = dt_strpd(q, fmt, ep)).typ) {
+					p = q;
 					goto found;
 				}
 			}


btrfs: clean away stripe_align helper

btrfs: clean away stripe_align helper

Only wraps the ALIGN macro.

Signed-off-by: David Sterba <a2ce9d316ca04d17b520237d2846a218b8284e52@suse.cz>
Signed-off-by: Chris Mason <e2e8c5702d8ed5f565988a1cf5bb35c9ce199e5e@fb.com>

--- fs/btrfs/extent-tree.c
+++ fs/btrfs/extent-tree.c
@@ -6263,14 +6263,6 @@
 	return ret;
 }

-static u64 stripe_align(struct btrfs_root *root,
-			struct btrfs_block_group_cache *cache,
-			u64 val, u64 num_bytes)
-{
-	u64 ret = ALIGN(val, root->stripesize);
-	return ret;
-}
-
 /*
  * when we wait for progress in the block group caching, its because
  * our allocation attempt failed at least once.  So, we must sleep
@@ -6751,8 +6743,7 @@
 			goto loop;
 		}
 checks:
-		search_start = stripe_align(root, block_group,
-					    offset, num_bytes);
+		search_start = ALIGN(offset, root->stripesize);

 		/* move on to the next group */
 		if (search_start + num_bytes >


Changed decimal_init to clear all of significand units.

--- src/decimal.c
+++ src/decimal.c
@@ -8,6 +8,7 @@

 void decimal_init(decimal *number, uint32_t capacity)
 {
+    uint32_t unit_count;
     uint32_t i;

     decimal_setFlags(number, 0);
@@ -16,8 +17,9 @@
     decimal_setExponent(number, 0);
     decimal_setCapacity(number, capacity);
     decimal_setLength(number, 1);
-    for (i = 0; i < capacity; ++i) {
-        decimal_setSignificandDigit(number, i, 0);
+    unit_count = DECIMAL_UNIT_COUNT(capacity);
+    for (i = 0; i < unit_count; ++i) {
+        number->significand[i] = 0;
     }
 }


Btrfs: Fix cache_block_group to catch holes at the start of the group

Cache block group was overly complex and missed free blocks at the very start
of the group.  This patch simplifies things significantly.

Signed-off-by: Chris Mason <a169954b4cb1a46cee25f659d3bddfebe02b5fba@oracle.com>

--- fs/btrfs/extent-tree.c
+++ fs/btrfs/extent-tree.c
@@ -39,6 +39,7 @@
 	u64 i;
 	u64 last = 0;
 	u64 hole_size;
+	u64 first_free;
 	int found = 0;

 	root = root->fs_info->extent_root;
@@ -51,16 +52,22 @@
 	path = btrfs_alloc_path();
 	if (!path)
 		return -ENOMEM;
+
 	path->reada = 2;
+	first_free = block_group->key.objectid;
 	key.objectid = block_group->key.objectid;
 	key.flags = 0;
 	key.offset = 0;
+
 	btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY);
 	ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
+
 	if (ret < 0)
 		return ret;
+
 	if (ret && path->slots[0] > 0)
 		path->slots[0]--;
+
 	while(1) {
 		leaf = btrfs_buffer_leaf(path->nodes[0]);
 		slot = path->slots[0];
@@ -71,50 +78,48 @@
 			if (ret == 0) {
 				continue;
 			} else {
-				if (found) {
-					hole_size = block_group->key.objectid +
-						block_group->key.offset - last;
-				} else {
-					last = block_group->key.objectid;
-					hole_size = block_group->key.offset;
-				}
-				for (i = 0; i < hole_size; i++) {
-					set_radix_bit(extent_radix,
-						      last + i);
-				}
 				break;
 			}
 		}
+
 		btrfs_disk_key_to_cpu(&key, &leaf->items[slot].key);
+		if (key.objectid < block_group->key.objectid) {
+			if (key.objectid + key.offset > first_free)
+				first_free = key.objectid + key.offset;
+			goto next;
+		}
+
 		if (key.objectid >= block_group->key.objectid +
 		    block_group->key.offset) {
-			if (found) {
-				hole_size = block_group->key.objectid +
-					block_group->key.offset - last;
-			} else {
-				last = block_group->key.objectid;
-				hole_size = block_group->key.offset;
-			}
+			break;
+		}
+
+		if (btrfs_key_type(&key) == BTRFS_EXTENT_ITEM_KEY) {
+			if (!found) {
+				last = first_free;
+				found = 1;
+			}
+			hole_size = key.objectid - last;
 			for (i = 0; i < hole_size; i++) {
 				set_radix_bit(extent_radix, last + i);
 			}
-			break;
-		}
-		if (btrfs_key_type(&key) == BTRFS_EXTENT_ITEM_KEY) {
-			if (!found) {
-				last = key.objectid + key.offset;
-				found = 1;
-			} else {
-				hole_size = key.objectid - last;
-				for (i = 0; i < hole_size; i++) {
-					set_radix_bit(extent_radix, last + i);
-				}
-				last = key.objectid + key.offset;
-			}
-		}
+			last = key.objectid + key.offset;
+		}
+next:
 		path->slots[0]++;
 	}

+	if (!found)
+		last = first_free;
+	if (block_group->key.objectid +
+	    block_group->key.offset > last) {
+		hole_size = block_group->key.objectid +
+			block_group->key.offset - last;
+		for (i = 0; i < hole_size; i++) {
+			set_radix_bit(extent_radix,
+					last + i);
+		}
+	}
 	block_group->cached = 1;
 err:
 	btrfs_free_path(path);


continue to debug rgkmax problem

continue to debug rgkmax problem

--- src/density.h
+++ src/density.h
@@ -507,6 +507,18 @@
             parameters_.fft().output(parameters_.num_gvec(), parameters_.fft_index(),
                                      potential_->effective_potential()->f_pw());

+            double v_pw_min = 1e100;
+            double v_pw_max = -1e100;
+            for (int ig = 0; ig < parameters_.num_gvec(); ig++)
+            {
+                v_pw_min = std::min(v_pw_min, abs(potential_->effective_potential()->f_pw(ig)));
+                v_pw_max = std::max(v_pw_max, abs(potential_->effective_potential()->f_pw(ig)));
+            }
+            if (Platform::mpi_rank() == 0)
+            {
+                printf("v_pw_min : %f, v_pw_max : %f\n", v_pw_min, v_pw_max);
+            }
+
             // solve secular equation and generate wave functions
             for (int ikloc = 0; ikloc < spl_num_kpoints_.local_size(); ikloc++)
             {


attempt (failed) at using makecontext on a 64-bit machine

--- iterator.c
+++ iterator.c
@@ -57,8 +57,19 @@
 	/* Fill in loop_context so that it makes swapcontext start loop. The
 	 * (void (*)(void)) typecast is to avoid a compiler warning but it is
 	 * not relevant to the behaviour of the function. */
-	makecontext(&loop_context, (void (*)(void)) loop,
-							3, &loop_context, &main_context2, &i_from_iterator);
+#if defined(__x86_64__)
+	int lc_high = (int)(&loop_context);
+	int lc_low = (long)(&loop_context) >> 32;
+	int mc2_high = (int)(&main_context2);
+	int mc2_low = (long)(&main_context2) >> 32;
+	int i_high = (int)(&i_from_iterator);
+	int i_low = (long)(&i_from_iterator) >> 32;
+	printf("high%i:low%i",lc_high, lc_low);
+	makecontext(&loop_context, (void (*)(void)) loop, 6, lc_high, lc_low, mc2_high, mc2_low, i_high, i_low);
+#else
+	makecontext(&loop_context, (void (*)(void)) loop, 3, &loop_context, &main_context2, &i_from_iterator);
+#endif
+

 	/* Clear the finished flag. */
 	iterator_finished = 0;


[ottf] Print test file name

[ottf] Print test file name

This commit modifies OTTF to print this name before and after a test to
make test logs clearer.

Signed-off-by: Alphan Ulusoy <23b245cc5a07aacf75a9db847b24c67dee1707bf@google.com>

--- sw/device/lib/testing/test_framework/ottf_main.c
+++ sw/device/lib/testing/test_framework/ottf_main.c
@@ -55,8 +55,11 @@

 static void report_test_status(bool result) {
   // Reinitialize UART before print any debug output if the test clobbered it.
-  if (kDeviceType != kDeviceSimDV && kTestConfig.can_clobber_uart) {
-    init_uart();
+  if (kDeviceType != kDeviceSimDV) {
+    if (kTestConfig.can_clobber_uart) {
+      init_uart();
+    }
+    LOG_INFO("Finished %s", kTestConfig.file);
     test_coverage_send_buffer();
   }

@@ -80,6 +83,7 @@
   // Initialize the UART to enable logging for non-DV simulation platforms.
   if (kDeviceType != kDeviceSimDV) {
     init_uart();
+    LOG_INFO("Running %s", kTestConfig.file);
   }

   // Run the test.


debug bar potential

debug bar potential

--- galpy/potential_src/potential_c_ext/DehnenBarPotential.c
+++ galpy/potential_src/potential_c_ext/DehnenBarPotential.c
@@ -2,8 +2,8 @@
 #include <galpy_potentials.h>
 //DehnenBarPotential
 //
-inline double calcSmooth(double tform, double tsteady){
-  double smooth, xi;
+inline double calcSmooth(double t,double tform, double tsteady){
+  double smooth, xi,deltat;
   if ( t < tform )
     smooth= 0.;
   else if ( t < tsteady ) {
@@ -28,7 +28,7 @@
   double omegab= *args++;
   double barphi= *args++;
   //Calculate Rforce
-  smooth= calc_smooth(tform,tsteady);
+  smooth= calcSmooth(t,tform,tsteady);
   if (R <= rb )
     return -3.*amp*af*smooth*cos(2.*(phi-omegab*t-barphi))*pow(R/rb,3.)/R;
   else
@@ -47,7 +47,7 @@
   double omegab= *args++;
   double barphi= *args++;
   //Calculate phiforce
-  smooth= calc_smooth(tform,tsteady);
+  smooth= calcSmooth(t,tform,tsteady);
   if (R <= rb )
     return 2.*amp*af*smooth*sin(2.*(phi-omegab*t-barphi))*(pow(R/rb,3.)-2.);
   else


Convert simple_delayed_request

Convert simple_delayed_request

--- test/core/end2end/tests/simple_delayed_request.c
+++ test/core/end2end/tests/simple_delayed_request.c
@@ -100,44 +100,85 @@
   gpr_timespec deadline = five_seconds_time();
   cq_verifier *v_client = cq_verifier_create(f->client_cq);
   cq_verifier *v_server = cq_verifier_create(f->server_cq);
+  grpc_op ops[6];
+  grpc_op *op;
+  grpc_metadata_array initial_metadata_recv;
+  grpc_metadata_array trailing_metadata_recv;
+  grpc_metadata_array request_metadata_recv;
+  grpc_call_details call_details;
+  grpc_status_code status;
+  char *details = NULL;
+  size_t details_capacity = 0;
+  int was_cancelled = 2;

   config.init_client(f, client_args);

-  c = grpc_channel_create_call_old(f->client, "/foo", "test.google.com",
-                                   deadline);
+  c = grpc_channel_create_call(f->client, f->client_cq, "/foo", "test.google.com",
+                               deadline);
   GPR_ASSERT(c);

-  GPR_ASSERT(GRPC_CALL_OK ==
-             grpc_call_invoke_old(c, f->client_cq, tag(2), tag(3), 0));
+  grpc_metadata_array_init(&initial_metadata_recv);
+  grpc_metadata_array_init(&trailing_metadata_recv);
+  grpc_metadata_array_init(&request_metadata_recv);
+  grpc_call_details_init(&call_details);
+
+  op = ops;
+  op->op = GRPC_OP_SEND_INITIAL_METADATA;
+  op->data.send_initial_metadata.count = 0;
+  op++;
+  op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+  op++;
+  op->op = GRPC_OP_RECV_INITIAL_METADATA;
+  op->data.recv_initial_metadata = &initial_metadata_recv;
+  op++;
+  op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+  op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+  op->data.recv_status_on_client.status = &status;
+  op->data.recv_status_on_client.status_details = &details;
+  op->data.recv_status_on_client.status_details_capacity = &details_capacity;
+  op++;
+  GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));

   config.init_server(f, server_args);

+  GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f->server, &s,
+                                                      &call_details,
+                                                      &request_metadata_recv,
+                                                      f->server_cq, tag(101)));
+  cq_expect_completion(v_server, tag(101), GRPC_OP_OK);
+  cq_verify(v_server);
+
+  op = ops;
+  op->op = GRPC_OP_SEND_INITIAL_METADATA;
+  op->data.send_initial_metadata.count = 0;
+  op++;
+  op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
+  op->data.send_status_from_server.trailing_metadata_count = 0;
+  op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
+  op->data.send_status_from_server.status_details = "xyz";
+  op++;
+  op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+  op->data.recv_close_on_server.cancelled = &was_cancelled;
+  op++;
+  GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
+
+  cq_expect_completion(v_server, tag(102), GRPC_OP_OK);
+  cq_verify(v_server);
+
+  cq_expect_completion(v_client, tag(1), GRPC_OP_OK);
   cq_verify(v_client);

-  GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done_old(c, tag(4)));
-  cq_expect_finish_accepted(v_client, tag(4), GRPC_OP_OK);
-  cq_verify(v_client);
-
-  GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f->server, tag(100)));
-  cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", "test.google.com",
-                           deadline, NULL);
-  cq_verify(v_server);
-
-  GPR_ASSERT(GRPC_CALL_OK ==
-             grpc_call_server_accept_old(s, f->server_cq, tag(102)));
-  GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata_old(s, 0));
-  cq_expect_client_metadata_read(v_client, tag(2), NULL);
-  cq_verify(v_client);
-
-  GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status_old(
-                                 s, GRPC_STATUS_UNIMPLEMENTED, "xyz", tag(5)));
-  cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_UNIMPLEMENTED,
-                                 "xyz", NULL);
-  cq_verify(v_client);
-
-  cq_expect_finish_accepted(v_server, tag(5), GRPC_OP_OK);
-  cq_expect_finished(v_server, tag(102), NULL);
-  cq_verify(v_server);
+  GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
+  GPR_ASSERT(0 == strcmp(details, "xyz"));
+  GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
+  GPR_ASSERT(0 == strcmp(call_details.host, "test.google.com"));
+  GPR_ASSERT(was_cancelled == 1);
+
+  gpr_free(details);
+  grpc_metadata_array_destroy(&initial_metadata_recv);
+  grpc_metadata_array_destroy(&trailing_metadata_recv);
+  grpc_metadata_array_destroy(&request_metadata_recv);
+  grpc_call_details_destroy(&call_details);

   grpc_call_destroy(c);
   grpc_call_destroy(s);


Fix bug in DispatchOnTensorType macro (#4808)

--- include/onnxruntime/core/framework/data_types_internal.h
+++ include/onnxruntime/core/framework/data_types_internal.h
@@ -112,7 +112,7 @@
       function<int8_t>(__VA_ARGS__);                              \
       break;                                                      \
     case ONNX_NAMESPACE::TensorProto_DataType_UINT8:              \
-      function<uint32_t>(__VA_ARGS__);                            \
+      function<uint8_t>(__VA_ARGS__);                            \
       break;                                                      \
     case ONNX_NAMESPACE::TensorProto_DataType_INT16:              \
       function<int16_t>(__VA_ARGS__);                             \


cell: inst reorder to save a cycle

cell: inst reorder to save a cycle

--- src/gallium/drivers/cell/ppu/cell_gen_fragment.c
+++ src/gallium/drivers/cell/ppu/cell_gen_fragment.c
@@ -1196,8 +1196,8 @@

       ASSERT(TILE_SIZE == 32);

+      spe_rotmi(f, y2_reg, y_reg, -1);  /* y2 = y / 2 */
       spe_rotmi(f, x2_reg, x_reg, -1);  /* x2 = x / 2 */
-      spe_rotmi(f, y2_reg, y_reg, -1);  /* y2 = y / 2 */
       spe_shli(f, y2_reg, y2_reg, 4);   /* y2 *= 16 */
       spe_a(f, quad_offset_reg, y2_reg, x2_reg);  /* offset = y2 + x2 */
       spe_shli(f, quad_offset_reg, quad_offset_reg, 4);   /* offset *= 16 */


freedreno/a5xx: fix VPC_VAR[n].DISABLE bits

We don't need varying interpolators enabled for pos/psize out of the VS
(despite the fact that they show up in VS_OUT map), so emit these before
we append pos/psize to the linkage.

Signed-off-by: Rob Clark <915c10c999604870200b6defbe633d857c856ca0@gmail.com>

--- src/gallium/drivers/freedreno/a5xx/fd5_program.c
+++ src/gallium/drivers/freedreno/a5xx/fd5_program.c
@@ -342,48 +342,6 @@
 	struct ir3_shader_linkage l = {0};
 	ir3_link_shaders(&l, s[VS].v, s[FS].v);

-	/* a5xx appends pos/psize to end of the linkage map: */
-	if (pos_regid != regid(63,0))
-		ir3_link_add(&l, pos_regid, 0xf, l.max_loc);
-
-	if (psize_regid != regid(63,0))
-		ir3_link_add(&l, psize_regid, 0x1, l.max_loc);
-
-	for (i = 0, j = 0; (i < 16) && (j < l.cnt); i++) {
-		uint32_t reg = 0;
-
-		OUT_PKT4(ring, REG_A5XX_SP_VS_OUT_REG(i), 1);
-
-		reg |= A5XX_SP_VS_OUT_REG_A_REGID(l.var[j].regid);
-		reg |= A5XX_SP_VS_OUT_REG_A_COMPMASK(l.var[j].compmask);
-		j++;
-
-		reg |= A5XX_SP_VS_OUT_REG_B_REGID(l.var[j].regid);
-		reg |= A5XX_SP_VS_OUT_REG_B_COMPMASK(l.var[j].compmask);
-		j++;
-
-		OUT_RING(ring, reg);
-	}
-
-	for (i = 0, j = 0; (i < 8) && (j < l.cnt); i++) {
-		uint32_t reg = 0;
-
-		OUT_PKT4(ring, REG_A5XX_SP_VS_VPC_DST_REG(i), 1);
-
-		reg |= A5XX_SP_VS_VPC_DST_REG_OUTLOC0(l.var[j++].loc);
-		reg |= A5XX_SP_VS_VPC_DST_REG_OUTLOC1(l.var[j++].loc);
-		reg |= A5XX_SP_VS_VPC_DST_REG_OUTLOC2(l.var[j++].loc);
-		reg |= A5XX_SP_VS_VPC_DST_REG_OUTLOC3(l.var[j++].loc);
-
-		OUT_RING(ring, reg);
-	}
-
-	OUT_PKT4(ring, REG_A5XX_SP_VS_OBJ_START_LO, 2);
-	OUT_RELOC(ring, s[VS].v->bo, 0, 0, 0);  /* SP_VS_OBJ_START_LO/HI */
-
-	if (s[VS].instrlen)
-		emit_shader(ring, s[VS].v);
-
 	BITSET_DECLARE(varbs, 128) = {0};
 	uint32_t *varmask = (uint32_t *)varbs;

@@ -396,6 +354,48 @@
 	OUT_RING(ring, ~varmask[1]);  /* VPC_VAR[1].DISABLE */
 	OUT_RING(ring, ~varmask[2]);  /* VPC_VAR[2].DISABLE */
 	OUT_RING(ring, ~varmask[3]);  /* VPC_VAR[3].DISABLE */
+
+	/* a5xx appends pos/psize to end of the linkage map: */
+	if (pos_regid != regid(63,0))
+		ir3_link_add(&l, pos_regid, 0xf, l.max_loc);
+
+	if (psize_regid != regid(63,0))
+		ir3_link_add(&l, psize_regid, 0x1, l.max_loc);
+
+	for (i = 0, j = 0; (i < 16) && (j < l.cnt); i++) {
+		uint32_t reg = 0;
+
+		OUT_PKT4(ring, REG_A5XX_SP_VS_OUT_REG(i), 1);
+
+		reg |= A5XX_SP_VS_OUT_REG_A_REGID(l.var[j].regid);
+		reg |= A5XX_SP_VS_OUT_REG_A_COMPMASK(l.var[j].compmask);
+		j++;
+
+		reg |= A5XX_SP_VS_OUT_REG_B_REGID(l.var[j].regid);
+		reg |= A5XX_SP_VS_OUT_REG_B_COMPMASK(l.var[j].compmask);
+		j++;
+
+		OUT_RING(ring, reg);
+	}
+
+	for (i = 0, j = 0; (i < 8) && (j < l.cnt); i++) {
+		uint32_t reg = 0;
+
+		OUT_PKT4(ring, REG_A5XX_SP_VS_VPC_DST_REG(i), 1);
+
+		reg |= A5XX_SP_VS_VPC_DST_REG_OUTLOC0(l.var[j++].loc);
+		reg |= A5XX_SP_VS_VPC_DST_REG_OUTLOC1(l.var[j++].loc);
+		reg |= A5XX_SP_VS_VPC_DST_REG_OUTLOC2(l.var[j++].loc);
+		reg |= A5XX_SP_VS_VPC_DST_REG_OUTLOC3(l.var[j++].loc);
+
+		OUT_RING(ring, reg);
+	}
+
+	OUT_PKT4(ring, REG_A5XX_SP_VS_OBJ_START_LO, 2);
+	OUT_RELOC(ring, s[VS].v->bo, 0, 0, 0);  /* SP_VS_OBJ_START_LO/HI */
+
+	if (s[VS].instrlen)
+		emit_shader(ring, s[VS].v);

 	// TODO depending on other bits in this reg (if any) set somewhere else?
 	OUT_PKT4(ring, REG_A5XX_PC_PRIM_VTX_CNTL, 1);


freedreno: fix compiler warning

freedreno: fix compiler warning

Signed-off-by: Rob Clark <6f78cdb10adbe0a7fbbf4098125a51f401c77a5f@freedesktop.org>

--- src/gallium/drivers/freedreno/freedreno_screen.c
+++ src/gallium/drivers/freedreno/freedreno_screen.c
@@ -398,6 +398,7 @@
 		return TRUE;
 	} else if (whandle->type == DRM_API_HANDLE_TYPE_FD) {
 		whandle->handle = fd_bo_dmabuf(bo);
+		return TRUE;
 	} else {
 		return FALSE;
 	}


Ignore entries with empty keyword names.

--- src/lib-storage/index/maildir/maildir-keywords.c
+++ src/lib-storage/index/maildir/maildir-keywords.c
@@ -144,7 +144,7 @@
 		*p++ = '\0';

 		idx = atoi(line);
-		if (idx < 0 || idx >= MAILDIR_MAX_KEYWORDS) {
+		if (idx < 0 || idx >= MAILDIR_MAX_KEYWORDS || *p == '\0') {
 			/* shouldn't happen */
 			continue;
 		}


* fixed line ending to UNIX like, deleted normal_3d header

git-svn-id: e7ea667a1d39a4453c4efcc4ba7bca3d620c3f19@4772 a9d63959-f2ad-4865-b262-bf0e56cfafb6

--- segmentation/include/pcl/segmentation/region_growing.h
+++ segmentation/include/pcl/segmentation/region_growing.h
@@ -41,7 +41,6 @@
 #define _REGIONGROWING_H_

 #include "pcl/search/search.h"
-#include "pcl/features/normal_3d.h"
 #include "pcl/point_cloud.h"
 #include "pcl/point_types.h"
 #include <list>


Removing stray ^ in splitRazers.

Removing stray ^ in splitRazers.

git-svn-id: a7f2a8f7432d210e972fb03898013d213e2b549b@7888 e6417c60-b987-48fd-844e-b20f0fcc1017

--- seqan/projects/library/apps/splitRazers/outputFormat.h
+++ seqan/projects/library/apps/splitRazers/outputFormat.h
@@ -612,7 +612,7 @@
 	if (options.maqMapping) options.outputFormat = 3;
 	int maxSeedErrors = (int)(options.errorRate * options.artSeedLength); //without + 1 here, used to check whether match should be supported if noBelowIdentity option is switched on
 #endif
-^	if (options.minMatchLen > 0) options.outputFormat = 33;
+	if (options.minMatchLen > 0) options.outputFormat = 33;
 	if (options.outputFormat == 3)
 	{
 		options.sortOrder = 1;		//  sort according to gPos


avoid dTHX; in APR::Table->do

avoid dTHX; in APR::Table->do

git-svn-id: b4be4a41b2a3352907de631eb6da1671a2f7b614@68557 13f79535-47bb-0310-9956-ffa450edef68

--- xs/APR/Table/APR__Table.h
+++ xs/APR/Table/APR__Table.h
@@ -1,6 +1,7 @@
 typedef struct {
     SV *cv;
     apr_table_t *filter; /*XXX: or maybe a mgv ? */
+    PerlInterpreter *perl;
 } mpxs_table_do_cb_data_t;

 typedef int (*mpxs_apr_table_do_cb_t)(void *, const char *, const char *);
@@ -8,10 +9,10 @@
 static int mpxs_apr_table_do_cb(void *data,
                                 const char *key, const char *val)
 {
-    dTHX; /*XXX*/
+    mpxs_table_do_cb_data_t *tdata = (mpxs_table_do_cb_data_t *)data;
+    dTHXa(tdata->perl);
     dSP;
     int rv = 0;
-    mpxs_table_do_cb_data_t *tdata = (mpxs_table_do_cb_data_t *)data;

     /* Skip completely if something is wrong */
     if (!(tdata && tdata->cv && key && val)) {
@@ -56,7 +57,10 @@

     tdata.cv = sub;
     tdata.filter = NULL;
-
+#ifdef USE_ITHREADS
+    tdata.perl = aTHX;
+#endif
+
     if (items > 2) {
         STRLEN len;
         tdata.filter = apr_table_make(table->a.pool, items-2);


added sorted_ref_array for sorting pointers based on their contents

error: pathspec 'z/core/sorted_ref_array.h' did not match any file(s) known to git

--- z/core/sorted_ref_array.h
+++ z/core/sorted_ref_array.h
@@ -0,0 +1,151 @@
+/**
+ * File:            sorted_ref_array.h
+ * Namespace:       z::core
+ * Description:     An extension of the array class which
+ *                  attempts to keep all data sorted.
+ *                  Unlike in sorted_array.h, elements are
+ *                  assumed to be pointers and are sorted
+ *                  with this in mind.
+ *
+ *
+ * Author:          Zachary Westerman
+ * Email:           zacharywesterman@yahoo.com
+ * Last modified:   12 Feb. 2017
+**/
+
+#pragma once
+#ifndef SORTED_REF_ARRAY_H_INCLUDED
+#define SORTED_REF_ARRAY_H_INCLUDED
+
+#include "array.h"
+
+namespace z
+{
+    namespace core
+    {
+        template <typename T>
+        class sorted_ref_array : public array<T>
+        {
+        private:
+            //private
+
+        public:
+            virtual int add(const T);
+
+            virtual int find(const T) const;
+
+            virtual void sort();
+        };
+
+
+
+        template <typename T>
+        int sorted_ref_array<T>::add(const T object)
+        {
+            if (this->array_data.size() == 0)
+            {
+                this->array_data.push_back(object);
+                return 0;
+            }
+            else
+            {
+                int left = 0;
+                int right = this->array_data.size()-1;
+
+
+                while (left < right)
+                {
+                    int center = (left + right) / 2;
+
+
+                    if (*(this->array_data.at(center)) > *object)
+                    {
+                        right = center;
+                    }
+                    else if (*(this->array_data.at(center)) < *object)
+                    {
+                        left = center + 1;
+                    }
+                    else
+                    {
+                        this->insert(object, center);
+                        return center;
+                    }
+
+
+                    //std::cout << left << ":" << right << std::endl;
+                }
+
+
+                if (*(this->array_data.at(left)) < *object)
+                    this->insert(object, left+1);
+                else
+                    this->insert(object, left);
+
+                return left;
+            }
+        }
+
+
+        template <typename T>
+        int sorted_ref_array<T>::find(const T object) const
+        {
+            if (this->array_data.size() == 0)
+                return -1;
+
+            int left = 0;
+            int right = this->array_data.size()-1;
+
+            while (left < right)
+            {
+                int center = (left + right) / 2;
+
+                if (*(this->array_data.at(center)) < *object)
+                {
+                    left = center + 1;
+                }
+                else if (*(this->array_data.at(center)) > *object)
+                {
+                    right = center - 1;
+                }
+                else
+                {
+                    return center;
+                }
+            }
+
+            if (*(this->array_data.at(left)) == *object)
+                return left;
+            else
+                return -1;
+        }
+
+
+        template <typename T>
+        void sorted_ref_array<T>::sort()
+        {
+            bool done = true;
+
+            do
+            {
+                done = true;
+
+
+                for (int i=0; i<(int)this->array_data.size()-1; i++)
+                {
+                    if (*(this->array_data[i]) > *(this->array_data[i+1]))
+                    {
+                        done = false;
+
+                        T temp = this->array_data[i];
+                        this->array_data[i] = this->array_data[i+1];
+                        this->array_data[i+1] = temp;
+                    }
+                }
+            }
+            while (!done);
+        }
+    }
+}
+
+#endif // SORTED_REF_ARRAY_H_INCLUDED


zcu102: add some explicit casts, avoid unnecessary FP arithmetic

Silences -Wfloat-conversion.

--- zcu102/energymon-zcu102.c
+++ zcu102/energymon-zcu102.c
@@ -204,7 +204,7 @@
       perror("zcu102_poll_sensors: skipping power sensor reading");
     } else {
       sum_w = sum_uw / 1e6;
-      delta_uj = sum_w * exec_us;
+      delta_uj = (uint64_t) (sum_w * (double) exec_us);
 #ifdef ENERGYMON_DEBUG
       fprintf(stderr, "zcu102_poll_sensors: Read total power: %lu uW (%f W)\n", sum_uw, sum_w);
       fprintf(stderr, "zcu102_poll_sensors: Calculated energy: %f W * %"PRIi64" us = %"PRIu64" uJ\n", sum_w, exec_us, delta_uj);
@@ -314,7 +314,7 @@
   }
   // On the ZCU102, the sensors change in increments of 25 mW so the
   //   minimum energy delta = 25 mW * the update interval time.
-  uint64_t prec = 0.025 * energymon_get_interval_zcu102(em);
+  uint64_t prec = energymon_get_interval_zcu102(em) / 40;
   return prec ? prec : 1;
 }


Fix alignment.

Fix alignment.

--- src/widgets/backuplistwidget.h
+++ src/widgets/backuplistwidget.h
@@ -14,8 +14,8 @@
     ~BackupListWidget();

 public slots:
-    void addItemWithUrl(QUrl url);
-    void addItemsWithUrls(QList<QUrl> urls);
+    void        addItemWithUrl(QUrl url);
+    void        addItemsWithUrls(QList<QUrl> urls);
     QList<QUrl> itemUrls();
     void        removeItems();
     void        recomputeListTotals();


Change some push/pops into direct stack operations.


Add test that passes union to unknown function

error: pathspec 'tests/regression/02-base/49-unknown_func_union.c' did not match any file(s) known to git

--- tests/regression/02-base/49-unknown_func_union.c
+++ tests/regression/02-base/49-unknown_func_union.c
@@ -0,0 +1,37 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+
+typedef struct list {
+    int val;
+    struct list *next;
+} list_t;
+
+
+typedef union either {
+    int value;
+    struct list node;
+} either_t;
+
+// void mutate_either(either_t e){
+//     list_t *next = e.node.next;
+//     next->val = 42;
+// }
+
+int main(){
+    list_t first;
+    list_t second;
+
+    first.next = &second;
+    first.val = 1;
+    second.next = NULL;
+    second.val = 2;
+
+    either_t e;
+    e.node = first;
+
+    // When passing a union to an unknown function, reachable memory should be invalidated
+    mutate_either(e);
+    assert(second.val == 2); //UNKNOWN!
+    return 0;
+}


Bug 726134: document that the cert_NSSCertFromPKIXCert function in lib/certhigh/certvfypkix.c depends on nssCert being the first field of struct PKIX_PL_CertStruct.  r=rrelyea.

--- security/nss/lib/libpkix/pkix_pl_nss/pki/pkix_pl_cert.h
+++ security/nss/lib/libpkix/pkix_pl_nss/pki/pkix_pl_cert.h
@@ -51,7 +51,10 @@
 #endif

 struct PKIX_PL_CertStruct {
-        CERTCertificate *nssCert;
+        CERTCertificate *nssCert;  /* Must be the first field.  The
+                                    * cert_NSSCertFromPKIXCert function in
+                                    * lib/certhigh/certvfypkix.c depends on
+                                    * this. */
         CERTGeneralName *nssSubjAltNames;
         PLArenaPool *arenaNameConstraints;
         PKIX_PL_X500Name *issuer;


(partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6

Fix compiler warning:
row/row0upd.c: In function 'row_upd_in_place_in_select':
row/row0upd.c:2040:9: error: variable 'err' set but not used [-Werror=unused-but-set-variable]

--- storage/innobase/row/row0upd.c
+++ storage/innobase/row/row0upd.c
@@ -2037,7 +2037,9 @@
 	upd_node_t*	node;
 	btr_pcur_t*	pcur;
 	btr_cur_t*	btr_cur;
+#ifdef UNIV_DEBUG
 	ulint		err;
+#endif /* UNIV_DEBUG */
 	mem_heap_t*	heap		= NULL;
 	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
 	*offsets_ = (sizeof offsets_) / sizeof *offsets_;
@@ -2074,8 +2076,11 @@
 	ut_ad(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE);
 	ut_ad(node->select_will_do_update);

-	err = btr_cur_update_in_place(BTR_NO_LOCKING_FLAG, btr_cur,
-				      node->update, node->cmpl_info,
-				      thr, mtr);
+#ifdef UNIV_DEBUG
+	err =
+#endif /* UNIV_DEBUG */
+	btr_cur_update_in_place(BTR_NO_LOCKING_FLAG, btr_cur,
+				node->update, node->cmpl_info,
+				thr, mtr);
 	ut_ad(err == DB_SUCCESS);
 }


again, be more explicit with types

again, be more explicit with types

git-svn-id: 931ab4487dc05a11552de95f7d42b8249ade56b7@1636 a5045d30-4826-4484-9c7f-6e55a06ddc77

--- Code/DataStructs/BitVect.h
+++ Code/DataStructs/BitVect.h
@@ -13,10 +13,9 @@
 #include <vector>
 #include <string>

-using std::vector;
-typedef vector<int> IntVect;
+typedef std::vector<int> IntVect;
 typedef IntVect::iterator IntVectIter;
-typedef vector<double> DoubleVect;
+typedef std::vector<double> DoubleVect;
 typedef DoubleVect::iterator DoubleVectIter;
 const int ci_BITVECT_VERSION=0x0020; //!< version number to use in pickles


the ABCs are still in "collections" in Py3.2 and not yet in "collections.abc"

--- Cython/Utility/Generator.c
+++ Cython/Utility/Generator.c
@@ -830,11 +830,11 @@
     static int abc_patched = 0;
     if (!abc_patched) {
         PyObject *module;
-        module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
+        module = PyImport_ImportModule((PY_VERSION_HEX >= 0x03030000) ? "collections.abc" : "collections");
         if (!module) {
             PyErr_WriteUnraisable(NULL);
             if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch "
-                    #if PY_MAJOR_VERSION >= 3
+                    #if PY_VERSION_HEX >= 0x03030000
                     "collections.abc.Generator"
                     #else
                     "collections.Generator"


KSNetworkResponse's constructor is public.

--- Deferred/KSNetworkClient.h
+++ Deferred/KSNetworkClient.h
@@ -5,6 +5,8 @@
 @interface KSNetworkResponse : NSObject
 @property (strong, nonatomic, readonly) NSURLResponse *response;
 @property (strong, nonatomic, readonly) NSData *data;
+
++ (KSNetworkResponse *)networkResponseWithURLResponse:(NSURLResponse *)response data:(NSData *)data;
 @end

 @interface KSNetworkClient : NSObject


A working, but still incomplete, version of the Mikropuhe driver. (dm)

git-svn-id: 30a5f035a20f1bc647618dbad7eea2a951b61b7c@525 91a5dbb7-01b9-0310-9b5f-b28072856b6e

--- Drivers/Mikropuhe/speech.c
+++ Drivers/Mikropuhe/speech.c
@@ -28,9 +28,6 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <sys/wait.h>

 #include "Programs/misc.h"
 #include "Programs/system.h"
@@ -65,28 +62,7 @@

 static void *speechChannel = NULL;
 static MPINT_SpeakFileParams speechParameters;
-
-static const char *devicePath = "/dev/dsp";
-static int deviceDescriptor = -1;
-
-static pid_t childProcess = -1;
-static int pipeDescriptors[2];
-static const int *pipeOutput = &pipeDescriptors[0];
-static const int *pipeInput = &pipeDescriptors[1];
-
-static int
-speechWriter (const void *bytes, unsigned int count, void *data, void *reserved) {
-  if (deviceDescriptor != -1) {
-    int written = write(deviceDescriptor, bytes, count);
-    if (written == count) return 0;
-    if (written == -1) {
-      LogError("Mikropuhe write");
-    } else {
-      LogPrint(LOG_ERR, "Mikropuhe incomplete write: %d < %d", written, count);
-    }
-  }
-  return 1;
-}
+static volatile int speechDevice = -1;

 static void
 speechError (int code, const char *action) {
@@ -130,6 +106,46 @@
       break;
   }
   LogPrint(LOG_ERR, "Mikropuhe %s error: %s", action, explanation);
+}
+
+static int
+speechWriter (const void *bytes, unsigned int count, void *data, void *reserved) {
+  int written = safe_write(speechDevice, bytes, count);
+  if (written == count) return 0;
+  if (written == -1) {
+    LogError("Mikropuhe write");
+  } else {
+    LogPrint(LOG_ERR, "Mikropuhe incomplete write: %d < %d", written, count);
+  }
+  return MPINT_ERR_GENERAL;
+}
+
+static int
+speechWrite (const char *text, int tags) {
+  if (speechDevice == -1) {
+    if ((speechDevice = getPcmDevice(LOG_WARNING)) == -1) return 0;
+    speechParameters.nSampleFreq = getPcmSampleRate(speechDevice);
+    speechParameters.nBits = 8;
+    speechParameters.nChannels = getPcmChannelCount(speechDevice);
+  }
+
+  speechParameters.nTags = tags;
+  if (mpChannelSpeakFile) {
+    int code = mpChannelSpeakFile(speechChannel, text, NULL, &speechParameters);
+    if (!code) return 1;
+    speechError(code, "channel speak");
+  }
+  return 0;
+}
+
+static int
+writeText (const char *text) {
+  return speechWrite(text, 0);
+}
+
+static int
+writeTag (const char *tag) {
+  return speechWrite(tag, MPINT_TAGS_OWN|MPINT_TAGS_SAPI5);
 }

 static void
@@ -167,12 +183,8 @@
   int code;
   loadLibrary();
   if (mpChannelInitEx) {
-    if ((code = mpChannelInitEx(&speechChannel, NULL, NULL, NULL)) == 0) {
+    if (!(code = mpChannelInitEx(&speechChannel, NULL, NULL, NULL))) {
       memset(&speechParameters, 0, sizeof(speechParameters));
-      speechParameters.nTags = MPINT_TAGS_SAPI5;
-      speechParameters.nSampleFreq = 22050;
-      speechParameters.nBits = 16;
-      speechParameters.nChannels = 1;
       speechParameters.nWriteWavHeader = 0;
       speechParameters.pfnWrite = speechWriter;
       speechParameters.pWriteData = NULL;
@@ -189,11 +201,14 @@

 static void
 spk_close (void) {
-  spk_mute();
-
   if (speechChannel) {
     if (mpChannelExit) mpChannelExit(speechChannel, NULL, 0);
     speechChannel = NULL;
+  }
+
+  if (speechDevice != -1) {
+    close(speechDevice);
+    speechDevice = -1;
   }

   if (speechLibrary) {
@@ -206,64 +221,31 @@
   }
 }

-static int
-doChildProcess (void) {
-  FILE *stream = fdopen(*pipeOutput, "r");
-  char buffer[0X400];
-  char *line;
-  while ((line = fgets(buffer, sizeof(buffer), stream))) {
-    if (mpChannelSpeakFile) {
-      int code;
-      if ((code = mpChannelSpeakFile(speechChannel, line, NULL, &speechParameters)) != 0)
-        speechError(code, "channel speak");
-    }
-  }
-  return 0;
-}
-
 static void
 spk_say (const unsigned char *buffer, int length) {
-  if (speechChannel) {
-    if (childProcess != -1) goto ready;
-
-    if (pipe(pipeDescriptors) != -1) {
-      if ((childProcess = fork()) == -1) {
-        LogError("fork");
-      } else if (childProcess == 0) {
-        _exit(doChildProcess());
-      } else
-      ready: {
-        unsigned char text[length + 1];
-        memcpy(text, buffer, length);
-        text[length] = '\n';
-        write(*pipeInput, text, sizeof(text));
-        return;
-      }
-
-      close(*pipeInput);
-      close(*pipeOutput);
-    } else {
-      LogError("pipe");
-    }
-  }
+  unsigned char text[length + 1];
+  memcpy(text, buffer, length);
+  text[length] = 0;
+  if (writeText(text))
+    writeTag("<break time=\"none\"/>");
 }

 static void
 spk_mute (void) {
-  if (childProcess != -1) {
-    close(*pipeInput);
-    close(*pipeOutput);
-
-    kill(childProcess, SIGKILL);
-    waitpid(childProcess, NULL, 0);
-    childProcess = -1;
-  }
 }

 static void
 spk_rate (int setting) {
+  char tag[0X40];
+  snprintf(tag, sizeof(tag), "<rate absspeed=\"%d\"/>",
+           setting * 10 / SPK_DEFAULT_RATE - 10);
+  writeTag(tag);
 }

 static void
 spk_volume (int setting) {
-}
+  char tag[0X40];
+  snprintf(tag, sizeof(tag), "<volume level=\"%d\"/>",
+           setting * 50 / SPK_DEFAULT_VOLUME);
+  writeTag(tag);
+}


Add missing const in some casts

Add missing const in some casts

--- Eigen/src/Core/Transpose.h
+++ Eigen/src/Core/Transpose.h
@@ -353,7 +353,7 @@
 {
   static bool run(const Scalar* dest, const OtherDerived& src)
   {
-    return (bool(blas_traits<OtherDerived>::IsTransposed) != DestIsTransposed) && (dest!=0 && dest==(Scalar*)extract_data(src));
+    return (bool(blas_traits<OtherDerived>::IsTransposed) != DestIsTransposed) && (dest!=0 && dest==(const Scalar*)extract_data(src));
   }
 };

@@ -362,8 +362,8 @@
 {
   static bool run(const Scalar* dest, const CwiseBinaryOp<BinOp,DerivedA,DerivedB>& src)
   {
-    return ((blas_traits<DerivedA>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(Scalar*)extract_data(src.lhs())))
-        || ((blas_traits<DerivedB>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(Scalar*)extract_data(src.rhs())));
+    return ((blas_traits<DerivedA>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(const Scalar*)extract_data(src.lhs())))
+        || ((blas_traits<DerivedB>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(const Scalar*)extract_data(src.rhs())));
   }
 };


Add meta_least_common_multiple helper.

Add meta_least_common_multiple helper.

--- Eigen/src/Core/util/Meta.h
+++ Eigen/src/Core/util/Meta.h
@@ -326,6 +326,22 @@
 template<int Y, int InfX, int SupX>
 class meta_sqrt<Y, InfX, SupX, true> { public:  enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };

+
+/** \internal Computes the least common multiple of two positive integer A and B
+  * at compile-time. It implements a naive algorithm testing all multiples of A.
+  * It thus works better if A>=B.
+  */
+template<int A, int B, int K=1, bool Done = ((A*K)%B)==0>
+struct meta_least_common_multiple
+{
+  enum { ret = meta_least_common_multiple<A,B,K+1>::ret };
+};
+template<int A, int B, int K>
+struct meta_least_common_multiple<A,B,K,true>
+{
+  enum { ret = A*K };
+};
+
 /** \internal determines whether the product of two numeric types is allowed and what the return type is */
 template<typename T, typename U> struct scalar_product_traits
 {


Added documentation for EC_Fog component.

--- EnvironmentModule/EC_Fog.h
+++ EnvironmentModule/EC_Fog.h
@@ -14,6 +14,52 @@
 {
     class ColourValue;
 }
+
+/// Environment fog.
+
+/**
+
+

+

+
+
Environment fog

+
+Registered by Enviroment::EnvironmentModule. EC_Fog is a component which defines scene overall fog. Its values are used when camera is above of any water cube. If user wants to syncronize
+old world enviroment changes with other clients this component can be used. In those cases user needs to create to scene primitive which has EC_Name-component for that component attribute name
+must be se as "FogEnvironment" after that Naali's enviroment module will add EC_Fog for that primitive and it is then syncronizable with other clients.
+
+Attributes:
+

+
 float : startDistanceAttr.
+
 The start distance from the camera of fog, note this has only effect if useAttr is on (or there does not exist Caelum).

+
 float : endDistanceAttr.
+
 The end distance from the camera of fog, note this has only effect if useAttr is on (or there does not exist Caelum).

+
 Color : colorAttr.
+
 Defines what is fog color, note this has only effect if useAttr is on (or there does not exist Caelum).

+
 int : modeAttr.
+
 Fog type ( none, linear, exp, exp2) this defines how fast fog density increases.

+
 bool : useAttr.
+
 Defines that are this fog values used over Caelums calculated fog values.

+
+

+
+ Exposes the following scriptable functions:
+

+
...
+

+
+ Reacts on the following actions:
+

+
...
+

+
+

+
+Does not emit any actions.
+
+

+
+*/

 namespace Environment
@@ -49,6 +95,7 @@
         DEFINE_QPROPERTY_ATTRIBUTE(bool, useAttr);
         Q_PROPERTY(bool useAttr READ getuseAttr WRITE setuseAttr);

+        /// Returns fog color as Ogre colour value.
         Ogre::ColourValue GetColorAsOgreValue() const;

      private:


remove debug statements

remove debug statements

--- gamma/taylor_precompute.c
+++ gamma/taylor_precompute.c
@@ -52,13 +52,9 @@

         _fmprb_vec_clear(gamma_taylor_coeffs, gamma_taylor_num);

-        printf("precomputing: num %ld, prec %ld bits\n", num, prec);
-
         num = FLINT_MAX(gamma_taylor_num * 1.5, num);
         prec = FLINT_MAX(gamma_taylor_prec * 1.5, prec);
         prec = FLINT_MAX(prec, 64);
-
-        printf("precomputing (2): num %ld, prec %ld bits\n", num, prec);

         wp = prec * 1.01 + 32;


switched from html to doxygen

switched from html to doxygen

git-svn-id: e7ea667a1d39a4453c4efcc4ba7bca3d620c3f19@3548 a9d63959-f2ad-4865-b262-bf0e56cfafb6

--- search/include/pcl/search/organized.h
+++ search/include/pcl/search/organized.h
@@ -55,10 +55,8 @@
     /** \brief OrganizedNeighbor is a class for optimized nearest neigbhor search in organized point clouds.
       *
       * The current API implements two different methods in the same corpus:
-      *

-      *
a fast, simple but approximate, window-based nearest neighbor estimation method, similar to 2D

-      *
a slower, but more accurate spherical projection method

-      *

+      *   - a fast, simple but approximate, window-based nearest neighbor estimation method, similar to 2D
+      *   - a slower, but more accurate spherical projection method
       *
       * You can switch between the two methods using \ref setPrecision (true/false). By default the class uses
       * the faster approximate method.


use bigger local variable to calculate free space int overflows at 1T free space

--- usr.sbin/lpr/lpd/recvjob.c
+++ usr.sbin/lpr/lpd/recvjob.c
@@ -329,7 +329,7 @@
 static int
 chksize(int size)
 {
-	int spacefree;
+	int64_t spacefree;
 	struct statfs sfb;

 	if (statfs(".", &sfb) < 0) {


Replaced <g> with <symbol>

Replaced <g> with <symbol>

--- util/dmtxwrite/dmtxwrite.c
+++ util/dmtxwrite/dmtxwrite.c
@@ -585,7 +585,7 @@
   <defs>\n", width, height);
    }

-   fprintf(fp, "  <g id=\"%s\">\n", idString);
+   fprintf(fp, "  <symbol id=\"%s\">\n", idString);
    fprintf(fp, "    <desc>Layout:%dx%d Symbol:%dx%d Data Matrix</desc>\n",
          width, height, symbolCols, symbolRows);

@@ -614,7 +614,7 @@
       }
    }

-   fprintf(fp, "  </g>\n");
+   fprintf(fp, "  </symbol>\n");

    /* Close SVG document */
    if(defineOnly == DmtxFalse) {


Feature #1112: Remove duplicated cluster header

--- include/ClusterPoolOld.h
+++ include/ClusterPoolOld.h
@@ -1,140 +0,0 @@
-/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)             */
-/*                                                                            */
-/* Licensed under the Apache License, Version 2.0 (the "License"); you may    */
-/* not use this file except in compliance with the License. You may obtain    */
-/* a copy of the License at                                                   */
-/*                                                                            */
-/* http://www.apache.org/licenses/LICENSE-2.0                                 */
-/*                                                                            */
-/* Unless required by applicable law or agreed to in writing, software        */
-/* distributed under the License is distributed on an "AS IS" BASIS,          */
-/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   */
-/* See the License for the specific language governing permissions and        */
-/* limitations under the License.                                             */
-/* -------------------------------------------------------------------------- */
-
-#ifndef CLUSTER_POOL_H_
-#define CLUSTER_POOL_H_
-
-#include <string>
-#include <sstream>
-#include <map>
-
-#include "SqlDB.h"
-
-using namespace std;
-
-
-/**
- *  A cluster helper class. It is not a normal PoolSQL,
- *  but a series of static methods related to clusters.
- */
-class ClusterPool
-{
-public:
-    /**
-     *  Cluster name for the default cluster
-     */
-    static const string DEFAULT_CLUSTER_NAME;
-
-private:
-    // -------------------------------------------------------------------------
-    // Friends
-    // -------------------------------------------------------------------------
-    friend class HostPool;
-
-    /* ---------------------------------------------------------------------- */
-    /* Attributes                                                             */
-    /* ---------------------------------------------------------------------- */
-    /**
-     *  This map stores the clusters
-     */
-    map<int, string>	cluster_names;
-
-
-    /* ---------------------------------------------------------------------- */
-    /* Methods for cluster management                                         */
-    /* ---------------------------------------------------------------------- */
-
-    /**
-     *  Returns true if the clid is an id for an existing cluster
-     *  @param clid ID of the cluster
-     *
-     *  @return true if the clid is an id for an existing cluster
-     */
-    bool exists(int clid)
-    {
-        return cluster_names.count(clid) > 0;
-    };
-
-    /**
-     *  Allocates a new cluster in the pool
-     *    @param clid the id assigned to the cluster
-     *    @return the id assigned to the cluster or -1 in case of failure
-     */
-    int allocate(int * clid, string name, SqlDB *db, string& error_str);
-
-    /**
-     *  Returns the xml representation of the given cluster
-     *    @param clid ID of the cluster
-     *
-     *    @return the xml representation of the given cluster
-     */
-    string info(int clid);
-
-    /**
-     *  Removes the given cluster from the pool and the DB
-     *    @param clid ID of the cluster
-     *
-     *    @return 0 on success
-     */
-    int drop(int clid, SqlDB *db);
-
-    /**
-     *  Dumps the cluster pool in XML format.
-     *    @param oss the output stream to dump the pool contents
-     *
-     *    @return 0 on success
-     */
-    int dump(ostringstream& oss);
-
-    /**
-     *  Bootstraps the database table(s) associated to the Cluster
-     */
-    static void bootstrap(SqlDB * db)
-    {
-        ostringstream oss(ClusterPool::db_bootstrap);
-        db->exec(oss);
-    };
-
-    /**
-     *  Function to insert new Cluster in the pool
-     *    @param oid the id assigned to the Cluster
-     *    @param name the Cluster's name
-     *    @return 0 on success, -1 in case of failure
-     */
-    int insert (int oid, string name, SqlDB *db);
-
-    /**
-     *  Formats as XML the given id and name.
-     *    @param oss the output stream to dump the pool contents
-     *
-     *    @return 0 on success
-     */
-    void dump_cluster(ostringstream& oss, int id, string name);
-
-
-    /* ---------------------------------------------------------------------- */
-    /* DB manipulation                                                        */
-    /* ---------------------------------------------------------------------- */
-
-    static const char * db_names;
-
-    static const char * db_bootstrap;
-
-    static const char * table;
-
-};
-
-#endif /*CLUSTER_POOL_H_*/


#7 Add CountDownLatch

#7 Add CountDownLatch

error: pathspec 'include/CountDownLatch.h' did not match any file(s) known to git

--- include/CountDownLatch.h
+++ include/CountDownLatch.h
@@ -0,0 +1,56 @@
+#ifndef _TPOOL_COUNTDOWNLATCH_H_
+#define _TPOOL_COUNTDOWNLATCH_H_
+
+#include "ConditionVariable.h"
+
+#include <boost/noncopyable.hpp>
+
+#include <cassert>
+
+namespace tpool {
+namespace sync {
+
+class CountDownLatch : private ::boost::noncopyable {
+public:
+    explicit CountDownLatch(const int count)
+    : m_count(count)
+    {
+        assert(count > 0);
+    }
+
+    void Wait()
+    {
+        MutexLocker lock(m_count_guard);
+        while (m_count > 0)
+        {
+            m_count_guard.Wait();
+        }
+    }
+
+    void CountDown()
+    {
+        MutexLocker lock(m_count_guard);
+        --m_count;
+        if (m_count == 0)
+        {
+            m_count_guard.NotifyAll();
+        }
+    }
+
+    int GetCount() const
+    {
+        MutexLocker lock(m_count_guard);
+        return m_count;
+    }
+
+private:
+    int m_count;
+    mutable MutexConditionVariable m_count_guard;
+};
+
+}  // namespace sync
+}  // namespace tpool
+
+
+#endif /* _TPOOL_COUNTDOWNLATCH_H_ */
+


nfsd: do_probe_callback should not clear rpc stats

Now that cb_stats are static (since commit
ff7d9756b501744540be65e172d27ee321d86103)
there's no need to clear them.

Initially I thought it might make sense to do
that every callback probing but since the stats
are per-program and they are shared between possibly
several client callback instances, zeroing them out
seems like the wrong thing to do.

Note that that commit also introduced a bug
since stats.program is also being cleared in the process
and it is not restored after the memset as it used to be.

Signed-off-by: Benny Halevy <23c997c90eb8537635e9392d48e7af1bf1b2ca22@panasas.com>
Signed-off-by: J. Bruce Fields <51738506c1b2ccb0761f23bdc612c93babf738ea@citi.umich.edu>

--- fs/nfsd/nfs4callback.c
+++ fs/nfsd/nfs4callback.c
@@ -397,9 +397,6 @@
 	addr.sin_port = htons(cb->cb_port);
 	addr.sin_addr.s_addr = htonl(cb->cb_addr);

-	/* Initialize rpc_stat */
-	memset(args.program->stats, 0, sizeof(struct rpc_stat));
-
 	/* Create RPC client */
 	client = rpc_create(&args);
 	if (IS_ERR(client)) {


ocfs2/cluster: Clean up messages in o2net

o2net messages needed a facelift.

Signed-off-by: Sunil Mushran <71202349b6bab84fd697c8fc05379fc0e6724c25@oracle.com>

--- fs/ocfs2/cluster/tcp.c
+++ fs/ocfs2/cluster/tcp.c
@@ -545,7 +545,7 @@
 	}

 	if (was_valid && !valid) {
-		printk(KERN_NOTICE "o2net: no longer connected to "
+		printk(KERN_NOTICE "o2net: No longer connected to "
 		       SC_NODEF_FMT "\n", SC_NODEF_ARGS(old_sc));
 		o2net_complete_nodes_nsw(nn);
 	}
@@ -555,7 +555,7 @@
 		cancel_delayed_work(&nn->nn_connect_expired);
 		printk(KERN_NOTICE "o2net: %s " SC_NODEF_FMT "\n",
 		       o2nm_this_node() > sc->sc_node->nd_num ?
-		       		"connected to" : "accepted connection from",
+		       "Connected to" : "Accepted connection from",
 		       SC_NODEF_ARGS(sc));
 	}

@@ -643,7 +643,7 @@
 			o2net_sc_queue_work(sc, &sc->sc_connect_work);
 			break;
 		default:
-			printk(KERN_INFO "o2net: connection to " SC_NODEF_FMT
+			printk(KERN_INFO "o2net: Connection to " SC_NODEF_FMT
 			      " shutdown, state %d\n",
 			      SC_NODEF_ARGS(sc), sk->sk_state);
 			o2net_sc_queue_work(sc, &sc->sc_shutdown_work);
@@ -1284,11 +1284,11 @@
 	struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num);

 	if (hand->protocol_version != cpu_to_be64(O2NET_PROTOCOL_VERSION)) {
-		mlog(ML_NOTICE, SC_NODEF_FMT " advertised net protocol "
-		     "version %llu but %llu is required, disconnecting\n",
-		     SC_NODEF_ARGS(sc),
-		     (unsigned long long)be64_to_cpu(hand->protocol_version),
-		     O2NET_PROTOCOL_VERSION);
+		printk(KERN_NOTICE "o2net: " SC_NODEF_FMT " Advertised net "
+		       "protocol version %llu but %llu is required. "
+		       "Disconnecting.\n", SC_NODEF_ARGS(sc),
+		       (unsigned long long)be64_to_cpu(hand->protocol_version),
+		       O2NET_PROTOCOL_VERSION);

 		/* don't bother reconnecting if its the wrong version. */
 		o2net_ensure_shutdown(nn, sc, -ENOTCONN);
@@ -1302,33 +1302,33 @@
 	 */
 	if (be32_to_cpu(hand->o2net_idle_timeout_ms) !=
 				o2net_idle_timeout()) {
-		mlog(ML_NOTICE, SC_NODEF_FMT " uses a network idle timeout of "
-		     "%u ms, but we use %u ms locally.  disconnecting\n",
-		     SC_NODEF_ARGS(sc),
-		     be32_to_cpu(hand->o2net_idle_timeout_ms),
-		     o2net_idle_timeout());
+		printk(KERN_NOTICE "o2net: " SC_NODEF_FMT " uses a network "
+		       "idle timeout of %u ms, but we use %u ms locally. "
+		       "Disconnecting.\n", SC_NODEF_ARGS(sc),
+		       be32_to_cpu(hand->o2net_idle_timeout_ms),
+		       o2net_idle_timeout());
 		o2net_ensure_shutdown(nn, sc, -ENOTCONN);
 		return -1;
 	}

 	if (be32_to_cpu(hand->o2net_keepalive_delay_ms) !=
 			o2net_keepalive_delay()) {
-		mlog(ML_NOTICE, SC_NODEF_FMT " uses a keepalive delay of "
-		     "%u ms, but we use %u ms locally.  disconnecting\n",
-		     SC_NODEF_ARGS(sc),
-		     be32_to_cpu(hand->o2net_keepalive_delay_ms),
-		     o2net_keepalive_delay());
+		printk(KERN_NOTICE "o2net: " SC_NODEF_FMT " uses a keepalive "
+		       "delay of %u ms, but we use %u ms locally. "
+		       "Disconnecting.\n", SC_NODEF_ARGS(sc),
+		       be32_to_cpu(hand->o2net_keepalive_delay_ms),
+		       o2net_keepalive_delay());
 		o2net_ensure_shutdown(nn, sc, -ENOTCONN);
 		return -1;
 	}

 	if (be32_to_cpu(hand->o2hb_heartbeat_timeout_ms) !=
 			O2HB_MAX_WRITE_TIMEOUT_MS) {
-		mlog(ML_NOTICE, SC_NODEF_FMT " uses a heartbeat timeout of "
-		     "%u ms, but we use %u ms locally.  disconnecting\n",
-		     SC_NODEF_ARGS(sc),
-		     be32_to_cpu(hand->o2hb_heartbeat_timeout_ms),
-		     O2HB_MAX_WRITE_TIMEOUT_MS);
+		printk(KERN_NOTICE "o2net: " SC_NODEF_FMT " uses a heartbeat "
+		       "timeout of %u ms, but we use %u ms locally. "
+		       "Disconnecting.\n", SC_NODEF_ARGS(sc),
+		       be32_to_cpu(hand->o2hb_heartbeat_timeout_ms),
+		       O2HB_MAX_WRITE_TIMEOUT_MS);
 		o2net_ensure_shutdown(nn, sc, -ENOTCONN);
 		return -1;
 	}
@@ -1539,28 +1539,16 @@
 {
 	struct o2net_sock_container *sc = (struct o2net_sock_container *)data;
 	struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num);
-
 #ifdef CONFIG_DEBUG_FS
-	ktime_t now = ktime_get();
+	unsigned long msecs = ktime_to_ms(ktime_get()) -
+		ktime_to_ms(sc->sc_tv_timer);
+#else
+	unsigned long msecs = o2net_idle_timeout();
 #endif

-	printk(KERN_NOTICE "o2net: connection to " SC_NODEF_FMT " has been idle for %u.%u "
-	     "seconds, shutting it down.\n", SC_NODEF_ARGS(sc),
-		     o2net_idle_timeout() / 1000,
-		     o2net_idle_timeout() % 1000);
-
-#ifdef CONFIG_DEBUG_FS
-	mlog(ML_NOTICE, "Here are some times that might help debug the "
-	     "situation: (Timer: %lld, Now %lld, DataReady %lld, Advance %lld-%lld, "
-	     "Key 0x%08x, Func %u, FuncTime %lld-%lld)\n",
-	     (long long)ktime_to_us(sc->sc_tv_timer), (long long)ktime_to_us(now),
-	     (long long)ktime_to_us(sc->sc_tv_data_ready),
-	     (long long)ktime_to_us(sc->sc_tv_advance_start),
-	     (long long)ktime_to_us(sc->sc_tv_advance_stop),
-	     sc->sc_msg_key, sc->sc_msg_type,
-	     (long long)ktime_to_us(sc->sc_tv_func_start),
-	     (long long)ktime_to_us(sc->sc_tv_func_stop));
-#endif
+	printk(KERN_NOTICE "o2net: Connection to " SC_NODEF_FMT " has been "
+	       "idle for %lu.%lu secs, shutting it down.\n", SC_NODEF_ARGS(sc),
+	       msecs / 1000, msecs % 1000);

 	/*
 	 * Initialize the nn_timeout so that the next connection attempt
@@ -1693,8 +1681,8 @@

 out:
 	if (ret) {
-		mlog(ML_NOTICE, "connect attempt to " SC_NODEF_FMT " failed "
-		     "with errno %d\n", SC_NODEF_ARGS(sc), ret);
+		printk(KERN_NOTICE "o2net: Connect attempt to " SC_NODEF_FMT
+		       " failed with errno %d\n", SC_NODEF_ARGS(sc), ret);
 		/* 0 err so that another will be queued and attempted
 		 * from set_nn_state */
 		if (sc)
@@ -1717,8 +1705,8 @@

 	spin_lock(&nn->nn_lock);
 	if (!nn->nn_sc_valid) {
-		mlog(ML_ERROR, "no connection established with node %u after "
-		     "%u.%u seconds, giving up and returning errors.\n",
+		printk(KERN_NOTICE "o2net: No connection established with "
+		       "node %u after %u.%u seconds, giving up.\n",
 		     o2net_num_from_nn(nn),
 		     o2net_idle_timeout() / 1000,
 		     o2net_idle_timeout() % 1000);
@@ -1861,21 +1849,21 @@

 	node = o2nm_get_node_by_ip(sin.sin_addr.s_addr);
 	if (node == NULL) {
-		mlog(ML_NOTICE, "attempt to connect from unknown node at %pI4:%d\n",
-		     &sin.sin_addr.s_addr, ntohs(sin.sin_port));
+		printk(KERN_NOTICE "o2net: Attempt to connect from unknown "
+		       "node at %pI4:%d\n", &sin.sin_addr.s_addr,
+		       ntohs(sin.sin_port));
 		ret = -EINVAL;
 		goto out;
 	}

 	if (o2nm_this_node() >= node->nd_num) {
 		local_node = o2nm_get_node_by_num(o2nm_this_node());
-		mlog(ML_NOTICE, "unexpected connect attempt seen at node '%s' ("
-		     "%u, %pI4:%d) from node '%s' (%u, %pI4:%d)\n",
-		     local_node->nd_name, local_node->nd_num,
-		     &(local_node->nd_ipv4_address),
-		     ntohs(local_node->nd_ipv4_port),
-		     node->nd_name, node->nd_num, &sin.sin_addr.s_addr,
-		     ntohs(sin.sin_port));
+		printk(KERN_NOTICE "o2net: Unexpected connect attempt seen "
+		       "at node '%s' (%u, %pI4:%d) from node '%s' (%u, "
+		       "%pI4:%d)\n", local_node->nd_name, local_node->nd_num,
+		       &(local_node->nd_ipv4_address),
+		       ntohs(local_node->nd_ipv4_port), node->nd_name,
+		       node->nd_num, &sin.sin_addr.s_addr, ntohs(sin.sin_port));
 		ret = -EINVAL;
 		goto out;
 	}
@@ -1900,10 +1888,10 @@
 		ret = 0;
 	spin_unlock(&nn->nn_lock);
 	if (ret) {
-		mlog(ML_NOTICE, "attempt to connect from node '%s' at "
-		     "%pI4:%d but it already has an open connection\n",
-		     node->nd_name, &sin.sin_addr.s_addr,
-		     ntohs(sin.sin_port));
+		printk(KERN_NOTICE "o2net: Attempt to connect from node '%s' "
+		       "at %pI4:%d but it already has an open connection\n",
+		       node->nd_name, &sin.sin_addr.s_addr,
+		       ntohs(sin.sin_port));
 		goto out;
 	}

@@ -1983,7 +1971,7 @@

 	ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
 	if (ret < 0) {
-		mlog(ML_ERROR, "unable to create socket, ret=%d\n", ret);
+		printk(KERN_ERR "o2net: Error %d while creating socket\n", ret);
 		goto out;
 	}

@@ -2000,16 +1988,15 @@
 	sock->sk->sk_reuse = 1;
 	ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin));
 	if (ret < 0) {
-		mlog(ML_ERROR, "unable to bind socket at %pI4:%u, "
-		     "ret=%d\n", &addr, ntohs(port), ret);
+		printk(KERN_ERR "o2net: Error %d while binding socket at "
+		       "%pI4:%u\n", ret, &addr, ntohs(port));
 		goto out;
 	}

 	ret = sock->ops->listen(sock, 64);
-	if (ret < 0) {
-		mlog(ML_ERROR, "unable to listen on %pI4:%u, ret=%d\n",
-		     &addr, ntohs(port), ret);
-	}
+	if (ret < 0)
+		printk(KERN_ERR "o2net: Error %d while listening on %pI4:%u\n",
+		       ret, &addr, ntohs(port));

 out:
 	if (ret) {


bindings: return value type fixup

bindings: return value type fixup

Signed-off-by: Wolfgang Bumiller <bac7898f539fd233d9ce33be7a9eda13ee647930@proxmox.com>
Acked-by: Serge E. Hallyn <3df611b026e4639bee8aef7a4beb2e39fcebb313@ubuntu.com>

--- bindings.c
+++ bindings.c
@@ -665,7 +665,7 @@
 	(*list)[0] = NULL;

 	if (!tmpc)
-		return NULL;
+		return false;

 	/* basedir / tmpc / cgroup \0 */
 	len = strlen(basedir) + strlen(tmpc) + strlen(cgroup) + 3;
@@ -815,7 +815,7 @@

 	*keys = NULL;
 	if (!tmpc)
-		return NULL;
+		return false;

 	/* basedir / tmpc / cgroup \0 */
 	len = strlen(basedir) + strlen(tmpc) + strlen(cgroup) + 3;


Fixed a segfault when MIME does not initialize

--- src/desktop.c
+++ src/desktop.c
@@ -558,7 +558,8 @@
 	for(i = 0; i < desktop->icon_cnt; i++)
 		desktopicon_delete(desktop->icon[i]);
 	free(desktop->icon);
-	mime_delete(desktop->mime);
+	if(desktop->mime != NULL)
+		mime_delete(desktop->mime);
 	free(desktop->path);
 	free(desktop);
 }


procfs: use kbasename()

procfs: use kbasename()

[b8f9cab8be13de37b9588aedad10a20fc3a68783@trendmicro.com.cn: remove duplicated include]
Signed-off-by: Andy Shevchenko <74f0c009df510614346aa771cd21959b78cdb413@linux.intel.com>
Signed-off-by: Wei Yongjun <b8f9cab8be13de37b9588aedad10a20fc3a68783@trendmicro.com.cn>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- fs/proc/proc_devtree.c
+++ fs/proc/proc_devtree.c
@@ -195,11 +195,7 @@
 	set_node_proc_entry(np, de);
 	for (child = NULL; (child = of_get_next_child(np, child));) {
 		/* Use everything after the last slash, or the full name */
-		p = strrchr(child->full_name, '/');
-		if (!p)
-			p = child->full_name;
-		else
-			++p;
+		p = kbasename(child->full_name);

 		if (duplicate_name(de, p))
 			p = fixup_name(np, de, p);


Fix ioctl() requested buffer size - it should be specified in bytes not bits.

This commit is part of Jakub Klama's work on bringing evdev support into
the FreeBSD kernel.

Author: Jakub Wojciech Klama <31328bf33c95b49e9115d368d1e0d10706a29fd7@freebsd.org>

--- evdev/input.c
+++ evdev/input.c
@@ -164,7 +164,7 @@

     memset(&ev_bits, 0, sizeof(ev_bits));

-    if (ioctl(_fd, EVIOCGBIT(0, EV_MAX), ev_bits) < 0)
+    if (ioctl(_fd, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits) < 0)
         goto on_err;

     // Build a dictionary of the device's capabilities
@@ -175,7 +175,7 @@
             eventcodes = PyList_New(0);

             memset(&code_bits, 0, sizeof(code_bits));
-            ioctl(_fd, EVIOCGBIT(ev_type, KEY_MAX), code_bits);
+            ioctl(_fd, EVIOCGBIT(ev_type, sizeof(code_bits)), code_bits);

             for (ev_code = 0; ev_code < KEY_MAX; ev_code++) {
                 if (test_bit(code_bits, ev_code)) {