[neuron] add a note for smt

[neuron] add a note for smt

--- src/pmu_sample.c
+++ src/pmu_sample.c
@@ -132,12 +132,16 @@
       (tvs[1].tv_sec - tvs[0].tv_sec) * MICROSECONDS +
       (tvs[1].tv_usec - tvs[0].tv_usec);

+  // FIXME: There seems to be some issues reading MSR on SandyBridge when
+  // SMT is enabled, maybe we should instead use the numbers we get from the
+  // actual logical cores.
   for (i = 0; i < num_of_cores; i++) {
     unsigned long long delta_cpu_clk_unhalted_core, delta_cpu_clk_unhalted_ref;
     // Handle overflow for CPU_CLK_UNHALTED_CORE
     if (cpu_clk_unhalted_core[1][i] < cpu_clk_unhalted_core[0][i]) {
       delta_cpu_clk_unhalted_core =
-          (UINT64_MAX - cpu_clk_unhalted_core[0][i]) + cpu_clk_unhalted_core[1][i];
+          (UINT64_MAX - cpu_clk_unhalted_core[0][i]) +
+          cpu_clk_unhalted_core[1][i];
     } else {
       delta_cpu_clk_unhalted_core =
           cpu_clk_unhalted_core[1][i] - cpu_clk_unhalted_core[0][i];
@@ -145,14 +149,16 @@
     // Handle overflow for CPU_CLK_UNHALTED_REF
     if (cpu_clk_unhalted_ref[1][i] < cpu_clk_unhalted_ref[0][i]) {
       delta_cpu_clk_unhalted_ref =
-          (UINT64_MAX - cpu_clk_unhalted_ref[0][i]) + cpu_clk_unhalted_ref[1][i];
+          (UINT64_MAX - cpu_clk_unhalted_ref[0][i]) +
+          cpu_clk_unhalted_ref[1][i];
     } else {
       delta_cpu_clk_unhalted_ref =
           cpu_clk_unhalted_ref[1][i] - cpu_clk_unhalted_ref[0][i];
     }
     unsigned int frequency =
         ((cycles[1] - cycles[0]) / microseconds) *
-        ((double) delta_cpu_clk_unhalted_core / (double) delta_cpu_clk_unhalted_ref);
+        ((double) delta_cpu_clk_unhalted_core /
+         (double) delta_cpu_clk_unhalted_ref);
     logging(LOG_CODE_INFO, "Core %d: frequency %uMHz\n", i, frequency);
   }
 }


Add new feature to test 64 Bytes Blocks.
- New Cmd line Options -S or --size4k (default 1)
-                      -B or --size64 (default 0)
can be used to test 64 Bytes blocks for memcopy.
See -help for Info.

Signed-off-by: Eberhard S. Amann <abf3c3727151683d37ede95f5333c0b4875fd19d@de.ibm.com>

--- software/tools/stage2.c
+++ software/tools/stage2.c
@@ -243,7 +243,8 @@

 static int memcpy_test(struct dnut_card* dnc,
 			int action,
-			int blocks,	/* Number of DEFAULT_MEMCPY_BLOCK */
+			int blocks_4k,	/* Number of DEFAULT_MEMCPY_BLOCK */
+			int blocks_64,	/* Number of 64 Bytes Blocks */
 			int input_o,
 			int output_o,
 			int align,
@@ -255,16 +256,17 @@
 	void *src_a = NULL, *src = NULL;
 	void *dest_a = NULL, *dest = NULL;
 	void *ddr3;
+	int blocks;
 	unsigned int memsize;

 	rc = 0;
-	/* align can be 16, 32, 64 .. 4096 */
+	/* align can be 64 .. 4096 */
 	if (align < 64) {
 		printf("align=%d must be 64 or higher\n", align);
 		return 1;
 	}
-	if ((align & 0xf) != 0) {
-		printf("align=%d must be a multible of 64KB\n", align);
+	if ((align & 0x3f) != 0) {
+		printf("align=%d must be a multible of 64\n", align);
 		return 1;
 	}
 	if (align > DEFAULT_MEMCPY_BLOCK) {
@@ -272,14 +274,17 @@
 		return 1;
 	}

+	/* Number of 64 Bytes Blocks */
+	blocks = (blocks_4k * 64) + blocks_64;
+
 	/* Check Size */
-	if (blocks > (int)(DDR_MEM_SIZE / DEFAULT_MEMCPY_BLOCK / 2)) {
+	if (blocks > (int)(DDR_MEM_SIZE / 64 / 2)) {
 		printf("Error: Number of Blocks: %d exceeds: %d\n",
 			blocks, (int)(DDR_MEM_SIZE/DEFAULT_MEMCPY_BLOCK/2));
 		return 1;
 	}

-	memsize = blocks * DEFAULT_MEMCPY_BLOCK;
+	memsize = blocks * 64;
 	/* Check Card Ram base and Size */
 	if ((card_ram_base + memsize) > DDR_MEM_SIZE) {
 		printf("Error: Size: 0x%8.8x exceeds DDR3 Limit: 0x%llx for Offset: 0x%llx\n",
@@ -294,8 +299,8 @@
 	}
 	src = src_a + input_o;	/* Add offset */
 	if (verbose_level > 0)
-		printf("  Src:  %p Size: 0x%x Align: %d offset: %d\n",
-			src, memsize, align, output_o);
+		printf("  Src:  %p Size: 0x%x (%d/%d) Align: %d offset: %d\n",
+			src, memsize, blocks_4k, blocks_64, align, output_o);
 	memset2(src_a, card_ram_base, memsize);

 	/* Allocate Dest Buffer if in Host->Host or DDR->Host Mode */
@@ -418,7 +423,8 @@
 		"    -e, --end            End delay time in msec (default %d)\n"
 		"    -i, --interval       Inrcrement steps in msec (default %d)\n"
 		"    ----- Action 2,3,4,5,6 Settings ------ (-a) -----\n"
-		"    -S, --size           Number of 4KB Blocks for Memcopy (default 1)\n"
+		"    -S, --size4k         Number of 4KB Blocks for Memcopy (default 1)\n"
+		"    -B, --size64         Number of 64 Bytes Blocks for Memcopy (default 0)\n"
 		"    -N, --iter           Memcpy Iterations (default 1)\n"
 		"    -A, --align          Memcpy alignemend (default 4 KB)\n"
 		"    -I, --ioff           Memcpy input offset (default 0)\n"
@@ -445,7 +451,8 @@
 	int card_no = 0;
 	int cmd;
 	int action = ACTION_CONFIG_COUNT;
-	int memcpy_num_blocks = 1;	/* Default is 1 Block */
+	int num_4k = 1;	/* Default is 1 4 K Blocks */
+	int num_64 = 0;	/* Default is 0 64 Bytes Blocks */
 	int rc = 1;
 	int memcpy_iter = DEFAULT_MEMCPY_ITER;
 	int memcpy_align = DEFAULT_MEMCPY_BLOCK;
@@ -465,7 +472,8 @@
 			{ "end",      required_argument, NULL, 'e' },
 			{ "interval", required_argument, NULL, 'i' },
 			{ "action",   required_argument, NULL, 'a' },
-			{ "size",     required_argument, NULL, 'S' },
+			{ "size4k",   required_argument, NULL, 'S' },
+			{ "size64",   required_argument, NULL, 'B' },
 			{ "iter",     required_argument, NULL, 'N' },
 			{ "align",    required_argument, NULL, 'A' },
 			{ "ioff",     required_argument, NULL, 'I' },
@@ -475,7 +483,7 @@
 			{ "timeout",  required_argument, NULL, 't' },
 			{ 0,          no_argument,       NULL, 0   },
 		};
-		cmd = getopt_long(argc, argv, "C:s:e:i:a:S:N:A:I:O:D:z:t:qvVh",
+		cmd = getopt_long(argc, argv, "C:s:e:i:a:S:B:N:A:I:O:D:z:t:qvVh",
 			long_options, &option_index);
 		if (cmd == -1)  /* all params processed ? */
 			break;
@@ -507,8 +515,11 @@
 			step_delay = strtol(optarg, (char **)NULL, 0);
 			break;
 		/* Action 2 3, 4, 5 Options */
-		case 'S':	/* block */
-			memcpy_num_blocks = strtol(optarg, (char **)NULL, 0);
+		case 'S':	/* size4k */
+			num_4k = strtol(optarg, (char **)NULL, 0);
+			break;
+		case 'B':	/* size64 */
+			num_64 = strtol(optarg, (char **)NULL, 0);
 			break;
 		case 'N':	/* iter */
 			memcpy_iter = strtol(optarg, (char **)NULL, 0);
@@ -576,7 +587,7 @@
 	case 4:
 	case 5:
 	case 6:
-		rc = memcpy_test(dn, action, memcpy_num_blocks, input_o, output_o,
+		rc = memcpy_test(dn, action, num_4k, num_64, input_o, output_o,
 				memcpy_align, memcpy_iter, card_ram_base,
 				timeout_ms);
 		break;


Formally specify if a MiniBraille input mode is temporary or permanent. (dm)

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

--- BrailleDrivers/MiniBraille/braille.c
+++ BrailleDrivers/MiniBraille/braille.c
@@ -176,9 +176,11 @@
 } InputBinding;

 struct InputModeStruct {
+  InputBinding keyF1, keyF2, keyLeft, keyUp, keyCenter, keyDown, keyRight;
+
+  unsigned temporary:1;
+  void (*modifyWindow) (BrailleDisplay *brl);
   const char *name;
-  InputBinding keyF1, keyF2, keyLeft, keyUp, keyCenter, keyDown, keyRight;
-  void (*modifyWindow) (BrailleDisplay *brl);
 };

 #define BIND(k,t,v) .key##k = {.type = IBT_##t, .value.t = (v)}
@@ -195,6 +197,8 @@
   BIND_BLOCK(Center, ROUTE),
   BIND_BLOCK(Down, CUTRECT),
   BIND_BLOCK(Right, CUTLINE),
+
+  .temporary = 1,
   .name = "Char-F1"
 };

@@ -206,6 +210,8 @@
   BIND_COMMAND(Up, PREFLOAD),
   BIND_COMMAND(Down, PREFMENU),
   BIND_COMMAND(Center, PREFSAVE),
+
+  .temporary = 1,
   .name = "F1-F1"
 };

@@ -217,14 +223,20 @@
   BIND_COMMAND(Up, SKPBLNKWINS),
   BIND_COMMAND(Down, SKPIDLNS),
   BIND_COMMAND(Center, SIXDOTS),
+
+  .temporary = 1,
   .name = "F1-F2"
 };

 static const InputMode inputMode_f1_left = {
+
+  .temporary = 1,
   .name = "F1-Left"
 };

 static const InputMode inputMode_f1_right = {
+
+  .temporary = 1,
   .name = "F1-Right"
 };

@@ -236,6 +248,8 @@
   BIND_COMMAND(Up, PRPGRPH),
   BIND_COMMAND(Down, NXPGRPH),
   BIND_COMMAND(Center, CSRJMP_VERT),
+
+  .temporary = 1,
   .name = "F1-Up"
 };

@@ -247,6 +261,8 @@
   BIND_COMMAND(Up, PRDIFLN),
   BIND_COMMAND(Down, NXDIFLN),
   BIND_COMMAND(Center, PASTE),
+
+  .temporary = 1,
   .name = "F1-Down"
 };

@@ -256,7 +272,10 @@
   BIND_FUNCTION(Right, incrementCursor),
   BIND_COMMAND(Up, LNUP),
   BIND_COMMAND(Down, LNDN),
-  .modifyWindow = putCursor
+
+  .temporary = 0,
+  .modifyWindow = putCursor,
+  .name = "F1-Center"
 };

 static const InputMode inputMode_f1 = {
@@ -267,6 +286,8 @@
   BIND_SUBMODE(Up, f1_up),
   BIND_SUBMODE(Down, f1_down),
   BIND_SUBMODE(Center, f1_center),
+
+  .temporary = 1,
   .name = "F1"
 };

@@ -278,6 +299,8 @@
   BIND_COMMAND(Up, TOP),
   BIND_COMMAND(Down, BOT),
   BIND_COMMAND(Center, CSRTRK),
+
+  .temporary = 1,
   .name = "F2"
 };

@@ -288,7 +311,10 @@
   BIND_COMMAND(Right, FWINRT),
   BIND_COMMAND(Up, LNUP),
   BIND_COMMAND(Down, LNDN),
-  BIND_COMMAND(Center, RETURN)
+  BIND_COMMAND(Center, RETURN),
+
+  .temporary = 0,
+  .name = "Basic"
 };

 static const InputMode *inputMode;
