moved bin op functions out of class body

--- CppImport/src/ClangAstVisitor.h
+++ CppImport/src/ClangAstVisitor.h
@@ -22,61 +22,32 @@

     // binary ops
-//    bool TraverseBinMul(clang::BinaryOperator* binOp)
-//    {return TraverseBinaryOp(binOp);}
-//    bool TraverseBinDiv(clang::BinaryOperator* binOp)
-//    {return TraverseBinaryOp(binOp);}
-//    bool TraverseBinRem(clang::BinaryOperator* binOp)
-//    {return TraverseBinaryOp(binOp);}
-    bool TraverseBinAdd(clang::BinaryOperator* binOp)
-    {return TraverseBinaryOp(binOp);}
-//    bool TraverseBinSub(clang::BinaryOperator* binOp)
-//    {return TraverseBinaryOp(binOp);}
-    bool TraverseBinAdd(clang::BinaryOperator* binOp)
-    {return TraverseBinaryOp(binOp);}
-//    bool TraverseBinSub(clang::BinaryOperator* binOp)
-//    {return TraverseBinaryOp(binOp);}
-    bool TraverseBinLT(clang::BinaryOperator* binOp)
-    {return TraverseBinaryOp(binOp);}
-    bool TraverseBinGT(clang::BinaryOperator* binOp)
-    {return TraverseBinaryOp(binOp);}
-    bool TraverseBinLE(clang::BinaryOperator* binOp)
-    {return TraverseBinaryOp(binOp);}
-    bool TraverseBinGE(clang::BinaryOperator* binOp)
-    {return TraverseBinaryOp(binOp);}
-    bool TraverseBinEQ(clang::BinaryOperator* binOp)
-    {return TraverseBinaryOp(binOp);}
-    bool TraverseBinNE(clang::BinaryOperator* binOp)
-    {return TraverseBinaryOp(binOp);}
-//    bool TraverseBinAnd(clang::BinaryOperator* binOp)
-//    {return TraverseBinaryOp(binOp);}
-//    bool TraverseBinXor(clang::BinaryOperator* binOp)
-//    {return TraverseBinaryOp(binOp);}
-//    bool TraverseBinOr(clang::BinaryOperator* binOp)
-//    {return TraverseBinaryOp(binOp);}
-    // binary assigns
-    bool TraverseBinAssign(clang::BinaryOperator* binOp)
-    {return TraverseAssignment(binOp);}
-//    bool TraverseBinMulAssign(clang::CompoundAssignOperator* binOp)
-//    {return TraverseAssignment(binOp);}
-//    bool TraverseBinDivAssign(clang::CompoundAssignOperator* binOp)
-//    {return TraverseAssignment(binOp);}
-//    bool TraverseBinRemAssign(clang::CompoundAssignOperator* binOp)
-//    {return TraverseAssignment(binOp);}
-//    bool TraverseBinAddAssign(clang::CompoundAssignOperator* binOp)
-//    {return TraverseAssignment(binOp);}
-//    bool TraverseBinSubAssign(clang::CompoundAssignOperator* binOp)
-//    {return TraverseAssignment(binOp);}
-//    bool TraverseBinShlAssign(clang::CompoundAssignOperator* binOp)
-//    {return TraverseAssignment(binOp);}
-//    bool TraverseBinShrAssign(clang::CompoundAssignOperator* binOp)
-//    {return TraverseAssignment(binOp);}
-//    bool TraverseBinAndAssign(clang::CompoundAssignOperator* binOp)
-//    {return TraverseAssignment(binOp);}
-//    bool TraverseBinXorAssign(clang::CompoundAssignOperator* binOp)
-//    {return TraverseAssignment(binOp);}
-//    bool TraverseBinOrAssign(clang::CompoundAssignOperator* binOp)
-//    {return TraverseAssignment(binOp);}
+//    bool TraverseBinMul(clang::BinaryOperator* binOp);
+//    bool TraverseBinDiv(clang::BinaryOperator* binOp);
+//    bool TraverseBinRem(clang::BinaryOperator* binOp);
+    bool TraverseBinAdd(clang::BinaryOperator* binOp);
+//    bool TraverseBinSub(clang::BinaryOperator* binOp);
+    bool TraverseBinLT(clang::BinaryOperator* binOp);
+    bool TraverseBinGT(clang::BinaryOperator* binOp);
+    bool TraverseBinLE(clang::BinaryOperator* binOp);
+    bool TraverseBinGE(clang::BinaryOperator* binOp);
+    bool TraverseBinEQ(clang::BinaryOperator* binOp);
+    bool TraverseBinNE(clang::BinaryOperator* binOp);
+//    bool TraverseBinAnd(clang::BinaryOperator* binOp);
+//    bool TraverseBinXor(clang::BinaryOperator* binOp);
+//    bool TraverseBinOr(clang::BinaryOperator* binOp);
+//     binary assigns
+    bool TraverseBinAssign(clang::BinaryOperator* binOp);
+//    bool TraverseBinMulAssign(clang::CompoundAssignOperator* binOp);
+//    bool TraverseBinDivAssign(clang::CompoundAssignOperator* binOp);
+//    bool TraverseBinRemAssign(clang::CompoundAssignOperator* binOp);
+//    bool TraverseBinAddAssign(clang::CompoundAssignOperator* binOp);
+//    bool TraverseBinSubAssign(clang::CompoundAssignOperator* binOp);
+//    bool TraverseBinShlAssign(clang::CompoundAssignOperator* binOp);
+//    bool TraverseBinShrAssign(clang::CompoundAssignOperator* binOp);
+//    bool TraverseBinAndAssign(clang::CompoundAssignOperator* binOp);
+//    bool TraverseBinXorAssign(clang::CompoundAssignOperator* binOp);
+//    bool TraverseBinOrAssign(clang::CompoundAssignOperator* binOp);

     bool VisitStmt(clang::Stmt* S);
@@ -99,3 +70,59 @@
     TranslateManager* trMngr_{};
     bool inBody_{false};
 };
