update-ref --stdin: read the whole input at once

Read the whole input into a strbuf at once, and then parse it from
there.  This might also be a tad faster, but that is not the point.
The point is to decouple the parsing code from the input source (the
old parsing code had to read new data even in the middle of commands).
Add docstrings for the parsing functions.

Signed-off-by: Michael Haggerty <c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu>
Signed-off-by: Junio C Hamano <a6723cc3f76163bf7adb636a73ac3b0ceb3e6b9b@pobox.com>

--- builtin/update-ref.c
+++ builtin/update-ref.c
@@ -85,44 +85,70 @@
 	return next;
 }

-static const char *parse_first_arg(const char *next, struct strbuf *arg)
-{
-	/* Parse argument immediately after "command SP" */
+/*
+ * Parse the argument immediately after "command SP".  If not -z, then
+ * handle C-quoting.  Write the argument to arg.  Set *next to point
+ * at the character that terminates the argument.  Die if C-quoting is
+ * malformed.
+ */
+static void parse_first_arg(struct strbuf *input, const char **next,
+			    struct strbuf *arg)
+{
 	strbuf_reset(arg);
 	if (line_termination) {
 		/* Without -z, use the next argument */
-		next = parse_arg(next, arg);
+		*next = parse_arg(*next, arg);
 	} else {
-		/* With -z, use rest of first NUL-terminated line */
-		strbuf_addstr(arg, next);
-		next = next + arg->len;
-	}
-	return next;
-}
-
-static const char *parse_next_arg(const char *next, struct strbuf *arg)
-{
-	/* Parse next SP-terminated or NUL-terminated argument, if any */
+		/* With -z, use everything up to the next NUL */
+		strbuf_addstr(arg, *next);
+		*next += arg->len;
+	}
+}
+
+/*
+ * Parse a SP/NUL separator followed by the next SP- or NUL-terminated
+ * argument, if any.  If there is an argument, write it to arg, set
+ * *next to point at the character terminating the argument, and
+ * return 0.  If there is no argument at all (not even the empty
+ * string), return a non-zero result and leave *next unchanged.
+ */
+static int parse_next_arg(struct strbuf *input, const char **next,
+			  struct strbuf *arg)
+{
 	strbuf_reset(arg);
 	if (line_termination) {
 		/* Without -z, consume SP and use next argument */
-		if (!*next)
-			return NULL;
-		if (*next != ' ')
-			die("expected SP but got: %s", next);
-		next = parse_arg(next + 1, arg);
+		if (!**next || **next == line_termination)
+			return -1;
+		if (**next != ' ')
+			die("expected SP but got: %s", *next);
+		(*next)++;
+		*next = parse_arg(*next, arg);
 	} else {
 		/* With -z, read the next NUL-terminated line */
-		if (*next)
-			die("expected NUL but got: %s", next);
-		if (strbuf_getline(arg, stdin, '\0') == EOF)
-			return NULL;
-		next = arg->buf + arg->len;
-	}
-	return next;
-}
-
-static void parse_cmd_update(const char *next)
+		if (**next)
+			die("expected NUL but got: %s", *next);
+		(*next)++;
+		if (*next == input->buf + input->len)
+			return -1;
+		strbuf_addstr(arg, *next);
+		*next += arg->len;
+	}
+	return 0;
+}
+
+
+/*
+ * The following five parse_cmd_*() functions parse the corresponding
+ * command.  In each case, next points at the character following the
+ * command name and the following space.  They each return a pointer
+ * to the character terminating the command, and die with an
+ * explanatory message if there are any parsing problems.  All of
+ * these functions handle either text or binary format input,
+ * depending on how line_termination is set.
+ */
+
+static const char *parse_cmd_update(struct strbuf *input, const char *next)
 {
 	struct strbuf ref = STRBUF_INIT;
 	struct strbuf newvalue = STRBUF_INIT;
@@ -131,26 +157,28 @@

 	update = update_alloc();

-	if ((next = parse_first_arg(next, &ref)) != NULL && ref.buf[0])
+	parse_first_arg(input, &next, &ref);
+	if (ref.buf[0])
 		update_store_ref_name(update, ref.buf);
 	else
 		die("update line missing <ref>");

-	if ((next = parse_next_arg(next, &newvalue)) != NULL)
+	if (!parse_next_arg(input, &next, &newvalue))
 		update_store_new_sha1(update, newvalue.buf);
 	else
 		die("update %s missing <newvalue>", ref.buf);

-	if ((next = parse_next_arg(next, &oldvalue)) != NULL)
+	if (!parse_next_arg(input, &next, &oldvalue)) {
 		update_store_old_sha1(update, oldvalue.buf);
-	else if(!line_termination)
+		if (*next != line_termination)
+			die("update %s has extra input: %s", ref.buf, next);
+	} else if (!line_termination)
 		die("update %s missing [<oldvalue>] NUL", ref.buf);

-	if (next && *next)
-		die("update %s has extra input: %s", ref.buf, next);
-}
-
-static void parse_cmd_create(const char *next)
+	return next;
+}
+
+static const char *parse_cmd_create(struct strbuf *input, const char *next)
 {
 	struct strbuf ref = STRBUF_INIT;
 	struct strbuf newvalue = STRBUF_INIT;
@@ -158,23 +186,27 @@

 	update = update_alloc();

-	if ((next = parse_first_arg(next, &ref)) != NULL && ref.buf[0])
+	parse_first_arg(input, &next, &ref);
+	if (ref.buf[0])
 		update_store_ref_name(update, ref.buf);
 	else
 		die("create line missing <ref>");

-	if ((next = parse_next_arg(next, &newvalue)) != NULL)
+	if (!parse_next_arg(input, &next, &newvalue))
 		update_store_new_sha1(update, newvalue.buf);
 	else
 		die("create %s missing <newvalue>", ref.buf);
+
 	if (is_null_sha1(update->new_sha1))
 		die("create %s given zero new value", ref.buf);

-	if (next && *next)
+	if (*next != line_termination)
 		die("create %s has extra input: %s", ref.buf, next);
-}
-
-static void parse_cmd_delete(const char *next)
+
+	return next;
+}
+
+static const char *parse_cmd_delete(struct strbuf *input, const char *next)
 {
 	struct strbuf ref = STRBUF_INIT;
 	struct strbuf oldvalue = STRBUF_INIT;
@@ -182,23 +214,26 @@

 	update = update_alloc();

-	if ((next = parse_first_arg(next, &ref)) != NULL && ref.buf[0])
+	parse_first_arg(input, &next, &ref);
+	if (ref.buf[0])
 		update_store_ref_name(update, ref.buf);
 	else
 		die("delete line missing <ref>");

-	if ((next = parse_next_arg(next, &oldvalue)) != NULL)
+	if (!parse_next_arg(input, &next, &oldvalue)) {
 		update_store_old_sha1(update, oldvalue.buf);
-	else if(!line_termination)
+		if (update->have_old && is_null_sha1(update->old_sha1))
+			die("delete %s given zero old value", ref.buf);
+	} else if (!line_termination)
 		die("delete %s missing [<oldvalue>] NUL", ref.buf);
-	if (update->have_old && is_null_sha1(update->old_sha1))
-		die("delete %s given zero old value", ref.buf);
-
-	if (next && *next)
+
+	if (*next != line_termination)
 		die("delete %s has extra input: %s", ref.buf, next);
-}
-
-static void parse_cmd_verify(const char *next)
+
+	return next;
+}
+
+static const char *parse_cmd_verify(struct strbuf *input, const char *next)
 {
 	struct strbuf ref = STRBUF_INIT;
 	struct strbuf value = STRBUF_INIT;
@@ -206,53 +241,64 @@

 	update = update_alloc();

-	if ((next = parse_first_arg(next, &ref)) != NULL && ref.buf[0])
+	parse_first_arg(input, &next, &ref);
+	if (ref.buf[0])
 		update_store_ref_name(update, ref.buf);
 	else
 		die("verify line missing <ref>");

-	if ((next = parse_next_arg(next, &value)) != NULL) {
+	if (!parse_next_arg(input, &next, &value)) {
 		update_store_old_sha1(update, value.buf);
 		update_store_new_sha1(update, value.buf);
-	} else if(!line_termination)
+	} else if (!line_termination)
 		die("verify %s missing [<oldvalue>] NUL", ref.buf);

-	if (next && *next)
+	if (*next != line_termination)
 		die("verify %s has extra input: %s", ref.buf, next);
-}
-
-static void parse_cmd_option(const char *next)
-{
-	if (!strcmp(next, "no-deref"))
+
+	return next;
+}
+
+static const char *parse_cmd_option(struct strbuf *input, const char *next)
+{
+	if (!strncmp(next, "no-deref", 8) && next[8] == line_termination)
 		update_flags |= REF_NODEREF;
 	else
 		die("option unknown: %s", next);
+	return next + 8;
 }

 static void update_refs_stdin(void)
 {
-	struct strbuf cmd = STRBUF_INIT;
-
+	struct strbuf input = STRBUF_INIT;
+	const char *next;
+
+	if (strbuf_read(&input, 0, 1000) < 0)
+		die_errno("could not read from stdin");
+	next = input.buf;
 	/* Read each line dispatch its command */
-	while (strbuf_getline(&cmd, stdin, line_termination) != EOF)
-		if (!cmd.buf[0])
+	while (next < input.buf + input.len) {
+		if (*next == line_termination)
 			die("empty command in input");
-		else if (isspace(*cmd.buf))
-			die("whitespace before command: %s", cmd.buf);
-		else if (starts_with(cmd.buf, "update "))
-			parse_cmd_update(cmd.buf + 7);
-		else if (starts_with(cmd.buf, "create "))
-			parse_cmd_create(cmd.buf + 7);
-		else if (starts_with(cmd.buf, "delete "))
-			parse_cmd_delete(cmd.buf + 7);
-		else if (starts_with(cmd.buf, "verify "))
-			parse_cmd_verify(cmd.buf + 7);
-		else if (starts_with(cmd.buf, "option "))
-			parse_cmd_option(cmd.buf + 7);
+		else if (isspace(*next))
+			die("whitespace before command: %s", next);
+		else if (starts_with(next, "update "))
+			next = parse_cmd_update(&input, next + 7);
+		else if (starts_with(next, "create "))
+			next = parse_cmd_create(&input, next + 7);
+		else if (starts_with(next, "delete "))
+			next = parse_cmd_delete(&input, next + 7);
+		else if (starts_with(next, "verify "))
+			next = parse_cmd_verify(&input, next + 7);
+		else if (starts_with(next, "option "))
+			next = parse_cmd_option(&input, next + 7);
 		else
-			die("unknown command: %s", cmd.buf);
-
-	strbuf_release(&cmd);
+			die("unknown command: %s", next);
+
+		next++;
+	}
+
+	strbuf_release(&input);
 }

 int cmd_update_ref(int argc, const char **argv, const char *prefix)


CORE-808: Increment the XRP sequence number when signing.

--- ripple/BRRippleAccount.c
+++ ripple/BRRippleAccount.c
@@ -210,7 +210,8 @@

     size_t tx_size =
         rippleTransactionSerializeAndSign(transaction, &key, &account->publicKey,
-                                          account->sequence, account->lastLedgerSequence);
+                                          account->sequence + 1,  // next sequence number
+                                          account->lastLedgerSequence);

     // Increment the sequence number if we were able to sign the bytes
     if (tx_size > 0) {


For compilation on Windows.

For compilation on Windows.

--- c/Objects/compactobject.c
+++ c/Objects/compactobject.c
@@ -575,15 +575,17 @@
 	0,                                      /* tp_descr_set */
 	0,                                      /* tp_dictoffset */
 	0,                                      /* tp_init */
-	PyType_GenericAlloc,                    /* tp_alloc */
+	/*PyType_GenericAlloc set below*/ 0,    /* tp_alloc */
 	compact_new,                            /* tp_new */
-	PyObject_GC_Del,                        /* tp_free */
+	/*PyObject_GC_Del set below*/ 0,        /* tp_free */
 };

 void psyco_compact_init(void)
 {
 	PyCompact_EmptyImpl = &k_empty_impl;
 	PyCompact_Type.ob_type = &PyType_Type;
+	PyCompact_Type.tp_alloc = &PyType_GenericAlloc;
+	PyCompact_Type.tp_free = &PyObject_GC_Del;
 }

 #else  /* !HAVE_COMPACT_OBJECT */


Export max_keylen so that it can be initialized before calling rn_init().

--- dyntrace/dyntrace/radix.h
+++ dyntrace/dyntrace/radix.h
@@ -28,6 +28,7 @@
  *
  *	@(#)radix.h	8.2 (Berkeley) 10/31/94
  * $FreeBSD: src/sys/net/radix.h,v 1.25 2004/04/18 11:48:35 luigi Exp $
+ * $kbyanc: dyntrace/dyntrace/radix.h,v 1.2 2004/10/18 18:38:45 kbyanc Exp $
  */

 #ifndef _RADIX_H_
@@ -152,6 +153,8 @@
 #define	RADIX_NODE_HEAD_LOCK_ASSERT(rnh) mtx_assert(&(rnh)->rnh_mtx, MA_OWNED)
 #endif /* _KERNEL */

+extern int max_keylen;
+
 void	 rn_init(void);
 int	 rn_inithead(void **, int);
 int	 rn_refines(void *, void *);


decompressor: explicitly track remaining items in a variable

This makes code easier to read.

--- c-ext/decompressor.c
+++ c-ext/decompressor.c
@@ -826,6 +826,7 @@
 	DestBuffer* destBuffer;
 	Py_ssize_t frameIndex;
 	Py_ssize_t localOffset = 0;
+	Py_ssize_t remainingItems = state->endOffset - state->startOffset + 1;
 	FramePointer* framePointers = state->framePointers;
 	size_t zresult;
 	unsigned long long currentOffset = 0;
@@ -882,14 +883,14 @@

 	destBuffer->destSize = currentOffset;

-	destBuffer->segments = calloc(state->endOffset - state->startOffset + 1, sizeof(BufferSegment));
+	destBuffer->segments = calloc(remainingItems, sizeof(BufferSegment));
 	if (NULL == destBuffer->segments) {
 		/* Caller will free state->dest as part of cleanup. */
 		state->error = WorkerError_memory;
 		return;
 	}

-	destBuffer->segmentsSize = state->endOffset - state->startOffset + 1;
+	destBuffer->segmentsSize = remainingItems;

 	for (frameIndex = state->startOffset; frameIndex <= state->endOffset; frameIndex++) {
 		void* source = framePointers[frameIndex].sourceData;
@@ -922,6 +923,7 @@
 		destBuffer->segments[localOffset].offset = framePointers[frameIndex].destOffset;
 		destBuffer->segments[localOffset].length = destCapacity;
 		localOffset++;
+		remainingItems--;
 	}
 }