@@ -296,7 +322,7 @@

 static void
 setInputMode (const InputMode *mode) {
-  if (mode->name) {
+  if (mode->temporary) {
     char title[sizeof(textCells) + 1];
     snprintf(title, sizeof(title), "%s Mode", mode->name);
     message(title, MSG_NODELAY|MSG_SILENT);
@@ -367,7 +393,7 @@
 brl_writeWindow (BrailleDisplay *brl) {
   if (inputMode->modifyWindow) inputMode->modifyWindow(brl);
   updateCells(textCells, brl->buffer, sizeof(textCells));
-  if (refreshNeeded && !inputMode->name) {
+  if (refreshNeeded && !inputMode->temporary) {
     writeCells(brl);
     refreshNeeded = 0;
   }
@@ -388,7 +414,7 @@
     int result = serialReadData(serialDevice, &byte, 1, 0, 0);

     if (result == 0) {
-      if (inputMode->name)
+      if (inputMode->temporary)
         if (millisecondsSince(&inputTime) > 3000)
           resetInputMode();

@@ -402,7 +428,7 @@
   }

   mode = inputMode;
-  if (mode->name) resetInputMode();
+  if (mode->temporary) resetInputMode();

   switch (byte) {
     case KEY_F1:     binding = &mode->keyF1;     break;
@@ -414,7 +440,7 @@
     case KEY_CENTER: binding = &mode->keyCenter; break;

     default:
-      LogPrint(LOG_WARNING, "unhandled key: %02X (%s)", byte, mode->name);
+      LogPrint(LOG_WARNING, "unhandled key: %s -> %02X", mode->name, byte);
       beep(brl);
       return EOF;
   }


Create render_ctache_file() in processing

--- src/processing.c
+++ src/processing.c
@@ -74,6 +74,60 @@
     fclose(out_fp);
 }

+static void
+render_ctache_file(FILE *in_fp,
+                   const char *out_file_name,
+                   struct layout *layouts,
+                   int num_layouts,
+                   ctache_data_t *file_data)
+{
+    FILE *out_fp = fopen(out_file_name, "w");
+    if (out_fp != NULL) {
+        if (!ctache_data_hash_table_has_key(file_data, LAYOUT)) {
+            /* Render the file as a ctache template */
+            ctache_render_file(in_fp, out_fp, file_data, ESCAPE_HTML);
+        } else {
+            /*
+             * Render the layout with the file content passed as a
+             * partial with the key "content"
+             */
+            char *content = read_file_contents(in_fp);
+            size_t content_len = strlen(content);
+            ctache_data_t *content_data;
+            content_data = ctache_data_create_string(content,
+                                                     content_len);
+            ctache_data_hash_table_set(file_data,
+                                       "content",
+                                       content_data);
+            ctache_data_t *layout_data;
+            layout_data = ctache_data_hash_table_get(file_data, LAYOUT);
+            char *layout_name = string_trim(layout_data->data.string);
+            char *layout = get_layout_content(layouts,
+                                              num_layouts,
+                                              layout_name);
+            if (layout == NULL) {
+                char *err_fmt = "ERROR: Layout not found: \"%s\"\n";
+                fprintf(stderr, err_fmt, layout_name);
+                abort();
+            }
+            size_t layout_len = strlen(layout);
+            ctache_render_string(layout,
+                                 layout_len,
+                                 out_fp,
+                                 file_data,
+                                 ESCAPE_HTML);
+            free(layout_name);
+        }
+
+        /* Clean up the output file pointer */
+        fclose(out_fp);
+        out_fp = NULL;
+    } else {
+        char *err_fmt = "ERROR: Could not open output file: %s\n";
+        fprintf(stderr, err_fmt, out_file_name);
+    }
+}
+
 void
 process_file(const char *in_file_name,
              struct process_file_args *args,
@@ -94,51 +148,13 @@
     FILE *in_fp = fopen(in_file_name, "r");
     if (in_fp != NULL) {
         cytoplasm_header_read(in_fp, file_data);
-        FILE *out_fp = fopen(out_file_name, "w");
-        if (out_fp != NULL) {
-            if (!ctache_data_hash_table_has_key(file_data, LAYOUT)) {
-                /* Render the file as a ctache template */
-                ctache_render_file(in_fp, out_fp, file_data, ESCAPE_HTML);
-            } else {
-                /*
-                 * Render the layout with the file content passed as a
-                 * partial with the key "content"
-                 */
-                char *content = read_file_contents(in_fp);
-                size_t content_len = strlen(content);
-                ctache_data_t *content_data;
-                content_data = ctache_data_create_string(content,
-                                                         content_len);
-                ctache_data_hash_table_set(file_data,
-                                           "content",
-                                           content_data);
-                ctache_data_t *layout_data;
-                layout_data = ctache_data_hash_table_get(file_data, LAYOUT);
-                char *layout_name = string_trim(layout_data->data.string);
-                char *layout = get_layout_content(args->layouts,
-                                                  args->num_layouts,
-                                                  layout_name);
-                if (layout == NULL) {
-                    char *err_fmt = "ERROR: Layout not found: \"%s\"\n";
-                    fprintf(stderr, err_fmt, layout_name);
-                    abort();
-                }
-                size_t layout_len = strlen(layout);
-                ctache_render_string(layout,
-                                     layout_len,
-                                     out_fp,
-                                     file_data,
-                                     ESCAPE_HTML);
-                free(layout_name);
-            }
-
-            /* Clean up the output file pointer */
-            fclose(out_fp);
-            out_fp = NULL;
-        } else {
-            char *err_fmt = "ERROR: Could not open output file: %s\n";
-            fprintf(stderr, err_fmt, out_file_name);
-        }
+
+        render_ctache_file(in_fp,
+                           out_file_name,
+                           args->layouts,
+                           args->num_layouts,
+                           file_data);
+
         fclose(in_fp);

         /* If necessary render the output file as markdown */


Add new simple patching option (not implemented yet).

--- sonnetrun/sonnetpatch.c
+++ sonnetrun/sonnetpatch.c
@@ -125,6 +125,7 @@
 bool hunk_get_type(uint32_t, const struct hunkdef **);
 bool hunk_to_patch_tokenize(char **);
 bool hunk_header_patch_sonnet(int, int);
+bool hunk_header_patch_simple(int, int);
 void snprintf_memf(char *, size_t, uint8_t);
 bool file_close(int *);
 bool file_open(int *, char *);
@@ -162,7 +163,7 @@
 {
 	int ifd, ofd;
 	int copt;
-	bool opt_patchit;
+	bool opt_patchit, opt_patchsimple;
 	char *myname;

 	opt_patchit = false;
@@ -170,6 +171,9 @@

 	while ((copt = getopt(argc, argv, "p:")) != -1) {
 		switch (copt) {
+		case 's':
+			opt_patchsimple = true;
+			break;
 		case 'p':
 			opt_patchit = true;
 			if (!hunk_to_patch_tokenize(&optarg)) {
@@ -197,7 +201,7 @@
 	if (!file_open(&ifd, argv[0]))
 		return 2;

-	if (opt_patchit) {
+	if (opt_patchit || opt_patchsimple) {
 		if (!file_create(&ofd, argv[1])) {
 			file_close(&ifd);
 			return 2;
@@ -206,9 +210,19 @@

 	if (!hunk_header_parse(ifd)) {
 		file_close(&ifd);
-		if(opt_patchit)
+		if(opt_patchit || opt_patchsimple)
 			file_close(&ofd);
 		return 3;
+	}
+
+	if(opt_patchsimple) {
+		/* XXX: handle errors */
+		hunk_header_patch_simple(ifd, ofd);
+
+		file_close(&ifd);
+		file_close(&ofd);
+
+		return 0;
 	}

 	if(!hunk_all_parse(ifd)) {
@@ -228,6 +242,13 @@
 	/* XXX: TAILQ cleanup here and above in case of errors */
 	file_close(&ifd);
 	return EXIT_SUCCESS;
+}
+
+bool
+hunk_header_patch_simple(int ifd, int ofd)
+{
+	/* TODO: implement */
+	return true;
 }

 bool
@@ -389,6 +410,8 @@

 	offset = lseek(ifd, 0, SEEK_CUR); /* get current offset */

+	printf("starting hunk parser at %llx\n", offset);
+
 	while (current_hunk < hh.table_size) {

 		/* extract a pointer for the current hunk from the queue */
@@ -404,6 +427,8 @@
 		hip->offset = offset;

 		offset = lseek(ifd, (hip->size+1) * sizeof(uint32_t), SEEK_CUR);
+
+		printf("lseeked to offset %llx\n", offset);

 		read32be(ifd, &subhunkid);
 		if (subhunkid != HUNK_END) {
@@ -573,7 +598,7 @@
 void
 usage(char *myname)
 {
-	printf("%s: [-p hnum...] hunkfile\n", myname);
+	printf("%s: [-s|-p hnum...] hunkfile [outfile]\n", myname);
 }

 void


Delete: libsefs/sqlite/config.h

Delete: libsefs/sqlite/config.h

}(Logical change 1.528)

--- setools/libsefs/sqlite/config.h
+++ setools/libsefs/sqlite/config.h
@@ -1 +0,0 @@
-#define SQLITE_PTR_SZ 4


samus: unwedge charge circuit if not charging for long time

This is another workaround for charge circuit wedging. It appears
that the BQ PROCHOT is not entirely reliable at detecting charge
circuit wedged, so let's take a big hammer to this and say if
we have a >5V charger and we haven't been charging for a while,
then attempt to unwedge the charge circuit. Only impact on user
is the battery won't charge quite as fast since we stop charging
briefly to unwedge the circuit.

BUG=chrome-os-partner:36081, chrome-os-partner:36620
BUG=chrome-os-partner:36636
BRANCH=samus
TEST=remove the PROCHOT check and wedge the circuit using "charger
voltage 7000" and make sure that we unwedge after 10s (or 2min
if we never recovered from last time).

Change-Id: I6a0d83aef5fcfdecaeb85367d8207aeea7a99c06
Signed-off-by: Alec Berg <1a4429eeda29095a12e19a73405f80f5b7f37a63@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/248940
Reviewed-by: Shawn N <5259333ce42e3ace6a73988cec7115ed9d3a661a@chromium.org>
Commit-Queue: Shawn N <5259333ce42e3ace6a73988cec7115ed9d3a661a@chromium.org>
Tested-by: Shawn N <5259333ce42e3ace6a73988cec7115ed9d3a661a@chromium.org>

--- board/samus/extpower.c
+++ board/samus/extpower.c
@@ -209,37 +209,129 @@
 	extpower_prev = extpower;
 }

+/* Return boostin_voltage or negative if error */
+static int get_boostin_voltage(void)
+{
+	/* Static structs to save stack space */
+	static struct ec_response_usb_pd_power_info pd_power_ret;
+	static struct ec_params_usb_pd_power_info pd_power_args;
+	int ret;
+	int err;
+
+	/* Boost-in voltage is maximum of voltage now on each port */
+	pd_power_args.port = 0;
+	err = pd_host_command(EC_CMD_USB_PD_POWER_INFO, 0,
+			      &pd_power_args,
+			      sizeof(struct ec_params_usb_pd_power_info),
+			      &pd_power_ret,
+			      sizeof(struct ec_response_usb_pd_power_info));
+	if (err < 0)
+		return err;
+	ret = pd_power_ret.meas.voltage_now;
+
+	pd_power_args.port = 1;
+	err = pd_host_command(EC_CMD_USB_PD_POWER_INFO, 0,
+			      &pd_power_args,
+			      sizeof(struct ec_params_usb_pd_power_info),
+			      &pd_power_ret,
+			      sizeof(struct ec_response_usb_pd_power_info));
+	if (err < 0)
+		return err;
+
+	/* Get max of two measuremente */
+	if (pd_power_ret.meas.voltage_now > ret)
+		ret = pd_power_ret.meas.voltage_now;
+
+	return ret;
+}
+
+
+/* Time interval between checking if charge circuit is wedged */
+#define CHARGE_WEDGE_CHECK_INTERVAL (2*SECOND)
+
+/*
+ * Number of iterations through check_charge_wedged() with charging stalled
+ * before attempting unwedge.
+ */
+#define CHARGE_STALLED_COUNT 5
+/*
+ * Number of iterations through check_charge_wedged() with charging stalled
+ * after we already just tried unwedging the circuit, before we try again.
+ */
+#define CHARGE_STALLED_REPEATEDLY_COUNT 60
+
+/*
+ * Minimum number of iterations through check_charge_wedged() between
+ * unwedge attempts.
+ */
+#define MIN_COUNTS_BETWEEN_UNWEDGES 3
+
 static void check_charge_wedged(void)
 {
-	int rv, prochot_status;
+	int rv, prochot_status, boostin_voltage;
 	static int counts_since_wedged;
+	static int charge_stalled_count = CHARGE_STALLED_COUNT;
+	uint8_t *batt_flags = host_get_memmap(EC_MEMMAP_BATT_FLAG);

 	if (charge_circuit_state == CHARGE_CIRCUIT_OK) {
 		/* Check PROCHOT warning */
 		rv = i2c_read8(I2C_PORT_CHARGER, BQ24773_ADDR,
 				BQ24773_PROCHOT_STATUS, &prochot_status);
 		if (rv)
-			return;
-
-		/*
-		 * If PROCHOT is asserted, then charge circuit is wedged, turn
+			prochot_status = 0;
+
+		/*
+		 * If AC is present, and battery is discharging, and
+		 * boostin voltage is above 5V, then we might be wedged.
+		 */
+		if ((*batt_flags & EC_BATT_FLAG_AC_PRESENT) &&
+		    (*batt_flags & EC_BATT_FLAG_DISCHARGING)) {
+			boostin_voltage = get_boostin_voltage();
+			if (boostin_voltage > 6000)
+				charge_stalled_count--;
+			else if (boostin_voltage >= 0)
+				charge_stalled_count = CHARGE_STALLED_COUNT;
+			/* If boostin_voltage < 0, don't change stalled count */
+		} else {
+			charge_stalled_count = CHARGE_STALLED_COUNT;
+		}
+
+		/*
+		 * If we were recently wedged, then give ourselves a free pass
+		 * here. This gives an opportunity for reading the PROCHOT
+		 * status to clear it if the error has gone away.
+		 */
+		if (counts_since_wedged < MIN_COUNTS_BETWEEN_UNWEDGES)
+			counts_since_wedged++;
+
+		/*
+		 * If PROCHOT is asserted, then charge circuit is wedged. If
+		 * charging has been stalled long enough, then also consider
+		 * the circuit wedged. To unwedge the charge circuit turn
 		 * on learn mode and notify PD to disable charging on all ports.
 		 * Note: learn mode is critical here because when in this state
 		 * backboosting causes >20V on boostin even after PD disables
 		 * CHARGE_EN lines.
-		 *
-		 * If we were recently wedged, then give ourselves a free pass
-		 * here. This gives an opportunity for reading the PROCHOT
-		 * status to clear it if the error has gone away.
-		 */
-		if (prochot_status && counts_since_wedged >= 2) {
+		 */
+		if ((prochot_status &&
+			counts_since_wedged >= MIN_COUNTS_BETWEEN_UNWEDGES) ||
+		    charge_stalled_count <= 0) {
 			counts_since_wedged = 0;
 			host_command_pd_send_status(PD_CHARGE_NONE);
 			charger_disable(1);
 			charge_circuit_state = CHARGE_CIRCUIT_WEDGED;
-			CPRINTS("Charge circuit wedged!");
-		} else {
-			counts_since_wedged++;
+			CPRINTS("Charge wedged! PROCHOT %02x, Stalled: %d",
+				prochot_status, charge_stalled_count);
+
+			/*
+			 * If this doesn't clear the problem, then start
+			 * the stall counter higher so that we don't retry
+			 * unwedging for a while. Note, if we do start charging
+			 * properly, then stall counter will be set to
+			 * default, so that we will trigger faster the first
+			 * time it stalls out.
+			 */
+			charge_stalled_count = CHARGE_STALLED_REPEATEDLY_COUNT;
 		}
 	} else {
 		/*
@@ -265,7 +357,8 @@
 	gpio_enable_interrupt(GPIO_BKBOOST_DET);

 	while (1) {
-		if (task_wait_event(2*SECOND) == TASK_EVENT_TIMER) {
+		if (task_wait_event(CHARGE_WEDGE_CHECK_INTERVAL) ==
+		    TASK_EVENT_TIMER) {
 			/* Periodically check if charge circuit is wedged */
 			check_charge_wedged();
 		} else {


ALSA: pcm: Simplify snd_pcm_action_lock_irq()

The function snd_pcm_action_lock_irq() can be much simplified by
simply wrapping snd_pcm_action() with the stream lock.  This was
rather the original idea, but later it was open coded for
optimization.  However, looking at the optimization part closely, one
notices that the probability of the optimized path is quite low; in
normal situations, the linked stream action happens only for the
triggered substream, thus the operation becomes identical.  So the
code simplification has a clear win, especially because we have now
doubly codes for both atomic and non-atomic locks.

Signed-off-by: Takashi Iwai <4596b3305151c7ee743192a95d394341e3d3b644@suse.de>


Create FFT_1024_17633281.h

Create FFT_1024_17633281.h

error: pathspec 'FFT_433_35507.d/FFT_1024_17633281.h' did not match any file(s) known to git

--- FFT_433_35507.d/FFT_1024_17633281.h
+++ FFT_433_35507.d/FFT_1024_17633281.h
@@ -0,0 +1,44 @@
+/* This is free and unencumbered software released into the public domain.
+ *
+ * Anyone is free to copy, modify, publish, use, compile, sell, or
+ * distribute this software, either in source code form or as a compiled
+ * binary, for any purpose, commercial or non-commercial, and by any
+ * means.
+ *
+ * See LICENSE for complete information.
+ */
+
+#ifndef _FFT_1024_17633281_H
+#define	_FFT_1024_17633281_H
+#include <inttypes.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef	FFTLONG
+	#define FFTLONG uint_fast64_t
+	#define PRIuFFTLONG PRIuFAST64
+#endif
+#ifndef FFTSHORT
+	#define FFTSHORT uint_fast32_t
+	#define PRIuFFTSHORT PRIuFAST32
+#endif
+
+/*
+We use Gentleman-Sande, decimation-in-frequency FFT, for the forward FFT.
+Note that we will not perform the usual scambling / bit-reversal procedure here because we will invert
+the fourier transform using decimation-in-time.
+*/
+void FFT_forward_1024_17633281(FFTSHORT x[1024]);
+
+/*
+We use Cooley-Tukey, decimation-in-time FFT, for the inverse FFT.
+Note that we will not perform the usual scambling / bit-reversal procedure here because we will the forward
+fourier transform is using decimation-in-frequency.
+*/
+void FFT_backward_1024_17633281(FFTSHORT x[1024]);
+
+/*O(nlogn) cyclic convolution*/
+void cyclic_convolution_1024_17633281(FFTSHORT z[1024], FFTSHORT x[1024], FFTSHORT y[1024]);
+
+
+#endif


[ALSA] Fix gus_pcm dereference before NULL

Modules: GUS Library

The NULL check of substream is simply superfluous. It is
guaranteed to receive non-NULL substream. Thanks Takashi.

Coverity bug #861

Signed-off-by: Eugene Teo <aeac6a9eca325c079277ea407621e7dff39d2bb4@eugeneteo.net>
Signed-off-by: Takashi Iwai <4596b3305151c7ee743192a95d394341e3d3b644@suse.de>

--- sound/isa/gus/gus_pcm.c
+++ sound/isa/gus/gus_pcm.c
@@ -114,8 +114,6 @@
 	unsigned char pan;
 	unsigned int voice;

-	if (substream == NULL)
-		return;
 	spin_lock_irqsave(&pcmp->lock, flags);
 	if (pcmp->flags & SNDRV_GF1_PCM_PFLG_ACTIVE) {
 		spin_unlock_irqrestore(&pcmp->lock, flags);


ASoC: dmic: Convert table based DAPM setup

Let the core take care of instantiating the DAPM widgets and routes, this makes
the code a bit shorter.

Signed-off-by: Lars-Peter Clausen <3318dc5ce3e4fb7c28a0b841b6801c884e1d0896@metafoo.de>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@linaro.org>

--- sound/soc/codecs/dmic.c
+++ sound/soc/codecs/dmic.c
@@ -50,20 +50,11 @@
 	{"DMIC AIF", NULL, "DMic"},
 };

-static int dmic_probe(struct snd_soc_codec *codec)
-{
-	struct snd_soc_dapm_context *dapm = &codec->dapm;
-
-	snd_soc_dapm_new_controls(dapm, dmic_dapm_widgets,
-				  ARRAY_SIZE(dmic_dapm_widgets));
-        snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));
-	snd_soc_dapm_new_widgets(dapm);
-
-	return 0;
-}
-
 static struct snd_soc_codec_driver soc_dmic = {
-	.probe	= dmic_probe,
+	.dapm_widgets = dmic_dapm_widgets,
+	.num_dapm_widgets = ARRAY_SIZE(dmic_dapm_widgets),
+	.dapm_routes = intercon,
+	.num_dapm_routes = ARRAY_SIZE(intercon),
 };

 static int dmic_dev_probe(struct platform_device *pdev)


ASoC: msm: 8974: Fix deadlock scenario with recursive mclk get

There is a possibility of deadlock when codec driver requests clock
recursively because API in the machine driver doesn't release mutex in
this scenario.
Fix API to release mutex when mclk is already being fed in order to avoid
deadlock.

CRs-fixed: 414807
Change-Id: Id9b9bd37f37cdb92d56c0c0aa2f63f4b9dd75ca9
Signed-off-by: Joonwoo Park <c2ec5539c4473ab294a95eac689618c01a8f4c1f@codeaurora.org>

--- sound/soc/msm/msm8974.c
+++ sound/soc/msm/msm8974.c
@@ -343,18 +343,20 @@
 		if (!codec_clk) {
 			dev_err(codec->dev, "%s: did not get Taiko MCLK\n",
 				__func__);
-			return -EINVAL;
+			ret = -EINVAL;
+			goto exit;
 		}

 		clk_users++;
 		if (clk_users != 1)
-			return ret;
+			goto exit;

 		ret = qpnp_clkdiv_enable(codec_clk);
 		if (ret) {
 			dev_err(codec->dev, "%s: Error enabling taiko MCLK\n",
 			       __func__);
-			return -ENODEV;
+			ret = -ENODEV;
+			goto exit;
 		}
 		taiko_mclk_enable(codec, 1, dapm);
 	} else {
@@ -367,8 +369,10 @@
 		} else {
 			pr_err("%s: Error releasing Tabla MCLK\n", __func__);
 			ret = -EINVAL;
-		}
-	}
+			goto exit;
+		}
+	}
+exit:
 	mutex_unlock(&cdc_mclk_mutex);
 	return ret;
 }


ASoC: pxa-ssp: Don't use SSCR0_SerClkDiv and SSCR0_SCR

Those macros are just screwed as soon as CONFIG_PXA25x is enabled.

This patch
- changes ssp_set_scr to take an ssp_dev pointer instead of ssp_device
- adds a corresponding ssp_get_scr function.

Signed-off-by: Philipp Zabel <1f94b3da04d839c1c06fd881f52fcf8011297561@gmail.com>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@opensource.wolfsonmicro.com>

--- sound/soc/pxa/pxa-ssp.c
+++ sound/soc/pxa/pxa-ssp.c
@@ -280,12 +280,33 @@
  * ssp_set_clkdiv - set SSP clock divider
  * @div: serial clock rate divider
  */
-static void ssp_set_scr(struct ssp_dev *dev, u32 div)
-{
-	struct ssp_device *ssp = dev->ssp;
-	u32 sscr0 = ssp_read_reg(dev->ssp, SSCR0) & ~SSCR0_SCR;
-
-	ssp_write_reg(ssp, SSCR0, (sscr0 | SSCR0_SerClkDiv(div)));
+static void ssp_set_scr(struct ssp_device *ssp, u32 div)
+{
+	u32 sscr0 = ssp_read_reg(ssp, SSCR0);
+
+	if (cpu_is_pxa25x() && ssp->type == PXA25x_SSP) {
+		sscr0 &= ~0x0000ff00;
+		sscr0 |= ((div - 2)/2) << 8; /* 2..512 */
+	} else {
+		sscr0 &= ~0x000fff00;
+		sscr0 |= (div - 1) << 8;     /* 1..4096 */
+	}
+	ssp_write_reg(ssp, SSCR0, sscr0);
+}
+
+/**
+ * ssp_get_clkdiv - get SSP clock divider
+ */
+static u32 ssp_get_scr(struct ssp_device *ssp)
+{
+	u32 sscr0 = ssp_read_reg(ssp, SSCR0);
+	u32 div;
+
+	if (cpu_is_pxa25x() && ssp->type == PXA25x_SSP)
+		div = ((sscr0 >> 8) & 0xff) * 2 + 2;
+	else
+		div = ((sscr0 >> 8) & 0xfff) + 1;
+	return div;
 }

 /*
@@ -326,7 +347,7 @@
 		break;
 	case PXA_SSP_CLK_AUDIO:
 		priv->sysclk = 0;
-		ssp_set_scr(&priv->dev, 1);
+		ssp_set_scr(ssp, 1);
 		sscr0 |= SSCR0_ACS;
 		break;
 	default:
@@ -387,7 +408,7 @@
 		ssp_write_reg(ssp, SSACD, val);
 		break;
 	case PXA_SSP_DIV_SCR:
-		ssp_set_scr(&priv->dev, div);
+		ssp_set_scr(ssp, div);
 		break;
 	default:
 		return -ENODEV;
@@ -674,8 +695,7 @@
 	case SND_SOC_DAIFMT_I2S:
 	       sspsp = ssp_read_reg(ssp, SSPSP);

-		if (((sscr0 & SSCR0_SCR) == SSCR0_SerClkDiv(4)) &&
-		     (width == 16)) {
+		if ((ssp_get_scr(ssp) == 4) && (width == 16)) {
 			/* This is a special case where the bitclk is 64fs
 			* and we're not dealing with 2*32 bits of audio
 			* samples.


dsdsds

dsdsds

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

--- firmware/PulseSensor_Spark.h
+++ firmware/PulseSensor_Spark.h
@@ -0,0 +1,44 @@
+#ifndef PULSE_INTERRUPT_H
+#define PULSE_INTERRUPT_H
+
+#include "application.h"
+#include "SparkIntervalTimer.h"
+
+volatile int rate[10];                    // array to hold last ten IBI values
+volatile unsigned long sampleCounter = 0;          // used to determine pulse timing
+volatile unsigned long lastBeatTime = 0;           // used to find IBI
+volatile int P =2048;                      // used to find peak in pulse wave, seeded
+volatile int T = 2048;                     // used to find trough in pulse wave, seeded
+volatile int thresh = 2048;                // used to find instant moment of heart beat, seeded
+volatile int amp = 410;                   // used to hold amplitude of pulse waveform, seeded
+volatile boolean firstBeat = true;        // used to seed rate array so we startup with reasonable BPM
+volatile boolean secondBeat = false;      // used to seed rate array so we startup with reasonable BPM
+
+// these variables are volatile because they are used during the interrupt service routine!
+volatile int BPM;                   // used to hold the pulse rate
+volatile int Signal;                // holds the incoming raw data
+volatile int IBI = 600;             // holds the time between beats, must be seeded!
+volatile boolean Pulse = false;     // true when pulse wave is high, false when it's low
+volatile boolean QS = false;        // becomes true when Arduoino finds a beat.
+
+// SparkIntervalTimer uses hardware timers that are otherwise allocated for PIN functions (ADC/PWM)
+// The first allocated timer is TIMR2 on Core and TIMR3 on Photon which is assigned to A0 & A1 ADC/PWM channels
+// So use A2 (though A0 & A1 ADC should still work on Core and not affected on Photon) for pulse input,
+// D7 (onboard LED) for blink LED and D6 for fancy LED
+//  VARIABLES
+int pulsePin = A2;				// Pulse Sensor purple wire connected to analog pin 0
+int blinkPin = D7;				// pin to blink led at each beat
+int fadePin = D6;				// pin to do fancy classy fading blink at each beat
+int fadeRate = 0;				// used to fade LED on with PWM on fadePin
+
+void interruptSetup();
+void pulseISR(void);
+
+// Setup a 2ms h/w timer
+IntervalTimer pulseTimer;
+
+#endif
+
+
+
+


Enable pin change interrupt in ir-receiver.

--- firmware/ir-receiver/board.h
+++ firmware/ir-receiver/board.h
@@ -62,8 +62,12 @@
         // The IR-Receiver is active-low and it leaves the pin floating when
         // inactive. We need to drive the line high ourselves (or use external
         // pull-up resistor).
-        IrDataPin::makeInput();
+        //IrDataPin::makeInput(); // it's input by default
         IrDataPin::enablePullUp();
+        // TODO: add features to lib so that we could enable interrupt like this:
+        //IrDataPin::enablePinChangeInterrupt();
+        PCICR |= (1 << PCIE0);  // Enable pin change interrupt controller 0
+        PCMSK |= (1 << PCINT0); // Enable pin change interrupts for pin0

         UartTxPin::makeOutput();
     }


detachables: Combine set_menu_items and set_disabled_idx_mask

The disabled_idx_mask always needs to be set according to the current
menu, so it makes sense to combine this task with the function that
changes menus. Call the new function vb2_change_menu() to indicate its
broader set of responsibilities.

BRANCH=None
BUG=None
TEST=make runtest

Change-Id: I122783cbc0b35d0d9e866f614646865c5c8a0ed0
Signed-off-by: Julius Werner <4d12f06cff3725783b352157673a720bc67c4afe@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/888081
Reviewed-by: Randall Spangler <62698fdbb84d1779579ee80c3f39fac22017e5bc@chromium.org>
Reviewed-by: Furquan Shaikh <6be5c96c464778f89679b1062a2e0a6af93d2aa5@chromium.org>
Reviewed-by: Shelley Chen <ab7b8cc85923339aed379eb1c5cc4dccfd2eb3d7@chromium.org>

--- firmware/lib/vboot_ui_menu.c
+++ firmware/lib/vboot_ui_menu.c
@@ -269,22 +269,30 @@
 }

 /**
- * Set current_menu to new_current_menu
+ * Switch to a new menu (but don't draw it yet).
  *
  * @param new_current_menu:	new menu to set current_menu to
  * @param new_current_menu_idx: new idx to set current_menu_idx to
- * @return VBERROR_SUCCESS, or non-zero error code if error.
- */
-static VbError_t vb2_set_menu_items(VB_MENU new_current_menu,
-			     int new_current_menu_idx)
+ */
+static void vb2_change_menu(VB_MENU new_current_menu,
+			    int new_current_menu_idx)
 {
 	prev_menu = current_menu;
 	current_menu = new_current_menu;
 	current_menu_idx = new_current_menu_idx;
+
 	/* Changing menus, so reset selected */
 	selected = 0;

-	return VBERROR_SUCCESS;
+	/* Reconfigure disabled_idx_mask for the new menu */
+	disabled_idx_mask = 0;
+	/* Disable Network Boot Option */
+	if (current_menu == VB_MENU_DEV)
+		disabled_idx_mask |= 1 << VB_DEV_NETWORK;
+	/* Disable cancel option if enterprise disabled dev mode */
+	if (current_menu == VB_MENU_TO_NORM &&
+	    disable_dev_boot == 1)
+		disabled_idx_mask |= 1 << VB_TO_NORM_CANCEL;
 }

 /**
@@ -293,9 +301,9 @@
 static void vb2_recovery_base_menu(int nogood)
 {
 	if (nogood)
-		vb2_set_menu_items(VB_MENU_RECOVERY_NO_GOOD, 0);
+		vb2_change_menu(VB_MENU_RECOVERY_NO_GOOD, 0);
 	else
-		vb2_set_menu_items(VB_MENU_RECOVERY_INSERT, 0);
+		vb2_change_menu(VB_MENU_RECOVERY_INSERT, 0);
 }

 /**
@@ -328,7 +336,7 @@
 			 * 1. Select dev menu
 			 * 2. Default to dev boot device
 			 */
-			vb2_set_menu_items(VB_MENU_DEV, next_menu_idx);
+			vb2_change_menu(VB_MENU_DEV, next_menu_idx);
 			break;
 		case VB_WARN_DBG_INFO:
 			/* Show debug info */
@@ -338,8 +346,7 @@
 			 * 1. Enable boot verification
 			 * 2. Default to the confirm option
 			 */
-			vb2_set_menu_items(VB_MENU_TO_NORM,
-					   VB_TO_NORM_CONFIRM);
+			vb2_change_menu(VB_MENU_TO_NORM, VB_TO_NORM_CONFIRM);
 			break;
 		case VB_WARN_POWER_OFF:
 			/* Power off machine */
@@ -347,7 +354,7 @@
 			break;
 		case VB_WARN_LANGUAGE:
 			/* Languages */
-			vb2_set_menu_items(VB_MENU_LANGUAGES, loc);
+			vb2_change_menu(VB_MENU_LANGUAGES, loc);
 			break;
 		default:
 			/* Invalid menu item.  Don't update anything. */
@@ -373,8 +380,7 @@
 			 * 1. Cancel (go back to developer warning menu)
 			 * 2. Default to power off option.
 			 */
-			vb2_set_menu_items(VB_MENU_DEV_WARNING,
-					   VB_WARN_POWER_OFF);
+			vb2_change_menu(VB_MENU_DEV_WARNING, VB_WARN_POWER_OFF);
 			break;
 		case VB_DEV_POWER_OFF:
 			/* Power off */
@@ -382,7 +388,7 @@
 			break;
 		case VB_DEV_LANGUAGE:
 			/* Language */
-			vb2_set_menu_items(VB_MENU_LANGUAGES, loc);
+			vb2_change_menu(VB_MENU_LANGUAGES, loc);
 			break;
 		default:
 			/* Invalid menu item.  Don't update anything. */
@@ -399,8 +405,7 @@
 			 * 1. Cancel (go back to developer warning menu)
 			 * 2. Default to power off
 			 */
-			vb2_set_menu_items(VB_MENU_DEV_WARNING,
-					   VB_WARN_POWER_OFF);
+			vb2_change_menu(VB_MENU_DEV_WARNING, VB_WARN_POWER_OFF);
 			break;
 		case VB_TO_NORM_POWER_OFF:
 			/* Power off */
@@ -408,7 +413,7 @@
 			break;
 		case VB_TO_NORM_LANGUAGE:
 			/* Language */
-			vb2_set_menu_items(VB_MENU_LANGUAGES, loc);
+			vb2_change_menu(VB_MENU_LANGUAGES, loc);
 			break;
 		default:
 			/* Invalid menu item.  Don't update anything */
@@ -418,8 +423,7 @@
 	case VB_MENU_RECOVERY_INSERT:
 	case VB_MENU_RECOVERY_NO_GOOD:
 	case VB_MENU_RECOVERY_BROKEN:
-		vb2_set_menu_items(VB_MENU_OPTIONS,
-				   VB_OPTIONS_CANCEL);
+		vb2_change_menu(VB_MENU_OPTIONS, VB_OPTIONS_CANCEL);
 		break;
 	case VB_MENU_TO_DEV:
 		switch(current_menu_idx) {
@@ -433,7 +437,7 @@
 			ret = VBERROR_SHUTDOWN_REQUESTED;
 			break;
 		case VB_TO_DEV_LANGUAGE:
-			vb2_set_menu_items(VB_MENU_LANGUAGES, loc);
+			vb2_change_menu(VB_MENU_LANGUAGES, loc);
 			break;
 		default:
 			/* Invalid menu item.  Don't update anything. */
@@ -451,7 +455,7 @@
 			ret = VBERROR_SHUTDOWN_REQUESTED;
 			break;
 		case VB_OPTIONS_LANGUAGE:
-			vb2_set_menu_items(VB_MENU_LANGUAGES, loc);
+			vb2_change_menu(VB_MENU_LANGUAGES, loc);
 			break;
 		default:
 			/* Invalid menu item.  Don't update anything. */
@@ -465,22 +469,22 @@
 		 */
 		switch (prev_menu) {
 		case VB_MENU_DEV_WARNING:
-			vb2_set_menu_items(prev_menu, VB_WARN_POWER_OFF);
+			vb2_change_menu(prev_menu, VB_WARN_POWER_OFF);
 			break;
 		case VB_MENU_DEV:
-			vb2_set_menu_items(prev_menu, VB_DEV_POWER_OFF);
+			vb2_change_menu(prev_menu, VB_DEV_POWER_OFF);
 			break;
 		case VB_MENU_TO_NORM:
-			vb2_set_menu_items(prev_menu, VB_TO_NORM_CONFIRM);
+			vb2_change_menu(prev_menu, VB_TO_NORM_CONFIRM);
 			break;
 		case VB_MENU_TO_DEV:
-			vb2_set_menu_items(prev_menu, VB_TO_DEV_CANCEL);
+			vb2_change_menu(prev_menu, VB_TO_DEV_CANCEL);
 			break;
 		case VB_MENU_OPTIONS:
-			vb2_set_menu_items(prev_menu, VB_OPTIONS_CANCEL);
+			vb2_change_menu(prev_menu, VB_OPTIONS_CANCEL);
 			break;
 		default:
-			vb2_set_menu_items(prev_menu, 0);
+			vb2_change_menu(prev_menu, 0);
 			break;
 		}
 		break;
@@ -508,24 +512,6 @@
 		}
 #endif
 	}
-	return VBERROR_SUCCESS;
-}
-
-/**
- * Adjust the disabled_idx_mask based on current menu and settings.
- *
- * @param flags flag to check for dev/normal mode.
- * @return VBERROR_SUCCESS
- */
-static VbError_t vb2_set_disabled_idx_mask(uint32_t flags) {
-	disabled_idx_mask = 0;
-	/* Disable Network Boot Option */
-	if (current_menu == VB_MENU_DEV)
-		disabled_idx_mask |= 1 << VB_DEV_NETWORK;
-	/* Disable cancel option if enterprise disabled dev mode */
-	if (current_menu == VB_MENU_TO_NORM &&
-	    disable_dev_boot == 1)
-		disabled_idx_mask |= 1 << VB_TO_NORM_CANCEL;
 	return VBERROR_SUCCESS;
 }

@@ -596,7 +582,7 @@

 	VB2_DEBUG("Entering\n");

-	vb2_set_menu_items(VB_MENU_DEV_WARNING, VB_WARN_POWER_OFF);
+	vb2_change_menu(VB_MENU_DEV_WARNING, VB_WARN_POWER_OFF);

 	/* Check if USB booting is allowed */
 	uint32_t allow_usb = vb2_nv_get(ctx, VB2_NV_DEV_BOOT_USB);
@@ -634,11 +620,10 @@
 			/* If dev mode is disabled, only allow TONORM */
 			disable_dev_boot = 1;
 			VB2_DEBUG("dev_disable_boot is set.\n");
-			vb2_set_menu_items(VB_MENU_TO_NORM, VB_TO_NORM_CONFIRM);
-		}
-	}
-
-	vb2_set_disabled_idx_mask(shared->flags);
+			vb2_change_menu(VB_MENU_TO_NORM, VB_TO_NORM_CONFIRM);
+		}
+	}
+
 	/* Show the dev mode warning screen */
 	vb2_draw_current_screen(ctx);

@@ -731,9 +716,7 @@
 			 * we'll lose the previous state
 			 */
 			vb2_update_locale(ctx);
-
 			ret = vb2_update_menu(ctx);
-			vb2_set_disabled_idx_mask(shared->flags);
 			vb2_draw_current_screen(ctx);

 			/* Probably shutting down */
@@ -920,7 +903,7 @@
 		vb2_nv_commit(ctx);

 		VbDisplayScreen(ctx, VB_SCREEN_OS_BROKEN, 0);
-		vb2_set_menu_items(VB_MENU_RECOVERY_BROKEN, 0);
+		vb2_change_menu(VB_MENU_RECOVERY_BROKEN, 0);
 		VB2_DEBUG("waiting for manual recovery\n");
 		while (1) {
 			key = VbExKeyboardRead();
@@ -960,7 +943,6 @@
 			usb_nogood = retval != VBERROR_NO_DISK_FOUND;
 			vb2_recovery_base_menu(usb_nogood);
 			vb2_draw_current_screen(ctx);
-			vb2_set_disabled_idx_mask(shared->flags);
 		}

 		/*
@@ -1004,9 +986,8 @@
 					VbExBeep(120, 400);
 					break;
 				}
-				vb2_set_menu_items(VB_MENU_TO_DEV,
+				vb2_change_menu(VB_MENU_TO_DEV,
 						   VB_TO_DEV_CANCEL);
-				vb2_set_disabled_idx_mask(shared->flags);
 				vb2_draw_current_screen(ctx);
 				break;
 			case VB_BUTTON_POWER_SHORT_PRESS:
@@ -1029,11 +1010,7 @@
 					 * we'll lose the previous state
 					 */
 					vb2_update_locale(ctx);
-
 					ret = vb2_update_menu(ctx);
-
-					vb2_set_disabled_idx_mask(shared->
-								  flags);
 					vb2_draw_current_screen(ctx);
 				}


[Graph]: fix a problem of requesting both edge lists of a vertex.

We should issue requests for both edge lists of a vertex to reduce
resource consumption.

--- flash-graph/vertex_compute.h
+++ flash-graph/vertex_compute.h
@@ -47,7 +47,14 @@
 	{
 		bool operator()(const ext_mem_vertex_info &info1,
 				const ext_mem_vertex_info &info2) {
-			return info1.get_off() > info2.get_off();
+			// We should order the vertex requests by their IDs.
+			// When a directed vertex wants to request both edges list,
+			// it results in two I/O requests and we want them to be served
+			// around the same time, so we don't need to consume a lot
+			// of resources for one of the requests.
+			// Ordering requests by vertex IDs has the same effect as vertex
+			// location on SSDs.
+			return info1.get_id() > info2.get_id();
 		}
 	};


cleanups

cleanups

--- common/tasking/taskscheduler_mic.h
+++ common/tasking/taskscheduler_mic.h
@@ -291,7 +291,6 @@
     __aligned(64) void* volatile data;

     __aligned(64) QuadTreeBarrier taskBarrier;
-//    __aligned(64) LinearBarrierActive taskBarrier;

     __dllexport bool enter(size_t threadIndex, size_t threadCount);
     __dllexport void leave(size_t threadIndex, size_t threadCount);
@@ -481,6 +480,5 @@
     __aligned(64) AlignedAtomicCounter32 head_task_list; /*! next index in the task queue where we'll insert a live task */
     __aligned(64) Task* volatile tasks[NUM_TASKS]; //!< queue of tasks
     __aligned(64) QuadTreeBarrier barrier;
-    //__aligned(64) LinearBarrierActive barrier;
   };
 }