+
+
+
+
+// binary ops
+//    inline bool ClangAstVisitor::TraverseBinMul(clang::BinaryOperator* binOp)
+//    {return TraverseBinaryOp(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinDiv(clang::BinaryOperator* binOp)
+//    {return TraverseBinaryOp(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinRem(clang::BinaryOperator* binOp)
+//    {return TraverseBinaryOp(binOp);}
+inline bool ClangAstVisitor::TraverseBinAdd(clang::BinaryOperator* binOp)
+{return TraverseBinaryOp(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinSub(clang::BinaryOperator* binOp)
+//    {return TraverseBinaryOp(binOp);}
+inline bool ClangAstVisitor::TraverseBinLT(clang::BinaryOperator* binOp)
+{return TraverseBinaryOp(binOp);}
+inline bool ClangAstVisitor::TraverseBinGT(clang::BinaryOperator* binOp)
+{return TraverseBinaryOp(binOp);}
+inline bool ClangAstVisitor::TraverseBinLE(clang::BinaryOperator* binOp)
+{return TraverseBinaryOp(binOp);}
+inline bool ClangAstVisitor::TraverseBinGE(clang::BinaryOperator* binOp)
+{return TraverseBinaryOp(binOp);}
+inline bool ClangAstVisitor::TraverseBinEQ(clang::BinaryOperator* binOp)
+{return TraverseBinaryOp(binOp);}
+inline bool ClangAstVisitor::TraverseBinNE(clang::BinaryOperator* binOp)
+{return TraverseBinaryOp(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinAnd(clang::BinaryOperator* binOp)
+//    {return TraverseBinaryOp(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinXor(clang::BinaryOperator* binOp)
+//    {return TraverseBinaryOp(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinOr(clang::BinaryOperator* binOp)
+//    {return TraverseBinaryOp(binOp);}
+// binary assigns
+inline bool ClangAstVisitor::TraverseBinAssign(clang::BinaryOperator* binOp)
+{return TraverseAssignment(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinMulAssign(clang::CompoundAssignOperator* binOp)
+//    {return TraverseAssignment(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinDivAssign(clang::CompoundAssignOperator* binOp)
+//    {return TraverseAssignment(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinRemAssign(clang::CompoundAssignOperator* binOp)
+//    {return TraverseAssignment(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinAddAssign(clang::CompoundAssignOperator* binOp)
+//    {return TraverseAssignment(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinSubAssign(clang::CompoundAssignOperator* binOp)
+//    {return TraverseAssignment(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinShlAssign(clang::CompoundAssignOperator* binOp)
+//    {return TraverseAssignment(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinShrAssign(clang::CompoundAssignOperator* binOp)
+//    {return TraverseAssignment(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinAndAssign(clang::CompoundAssignOperator* binOp)
+//    {return TraverseAssignment(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinXorAssign(clang::CompoundAssignOperator* binOp)
+//    {return TraverseAssignment(binOp);}
+//    inline bool ClangAstVisitor::TraverseBinOrAssign(clang::CompoundAssignOperator* binOp)
+//    {return TraverseAssignment(binOp);}


net: core: Fix IPv6 extra header options handling

If the packet contains IPv6 header + Extra header + ICMPv6 headers,
last header does not contain 'next header and length' fields. So
while parsing header we should first check next header and continue
parsing. Otherwise we parse 2 bytes extra and set invalid ext hdr len
and handover to other layers. So everything goes wrong after that.

Also simplified next header parsing to minimal.

Change-Id: I5d8235c5a57c8b77adf6a07eb8eb74350a3e4dc6
Signed-off-by: Ravi kumar Veeramally <406c082aeb452858c41b213a757768e1c1dff29e@linux.intel.com>

--- subsys/net/ip/net_core.c
+++ subsys/net/ip/net_core.c
@@ -187,6 +187,12 @@
 	return NULL;
 }

+static inline bool is_upper_layer_protocol_header(uint8_t proto)
+{
+	return (proto == IPPROTO_ICMPV6 || proto == IPPROTO_UDP ||
+		proto == IPPROTO_TCP);
+}
+
 static inline enum net_verdict process_ipv6_pkt(struct net_buf *buf)
 {
 	struct net_ipv6_hdr *hdr = NET_IPV6_BUF(buf);
@@ -238,18 +244,9 @@
 	 * headers can be slow so do this checking here. There cannot
 	 * be any extension headers after the upper layer protocol header.
 	 */
-	switch (*(net_nbuf_next_hdr(buf))) {
-	case IPPROTO_ICMPV6:
-		return process_icmpv6_pkt(buf, hdr);
-
-#if defined(CONFIG_NET_UDP)
-	case IPPROTO_UDP:
-		return net_conn_input(IPPROTO_UDP, buf);
-#endif
-#if defined(CONFIG_NET_TCP)
-	case IPPROTO_TCP:
-		return net_conn_input(IPPROTO_TCP, buf);
-#endif
+	next = *(net_nbuf_next_hdr(buf));
+	if (is_upper_layer_protocol_header(next)) {
+		goto upper_proto;
 	}

 	/* Go through the extensions */
@@ -261,25 +258,24 @@
 	while (frag) {
 		enum net_verdict verdict;

+		if (is_upper_layer_protocol_header(next)) {
+			NET_DBG("IPv6 next header %d", next);
+			net_nbuf_set_ext_len(buf, offset -
+					     sizeof(struct net_ipv6_hdr));
+			goto upper_proto;
+		}
+
 		frag = net_nbuf_read_u8(frag, offset, &offset, &next_hdr);
 		frag = net_nbuf_read_u8(frag, offset, &offset, &length);
-		if (!frag) {
+		if (!frag && offset == 0xffff) {
 			goto drop;
 		}

 		length = length * 8 + 8;
 		verdict = NET_OK;

-#if defined(CONFIG_NET_DEBUG_CORE)
 		/* Print the length only for IPv6 extension */
-		if (next != IPPROTO_ICMPV6 && next != IPPROTO_UDP &&
-		    next != IPPROTO_TCP) {
-			NET_DBG("IPv6 next header %d length %d bytes",
-				next, length);
-		} else {
-			NET_DBG("IPv6 next header %d", next);
-		}
-#endif /* CONFIG_NET_DEBUG_CORE */
+		NET_DBG("IPv6 next header %d length %d bytes", next, length);

 		switch (next) {
 		case NET_IPV6_NEXTHDR_NONE:
@@ -291,15 +287,16 @@
 			goto drop;

 		case NET_IPV6_NEXTHDR_HBHO:
+			/* HBH option needs to be the first one */
+			if (first_option != NET_IPV6_NEXTHDR_HBHO) {
+				goto bad_hdr;
+			}
+
 			/* Hop by hop option */
 			if (net_nbuf_ext_bitmap(buf) &
 			    NET_IPV6_EXT_HDR_BITMAP_HBHO) {
 				goto bad_hdr;
 			}
-			/* HBH option needs to be the first one */
-			if (first_option != NET_IPV6_NEXTHDR_HBHO) {
-				goto bad_hdr;
-			}

 			net_nbuf_add_ext_bitmap(buf,
 						NET_IPV6_EXT_HDR_BITMAP_HBHO);
@@ -307,51 +304,35 @@
 			frag = handle_ext_hdr_options(buf, frag, real_len,
 						      length, offset, &offset,
 						      &verdict);
-			if (verdict == NET_DROP) {
-				goto drop;
-			} else if (verdict == NET_CONTINUE) {
-				/* ignore the option */
-				break;
-			}
-
-			if (!frag && offset) {
-				/* Header issue, the ICMPv6 parameter problem
-				 * error is already sent so just drop the msg
-				 * here.
-				 */
-				goto drop;
-			}
-
 			break;

-		/* The next header after the extensions can be also
-		 * one of the main protocols.
-		 */
-		case IPPROTO_ICMPV6:
-			net_nbuf_set_ext_len(buf,
-					     offset -
-					     sizeof(struct net_ipv6_hdr));
-			return process_icmpv6_pkt(buf, hdr);
-
-#if defined(CONFIG_NET_UDP)
-		case IPPROTO_UDP:
-			net_nbuf_set_ext_len(buf,
-					     offset -
-					     sizeof(struct net_ipv6_hdr));
-			return net_conn_input(IPPROTO_UDP, buf);
-#endif
-#if defined(CONFIG_NET_TCP)
-		case IPPROTO_TCP:
-			net_nbuf_set_ext_len(buf,
-					     offset -
-					     sizeof(struct net_ipv6_hdr));
-			return net_conn_input(IPPROTO_TCP, buf);
-#endif
 		default:
 			goto bad_hdr;
 		}

+		if (verdict == NET_DROP) {
+			goto drop;
+		}
+
 		next = next_hdr;
+	}
+
+upper_proto:
+	switch (next) {
+	case IPPROTO_ICMPV6:
+		return process_icmpv6_pkt(buf, hdr);
+	case IPPROTO_UDP:
+#if defined(CONFIG_NET_UDP)
+		return net_conn_input(IPPROTO_UDP, buf);
+#else
+		return NET_DROP;
+#endif
+	case IPPROTO_TCP:
+#if defined(CONFIG_NET_TCP)
+		return net_conn_input(IPPROTO_TCP, buf);
+#else
+		return NET_DROP;
+#endif
 	}

 drop:


Don't free host header since it's in the dict.

--- src/request.c
+++ src/request.c
@@ -127,7 +127,7 @@
     bdestroy(req->path); req->path = NULL;
     bdestroy(req->query_string); req->query_string = NULL;
     bdestroy(req->fragment); req->fragment = NULL;
-    bdestroy(req->host); req->host = NULL;
+    // we don't own the host header
     bdestroy(req->host_name); req->host_name = NULL;
 }


Fix a NULL pointer issue in request.c

Fix a NULL pointer issue in request.c

With a malformed request line, rent.method would not be populated,
and thus would remain NULL. This caused problems with how we determine
outputting the body of a page, as strcmp() was used to see whether or
not the request method wanted a body. If rent.method had the value
"HEAD", we would ignore outputting it. Since strcmp(), however, is not
NULL-safe, this would lead to a segmentation fault in the request
process.

--- src/request.c
+++ src/request.c
@@ -979,7 +979,7 @@
 		/* put body, if any
 		 * e.g. /robots.txt, /, error pages
 		 */
-		if (strcmp(rent.method, "HEAD") != 0) {
+		if (rent.method == NULL || strcmp(rent.method, "HEAD") != 0) {
 			if (rent.code == 200) {
 				char fbuf[64];
 				size_t fret = 0;


[core] perf: one-element cache for host normalize

one-element cache for http_request_host_normalize() on IP address

--- src/request.c
+++ src/request.c
@@ -253,16 +253,24 @@
             buffer_string_set_length(b, (size_t)(colon - p)); /*(remove port str)*/
         }

-        if (light_isdigit(*p)) {
+        if (light_isdigit(*p)) do {
             /* (IPv4 address literal or domain starting w/ digit (e.g. 3com))*/
+            /* (check one-element cache of normalized IPv4 address string) */
+            static struct { char s[INET_ADDRSTRLEN]; size_t n; } laddr;
+            size_t n = colon ? (size_t)(colon - p) : blen;
             sock_addr addr;
+            if (n == laddr.n && 0 == memcmp(p, laddr.s, n)) break;
             if (1 == sock_addr_inet_pton(&addr, p, AF_INET, 0)) {
                 sock_addr_inet_ntop_copy_buffer(b, &addr);
+                n = buffer_string_length(b);
+                if (n < sizeof(laddr.s)) memcpy(laddr.s, b->ptr, (laddr.n = n));
             }
-        }
-    } else { /* IPv6 addr */
+        } while (0);
+    } else do { /* IPv6 addr */
       #if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)

+        /* (check one-element cache of normalized IPv4 address string) */
+        static struct { char s[INET6_ADDRSTRLEN]; size_t n; } laddr;
         sock_addr addr;
         char *bracket = b->ptr+blen-1;
         char *percent = strchr(b->ptr+1, '%');
@@ -286,6 +294,13 @@
             }
         }

+        len = (size_t)((percent ? percent : bracket) - (b->ptr+1));
+        if (laddr.n == len && 0 == memcmp(laddr.s, b->ptr+1, len)) {
+            /* truncate after ']' and re-add normalized port, if needed */
+            buffer_string_set_length(b, (size_t)(bracket - b->ptr + 1));
+            break;
+        }
+
         *bracket = '\0';/*(terminate IPv6 string)*/
         if (percent) *percent = '\0'; /*(remove %interface from address)*/
         rc = sock_addr_inet_pton(&addr, b->ptr+1, AF_INET6, 0);
@@ -298,6 +313,7 @@
         if (percent) {
             if (percent > bracket) return -1;
             if (len + (size_t)(bracket - percent) >= sizeof(buf)) return -1;
+            if (len < sizeof(laddr.s)) memcpy(laddr.s, buf, (laddr.n = len));
             memcpy(buf+len, percent, (size_t)(bracket - percent));
             len += (size_t)(bracket - percent);
         }
@@ -310,7 +326,7 @@
         return -1;

       #endif
-    }
+    } while (0);

     if (0 != port && port != scheme_port) {
         buffer_append_string_len(b, CONST_STR_LEN(":"));


[core] perf: request processing

[core] perf: request processing

--- src/request.c
+++ src/request.c
@@ -452,18 +452,8 @@
  *
  * returns 0 on success, HTTP status on error
  */
-static int parse_single_header(server *srv, connection *con, parse_header_state *state, char *k, size_t klen, char *v, size_t vlen) {
-    const enum http_header_e id = http_header_hkey_get(k, klen);
+static int parse_single_header(server *srv, connection *con, parse_header_state *state, const enum http_header_e id, char *k, size_t klen, char *v, size_t vlen) {
     buffer **saveb = NULL;
-
-    /* strip leading whitespace */
-    for (; vlen > 0 && (v[0] == ' ' || v[0] == '\t'); ++v, --vlen) ;
-
-    /* strip trailing whitespace */
-    while (vlen > 0 && (v[vlen - 1] == ' ' || v[vlen - 1] == '\t')) --vlen;
-
-    /* empty header-fields are not allowed by HTTP-RFC, we just ignore them */
-    if (0 == vlen) return 0; /* ignore header */

     /*
      * Note: k might not be '\0'-terminated
@@ -554,7 +544,6 @@
         break;
     }

-    con->request.htags |= id;
     http_header_request_append(con, id, k, klen, v, vlen);

     if (saveb) {
@@ -598,6 +587,10 @@
 	ptr[i] = '\0';
 	state->reqline_len = i+1;

+	if (NULL == proto) {
+		return http_request_header_line_invalid(srv, 400, "incomplete request line -> 400");
+	}
+
 			{
 				char *nuri = NULL;
 				size_t j, jlen;
@@ -608,10 +601,6 @@
 					ptr[i-1] = '\0';
 				} else if (http_header_strict) { /* '\n' */
 					return http_request_header_line_invalid(srv, 400, "missing CR before LF in header -> 400");
-				}
-
-				if (NULL == proto) {
-					return http_request_header_line_invalid(srv, 400, "incomplete request line -> 400");
 				}

 				con->request.http_method = get_http_method_key(ptr, uri - 1 - ptr);
@@ -689,11 +678,147 @@
 	return 0;
 }

+__attribute_noinline__
+static int http_request_parse_header_other(server *srv, const char *k, int klen, const unsigned int http_header_strict) {
+    for (int i = 0; i < klen; ++i) {
+        if (light_isalpha(k[i]) || k[i] == '-') continue; /*(common cases)*/
+        /**
+         * 1*<any CHAR except CTLs or separators>
+         * CTLs == 0-31 + 127, CHAR = 7-bit ascii (0..127)
+         *
+         */
+        switch(k[i]) {
+        case ' ':
+        case '\t':
+            return http_request_header_line_invalid(srv, 400, "WS character in key -> 400");
+        case '(':
+        case ')':
+        case '<':
+        case '>':
+        case '@':
+        case ',':
+        case ';':
+        case '\\':
+        case '\"':
+        case '/':
+        case '[':
+        case ']':
+        case '?':
+        case '=':
+        case '{':
+        case '}':
+            return http_request_header_char_invalid(srv, k[i], "invalid character in header key -> 400");
+        default:
+            if (http_header_strict ? (k[i] < 32 || ((unsigned char *)k)[i] >= 127) : k[i] == '\0')
+                return http_request_header_char_invalid(srv, k[i], "invalid character in header key -> 400");
+            break; /* ok */
+        }
+    }
+    return 0;
+}
+
+static int http_request_parse_headers(server *srv, connection *con, buffer *hdrs, parse_header_state *state) {
+    char * const ptr = hdrs->ptr;
+    const unsigned int http_header_strict = (con->conf.http_parseopts & HTTP_PARSEOPT_HEADER_STRICT);
+    size_t i = state->reqline_len;
+
+    if (ptr[i] == ' ' || ptr[i] == '\t') {
+        return http_request_header_line_invalid(srv, 400, "WS at the start of first line -> 400");
+    }
+
+    const size_t ilen = buffer_string_length(hdrs);
+    for (; i < ilen; ++i) {
+        char *k = ptr + i;
+        char *end = k;
+        while ((end = memchr(end, '\n', ilen - i)) && (end[1] == ' ' || end[1] == '\t')) {
+            /* line folding */
+            if (end != k && end[-1] == '\r')
+                end[-1] = ' ';
+            else if (http_header_strict)
+                return http_request_header_line_invalid(srv, 400, "missing CR before LF in header -> 400");
+            end[0] = ' ';
+            end += 2;
+        }
+        if (NULL == end) /*(should not happen)*/
+            return http_request_header_line_invalid(srv, 400, "missing LF in header -> 400");
+        i = end - ptr;
+        if (i+1 == ilen) break; /* end of headers */
+        if (end != k && end[-1] == '\r')
+            --end;
+        else if (http_header_strict)
+            return http_request_header_line_invalid(srv, 400, "missing CR before LF in header -> 400");
+        /* remove trailing whitespace from value */
+        while (end != k && (end[-1] == ' ' || end[-1] == '\t')) --end;
+        /*(for if value is further parsed (in parse_single_header())
+         * and '\0' is expected at end of string)*/
+        *end = '\0';
+
+        char *colon = memchr(k, ':', end - k);
+        if (NULL == colon)
+            return http_request_header_line_invalid(srv, 400, "invalid header missing ':' -> 400");
+
+        char *v = colon + 1;
+
+        /* RFC7230 Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing
+         * 3.2.4.  Field Parsing
+         * [...]
+         * No whitespace is allowed between the header field-name and colon.  In
+         * the past, differences in the handling of such whitespace have led to
+         * security vulnerabilities in request routing and response handling.  A
+         * server MUST reject any received request message that contains
+         * whitespace between a header field-name and colon with a response code
+         * of 400 (Bad Request).  A proxy MUST remove any such whitespace from a
+         * response message before forwarding the message downstream.
+         */
+        /* (line k[-1] is always preceded by a '\n',
+         *  including first header after request-line,
+         *  so no need to check colon != k) */
+        if (colon[-1] == ' ' || colon[-1] == '\t') {
+            if (http_header_strict) {
+                return http_request_header_line_invalid(srv, 400, "invalid whitespace between field-name and colon -> 400");
+            }
+            else {
+                /* remove trailing whitespace from key(if !http_header_strict)*/
+                do { --colon; } while (colon[-1] == ' ' || colon[-1] == '\t');
+            }
+        }
+
+        const int klen = (int)(colon - k);
+        const enum http_header_e id = http_header_hkey_get(k, klen);
+
+        if (id == HTTP_HEADER_OTHER
+            && 0 != http_request_parse_header_other(srv, k, klen, http_header_strict)) {
+            return 400;
+        }
+
+        /* remove leading whitespace from value */
+        while (*v == ' ' || *v == '\t') ++v;
+
+        const int vlen = (int)(end - v);
+        /* empty header-fields are not allowed by HTTP-RFC, we just ignore them */
+        if (0 == vlen) continue; /* ignore header */
+
+        if (http_header_strict) {
+            for (int j = 0; j < vlen; ++j) {
+                if ((((unsigned char *)v)[j] < 32 && v[j] != '\t') || v[j]==127)
+                    return http_request_header_char_invalid(srv, v[j], "invalid character in header -> 400");
+            }
+        }
+        else {
+            for (int j = 0; j < vlen; ++j) {
+                if (v[j] == '\0')
+                    return http_request_header_char_invalid(srv, v[j], "invalid character in header -> 400");
+            }
+        }
+
+        int status = parse_single_header(srv, con, state, id, k, (size_t)klen, v, (size_t)vlen);
+        if (0 != status) return status;
+    }
+
+    return 0;
+}
+
 int http_request_parse(server *srv, connection *con, buffer *hdrs) {
-	char * const ptr = hdrs->ptr;
-	char *value = NULL;
-	size_t i, first, ilen;
-	const unsigned int http_header_strict = (con->conf.http_parseopts & HTTP_PARSEOPT_HEADER_STRICT);
 	int status;

 	parse_header_state state;
@@ -702,137 +827,8 @@
 	status = http_request_parse_reqline(srv, con, hdrs, &state);
 	if (0 != status) return status;

-	i = first = state.reqline_len;
-
-	if (ptr[i] == ' ' || ptr[i] == '\t') {
-		return http_request_header_line_invalid(srv, 400, "WS at the start of first line -> 400");
-	}
-
-	ilen = buffer_string_length(hdrs);
-	for (int is_key = 1, key_len = 0; i < ilen; ++i) {
-		char *cur = ptr + i;
-
-		if (is_key) {
-			/**
-			 * 1*<any CHAR except CTLs or separators>
-			 * CTLs == 0-31 + 127, CHAR = 7-bit ascii (0..127)
-			 *
-			 */
-			switch(*cur) {
-			case ' ':
-			case '\t':
-				/* RFC7230 Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing
-				 * 3.2.4.  Field Parsing
-				 * [...]
-				 * No whitespace is allowed between the header field-name and colon.  In
-				 * the past, differences in the handling of such whitespace have led to
-				 * security vulnerabilities in request routing and response handling.  A
-				 * server MUST reject any received request message that contains
-				 * whitespace between a header field-name and colon with a response code
-				 * of 400 (Bad Request).  A proxy MUST remove any such whitespace from a
-				 * response message before forwarding the message downstream.
-				 */
-				if (http_header_strict)
-					return http_request_header_line_invalid(srv, 400, "invalid whitespace between field-name and colon -> 400");
-				/* skip every thing up to the : */
-				do { ++cur; } while (*cur == ' ' || *cur == '\t');
-				if (*cur != ':') {
-					return http_request_header_line_invalid(srv, 400, "WS character in key -> 400");
-				}
-				/* fall through */
-			case ':':
-				is_key = 0;
-				key_len = i - first;
-				value = cur + 1;
-				i = cur - ptr;
-				break;
-			case '(':
-			case ')':
-			case '<':
-			case '>':
-			case '@':
-			case ',':
-			case ';':
-			case '\\':
-			case '\"':
-			case '/':
-			case '[':
-			case ']':
-			case '?':
-			case '=':
-			case '{':
-			case '}':
-				return http_request_header_char_invalid(srv, *cur, "invalid character in header key -> 400");
-			case '\r':
-				if (ptr[i+1] == '\n' && i == first) {
-					/* End of Header */
-					++i;
-				} else {
-					return http_request_header_line_invalid(srv, 400, "CR without LF -> 400");
-				}
-				break;
-			case '\n':
-				if (http_header_strict) {
-					return http_request_header_line_invalid(srv, 400, "missing CR before LF in header -> 400");
-				} else if (i == first) {
-					/* End of Header */
-					break;
-				}
-				/* fall through */
-			default:
-				if (http_header_strict ? (*cur < 32 || ((unsigned char)*cur) >= 127) : *cur == '\0') {
-					return http_request_header_char_invalid(srv, *cur, "invalid character in header key -> 400");
-				}
-				/* ok */
-				break;
-			}
-		} else {
-			switch(*cur) {
-			case '\r':
-				if (cur[1] != '\n') {
-					return http_request_header_line_invalid(srv, 400, "CR without LF -> 400");
-				}
-				if (cur[2] == ' ' || cur[2] == '\t') { /* header line folding */
-					cur[0] = ' ';
-					cur[1] = ' ';
-					i += 2;
-					continue;
-				}
-				++i;
-				/* fall through */
-			case '\n':
-					if (*cur == '\n') {
-						if (http_header_strict) {
-							return http_request_header_line_invalid(srv, 400, "missing CR before LF in header -> 400");
-						}
-						if (cur[1] == ' ' || cur[1] == '\t') { /* header line folding */
-							cur[0] = ' ';
-							i += 1;
-							continue;
-						}
-					}
-
-					/* End of Headerline */
-					*cur = '\0'; /*(for if value is further parsed and '\0' is expected at end of string)*/
-
-					status = parse_single_header(srv, con, &state, ptr + first, key_len, value, cur - value);
-					if (0 != status) return status;
-
-					first = i+1;
-					is_key = 1;
-					value = NULL;
-				break;
-			case ' ':
-			case '\t':
-				break;
-			default:
-				if (http_header_strict ? (*cur >= 0 && *cur < 32) : *cur == '\0') {
-					return http_request_header_char_invalid(srv, *cur, "invalid character in header -> 400");
-				}
-				break;
-			}
-		}
-	}
+	status = http_request_parse_headers(srv, con, hdrs, &state);
+	if (0 != status) return status;

 	/* do some post-processing */


schema parser BUGFIX memory leak when resolving unique statement

--- src/resolve.c
+++ src/resolve.c
@@ -4603,7 +4603,10 @@
         break;
     }

-    if (has_str && !rc) {
+    if (has_str && (!rc || rc != EXIT_FAILURE)) {
+        /* the string is no more needed in case of success
+         * or fatal error. In case of forward reference,
+         * we will try to resolve the string later */
         lydict_remove(mod->ctx, str_snode);
     }


CFG_STATUSBAR back again

CFG_STATUSBAR back again

--- sw/source/ui/inc/cfgid.h
+++ sw/source/ui/inc/cfgid.h
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: cfgid.h,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.3 $
  *
- *  last change: $Author: os $ $Date: 2000-10-12 08:25:11 $
+ *  last change: $Author: os $ $Date: 2000-10-19 08:24:19 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -65,6 +65,7 @@
 #include <sfx2/sfx.hrc>
 #endif

+#define CFG_STATUSBAR                         (SFX_ITEMTYPE_SW_BEGIN +13)
 #define CFG_SW_MENU             (SFX_ITEMTYPE_SW_BEGIN +16)
 #define CFG_SW_ACCEL            (SFX_ITEMTYPE_SW_BEGIN +17)
 #define CFG_SWWEB_MENU          (SFX_ITEMTYPE_SW_BEGIN +19)


resolve BUGFIX handle resolving refine target

Which is performed on a uses without a parent
since the augment has not been resolved yet.

Fixes #296

--- src/resolve.c
+++ src/resolve.c
@@ -1797,14 +1797,14 @@
     }

     start_parent = lys_parent(start);
-    while (start_parent && (start_parent->nodetype == LYS_USES)) {
+    while ((start_parent->nodetype == LYS_USES) && lys_parent(start_parent)) {
         start_parent = lys_parent(start_parent);
     }

     while (1) {
         sibling = NULL;
         while ((sibling = lys_getnext(sibling, start_parent, module,
-                                      LYS_GETNEXT_WITHCHOICE | LYS_GETNEXT_WITHCASE))) {
+                                      LYS_GETNEXT_WITHCHOICE | LYS_GETNEXT_WITHCASE | LYS_GETNEXT_PARENTUSES))) {
             /* name match */
             if (sibling->name && !strncmp(name, sibling->name, nam_len) && !sibling->name[nam_len]) {
                 r = schema_nodeid_siblingcheck(sibling, &shorthand, id, module, mod_name, mod_name_len, 0, &start_parent);


INTEGRATION: CWS ooo19126 (1.5.528); FILE MERGED 2005/09/05 13:44:59 rt 1.5.528.1: #i54170# Change license header: remove SISSL

--- sw/source/ui/inc/cfgid.h
+++ sw/source/ui/inc/cfgid.h
@@ -1,61 +1,35 @@
 /*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
  *
  *  $RCSfile: cfgid.h,v $
  *
- *  $Revision: 1.5 $
+ *  $Revision: 1.6 $
  *
- *  last change: $Author: pjunck $ $Date: 2004-10-22 13:58:27 $
+ *  last change: $Author: rt $ $Date: 2005-09-09 09:03:00 $
  *
- *  The Contents of this file are made available subject to the terms of
- *  either of the following licenses
- *
- *         - GNU Lesser General Public License Version 2.1
- *         - Sun Industry Standards Source License Version 1.1
- *
- *  Sun Microsystems Inc., October, 2000
- *
- *  GNU Lesser General Public License Version 2.1
- *  =============================================
- *  Copyright 2000 by Sun Microsystems, Inc.
- *  901 San Antonio Road, Palo Alto, CA 94303, USA
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License version 2.1, as published by the Free Software Foundation.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- *  MA  02111-1307  USA
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
  *
  *
- *  Sun Industry Standards Source License Version 1.1
- *  =================================================
- *  The contents of this file are subject to the Sun Industry Standards
- *  Source License Version 1.1 (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.openoffice.org/license.html.
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
  *
- *  Software provided under this License is provided on an "AS IS" basis,
- *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- *  See the License for the specific provisions governing your rights and
- *  obligations concerning the Software.
+ *    This library is free software; you can redistribute it and/or
+ *    modify it under the terms of the GNU Lesser General Public
+ *    License version 2.1, as published by the Free Software Foundation.
  *
- *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *    This library is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *    Lesser General Public License for more details.
  *
- *  Copyright: 2000 by Sun Microsystems, Inc.
- *
- *  All Rights Reserved.
- *
- *  Contributor(s): _______________________________________
- *
+ *    You should have received a copy of the GNU Lesser General Public
+ *    License along with this library; if not, write to the Free Software
+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ *    MA  02111-1307  USA
  *
  ************************************************************************/
 #ifndef _CFGID_H


Fix close_popups for xdg-shell

Fix close_popups for xdg-shell

wlr_xdg_popup_destroy will destroy popups, so we need to walk the tree
carefully. It's enough to just destroy all direct children, since destroying
the parent will also destroy all children.

--- sway/desktop/xdg_shell.c
+++ sway/desktop/xdg_shell.c
@@ -236,19 +236,11 @@
 	}
 }

-static void close_popups_iterator(struct wlr_surface *surface,
-		int sx, int sy, void *data) {
-	struct wlr_xdg_surface *xdg_surface =
-		wlr_xdg_surface_from_wlr_surface(surface);
-	if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP
-			&& xdg_surface->popup) {
-		wlr_xdg_popup_destroy(xdg_surface);
-	}
-}
-
 static void close_popups(struct sway_view *view) {
-	wlr_xdg_surface_for_each_popup(view->wlr_xdg_surface,
-			close_popups_iterator, NULL);
+	struct wlr_xdg_popup *popup, *tmp;
+	wl_list_for_each_safe(popup, tmp, &view->wlr_xdg_surface->popups, link) {
+		wlr_xdg_popup_destroy(popup->base);
+	}
 }

 static void destroy(struct sway_view *view) {


ENH: updated documentation

ENH: updated documentation

--- Code/Common/itkInteriorExteriorSpatialFunction.h
+++ Code/Common/itkInteriorExteriorSpatialFunction.h
@@ -70,7 +70,7 @@

 template <unsigned int VImageDimension=3,typename TInput=Point<double,3> >
 class ITK_EXPORT InteriorExteriorSpatialFunction : public
-  SpatialFunction<bool, VImageDimension,TInput >
+  SpatialFunction<bool, VImageDimension, TInput >
 {
 public:
   /** Standard class typedefs. */


Changing type of 'hours', 'httpStatus' and 'protocols' arrays to uint64_t

--- src/results.h
+++ src/results.h
@@ -25,11 +25,11 @@
 	uint64_t hitsIPv4;
 	uint64_t hitsIPv6;
 	uint64_t countries[255];
-	int hours[24];
-	int httpStatus[STATUS_CODE_MAX];
+	uint64_t hours[24];
+	uint64_t httpStatus[STATUS_CODE_MAX];
 	double runtime;
 	char timeStamp[20];
-	int protocols[2];
+	uint64_t protocols[2];
 };

 typedef struct results Results;


add SPI PORT for pull up resistors

add SPI PORT for pull up resistors

--- lib/spi/spi.h
+++ lib/spi/spi.h
@@ -10,23 +10,27 @@
  * the Makefile
  */
 #ifndef
-#define DDR_SPI	DDRB
-#define
-
-#ifndef
-#define DD_MOSI	DDB3
+#define DDR_SPI		DDRB
 #endif

 #ifndef
-#define DD_SCK	DDB5
+#define PORT_SPI	PORTB
 #endif

 #ifndef
-#define DD_MISO	DDB4
+#define DD_MOSI		DDB3
 #endif

 #ifndef
-#define DD_SS	DDB2
+#define DD_SCK		DDB5
+#endif
+
+#ifndef
+#define DD_MISO		DDB4
+#endif
+
+#ifndef
+#define DD_SS		DDB2
 #endif

 #include <inttypes.h>


More config tweaks

More config tweaks

--- src/config.c
+++ src/config.c
@@ -6,13 +6,13 @@
     luaL_openlibs(L);

     lua_newtable(L);
-    #define F(f,t,...) do {\
+    #define F(f,s) do {\
         lua_pushstring(L, #f);\
-        lua_push##t(L, __VA_ARGS__);\
+        lua_pushstring(L, s);\
         lua_settable(L, -3);\
     } while (0)
-    F(compiler, string, "cc");
-    F(lightbuild, string, "lightbuild");
+    F(compiler, "cc");
+    F(lightbuild, "lightbuild");
     #undef F
     lua_setglobal(L, "config");
     return L;


Turn off logging of secrets

Turn off logging of secrets

--- lib/src/tls.c
+++ lib/src/tls.c
@@ -155,7 +155,7 @@
 #define HKDF_BASE_LABEL "quic "
 #define st_quicly_cipher_context_t cipher_ctx
 #define quicly_hexdump(a, b, c) hex2str(a, b)
-#define QUICLY_DEBUG 1
+#define QUICLY_DEBUG 0

 // from quicly


format the code alignment.

format the code alignment.

--- src/config.c
+++ src/config.c
@@ -227,8 +227,8 @@
     }
     /* FIXME can't support wrap line */
     if (!parse_line(config_input_line)) {
-	    do_debug(LOG_INFO, "parse_config_file: unknown keyword in '%s' at file %s\n",
-    			config_input_line, file_name);
+        do_debug(LOG_INFO, "parse_config_file: unknown keyword in '%s' at file %s\n",
+                 config_input_line, file_name);
     }

 final:
@@ -253,7 +253,7 @@
     conf.debug_level = LOG_ERR;
     conf.print_detail = FALSE;
     while (fgets(config_input_line, LEN_1024, fp)) {
-		process_input_line(config_input_line, LEN_1024, file_name);
+        process_input_line(config_input_line, LEN_1024, file_name);
     }
     if (fclose(fp) < 0) {
         do_debug(LOG_FATAL, "fclose error:%s", strerror(errno));
@@ -299,7 +299,7 @@
             }
             memset(config_input_line, '\0', LEN_1024);
             while (fgets(config_input_line, LEN_1024, fp)) {
-				process_input_line(config_input_line, LEN_1024, buf);
+                process_input_line(config_input_line, LEN_1024, buf);
             }
             if (fclose(fp) < 0) {
                 do_debug(LOG_FATAL, "fclose error:%s", strerror(errno));


Randomize the order of TPs

Randomize the order of TPs

--- lib/src/tls.c
+++ lib/src/tls.c
@@ -392,8 +392,9 @@
         if (tp >= TP_MAX) {
             uint16_t unknown_len;
             i = dec(&unknown_len, buf, len, i, sizeof(unknown_len), "%u");
-            warn(WRN, "\t" BLD RED "unknown tp" NRM " (0x%04x w/len %u) = %s",
-                 tp, unknown_len, hex2str(&buf[i], unknown_len));
+            warn(WRN, "\t" BLD "%s tp" NRM " (0x%04x w/len %u) = %s",
+                 (tp & 0xff00) == 0xff00 ? YEL "private" : RED "unknown", tp,
+                 unknown_len, hex2str(&buf[i], unknown_len));
             i += unknown_len;
             continue;
         }
@@ -648,29 +649,79 @@
     uint16_t i = sizeof(uint16_t);
     const uint16_t len = sizeof(c->tls.tp_buf);

-    if (c->is_clnt) {
-        enc_tp(c, TP_IMSU, (uint64_t)c->tp_in.max_streams_uni);
-        enc_tp(c, TP_IMSD_U, c->tp_in.max_strm_data_uni);
-    } else {
-        enc_tp_buf(c, TP_SRT, c->scid->srt, sizeof(c->scid->srt));
-        if (c->odcid.len)
-            enc_tp_buf(c, TP_OCID, c->odcid.id, c->odcid.len);
-    }
-    enc_tp(c, TP_IMSB, (uint64_t)c->tp_in.max_streams_bidi);
-    enc_tp(c, TP_IDTO, c->tp_in.idle_to);
-    enc_tp(c, TP_IMSD_BR, c->tp_in.max_strm_data_bidi_remote);
-    enc_tp(c, TP_IMSD_BL, c->tp_in.max_strm_data_bidi_local);
-    enc_tp(c, TP_IMD, c->tp_in.max_data);
-    enc_tp(c, TP_ADE, c->tp_in.ack_del_exp);
-    enc_tp(c, TP_MAD, c->tp_in.max_ack_del);
-    enc_tp(c, TP_MPS, w_mtu(c->w));
-
     // add a grease tp
     uint8_t grease[18];
     rand_bytes(&grease, sizeof(grease));
     const uint16_t grease_type = 0xff00 + grease[0];
     const uint16_t grease_len = grease[1] & 0x0f;
-    enc_tp_buf(c, grease_type, &grease[2], grease_len);
+
+    uint16_t tp_order[TP_MAX + 1] = {TP_OCID, TP_IDTO,    TP_SRT,     TP_MPS,
+                                     TP_IMD,  TP_IMSD_BL, TP_IMSD_BR, TP_IMSD_U,
+                                     TP_IMSB, TP_IMSU,    TP_ADE,     TP_MAD,
+                                     TP_DMIG, TP_PRFA,    grease_type};
+
+    // modern version of Fisher-Yates
+    // https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
+    for (size_t j = TP_MAX; j >= 1; j--) {
+        const size_t r = w_rand_uniform(j);
+        const uint16_t tmp = tp_order[r];
+        tp_order[r] = tp_order[j];
+        tp_order[j] = tmp;
+    }
+
+    for (size_t j = 0; j <= TP_MAX; j++)
+        switch (tp_order[j]) {
+        case TP_IMSU:
+            if (c->is_clnt)
+                enc_tp(c, TP_IMSU, (uint64_t)c->tp_in.max_streams_uni);
+            break;
+        case TP_IMSD_U:
+            if (c->is_clnt)
+                enc_tp(c, TP_IMSD_U, c->tp_in.max_strm_data_uni);
+            break;
+        case TP_SRT:
+            if (!c->is_clnt)
+                enc_tp_buf(c, TP_SRT, c->scid->srt, sizeof(c->scid->srt));
+            break;
+        case TP_OCID:
+            if (!c->is_clnt && c->odcid.len)
+                enc_tp_buf(c, TP_OCID, c->odcid.id, c->odcid.len);
+            break;
+        case TP_IMSB:
+            enc_tp(c, TP_IMSB, (uint64_t)c->tp_in.max_streams_bidi);
+            break;
+        case TP_IDTO:
+            enc_tp(c, TP_IDTO, c->tp_in.idle_to);
+            break;
+        case TP_IMSD_BR:
+            enc_tp(c, TP_IMSD_BR, c->tp_in.max_strm_data_bidi_remote);
+            break;
+        case TP_IMSD_BL:
+            enc_tp(c, TP_IMSD_BL, c->tp_in.max_strm_data_bidi_local);
+            break;
+        case TP_IMD:
+            enc_tp(c, TP_IMD, c->tp_in.max_data);
+            break;
+        case TP_ADE:
+            enc_tp(c, TP_ADE, c->tp_in.ack_del_exp);
+            break;
+        case TP_MAD:
+            enc_tp(c, TP_MAD, c->tp_in.max_ack_del);
+            break;
+        case TP_MPS:
+            enc_tp(c, TP_MPS, w_mtu(c->w));
+            break;
+        case TP_PRFA:
+        case TP_DMIG:
+            // TODO: unhandled
+            break;
+        default:
+            if (tp_order[j] == grease_type)
+                enc_tp_buf(c, grease_type, &grease[2], grease_len);
+            else
+                die("unknown tp 0x%04x", tp_order[j]);
+            break;
+        }

     // encode length of all transport parameters
     const uint16_t enc_len = i - sizeof(uint16_t);


[NFC] Move the export attribute after extern "C".

Not all compilers support attributes before `extern "C"`. gcc is the main one
that doesn't support it.

git-svn-id: 62ef012455b6b8fcec9c41ca270ebf409aae1006@358301 91177308-0d34-0410-b5e6-96231b3b80d8

--- src/config.h
+++ src/config.h
@@ -70,23 +70,22 @@
 #define _LIBUNWIND_WEAK_ALIAS(name, aliasname)                                 \
   __asm__(".globl " SYMBOL_NAME(aliasname));                                   \
   __asm__(SYMBOL_NAME(aliasname) " = " SYMBOL_NAME(name));                     \
-  _LIBUNWIND_EXPORT                                                            \
-  extern "C" __typeof(name) aliasname __attribute__((weak_import));
+  extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname                        \
+      __attribute__((weak_import));
 #elif defined(__ELF__)
 #define _LIBUNWIND_WEAK_ALIAS(name, aliasname)                                 \
-  _LIBUNWIND_EXPORT                                                            \
-  extern "C" __typeof(name) aliasname __attribute__((weak, alias(#name)));
+  extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname                        \
+      __attribute__((weak, alias(#name)));
 #elif defined(_WIN32)
 #if defined(__MINGW32__)
 #define _LIBUNWIND_WEAK_ALIAS(name, aliasname)                                 \
-  _LIBUNWIND_EXPORT                                                            \
-  extern "C" __typeof(name) aliasname __attribute__((alias(#name)));
+  extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname                        \
+      __attribute__((alias(#name)));
 #else
 #define _LIBUNWIND_WEAK_ALIAS(name, aliasname)                                 \
   __pragma(comment(linker, "/alternatename:" SYMBOL_NAME(aliasname) "="        \
                                              SYMBOL_NAME(name)))               \
-  _LIBUNWIND_EXPORT \
-  extern "C" __typeof(name) aliasname;
+  extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname;
 #endif
 #else
 #error Unsupported target


Marginally more robust glibc version test for sync_file_range detection.

--- src/config.h
+++ src/config.h
@@ -57,7 +57,7 @@
 #ifdef __linux__
 #include <linux/version.h>
 #include <features.h>
-#ifdef __GLIBC__
+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
 #if (LINUX_VERSION_CODE >= 0x020611 && __GLIBC_PREREQ(2, 6))
 #define HAVE_SYNC_FILE_RANGE 1
 #endif


Adding missing variant.h

Adding missing variant.h

error: pathspec 'variants/arduino_zero/variant.h' did not match any file(s) known to git

--- variants/arduino_zero/variant.h
+++ variants/arduino_zero/variant.h
@@ -0,0 +1,240 @@
+/*
+  Copyright (c) 2014 Arduino.  All right reserved.
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the GNU Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#ifndef _VARIANT_ARDUINO_ZERO_
+#define _VARIANT_ARDUINO_ZERO_
+
+/*----------------------------------------------------------------------------
+ *        Definitions
+ *----------------------------------------------------------------------------*/
+
+/** Frequency of the board main oscillator */
+#define VARIANT_MAINOSC		(32768ul)
+
+/** Master clock frequency */
+#define VARIANT_MCK			  (48000000ul)
+
+/*----------------------------------------------------------------------------
+ *        Headers
+ *----------------------------------------------------------------------------*/
+
+#include "Arduino.h"
+#ifdef __cplusplus
+//#include "USARTClass.h"
+#endif
+
+#ifdef __cplusplus
+extern "C"{
+#endif // __cplusplus
+
+/**
+ * Libc porting layers
+ */
+#if defined (  __GNUC__  )
+#    include <syscalls.h> /** RedHat Newlib minimal stub */
+#endif
+
+/*----------------------------------------------------------------------------
+ *        Pins
+ *----------------------------------------------------------------------------*/
+
+// Number of pins defined in PinDescription array
+#define PINS_COUNT           (25u)
+#define NUM_DIGITAL_PINS     (19u)
+#define NUM_ANALOG_INPUTS    (5u)
+#define NUM_ANALOG_OUTPUTS   (1u)
+
+#define digitalPinToPort(P)        ( g_APinDescription[P].pPort )
+#define digitalPinToBitMask(P)     ( g_APinDescription[P].ulPin )
+#define digitalPinToTimer(P)       (  )
+//#define analogInPinToBit(P)        ( )
+#define portOutputRegister(port)   ( &(port->PIO_ODSR) )
+#define portInputRegister(port)    ( &(port->PIO_PDSR) )
+//#define portModeRegister(P)        (  )
+#define digitalPinHasPWM(P)        ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER )
+
+// Interrupts
+#define digitalPinToInterrupt(p)  ((p) < NUM_DIGITAL_PINS ? (p) : -1)
+
+// LEDs
+#define PIN_LED_13           (13u)
+#define PIN_LED_RXL          (72u)
+#define PIN_LED_TXL          (73u)
+#define PIN_LED              PIN_LED_13
+#define PIN_LED2             PIN_LED_RXL
+#define PIN_LED3             PIN_LED_TXL
+#define LED_BUILTIN          PIN_LED_13
+
+/*
+ * SPI Interfaces
+ */
+#define SPI_INTERFACES_COUNT 1
+
+#define SPI_INTERFACE        SPI0
+#define SPI_INTERFACE_ID     ID_SPI0
+#define SPI_CHANNELS_NUM 4
+#define PIN_SPI_SS0          (77u)
+#define PIN_SPI_SS1          (87u)
+#define PIN_SPI_SS2          (86u)
+#define PIN_SPI_SS3          (78u)
+#define PIN_SPI_MOSI         (75u)
+#define PIN_SPI_MISO         (74u)
+#define PIN_SPI_SCK          (76u)
+#define BOARD_SPI_SS0        (10u)
+#define BOARD_SPI_SS1        (4u)
+#define BOARD_SPI_SS2        (52u)
+#define BOARD_SPI_SS3        PIN_SPI_SS3
+#define BOARD_SPI_DEFAULT_SS BOARD_SPI_SS3
+
+#define BOARD_PIN_TO_SPI_PIN(x) \
+	(x==BOARD_SPI_SS0 ? PIN_SPI_SS0 : \
+	(x==BOARD_SPI_SS1 ? PIN_SPI_SS1 : \
+	(x==BOARD_SPI_SS2 ? PIN_SPI_SS2 : PIN_SPI_SS3 )))
+#define BOARD_PIN_TO_SPI_CHANNEL(x) \
+	(x==BOARD_SPI_SS0 ? 0 : \
+	(x==BOARD_SPI_SS1 ? 1 : \
+	(x==BOARD_SPI_SS2 ? 2 : 3)))
+
+static const uint8_t SS   = BOARD_SPI_SS0;
+static const uint8_t SS1  = BOARD_SPI_SS1;
+static const uint8_t SS2  = BOARD_SPI_SS2;
+static const uint8_t SS3  = BOARD_SPI_SS3;
+static const uint8_t MOSI = PIN_SPI_MOSI;
+static const uint8_t MISO = PIN_SPI_MISO;
+static const uint8_t SCK  = PIN_SPI_SCK;
+
+/*
+ * Wire Interfaces
+ */
+#define WIRE_INTERFACES_COUNT 2
+
+#define PIN_WIRE_SDA         (20u)
+#define PIN_WIRE_SCL         (21u)
+#define WIRE_INTERFACE       TWI1
+#define WIRE_INTERFACE_ID    ID_TWI1
+#define WIRE_ISR_HANDLER     TWI1_Handler
+#define WIRE_ISR_ID          TWI1_IRQn
+
+#define PIN_WIRE1_SDA        (70u)
+#define PIN_WIRE1_SCL        (71u)
+#define WIRE1_INTERFACE      TWI0
+#define WIRE1_INTERFACE_ID   ID_TWI0
+#define WIRE1_ISR_HANDLER    TWI0_Handler
+#define WIRE1_ISR_ID         TWI0_IRQn
+
+/*
+ * UART/USART Interfaces
+ */
+// Serial
+#define PINS_UART            (81u)
+// Serial1
+#define PINS_USART0          (82u)
+// Serial2
+#define PINS_USART1          (83u)
+// Serial3
+#define PINS_USART3          (84u)
+
+/*
+ * USB Interfaces
+ */
+#define PINS_USB             (85u)
+
+/*
+ * Analog pins
+ */
+static const uint8_t A0  = 20 ;
+static const uint8_t A1  = 21 ;
+static const uint8_t A2  = 22 ;
+static const uint8_t A3  = 23 ;
+static const uint8_t A4  = 24 ;
+static const uint8_t A5  = 25 ;
+#define ADC_RESOLUTION		12
+
+/*
+ * DAC
+ */
+#define DACC_INTERFACE		   DACC
+#define DACC_INTERFACE_ID	   ID_DACC
+#define DACC_RESOLUTION		   12
+#define DACC_ISR_HANDLER     DACC_Handler
+#define DACC_ISR_ID          DACC_IRQn
+
+/*
+ * PWM
+ */
+#define PWM_INTERFACE		PWM
+#define PWM_INTERFACE_ID	ID_PWM
+#define PWM_FREQUENCY		1000
+#define PWM_MAX_DUTY_CYCLE	255
+#define PWM_MIN_DUTY_CYCLE	0
+#define PWM_RESOLUTION		8
+
+/*
+ * TC
+ */
+#define TC_INTERFACE        TC0
+#define TC_INTERFACE_ID     ID_TC0
+#define TC_FREQUENCY        1000
+#define TC_MAX_DUTY_CYCLE   255
+#define TC_MIN_DUTY_CYCLE   0
+#define TC_RESOLUTION		8
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+ *        Arduino objects - C++ only
+ *----------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+
+//extern UARTClass Serial;
+//extern USARTClass Serial1;
+//extern USARTClass Serial2;
+//extern USARTClass Serial3;
+
+#endif
+
+// These serial port names are intended to allow libraries and architecture-neutral
+// sketches to automatically default to the correct port name for a particular type
+// of use.  For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
+// the first hardware serial port whose RX/TX pins are not dedicated to another use.
+//
+// SERIAL_PORT_MONITOR        Port which normally prints to the Arduino Serial Monitor
+//
+// SERIAL_PORT_USBVIRTUAL     Port which is USB virtual serial
+//
+// SERIAL_PORT_LINUXBRIDGE    Port which connects to a Linux system via Bridge library
+//
+// SERIAL_PORT_HARDWARE       Hardware serial port, physical RX & TX pins.
+//
+// SERIAL_PORT_HARDWARE_OPEN  Hardware serial ports which are open for use.  Their RX & TX
+//                            pins are NOT connected to anything by default.
+#define SERIAL_PORT_MONITOR         Serial
+#define SERIAL_PORT_USBVIRTUAL      SerialUSB
+#define SERIAL_PORT_HARDWARE_OPEN   Serial1
+#define SERIAL_PORT_HARDWARE_OPEN1  Serial2
+#define SERIAL_PORT_HARDWARE_OPEN2  Serial3
+#define SERIAL_PORT_HARDWARE        Serial
+#define SERIAL_PORT_HARDWARE1       Serial1
+#define SERIAL_PORT_HARDWARE2       Serial2
+#define SERIAL_PORT_HARDWARE3       Serial3
+
+#endif /* _VARIANT_ARDUINO_ZERO_ */
+


Mark ALignedBit as deprecated.

Mark ALignedBit as deprecated.

--- Eigen/src/Core/util/Constants.h
+++ Eigen/src/Core/util/Constants.h
@@ -140,7 +140,7 @@
   */
 const unsigned int DirectAccessBit = 0x40;

-/* \ingroup flags
+/** \deprecated \ingroup flags
   *
   * means the first coefficient packet is guaranteed to be aligned.
   * An expression cannot has the AlignedBit without the PacketAccessBit flag.


gaaaaaaaaaaaaaaaaaah
can't believe that 3 people wasted so much time because of a missing &
!!!!!
and this time MSVC didn't catch it so it was really copying the vector
on the stack at an unaligned location!

--HG--
extra : convert_revision : svn%3A283d02a7-25f6-0310-bc7c-ecb5cbfe19da/trunk/kdesupport/eigen2%40906184

--- Eigen/src/Geometry/AlignedBox.h
+++ Eigen/src/Geometry/AlignedBox.h
@@ -57,7 +57,7 @@
   { setNull(); }

   /** Constructs a box with extremities \a _min and \a _max. */
-  inline AlignedBox(const VectorType& _min, const VectorType _max) : m_min(_min), m_max(_max) {}
+  inline AlignedBox(const VectorType& _min, const VectorType& _max) : m_min(_min), m_max(_max) {}

   /** Constructs a box containing a single point \a p. */
   inline explicit AlignedBox(const VectorType& p) : m_min(p), m_max(p) {}


Pass Vector3 type by reference

Pass Vector3 type by reference

--- Eigen/src/Geometry/Quaternion.h
+++ Eigen/src/Geometry/Quaternion.h
@@ -162,7 +162,7 @@
   { return coeffs().isApprox(other.coeffs(), prec); }

 	/** return the result vector of \a v through the rotation*/
-  EIGEN_STRONG_INLINE Vector3 _transformVector(Vector3 v) const;
+  EIGEN_STRONG_INLINE Vector3 _transformVector(const Vector3 &v) const;

   /** \returns \c *this with scalar type casted to \a NewScalarType
     *
@@ -462,7 +462,7 @@
   */
 template <class Derived>
 EIGEN_STRONG_INLINE typename QuaternionBase<Derived>::Vector3
-QuaternionBase<Derived>::_transformVector(Vector3 v) const
+QuaternionBase<Derived>::_transformVector(const Vector3 &v) const
 {
     // Note that this algorithm comes from the optimization by hand
     // of the conversion to a Matrix followed by a Matrix/Vector product.


Make sure that optical PHYs work ...

Make sure that optical PHYs work ...

Submitted by:	Chelsio Inc.
MFC after:	1 day


Catch up with the moving target: merge the change from rev 1.19 of the
now dead sys/pci/if_pdq.c which has been committed about by the same
time i made my tests with Matt's code.

LINT should compile now again.

Well, that's a clear case where ``CVS writer locks'' would certainly
(not) have helped. :-]

--- sys/dev/pdq/pdq_ifsubr.c
+++ sys/dev/pdq/pdq_ifsubr.c
@@ -21,7 +21,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $Id: pdq_ifsubr.c,v 1.1.1.1 1997/01/17 23:19:49 joerg Exp $
+ * $Id: pdq_ifsubr.c,v 1.2 1997/01/17 23:54:32 joerg Exp $
  *
  */

@@ -253,17 +253,19 @@
     size_t num_addrs)
 {
     pdq_softc_t *sc = (pdq_softc_t *) pdq->pdq_os_ctx;
-    struct ether_multistep step;
-    struct ether_multi *enm;
-
-    ETHER_FIRST_MULTI(step, &sc->sc_ac, enm);
-    while (enm != NULL && num_addrs > 0) {
-	((u_short *) addr->lanaddr_bytes)[0] = ((u_short *) enm->enm_addrlo)[0];
-	((u_short *) addr->lanaddr_bytes)[1] = ((u_short *) enm->enm_addrlo)[1];
-	((u_short *) addr->lanaddr_bytes)[2] = ((u_short *) enm->enm_addrlo)[2];
-	ETHER_NEXT_MULTI(step, enm);
-	addr++;
-	num_addrs--;
+    struct ifmultiaddr *ifma;
+
+    for (ifma = sc->sc_if.if_multiaddrs.lh_first; ifma && num_addrs > 0;
+	 ifma = ifma->ifma_link.le_next) {
+	    char *mcaddr;
+	    if (ifma->ifma_addr->sa_family != AF_LINK)
+		    continue;
+	    mcaddr = LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
+	    ((u_short *) addr->lanaddr_bytes)[0] = ((u_short *) mcaddr)[0];
+	    ((u_short *) addr->lanaddr_bytes)[1] = ((u_short *) mcaddr)[1];
+	    ((u_short *) addr->lanaddr_bytes)[2] = ((u_short *) mcaddr)[2];
+	    addr++;
+	    num_addrs--;
     }
 }
 @@ -335,22 +337,14 @@
 	}

 	case SIOCADDMULTI:
-	case SIOCDELMULTI: {
-	    /*
-	     * Update multicast listeners
-	     */
-	    if (cmd == SIOCADDMULTI)
-		error = ether_addmulti((struct ifreq *)data, &sc->sc_ac);
-	    else
-		error = ether_delmulti((struct ifreq *)data, &sc->sc_ac);
-
-	    if (error == ENETRESET) {
+	case SIOCDELMULTI:
+		/*
+		 * Update multicast listeners
+		 */
 		if (sc->sc_if.if_flags & IFF_RUNNING)
-		    pdq_run(sc->sc_pdq);
+			pdq_run(sc->sc_pdq);
 		error = 0;
-	    }
-	    break;
-	}
+		break;

 #if defined(SIOCSIFMTU)
 #if !defined(ifr_mtu)
@@ -403,6 +397,8 @@
     ifp->if_ioctl = pdq_ifioctl;
     ifp->if_output = fddi_output;
     ifp->if_start = pdq_ifstart;
+#warning "Implement fddi_resolvemulti!"
+/*    ifp->if_resolvemulti = ether_resolvemulti; XXX */

     if_attach(ifp);
     fddi_ifattach(ifp);


Include Peter Wemm's renaming and restructuring

Change from lkm to kld

--- sys/dev/vinum/vinumext.h
+++ sys/dev/vinum/vinumext.h
@@ -33,7 +33,7 @@
  * otherwise) arising in any way out of the use of this software, even if
  * advised of the possibility of such damage.
  *
- * $Id: vinumext.h,v 1.4 1998/12/28 04:56:24 peter Exp $
+ * $Id: vinumext.h,v 1.18 1999/01/15 02:41:16 grog Exp grog $
  */

 /* vinumext.h: external definitions */
@@ -58,9 +58,9 @@
 #ifdef KERNEL
 int give_sd_to_plex(int plexno, int sdno);
 int give_plex_to_volume(int volno, int plexno);
-int check_drive(char *);
-enum drive_label_info read_drive_label(struct drive *drive);
-int parse_config(char *, struct keywordset *);
+struct drive *check_drive(char *);
+enum drive_label_info read_drive_label(struct drive *, int);
+int parse_config(char *, struct keywordset *, int);
 int parse_user_config(char *cptr, struct keywordset *keyset);
 u_int64_t sizespec(char *spec);
 int volume_index(struct volume *volume);
@@ -81,17 +81,18 @@
 void free_plex(int plexno);
 int get_empty_volume(void);
 int find_volume(const char *name, int create);
-void config_subdisk(void);
-void config_plex(void);
-void config_volume(void);
-void config_drive(void);
+void config_subdisk(int);
+void config_plex(int);
+void config_volume(int);
+void config_drive(int);
 void updateconfig(int);
 void update_sd_config(int sdno, int kernelstate);
 void update_plex_config(int plexno, int kernelstate);
 void update_volume_config(int volno, int kernelstate);
 void update_config(void);
 void drive_io_done(struct buf *);
-int save_config(void);
+void save_config(void);
+void daemon_save_config(void);
 void write_config(char *, int);
 int start_config(void);
 void finish_config(int);
@@ -102,16 +103,17 @@
 void remove_volume_entry(int volno, int force, int recurse);

 void checkernel(char *);
-int open_drive(struct drive *, struct proc *);
+int open_drive(struct drive *, struct proc *, int);
 void close_drive(struct drive *drive);
-int driveio(struct drive *, void *, size_t, off_t, int);
+int driveio(struct drive *, char *, size_t, off_t, int);
 /* #define read_drive(a, b, c, d) driveio (a, b, c, d, B_READ)
    #define write_drive(a, b, c, d) driveio (a, b, c, d, B_WRITE) */
 int set_drive_parms(struct drive *drive);
-int init_drive(struct drive *);
+int init_drive(struct drive *, int);
 /* void throw_rude_remark (int, struct _ioctl_reply *, char *, ...); XXX */
 void throw_rude_remark(int, char *,...);

+/* XXX die die */
 int read_drive(struct drive *drive, void *buf, size_t length, off_t offset);
 int write_drive(struct drive *drive, void *buf, size_t length, off_t offset);
 void format_config(char *config, int len);
@@ -119,6 +121,8 @@
 void free_drive(struct drive *drive);
 void down_drive(struct drive *drive);
 void remove_drive(int driveno);
+
+void vinum_scandisk(char *drivename[], int drives);

 /* I/O */
 d_open_t vinumopen;
@@ -132,6 +136,7 @@

 int vinumstart(struct buf *bp, int reviveok);
 int launch_requests(struct request *rq, int reviveok);
+void sdio(struct buf *bp);

 /* XXX Do we need this? */
 int vinumpart(dev_t);
@@ -145,19 +150,25 @@

 void expand_table(void **, int, int);

-void add_defective_region(struct plex *plex, off_t offset, size_t length);
-void add_unmapped_region(struct plex *plex, off_t offset, size_t length);
-void rebuild_plex_unmappedlist(struct plex *plex);
 struct request;
 struct rqgroup *allocrqg(struct request *rq, int elements);
 void deallocrqg(struct rqgroup *rqg);

+/* Device number decoding */
+int Volno(dev_t x);
+int Plexno(dev_t x);
+int Sdno(dev_t x);
+
 /* State transitions */
-int set_drive_state(int driveno, enum drivestate state, int force);
+int set_drive_state(int driveno, enum drivestate state, enum setstateflags flags);
 int set_sd_state(int sdno, enum sdstate state, enum setstateflags flags);
 enum requeststatus checksdstate(struct sd *sd, struct request *rq, daddr_t diskaddr, daddr_t diskend);
 int set_plex_state(int plexno, enum plexstate state, enum setstateflags flags);
 int set_volume_state(int volumeno, enum volumestate state, enum setstateflags flags);
+void update_sd_state(int sdno);
+void update_plex_state(int plexno);
+void update_volume_state(int volno);
+void invalidate_subdisks(struct plex *, enum sdstate);
 void get_volume_label(struct volume *vol, struct disklabel *lp);
 int write_volume_label(int);
 void start_object(struct vinum_ioctl_msg *);
@@ -168,10 +179,11 @@
 int initsd(int);

 int restart_plex(int plexno);
-int revive_block(int plexno);
+int revive_read(struct sd *sd);
+int revive_block(int sdno);

 /* Auxiliary functions */
-enum sdstates sdstatemap(struct plex *plex, int *sddowncount);
+enum sdstates sdstatemap(struct plex *plex);
 enum volplexstate vpstate(struct plex *plex);
 #endif

@@ -194,6 +206,8 @@
 void resetstats(struct vinum_ioctl_msg *msg);

 /* Locking */
+int lockdrive(struct drive *drive);
+void unlockdrive(struct drive *drive);
 int lockvol(struct volume *vol);
 void unlockvol(struct volume *vol);
 int lockplex(struct plex *plex);
@@ -202,3 +216,11 @@
 void unlockrange(struct plex *plex, off_t first, off_t last);
 int lock_config(void);
 void unlock_config(void);
+
+/* Dmon */
+
+void vinum_daemon(void);
+int vinum_finddaemon(void);
+int vinum_setdaemonopts(int);
+extern struct daemonq *daemonq;				    /* daemon's work queue */
+extern struct daemonq *dqend;				    /* and the end of the queue */


Initialize the PIIX timecounter in piix_attach(), which is called only once, instead of doing it in piix_probe(), which is called every time the PCI bus is rescanned.

--- sys/i386/i386/mp_clock.c
+++ sys/i386/i386/mp_clock.c
@@ -101,12 +101,11 @@
 	switch (pci_get_devid(dev)) {
 	case 0x71138086:
 		d = pci_read_config(dev, 0x4, 2);
-		if (!(d & 1))
-			return 0;	/* IO space not mapped */
-		d = pci_read_config(dev, 0x40, 4);
-		piix_timecounter_address = (d & 0xffc0) + 8;
-		piix_timecounter.tc_frequency = piix_freq;
-		tc_init(&piix_timecounter);
+		if (d & 1)
+			return (0);
+		printf("PIIX I/O space not mapped\n");
+		return (ENXIO);
+	default:
 		return (ENXIO);
 	};
 	return (ENXIO);
@@ -115,8 +114,13 @@
 static int
 piix_attach (device_t dev)
 {
-
-	return 0;
+	u_int32_t	d;
+
+	d = pci_read_config(dev, 0x40, 4);
+	piix_timecounter_address = (d & 0xffc0) + 8;
+	piix_timecounter.tc_frequency = piix_freq;
+	tc_init(&piix_timecounter);
+	return (0);
 }

 static device_method_t piix_methods[] = {


Pull in prototype for splq().

Pull in prototype for splq().

--- sys/i386/isa/ipl_funcs.c
+++ sys/i386/isa/ipl_funcs.c
@@ -23,13 +23,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$Id: ipl_funcs.c,v 1.16 1999/04/21 07:26:27 peter Exp $
+ *	$Id: ipl_funcs.c,v 1.17 1999/04/28 01:04:15 luoqi Exp $
  */

 #include <sys/types.h>
 #include <sys/systm.h>
 #include <machine/ipl.h>
 #include <machine/globals.h>
+#include <i386/isa/intr_machdep.h>

 #ifndef SMP
 /*


Fix a double-free in the 'm->m_len < sizeof (struct ip)' sanity check.

Bug report by:	<james@towardex.com>
MFC after:	2 weeks

--- sys/netinet/ip_fastfwd.c
+++ sys/netinet/ip_fastfwd.c
@@ -195,9 +195,9 @@
 	 * Is first mbuf large enough for ip header and is header present?
 	 */
 	if (m->m_len < sizeof (struct ip) &&
-	   (m = m_pullup(m, sizeof (struct ip))) == 0) {
+	   (m = m_pullup(m, sizeof (struct ip))) == NULL) {
 		ipstat.ips_toosmall++;
-		goto drop;
+		return 1;	/* mbuf already free'd */
 	}

 	ip = mtod(m, struct ip *);


Oops, revert an accidental local change that got added in my last commit (r218627).  No damage was done in the last commit, just some duplicated code was added (which is now removed).


Implement pv entries as separate structures from the ttes, like other architectures do.

--- sys/sparc64/include/pv.h
+++ sys/sparc64/include/pv.h
@@ -1,5 +1,10 @@
 /*-
- * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
+ * Copyright (c) 1991 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department and William Jolitz of UUNET Technologies Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -9,14 +14,18 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Berkeley Software Design Inc's name may not be used to endorse or
- *    promote products derived from this software without specific prior
- *    written permission.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -25,173 +34,31 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	from BSDI: pmap.c,v 1.28.2.15 2000/04/27 03:10:31 cp Exp
  * $FreeBSD$
  */

 #ifndef	_MACHINE_PV_H_
 #define	_MACHINE_PV_H_

-#define	PV_LOCK()
-#define	PV_UNLOCK()
+extern vm_zone_t pvzone;
+extern struct vm_zone pvzone_store;
+extern struct vm_object pvzone_obj;
+extern int pv_entry_count;
+extern int pv_entry_max;
+extern int pv_entry_high_water;
+extern struct pv_entry *pvinit;

-#define	ST_TTE			offsetof(struct stte, st_tte)
-#define	ST_NEXT			offsetof(struct stte, st_next)
-#define	ST_PREV			offsetof(struct stte, st_prev)
+pv_entry_t pv_alloc(void);
+void pv_free(pv_entry_t pv);

-#define	TTE_DATA		offsetof(struct tte, tte_data)
-#define	TTE_TAG			offsetof(struct tte, tte_tag)
-
-#define	PVH_FIRST		offsetof(struct pv_head, pvh_first)
-
-#define	PV_OFF(pa)		((vm_offset_t)(pa) - avail_start)
-#define	PV_INDEX(pa)		(PV_OFF(pa) >> PAGE_SHIFT)
-#define	PV_SHIFT		(3)
-
-#define	casxp(pa, exp, src) \
-	casxa((vm_offset_t *)pa, exp, src, ASI_PHYS_USE_EC)
-#define	ldxp(pa)		ldxa(pa, ASI_PHYS_USE_EC)
-#define	stxp(pa, val)		stxa(pa, ASI_PHYS_USE_EC, val)
-
-struct pv_entry {
-	vm_offset_t pv_next;
-	vm_offset_t pv_prev;
-};
-
-struct pv_head {
-	vm_offset_t pvh_first;
-};
-
-extern vm_offset_t pv_table;
-extern u_long pv_generation;
-
-static __inline vm_offset_t
-pv_lookup(vm_offset_t pa)
-{
-	return (pv_table + (PV_INDEX(pa) << PV_SHIFT));
-}
-
-static __inline vm_offset_t
-pvh_get_first(vm_offset_t pvh)
-{
-	return (ldxp(pvh + PVH_FIRST));
-}
-
-static __inline vm_offset_t
-pv_get_next(vm_offset_t pstp)
-{
-	return (ldxp(pstp + ST_NEXT));
-}
-
-static __inline vm_offset_t
-pv_get_prev(vm_offset_t pstp)
-{
-	return (ldxp(pstp + ST_PREV));
-}
-
-static __inline u_long
-pv_get_tte_data(vm_offset_t pstp)
-{
-	return (ldxp(pstp + ST_TTE + TTE_DATA));
-}
-
-static __inline u_long
-pv_get_tte_tag(vm_offset_t pstp)
-{
-	return (ldxp(pstp + ST_TTE + TTE_TAG));
-}
-
-#define	pv_get_tte(pstp) ({ \
-	struct tte __tte; \
-	__tte.tte_tag = pv_get_tte_tag(pstp); \
-	__tte.tte_data = pv_get_tte_data(pstp); \
-	__tte; \
-})
-
-static __inline void
-pvh_set_first(vm_offset_t pvh, vm_offset_t first)
-{
-	stxp(pvh + PVH_FIRST, first);
-}
-
-static __inline void
-pv_set_next(vm_offset_t pstp, vm_offset_t next)
-{
-	stxp(pstp + ST_NEXT, next);
-}
-
-static __inline void
-pv_set_prev(vm_offset_t pstp, vm_offset_t prev)
-{
-	stxp(pstp + ST_PREV, prev);
-}
-
-static __inline void
-pv_remove_phys(vm_offset_t pstp)
-{
-	vm_offset_t next;
-	vm_offset_t prev;
-
-	next = pv_get_next(pstp);
-	prev = pv_get_prev(pstp);
-	if (next != 0)
-		pv_set_next(next, prev);
-	stxp(prev, next);
-}
-
-static __inline void
-pv_atomic_bit_clear(vm_offset_t pstp, u_long bits)
-{
-	vm_offset_t dp;
-	vm_offset_t d1;
-	vm_offset_t d2;
-	vm_offset_t d3;
-
-	dp = pstp + ST_TTE + TTE_DATA;
-	for (d1 = ldxp(dp);; d1 = d3) {
-		d2 = d1 & ~bits;
-		d3 = casxp(dp, d1, d2);
-		if (d1 == d3)
-			break;
-	}
-}
-
-static __inline void
-pv_atomic_bit_set(vm_offset_t pstp, u_long bits)
-{
-	vm_offset_t dp;
-	vm_offset_t d1;
-	vm_offset_t d2;
-	vm_offset_t d3;
-
-	dp = pstp + ST_TTE + TTE_DATA;
-	for (d1 = ldxp(dp);; d1 = d3) {
-		d2 = d1 | bits;
-		d3 = casxp(dp, d1, d2);
-		if (d1 == d3)
-			break;
-	}
-}
-
-static __inline int
-pv_atomic_bit_test(vm_offset_t pstp, u_long bits)
-{
-	vm_offset_t dp;
-
-	dp = pstp + ST_TTE + TTE_DATA;
-	return ((casxp(dp, 0, 0) & bits) != 0);
-}
-
-void pv_dump(vm_offset_t pvh);
-
-void pv_insert(pmap_t pm, vm_offset_t pa, vm_offset_t va, struct stte *stp);
-void pv_remove_virt(struct stte *stp);
+void pv_insert(pmap_t pm, vm_page_t m, vm_offset_t va);
+pv_entry_t pv_lookup(pmap_t pm, vm_page_t m, vm_offset_t va);
+void pv_remove(pmap_t pm, vm_page_t m, vm_offset_t va);
+int pv_page_exists(pmap_t pm, vm_page_t m);
+void pv_remove_all(vm_page_t m);

 void pv_bit_clear(vm_page_t m, u_long bits);
 int pv_bit_count(vm_page_t m, u_long bits);
-void pv_bit_set(vm_page_t m, u_long bits);
 int pv_bit_test(vm_page_t m, u_long bits);

-void pv_global_remove_all(vm_page_t m);
-
 #endif /* !_MACHINE_PV_H_ */


Don't create vnode_pager objects for the disk device. geom_vfs will do that.

--- sys/ufs/ffs/ffs_vfsops.c
+++ sys/ufs/ffs/ffs_vfsops.c
@@ -417,7 +417,6 @@
 	vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td);
 	if (vinvalbuf(devvp, 0, td, 0, 0) != 0)
 		panic("ffs_reload: dirty1");
-	VOP_CREATEVOBJECT(devvp, td->td_ucred, td);
 	VOP_UNLOCK(devvp, 0, td);

 	/*
@@ -562,7 +561,6 @@
 	dev = devvp->v_rdev;
 	cred = td ? td->td_ucred : NOCRED;

-	VOP_CREATEVOBJECT(devvp, td->td_ucred, td);
 	ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
 	DROP_GIANT();
 	g_topology_lock();


perf: Remove redundant PMU assignment

perf: Remove redundant PMU assignment

Currently perf_branch_stack_sched_in iterates over the set of pmus,
checks that each pmu has a flush_branch_stack callback, then overwrites
the pmu before calling the callback. This is either redundant or broken.

In systems with a single hw pmu, pmu == cpuctx->ctx.pmu, and thus the
assignment is redundant.

In systems with multiple hw pmus (i.e. multiple pmus with task_ctx_nr ==
perf_hw_context) the pmus share the same perf_cpu_context. Thus the
assignment can cause one of the pmus to flush its branch stack
repeatedly rather than causing each of the pmus to flush their branch
stacks. Worse still, if only some pmus have the callback the assignment
can result in a branch to NULL.

This patch removes the redundant assignment.

Signed-off-by: Mark Rutland <1db9dd262beaa64f35756dd39531d9747b7778bb@arm.com>
Acked-by: Will Deacon <b913f13ef92ac157955c954ccaaff7be065faba4@arm.com>
Signed-off-by: Peter Zijlstra <3fddac958924aef220f202ca567388ddab3f14a8@infradead.org>
Cc: Stephane Eranian <f199ae9781930a5b94b284ca2f471140752002a7@google.com>
Link: http://lkml.kernel.org/r/1392054264-23570-3-git-send-email-1db9dd262beaa64f35756dd39531d9747b7778bb@arm.com
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@kernel.org>

--- kernel/events/core.c
+++ kernel/events/core.c
@@ -2582,8 +2582,6 @@
 		if (cpuctx->ctx.nr_branch_stack > 0
 		    && pmu->flush_branch_stack) {

-			pmu = cpuctx->ctx.pmu;
-
 			perf_ctx_lock(cpuctx, cpuctx->task_ctx);

 			perf_pmu_disable(pmu);


MFC: ufs_lookup.c 1.81     - fixes around whiteout processing bug

--- sys/ufs/ufs/ufs_lookup.c
+++ sys/ufs/ufs/ufs_lookup.c
@@ -700,7 +700,7 @@
 	struct buf *bp;
 	u_int dsize;
 	struct direct *ep, *nep;
-	int error, ret, blkoff, loc, spacefree, flags;
+	int error, ret, blkoff, loc, spacefree, flags, namlen;
 	char *dirbuf;

 	td = curthread;	/* XXX */
@@ -875,8 +875,16 @@
 	 * Update the pointer fields in the previous entry (if any),
 	 * copy in the new entry, and write out the block.
 	 */
+#	if (BYTE_ORDER == LITTLE_ENDIAN)
+		if (OFSFMT(dvp))
+			namlen = ep->d_type;
+		else
+			namlen = ep->d_namlen;
+#	else
+		namlen = ep->d_namlen;
+#	endif
 	if (ep->d_ino == 0 ||
-	    (ep->d_ino == WINO &&
+	    (ep->d_ino == WINO && namlen == dirp->d_namlen &&
 	     bcmp(ep->d_name, dirp->d_name, dirp->d_namlen) == 0)) {
 		if (spacefree + dsize < newentrysize)
 			panic("ufs_direnter: compact1");


sched: fix gcc warnings

sched: fix gcc warnings

Meelis Roos reported these warnings on sparc64:

  CC      kernel/sched.o
  In file included from kernel/sched.c:879:
  kernel/sched_debug.c: In function 'nsec_high':
  kernel/sched_debug.c:38: warning: comparison of distinct pointer types lacks a cast

the debug check in do_div() is over-eager here, because the long long
is always positive in these places. Mark this by casting them to
unsigned long long.

no change in code output:

   text    data     bss     dec     hex filename
  51471    6582     376   58429    e43d sched.o.before
  51471    6582     376   58429    e43d sched.o.after

  md5:
   7f7729c111f185bf3ccea4d542abc049  sched.o.before.asm
   7f7729c111f185bf3ccea4d542abc049  sched.o.after.asm

Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@elte.hu>

--- kernel/sched_debug.c
+++ kernel/sched_debug.c
@@ -31,9 +31,9 @@
 /*
  * Ease the printing of nsec fields:
  */
-static long long nsec_high(long long nsec)
-{
-	if (nsec < 0) {
+static long long nsec_high(unsigned long long nsec)
+{
+	if ((long long)nsec < 0) {
 		nsec = -nsec;
 		do_div(nsec, 1000000);
 		return -nsec;
@@ -43,9 +43,9 @@
 	return nsec;
 }

-static unsigned long nsec_low(long long nsec)
-{
-	if (nsec < 0)
+static unsigned long nsec_low(unsigned long long nsec)
+{
+	if ((long long)nsec < 0)
 		nsec = -nsec;

 	return do_div(nsec, 1000000);


tracing: Add description of set_graph_notrace to tracing/README

It was missing the description of set_graph_notrace file.  Add it.

Link: http://lkml.kernel.org/p/1402590233-22321-5-git-send-email-5c915a589b3ddf58cebf14bec41bcc143b37ac3c@kernel.org

Signed-off-by: Namhyung Kim <5c915a589b3ddf58cebf14bec41bcc143b37ac3c@kernel.org>
Signed-off-by: Steven Rostedt <43232e92d70cc7aa53504ad0397085ee47bad87f@goodmis.org>

--- kernel/trace/trace.c
+++ kernel/trace/trace.c
@@ -3663,6 +3663,7 @@
 #endif
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 	"  set_graph_function\t- Trace the nested calls of a function (function_graph)\n"
+	"  set_graph_notrace\t- Do not trace the nested calls of a function (function_graph)\n"
 	"  max_graph_depth\t- Trace a limited depth of nested calls (0 is unlimited)\n"
 #endif
 #ifdef CONFIG_TRACER_SNAPSHOT


bugfix

bugfix

--- system/kern/kern_sched.c
+++ system/kern/kern_sched.c
@@ -230,9 +230,9 @@
 	thread = sched_schedule_next(scheduler);

 	/*
-	 * Decrement the thread count.
-	 */
-	scheduler->sched_thread_count --;
+	 * Decrement the thread count. (If thread is a valid pointer.)
+	 */
+	if(thread) scheduler->sched_thread_count --;

 	/*
 	 * Unlock the scheduler, and get rid of the THREAD_SF_LOCK_SCHED-flag.
@@ -241,9 +241,9 @@
 	myself->t_stateflags &= ~THREAD_SF_LOCK_SCHED;

 	/*
-	 * Clear the thread's current cpu.
-	 */
-	thread->t_current_cpu = 0;
+	 * Clear the thread's current cpu. (If thread is a valid pointer.)
+	 */
+	if(thread) thread->t_current_cpu = 0;
 	return thread;
 }


tracing: Change tracing_fops/snapshot_fops to rely on tracing_get_cpu()

tracing_open() and tracing_snapshot_open() are racy, the memory
inode->i_private points to can be already freed.

Convert these last users of "inode->i_private == trace_cpu" to
use "i_private = trace_array" and rely on tracing_get_cpu().

v2: incorporate the fix from Steven, tracing_release() must not
    blindly dereference file->private_data unless we know that
    the file was opened for reading.

Link: http://lkml.kernel.org/r/20130723152610.GA23737@redhat.com

Signed-off-by: Oleg Nesterov <20b70f0af00562e63758b9ee42012ecc96c58590@redhat.com>
Signed-off-by: Steven Rostedt <43232e92d70cc7aa53504ad0397085ee47bad87f@goodmis.org>

--- kernel/trace/trace.c
+++ kernel/trace/trace.c
@@ -2862,9 +2862,9 @@
 };

 static struct trace_iterator *
-__tracing_open(struct trace_array *tr, struct trace_cpu *tc,
-	       struct inode *inode, struct file *file, bool snapshot)
-{
+__tracing_open(struct inode *inode, struct file *file, bool snapshot)
+{
+	struct trace_array *tr = inode->i_private;
 	struct trace_iterator *iter;
 	int cpu;

@@ -2905,8 +2905,8 @@
 		iter->trace_buffer = &tr->trace_buffer;
 	iter->snapshot = snapshot;
 	iter->pos = -1;
+	iter->cpu_file = tracing_get_cpu(inode);
 	mutex_init(&iter->mutex);
-	iter->cpu_file = tc->cpu;

 	/* Notify the tracer early; before we stop tracing. */
 	if (iter->trace && iter->trace->open)
@@ -2986,22 +2986,18 @@

 static int tracing_release(struct inode *inode, struct file *file)
 {
+	struct trace_array *tr = inode->i_private;
 	struct seq_file *m = file->private_data;
 	struct trace_iterator *iter;
-	struct trace_array *tr;
 	int cpu;

-	/* Writes do not use seq_file, need to grab tr from inode */
 	if (!(file->f_mode & FMODE_READ)) {
-		struct trace_cpu *tc = inode->i_private;
-
-		trace_array_put(tc->tr);
+		trace_array_put(tr);
 		return 0;
 	}

+	/* Writes do not use seq_file */
 	iter = m->private;
-	tr = iter->tr;
-
 	mutex_lock(&trace_types_lock);

 	for_each_tracing_cpu(cpu) {
@@ -3048,8 +3044,7 @@

 static int tracing_open(struct inode *inode, struct file *file)
 {
-	struct trace_cpu *tc = inode->i_private;
-	struct trace_array *tr = tc->tr;
+	struct trace_array *tr = inode->i_private;
 	struct trace_iterator *iter;
 	int ret = 0;

@@ -3057,16 +3052,17 @@
 		return -ENODEV;

 	/* If this file was open for write, then erase contents */
-	if ((file->f_mode & FMODE_WRITE) &&
-	    (file->f_flags & O_TRUNC)) {
-		if (tc->cpu == RING_BUFFER_ALL_CPUS)
+	if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) {
+		int cpu = tracing_get_cpu(inode);
+
+		if (cpu == RING_BUFFER_ALL_CPUS)
 			tracing_reset_online_cpus(&tr->trace_buffer);
 		else
-			tracing_reset(&tr->trace_buffer, tc->cpu);
+			tracing_reset(&tr->trace_buffer, cpu);
 	}

 	if (file->f_mode & FMODE_READ) {
-		iter = __tracing_open(tr, tc, inode, file, false);
+		iter = __tracing_open(inode, file, false);
 		if (IS_ERR(iter))
 			ret = PTR_ERR(iter);
 		else if (trace_flags & TRACE_ITER_LATENCY_FMT)
@@ -4680,8 +4676,7 @@
 #ifdef CONFIG_TRACER_SNAPSHOT
 static int tracing_snapshot_open(struct inode *inode, struct file *file)
 {
-	struct trace_cpu *tc = inode->i_private;
-	struct trace_array *tr = tc->tr;
+	struct trace_array *tr = inode->i_private;
 	struct trace_iterator *iter;
 	struct seq_file *m;
 	int ret = 0;
@@ -4690,7 +4685,7 @@
 		return -ENODEV;

 	if (file->f_mode & FMODE_READ) {
-		iter = __tracing_open(tr, tc, inode, file, true);
+		iter = __tracing_open(inode, file, true);
 		if (IS_ERR(iter))
 			ret = PTR_ERR(iter);
 	} else {
@@ -4707,8 +4702,8 @@
 		ret = 0;

 		iter->tr = tr;
-		iter->trace_buffer = &tc->tr->max_buffer;
-		iter->cpu_file = tc->cpu;
+		iter->trace_buffer = &tr->max_buffer;
+		iter->cpu_file = tracing_get_cpu(inode);
 		m->private = iter;
 		file->private_data = m;
 	}
@@ -5525,7 +5520,6 @@
 static void
 tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
 {
-	struct trace_array_cpu *data = per_cpu_ptr(tr->trace_buffer.data, cpu);
 	struct dentry *d_percpu = tracing_dentry_percpu(tr, cpu);
 	struct dentry *d_cpu;
 	char cpu_dir[30]; /* 30 characters should be more than enough */
@@ -5546,7 +5540,7 @@

 	/* per cpu trace */
 	trace_create_cpu_file("trace", 0644, d_cpu,
-				&data->trace_cpu, cpu, &tracing_fops);
+				tr, cpu, &tracing_fops);

 	trace_create_cpu_file("trace_pipe_raw", 0444, d_cpu,
 				tr, cpu, &tracing_buffers_fops);
@@ -5559,7 +5553,7 @@

 #ifdef CONFIG_TRACER_SNAPSHOT
 	trace_create_cpu_file("snapshot", 0644, d_cpu,
-				&data->trace_cpu, cpu, &snapshot_fops);
+				tr, cpu, &snapshot_fops);

 	trace_create_cpu_file("snapshot_raw", 0444, d_cpu,
 				tr, cpu, &snapshot_raw_fops);
@@ -6125,7 +6119,7 @@
 			  tr, &tracing_iter_fops);

 	trace_create_file("trace", 0644, d_tracer,
-			(void *)&tr->trace_cpu, &tracing_fops);
+			  tr, &tracing_fops);

 	trace_create_file("trace_pipe", 0444, d_tracer,
 			  tr, &tracing_pipe_fops);
@@ -6146,11 +6140,11 @@
 			  &trace_clock_fops);

 	trace_create_file("tracing_on", 0644, d_tracer,
-			    tr, &rb_simple_fops);
+			  tr, &rb_simple_fops);

 #ifdef CONFIG_TRACER_SNAPSHOT
 	trace_create_file("snapshot", 0644, d_tracer,
-			  (void *)&tr->trace_cpu, &snapshot_fops);
+			  tr, &snapshot_fops);
 #endif

 	for_each_tracing_cpu(cpu)


Fixed lexer->text state for the last token.

--- njs/njs_lexer.c
+++ njs/njs_lexer.c
@@ -450,6 +450,8 @@
         return njs_lexer_multi(lexer, token, n, multi);
     }

+    lexer->text.length = lexer->start - lexer->text.start;
+
     return NJS_TOKEN_END;
 }


asprintf: doxygen

asprintf: doxygen

--- nmsg/asprintf.h
+++ nmsg/asprintf.h
@@ -1,8 +1,14 @@
 #ifndef NMSG_ASPRINTF_H
+
+/*! \file nmsg/asprintf.h
+ * \brief Asprintf utility functions.
+ *
+ * Portable replacements for the asprintf(3) and vasprintf(3) functions.
+ */

 #include <stdarg.h>

-int nmsg_asprintf(char **, const char *, ...);
-int nmsg_vasprintf(char **, const char *, va_list);
+int nmsg_asprintf(char **strp, const char *fmt, ...);
+int nmsg_vasprintf(char **strp, const char *fmt, va_list args);

 #endif /* NMSG_ASPRINTF_H */


nmsg/isc/defs.h: new

nmsg/isc/defs.h: new

error: pathspec 'nmsg/isc/defs.h' did not match any file(s) known to git

--- nmsg/isc/defs.h
+++ nmsg/isc/defs.h
@@ -0,0 +1,25 @@
+#ifndef NMSG_ISC_DEFS_H
+#define NMSG_ISC_DEFS_H
+
+#define NMSG_VENDOR_ISC_NCAP_ID		1
+#define NMSG_VENDOR_ISC_NCAP_NAME	"ncap"
+
+#define NMSG_VENDOR_ISC_EMAIL_ID	2
+#define NMSG_VENDOR_ISC_EMAIL_NAME	"email"
+
+#define NMSG_VENDOR_ISC_LINKPAIR_ID	3
+#define NMSG_VENDOR_ISC_LINKPAIR_NAME	"linkpair"
+
+#define NMSG_VENDOR_ISC_HTTP_ID		4
+#define NMSG_VENDOR_ISC_HTTP_NAME	"http"
+
+#define NMSG_VENDOR_ISC_IPCONN_ID	5
+#define NMSG_VENDOR_ISC_IPCONN_NAME	"ipconn"
+
+#define NMSG_VENDOR_ISC_LOGLINE_ID	6
+#define NMSG_VENDOR_ISC_LOGLINE_NAME	"logline"
+
+#define NMSG_VENDOR_ISC_DNS_ID		7
+#define NMSG_VENDOR_ISC_DNS_NAME	"dns"
+
+#endif /* NMSG_ISC_DEFS_H */


Enable watches of non-cwd

Enable watches of non-cwd

If a pattern contains a path, it is safe to assume that the user wants
to place the watch in that path. This patch makes this possible.

--- trigger.c
+++ trigger.c
@@ -1,3 +1,4 @@
+#include <libgen.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <signal.h>
@@ -110,6 +111,43 @@
 	log_info("Terminating ...");
 }

+/*
+ * Determine the path for which to add a watch. If the pattern looks like
+ * a path, it probably is, in which case we use the dirname() of the pattern
+ * as the path and modify pattern accordingly with basename(). If it does not
+ * look like a path or if we don't have a pattern, we use the current working
+ * directory.
+ */
+static char * determine_watch_path(char **pattern)
+{
+	char *p = NULL;
+	char *dirc = NULL;
+	char *basec= NULL;
+	char *dname= NULL;
+	char *bname = NULL;
+	if (pattern != NULL && *pattern != NULL) {
+		check_mem(dirc= strdup(*pattern));
+		check_mem(basec= strdup(*pattern));
+		bname = basename(dirc);
+		dname = dirname(basec);
+		if (0 != strcmp(dname, ".")) {
+			check_mem(p = strdup(dname));
+			free(*pattern);
+			check_mem(*pattern = strdup(bname));
+		}
+		free(dirc);
+		free(basec);
+	}
+	if (p == NULL) {
+		if ((p = getcwd(p, 0)) == NULL ) {
+			log_err("Failed to get current working directory: %s", strerror(errno));
+			return NULL;
+		}
+	}
+	return p;
+error:
+	return NULL;
+}

 static void print_usage()
 {
@@ -121,8 +159,7 @@
 	int inotify_fd, wd;
 	char *path = NULL;
 	char *pattern = NULL;
-	path = getcwd(NULL, 0);
-	check(path, "Failed to get current working directory");
+
 	check((argc > 1 && argc < 4), "Wrong number of arguments");
 	if (strcmp(argv[1], "-h") == 0) {
 		print_usage();
@@ -131,12 +168,18 @@
 	check_mem(command = strdup(argv[1]));
 	if (argc == 3)
 		check_mem(pattern = strdup(argv[2]));
+
+	path = determine_watch_path(&pattern);
+	check(path, "Failed to determine directory to watch");
 	inotify_fd = open_inotify_fd();
 	log_info("Inotify instance initialized ...");
 	add_watch(inotify_fd, path);
-	log_info("Watch added for '%s' ...", path);
+	log_info("Watch pattern '%s' added for '%s' ...", pattern, path);
 	process_events(inotify_fd, (const char *) pattern);
 	log_info("Stopped watching '%s' ...", path);
+	free(command);
+	free(path);
+	free(pattern);
 	return 0;
 error:
 	print_usage();


Add license and a short manual in tst-spf.

Signed-off-by: Florent Bruneau <5d0958454f46908a14eb42e25abfc486c9e7cb2c@polytechnique.org>

--- tst-spf.c
+++ tst-spf.c
@@ -1,3 +1,51 @@
+/******************************************************************************/
+/*          pfixtools: a collection of postfix related tools                  */
+/*          ~~~~~~~~~                                                         */
+/*  ________________________________________________________________________  */
+/*                                                                            */
+/*  Redistribution and use in source and binary forms, with or without        */
+/*  modification, are permitted provided that the following conditions        */
+/*  are met:                                                                  */
+/*                                                                            */
+/*  1. Redistributions of source code must retain the above copyright         */
+/*     notice, this list of conditions and the following disclaimer.          */
+/*  2. Redistributions in binary form must reproduce the above copyright      */
+/*     notice, this list of conditions and the following disclaimer in the    */
+/*     documentation and/or other materials provided with the distribution.   */
+/*  3. The names of its contributors may not be used to endorse or promote    */
+/*     products derived from this software without specific prior written     */
+/*     permission.                                                            */
+/*                                                                            */
+/*  THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS   */
+/*  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED         */
+/*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE    */
+/*  DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY         */
+/*  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL        */
+/*  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS   */
+/*  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)     */
+/*  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,       */
+/*  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN  */
+/*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE           */
+/*  POSSIBILITY OF SUCH DAMAGE.                                               */
+/*                                                                            */
+/*   Copyright (c) 2006-2009 the Authors                                      */
+/*   see AUTHORS and source files for details                                 */
+/******************************************************************************/
+
+/*
+ * Copyright © 2009 Florent Bruneau
+ */
+
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! *
+ *  To run the test, you must have a resolv.conf in your current directoy with *
+ *  the following content:                                                     *
+ *                                                                             *
+ *  search example.com                                                         *
+ *  nameserver 88.163.156.52                                                   *
+ *                                                                             *
+ *  The IP of the nameserver may change in the future.                         *
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+
 #include "spf.h"
 #include "server.h"

@@ -240,7 +288,7 @@
 int main(int argc, char *argv[])
 {
     dns_use_local_conf("resolv.conf");
-    log_level = LOG_DEBUG;
+    log_level = LOG_NOTICE;
     spf_test_next(NULL);
     return server_loop(NULL, NULL, NULL, NULL, NULL);
 }


fixed small typename issue with recent Iterable<T> changes

--- Library/Sources/Stroika/Foundation/Containers/Iterable.h
+++ Library/Sources/Stroika/Foundation/Containers/Iterable.h
@@ -144,8 +144,8 @@

             protected:
-                nonvirtual  Iterable<T>::_IRep&         _GetRep ();
-                nonvirtual  const Iterable<T>::_IRep&   _GetRep () const;
+                nonvirtual  typename Iterable<T>::_IRep&         _GetRep ();
+                nonvirtual  const typename Iterable<T>::_IRep&   _GetRep () const;

             protected:
                 nonvirtual  void                        _SetRep (Memory::SharedByValue<_IRep> rep);


still working

still working

--- TRAPSat_cFS/cfs/apps/ads1115/fsw/src/ads1115_device.c
+++ TRAPSat_cFS/cfs/apps/ads1115/fsw/src/ads1115_device.c
@@ -162,15 +162,29 @@

         /*
         ** double check ADS1115_ADC_CH_BUF_SIZE
-        */
         OS_printf("sizeof(ADS1115_ChannelData.adc_ch_1) = %d\n", sizeof(ADS1115_ChannelData.adc_ch_1));
-
+        */
+
+        /*
+        *(&ADS1115_ChannelData.adc_ch_1 + (ADS1115_ADC_CH_BUF_SIZE*adc_ch_sel)) = i2c_data[0];
+        *(&ADS1115_ChannelData.adc_ch_1 + (ADS1115_ADC_CH_BUF_SIZE*adc_ch_sel) + 1) = i2c_data[1];
+        */
+
+        memcpy((&ADS1115_ChannelData.adc_ch_1 + (ADS1115_ADC_CH_BUF_SIZE*adc_ch_sel)),
+                &i2c_data,
+                ADS1115_ADC_CH_BUF_SIZE);
+
+        /*
         memcpy((&ADS1115_ChannelData.adc_ch_1 + (ADS1115_ADC_CH_BUF_SIZE*adc_ch_sel)),
                 &i2c_data_word,
                 ADS1115_ADC_CH_BUF_SIZE);
-
-        OS_printf("ADS1115: Struct Data => Channel %d Voltage: %f V\n", adc_ch_sel,
-            (float) ((uint16*)(&ADS1115_ChannelData.adc_ch_1 + (ADS1115_ADC_CH_BUF_SIZE*adc_ch_sel))*4.096/32767.0));
+        */
+
+        float voltage = (uint16 *)(&ADS1115_ChannelData.adc_ch_1 + (ADS1115_ADC_CH_BUF_SIZE*adc_ch_sel));
+        voltage *= (4.096/32767.0);
+
+        OS_printf("ADS1115: Struct Data => Channel %d Voltage: %f V\n", adc_ch_sel, voltage);
+
     } /* Channel Select Loop End Here */

     /*


Tidy up.

Tidy up.

--- htp/bstr.c
+++ htp/bstr.c
@@ -411,8 +411,7 @@
             d = -1;
         }

-        // Check that the digit makes sense with the base
-        // we are using.
+        // Check that the digit makes sense with the base we are using.
         if ((d == -1) || (d >= base)) {
             if (tflag) {
                 // Return what we have so far; lastlen points


Removed intrusive_list::operator=(...) - swapping no longer available

--- intrusive_list.h
+++ intrusive_list.h
@@ -82,6 +82,8 @@
 	template < typename T , typename Allocator_ >
 	class intrusive_list : public Allocator_
 	{
+		TOOLKIT_NONASSIGNABLE(intrusive_list);
+
 	public:
 		typedef intrusive_list_node<T>	node_type;

@@ -175,17 +177,6 @@
 			}
 		}

-		intrusive_list& operator = (const intrusive_list& other)
-		{
-			if (this == &other)
-				return *this;
-
-			intrusive_list tmp(other);
-			swap(tmp);
-
-			return *this;
-		}
-
 		iterator begin()		{ return iterator(_root._next); }
 		iterator end()			{ return iterator(&_root); }


Fixes for bsd

Fixes for bsd

--- libatmi/conversation.c
+++ libatmi/conversation.c
@@ -1503,7 +1503,8 @@
     }

     /* Send disconnect command to server */
-    if (EXFAIL==ndrx_tpsend (cd, NULL, 0L, 0L, &revent, ATMI_COMMAND_DISCONN))
+    if (EXFAIL!=conv->reply_q && EXFAIL==ndrx_tpsend (cd, NULL, 0L, 0L,
+            &revent, ATMI_COMMAND_DISCONN))
     {
         NDRX_LOG(log_debug, "Failed to send disconnect to server - IGNORE!");
     }


b frame strategy 2

b frame strategy 2

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

--- libavcodec/mpegvideo.c
+++ libavcodec/mpegvideo.c
@@ -2141,6 +2141,99 @@
     return 0;
 }

+static int estimate_best_b_count(MpegEncContext *s){
+    AVCodec *codec= avcodec_find_encoder(s->avctx->codec_id);
+    AVCodecContext *c= avcodec_alloc_context();
+    AVFrame input[FF_MAX_B_FRAMES+2];
+    const int scale= 0;
+    int i, j, out_size;
+    int outbuf_size= (s->width * s->height) >> (2*scale); //FIXME
+    uint8_t *outbuf= av_malloc(outbuf_size);
+    ImgReSampleContext *resample;
+    int64_t best_rd= INT64_MAX;
+    int best_b_count= -1;
+    const int lambda2= s->lambda2;
+
+    c->width = s->width >> scale;
+    c->height= s->height>> scale;
+    c->flags= CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR | CODEC_FLAG_INPUT_PRESERVED /*| CODEC_FLAG_EMU_EDGE*/;
+    c->flags|= s->avctx->flags & CODEC_FLAG_QPEL;
+    c->mb_decision= s->avctx->mb_decision;
+    c->me_cmp= s->avctx->me_cmp;
+    c->mb_cmp= s->avctx->mb_cmp;
+    c->me_sub_cmp= s->avctx->me_sub_cmp;
+    c->pix_fmt = PIX_FMT_YUV420P;
+    c->time_base= s->avctx->time_base;
+    c->max_b_frames= s->max_b_frames;
+
+    if (avcodec_open(c, codec) < 0)
+        return -1;
+
+    resample= img_resample_init(c->width, c->height, s->width, s->height); //FIXME use sws
+
+    for(i=0; i<s->max_b_frames+2; i++){
+        int ysize= c->width*c->height;
+        int csize= (c->width/2)*(c->height/2);
+
+        avcodec_get_frame_defaults(&input[i]);
+        input[i].data[0]= av_malloc(ysize + 2*csize);
+        input[i].data[1]= input[i].data[0] + ysize;
+        input[i].data[2]= input[i].data[1] + csize;
+        input[i].linesize[0]= c->width;
+        input[i].linesize[1]=
+        input[i].linesize[2]= c->width/2;
+
+        if(!i || s->input_picture[i-1])
+            img_resample(resample, &input[i], i ? s->input_picture[i-1] : s->next_picture_ptr);
+    }
+
+    for(j=0; j<s->max_b_frames+1; j++){
+        int64_t rd=0;
+
+        if(!s->input_picture[j])
+            break;
+
+        c->error[0]= c->error[1]= c->error[2]= 0;
+
+        input[0].pict_type= I_TYPE;
+        input[0].quality= 2 * FF_QP2LAMBDA;
+        out_size = avcodec_encode_video(c, outbuf, outbuf_size, &input[0]);
+
+        for(i=0; i<s->max_b_frames+1; i++){
+            int is_p= i % (j+1) == j || i==s->max_b_frames;
+
+            input[i+1].pict_type= is_p ? P_TYPE : B_TYPE;
+            input[i+1].quality= s->rc_context.last_qscale_for[input[i+1].pict_type];
+            out_size = avcodec_encode_video(c, outbuf, outbuf_size, &input[i+1]);
+            rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT;
+        }
+
+        /* get the delayed frames */
+        while(out_size){
+            out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
+            rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT;
+        }
+
+        rd += c->error[0] + c->error[1] + c->error[2];
+
+        if(rd < best_rd){
+            best_rd= rd;
+            best_b_count= j;
+        }
+    }
+
+    av_freep(&outbuf);
+    avcodec_close(c);
+    av_freep(&c);
+    img_resample_close(resample);
+
+    for(i=0; i<s->max_b_frames+2; i++){
+        av_freep(&input[i].data[0]);
+    }
+
+    return best_b_count;
+}
+
 static void select_input_picture(MpegEncContext *s){
     int i;

@@ -2217,6 +2310,8 @@
                 for(i=0; i<b_frames+1; i++){
                     s->input_picture[i]->b_frame_score=0;
                 }
+            }else if(s->avctx->b_frame_strategy==2){
+                b_frames= estimate_best_b_count(s);
             }else{
                 av_log(s->avctx, AV_LOG_ERROR, "illegal b frame strategy\n");
                 b_frames=0;