build: silence compiler warning on BSD

build: silence compiler warning on BSD

Building on 64-bit FreeBSD 8.2 complained about a cast between
a pointer and a smaller integer.  Going through an intermediate
cast shuts up the compiler.

* src/util/threads-pthread.c (virThreadSelfID): Silence a warning.

--- src/util/threads-pthread.c
+++ src/util/threads-pthread.c
@@ -216,7 +216,7 @@
     tid = syscall(SYS_gettid);
     return (int)tid;
 #else
-    return (int)(void *)pthread_self();
+    return (int)(intptr_t)(void *)pthread_self();
 #endif
 }


[CamelVeeSummary] Do not freeze folder when setting info flags

The thaw can cause write of message changes, which can cause slowness
when saving changes for many message infos.

--- camel/camel-vee-summary.c
+++ camel/camel-vee-summary.c
@@ -256,9 +256,7 @@
 		if (ignore_changes)
 			camel_vee_folder_ignore_next_changed_event (vf, camel_folder_summary_get_folder (rmi->summary));

-		camel_folder_freeze (camel_folder_summary_get_folder (rmi->summary));
 		res = camel_message_info_set_flags (rmi, flags, set);
-		camel_folder_thaw (camel_folder_summary_get_folder (rmi->summary));

 		if (res) {
 			/* update flags on itself too */


Don't support RAW

Don't support RAW

git-svn-id: 40dd595c6684d839db675001a64203a1457e7319@2951 67ed7778-7388-44ab-90cf-0a291f65f57c

--- camlibs/polaroid/pdc700.c
+++ camlibs/polaroid/pdc700.c
@@ -487,7 +487,7 @@
 	const char header[] = "P6\n80 60\n255\n";
 	unsigned char *data = NULL, *ppm;

-#if 0
+#if 1
 	if (type == GP_FILE_TYPE_RAW)
 		return (GP_ERROR_NOT_SUPPORTED);
 #endif
@@ -527,7 +527,7 @@
 		break;

 	case GP_FILE_TYPE_RAW:
-#if 1
+#if 0
 		CRF (gp_file_set_data_and_size (file, data, size), data);
 		CHECK_RESULT (gp_file_set_mime_type (file, GP_MIME_RAW));
 		break;


Fixed a switch fall through bug.

Fixed a switch fall through bug.

--- camlibs/stv0680/library.c
+++ camlibs/stv0680/library.c
@@ -147,6 +147,7 @@
 			return ret;
 		}
 	    }
+	    break;
 	}
 	default:
 	    return GP_ERROR_NOT_SUPPORTED;


rpcsvc: allocate a new program structure before registering it.

Signed-off-by: Raghavendra G <raghavendra@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>

BUG: 1836 (server is hung in infinite loop while trying to search for an actor during request processing)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1836

--- rpc/rpc-lib/src/rpcsvc.c
+++ rpc/rpc-lib/src/rpcsvc.c
@@ -2016,7 +2016,9 @@
 inline int
 rpcsvc_program_register (rpcsvc_t *svc, rpcsvc_program_t *program)
 {
-        int                      ret              = -1;
+        int               ret                = -1;
+        rpcsvc_program_t *newprog            = NULL;
+        char              already_registered = 0;

         if (!svc) {
                 goto out;
@@ -2025,19 +2027,44 @@
         if (program->actors == NULL) {
                 goto out;
         }
-
-        INIT_LIST_HEAD (&program->program);

         pthread_mutex_lock (&svc->rpclock);
         {
-                list_add_tail (&program->program, &svc->programs);
+                list_for_each_entry (newprog, &svc->programs, program) {
+                        if ((newprog->prognum == program->prognum)
+                            && (newprog->progver == program->progver)) {
+                                already_registered = 1;
+                                break;
+                        }
+                }
+        }
+        pthread_mutex_unlock (&svc->rpclock);
+
+        if (already_registered) {
+                ret = 0;
+                goto out;
+        }
+
+        newprog = GF_CALLOC (1, sizeof(*newprog),gf_common_mt_rpcsvc_program_t);
+        if (newprog == NULL) {
+                gf_log (GF_RPCSVC, GF_LOG_ERROR, "out of memory");
+                goto out;
+        }
+
+        memcpy (newprog, program, sizeof (*program));
+
+        INIT_LIST_HEAD (&newprog->program);
+
+        pthread_mutex_lock (&svc->rpclock);
+        {
+                list_add_tail (&newprog->program, &svc->programs);
         }
         pthread_mutex_unlock (&svc->rpclock);

         ret = 0;
         gf_log (GF_RPCSVC, GF_LOG_DEBUG, "New program registered: %s, Num: %d,"
-                " Ver: %d, Port: %d", program->progname, program->prognum,
-                program->progver, program->progport);
+                " Ver: %d, Port: %d", newprog->progname, newprog->prognum,
+                newprog->progver, newprog->progport);

 out:
         if (ret == -1) {


Fixed app directory resolving under Win32

git-svn-id: ab66a9de07fa9d47c5829c82992f5279466c775f@3193 63c20433-aa62-49bd-875c-5a186b69a8fb

--- src/utils/os_config_init.c
+++ src/utils/os_config_init.c
@@ -91,12 +91,17 @@
 #endif

 	/*remove exe name*/
-	sep = strrchr(file_path, '\\');
-	if (sep) sep[0] = 0;
+	if (strstr(file_path, ".exe")) {
+		sep = strrchr(file_path, '\\');
+		if (sep) sep[0] = 0;
+	}
+
+	strcpy(szPath, file_path);
+	strlwr(szPath);

 	/*if this is run from a browser, we do not get our app path - fortunately on Windows, we always use 'GPAC' in the
 	installation path*/
-	if (!strstr(file_path, "GPAC")) {
+	if (!strstr(file_path, "gpac")) {
 		HKEY hKey = NULL;
 		DWORD dwSize = GF_MAX_PATH;
 		DWORD dwType = REG_SZ;


fixes Dr. Memory issue 665: need to preserve xmm6 + xmm7 for 32-bit Windows

git-svn-id: ed337ca7cdb08c0ba29d8fe58632bb7686892c2d@1145 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6

--- core/lib/globals_shared.h
+++ core/lib/globals_shared.h
@@ -1516,34 +1516,6 @@
  * so we have no alignment declarations there at the moment either.
  */

-/* PR 306394: for 32-bit xmm0-7 are caller-saved, and are touched by
- * libc routines invoked by DR in some Linux systems (xref i#139),
- * so they should be saved in 32-bit Linux.
- */
-/* Xref i#139:
- * XMM register preservation will cause extra runtime overhead.
- * We test it over 32-bit SPEC2006 on a 64-bit Debian Linux, which shows
- * that DR with xmm preservation adds negligible overhead over DR without
- * xmm preservation.
- * It means xmm preservation would have little performance impact over
- * DR base system. This is mainly because DR's own operations' overhead
- * is much higher than the context switch overhead.
- * However, if a program is running with a DR client which performs many
- * clean calls (one or more per basic block), xmm preservation may
- * have noticable impacts, i.e. pushing bbs over the max size limit,
- * and could have a noticeable performance hit.
- */
-#ifdef WINDOWS
-# define NUM_XMM_SAVED 6 /* xmm0-5; for 32-bit we have space for xmm0-7 */
-#else
-# ifdef X64
-#  define NUM_XMM_SAVED 16 /* xmm0-15 */
-# else
-/* i#139: save xmm0-7 registers in 32-bit Linux. */
-#  define NUM_XMM_SAVED 8 /* xmm0-7 */
-# endif
-#endif
-
 /* DR_API EXPORT TOFILE dr_defines.h */
 /* DR_API EXPORT BEGIN */
 /** 128-bit XMM register. */
@@ -1617,4 +1589,29 @@
 #include "mcxtx.h"
 } priv_mcontext_t;

+/* DR_API EXPORT END */
+
+/* PR 306394: for 32-bit xmm0-7 are caller-saved, and are touched by
+ * libc routines invoked by DR in some Linux systems (xref i#139),
+ * so they should be saved in 32-bit Linux.
+ */
+/* Xref i#139:
+ * XMM register preservation will cause extra runtime overhead.
+ * We test it over 32-bit SPEC2006 on a 64-bit Debian Linux, which shows
+ * that DR with xmm preservation adds negligible overhead over DR without
+ * xmm preservation.
+ * It means xmm preservation would have little performance impact over
+ * DR base system. This is mainly because DR's own operations' overhead
+ * is much higher than the context switch overhead.
+ * However, if a program is running with a DR client which performs many
+ * clean calls (one or more per basic block), xmm preservation may
+ * have noticable impacts, i.e. pushing bbs over the max size limit,
+ * and could have a noticeable performance hit.
+ */
+/* We now save everything but we keep separate NUM_XMM_SLOTS vs NUM_XMM_SAVED
+ * in case we go back to not saving some slots in the future: e.g., w/o
+ * CLIENT_INTERFACE we could control our own libs enough to avoid some saves.
+ */
+#define NUM_XMM_SAVED NUM_XMM_SLOTS
+
 #endif /* ifndef _GLOBALS_SHARED_H_ */


avoid freeing queuebuf multiple times, and free buffer after cancelling connection


Restrict the rank to INFINITE_RANK

Restrict the rank to INFINITE_RANK

--- core/net/rpl/rpl-of-etx.c
+++ core/net/rpl/rpl-of-etx.c
@@ -32,7 +32,7 @@
  *
  * This file is part of the Contiki operating system.
  *
- * $Id: rpl-of-etx.c,v 1.3 2010/06/02 16:23:11 joxe Exp $
+ * $Id: rpl-of-etx.c,v 1.4 2010/06/03 12:12:20 nvt-se Exp $
  */
 /**
  * \file
@@ -64,16 +64,15 @@
 #define PATH_ETX_MIN			1
 #define PATH_ETX_MAX			200
 #define PARENT_SWITCH_ETX_THRESHOLD	0.5
-#define INFINITY			0xffff

-typedef unsigned int etx_t;
+typedef uint16_t etx_t;

-static etx_t min_path_etx = INFINITY;
+static etx_t min_path_etx = INFINITE_RANK;

 static void
 reset(void *dag)
 {
-  min_path_etx = INFINITY;
+  min_path_etx = INFINITE_RANK;
 }

 static void
@@ -84,15 +83,15 @@
   dag = (rpl_dag_t *)parent->dag;

   if(known) {
-    if(min_path_etx != INFINITY) {
+    if(min_path_etx != INFINITE_RANK) {
       dag->rank = min_path_etx + etx;
       PRINTF("RPL: New path ETX: %u  min_path_etx=%u etx=%u\n",
              (unsigned)(min_path_etx + etx), min_path_etx, etx);
     }
   } else {
     if(RPL_PARENT_COUNT(dag) == 1) {
-      /* Our last parent has disappeared, set the path ETX to infinity. */
-      min_path_etx = INFINITY;
+      /* Our last parent has disappeared, set the path ETX to INFINITE_RANK. */
+      min_path_etx = INFINITE_RANK;
     }
   }
 }
@@ -109,13 +108,14 @@
     PRINTF("RPL: min_path_etx updated to:%u\n", min_path_etx);
   }

-  /* calculate the rank based on the new rank information from DIO or
-     stored otherwise */
-  new_rank = rank + LINK_ETX_MAX;
-
-  /* if(new_rank < rank) { */
-  /*   return INFINITE_RANK; */
-  /* } */
+  if(INFINITE_RANK - rank < LINK_ETX_MAX) {
+    /* Reached the maximum rank. */
+    new_rank = INFINITE_RANK;
+  } else {
+   /* Calculate the rank based on the new rank information from DIO or
+      stored otherwise. */
+    new_rank = rank + LINK_ETX_MAX;
+  }

   PRINTF("RPL: Path ETX %u\n", (unsigned)new_rank);


vppinfra: optimize and simplify splat inline functions

Example for u32x4 case:
Old code generates 2 instructions:

vmovd  %edi,%xmm0
vpunpckldq %xmm0,%xmm0,%xmm0
vpunpcklqdq %xmm0,%xmm0,%xmm0

New code uses only one instruction:
mov    %edi,-0x4(%rsp)
vbroadcastss -0x4(%rsp),%xmm0

Change-Id: I989dc3025f5fe3f6c880972389ded11f31e2f3f6
Signed-off-by: Damjan Marion <9141bba8b2efed526e55cf796d48631af330ad98@cisco.com>

--- src/vppinfra/vector_sse2.h
+++ src/vppinfra/vector_sse2.h
@@ -175,56 +175,50 @@
 always_inline u64x2
 u64x2_splat (u64 a)
 {
-  u64x2 x = { a };
-  x = u64x2_interleave_lo (x, x);
+  u64x2 x = { a, a };
   return x;
 }

 always_inline u32x4
 u32x4_splat (u32 a)
 {
-  u32x4 x = { a };
-  x = u32x4_interleave_lo (x, x);
-  x = (u32x4) u64x2_interleave_lo ((u64x2) x, (u64x2) x);
+  u32x4 x = { a, a, a, a };
   return x;
 }

 always_inline u16x8
 u16x8_splat (u16 a)
 {
-  u32 t = (u32) a | ((u32) a << 16);
-  return (u16x8) u32x4_splat (t);
+  u16x8 x = { a, a, a, a, a, a, a, a };
+  return x;
 }

 always_inline u8x16
 u8x16_splat (u8 a)
 {
-  u32 t = (u32) a | ((u32) a << 8);
-  t |= t << 16;
-  return (u8x16) u16x8_splat (t);
+  u8x16 x = { a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a };
+  return x;
 }

 always_inline u32x2
 u32x2_splat (u32 a)
 {
-  u32x2 x = { a };
-  x = u32x2_interleave_lo (x, x);
+  u32x2 x = { a, a };
   return x;
 }

 always_inline u16x4
 u16x4_splat (u16 a)
 {
-  u32 t = (u32) a | ((u32) a << 16);
-  return (u16x4) u32x2_splat (t);
+  u16x4 x = { a, a, a, a };
+  return x;
 }

 always_inline u8x8
 u8x8_splat (u8 a)
 {
-  u32 t = (u32) a | ((u32) a << 8);
-  t |= t << 16;
-  return (u8x8) u32x2_splat (t);
+  u8x8 x = { a, a, a, a, a, a, a, a };
+  return x;
 }

 #define i64x2_splat u64x2_splat