Fix memory leak in test_ld_conv

Fix memory leak in test_ld_conv

--- tests/modules/misc.c
+++ tests/modules/misc.c
@@ -74,6 +74,7 @@
         RedisModule_ReplyWithError(ctx, err);
         goto final;
     }
+
     /* Make sure we can't convert a string that has \0 in it */
     char buf[4] = "123";
     buf[1] = '\0';
@@ -81,8 +82,11 @@
     long double ld3;
     if (RedisModule_StringToLongDouble(s3, &ld3) == REDISMODULE_OK) {
         RedisModule_ReplyWithError(ctx, "Invalid string successfully converted to long double");
-        goto final;
-    }
+        RedisModule_FreeString(ctx, s3);
+        goto final;
+    }
+    RedisModule_FreeString(ctx, s3);
+
     RedisModule_ReplyWithLongDouble(ctx, ld2);
 final:
     RedisModule_FreeString(ctx, s1);


CController::execOnUiThread: unnecessary std::function wrapper removed

--- file-commander-core/src/ccontroller.h
+++ file-commander-core/src/ccontroller.h
@@ -71,12 +71,9 @@
 		_workerThread.exec(std::forward<Executable>(task), std::forward<Args>(args)...);
 	}

-	template <class Executable, typename ...Args>
-	void execOnUiThread(Executable&& task, Args&&... args)
+	inline void execOnUiThread(const std::function<void ()>& task)
 	{
-		_uiQueue.enqueue([=]() {
-			task(std::forward<Args>(args)...);
-		});
+		_uiQueue.enqueue(task);
 	}

 // Getters