cc3200: Make sure RTC wake value is >= 1ms.

--- cc3200/mods/pybrtc.c
+++ cc3200/mods/pybrtc.c
@@ -192,7 +192,7 @@
     // check if any parameters were passed
     mp_obj_t _callback = mpcallback_find((mp_obj_t)&pyb_rtc_obj);
     if (kw_args->used > 0 || !_callback) {
-        uint32_t f_mseconds = args[3].u_int;
+        uint32_t f_mseconds = MAX(1, args[3].u_int);
         uint32_t seconds;
         uint16_t mseconds;
         // get the seconds and the milliseconds from the RTC


Remove `#ifdef` catering to MSVC 2012 and earlier in `math_funcs.h`

For the `master` branch, the minimum supported MSVC version is now
MSVC 2017 (with MSVC 2019 being recommended).

--- core/math/math_funcs.h
+++ core/math/math_funcs.h
@@ -384,28 +384,10 @@
 		return u.d;
 	}

-	//this function should be as fast as possible and rounding mode should not matter
+	// This function should be as fast as possible and rounding mode should not matter.
 	static _ALWAYS_INLINE_ int fast_ftoi(float a) {
-		static int b;
-
-#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0603) || WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP // windows 8 phone?
-		b = (int)((a > 0.0) ? (a + 0.5) : (a - 0.5));
-
-#elif defined(_MSC_VER) && _MSC_VER < 1800
-		__asm fld a __asm fistp b
-		/*#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) )
-		// use AT&T inline assembly style, document that
-		// we use memory as output (=m) and input (m)
-		__asm__ __volatile__ (
-		"flds %1        \n\t"
-		"fistpl %0      \n\t"
-		: "=m" (b)
-		: "m" (a));*/
-
-#else
-		b = lrintf(a); //assuming everything but msvc 2012 or earlier has lrint
-#endif
-		return b;
+		// Assuming every supported compiler has `lrint()`.
+		return lrintf(a);
 	}

 	static _ALWAYS_INLINE_ uint32_t halfbits_to_floatbits(uint16_t h) {


- Remove redundant include of platform/globals.h.

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

git-svn-id: c93d8a2297af3b929165606efe145742a534bc71@21860 260f80e4-7a28-3924-810f-c04153c831b5

--- runtime/vm/class_table.h
+++ runtime/vm/class_table.h
@@ -6,7 +6,6 @@
 #define VM_CLASS_TABLE_H_

 #include "platform/assert.h"
-#include "platform/globals.h"
 #include "vm/globals.h"

 namespace dart {


*** empty log message ***

*** empty log message ***

git-svn-id: 17d41c460f3ddabe6271dd210d2e0bf85f349cae@362 29311d96-e01e-0410-9327-a35deaab8ce9

--- ceph/client/Buffercache.h
+++ ceph/client/Buffercache.h
@@ -16,6 +16,20 @@
 class Buffercache;

 class Bufferhead : public LRUObject {
+  int ref;
+
+  int get() {
+	assert(ref >= 0);
+	if (ref == 0) lru_pin();
+	ref++;
+  }
+  int put() {
+	assert(ref > 0);
+	ref--;
+	if (ref == 0) lru_unpin();
+  }
+
+
  public: // FIXME: make more private and write some accessors
   off_t offset;
   size_t len;
@@ -27,11 +41,11 @@
   // write_waiters: threads waiting for writes into the buffer
   list<Cond*> read_waiters, write_waiters;
   Buffercache *bc;
-  ref = 0;

   // cons/destructors
-  Bufferhead(inodeno_t ino, off_t off, size_t len, Buffercache *bc, int state=BUFHD_STATE_CLEAN) {
-    this->ino = ino;
+  Bufferhead(inodeno_t ino, off_t off, size_t len, Buffercache *bc, int state=BUFHD_STATE_CLEAN)
+	: ref(0) {
+	this->ino = ino;
     this->offset = off;
 	this->len = len;
 	this->state = state;
@@ -41,39 +55,29 @@
   }

   ~Bufferhead() {
-    list<bufferptr> bl = bh->bl.buffers();
-    for (list<bufferptr>::iterator it == bl.begin();
-         it != bl.end();
-         it++) {
-      delete *it;
-    }
   }

   //Bufferhead(inodeno_t ino, off_t off, size_t len, int state);
   // ~Bufferhead(); FIXME: need to mesh with allocator scheme

-  void get() {
-    ref++;
-    assert(ref > 0);
-  }
-
-  void put() {
-    assert (ref > 0);
-    ref--;
-    if (ref == 0) {
-      assert(!lru_pinned);
-      delete this;
-    }
-  }
-
-  void add_read_waiter(Cond *cond) {
-    read_waiters->push_back(cond);
-	lru_pin();
-  }
-
-  void add_write_waiter(Cond *cond) {
-    write_waiters->push_back(cond);
-	lru_pin();
+
+  /** wait_for_(read|write)
+   * put Cond on local stack, block until woken up.
+   * _caller_ pins to avoid any race weirdness
+   */
+  void wait_for_read(Mutex &lock) {
+	Cond cond;
+	get();
+	read_waiters.push_back(&cond);
+	cond.Wait(lock);
+	put();
+  }
+  void wait_for_write(Mutex &lock) {
+	Cond cond;
+	get();
+	write_waiters.push_back(&cond);
+	cond.Wait(lock);
+	put();
   }

   void wakeup_read_waiters() {
@@ -83,9 +87,7 @@
 	  (*it)->Signal();
 	}
     read_waiters.clear();
-	if (write_waiters.empty()) lru_unpin();
-  }
-
+  }
   void wakeup_write_waiters() {
     for (list<Cond*>::iterator it = write_waiters.begin();
 		 it != write_waiters.end();
@@ -93,7 +95,6 @@
 	  (*it)->Signal();
 	}
     write_waiters.clear();
-	if (read_waiters.empty()) lru_unpin();
   }

   void miss_start() {
@@ -108,7 +109,7 @@
 	wakeup_write_waiters();
   }

-  void dirty() {
+  void mark_dirty() {
     if (state == BUFHD_STATE_CLEAN) {
       state = BUFHD_STATE_DIRTY;
       bc->dirty_size += bh->len;
@@ -151,6 +152,7 @@
   }
 };

+
 class Filecache {
  public:
   map<off_t, Bufferhead*> buffer_map;


i#1569 AArch64: Correct definition of DR_REG_SYSNUM.

Review-URL: https://codereview.appspot.com/301250043

--- core/unix/os_exports.h
+++ core/unix/os_exports.h
@@ -102,7 +102,15 @@
 #define TLS_REG_LIB  LIB_SEG_TLS  /* TLS reg commonly used by libraries in Linux */
 #define TLS_REG_ALT  SEG_TLS      /* spare TLS reg, used by DR in X86 Linux */

-#define DR_REG_SYSNUM IF_X86_ELSE(REG_EAX/* not XAX */, DR_REG_R7)
+#ifdef X86
+# define DR_REG_SYSNUM REG_EAX /* not XAX */
+#elif defined(ARM)
+# define DR_REG_SYSNUM DR_REG_R7
+#elif defined(AARCH64)
+# define DR_REG_SYSNUM DR_REG_X8
+#else
+# error NYI
+#endif

 #ifdef AARCHXX
 # ifdef ANDROID


fixed the clear_and_remove_attributes method.

Signed-off-by: Étienne Schmitt <25d5031dc1a1d443222aec9a4e916501ae23c255@inria.fr>

--- cgogn/core/map/map_base.h
+++ cgogn/core/map/map_base.h
@@ -81,7 +81,7 @@
 	Self& operator=(Self &&) = delete;

 	/**
-	 * @brief clear : clear the topology (empty the dart attributes) leaving the other attributes unmodified
+	 * @brief clear : clear the topology (empty the dart attributes including embeddings) leaving the other attributes unmodified
 	 */
 	inline void clear()
 	{
@@ -98,15 +98,23 @@
 	{
 		this->topology_.clear_attributes();

-		for (unsigned int j = 0u; j < NB_THREADS; ++j)
-			this->mark_attributes_topology_[j].clear();
-
-		for (unsigned int i = 0u; i < NB_ORBITS; ++i)
-		{
-			this->attributes_[i].remove_attributes();
-			this->embeddings_[i] = nullptr;
-			for (unsigned int j = 0u; j < NB_THREADS; ++j)
-					this->mark_attributes_[i][j].clear();
+		for (auto& mark_att_topo : this->mark_attributes_topology_)
+			mark_att_topo.clear();
+
+		for (auto& att : this->attributes_)
+			att.remove_attributes();
+
+		for (std::size_t i = 0u; i < NB_ORBITS; ++i)
+		{
+			if (this->embeddings_[i] != nullptr)
+			{
+				this->topology_.remove_attribute(this->embeddings_[i]);
+				this->embeddings_[i] = nullptr;
+				this->global_topo_cache_[i] = nullptr;
+			}
+
+			for (auto& mark_attr : this->mark_attributes_[i])
+				mark_attr.clear();
 		}
 	}


Refactored tool utilities

Refactored tool utilities

--- src/worker/ToolUtilities.h
+++ src/worker/ToolUtilities.h
@@ -18,33 +18,41 @@
     CToolUtilities() { }
     virtual ~CToolUtilities() { }
 public:
-    void Download(CTool& tool, bool bExtract, bool bInstall, int nIndex, CConfiguration *pConfig, std::function<void(int, CString)> callback)
+    bool Download(CTool& tool, bool bExtract, bool bInstall, int nIndex, CConfiguration *pConfig, std::function<void(int, CString)> callback = nullptr)
     {
         CDownload m_Download;
         CString szUrl = tool.szUrl;
         CString szFilePath = m_App.CombinePath(m_App.szToolsPath, tool.szFile);
         CString szFolderPath = m_App.CombinePath(m_App.szToolsPath, ::GetOnlyFileName(tool.szFile));

-        m_Download.Download(szUrl, szFilePath,
+        bool bResult = m_Download.Download(szUrl, szFilePath,
             [nIndex, pConfig, callback](int nProgress, CString szStatus)
         {
-            for (int s = 0; s < 8; s++)
+            if (callback != nullptr)
             {
-                if (szStatus.Find(pszDownloadStatus[s]) >= 0)
+                for (int s = 0; s < 8; s++)
                 {
-                    CString szTranslation = pConfig->m_Language.GetString(0x00400001 + s, pszDownloadStatus[s]);
-                    szStatus.Replace(pszDownloadStatus[s], szTranslation);
+                    if (szStatus.Find(pszDownloadStatus[s]) >= 0)
+                    {
+                        CString szTranslation = pConfig->m_Language.GetString(0x00400001 + s, pszDownloadStatus[s]);
+                        szStatus.Replace(pszDownloadStatus[s], szTranslation);
+                    }
                 }
+                callback(nIndex, szStatus);
             }
+        });

-            callback(nIndex, szStatus);
-        });
+        if (bResult == false)
+        {
+            return false;
+        }

         if (tool.szExtract.CompareNoCase(_T("install")) == 0)
         {
             if (bInstall == true)
             {
                 ::LaunchAndWait(szFilePath, _T(""), TRUE);
+                return true;
             }
         }

@@ -59,8 +67,12 @@
                 {
                     if (::MakeFullPath(szFolderPath) == false)
                     {
-                        CString szStatus = pConfig->m_Language.GetString(0x00410001, pszExtractStatus[0]);
-                        callback(nIndex, szStatus);
+                        if (callback != nullptr)
+                        {
+                            CString szStatus = pConfig->m_Language.GetString(0x00410001, pszExtractStatus[0]);
+                            callback(nIndex, szStatus);
+                        }
+                        return false;
                     }
                 }

@@ -69,17 +81,43 @@
                     bool bUnzipResult = ::Unzip2Folder(file, folder);
                     if (bUnzipResult == true)
                     {
-                        CString szStatus = pConfig->m_Language.GetString(0x00410002, pszExtractStatus[1]);
-                        callback(nIndex, szStatus);
+                        if (callback != nullptr)
+                        {
+                            CString szStatus = pConfig->m_Language.GetString(0x00410002, pszExtractStatus[1]);
+                            callback(nIndex, szStatus);
+                        }
+                        return true;
                     }
                     else
                     {
-                        CString szStatus = pConfig->m_Language.GetString(0x00410003, pszExtractStatus[2]);
-                        callback(nIndex, szStatus);
+                        if (callback != nullptr)
+                        {
+                            CString szStatus = pConfig->m_Language.GetString(0x00410003, pszExtractStatus[2]);
+                            callback(nIndex, szStatus);
+                        }
+                        return false;
                     }
                 }
             }
         }
+    }
+    int FindTool(CToolsList& m_Tools, CString szPlatform, CString szFormatId)
+    {
+        int nTool = m_Tools.GetToolByFormatAndPlatform(szFormatId, szPlatform);
+        if (nTool >= 0)
+        {
+            return nTool;
+        }
+        return -1;
+    }
+    int FindTool(CToolsList& m_Tools, CString szFormatId)
+    {
+#if defined(_WIN32) & !defined(_WIN64)
+        CString szPlatform = _T("x86");
+#else
+        CString szPlatform = _T("x64");
+#endif
+        return FindTool(m_Tools, szFormatId);
     }
     void SetFormatPaths(CFormatsList& m_Formats, CToolsList& m_Tools, CString szPlatform)
     {


[http] fixes HEAD requests not sending the right Content-Length.

--- src/x0/http/HttpResponse.h
+++ src/x0/http/HttpResponse.h
@@ -220,7 +220,7 @@
 			if (static_cast<int>(status) == 0)
 				status = http_error::not_found;

-			if (!content_forbidden())
+			if (!content_forbidden() && status != http_error::ok)
 				write(make_default_content(), std::bind(&HttpResponse::onFinished, this, std::placeholders::_1));
 			else
 				connection_->writeAsync(serialize(), std::bind(&HttpResponse::onFinished, this, std::placeholders::_1));


Fix for C2036 void pointer unknown size build error on Windows.

--- channels/rail/rail_main.c
+++ channels/rail/rail_main.c
@@ -128,7 +128,7 @@
 	while (data && data->size > 0)
 	{
 		rail_process_plugin_data(rail_order, data);
-		data = (RDP_PLUGIN_DATA*)(((void*) data) + data->size);
+		data = (RDP_PLUGIN_DATA*)((char *)(data) + data->size);
 	}
 }


CrankMatFloat4: fixed mulv operation.

CrankMatFloat4: fixed mulv operation.


Create File.h

Create File.h

--- cpp/lib/include/File.h
+++ cpp/lib/include/File.h
@@ -100,7 +100,7 @@
     inline int get() {
         if (unlikely(pushed_back_count_ > 0)) {
             const char pushed_back_char(pushed_back_chars_[0]);
-            ++pushed_back_count_;
+            --pushed_back_count_;
             for (unsigned i(0); i < pushed_back_count_; ++i)
                 pushed_back_chars_[i] = pushed_back_chars_[i + 1];
             return pushed_back_char;


Forgot a "const".

Forgot a "const".

--- cpp/lib/include/MARC.h
+++ cpp/lib/include/MARC.h
@@ -171,6 +171,14 @@
         return extracted_values;
     }

+    /** \return Either the contents of the subfield or the empty string if no corresponding subfield was found. */
+    inline std::string getFirstSubfieldWithCode(const char subfield_code) const {
+        const auto iter(std::find_if(subfields_.cbegin(), subfields_.cend(),
+                                     [subfield_code](const Subfield subfield) -> bool
+                                         { return subfield.code_ == subfield_code; }));
+        return (iter == subfields_.cend()) ? "" : iter->value_;
+    }
+
     /** \brief Extracts all values from subfields with a matching subfield code.
      *  \return The values of the subfields with matching codes.
      */


Really really prevent llvm-config's NDEBUG from removing our asserts.

--- cpp/src/LLVM_Headers.h
+++ cpp/src/LLVM_Headers.h
@@ -69,6 +69,7 @@
 // llvm may sometimes define NDEBUG, which is annoying, because we always want asserts
 #ifdef NDEBUG
 #undef NDEBUG
+#include <assert.h>
 #endif

 #endif


chip/stm32/clock-stm32l.c: Format with clang-format

BUG=b:236386294
BRANCH=none
TEST=none

Change-Id: I47ca0a89182b88321ae6e8bc65349349bb818ad5
Signed-off-by: Jack Rosenthal <d3f605bef1867f59845d4ce6e4f83b8dc9e4e0ae@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729467
Reviewed-by: Jeremy Bettis <4df7b5147fee087dca33c181f288ee7dbf56e022@chromium.org>

--- chip/stm32/clock-stm32l.c
+++ chip/stm32/clock-stm32l.c
@@ -37,9 +37,9 @@
 #define MSI_1MHZ_CLOCK BIT(20)

 enum clock_osc {
-	OSC_INIT = 0,	/* Uninitialized */
-	OSC_HSI,	/* High-speed oscillator */
-	OSC_MSI,	/* Med-speed oscillator @ 1 MHz */
+	OSC_INIT = 0, /* Uninitialized */
+	OSC_HSI, /* High-speed oscillator */
+	OSC_MSI, /* Med-speed oscillator @ 1 MHz */
 };

 static int freq;
@@ -86,8 +86,8 @@
 	switch (osc) {
 	case OSC_HSI:
 		/* Ensure that HSI is ON */
-		wait_for_ready(&STM32_RCC_CR,
-			       STM32_RCC_CR_HSION, STM32_RCC_CR_HSIRDY);
+		wait_for_ready(&STM32_RCC_CR, STM32_RCC_CR_HSION,
+			       STM32_RCC_CR_HSIRDY);

 		/* Disable LPSDSR */
 		STM32_PWR_CR &= ~STM32_PWR_CR_LPSDSR;
@@ -122,7 +122,7 @@
 		STM32_RCC_CFGR = STM32_RCC_CFGR_SW_HSI;
 		/* RM says to check SWS bits to make sure HSI is the sysclock */
 		while ((STM32_RCC_CFGR & STM32_RCC_CFGR_SWS_MASK) !=
-			STM32_RCC_CFGR_SWS_HSI)
+		       STM32_RCC_CFGR_SWS_HSI)
 			;

 		/* Disable MSI */
@@ -137,14 +137,14 @@
 			(STM32_RCC_ICSCR & ~STM32_RCC_ICSCR_MSIRANGE_MASK) |
 			STM32_RCC_ICSCR_MSIRANGE_1MHZ;
 		/* Ensure that MSI is ON */
-		wait_for_ready(&STM32_RCC_CR,
-			       STM32_RCC_CR_MSION, STM32_RCC_CR_MSIRDY);
+		wait_for_ready(&STM32_RCC_CR, STM32_RCC_CR_MSION,
+			       STM32_RCC_CR_MSIRDY);

 		/* Switch to MSI */
 		STM32_RCC_CFGR = STM32_RCC_CFGR_SW_MSI;
 		/* RM says to check SWS bits to make sure MSI is the sysclock */
 		while ((STM32_RCC_CFGR & STM32_RCC_CFGR_SWS_MASK) !=
-			STM32_RCC_CFGR_SWS_MSI)
+		       STM32_RCC_CFGR_SWS_MSI)
 			;

 		/*
@@ -208,7 +208,6 @@

 	/* Only change clock if needed */
 	if ((!!new_mask) != (!!clock_mask)) {
-
 		/* Flush UART before switching clock speed */
 		cflush();

@@ -314,7 +313,7 @@
 	}
 }
 DECLARE_HOOK(HOOK_POWER_BUTTON_CHANGE, fake_hibernate_power_button_hook,
-	HOOK_PRIO_DEFAULT);
+	     HOOK_PRIO_DEFAULT);

 static void fake_hibernate_lid_hook(void)
 {
@@ -379,6 +378,5 @@
 	ccprintf("Clock frequency is now %d Hz\n", freq);
 	return EC_SUCCESS;
 }
-DECLARE_CONSOLE_COMMAND(clock, command_clock,
-			"hsi | msi",
+DECLARE_CONSOLE_COMMAND(clock, command_clock, "hsi | msi",
 			"Set clock frequency");


ASN1: Make ASN1_item_verify_ctx() work with provider-native keys

Reviewed-by: Matt Caswell <1fa2ef4755a9226cb9a0a4840bd89b158ac71391@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12587)

--- crypto/asn1/a_verify.c
+++ crypto/asn1/a_verify.c
@@ -163,7 +163,7 @@
         }

         /* Check public key OID matches public key type */