Length of INS:ME elements should be ~MEI size

--- vh/vh_setcover.c
+++ vh/vh_setcover.c
@@ -817,6 +817,7 @@
 	//int totalEditDist = 0; // total of edit distance of all paired-end reads for individuals which we are considering
 	float bestScore, weightNew, normalizedWeightedSup = 0;
 	int numReadCanBeCovered = 0, indCount, count, i, k;
+	int mei_length = 0, sv_length = 0;

 	bool passMinSup;
 	float bestScoreRD = 0;
@@ -883,6 +884,12 @@
 				listClusterEl[clusterId].posEndSV + 20, params->mei);

 		if( mei != NULL)
+		{
+			mei_length = abs( mei->repeat_end - mei->repeat_start);
+			sv_length = abs( ( listClusterEl[clusterId].posEndSV - listClusterEl[clusterId].posStartSV + 1));
+		}
+
+		if( ( mei != NULL) && ( sv_length > 0.8 * mei_length) && ( sv_length < 1.2 * mei_length))
 		{
 			calculateCNVScore(in_bams, params, clusterId, listClusterEl[clusterId].SVtype, true, listClusterEl[clusterId].CNV_Score);
 			bestScore = listClusterEl[clusterId].CNV_Score[0];


Improve SingletonThreadLocal performance

Summary:
[Folly] Improve `SingletonThreadLocal` performance.

By explicitly controlling inlining behavior.

The ctor is definitionally cold - once per process - so outline.

`get` is hot so inline. Uncached `get` is cold - once per thread - so outline uncached.

Reviewed By: djwatson

Differential Revision: D6736662

fbshipit-source-id: 4cd77c7772b46e2e3c6b2a3dc071b2b06522979e

--- folly/SingletonThreadLocal.h
+++ folly/SingletonThreadLocal.h
@@ -43,29 +43,29 @@

   SingletonThreadLocal() : SingletonThreadLocal([]() { return new T(); }) {}

-  explicit SingletonThreadLocal(CreateFunc createFunc)
-      : singleton_([createFunc = std::move(createFunc)]() mutable {
-          return new ThreadLocalT([createFunc =
-                                       std::move(createFunc)]() mutable {
-            return new Wrapper(std::unique_ptr<T>(createFunc()));
+  template <typename Create>
+  FOLLY_NOINLINE explicit SingletonThreadLocal(Create create)
+      : singleton_([create = std::move(create)]() mutable {
+          return new ThreadLocalT([create = std::move(create)]() mutable {
+            return new Wrapper(std::unique_ptr<T>(create()));
           });
         }) {}

-  static T& get() {
+  FOLLY_ALWAYS_INLINE static T& get() {
 #ifdef FOLLY_TLS
-    if (UNLIKELY(*localPtr() == nullptr)) {
-      *localPtr() = &(**SingletonT::get());
-    }
-
-    return **localPtr();
+    return *localPtr() ? **localPtr() : *(*localPtr() = &getSlow());
 #else
     return **SingletonT::get();
 #endif
   }

  private:
+  FOLLY_NOINLINE static T& getSlow() {
+    return **SingletonT::get();
+  }
+
 #ifdef FOLLY_TLS
-  static T** localPtr() {
+  FOLLY_ALWAYS_INLINE static T** localPtr() {
     static FOLLY_TLS T* localPtr = nullptr;
     return &localPtr;
   }


Small correction on write function. May dropped a byte when already sending

--- freertos123/tivac_hardware_freertos.h
+++ freertos123/tivac_hardware_freertos.h
@@ -135,9 +135,15 @@
     // write data to the connection to ROS
     void write(uint8_t* data, int length)
     {
-      RingBufWrite(&txBuffer, data, length);
-      // Trigger sending buffer
-      MAP_UARTCharPutNonBlocking(UART0_BASE, RingBufReadOne(&txBuffer));
+      // Trigger sending buffer, if not already sending
+      if (RingBufEmpty(&txBuffer))
+        RingBufWrite(&txBuffer, data, length);
+        MAP_UARTCharPutNonBlocking(UART0_BASE, RingBufReadOne(&txBuffer));
+      }
+      else
+      {
+        RingBufWrite(&txBuffer, data, length);
+      }
     }

     // returns milliseconds since start of program


From Philippe
The issue is that on (at least some) linux ptrdiff_t is defined as int AND in gcc 2.95.2, ptrdiff_t is used as a template parameter (so it matters whethere it is int or long).

git-svn-id: ecbadac9c76e8cf640a0bca86f6bd796c98521e3@6175 27541ba8-7e3a-0410-8455-c3a389f83636

--- cint/include/stddef.h
+++ cint/include/stddef.h
@@ -1,6 +1,10 @@
 #ifndef G__STDDEF_H
 #define G__STDDEF_H
+#if (G__GNUC==2)
+typedef int ptrdiff_t;
+#else
 typedef long ptrdiff_t;
+#endif
 typedef unsigned int size_t;
 typedef unsigned int wchar_t;
 #endif


root process is now waiting for its children to terminate before terminating itself

--- source/common/process.c
+++ source/common/process.c
@@ -4,6 +4,8 @@
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>

 #include "common/utility.h"

@@ -36,7 +38,7 @@
 }

-void start_process(char *argv[]) {
+pid_t start_process(char *argv[]) {
 	// Will need to set the group id
 	const pid_t parent_pid = getpid();
 	const pid_t pid = fork();
@@ -57,6 +59,8 @@
 			throw("Error opening child process");
 		}
 	}
+
+	return pid;
 }

 void copy_arguments(char *arguments[], int argc, char *argv[]) {
@@ -69,10 +73,10 @@
 	arguments[argc] = NULL;
 }

-void start_child(char *name, int argc, char *argv[]) {
+pid_t start_child(char *name, int argc, char *argv[]) {
 	char *arguments[8] = {name};
 	copy_arguments(arguments, argc, argv);
-	start_process(arguments);
+	return start_process(arguments);
 }

 void start_children(char *prefix, int argc, char *argv[]) {
@@ -101,8 +105,11 @@
 	);
 	// clang-format on

-	start_child(server_name, argc, argv);
-	start_child(client_name, argc, argv);
+	pid_t c1_id = start_child(server_name, argc, argv);
+	pid_t c2_id = start_child(client_name, argc, argv);
+
+	waitpid(c1_id, NULL, WUNTRACED);
+	waitpid(c2_id, NULL, WUNTRACED);

 	free(build_path);
 }


the branch uses Q_WS_WIN, looks more correct to me

--- phonon/phonon_export.h
+++ phonon/phonon_export.h
@@ -25,7 +25,7 @@
 #include <QtCore/QtGlobal>

 #ifndef PHONON_EXPORT
-# if defined Q_OS_WIN
+# if defined Q_WS_WIN
 #  ifdef MAKE_PHONON_LIB /* We are building this library */
 #   define PHONON_EXPORT Q_DECL_EXPORT
 #  else /* We are using this library */


Fix include

Fix include

--- src/qgitconfig.h
+++ src/qgitconfig.h
@@ -25,7 +25,7 @@

 #include "git2.h"

-#include <libqgit2_export.h>
+#include "libqgit2_export.h"

 namespace LibQGit2
 {


device: don't allow sending messages without a proper CID

--- src/qmi-device.c
+++ src/qmi-device.c
@@ -733,6 +733,18 @@
         error = g_error_new (QMI_CORE_ERROR,
                              QMI_CORE_ERROR_WRONG_STATE,
                              "Device must be open to send commands");
+        transaction_complete_and_free (tr, NULL, error);
+        g_error_free (error);
+        return;
+    }
+
+    /* Non-CTL services should use a proper CID */
+    if (qmi_message_get_service (message) != QMI_SERVICE_CTL &&
+        qmi_message_get_client_id (message) == 0) {
+        error = g_error_new (QMI_CORE_ERROR,
+                             QMI_CORE_ERROR_FAILED,
+                             "Cannot send message in service '%s' without a CID",
+                             qmi_service_get_string (qmi_message_get_service (message)));
         transaction_complete_and_free (tr, NULL, error);
         g_error_free (error);
         return;


optimize by reducing RAM consumption

optimize by reducing RAM consumption

--- black-hole-solitaire/c-solver/lib.c
+++ black-hole-solitaire/c-solver/lib.c
@@ -116,7 +116,7 @@
     can_move__row *can_move;
     bhs_queue_item_t queue[QUEUE_MAX_SIZE];
 #define MAX_NUM_STATES (NUM_SUITS * NUM_RANKS + 1)
-    uint_fast32_t depths_stack[MAX_NUM_STATES];
+    uint8_t depths_stack[MAX_NUM_STATES + 1];
     bhs_solution_state_t states_in_solution[MAX_NUM_STATES];
 } bhs_solver_t;


msnconnection: set method before adding properties

--- gst/fsmsnconference/fs-msn-connection.c
+++ gst/fsmsnconference/fs-msn-connection.c
@@ -132,6 +132,11 @@

   parent_class = g_type_class_peek_parent (klass);

+  gobject_class->dispose = fs_msn_connection_dispose;
+  gobject_class->finalize = fs_msn_connection_finalize;
+  gobject_class->get_property = fs_msn_connection_get_property;
+  gobject_class->set_property = fs_msn_connection_set_property;
+
   signals[SIGNAL_NEW_LOCAL_CANDIDATE] = g_signal_new
       ("new-local-candidate",
           G_TYPE_FROM_CLASS (klass),
@@ -142,7 +147,6 @@
           g_cclosure_marshal_VOID__BOXED,
           G_TYPE_NONE, 1, FS_TYPE_CANDIDATE);

-
   signals[SIGNAL_LOCAL_CANDIDATES_PREPARED] = g_signal_new
     ("local-candidates-prepared",
       G_TYPE_FROM_CLASS (klass),
@@ -153,7 +157,6 @@
       g_cclosure_marshal_VOID__VOID,
       G_TYPE_NONE, 0);

-
   signals[SIGNAL_CONNECTED] = g_signal_new
     ("connected",
       G_TYPE_FROM_CLASS (klass),
@@ -164,7 +167,6 @@
       g_cclosure_marshal_VOID__UINT,
         G_TYPE_NONE, 1, G_TYPE_UINT);

-
   signals[SIGNAL_CONNECTION_FAILED] = g_signal_new
     ("connection-failed",
       G_TYPE_FROM_CLASS (klass),
@@ -182,11 +184,6 @@
           "This is the session-id of the MSN session",
           1000, 9999, 9000,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
-  gobject_class->dispose = fs_msn_connection_dispose;
-  gobject_class->finalize = fs_msn_connection_finalize;
-  gobject_class->get_property = fs_msn_connection_get_property;
-  gobject_class->set_property = fs_msn_connection_set_property;
 }

 static void


rtp: Put channels as encoding-params as expected

--- gst/fsrtpconference/fs-rtp-conference.c
+++ gst/fsrtpconference/fs-rtp-conference.c
@@ -773,8 +773,15 @@
     gst_structure_set (structure, "payload", G_TYPE_INT, codec->id, NULL);

   if (codec->channels)
-    gst_structure_set (structure, "channels", G_TYPE_INT, codec->channels,
-      NULL);
+  {
+    gchar tmp[11];
+
+    snprintf (tmp, 11, "%u", codec->channels);
+    gst_structure_set (structure,
+        "channels", G_TYPE_INT, codec->channels,
+        "encoding-params", G_TYPE_STRING, tmp,
+        NULL);
+  }

   for (item = codec->optional_params;
        item;


[ 2916466 ] Use a common header file for classProviders

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

--- classProviderCommon.h
+++ classProviderCommon.h
@@ -0,0 +1,58 @@
+/*
+ * classProviderCommon.h
+ *
+ * (C) Copyright IBM Corp. 2005, 2009
+ *
+ * THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
+ * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
+ * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
+ *
+ * You can obtain a current copy of the Eclipse Public License from
+ * http://www.opensource.org/licenses/eclipse-1.0.php
+ *
+ * Author:       Adrian Schuur <schuur@de.ibm.com>
+ *
+ * Description:
+ *
+ * Common header file for classProvider, classProviderGz, classProviderMem,
+ *                        and classProviderSf
+ *
+*/
+
+#include "utilft.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include <sys/types.h>
+#include <dirent.h>
+
+#include "constClass.h"
+#include "providerRegister.h"
+#include "trace.h"
+#include "control.h"
+
+#include "cmpidt.h"
+#include "cmpift.h"
+#include "cmpiftx.h"
+#include "cmpimacs.h"
+#include "cmpimacsx.h"
+#include "objectImpl.h"
+#include "mrwlock.h"
+
+static const CMPIBroker *_broker;
+
+extern char * configfile;
+extern ProviderRegister *pReg;
+
+typedef struct nameSpaces {
+   int next,max,blen;
+   char *base;
+   char *names[1];
+} NameSpaces;
+
+static UtilHashTable *nsHt=NULL;
+static pthread_once_t nsHt_once = PTHREAD_ONCE_INIT;
+
+#define Iterator HashTableIterator*
+#define NEW(x) ((x *) calloc(1,sizeof(x)))


EINTR check on open of cache

EINTR check on open of cache

--- gass/cache/source/globus_gass_cache.c
+++ gass/cache/source/globus_gass_cache.c
@@ -1493,8 +1493,8 @@
                                 {
                                     return(GLOBUS_GASS_CACHE_ERROR_QUOTA_EXCEEDED);
                                 }
-                                else
-                                {
+				else if (errno != EINTR )
+				{
 	                            return(GLOBUS_GASS_CACHE_ERROR_CAN_NOT_CREATE);
                                 }
 			    }


remove {} inside #ifdef around a declaration to avoid scope problem with variables

--- gass/cache/source/globus_gass_cache.c
+++ gass/cache/source/globus_gass_cache.c
@@ -1179,10 +1179,8 @@
     int    return_code=GLOBUS_SUCCESS;

 #   ifdef LOCK_TOUT
-    {
 	int    lock_tout=0;
 	struct timeval tv;
-    }
 #   endif

     /* build the name of the file used to lock "file_to_be_locked" */


plasma_atomic_fetch_sub_*

--- plasma/plasma_atomic.h
+++ plasma/plasma_atomic.h
@@ -992,6 +992,33 @@

 /*
+ * plasma_atomic_fetch_sub_ptr - atomic pointer  fetch and sub
+ * plasma_atomic_fetch_sub_u64 - atomic uint64_t fetch and sub
+ * plasma_atomic_fetch_sub_u32 - atomic uint32_t fetch and sub
+ */
+
+#if defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER)
+
+  #define plasma_atomic_fetch_sub_ptr_impl(ptr,subval) \
+          __sync_fetch_and_sub((ptr),(subval))
+  #define plasma_atomic_fetch_sub_u64_impl(ptr,subval) \
+          __sync_fetch_and_sub((ptr),(subval))
+  #define plasma_atomic_fetch_sub_u32_impl(ptr,subval) \
+          __sync_fetch_and_sub((ptr),(subval))
+
+#else
+
+  #define plasma_atomic_fetch_sub_ptr(ptr,subval) \
+          plasma_atomic_fetch_add_ptr((ptr),-(subval))
+  #define plasma_atomic_fetch_sub_u64(ptr,subval) \
+          plasma_atomic_fetch_add_u64((ptr),-(subval))
+  #define plasma_atomic_fetch_sub_u32(ptr,subval) \
+          plasma_atomic_fetch_add_u32((ptr),-(subval))
+
+#endif
+
+
+/*
  * plasma_atomic_fetch_or_ptr - atomic pointer  fetch and or
  * plasma_atomic_fetch_or_u64 - atomic uint64_t fetch and or
  * plasma_atomic_fetch_or_u32 - atomic uint32_t fetch and or


Fix typo.

Fix typo.

--- pool_connection_pool.c
+++ pool_connection_pool.c
@@ -5,7 +5,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2010	PgPool Global Development Group
+ * Copyright (c) 2003-2011	PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -467,7 +467,7 @@
 	fd = socket(AF_UNIX, SOCK_STREAM, 0);
 	if (fd == -1)
 	{
-		pool_error("connect_unix_domain_socket_by_port: setsockopt() failed: %s", strerror(errno));
+		pool_error("connect_unix_domain_socket_by_port: socket() failed: %s", strerror(errno));
 		return -1;
 	}


Improve error messages.

Improve error messages.

--- src/rpc_typing.c
+++ src/rpc_typing.c
@@ -43,6 +43,7 @@
 static int rpct_read_type(struct rpct_file *file, const char *decl,
     rpc_object_t obj);
 static int rpct_parse_type(const char *decl, GPtrArray *variables);
+static void rpct_interface_free(struct rpct_interface *iface);

 static struct rpct_context *context = NULL;
 static const char *builtin_types[] = {
@@ -408,6 +409,15 @@
 }

 static void
+rpct_interface_free(struct rpct_interface *iface)
+{
+
+	g_free(iface->name);
+	g_free(iface->description);
+	g_hash_table_destroy(iface->members);
+}
+
+static void
 rpct_if_member_free(struct rpct_if_member *member)
 {

@@ -1002,7 +1012,8 @@

 	iface = g_malloc0(sizeof(*iface));
 	iface->name = g_match_info_fetch(match, 1);
-	iface->members = g_hash_table_new(g_str_hash, g_str_equal);
+	iface->members = g_hash_table_new_full(g_str_hash, g_str_equal,
+	    g_free, (GDestroyNotify)rpct_if_member_free);
 	iface->description = g_strdup(rpc_dictionary_get_string(obj,
 	    "description"));

@@ -1067,8 +1078,7 @@
 	file->body = rpc_retain(obj);
 	file->path = g_strdup(path);
 	file->uses = g_ptr_array_new_with_free_func(g_free);
-	file->types = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
-	    NULL);
+	file->types = g_hash_table_new(g_str_hash, g_str_equal);
 	file->interfaces = g_hash_table_new(g_str_hash, g_str_equal);

 	if (rpct_read_meta(file, rpc_dictionary_get_value(obj, "meta")) < 0) {
@@ -1247,6 +1257,7 @@
 {
 	struct rpc_inbound_call *ic = cookie;
 	struct rpct_if_member *member;
+	char *msg;
 	rpc_object_t errors;

 	member = rpct_find_if_member(ic->ric_interface, ic->ric_name);
@@ -1254,8 +1265,11 @@
 		return (NULL);

 	if (!rpct_validate_args(member, args, &errors)) {
-		rpc_function_error_ex(cookie, rpc_error_create(EINVAL,
-		    "Validation failed", errors));
+		msg = g_strdup_printf("Validation failed: %jd errors",
+		    rpc_array_get_count(errors));
+
+		rpc_function_error_ex(cookie, rpc_error_create(EINVAL, msg, errors));
+		g_free(msg);
 	}

 	return (NULL);
@@ -1275,7 +1289,7 @@

 	if (!rpct_validate_return(member, result, &errors)) {
 		rpc_function_error_ex(cookie, rpc_error_create(EINVAL,
-		    "Validation failed", errors));
+		    "Return value validation failed", errors));
 	}

 	return (NULL);
@@ -1293,7 +1307,7 @@
 	context->types = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
 	    (GDestroyNotify)rpct_type_free);
 	context->interfaces = g_hash_table_new_full(g_str_hash, g_str_equal,
-	    g_free, NULL);
+	    g_free, (GDestroyNotify)rpct_interface_free);

 	for (b = builtin_types; *b != NULL; b++) {
 		type = g_malloc0(sizeof(*type));


Implement rpct_newi().

Implement rpct_newi().

--- src/rpc_typing.c
+++ src/rpc_typing.c
@@ -82,24 +82,26 @@
 rpc_object_t
 rpct_new(const char *decl, const char *realm, rpc_object_t object)
 {
-	rpc_object_t inst;
 	struct rpct_typei *typei;
-	const char *type_realm = realm;
-
-	if (type_realm == NULL)
-		type_realm = context->global_realm;
-
-	typei = rpct_instantiate_type(decl, type_realm);
+
+	if (realm == NULL)
+		realm = context->global_realm;
+
+	typei = rpct_instantiate_type(decl, realm);
 	if (typei == NULL)
 		return (NULL);

-	inst = object;
+	return (rpct_newi(typei, object));
+}
+
+rpc_object_t
+rpct_newi(rpct_typei_t typei, rpc_object_t object)
+{
 	if (object == NULL)
-		inst = rpc_dictionary_create();
-
-	inst->ro_typei = typei;
-
-	return (inst);
+		object = rpc_dictionary_create();
+
+	object->ro_typei = typei;
+	return (object);
 }

 rpct_class_t


xfreerdp: don't execute action script when not present

--- client/X11/xf_event.c
+++ client/X11/xf_event.c
@@ -138,6 +138,9 @@
 	char buffer[1024] = { 0 };
 	char command[1024] = { 0 };

+	if (!xfc->actionScript)
+		return 1;
+
 	if (event->type > (sizeof(X11_EVENT_STRINGS) / sizeof(const char*)))
 		return 1;


sdn_sensor.c: refactor

sdn_sensor.c: refactor

--- src/sdn_sensor.c
+++ src/sdn_sensor.c
@@ -384,75 +384,76 @@
     qconf = NULL;

     /* Initialize the port/queue configuration of each logical core */
-    for (portid = 0; portid < nb_ports; portid++) {
+    for (port_id = 0; port_id < nb_ports; port_id++) {
         /* skip ports that are not enabled */
-        if ((ss_enabled_port_mask & (1 << portid)) == 0)
+        if ((ss_enabled_port_mask & (1 << port_id)) == 0)
             continue;

         /* get the lcore_id for this port */
         while (rte_lcore_is_enabled(rx_lcore_id) == 0 ||
-               lcore_queue_conf[rx_lcore_id].n_rx_port ==
+               lcore_queue_conf[rx_lcore_id].rx_port_count ==
                ss_rx_queue_per_lcore) {
             rx_lcore_id++;
-            if (rx_lcore_id >= RTE_MAX_LCORE)
+            if (rx_lcore_id >= RTE_MAX_LCORE) {
                 rte_exit(EXIT_FAILURE, "Not enough cores\n");
-        }
-
-        if (qconf != &lcore_queue_conf[rx_lcore_id])
+            }
+        }
+
+        if (qconf != &lcore_queue_conf[rx_lcore_id]) {
             /* Assigned a new logical core in the loop above. */
             qconf = &lcore_queue_conf[rx_lcore_id];
-
-        qconf->rx_port_list[qconf->n_rx_port] = portid;
-        qconf->n_rx_port++;
-        printf("Lcore %u: RX port %u\n", rx_lcore_id, (unsigned) portid);
+        }
+
+        qconf->rx_port_list[qconf->rx_port_count] = port_id;
+        qconf->rx_port_count++;
+        printf("Lcore %u: RX port %u\n", rx_lcore_id, (unsigned) port_id);
     }

     nb_ports_available = nb_ports;

     /* Initialise each port */
-    for (portid = 0; portid < nb_ports; portid++) {
+    for (port_id = 0; port_id < nb_ports; port_id++) {
         /* skip ports that are not enabled */
-        if ((ss_enabled_port_mask & (1 << portid)) == 0) {
-            printf("Skipping disabled port %u\n", (unsigned) portid);
+        if ((ss_enabled_port_mask & (1 << port_id)) == 0) {
+            printf("Skipping disabled port %u\n", (unsigned) port_id);
             nb_ports_available--;
             continue;
         }
         /* init port */
-        printf("Initializing port %u... ", (unsigned) portid);
+        printf("Initializing port %u... ", (unsigned) port_id);
         fflush(stdout);
-        ret = rte_eth_dev_configure(portid, 1, 1, &port_conf);
-        if (ret < 0)
-            rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%u\n",
-                  ret, (unsigned) portid);
-
-        rte_eth_macaddr_get(portid,&ss_ports_eth_addr[portid]);
+        rv = rte_eth_dev_configure(port_id, 1, 1, &port_conf);
+        if (rv < 0) {
+            rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%u\n", rv, (unsigned) port_id);
+        }
+
+        rte_eth_macaddr_get(port_id,&port_eth_addrs[port_id]);

         /* init one RX queue */
         fflush(stdout);
-        ret = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
-                         rte_eth_dev_socket_id(portid), &rx_conf,
+        rv = rte_eth_rx_queue_setup(port_id, 0, rxd_count,
+                         rte_eth_dev_socket_id(port_id), &rx_conf,
                          ss_pktmbuf_pool);
-        if (ret < 0)
-            rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup:err=%d, port=%u\n",
-                  ret, (unsigned) portid);
+        if (rv < 0) {
+            rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup:err=%d, port=%u\n", rv, (unsigned) port_id);
+        }

         /* init one TX queue on each port */
         fflush(stdout);
-        ret = rte_eth_tx_queue_setup(portid, 0, nb_txd,
-                rte_eth_dev_socket_id(portid), &tx_conf);
-        if (ret < 0)
-            rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup:err=%d, port=%u\n",
-                ret, (unsigned) portid);
+        rv = rte_eth_tx_queue_setup(port_id, 0, txd_count, rte_eth_dev_socket_id(port_id), &tx_conf);
+        if (rv < 0) {
+            rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup:err=%d, port=%u\n", rv, (unsigned) port_id);
+        }

         /* Start device */
-        ret = rte_eth_dev_start(portid);
-        if (ret < 0)
-            rte_exit(EXIT_FAILURE, "rte_eth_dev_start:err=%d, port=%u\n",
-                  ret, (unsigned) portid);
+        rv = rte_eth_dev_start(port_id);
+        if (rv < 0) {
+            rte_exit(EXIT_FAILURE, "rte_eth_dev_start:err=%d, port=%u\n", rv, (unsigned) port_id);
+        }

         printf("done: \n");

-        rte_eth_promiscuous_enable(portid);
+        rte_eth_promiscuous_enable(port_id);

         printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n",
                 (unsigned) portid,


core: Fix missing channel unref on cached session watch

g_io_add_watch function takes own reference so local one needs to
be dropped. Fix following Valgrind report:

126 (120 direct, 6 indirect) bytes in 1 blocks are definitely lost in
    loss record 146 of 158
at 0x4C2745D: malloc (in /usr/lib64/valgrind/
   vgpreload_memcheck-amd64-linux.so)
by 0x4E7FE6E: g_malloc (in /usr/lib64/libglib-2.0.so.0.3800.2)
by 0x4EBC5B7: g_io_channel_unix_new (in /usr/lib64/
   libglib-2.0.so.0.3800.2)
by 0x4496B4: search_completed_cb (sdp-client.c:129)
by 0x45217B: sdp_process (sdp.c:4350)
by 0x449814: search_process_cb (sdp-client.c:228)
by 0x4E7A2A5: g_main_context_dispatch (in /usr/
   lib64/libglib-2.0.so.0.3800.2)
by 0x4E7A627: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2)
by 0x4E7AA39: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3800.2)
by 0x404372: main (main.c:550)

--- src/sdp-client.c
+++ src/sdp-client.c
@@ -130,6 +130,8 @@

 	cached->io_id = g_io_add_watch(chan, G_IO_HUP | G_IO_ERR | G_IO_NVAL,
 						disconnect_watch, cached);
+
+	g_io_channel_unref(chan);
 }

 struct search_context {


Handle explicitly typed statement functions

--- src/sema/scope.c
+++ src/sema/scope.c
@@ -846,9 +846,20 @@
 	if (!func) return NULL;
 	func->src = stmt->src;

-	ofc_sema_decl_t* rdecl
-		= ofc_sema_scope_decl_find_create_ns(
+	ofc_sema_decl_t* edecl
+		= ofc_sema_scope_decl_find_modify(
+			scope, base_name.string, true);
+
+	ofc_sema_decl_t* rdecl;
+	if (edecl)
+	{
+		rdecl = ofc_sema_decl_copy(edecl);
+	}
+	else
+	{
+		rdecl = ofc_sema_scope_decl_find_create_ns(
 			func, base_name, true, NULL);
+	}
 	if (!rdecl || !rdecl->type)
 	{
 		ofc_sparse_ref_error(stmt->src,


WL#5710 - fixed (c) character causing compile issue.

--- client/mysql_plugin.c
+++ client/mysql_plugin.c
@@ -1,4 +1,5 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+/*
+   Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by


require Service ptql in sigar_sevices_query

--- src/sigar_ptql.c
+++ src/sigar_ptql.c
@@ -141,6 +141,9 @@

 #define branch_strstr(branch, s1, s2) \
     (IS_ICASE(branch) ? sigar_strcasestr(s1, s2) : strstr(s1, s2))
+
+#define IS_PID_SERVICE_QUERY(branch) \
+    (branch->flags >= PTQL_PID_SERVICE_NAME)

 static void data_free(void *data)
 {
@@ -890,8 +893,15 @@
     }

     if (query->branches.number == 1) {
-        status =
-            sigar_services_walk(walker, &query->branches.data[0]);
+        ptql_branch_t *branch = &query->branches.data[0];
+
+        if (IS_PID_SERVICE_QUERY(branch)) {
+            status = sigar_services_walk(walker, branch);
+        }
+        else {
+            ptql_error(error, "Invalid Service query: %s", ptql);
+            status = SIGAR_PTQL_MALFORMED_QUERY;
+        }
     }
     else {
         ptql_error(error, "Too many queries (%d), must be (1)",
@@ -950,7 +960,7 @@
     int status, i;
     sigar_pid_t match_pid;

-    if (branch->flags >= PTQL_PID_SERVICE_NAME) {
+    if (IS_PID_SERVICE_QUERY(branch)) {
         if ((branch->flags > PTQL_PID_SERVICE_NAME) ||
             (branch->op_name != PTQL_OP_EQ))
         {


Fix potential overflow for high bitdepths in chroma from luma prediction

--- common/common_block.c
+++ common/common_block.c
@@ -146,7 +146,8 @@
     return;

   // Compute linear fit between predicted chroma and predicted luma
-  int32_t ysum = 0, usum = 0, vsum = 0, yysum = 0, yusum = 0, yvsum = 0, uusum = 0, vvsum = 0;
+  // Could be int32_t when SAMPLE is 8 bit
+  int64_t ysum = 0, usum = 0, vsum = 0, yysum = 0, yusum = 0, yvsum = 0, uusum = 0, vvsum = 0;
   for (int i = 0; i < nc; i++)
     for (int j = 0; j < nc; j++) {
       int us = u[i * (cstride >> sub) + j];
@@ -165,18 +166,18 @@
       vvsum += vs * vs;
     }

-  int64_t ssyy = yysum - ((int64_t)ysum*ysum >> lognc * 2);
-  int64_t ssuu = uusum - ((int64_t)usum*usum >> lognc * 2);
-  int64_t ssvv = vvsum - ((int64_t)vsum*vsum >> lognc * 2);
-  int64_t ssyu = yusum - ((int64_t)ysum*usum >> lognc * 2);
-  int64_t ssyv = yvsum - ((int64_t)ysum*vsum >> lognc * 2);
+  int64_t ssyy = yysum - (ysum*ysum >> lognc * 2);
+  int64_t ssuu = uusum - (usum*usum >> lognc * 2);
+  int64_t ssvv = vvsum - (vsum*vsum >> lognc * 2);
+  int64_t ssyu = yusum - (ysum*usum >> lognc * 2);
+  int64_t ssyv = yvsum - (ysum*vsum >> lognc * 2);

   // Require a correlation above a threshold
   if (ssyy) {
     if (ssyu * ssyu * 2 > ssyy * ssuu) {
-      int64_t a64 = ((int64_t)ssyu << 16) / ssyy;
-      int64_t b64 = (((int64_t)usum << 16) - a64 * ysum) >> lognc * 2;
-      int32_t a = (int32_t)clip(a64, -(1 << 23), 1 << 23);
+      int64_t a64 = (ssyu << 16) / ssyy;
+      int64_t b64 = ((usum << 16) - a64 * ysum) >> lognc * 2;
+      int32_t a = (int32_t)clip(a64, -(1 << (31 - bitdepth)), 1 << (31 - bitdepth));
       int32_t b = (int32_t)clip(b64 + (1 << 15), -(1LL << 31), (1U << 31) - 1);

       // Map reconstructed luma to new predicted chroma
@@ -191,9 +192,9 @@
         }
     }
     if (ssyv * ssyv * 2 > ssyy * ssvv) {
-      int64_t a64 = ((int64_t)ssyv << 16) / ssyy;
-      int64_t b64 = (((int64_t)vsum << 16) - a64 * ysum) >> lognc * 2;
-      int32_t a = (int32_t)clip(a64, -(1 << 23), 1 << 23);
+      int64_t a64 = (ssyv << 16) / ssyy;
+      int64_t b64 = ((vsum << 16) - a64 * ysum) >> lognc * 2;
+      int32_t a = (int32_t)clip(a64, -(1 << (31 - bitdepth)), 1 << (31 - bitdepth));
       int32_t b = (int32_t)clip(b64 + (1 << 15), -(1LL << 31), (1U << 31) - 1);

       // Map reconstructed luma to new predicted chroma


added real type

added real type


Move sport constants outside of interface so they can be used in swift

--- TeamSnapSDK/SDK/DataTypes/TSDKSport.h
+++ TeamSnapSDK/SDK/DataTypes/TSDKSport.h
@@ -7,8 +7,6 @@
 #import <Foundation/Foundation.h>
 #import "TSDKCollectionObject.h"
 #import "TSDKObjectsRequest.h"
-
-@interface TSDKSport : TSDKCollectionObject

 extern const NSInteger TSPSportBaseball;
 extern const NSInteger TSPSportSoftBall;
@@ -33,6 +31,8 @@
 extern const NSInteger TSPSportFloorball;
 extern const NSInteger TSPSportStreetHockey;
 extern const NSInteger TSPSportNonSportGroup;
+
+@interface TSDKSport : TSDKCollectionObject

 @property (nonatomic, assign) BOOL hasShootouts; //Example: 0
 @property (nonatomic, assign) BOOL hasStatisticTemplate; //Example: 1


Fixing some testing statements in filedescriptors test

--- Tests/String/string_filedescriptors.c
+++ Tests/String/string_filedescriptors.c
@@ -22,38 +22,37 @@
     //things like BOM in the start of the file
 	EXPECTNOT(0,(futf8=fopen("utf8stringfile","rb")))
     //expect to see succesfull initialization
-	EXPECTGE(0,rfString_Init_fUTF8(&s1,futf8,&eof,RF_EOL_LF))
+	EXPECTGE(rfString_Init_fUTF8(&s1,futf8,&eof,RF_EOL_LF), 0)

     //expect to see the first line of the file (as mentioned in the first comment let's just get rid of the bom here)
     EXPECT(true,rfString_PruneStart(&s1,1))
     rfPrintf("%S",&s1);//ending newline is included since we don't use RF_TextFile
-
-    //assign the next line to the same string
-    EXPECTGE(0,rfString_Assign_fUTF8(&s1,futf8,&eof,RF_EOL_LF))
-    //append the next line to the same string
-    EXPECTGE(0,rfString_Append_fUTF8(&s1,futf8,&eof,RF_EOL_LF))
+    //assign the next line to the same string
+  EXPECTGE(rfString_Assign_fUTF8(&s1,futf8,&eof,RF_EOL_LF), 0)
+    //append the next line to the same string
+  EXPECTGE(rfString_Append_fUTF8(&s1,futf8,&eof,RF_EOL_LF), 0)
 	EXPECT_MSG(true,eof,"The end of file should have been reached and this flag should have been true")
 	//remove the appended newlines since we want to read it one-off from the other file
-    EXPECT(true,rfString_Remove(&s1,RFS_("\n"),0,0))
-    //open an output file and write the string there
-    EXPECTNOT(0,(f = fopen("outputfile","w+b")))
-    EXPECT(RF_SUCCESS,rfString_Fwrite(&s1,f,RF_UTF8))
-    EXPECT(0,fseek(f,0,SEEK_SET))
-
-    //read from that same file and compare
-    EXPECTGE(0,rfString_Init_fUTF8(&s2,f,&eof,RF_EOL_LF))
-    EXPECT(true,rfString_Equal(&s1,&s2))
+  EXPECT(true,rfString_Remove(&s1,RFS_("\n"),0,0))
+  //open an output file and write the string there
+  EXPECTNOT(0,(f = fopen("outputfile","w+b")))
+  EXPECT(RF_SUCCESS,rfString_Fwrite(&s1,f,RF_UTF8))
+  EXPECT(0,fseek(f,0,SEEK_SET))
+
+  //read from that same file and compare
+  EXPECTGE(rfString_Init_fUTF8(&s2,f,&eof,RF_EOL_LF), 0)
+  EXPECT(true,rfString_Equal(&s1,&s2))

 	///let's do the same for RF_StringX
 	fclose(f);
 	EXPECT(0,fseek(futf8,0,SEEK_SET))

-	EXPECTGE(0,rfStringX_Init_fUTF8(&sx1,futf8,&eof,RF_EOL_LF))
+	EXPECTGE(rfStringX_Init_fUTF8(&sx1,futf8,&eof,RF_EOL_LF), 0)
 	EXPECT(true,rfString_PruneStart(&sx1,1))
 	rfPrintf("%S",&sx1);//ending newline is included since we don't use RF_TextFile
-	EXPECTGE(0,rfStringX_Assign_fUTF8(&sx1,futf8,&eof,RF_EOL_LF))
-    //append the next line to the same string
-    EXPECTGE(0,rfStringX_Append_fUTF8(&sx1,futf8,&eof,RF_EOL_LF))
+	EXPECTGE(rfStringX_Assign_fUTF8(&sx1,futf8,&eof,RF_EOL_LF), 0)
+    //append the next line to the same string
+  EXPECTGE(rfStringX_Append_fUTF8(&sx1,futf8,&eof,RF_EOL_LF), 0)
 	EXPECT_MSG(true,eof,"The end of file should have been reached and this flag should have been true")
 	//remove the appended newlines since we want to read it one-off from the other file
     EXPECT(true,rfString_Remove(&sx1,RFS_("\n"),0,0))
@@ -63,7 +62,7 @@
     EXPECT(0,fseek(f,0,SEEK_SET))

     //read from that same file and compare
-    EXPECTGE(0,rfStringX_Init_fUTF8(&sx2,f,&eof,RF_EOL_LF))
+  EXPECTGE(rfStringX_Init_fUTF8(&sx2,f,&eof,RF_EOL_LF), 0)
     EXPECT(true,rfString_Equal(&sx1,&sx2))

     fclose(futf8);
@@ -73,14 +72,14 @@
     EXPECTNOT(0,(futf16 = fopen("utf16lestringfile","rb")))

     //expect to see succesfull initialization
-	EXPECTGE(0,rfString_Init_fUTF16(&s3,futf16,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfString_Init_fUTF16(&s3,futf16,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
     //expect to see the first line of the file (as mentioned in the first comment let's just get rid of the bom here)
     EXPECT(true,rfString_PruneStart(&s3,1));
     rfPrintf("%S",&s3);//ending newline is included since we don't use RF_TextFile
     //assign the next line to the same string
-    EXPECTGE(0,rfString_Assign_fUTF16(&s3,futf16,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfString_Assign_fUTF16(&s3,futf16,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
     //append the next line to the same string and check for EOF
-    EXPECTGE(0,rfString_Append_fUTF16(&s3,futf16,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfString_Append_fUTF16(&s3,futf16,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
 	EXPECT_MSG(true,eof,"The end of file should have been reached and this flag should have been true");
 	//remove the appended newlines since we want to read it one-off from the other file
     EXPECT(true,rfString_Remove(&s3,RFS_("\n"),0,0))
@@ -91,21 +90,21 @@
     EXPECT(0,fseek(f,0,SEEK_SET))

     //read from that same file and compare
-    EXPECTGE(0,rfString_Init_fUTF16(&s4,f,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfString_Init_fUTF16(&s4,f,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
     EXPECT(true,rfString_Equal(&s3,&s4));

 	///do the same for RF_StringX
 	EXPECT(0,fseek(futf16,0,SEEK_SET))
 	fclose(f);
 	//expect to see succesfull initialization
-	EXPECTGE(0,rfStringX_Init_fUTF16(&sx3,futf16,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
+	EXPECTGE(rfStringX_Init_fUTF16(&sx3,futf16,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
     //expect to see the first line of the file (as mentioned in the first comment let's just get rid of the bom here)
     EXPECT(true,rfString_PruneStart(&sx3,1));
     rfPrintf("%S",&sx3);//ending newline is included since we don't use RF_TextFile
     //assign the next line to the same string
-    EXPECTGE(0,rfStringX_Assign_fUTF16(&sx3,futf16,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfStringX_Assign_fUTF16(&sx3,futf16,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
     //append the next line to the same string and check for EOF
-    EXPECTGE(0,rfStringX_Append_fUTF16(&sx3,futf16,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfStringX_Append_fUTF16(&sx3,futf16,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
 	EXPECT_MSG(true,eof,"The end of file should have been reached and this flag should have been true");
 	//remove the appended newlines since we want to read it one-off from the other file
     EXPECT(true,rfString_Remove(&sx3,RFS_("\n"),0,0))
@@ -116,7 +115,7 @@
     EXPECT(0,fseek(f,0,SEEK_SET))

     //read from that same file and compare
-    EXPECTGE(0,rfStringX_Init_fUTF16(&sx4,f,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfStringX_Init_fUTF16(&sx4,f,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
     EXPECT(true,rfString_Equal(&sx3,&sx4));

     fclose(futf16);
@@ -126,14 +125,14 @@
     EXPECTNOT(0,(futf16 = fopen("utf16bestringfile","rb")))

     //expect to see succesfull initialization
-	EXPECTGE(0,rfString_Init_fUTF16(&s5,futf16,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfString_Init_fUTF16(&s5,futf16,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
     //expect to see the first line of the file (as mentioned in the first comment let's just get rid of the bom here)
     EXPECT(true,rfString_PruneStart(&s5,1))
     rfPrintf("%S",&s5);//ending newline is included since we don't use RF_TextFile
     //assign the next line to the same string
-    EXPECTGE(0,rfString_Assign_fUTF16(&s5,futf16,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
-    //append the next line to the same string
-    EXPECTGE(0,rfString_Append_fUTF16(&s5,futf16,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfString_Assign_fUTF16(&s5,futf16,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
+    //append the next line to the same string
+    EXPECTGE(rfString_Append_fUTF16(&s5,futf16,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
 	EXPECT_MSG(true,eof,"The end of file should have been reached and this flag should have been true");
 	//remove the appended newlines since we want to read it one-off from the other file
     EXPECT(true,rfString_Remove(&s5,RFS_("\n"),0,0))
@@ -144,21 +143,21 @@
     EXPECT(0,fseek(f,0,SEEK_SET))

     //read from that same file and compare
-    EXPECTGE(0,rfString_Init_fUTF16(&s6,f,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfString_Init_fUTF16(&s6,f,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
     EXPECT(true,rfString_Equal(&s5,&s6))

 	///do the same for RF_StringX
 	fclose(f);
 	EXPECT(0,fseek(futf16,0,SEEK_SET))
 	//expect to see succesfull initialization
-	EXPECTGE(0,rfStringX_Init_fUTF16(&sx5,futf16,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
+	EXPECTGE(rfStringX_Init_fUTF16(&sx5,futf16,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
     //expect to see the first line of the file (as mentioned in the first comment let's just get rid of the bom here)
     EXPECT(true,rfString_PruneStart(&sx5,1))
     rfPrintf("%S",&sx5);//ending newline is included since we don't use RF_TextFile
     //assign the next line to the same string
-    EXPECTGE(0,rfStringX_Assign_fUTF16(&sx5,futf16,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
-    //append the next line to the same string
-    EXPECTGE(0,rfStringX_Append_fUTF16(&sx5,futf16,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
+  EXPECTGE(rfStringX_Assign_fUTF16(&sx5,futf16,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
+    //append the next line to the same string
+  EXPECTGE(rfStringX_Append_fUTF16(&sx5,futf16,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
 	EXPECT_MSG(true,eof,"The end of file should have been reached and this flag should have been true");
 	//remove the appended newlines since we want to read it one-off from the other file
     EXPECT(true,rfString_Remove(&sx5,RFS_("\n"),0,0))
@@ -169,7 +168,7 @@
     EXPECT(0,fseek(f,0,SEEK_SET))

     //read from that same file and compare
-    EXPECTGE(0,rfStringX_Init_fUTF16(&sx6,f,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfStringX_Init_fUTF16(&sx6,f,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
     EXPECT(true,rfString_Equal(&sx5,&sx6))

     fclose(futf16);
@@ -180,14 +179,14 @@
     EXPECTNOT(0,(futf32 = fopen("utf32lestringfile","rb")))

     //expect to see succesfull initialization
-	EXPECTGE(0,rfString_Init_fUTF32(&s7,futf32,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfString_Init_fUTF32(&s7,futf32,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
     //expect to see the first line of the file (as mentioned in the first comment let's just get rid of the bom here)
     EXPECT(true,rfString_PruneStart(&s7,1))
     rfPrintf("%S",&s7);//ending newline is included since we don't use RF_TextFile
     //assign the next line to the same string
-    EXPECTGE(0,rfString_Assign_fUTF32(&s7,futf32,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
-    //append the next line to the same string
-    EXPECTGE(0,rfString_Append_fUTF32(&s7,futf32,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfString_Assign_fUTF32(&s7,futf32,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
+    //append the next line to the same string
+    EXPECTGE(rfString_Append_fUTF32(&s7,futf32,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
 	EXPECT_MSG(true,eof,"The end of file should have been reached and this flag should have been true");
 	//remove the appended newlines since we want to read it one-off from the other file
     EXPECT(true,rfString_Remove(&s7,RFS_("\n"),0,0))
@@ -198,21 +197,21 @@
     EXPECT(0,fseek(f,0,SEEK_SET))

     //read from that same file and compare
-    EXPECTGE(0,rfString_Init_fUTF32(&s8,f,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfString_Init_fUTF32(&s8,f,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
     EXPECT(true,rfString_Equal(&s7,&s8))

 	///for RF_StringX
     EXPECT(0,fseek(futf32,0,SEEK_SET))
 	fclose(f);
 	//expect to see succesfull initialization
-	EXPECTGE(0,rfStringX_Init_fUTF32(&sx7,futf32,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfStringX_Init_fUTF32(&sx7,futf32,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
     //expect to see the first line of the file (as mentioned in the first comment let's just get rid of the bom here)
     EXPECT(true,rfString_PruneStart(&sx7,1))
     rfPrintf("%S",&sx7);//ending newline is included since we don't use RF_TextFile
     //assign the next line to the same string
-    EXPECTGE(0,rfStringX_Assign_fUTF32(&sx7,futf32,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
-    //append the next line to the same string
-    EXPECTGE(0,rfStringX_Append_fUTF32(&sx7,futf32,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfStringX_Assign_fUTF32(&sx7,futf32,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
+    //append the next line to the same string
+    EXPECTGE(rfStringX_Append_fUTF32(&sx7,futf32,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
 	EXPECT_MSG(true,eof,"The end of file should have been reached and this flag should have been true");
 	//remove the appended newlines since we want to read it one-off from the other file
     EXPECT(true,rfString_Remove(&sx7,RFS_("\n"),0,0))
@@ -223,7 +222,7 @@
     EXPECT(0,fseek(f,0,SEEK_SET))

     //read from that same file and compare
-    EXPECTGE(0,rfStringX_Init_fUTF32(&sx8,f,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfStringX_Init_fUTF32(&sx8,f,RF_LITTLE_ENDIAN,&eof,RF_EOL_LF), 0)
     EXPECT(true,rfString_Equal(&sx7,&sx8))

     fclose(futf32);
@@ -234,14 +233,14 @@
     EXPECTNOT(0,(futf32 = fopen("utf32bestringfile","rb")))

     //expect to see succesfull initialization
-	EXPECTGE(0,rfString_Init_fUTF32(&s9,futf32,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfString_Init_fUTF32(&s9,futf32,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
     //expect to see the first line of the file (as mentioned in the first comment let's just get rid of the bom here)
     EXPECT(true,rfString_PruneStart(&s9,1))
     rfPrintf("%S",&s9);//ending newline is included since we don't use RF_TextFile
     //assign the next line to the same string
-    EXPECTGE(0,rfString_Assign_fUTF32(&s9,futf32,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
-    //append the next line to the same string
-    EXPECTGE(0,rfString_Append_fUTF32(&s9,futf32,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfString_Assign_fUTF32(&s9,futf32,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
+    //append the next line to the same string
+    EXPECTGE(rfString_Append_fUTF32(&s9,futf32,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
 	EXPECT_MSG(true,eof,"The end of file should have been reached and this flag should have been true");
 	//remove the appended newlines since we want to read it one-off from the other file
     EXPECT(true,rfString_Remove(&s9,RFS_("\n"),0,0))
@@ -252,7 +251,7 @@
     EXPECT(0,fseek(f,0,SEEK_SET))

     //read from that same file and compare
-    EXPECTGE(0,rfString_Init_fUTF32(&s10,f,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfString_Init_fUTF32(&s10,f,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
     EXPECT(true,rfString_Equal(&s9,&s10))

@@ -260,14 +259,14 @@
 	EXPECT(0,fseek(futf32,0,SEEK_SET))
 	fclose(f);
     //expect to see succesfull initialization
-	EXPECTGE(0,rfStringX_Init_fUTF32(&sx9,futf32,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfStringX_Init_fUTF32(&sx9,futf32,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
     //expect to see the first line of the file (as mentioned in the first comment let's just get rid of the bom here)
     EXPECT(true,rfString_PruneStart(&sx9,1))
     rfPrintf("%S",&sx9);//ending newline is included since we don't use RF_TextFile
     //assign the next line to the same string
-    EXPECTGE(0,rfStringX_Assign_fUTF32(&sx9,futf32,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
-    //append the next line to the same string
-    EXPECTGE(0,rfStringX_Append_fUTF32(&sx9,futf32,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfStringX_Assign_fUTF32(&sx9,futf32,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
+    //append the next line to the same string
+    EXPECTGE(rfStringX_Append_fUTF32(&sx9,futf32,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
 	EXPECT_MSG(true,eof,"The end of file should have been reached and this flag should have been true");
 	//remove the appended newlines since we want to read it one-off from the other file
     EXPECT(true,rfString_Remove(&sx9,RFS_("\n"),0,0))
@@ -278,7 +277,7 @@
     EXPECT(0,fseek(f,0,SEEK_SET))

     //read from that same file and compare
-    EXPECTGE(0,rfStringX_Init_fUTF32(&sx10,f,RF_BIG_ENDIAN,&eof,RF_EOL_LF))
+    EXPECTGE(rfStringX_Init_fUTF32(&sx10,f,RF_BIG_ENDIAN,&eof,RF_EOL_LF), 0)
     EXPECT(true,rfString_Equal(&sx9,&sx10))

 	fclose(futf32);


Fixed some of the Scene time callbacks so that they are correctly attached for each scene object.

--- source/graphics/scene.c
+++ source/graphics/scene.c
@@ -441,6 +441,36 @@
 	return (return_code);
 } /* Scene_changed_private */

+static int Scene_time_update_callback(struct Time_object *time_object,
+	double current_time, void *scene_void)
+/*******************************************************************************
+LAST MODIFIED : 5 October 1998
+
+DESCRIPTION :
+Responds to changes in the time object.
+==============================================================================*/
+{
+	int return_code;
+	struct Scene *scene;
+
+	ENTER(Scene_time_update_callback);
+	USE_PARAMETER(current_time);
+	if (time_object && (scene=(struct Scene *)scene_void))
+	{
+		Scene_notify_object_changed(scene,/*fast_changing*/0);
+		return_code=1;
+	}
+	else
+	{
+		display_message(ERROR_MESSAGE,
+			"Scene_time_update_callback.  Invalid argument(s)");
+		return_code=0;
+	}
+	LEAVE;
+
+	return (return_code);
+} /* Scene_time_update_callback */
+
 static int Scene_object_changed_external(struct Scene_object *scene_object)
 /*******************************************************************************
 LAST MODIFIED : 12 July 2000
@@ -560,7 +590,24 @@
 		}
 		else
 		{
+			if (scene_object->time_object)
+			{
+				/* If setting to NULL we want to clear out the old callback */
+				if (scene_object->scene)
+				{
+					Time_object_remove_callback(scene_object->time_object,
+						Scene_time_update_callback, scene_object->scene);
+				}
+			}
 			scene_object->scene = scene;
+			if (scene_object->time_object)
+			{
+				if (scene_object->scene)
+				{
+					Time_object_add_callback(scene_object->time_object,
+						Scene_time_update_callback, scene_object->scene);
+				}
+			}
 			return_code=1;
 		}
 	}
@@ -1157,10 +1204,6 @@
 				{
 					DEACCESS(Scene)(&(scene_object->child_scene));
 				}
-				/* The scene_object is not accessing the scene as the
-					scene owns these objects and destroys them all before
-					destroying itself */
-				scene_object->scene = (struct Scene *)NULL;
 				if (scene_object->scene_manager_callback_id &&
 					scene_object->scene_manager)
 				{
@@ -1184,8 +1227,17 @@
 				{
 					Time_object_remove_callback(scene_object->time_object,
 						Scene_object_time_update_callback, scene_object);
+					if (scene_object->scene)
+					{
+						Time_object_remove_callback(scene_object->time_object,
+							Scene_time_update_callback, scene_object->scene);
+					}
 					DEACCESS(Time_object)(&(scene_object->time_object));
 				}
+				/* The scene_object is not accessing the scene as the
+					scene owns these objects and destroys them all before
+					destroying itself */
+				scene_object->scene = (struct Scene *)NULL;
 				if(scene_object->name)
 				{
 					DEALLOCATE(scene_object->name);
@@ -1997,36 +2049,6 @@
 	}
 	LEAVE;
 } /* Scene_Texture_change */
-
-static int Scene_time_update_callback(struct Time_object *time_object,
-	double current_time, void *scene_void)
-/*******************************************************************************
-LAST MODIFIED : 5 October 1998
-
-DESCRIPTION :
-Responds to changes in the time object.
-==============================================================================*/
-{
-	int return_code;
-	struct Scene *scene;
-
-	ENTER(Scene_time_update_callback);
-	USE_PARAMETER(current_time);
-	if (time_object && (scene=(struct Scene *)scene_void))
-	{
-		Scene_notify_object_changed(scene,/*fast_changing*/0);
-		return_code=1;
-	}
-	else
-	{
-		display_message(ERROR_MESSAGE,
-			"Scene_time_update_callback.  Invalid argument(s)");
-		return_code=0;
-	}
-	LEAVE;
-
-	return (return_code);
-} /* Scene_time_update_callback */

 static int Scene_object_update_time_behaviour(
 	struct Scene_object *scene_object, void *time_object_void)
@@ -3611,16 +3633,22 @@
 				{
 					Time_object_remove_callback(scene_object->time_object,
 						Scene_object_time_update_callback, scene_object);
-					Time_object_remove_callback(scene_object->time_object,
-						Scene_time_update_callback, scene_object->scene);
+					if (scene_object->scene)
+					{
+						Time_object_remove_callback(scene_object->time_object,
+							Scene_time_update_callback, scene_object->scene);
+					}
 				}
 				REACCESS(Time_object)(&(scene_object->time_object),time);
 				if (time)
 				{
 					Time_object_add_callback(scene_object->time_object,
 						Scene_object_time_update_callback, scene_object);
-					Time_object_add_callback(scene_object->time_object,
-						Scene_time_update_callback, scene_object->scene);
+					if (scene_object->scene)
+					{
+						Time_object_add_callback(scene_object->time_object,
+							Scene_time_update_callback, scene_object->scene);
+					}
 				}
 			}
 			return_code=1;


Only notify parent scene of changes to scene_object when parent exists.

--- source/graphics/scene.c
+++ source/graphics/scene.c
@@ -553,7 +553,10 @@
 	ENTER(Scene_object_graphics_object_update_callback);
 	if (graphics_object && (scene_object=(struct Scene_object *)scene_object_void))
 	{
-		Scene_update_time_behaviour(scene_object->scene, graphics_object);
+		if (scene_object->scene)
+		{
+			Scene_update_time_behaviour(scene_object->scene, graphics_object);
+		}
 		Scene_object_changed_internal(scene_object);
 		return_code=1;
 	}
@@ -587,8 +590,11 @@
 		if (g_VISIBLE==scene_object->visibility)
 		{
 			Scene_object_changed_external(scene_object);
-			Scene_update_time_behaviour_with_gt_element_group(scene_object->scene,
-				gt_element_group);
+			if (scene_object->scene)
+			{
+				Scene_update_time_behaviour_with_gt_element_group(
+					scene_object->scene, gt_element_group);
+			}
 		}
 		return_code=1;
 	}


Fix a bug where we were adding twice a task to ready queue

--- source/kernel/src/fx3.c
+++ source/kernel/src/fx3.c
@@ -214,28 +214,44 @@
  */
 static bool markTaskReady(struct task_control_block* tcb)
 {
-   assert(tcb->config->timeSlice_ticks >= tcb->roundRobinSliceLeft_ticks);
-   if (tcb->config->timeSlice_ticks && (0 == tcb->roundRobinSliceLeft_ticks))
-   {
-      tcb->state = TS_EXHAUSTED;
+   if (TS_READY != tcb->state)
+   {
+      for (uint32_t ii = 0; ii < runnableTasks.size; ii ++)
+      {
+         uint32_t* priority = runnableTasks.memPool[ii + 1];
+         struct task_control_block* readyTask = (struct task_control_block*) (((uint8_t*) priority) - (offsetof(struct task_control_block, effectivePriority)));
+
+         assert(readyTask != tcb);
+
+         assert((TS_READY == readyTask->state) || (TS_EXHAUSTED == readyTask->state));
+      }
+
+      assert(tcb->config->timeSlice_ticks >= tcb->roundRobinSliceLeft_ticks);
+      if (tcb->config->timeSlice_ticks && (0 == tcb->roundRobinSliceLeft_ticks))
+      {
+         tcb->state = TS_EXHAUSTED;
+      }
+      else
+      {
+         tcb->state = TS_READY;
+      }
+
+      tcb->sleepUntil_ticks  = 0;
+      tcb->effectivePriority = computeEffectivePriority(tcb->state, tcb->config);
+      prq_push(&runnableTasks, &tcb->effectivePriority);
+
+#ifdef FX3_RTT_TRACE
+      if (&idleTask != tcb)
+      {
+         SEGGER_SYSVIEW_OnTaskStartReady((uint32_t) tcb);
+      }
+#endif
+      return (tcb->effectivePriority < runningTask->effectivePriority);
    }
    else
    {
-      tcb->state = TS_READY;
-   }
-
-   tcb->sleepUntil_ticks  = 0;
-   tcb->effectivePriority = computeEffectivePriority(tcb->state, tcb->config);
-   prq_push(&runnableTasks, &tcb->effectivePriority);
-
-#ifdef FX3_RTT_TRACE
-   if (&idleTask != tcb)
-   {
-      SEGGER_SYSVIEW_OnTaskStartReady((uint32_t) tcb);
-   }
-#endif
-
-   return (tcb->effectivePriority < runningTask->effectivePriority);
+      return true;
+   }
 }

 static void scheduleReadyTask(struct task_control_block* tcb)