-        if (EVP_PKEY_type(pknid) != pkey->ameth->pkey_id) {
+        if (!EVP_PKEY_is_a(pkey, OBJ_nid2sn(pknid))) {
             ASN1err(0, ASN1_R_WRONG_PUBLIC_KEY_TYPE);
             goto err;
         }


Cleanup ASN1 OID module when it exits.

Cleanup ASN1 OID module when it exits.

--- crypto/asn1/asn_moid.c
+++ crypto/asn1/asn_moid.c
@@ -87,9 +87,14 @@
 			}
 		}
 	return 1;
-}
+	}
+
+static void oid_module_finish(CONF_IMODULE *md)
+	{
+	OBJ_cleanup();
+	}

 void ASN1_add_oid_module(void)
 	{
-	CONF_module_add("oid_section", oid_module_init, 0);
+	CONF_module_add("oid_section", oid_module_init, oid_module_finish);
 	}


Free up ADB and CHOICE if already initialised.

CVE-2015-0287

Reviewed-by: Tim Hudson <eb0be8e447f673b41b10eda09d63cd72526b0a42@openssl.org>
Reviewed-by: Emilia Käsper <6521fc25e7624eef7c3a0d89b71de7e612d27d37@openssl.org>

--- crypto/asn1/tasn_dec.c
+++ crypto/asn1/tasn_dec.c
@@ -303,9 +303,16 @@
     case ASN1_ITYPE_CHOICE:
         if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
             goto auxerr;
-
-        /* Allocate structure */
-        if (!*pval && !ASN1_item_ex_new(pval, it)) {
+        if (*pval) {
+            /* Free up and zero CHOICE value if initialised */
+            i = asn1_get_choice_selector(pval, it);
+            if ((i >= 0) && (i < it->tcount)) {
+                tt = it->templates + i;
+                pchptr = asn1_get_field_ptr(pval, tt);
+                ASN1_template_free(pchptr, tt);
+                asn1_set_choice_selector(pval, -1, it);
+            }
+        } else if (!ASN1_item_ex_new(pval, it)) {
             ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
             goto err;
         }
@@ -384,6 +391,17 @@

         if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
             goto auxerr;
+
+        /* Free up and zero any ADB found */
+        for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
+            if (tt->flags & ASN1_TFLG_ADB_MASK) {
+                const ASN1_TEMPLATE *seqtt;
+                ASN1_VALUE **pseqval;
+                seqtt = asn1_do_adb(pval, tt, 1);
+                pseqval = asn1_get_field_ptr(pval, seqtt);
+                ASN1_template_free(pseqval, seqtt);
+            }
+        }

         /* Get each field entry */
         for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {


crypto/x509/x509_vpm.c: Simplify int_x509_param_set1()

This change also avoids calling strlen twice when srclen is 0

Reviewed-by: Rich Salz <c04971a99e5a9ee80eaab4b1deb37e845b0bd697@openssl.org>
Reviewed-by: Matt Caswell <1fa2ef4755a9226cb9a0a4840bd89b158ac71391@openssl.org>

--- crypto/x509/x509_vpm.c
+++ crypto/x509/x509_vpm.c
@@ -259,12 +259,11 @@
 {
     void *tmp;
     if (src) {
-        if (srclen == 0) {
-            tmp = OPENSSL_strdup(src);
+        if (srclen == 0)
             srclen = strlen(src);
-        } else
-            tmp = OPENSSL_memdup(src, srclen);
-        if (!tmp)
+
+        tmp = OPENSSL_memdup(src, srclen);
+        if (tmp == NULL)
             return 0;
     } else {
         tmp = NULL;
@@ -272,7 +271,7 @@
     }
     OPENSSL_free(*pdest);
     *pdest = tmp;
-    if (pdestlen)
+    if (pdestlen != NULL)
         *pdestlen = srclen;
     return 1;
 }


Added a HighPrecisionTimer class for recording the metrics

--- cvmfs/util/algorithm.h
+++ cvmfs/util/algorithm.h
@@ -14,6 +14,7 @@
 #include "atomic.h"
 #include "murmur.h"
 // TODO(jblomer): should be also part of algorithm
+#include "platform.h"
 #include "prng.h"
 #include "util/single_copy.h"

@@ -106,6 +107,7 @@
   timeval start_, end_;
 };

+
 /**
  * Log2Histogram is a simple implementation of
  * log2 histogram data structure which stores
@@ -159,6 +161,23 @@
   std::vector<atomic_int32> GetBins(const Log2Histogram &h);
 };

+
+class HighPrecisionTimer : SingleCopy {
+ public:
+  explicit HighPrecisionTimer(Log2Histogram *recorder)
+    : timestamp_start_(platform_monotonic_time_ns())
+    , recorder_(recorder)
+  { }
+
+  ~HighPrecisionTimer() {
+    recorder_->Add(platform_monotonic_time_ns() - timestamp_start_);
+  }
+
+ private:
+  uint64_t timestamp_start_;
+  Log2Histogram *recorder_;
+};
+
 #ifdef CVMFS_NAMESPACE_GUARD
 }  // namespace CVMFS_NAMESPACE_GUARD
 #endif


edited the comment on the first line to match to example name

--- 002-math-with-printf/main.c
+++ 002-math-with-printf/main.c
@@ -1,4 +1,4 @@
-/* calc with printf */
+/* math with printf */

 #include <stdio.h>


multiple-send

multiple-send

--- Classes/main.c
+++ Classes/main.c
@@ -22,6 +22,14 @@

 #define BUFFER_SIZE 1500

+rbool sendToArgument(pointer context, pointer object, size_t iterator) {
+    RTCPDataStruct *data = object;
+    if(data->socket != nil) {
+        $(data->socket, m(sendString, RSocket)), context);
+    }
+    return yes;
+}
+
 pointer exec(RTCPDataStruct *data) {
     char    buffer[BUFFER_SIZE];
     const char    *address = addressToString(&data->socket->address);
@@ -29,6 +37,8 @@
     unsigned currentThread =  (unsigned int) currentThreadIdentifier();
     byte     resultFlag;
     size_t   receivedSize;
+    REnumerateDelegate executor;
+    executor.virtualEnumerator = sendToArgument;

     RPrintf("[I] %s:%u connected [tuid : %u]\n", address, port, currentThread);

@@ -38,7 +48,12 @@
     while(resultFlag != networkConnectionClosedConst) {
         buffer[receivedSize] = 0;
         RPrintf("%s:%u[%u] > %s", address, port, currentThread, buffer);
-        $(data->socket, m(send, RSocket)), buffer, receivedSize);
+
+        executor.context = RCStringInit(buffer, receivedSize);
+
+        $(((RTCPHandler*)data->context)->arguments, m(enumerate, RArray)), &executor, yes);
+        deallocator(executor.context);
+
         resultFlag =  $(data->socket, m(receive, RSocket)), buffer, BUFFER_SIZE, &receivedSize);
     }


anybody here fixed

anybody here fixed

--- Classes/main.c
+++ Classes/main.c
@@ -161,8 +161,10 @@
         chatRoomList = $(data->handler->arguments, m(subarrayWithPredicate, RArray)), &chatRoomPredicate);

         if(chatRoomList != nil) {
+            chatRoomList->destructorDelegate = nil;
+            $(chatRoomList, m(deleteObject, RArray)), data); // delete self record
+
             $(chatRoomList, m(enumerate, RArray)), &listEnumerator, yes);
-            chatRoomList->destructorDelegate = nil;
             deleter(chatRoomList, RArray);
         }

@@ -176,7 +178,7 @@

     } else if($(command, m(startsOn, RCString)), RS("exit"))) {

-        $(data->socket, m(sendString, RSocket)), RS("RServer bye c:\n"));
+        $(data->socket, m(sendString, RSocket)), RS("Bye-bye, Johnny.\n"));
         deleter(data->socket, RSocket); // close
         data->socket = nil;
     }
@@ -201,7 +203,8 @@

     RString *welcome = stringWithFormat("Welcome %s\n"
                                         "You enter default chatroom, to change type \'--change chatroom name\'\n"
-                                        "To change nickname \'--set nickname name\'\n", chatData->nickname->baseString);
+                                        "To change nickname \'--set nickname name\'\n"
+                                        "Follow the white rabbit.\n", chatData->nickname->baseString);

     $(data->socket, m(sendString, RSocket)), welcome);
     deleter(welcome, RString);


Print logw to screen

Print logw to screen

--- Code/Sampler.h
+++ Code/Sampler.h
@@ -106,7 +106,8 @@
 	// Set the new threshold
 	threshold[which_scalar] = particles[worst].get_scalars()[which_scalar];

-	std::cout<<"# Iteration "<<(iteration+1)<<". Threshold = (";
+	std::cout<<"# Iteration "<<(iteration+1)<<":"<<std::endl;
+	std::cout<<"# logw = "<<logw<<", threshold = (";
 	for(size_t i=0; i<(threshold.size()-1); i++)
 		std::cout<<threshold[i]<<", ";
 	std::cout<<threshold[threshold.size()-1]<<")."<<std::endl;


CORE-378: Calculate BTC fee basis using transaction fee and size

--- crypto/BRCryptoTransfer.c
+++ crypto/BRCryptoTransfer.c
@@ -407,10 +407,14 @@
     switch (transfer->type) {
         case BLOCK_CHAIN_TYPE_BTC: {
             BRWallet *wid = transfer->u.btc.wid;
-
-            uint64_t fee = BRWalletFeePerKb (wid);
-
-            return cryptoFeeBasisCreateAsBTC (fee);
+            BRTransaction *tid = transfer->u.btc.tid;
+
+            uint64_t fee = BRWalletFeeForTx (wid, tid);
+            uint64_t feePerKb = (UINT64_MAX == fee
+                                 ? DEFAULT_FEE_PER_KB
+                                 : (fee * 1000) / BRTransactionVSize (tid));
+
+            return cryptoFeeBasisCreateAsBTC (feePerKb);
         }
         case BLOCK_CHAIN_TYPE_ETH: {
             BREthereumEWM ewm = transfer->u.eth.ewm;


g: recover from usb_upgrade interruptions

The usb upgrade protocol is very fragile, any error while transferring
data causes the state machine on the target to lock up, and the only
way to resume the upgrade is to power cycle the device.

With this patch USB callbacks which happen more than 5 seconds since
the previous callback would be considered a start of new transfer,
thus allowing to attempt a new upgrade without the power cycle.

BRANCH=none
BUG=chrome-os-partner:52856
TEST=the following script allows to upgrade successfully:
    $ while not  ./extra/usb_updater/usb_updater build/cr50/ec.bin; do sleep 6; done

Change-Id: Ibe1078cf62073ce89a31416522b0d6917bc923b9
Signed-off-by: Vadim Bendebury <5515d6d2d0829cbe0dd0dcf2094aaded06d58514@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/341572
Reviewed-by: Marius Schilder <d423f2980be0298efdef7df239b147d21d472f26@chromium.org>
Reviewed-by: Mary Ruthven <81380f3403fed74252e92df3ed012a1819ec6296@chromium.org>

--- chip/g/usb_upgrade.c
+++ chip/g/usb_upgrade.c
@@ -91,12 +91,37 @@
 static uint32_t block_size;
 static uint32_t block_index;

+/*
+ * When was last time a USB callback was called, in microseconds, free running
+ * timer.
+ */
+static uint64_t prev_activity_timestamp;
+
 /* Called to deal with data from the host */
 static void upgrade_out_handler(struct consumer const *consumer, size_t count)
 {
 	struct update_pdu_header updu;
 	size_t resp_size;
 	uint32_t resp_value;
+	uint64_t delta_time;
+
+	/* How much time since the previous USB callback? */
+	delta_time = get_time().val - prev_activity_timestamp;
+	prev_activity_timestamp += delta_time;
+
+	/* If timeout exceeds 5 seconds - let's start over. */
+	if ((delta_time > 5000000) && (rx_state_ != rx_idle)) {
+		if (block_buffer) {
+			/*
+			 * Previous transfer could have been aborted mid
+			 * block.
+			 */
+			shared_mem_release(block_buffer);
+			block_buffer = NULL;
+		}
+		rx_state_ = rx_idle;
+		CPRINTS("FW update: recovering after timeout\n");
+	}

 	if (rx_state_ == rx_idle) {
 		/* This better be the first block, of zero size. */
@@ -210,10 +235,11 @@
 	 */
 	fw_upgrade_command_handler(block_buffer, block_index, &resp_size);

-	shared_mem_release(block_buffer);
 	resp_value = block_buffer[0];
 	QUEUE_ADD_UNITS(&upgrade_to_usb, &resp_value, sizeof(resp_value));
 	rx_state_ = rx_outside_block;
+	shared_mem_release(block_buffer);
+	block_buffer = NULL;
 }

 static void upgrade_flush(struct consumer const *consumer)


Fix the BdsExpandPartitionPartialDevicePathToFull() hang issue by duplicates BlockIoDevicePath when the CachedDevicePath returned from BdsLibDelPartMatchInstance() is NULL.

Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>

git-svn-id: 3158a46dfd52e07d1fda3e32e1ab2e353a00b20f@14733 6f19259b-4bc3-4df7-8a09-765794883524

--- IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
+++ IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
@@ -2637,17 +2637,16 @@
           TempNewDevicePath = CachedDevicePath;
           CachedDevicePath = BdsLibDelPartMatchInstance (CachedDevicePath, BlockIoDevicePath);
           FreePool(TempNewDevicePath);
-
-          TempNewDevicePath = CachedDevicePath;
-          CachedDevicePath = AppendDevicePathInstance (BlockIoDevicePath, CachedDevicePath);
-          if (TempNewDevicePath != NULL) {
-            FreePool(TempNewDevicePath);
-          }
-        } else {
+        }
+
+        if (CachedDevicePath != NULL) {
           TempNewDevicePath = CachedDevicePath;
           CachedDevicePath = AppendDevicePathInstance (BlockIoDevicePath, CachedDevicePath);
           FreePool(TempNewDevicePath);
+        } else {
+          CachedDevicePath = DuplicateDevicePath (BlockIoDevicePath);
         }
+
         //
         // Here limit the device path instance number to 12, which is max number for a system support 3 IDE controller
         // If the user try to boot many OS in different HDs or partitions, in theory,


Add additional reset when Memory Type Information settings change.

git-svn-id: 5648d1bec6962b0a6d1d1b40eba8cf5cdb62da3d@10879 6f19259b-4bc3-4df7-8a09-765794883524

--- IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
+++ IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
@@ -1117,18 +1117,23 @@
   EFI_MEMORY_TYPE_INFORMATION  *PreviousMemoryTypeInformation;
   EFI_MEMORY_TYPE_INFORMATION  *CurrentMemoryTypeInformation;
   UINTN                        VariableSize;
-  BOOLEAN                      UpdateRequired;
   UINTN                        Index;
   UINTN                        Index1;
   UINT32                       Previous;
   UINT32                       Current;
   UINT32                       Next;
   EFI_HOB_GUID_TYPE            *GuidHob;
+  BOOLEAN                      MemoryTypeInformationModified;
   BOOLEAN                      MemoryTypeInformationVariableExists;

-  UpdateRequired = TRUE;
+  MemoryTypeInformationModified       = FALSE;
   MemoryTypeInformationVariableExists = FALSE;

+  //
+  // Only get the the Memory Type Information variable in the boot mode
+  // other than BOOT_WITH_DEFAULT_SETTINGS because the Memory Type
+  // Information is not valid in this boot mode.
+  //
   if (GetBootModeHob () != BOOT_WITH_DEFAULT_SETTINGS) {
     VariableSize = 0;
     Status = gRT->GetVariable (
@@ -1140,7 +1145,6 @@
                     );
     if (Status == EFI_BUFFER_TOO_SMALL) {
       MemoryTypeInformationVariableExists = TRUE;
-      UpdateRequired = FALSE;
     }
   }

@@ -1210,23 +1214,34 @@

     if (Next != Previous) {
       PreviousMemoryTypeInformation[Index].NumberOfPages = Next;
-      UpdateRequired = TRUE;
+      MemoryTypeInformationModified = TRUE;
     }

     DEBUG ((EFI_D_INFO, "  %02x    %08x  %08x  %08x\n", PreviousMemoryTypeInformation[Index].Type, Previous, Current, Next));
   }

   //
-  // If any changes were made to the Memory Type Information settings, then set the new variable value
-  //
-  if (UpdateRequired || !MemoryTypeInformationVariableExists) {
+  // If any changes were made to the Memory Type Information settings, then set the new variable value;
+  // Or create the variable in first boot.
+  //
+  if (MemoryTypeInformationModified || !MemoryTypeInformationVariableExists) {
     Status = gRT->SetVariable (
-          EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,
-          &gEfiMemoryTypeInformationGuid,
-          EFI_VARIABLE_NON_VOLATILE  | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
-          VariableSize,
-          PreviousMemoryTypeInformation
-          );
+                    EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,
+                    &gEfiMemoryTypeInformationGuid,
+                    EFI_VARIABLE_NON_VOLATILE  | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+                    VariableSize,
+                    PreviousMemoryTypeInformation
+                    );
+
+    //
+    // If the Memory Type Information settings have been modified, then reset the platform
+    // so the new Memory Type Information setting will be used to guarantee that an S4
+    // entry/resume cycle will not fail.
+    //
+    if (MemoryTypeInformationModified) {
+      DEBUG ((EFI_D_ERROR, "Memory Type Information settings change. Warm Reset!!!\n"));
+      gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
+    }
   }
 }


cmdeval(): factor out launching logic

cmdeval(): factor out launching logic

--- command.c
+++ command.c
@@ -10,7 +10,8 @@
 #include "cmd.h"
 #include "addr.h"

-static void	cleanup	(Buffer *, Arg *arg);
+static void	cleanup	(Buffer *, Arg *);
+static int	runcmd (State *, Buffer *, Command *, Arg *, char *err);
 static void	sighandle (int);

 static sigjmp_buf jbuf;
@@ -39,6 +40,51 @@
 }

 int
+runcmd (State *st, Buffer *buf, Command *cmd, Arg *arg, char *err)
+{
+	size_t pos = 0;
+	Selection *sel;
+	String *addr;
+	if (!cmd) {
+		strcpy (err, "unknown command");
+		goto fail;
+	}
+
+	if (cmd->mode) {
+		arg->mode = malloc (strlen (cmd->mode) * sizeof *arg->mode);
+		if (!arg->mode) die("malloc");
+		strcpy (arg->mode, cmd->mode);
+	}
+
+	if (!arg->sel.v && cmd->defaddr) {
+		addr = chartostr (cmd->defaddr);
+
+		sel = getaddr (addr, &pos, buf, err);
+		if (sel == NULL || sel == ERR)
+			goto fail;
+
+		vec_copy (arg->sel, *sel);
+
+		free_vector (*sel);
+		free (sel);
+	}
+
+	return (cmd->func (st, buf, arg, err));
+
+fail:
+	return (FAIL);
+}
+
+void
+sighandle (int signo) {
+	switch (signo) {
+	case SIGINT:
+		siglongjmp (jbuf, 1);
+		break;
+	}
+}
+
+int
 cmdchck (const void *a, const void *b)
 {
 	return strcmp (((char *)a), ((Command *)b)->name);
@@ -48,15 +94,6 @@
 cmdcmp (const void *a, const void *b)
 {
 	return strcmp (((Command *)a)->name, ((Command *)b)->name);
-}
-
-void
-sighandle (int signo) {
-	switch (signo) {
-	case SIGINT:
-		siglongjmp (jbuf, 1);
-		break;
-	}
 }

 #if 0
@@ -98,10 +135,7 @@
 cmdeval (State *st, Buffer *buf, Arg *arg, char *err)
 {
 	int ret = FAIL;
-	size_t pos = 0;
 	Command *cmd;
-	Selection *sel;
-	String *addr;

 	act.sa_handler = sighandle;

@@ -115,36 +149,12 @@
 	cmd = bsearch (arg->name, st->cmds.v, st->cmds.c,
 			sizeof *st->cmds.v, &cmdchck);

-	if (!cmd) {
-		strcpy (err, "unknown command");
-		ret = FAIL;
-		goto finally;
-	}
-
-	if (cmd->mode) {
-		arg->mode = malloc (strlen (cmd->mode) * sizeof *arg->mode);
-		if (!arg->mode) die("malloc");
-		strcpy (arg->mode, cmd->mode);
-	}
-	if (!arg->sel.v) {
-		addr = chartostr (cmd->defaddr);
-		sel = getaddr (addr, &pos, buf, err);
-		if (sel == NULL || sel == ERR)
-			goto finally;
-
-		vec_copy (arg->sel, *sel);
-		free_vector (*sel);
-		free (sel);
-	}
-
-
-	if (cmd->func (st, buf, arg, err) == FAIL)
-		goto finally;
-
-	ret = SUCC;
+	if (runcmd (st, buf, cmd, arg, err) == SUCC)
+		ret = SUCC;

 finally:
 	cleanup (buf, arg);
-	return ret;
+	return (ret);

 }
+


freearg->param

freearg->param

--- command.c
+++ command.c
@@ -20,6 +20,7 @@
 void
 cleanup (Buffer *buf, Arg *arg)
 {
+	size_t i;
 	/* reset signal handlers */
 	if (sigaction (SIGINT, &old, NULL) == -1)
 		perror ("sigaction");
@@ -28,10 +29,10 @@
 		free (arg->name);
 	if (arg->mode)
 		free (arg->mode);
-	if (arg->cnt) {
-		for (;arg->cnt--;)
-			free (arg->vec[arg->cnt]);
-		free (arg->vec);
+	if (arg->param.c) {
+		for (i = 0;i < arg->param.c; ++i)
+			free (arg->param.v[arg->cnt]);
+		free_vector (arg->param);
 	}
 	free_vector (arg->sel);
 	free (arg);


Fix internal stacks

Fix internal stacks

The internal stacks has changed between releases.

--- erts/emulator/beam/copy.c
+++ erts/emulator/beam/copy.c
@@ -907,7 +907,7 @@
 #define SHTABLE_PUSH(s,x,y,b)					\
 do {								\
     if (s.sp > s.end - SHTABLE_INCR) {				\
-        erl_grow_estack(&s, ESTK_DEF_STACK(s));			\
+        erl_grow_estack(&(s), SHTABLE_INCR);	       		\
     }								\
     *s.sp++ = (x);						\
     *s.sp++ = (y);						\
@@ -959,6 +959,7 @@
         WSTK_DEF_STACK(s),  /* wstart */		\
         WSTK_DEF_STACK(s),  /* wsp */			\
         WSTK_DEF_STACK(s) + DEF_WSTACK_SIZE, /* wend */	\
+        WSTK_DEF_STACK(s),  /* wdflt */ 		\
         ERTS_ALC_T_ESTACK /* alloc_type */		\
     };							\
     int WSTK_CONCAT(s,_bitoffs) = 0;			\
@@ -969,8 +970,9 @@
     /* no WSTK_DEF_STACK(s), read-only */		\
     ErtsWStack s = {					\
         info->bitstore_start,  /* wstart */		\
-        NULL,                  /* wsp, read-only */	\
+        NULL,                  /* wsp,  read-only */	\
         NULL,                  /* wend, read-only */	\
+        NULL,                  /* wdef, read-only */	\
         info->bitstore_alloc_type /* alloc_type */	\
     };							\
     int WSTK_CONCAT(s,_bitoffs) = 0;			\
@@ -983,6 +985,7 @@
         ESTK_DEF_STACK(s),  /* start */			\
         ESTK_DEF_STACK(s),  /* sp */			\
         ESTK_DEF_STACK(s) + DEF_ESTACK_SIZE, /* end */	\
+        ESTK_DEF_STACK(s),  /* default */		\
         ERTS_ALC_T_ESTACK /* alloc_type */		\
     };							\
     Uint ESTK_CONCAT(s,_offset) = 0
@@ -991,8 +994,9 @@
     /* no ESTK_DEF_STACK(s), read-only */		\
     ErtsEStack s = {					\
         info->shtable_start,     /* start */		\
-        NULL,                    /* sp, read-only */	\
+        NULL,                    /* sp,  read-only */	\
         NULL,                    /* end, read-only */	\
+        NULL,                    /* def, read-only */	\
         info->shtable_alloc_type /* alloc_type */	\
     };							\
     /* no ESTK_CONCAT(s,_offset), read-only */


at(const ArrayType*) : Fix a bug.

at(const ArrayType*) : Fix a bug.

--- esidl/include/cplusplus.h
+++ esidl/include/cplusplus.h
@@ -256,6 +256,10 @@
         std::string name = getScopedName(prefixedModuleName, "::dom::ObjectArray");
         write("%s<", name.c_str());
         spec->accept(this);
+        if (spec->isInterface(currentNode))
+        {
+            write("*");
+        }
         write(">");
     }


COMP: Fix for MingW

COMP: Fix for MingW

--- Utilities/tiff/tif_jpeg.c
+++ Utilities/tiff/tif_jpeg.c
@@ -64,7 +64,7 @@
 */

 /* Define "boolean" as unsigned char, not int, per Windows custom. */
-#if defined(WIN32)
+#if defined(WIN32) && !defined(__MINGW32__)
 # ifndef __RPCNDR_H__            /* don't conflict if rpcndr.h already read */
    typedef unsigned char boolean;
 # endif


4G sounds slower than LTE

4G sounds slower than LTE

--- selfdrive/ui/qt/sidebar.h
+++ selfdrive/ui/qt/sidebar.h
@@ -29,7 +29,7 @@
     {cereal::DeviceState::NetworkType::WIFI, "WiFi"},
     {cereal::DeviceState::NetworkType::CELL2_G, "2G"},
     {cereal::DeviceState::NetworkType::CELL3_G, "3G"},
-    {cereal::DeviceState::NetworkType::CELL4_G, "4G"},
+    {cereal::DeviceState::NetworkType::CELL4_G, "LTE"},
     {cereal::DeviceState::NetworkType::CELL5_G, "5G"}
   };
   const QMap<cereal::DeviceState::NetworkStrength, QImage> signal_imgs = {


Document flutter::DartServiceIsolate. (#17301)

--- runtime/dart_service_isolate.h
+++ runtime/dart_service_isolate.h
@@ -11,16 +11,54 @@
 #include <string>

 #include "flutter/fml/compiler_specific.h"
-
 #include "third_party/dart/runtime/include/dart_api.h"

 namespace flutter {

+//------------------------------------------------------------------------------
+/// @brief      Utility methods for interacting with the DartVM managed service
+///             isolate present in debug and profile runtime modes.
+///
 class DartServiceIsolate {
  public:
+  //----------------------------------------------------------------------------
+  /// The handle used to refer to callbacks registered with the service isolate.
+  ///
+  using CallbackHandle = ptrdiff_t;
+
+  //----------------------------------------------------------------------------
+  /// A callback made by the Dart VM when the observatory is ready. The argument
+  /// indicates the observatory URI.
+  ///
   using ObservatoryServerStateCallback =
-      std::function<void(const std::string&)>;
+      std::function<void(const std::string& observatory_uri)>;

+  //----------------------------------------------------------------------------
+  /// @brief      Start the service isolate. This call may only be made in the
+  ///             Dart VM initiated isolate creation callback. It is only valid
+  ///             to make this call when the VM explicitly requests the creation
+  ///             of the service isolate. The VM does this by specifying the
+  ///             script URI to be `DART_VM_SERVICE_ISOLATE_NAME`. The isolate
+  ///             to be designated as the service isolate must already be
+  ///             created (but not running) when this call is made.
+  ///
+  /// @param[in]  server_ip                     The service protocol IP address.
+  /// @param[in]  server_port                   The service protocol port.
+  /// @param[in]  embedder_tag_handler          The library tag handler.
+  /// @param[in]  disable_origin_check          If websocket origin checks must
+  ///                                           be enabled.
+  /// @param[in]  disable_service_auth_codes    If service auth codes must be
+  ///                                           enabled.
+  /// @param[in]  enable_service_port_fallback  If fallback to port 0 must be
+  ///                                           enabled when the bind fails.
+  /// @param      error                         The error when this method
+  ///                                           returns false. This string must
+  ///                                           be freed by the caller using
+  ///                                           `free`.
+  ///
+  /// @return     If the startup was successful. Refer to the `error` for
+  ///             details on failure.
+  ///
   static bool Startup(std::string server_ip,
                       intptr_t server_port,
                       Dart_LibraryTagHandler embedder_tag_handler,
@@ -29,14 +67,32 @@
                       bool enable_service_port_fallback,
                       char** error);

-  using CallbackHandle = ptrdiff_t;
-
-  // Returns a handle for the callback that can be used in
-  // RemoveServerStatusCallback
+  //----------------------------------------------------------------------------
+  /// @brief      Add a callback that will get invoked when the observatory
+  ///             starts up. If the observatory has already started before this
+  ///             call is made, the callback is invoked immediately.
+  ///
+  ///             This method is thread safe.
+  ///
+  /// @param[in]  callback  The callback with information about the observatory.
+  ///
+  /// @return     A handle for the callback that can be used later in
+  ///             `RemoveServerStatusCallback`.
+  ///
   [[nodiscard]] static CallbackHandle AddServerStatusCallback(
       const ObservatoryServerStateCallback& callback);

-  // Accepts the handle returned by AddServerStatusCallback
+  //----------------------------------------------------------------------------
+  /// @brief      Removed a callback previously registered via
+  ///             `AddServiceStatusCallback`.
+  ///
+  ///             This method is thread safe.
+  ///
+  /// @param[in]  handle  The handle
+  ///
+  /// @return     If the callback was unregistered. This may fail if there was
+  ///             no such callback with that handle.
+  ///
   static bool RemoveServerStatusCallback(CallbackHandle handle);

  private:


esn : Network : add memeber function SetInputs()

--- esn/include/esn/network.h
+++ esn/include/esn/network.h
@@ -1,11 +1,16 @@
 #ifndef __ESN_NETWORK_H__
 #define __ESN_NETWORK_H__
+
+#include <vector>

 namespace ESN {

     class Network
     {
     public:
+        virtual void
+        SetInputs( const std::vector< float > & ) = 0;
+
         virtual void
         Step( float step ) = 0;


On the svn-mergeinfo-normalizer branch:
Fix the detection of deleted branches in case the branch got deleted
implicitly by deleting some parent path.

* tools/client-side/svn-mergeinfo-normalizer/log.c
  (svn_min__find_deletion): Correct parameter order.

git-svn-id: b7cd526623d5f0b7bd73edec54ab5793cd4e2f05@1692506 13f79535-47bb-0310-9956-ffa450edef68

--- tools/client-side/svn-mergeinfo-normalizer/log.c
+++ tools/client-side/svn-mergeinfo-normalizer/log.c
@@ -414,7 +414,7 @@
           const char *deleted_path
             = APR_ARRAY_IDX(entry->paths, k, const char *);

-          if (in_subtree(deleted_path, path, NULL))
+          if (in_subtree(path, deleted_path, NULL))
             return entry->revision;
         }
     }


FIX: catalog traversal no_close parameter

--- cvmfs/catalog_traversal.h
+++ cvmfs/catalog_traversal.h
@@ -609,17 +609,21 @@
     assert (job.catalog != NULL);
     this->NotifyListeners(job.GetCallbackData());

-    // close the catalog again after it was processed
-    if (! no_close_) {
-      delete job.catalog; job.catalog = NULL;
-    }
-
-    // we can delete the temporary catalog file here
+    // skip the catalog closing procedure if asked for
+    // Note: In this case it is the user's responsibility to both delete the
+    //       yielded catalog object and the underlying database temp file
+    if (no_close_) {
+      return true;
+    }
+
+    // we can close the catalog here and delete the temporary file
+    delete job.catalog; job.catalog = NULL;
     if (! job.catalog_file_path.empty()) {
       const int retval = unlink(job.catalog_file_path.c_str());
       if (retval != 0) {
         LogCvmfs(kLogCatalogTraversal, error_sink_, "Failed to unlink %s - %d",
                  job.catalog_file_path.c_str(), errno);
+        return false;
       }
     }


Coverity Fixes

Coverity Fixes

--- PWGLF/STRANGENESS/LambdaK0PbPb/AliAnalysisTaskLukeAOD.h
+++ PWGLF/STRANGENESS/LambdaK0PbPb/AliAnalysisTaskLukeAOD.h
@@ -59,7 +59,7 @@

 	TList           *fOutput;        // Output list
 	AliPIDResponse	*fPIDResponse;	 // PID
-	UInt_t			maskIsSelected; // Physics Selection
+	//UInt_t			maskIsSelected; // Physics Selection

     TH1F            *fHistPt;        // Pt spectrum
     TH1F            *fHistEta;       // pseudorapidity spectrum


Added include guard

Added include guard

--- qualify_macros/qualify_macros.h
+++ qualify_macros/qualify_macros.h
@@ -1,3 +1,6 @@
+#ifndef _SGDC_QUALIFY_MACROS_H
+#define _SGDC_QUALIFY_MACROS_H 1
+
 #ifndef SGDC_PREFIX
 #define SGDC_PREFIX SGDC_
 #endif
@@ -18,3 +21,5 @@
 #define _SGDC_QP(f) _SGDC_QP_(SGDC_PREFIX, f, T)
 #define _SGDC_QP_(p, f, T) _QUALIFY_WITH_PREFIX_T (p, f, T)
 #define _QUALIFY_WITH_PREFIX_T(p, f, T) _ ## p ## f ## _ ## T
+
+#endif


Added missing header

Added missing header

--- daedalus/DaedalusStdlib.h
+++ daedalus/DaedalusStdlib.h
@@ -2,6 +2,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string>
+#include <string.h>

 namespace Daedalus
 {
@@ -158,6 +159,18 @@
                 ITM_CAT_MAGIC			= 1<<31,
             };

+            enum Flags
+            {
+                ITEM_SWD	  = 1 << 14,		//	Waffe wird wie ein Schwert behandelt
+                ITEM_AXE	  = 1 << 15,		//	Waffe wird wie eine Axt behandelt
+                ITEM_2HD_SWD  = 1 << 16,		//	Waffe wird wie ein Zweihänder behandelt
+                ITEM_2HD_AXE  = 1 << 17,		//	Waffe wird wie eine Streitaxt behandelt
+                ITEM_BOW	  = 1 << 19,		//	Waffe wird wie ein Bogen behandelt
+                ITEM_CROSSBOW = 1 << 20,		//	Waffe wird wie eine Armbrust behandelt
+                ITEM_AMULET	  = 1 << 22,
+                ITEM_RING	  = 1 << 11,
+            };
+
             // Für alle Items
             int32_t id;
             std::string name, nameID;


e-kermit: let compiler happy

e-kermit: let compiler happy

--- deps/ek/cdefs.h
+++ deps/ek/cdefs.h
@@ -21,7 +21,7 @@
   the cc command line.
 */
 #ifndef HAVE_UCHAR
-typedef unsigned char UCHAR;
+typedef char UCHAR;
 #endif /* HAVE_UCHARE */
 #ifndef HAVE_ULONG
 typedef unsigned long ULONG;


Bug 618718  - Seahorse won't build with --disable-pgp

ifdef'd around this one appropriately.

--- daemon/seahorse-service.c
+++ daemon/seahorse-service.c
@@ -36,9 +36,11 @@
 #include "seahorse-source.h"
 #include "seahorse-util.h"

-#include "../pgp/seahorse-pgp.h"
-#include "../pgp/seahorse-gpgme-source.h"
-#include "../pgp/seahorse-gpgme-key-op.h"
+#if WITH_PGP
+    #include "../pgp/seahorse-pgp.h"
+    #include "../pgp/seahorse-gpgme-source.h"
+    #include "../pgp/seahorse-gpgme-key-op.h"
+#endif

 #include <gio/gio.h>

@@ -194,43 +196,51 @@
     gchar   *comment=NULL;
     SeahorseWidget *swidget;

-    sksrc = seahorse_context_find_source (seahorse_context_for_app (),
-                                          SEAHORSE_PGP_TYPE,
-                                          SEAHORSE_LOCATION_LOCAL);
-    g_return_val_if_fail (sksrc != NULL, FALSE);
-
-    pval = &val;
-
-    if (g_strcmp0 (ktype,"openpgp")==0) {
-        pval = (GValue *)g_hash_table_lookup (values,"name");
-        if ((pval) && (G_VALUE_TYPE (pval) == G_TYPE_STRING))
-            name=g_value_dup_string (pval);
-
-        pval = g_hash_table_lookup (values,"email");
-        if ((pval) && (G_VALUE_TYPE (pval) == G_TYPE_STRING))
-            email=g_value_dup_string (pval);
-
-        pval = g_hash_table_lookup (values,"comment");
-        if ((pval) && (G_VALUE_TYPE (pval) == G_TYPE_STRING))
-            comment=g_value_dup_string (pval);
-
-        seahorse_gpgme_generate_key(sksrc, name, email, comment,
-                        DSA_ELGAMAL, 2048,0);
-
-        g_free (name);
-        name = NULL;
-        g_free (email);
-        email = NULL;
-        g_free (comment);
-        comment = NULL;
-    }
-    else {
+    #if WITH_PGP
+        sksrc = seahorse_context_find_source (seahorse_context_for_app (),
+                                              SEAHORSE_PGP_TYPE,
+                                              SEAHORSE_LOCATION_LOCAL);
+        g_return_val_if_fail (sksrc != NULL, FALSE);
+
+        pval = &val;
+
+        if (g_strcmp0 (ktype,"openpgp")==0) {
+
+                pval = (GValue *)g_hash_table_lookup (values,"name");
+                if ((pval) && (G_VALUE_TYPE (pval) == G_TYPE_STRING))
+                    name=g_value_dup_string (pval);
+
+                pval = g_hash_table_lookup (values,"email");
+                if ((pval) && (G_VALUE_TYPE (pval) == G_TYPE_STRING))
+                    email=g_value_dup_string (pval);
+
+                pval = g_hash_table_lookup (values,"comment");
+                if ((pval) && (G_VALUE_TYPE (pval) == G_TYPE_STRING))
+                    comment=g_value_dup_string (pval);
+
+                seahorse_gpgme_generate_key(sksrc, name, email, comment,
+                                DSA_ELGAMAL, 2048,0);
+
+                g_free (name);
+                name = NULL;
+                g_free (email);
+                email = NULL;
+                g_free (comment);
+                comment = NULL;
+
+        }
+        else {
+            g_set_error (error, SEAHORSE_DBUS_ERROR, SEAHORSE_DBUS_ERROR_INVALID,
+                         _("This keytype is not supported: %s"), ktype);
+            return FALSE;
+        }
+
+        return TRUE;
+    #else
         g_set_error (error, SEAHORSE_DBUS_ERROR, SEAHORSE_DBUS_ERROR_INVALID,
-                     _("This keytype is not supported: %s"), ktype);
+                 _("Support for this feature was not enabled at build time"), NULL);
         return FALSE;
-    }
-
-    return TRUE;
+    #endif
 }


Fixes for clang: base class's functions must be made available for the lookup to succeed.

git-svn-id: acec3fd5b7ea1eb9e79d6329d318e8118ee2e14f@36698 27541ba8-7e3a-0410-8455-c3a389f83636

--- cint/reflex/inc/Reflex/Builder/CollectionProxy.h
+++ cint/reflex/inc/Reflex/Builder/CollectionProxy.h
@@ -110,6 +110,11 @@
    : public Address<typename T::const_reference>
 #endif
 {
+#ifdef _KCC  // KAI compiler
+   typedef Address<typename T::value_type&> Address_t;
+#else
+   typedef Address<typename T::const_reference> Address_t;
+#endif
    typedef T Cont_t;
    typedef typename T::iterator Iter_t;
    typedef typename T::value_type Value_t;
@@ -153,7 +158,7 @@
 #else
       typename T::const_reference ref = *(e->iter());
 #endif
-      return e->fStart = address(ref);
+      return e->fStart = Address_t::address(ref);
    }

@@ -171,7 +176,7 @@
 #else
       typename T::const_reference ref = *(e->iter());
 #endif
-      return address(ref);
+      return Address_t::address(ref);
    }


client/Android: optimize android_end_paint() logic

1. Don't draw to screen if server sends begin/end paint
messages without any real updates.
2. Redraw only summary region that covers really invalidated
part of screen.

--- client/Android/FreeRDPCore/jni/android_freerdp.c
+++ client/Android/FreeRDPCore/jni/android_freerdp.c
@@ -111,20 +111,44 @@

 void android_end_paint(rdpContext* context)
 {
+	int i;
+	int ninvalid;
+	HGDI_RGN cinvalid;
+	int x1, y1, x2, y2;
 	androidContext *ctx = (androidContext*)context;
 	rdpSettings* settings = context->instance->settings;

-	DEBUG_ANDROID("ui_update");
-
 	assert(ctx);
 	assert(settings);
 	assert(context->instance);

-	DEBUG_ANDROID("width=%d, height=%d, bpp=%d", settings->DesktopWidth,
-			settings->DesktopHeight, settings->ColorDepth);
+	ninvalid = ctx->rdpCtx.gdi->primary->hdc->hwnd->ninvalid;
+	if (ninvalid == 0)
+	{
+		DEBUG_ANDROID("ui_update: ninvalid=%d", ninvalid);
+		return;
+	}
+
+	cinvalid = ctx->rdpCtx.gdi->primary->hdc->hwnd->cinvalid;
+
+	x1 = cinvalid[0].x;
+	y1 = cinvalid[0].x + cinvalid[0].y;
+	x2 = cinvalid[0].w;
+	y2 = cinvalid[0].y + cinvalid[0].h;
+
+	for (i = 0; i < ninvalid; i++)
+	{
+		x1 = MIN(x1, cinvalid[i].x);
+		y1 = MIN(y1, cinvalid[i].y);
+		x2 = MAX(x2, cinvalid[i].x + cinvalid[i].w);
+		y2 = MAX(y2, cinvalid[i].y + cinvalid[i].h);
+	}
+
+	DEBUG_ANDROID("ui_update: ninvalid=%d x=%d, y=%d, width=%d, height=%d, bpp=%d",
+			ninvalid, x1, y1, x2 - x1, y2 - y1, settings->ColorDepth);

 	freerdp_callback("OnGraphicsUpdate", "(IIIII)V", context->instance,
-		0, 0, settings->DesktopWidth, settings->DesktopHeight);
+		x1, y1, x2 - x1, y2 - y1);
 }

 void android_desktop_resize(rdpContext* context)


[202. Happy Number][Accepted]committed by Victor

error: pathspec '202-Happy-Number/solution.c' did not match any file(s) known to git

--- 202-Happy-Number/solution.c
+++ 202-Happy-Number/solution.c
@@ -0,0 +1,33 @@
+bool isHappy(int n) {
+    int nDigtal[10]={0};
+    int sum=0;
+    int sumArray[50]={0};
+    int nCount=0;
+    do
+    {
+        memset(nDigtal,0,sizeof(int)*10);
+        int nPos=0;
+        sum=0;
+        while(n!=0)
+        {
+                nDigtal[nPos]=n%10;
+                n/=10;
+                nPos++;
+        }
+        for(int i=0;i<10;i++)
+        {
+            sum+=nDigtal[i]*nDigtal[i];//printf("%d,",nDigtal[i]);
+        }
+        for(int i=0;i<50;++i)
+        {
+                if(sum==sumArray[i])
+                    return false;
+        }
+        sumArray[++nCount]=sum;
+        //printf("\n");
+        n=sum;
+    }while(sum!=1);
+
+    return true;
+
+}


- adjust water marks

- adjust water marks

--- strinet/src/drivers/inet.c
+++ strinet/src/drivers/inet.c
@@ -753,8 +753,8 @@
 	.mi_idname = DRV_NAME,		/* Module name */
 	.mi_minpsz = 0,			/* Min packet size accepted */
 	.mi_maxpsz = (1 << 16),		/* Max packet size accepted */
-	.mi_hiwat = SHEADHIWAT << 2,	/* Hi water mark */
-	.mi_lowat = SHEADLOWAT << 2,	/* Lo water mark */
+	.mi_hiwat = SHEADHIWAT << 4,	/* Hi water mark */
+	.mi_lowat = 0,			/* Lo water mark */
 };

 STATIC struct module_stat ss_rstat __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
@@ -780,8 +780,8 @@
 	.mi_idname = DRV_NAME,		/* Module name */
 	.mi_minpsz = 0,			/* Min packet size accepted */
 	.mi_maxpsz = (1 << 16),		/* Max packet size accepted */
-	.mi_hiwat = SHEADHIWAT + STRHIGH,	/* Hi water mark */
-	.mi_lowat = SHEADLOWAT - STRLOW,	/* Lo water mark */
+	.mi_hiwat = STRHIGH,		/* Hi water mark */
+	.mi_lowat = STRLOW,		/* Lo water mark */
 };

 STATIC streamscall int ss_wput(queue_t *, mblk_t *);
@@ -16165,6 +16165,8 @@
 	int cminor = getminor(*devp);
 	ss_t *ss, **ipp = &ss_opens;
 	const ss_profile_t *prof;
+	mblk_t *mp;
+	struct stroptions *so;

 	if (q->q_ptr != NULL) {
 		return (0);	/* already open */
@@ -16189,6 +16191,8 @@
 	if (sflag == CLONEOPEN)
 #endif
 		cminor = FREE_CMINOR;
+	if (!(mp = allocb(sizeof(*so), BPRI_MED)))
+		return (ENOBUFS);
 	spin_lock_bh(&ss_lock);
 	for (; *ipp; ipp = &(*ipp)->next) {
 		if (cmajor != (*ipp)->cmajor)
@@ -16210,6 +16214,7 @@
 	if (mindex >= SS__CMAJORS || !cmajor) {
 		ptrace(("%s: ERROR: no device numbers available\n", DRV_NAME));
 		spin_unlock_bh(&ss_lock);
+		freeb(mp);
 		return (ENXIO);
 	}
 #if defined LFS
@@ -16222,6 +16227,7 @@
 				DRV_NAME, err));
 			unfreezestr(q, flags);
 			spin_unlock_bh(&ss_lock);
+			freeb(mp);
 			return (err);
 		}
 		if ((err = strqset(q, QHIWAT, 2, STRHIGH))) {
@@ -16229,6 +16235,7 @@
 				DRV_NAME, err));
 			unfreezestr(q, flags);
 			spin_unlock_bh(&ss_lock);
+			freeb(mp);
 			return (err);
 		}
 		unfreezestr(q, flags);
@@ -16239,6 +16246,7 @@
 	if (!(ss = ss_alloc_priv(q, ipp, cmajor, cminor, crp, prof))) {
 		ptrace(("%s: ERROR: No memory\n", DRV_NAME));
 		spin_unlock_bh(&ss_lock);
+		freeb(mp);
 		return (ENOMEM);
 	}
 	/* Create all but raw sockets at open time.  For raw sockets, we do not know the protocol
@@ -16249,9 +16257,23 @@
 	if ((err = ss_sock_init(ss)) < 0) {
 		ptrace(("%s: ERROR: from ss_sock_init %d\n", DRV_NAME, -err));
 		ss_free_priv(q);
+		freeb(mp);
 		return (-err);
 	}
+	so = (typeof(so)) mp->b_wptr;
+	bzero(so, sizeof(*so));
+	so->so_flags |= SO_MINPSZ;
+	so->so_minpsz = ss_winfo.mi_minpsz;
+	so->so_flags |= SO_MAXPSZ;
+	so->so_maxpsz = ss_winfo.mi_maxpsz;
+	so->so_flags |= SO_HIWAT;
+	so->so_hiwat = (SHEADHIWAT << 2) + (STRHIGH << 1);
+	so->so_flags |= SO_LOWAT;
+	so->so_lowat = 0;
+	mp->b_wptr += sizeof(*so);
+	mp->b_datap->db_type = M_SETOPTS;
 	qprocson(q);
+	putnext(q, mp);
 	return (0);
 }


adjust to fit in VS

adjust to fit in VS

--- DynamicArray.c
+++ DynamicArray.c
@@ -11,7 +11,7 @@
 #pragma mark - Inner Function

 static void *itemAt(const Array *pArr, int index) {
-    return pArr->pData + index * pArr->itemSize;
+    return (void *)((char *)(pArr->pData) + index * pArr->itemSize);
 }

 #pragma mark - Make Array


cosmetic change in qdfdiag, replaced 4 char constants in xdfopn

--- EXTRAS/xdf98.c
+++ EXTRAS/xdf98.c
@@ -471,8 +471,10 @@
       fh = file_table[index]->header;
       }
    nw = c_wasize(iun);
-   strncpy(vers,(char *)&(fh->vrsn),4);
-   strncpy(appl,(char *)&(fh->sign),4);
+   if(*little_endian){ int  ct=fh->vrsn ; vers[0]=(ct>>24)&&0xFF ; vers[1]=(ct>>16)&&0xFF ; vers[2]=(ct>>8)&&0xFF ; vers[3]=ct&&0xFF ;  }
+   else strncpy(vers,(char *)&(fh->vrsn),4);
+   if(*little_endian){ int  ct=fh->sign ; appl[0]=(ct>>24)&&0xFF ; appl[1]=(ct>>16)&&0xFF ; appl[2]=(ct>>8)&&0xFF ; appl[3]=ct&&0xFF ;  }
+   else strncpy(appl,(char *)&(fh->sign),4);
    vers[4] = '\0';
    appl[4] = '\0';
    readpos = 1 + W64TOwd(header64.lng);
@@ -1893,8 +1895,13 @@
   double nhours;
   int deet,npas,i_nhours,run,datexx;
   word STDP_sign = 'S' << 24 | 'T' << 16 | 'D' << 8 | 'P';
+  word stdp_sign = 's' << 24 | 't' << 16 | 'd' << 8 | 'p';
   word STDR_sign = 'S' << 24 | 'T' << 16 | 'D' << 8 | 'R';
+  word stdr_sign = 's' << 24 | 't' << 16 | 'd' << 8 | 'r';
   word STDS_sign = 'S' << 24 | 'T' << 16 | 'D' << 8 | 'S';
+  word stds_sign = 's' << 24 | 't' << 16 | 'd' << 8 | 's';
+  word XDF0_sign = 'X' << 24 | 'D' << 16 | 'F' << 8 | '0';
+  word xdf0_sign = 'x' << 24 | 'd' << 16 | 'd' << 8 | '0';

   if (!init_package_done) {
      init_package();
@@ -1993,8 +2000,8 @@
     stdf_dir_keys *stdf_entry;
     xdf_dir_page * curpage;

-    c_waread(unit,&header64,wdaddress,W64TOWD(2));
-    if (header64.data[0] == 'XDF0' || header64.data[0] == 'xdf0') {
+    c_waread(unit,&header64,wdaddress,W64TOWD(2));       /* read first 16 bytes of file */
+    if (header64.data[0] == XDF0_sign || header64.data[0] == xdf0_sign) {
     /*if (strncmp(&header64.data[0], "XDF0", 4) == 0 || strncmp(&header64.data[0], "xdf0", 4) == 0) {*/
       if ((f->header = calloc(1,header64.lng*8)) == NULL) {
         sprintf(errmsg,"memory is full");
@@ -2038,8 +2045,8 @@
       }

       if (f->header->nbd ==0) {
-        if ( (f->cur_info->attr.std) && (header64.data[1] == 'STDR' || header64.data[1] == 'stdr' ||
-                                         header64.data[1] == 'STDP' || header64.data[1] == 'stdp') ) {
+        if ( (f->cur_info->attr.std) && (header64.data[1] == STDR_sign || header64.data[1] == stdr_sign ||
+                                         header64.data[1] == STDP_sign || header64.data[1] == stdp_sign ) ) {
           sprintf(errmsg,"File probably dammaged\n file in error: %s\n",FGFDT[index_fnom].file_name);
           return(error_msg("c_xdfopn",ERR_BAD_DIR,ERROR));
           }


Moved csoundPrintf (which replaces csoundMessage0) to the end of the function table, in an attempt to preserve compatibility with plugin opcodes compiled for earlier versions of Csound.

--- Engine/oload.c
+++ Engine/oload.c
@@ -175,7 +175,6 @@
         csoundRewindScore,
         csoundMessage,
         csoundMessageV,
-        csoundPrintf,
         csoundThrowMessage,
         csoundThrowMessageV,
         csoundSetMessageCallback,
@@ -266,6 +265,7 @@
         catpath,
         rewriteheader,
         writeheader,
+        csoundPrintf,
         /*
         * Data fields.
         */


xv colorkey change

xv colorkey change

--- client/X11/xf_tsmf.c
+++ client/X11/xf_tsmf.c
@@ -44,6 +44,7 @@
 {
 	long xv_port;
 	Atom xv_colorkey_atom;
+	Atom xv_autopaint_colorkey_atom;
 	int xv_image_size;
 	int xv_shmid;
 	char* xv_shmaddr;
@@ -77,6 +78,7 @@
 	xfi->xv_context = xv;

 	xv->xv_colorkey_atom = None;
+	xv->xv_autopaint_colorkey_atom = None;
 	xv->xv_image_size = 0;
 	xv->xv_port = xv_port;

@@ -125,9 +127,15 @@
 	{
 		if (strcmp(attr[i].name, "XV_COLORKEY") == 0)
 		{
-			xv->xv_colorkey_atom = XInternAtom(xfi->display, "XV_COLORKEY", false);
-			XvSetPortAttribute(xfi->display, xv->xv_port, xv->xv_colorkey_atom, attr[i].min_value + 1);
-			break;
+			xv->xv_colorkey_atom =
+					XInternAtom(xfi->display, "XV_COLORKEY", false);
+			XvSetPortAttribute(xfi->display, xv->xv_port, xv->xv_colorkey_atom, 1);
+		}
+		if (strcmp(attr[i].name, "XV_AUTOPAINT_COLORKEY") == 0)
+		{
+			xv->xv_autopaint_colorkey_atom =
+					XInternAtom(xfi->display, "XV_AUTOPAINT_COLORKEY", false);
+			XvSetPortAttribute(xfi->display, xv->xv_port, xv->xv_autopaint_colorkey_atom, 0);
 		}
 	}
 	XFree(attr);
@@ -220,7 +228,7 @@
 	if (vevent->x < -2048 || vevent->y < -2048 || vevent->num_visible_rects <= 0)
 		return;

-	if (xv->xv_colorkey_atom != None)
+	if (xv->xv_colorkey_atom != None && 0)
 	{
 		XvGetPortAttribute(xfi->display, xv->xv_port, xv->xv_colorkey_atom, &colorkey);
 		XSetFunction(xfi->display, xfi->gc, GXcopy);


task_wdt: Pause hardware wdt during debugging

Enable the option to pause the fallback hardware watchdog if the MCU is
halted by a debugger.

This fixes issue #33509 where some boards with Nordic MCUs could not be
flashed anymore after using the task watchdog sample.

Signed-off-by: Martin Jäger <54669547a225ff20cba8b75a4adca540eef25858@libre.solar>

--- subsys/task_wdt/task_wdt.c
+++ subsys/task_wdt/task_wdt.c
@@ -131,7 +131,8 @@
 #ifdef CONFIG_TASK_WDT_HW_FALLBACK
 			if (!hw_wdt_started && hw_wdt_dev) {
 				/* also start fallback hw wdt */
-				wdt_setup(hw_wdt_dev, 0);
+				wdt_setup(hw_wdt_dev,
+					WDT_OPT_PAUSE_HALTED_BY_DBG);
 				hw_wdt_started = true;
 			}
 #endif


Update task04.c

Update task04.c


* libsvn_fs/dag.c

* libsvn_fs/dag.c

  (svn_fs__dag_clone_child): How many times will I re-work this
  function?

  (svn_fs__dag_dup): Some temporary gutz for this one, with comments
  and todos for researching this function's intent (Jim B., are you
  there?)

  (svn_fs__dag_open): Implemented this function.

git-svn-id: f8a4e5e023278da1e04e203c7fe051e3c4285d88@838706 13f79535-47bb-0310-9956-ffa450edef68

--- subversion/libsvn_fs/dag.c
+++ subversion/libsvn_fs/dag.c
@@ -356,12 +356,9 @@
                          const char *name,
                          trail_t *trail)
 {
-  dag_node_t *new_node;  /* node we'll return. */
+  dag_node_t *cur_entry_node; /* node currently in the parent with
+                                 name NAME */
   svn_fs_id_t *new_node_id; /* node id we'll put into NEW_NODE */
-  svn_fs_id_t *node_id; /* node id to which the parent currently refers */
-  skel_t *node_skel; /* NODE-REVISION of The Node referred to in parent */
-  skel_t *entry_skel; /* ENTRY skel in parent for The Node */
-  skel_t *id_skel; /* atom containing node id of The Node */

   if (! svn_fs__dag_is_mutable (parent)) /* is the parent mutable? */
     {
@@ -372,73 +369,47 @@
          "Attempted to clone child of non-mutable node");
     }

-  /* Find the entry named NAME in PARENT if it exists. */
-  entry_skel = find_dir_entry (parent, name);
-  if (! entry_skel)
-    {
-      /* return some other nasty error */
-      return
-        svn_error_createf
-        (SVN_ERR_FS_NOT_FOUND, 0, NULL, trail->pool,
-         "Attempted to clone non-existant child node");
-    }
-
-  /* Alrighty then.  We'll snatch the NODE-REVISION for the child we
-     found (based on it's ID, the second atom in the ENTRY that
-     find_dir_entry returned to us), and see what we can see. */
-  id_skel = entry_skel->children->next;
-  node_id = svn_fs_parse_id (id_skel->data, id_skel->len,
-                             trail->pool);
-  SVN_ERR (svn_fs__get_node_revision (&node_skel,
-                                      parent->fs,
-                                      node_id,
-                                      trail));
-
-  if (! node_skel)
-    {
-      /* Get a nice string to hold our error-causing id... */
-      svn_string_t *id_str = svn_string_ncreate (id_skel->data,
-                                                 id_skel->len,
-                                                 trail->pool);
-
-      /* ...and then return the error. */
-      return
-        svn_error_createf
-        (SVN_ERR_FS_NOT_FOUND, 0, NULL, trail->pool,
-         "Unable to find node-revision '%s'.", id_str->data);
-    }
-
-  if (has_mutable_flag (node_skel))
+  /* Find the node named NAME in PARENT's entries list if it exists. */
+  SVN_ERR (svn_fs__dag_open (&cur_entry_node,
+                             parent,
+                             name,
+                             trail));
+
+  if (svn_fs__dag_is_mutable (cur_entry_node))
     {
       /* This has already been cloned */
-      new_node_id = node_id;
+      new_node_id = cur_entry_node->id;
     }
   else
     {
-      /* Get a nice string to hold our error-causing id... */
       svn_string_t *id_str;
+      skel_t *entry_skel;

       /* Do the clone thingy here. */
       SVN_ERR (svn_fs__create_successor (&new_node_id, parent->fs,
-                                         node_id, node_skel, trail));
+                                         cur_entry_node->id,
+                                         cur_entry_node->contents,
+                                         trail));

       /* We can take our old ENTRY_SKEL and make it's ID point to
          whole new SKEL_T that contains the new clone's ID, now. */
       id_str = svn_fs_unparse_id (new_node_id, trail->pool);
+      entry_skel = find_dir_entry (parent, name);
       entry_skel->children->next = svn_fs__str_atom (id_str->data,
                                                      trail->pool);

     }
-
-  /* Initialize the youngster. */
-  new_node = apr_pcalloc (trail->pool, sizeof (*new_node));
-  new_node->fs = parent->fs;
-  new_node->id = new_node_id;
-  new_node->contents = node_skel;
-  new_node->pool = trail->pool;
-
-  /* Prepare this newborn for safe return. */
-  *child_p = new_node;
+  {
+    /* Initialize the youngster. */
+    dag_node_t *new_node = apr_pcalloc (trail->pool, sizeof (*new_node));
+    new_node->fs = parent->fs;
+    new_node->id = new_node_id;
+    new_node->contents = cur_entry_node->contents;
+    new_node->pool = trail->pool;
+
+    /* Prepare this newborn for safe return. */
+    *child_p = new_node;
+  }

   return SVN_NO_ERROR;
 }
@@ -618,7 +589,6 @@
             svn_boolean_t is_dir,
             trail_t *trail)
 {
-  dag_node_t *new_node;  /* The node we'll return. */
   svn_fs_id_t *new_node_id;
   skel_t *new_node_skel;

@@ -738,16 +708,17 @@
         (SVN_ERR_FS_ALREADY_EXISTS, 0, NULL, trail->pool,
          "Attempted to create entry that already exists");
     }
-
-  /* Initialize the youngster. */
-  new_node = apr_pcalloc (trail->pool, sizeof (*new_node));
-  new_node->fs = parent->fs;
-  new_node->id = new_node_id;
-  new_node->contents = new_node_skel;
-  new_node->pool = trail->pool;
-
-  /* Prepare this newborn for safe return. */
-  *child_p = new_node;
+  {
+    /* Initialize the youngster. */
+    dag_node_t *new_node = apr_pcalloc (trail->pool, sizeof (*new_node));
+    new_node->fs = parent->fs;
+    new_node->id = new_node_id;
+    new_node->contents = new_node_skel;
+    new_node->pool = trail->pool;
+
+    /* Prepare this newborn for safe return. */
+    *child_p = new_node;
+  }

   return SVN_NO_ERROR;
 }
@@ -821,10 +792,23 @@
 dag_node_t *svn_fs__dag_dup (dag_node_t *node,
                              trail_t *trail)
 {
-  abort();
-  /* NOTREACHED */
-  return NULL;
-}
+  /* cmpilato has a call into jimb to discern the vision behind this
+     function's existance.  Best guess:  lifetime stuff (the important
+     thing is not the dup'ing of the node, but the fact that the dup
+     gets alloc'ed from a specific pool. */
+
+  /* Allocate our new node. */
+  dag_node_t *new_node = apr_pcalloc (trail->pool, sizeof (*new_node));
+  new_node->fs = node->fs;
+  new_node->id = node->id;
+  new_node->contents = node->contents;
+  new_node->pool = trail->pool;
+
+  /* $5 sez the above is NOT done right...waiting to hear from jimb */
+
+  return new_node;
+}
+

 /* Open the node named NAME in the directory PARENT, as part of TRAIL.
    Set *CHILD_P to the new node, allocated in TRAIL->pool.  NAME must be a
@@ -835,9 +819,49 @@
                                const char *name,
                                trail_t *trail)
 {
-  abort();
-  /* NOTREACHED */
-  return NULL;
+  skel_t *entry_skel;
+  skel_t *node_skel;
+  svn_fs_id_t *node_id;
+
+  /* Find the entry named NAME in PARENT if it exists. */
+  entry_skel = find_dir_entry (parent, name);
+  if (! entry_skel)
+    {
+      /* return some other nasty error */
+      return
+        svn_error_createf
+        (SVN_ERR_FS_NOT_FOUND, 0, NULL, trail->pool,
+         "Attempted to open non-existant child node");
+    }
+
+  /* Alrighty then.  We'll snatch the NODE-REVISION for the child we
+     found (based on it's ID, the second atom in the ENTRY that
+     find_dir_entry returned to us), and see what we can see. */
+  if ((entry_skel->children) && (entry_skel->children->next))
+    {
+      skel_t *id_skel = entry_skel->children->next;
+      node_id = svn_fs_parse_id (id_skel->data,
+                                 id_skel->len,
+                                 trail->pool);
+      SVN_ERR (svn_fs__get_node_revision (&node_skel,
+                                          parent->fs,
+                                          node_id,
+                                          trail));
+
+    }
+  {
+    /* Allocate our new node. */
+    dag_node_t *new_node = apr_pcalloc (trail->pool, sizeof (*new_node));
+    new_node->fs = parent->fs;
+    new_node->id = node_id;
+    new_node->contents = node_skel;
+    new_node->pool = trail->pool;
+
+    /* Prepare this newborn for safe return. */
+    *child_p = new_node;
+  }
+
+  return SVN_NO_ERROR;
 }