Added the colorsmith "compiler" which will generate wide colorsmith instructions

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

--- colorsmithcc.c
+++ colorsmithcc.c
@@ -0,0 +1,442 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <wiringPi.h>
+#include <piGlow.h>
+#include <string.h>
+#include <errno.h>
+#include "types.h"
+
+/*
+ * NOTE: this doesn't follow the internal piglow led layout but my own based
+ * on how colorflow "animates" pixels. Since the piglow lays out leds in a
+ * swirl, it is a little hard to describe which leds map to which led register.
+ *
+ * I will give a description as best as possible though.
+ *
+ * The Led closest to the piglow logo on the device is led zero. Following the
+ * curve into the center, the next five leds are 1,2,3,4, and 5. Then starting
+ * with the outmost led in the lower right corner is led 6. The next five leds
+ * tracing into the center are 7,8,9,10,11. Then the final led leg starting in
+ * the lower left hand corner is 12, 13, 14, 15,16, 17.
+ *
+ * Here is a crapy ascii art representation
+ * ----------------------------------------
+ * PIGLOW
+ *
+ *               0
+ *             1
+ *           2
+ *             3        10
+ *               4   11    9
+ *                 5         8
+ *                   17        7
+ *                16             6
+ *    12       15
+ *       13 14
+ *
+ * ----------------------------------------
+ *
+ * As I said, crappy representation but this is what I based everything off of.
+ *
+ */
+typedef struct ColorsmithInstruction {
+   byte command;
+   byte leg;
+   byte ring;
+   byte intensity;
+} ColorsmithInstruction;
+#define getcommand(value) ((byte)(value & 0x3))
+#define getleg(value) ((byte)((value & 0x1C) >> 2))
+#define getring(value) ((byte)((value & 0xE0) >> 5))
+
+enum {
+   RegisterCount = 19,
+   DelayRegister = 18,
+};
+
+struct colorsmithucodecore {
+   byte registers[RegisterCount];
+} colorsmithucodecore;
+
+
+enum {
+   ColorsmithCommandGlow1 = 0,
+   ColorsmithCommandGlowLeg,
+   ColorsmithCommandGlowRing,
+   ColorsmithCommandDelay,
+};
+
+/* inefficient but who cares */
+void core_initialize(colorsmithucodecore*);
+void core_commitstate(colorsmithucodecore*, FILE*);
+void decode(FILE* input);
+void interpret(ColorsmithInstruction* inst);
+void glow1(ColorsmithInstruction* inst);
+void glowleg(ColorsmithInstruction* inst);
+void glowring(ColorsmithInstruction* inst);
+void glowdelay(ColorsmithInstruction* inst);
+byte getnormalizedintensity(ColorsmithInstruction* inst);
+byte getnormalizedring(ColorsmithInstruction* inst);
+void usage(char* name);
+void error(const char* message, int code);
+void setleg(colorsmithucodecore* c, int leg, int intensity);
+void setled(colorsmithucodecore* c, int leg, int ring, int intensity);
+int parseBigEndian = 0;
+int colorintensity = 10;
+int allowdelay = 1;
+/* read one byte at a time */
+int bytemode = 0;
+colorsmithucodecore core;
+int main(int argc, char* argv[]) {
+   char* line;
+   char* tmpLine;
+   FILE* file;
+   int needsClosing, last, i, errorFree;
+   line = 0;
+   file = 0;
+   last = argc - 1;
+   tmpLine = 0;
+   needsClosing = 0;
+   errorFree = 1;
+   if(argc > 1) {
+      for(i = 1; errorFree && (i < last); ++i) {
+         tmpLine = argv[i];
+         if(strlen(tmpLine) == 2 && tmpLine[0] == '-') {
+            switch(tmpLine[1]) {
+               case 'b':
+                  parseBigEndian = 1;
+                  break;
+               case 'f':
+                  colorintensity = 256;
+                  printf("%s\n","WARNING: Do not stare directly at PiGlow LEDs in full intensity mode!\nThey are super bright");
+                  break;
+               case 'g':
+                  bytemode = 1;
+                  break;
+               case '2':
+                  colorintensity = 2;
+                  break;
+               case 'n':
+                  allowdelay = 0;
+                  break;
+               default:
+                  errorFree = 0;
+                  break;
+            }
+         } else {
+            errorFree = 0;
+            break;
+         }
+      }
+      if(errorFree) {
+         line = argv[last];
+         if(strlen(line) == 1 && line[0] == '-') {
+            file = stdin;
+         } else if(strlen(line) >= 1 && line[0] != '-') {
+            file = fopen(line, "r");
+            if(!file) {
+               fprintf(stderr, "couldn't open %s\n", line);
+               exit(errno);
+            }
+            needsClosing = 1;
+         }
+      }
+   }
+
+   if(file) {
+      piGlowSetup(0);
+      core_initialize(&core);
+      decode(file);
+      if(needsClosing && fclose(file) != 0) {
+         fprintf(stderr, "couldn't close %s\n", line);
+         exit(errno);
+      }
+   } else {
+      usage(argv[0]);
+   }
+   return 0;
+}
+
+void usage(char* name) {
+   fprintf(stderr, "usage: %s [-b] [-f | -2] [-g] [-n] <file> \n", name);
+}
+
+void decode(FILE* input) {
+   // translate 2 bytes to 19 bytes!
+   ColorsmithInstruction inst;
+   int a, b;
+   do {
+      a = fgetc(input);
+      if(bytemode) {
+         b = a;
+      } else {
+         b = fgetc(input);
+      }
+
+      if(parseBigEndian) {
+         inst.command = getcommand(b);
+         inst.leg = getleg(b);
+         inst.ring = getring(b);
+         inst.intensity = a;
+      } else {
+         inst.command = getcommand(a);
+         inst.leg = getleg(a);
+         inst.ring = getring(a);
+         inst.intensity = b;
+      }
+      interpret(&inst);
+   } while(a != EOF && b != EOF);
+}
+
+void interpret(ColorsmithInstruction* inst) {
+   switch(inst->command) {
+      case ColorsmithCommandGlow1:
+         glow1(inst);
+         break;
+      case ColorsmithCommandGlowLeg:
+         glowleg(inst);
+         break;
+      case ColorsmithCommandGlowRing:
+         glowring(inst);
+         break;
+      case ColorsmithCommandDelay:
+         glowdelay(inst);
+         break;
+      default:
+         error("panic: unknown command provided", 1);
+   }
+   //commit the core state now that we are done
+   //default to stdout for now
+   core_commitstate(&core, stdout);
+   //we need to clear out the delay each iteration
+   core.registers[DelayRegister] = 0;
+}
+/* this one is a little interesting since it is using a combination of leg and
+ * ring to determine which individual led to set.
+ *
+ * This follows base 6 numbering so converting it to base 10 we can compute the
+ * individual led as:
+ *    index = 6 * leg + ring
+ */
+void glow1(ColorsmithInstruction* inst) {
+   int ring, intensity;
+   ring = getnormalizedring(inst);
+   intensity = getnormalizedintensity(inst);
+   switch(inst->leg) {
+      case 0:
+      case 1:
+      case 2:
+         setled(&core, inst->leg, ring, intensity);
+         break;
+      case 3:
+         setled(&core, 0, ring, intensity);
+         setled(&core, 1, ring, intensity);
+         break;
+      case 4:
+         setled(&core, 0, ring, intensity);
+         setled(&core, 2, ring, intensity);
+         break;
+      case 5:
+         setled(&core, 1, ring, intensity);
+         setled(&core, 2, ring, intensity);
+         break;
+      case 6:
+         // turn on all leds
+         setled(&core, 0, ring, intensity);
+         setled(&core, 1, ring, intensity);
+         setled(&core, 2, ring, intensity);
+         break;
+      case 7:
+         /* turn them off */
+         // just reinitialize the core in this case
+         core_initialize(&core);
+         break;
+      default:
+         error("panic: unknown leg combo provided", 2);
+   }
+}
+/* The following is the map for leg glowing to leds to be triggered:
+ *
+ * Leg 0: 0-5
+ * Leg 1: 6-11
+ * Leg 2: 12-17
+ */
+void glowleg(ColorsmithInstruction* inst) {
+   int intensity;
+   intensity = getnormalizedintensity(inst);
+
+   switch(inst->leg) {
+      case 0:
+      case 1:
+      case 2:
+         setleg(&core, inst->leg, intensity);
+         break;
+      case 3:
+         setleg(&core, 0, intensity);
+         setleg(&core, 1, intensity);
+         break;
+      case 4:
+         setleg(&core, 0, intensity);
+         setleg(&core, 2, intensity);
+         break;
+      case 5:
+         setleg(&core, 1, intensity);
+         setleg(&core, 2, intensity);
+         break;
+      case 6:
+         setleg(&core, 0, intensity);
+         setleg(&core, 1, intensity);
+         setleg(&core, 2, intensity);
+         break;
+      case 7:
+         /* turn them off */
+         //just reinitialize the core since everything is being turned off
+         core_initialize(&core);
+         break;
+      default:
+         error("panic: unknown leg combo provided", 2);
+   }
+}
+void setleg(colorsmithucodecore* c, int leg, int intensity) {
+   int i, begin, end;
+   switch (leg) {
+      case 0:
+         begin = 0;
+         end = 6;
+         break;
+      case 1:
+         begin = 6;
+         end = 12;
+         break;
+      case 2:
+         begin = 12;
+         end = 18;
+         break;
+      default:
+         error("panic: unknown leg provided to be set!", 4);
+   }
+   for(i = begin; i < end; i++) {
+      c->registers[i] = intensity;
+   }
+}
+
+/* According to the wiringPi comments for the piGlow, ring 0 is the outermost
+ * and ring 5 is the inner most. Using the above guide, the layout of rings are
+ * as follows:
+ *
+ * Ring 0: 0,  6, 12
+ * Ring 1: 1,  7, 13
+ * Ring 2: 2,  8, 14
+ * Ring 3: 3,  9, 15
+ * Ring 4: 4, 10, 16
+ * Ring 5: 5, 11, 17
+ */
+void glowring(ColorsmithInstruction* inst) {
+   int ring, intensity;
+   ring = getnormalizedring(inst);
+   intensity = getnormalizedintensity(inst);
+   switch(ring) {
+      case 0:
+         core.registers[0] = intensity;
+         core.registers[6] = intensity;
+         core.registers[12] = intensity;
+         break;
+      case 1:
+         core.registers[1] = intensity;
+         core.registers[7] = intensity;
+         core.registers[13] = intensity;
+         break;
+      case 2:
+         core.registers[2] = intensity;
+         core.registers[8] = intensity;
+         core.registers[14] = intensity;
+         break;
+      case 3:
+         core.registers[3] = intensity;
+         core.registers[9] = intensity;
+         core.registers[15] = intensity;
+         break;
+      case 4:
+         core.registers[4] = intensity;
+         core.registers[10] = intensity;
+         core.registers[16] = intensity;
+         break;
+      case 5:
+         core.registers[5] = intensity;
+         core.registers[11] = intensity;
+         core.registers[17] = intensity;
+         break;
+      default:
+         error("panic: unknown ring combo provided", 3);
+   }
+}
+void glowdelay(ColorsmithInstruction* inst) {
+   // keep the current state but just institute a delay.
+   if(allowdelay) {
+      core.registers[DelayRegister] = inst->intensity;
+   }
+}
+byte getnormalizedintensity(ColorsmithInstruction* inst) {
+   return inst->intensity % colorintensity;
+}
+byte getnormalizedring(ColorsmithInstruction* inst) {
+   return inst->ring % 6;
+}
+void error(const char* message, int code) {
+   fprintf(stderr, "%s\n", message);
+   exit(code);
+}
+
+void core_initialize(colorsmithucodecore* core) {
+   /* initialize the registers to zero */
+   int i;
+   for(i = 0; i < RegisterCount; i++) {
+      core->registers[i] = 0;
+   }
+}
+
+void core_commitstate(colorsmithucodecore* core, FILE* file) {
+   size_t result;
+   result = fwrite(uop, sizeof(colorsmithucodecore), 1, out);
+   if (result != 1) {
+      error("Couldn't output result to file", ferror(out));
+   }
+}
+
+void setleg(colorsmithucodecore* c, int leg, int intensity) {
+   int i, begin, end;
+   switch (leg) {
+      case 0:
+         begin = 0;
+         end = 6;
+         break;
+      case 1:
+         begin = 6;
+         end = 12;
+         break;
+      case 2:
+         begin = 12;
+         end = 18;
+         break;
+      default:
+         error("panic: unknown leg provided to be set!", 4);
+   }
+   for(i = begin; i < end; i++) {
+      c->registers[i] = intensity;
+   }
+}
+void setled(colorsmithucodecore* c, int leg, int ring, int intensity) {
+   // we end up with base 6 math since each leg has 6 entries and each ring has
+   // three so we can come up with a base six math layout
+   //
+   //
+   int index;
+   index = 6 * ring + leg;
+   if (index >= 0 && index < 18) {
+      c->registers[index] = intensity;
+   } else {
+      //print this
+      fprintf(stderr, "got illegal index %d from (+ (* 6 %d) %d)\n", index, leg, ring);
+      error("panic: see above line!", 5);
+   }
+}


Resolve "V730 Not all members of a class are initialized inside the constructor. Consider inspecting: _positionChangeTimer, _mapUpdateTimer, _delayedTeleport. world Transporter.cpp 16"

--- src/world/Objects/Transporter.h
+++ src/world/Objects/Transporter.h
@@ -143,9 +143,9 @@
     PassengerSet::iterator _passengerTeleportItr;
     PassengerSet _staticPassengers;

-    int32_t _positionChangeTimer;
-    int32_t _mapUpdateTimer;
+    int32_t _positionChangeTimer = 0;
+    int32_t _mapUpdateTimer = 0;

     uint32_t positionUpdateDelay;
-    bool _delayedTeleport;
+    bool _delayedTeleport = false;
 };


Add `bt-status` source code

Add `bt-status` source code

BlueZ `btmgmt -i 0 info` started behaving weirdly when no TTY was
attached. (No output.)

So, wrote a simple program to just check the `powered` status of a
Bluetooth interface.

error: pathspec 'bin/src/bt-status.c' did not match any file(s) known to git

--- bin/src/bt-status.c
+++ bin/src/bt-status.c
@@ -0,0 +1,244 @@
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/hci.h>
+
+#ifndef __packed
+#define __packed __attribute__((packed));
+#endif
+
+#define MGMT_EV_CMD_COMPLETE 0x0001
+#define MGMT_EV_CMD_STATUS 0x0002
+
+#define MGMT_OP_READ_INFO 0x0004
+
+#define MGMT_MAX_NAME_LENGTH (248 + 1)
+#define MGMT_MAX_SHORT_NAME_LENGTH (10 + 1)
+#define MAX_REPLY_SIZE 512
+
+#define MGMT_SETTINGS_POWERED (1 << 0)
+
+/* Internal structs from BlueZ src/shared/mgmt.c */
+
+// Typedef `xyz_t` and `xyz_ptr` for `struct xyz` and `struct xyz *`.
+#define TYPEDEFS(STRUCT) \
+  typedef struct STRUCT STRUCT ## _t; \
+  typedef struct STRUCT *STRUCT ## _ptr
+
+// Request that gets queued in `struct mgmt.request_queue`
+struct mgmt_request {
+  unsigned int id;
+  uint16_t opcode;
+  uint16_t index;
+  void *buf;
+  uint16_t len;
+  // Remaining fields not used in this program:
+  // mgmt_request_func_t callback;
+  // mgmt_destroy_func_t destroy;
+  // void *user_data;
+};
+TYPEDEFS(mgmt_request);
+
+// Header for commands as sent on the wire (to HCI control channel)
+struct mgmt_hdr {
+  uint16_t opcode;
+  uint16_t index;
+  uint16_t len;
+} __packed;
+TYPEDEFS(mgmt_hdr);
+#define mgmt_hdr_sz sizeof(mgmt_hdr_t)
+
+// Header for successful response for read_info operation
+struct mgmt_ev_cmd_complete {
+  uint16_t opcode;
+  uint8_t status;
+  uint8_t data[0];
+} __packed;
+TYPEDEFS(mgmt_ev_cmd_complete);
+#define mgmt_ev_cmd_complete_sz sizeof(mgmt_ev_cmd_complete_t)
+
+// Body for successful response for read_info operation
+struct mgmt_rp_read_info {
+  bdaddr_t bdaddr;
+  uint8_t version;
+  uint16_t manufacturer;
+  uint32_t supported_settings;
+  uint32_t current_settings;
+  uint8_t dev_class[3];
+  uint8_t name[MGMT_MAX_NAME_LENGTH];
+  uint8_t short_name[MGMT_MAX_SHORT_NAME_LENGTH];
+} __packed;
+TYPEDEFS(mgmt_rp_read_info);
+#define mgmt_rp_read_info_sz sizeof(mgmt_rp_read_info_t)
+
+// Send a request using vectorized IO (mirrors BlueZ, but probably overkill)
+// Returns 0 on success, 1 on error.
+static int send_req(int sock, const mgmt_request_ptr req) {
+  struct iovec iov;
+  iov.iov_base = req->buf;
+  iov.iov_len = req->len;
+  ssize_t sent = writev(sock, &iov, 1);
+  return sent != req->len;
+}
+
+// Each request needs a unique identifier.
+static unsigned int req_id = 0;
+
+// Fill the request structure for a request to be sent.
+static void init_req(mgmt_request_ptr req, uint16_t opcode, uint16_t index) {
+  mgmt_hdr_ptr hdr;
+
+  req->len = mgmt_hdr_sz;
+  req->buf = malloc(req->len);
+
+  hdr = (mgmt_hdr_ptr)req->buf;
+  hdr->opcode = htobs(opcode);
+  hdr->index = htobs(index);
+  hdr->len = htobs(0);
+
+  req->opcode = opcode;
+  req->index = index;
+  req->id = req_id++;
+}
+
+// Bind a Bluetooth raw socket to the HCI control channel.
+static int bind_raw_hci(void) {
+  int sock, flags;
+
+  union {
+    struct sockaddr sa;
+    struct sockaddr_hci hci;
+  } addr;
+
+  flags = SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK;
+  sock = socket(AF_BLUETOOTH, flags, BTPROTO_HCI);
+
+  addr.hci.hci_family = AF_BLUETOOTH;
+  addr.hci.hci_dev = HCI_DEV_NONE;
+  addr.hci.hci_channel = HCI_CHANNEL_CONTROL;
+
+  bind(sock, &addr.sa, sizeof(addr.hci));
+
+  return sock;
+}
+
+// Use `write(2)` (not printf) to print a constant string to stdout
+#define print(STR) write(1, STR, sizeof(STR))
+
+// Use `write(2)` (not printf) to print a constant string to stdout w/ newline.
+#define echo(STR) print(STR "\n")
+
+// `echo` + exit with error status
+#define die(STR) { echo(STR); return 1; }
+
+// Stringify any single `ARG`.
+#define STRINGIFY(ARG) #ARG
+
+// Macro `ARG` needs another layer of indirection
+#define STRINGIFY_MACRO(ARG) STRINGIFY(ARG)
+
+// Debug macro. `here();` on line 123 prints "HERE 123\n" when hit.
+#define here() echo("HERE " STRINGIFY_MACRO(__LINE__))
+
+// Parse commandline arguments.
+// Return 0 on success, 1 on error.
+static int parse_args(int argc, char **argv, int *quiet, uint16_t *index) {
+  int bad = 0;
+  char c;
+
+  *quiet = 0;
+  *index = 0;
+  for (int i=1; i<argc; i++) {
+    c = argv[i][0];
+    if (!strcmp(argv[i], "-q")) *quiet = 1;
+    else if (c >= '0' && c <= '9' && argv[i][1] == '\0') *index = c - '0';
+    else bad++;
+  }
+
+  return !bad;
+}
+
+// Write a single character to stdout.
+static void write_char(char c) {
+  write(1, &c, 1);
+}
+
+// Hex digits
+static char hex[] = "0123456789abcdef";
+
+// Write a byte in hex notation to stdout.
+static void write_hex_byte(uint8_t b) {
+  write_char(hex[(b >> 4) & 0xf]);
+  write_char(hex[b & 0xf]);
+}
+
+// Main program parses args, reads info for selected index.
+// Only arguments are:
+// "-q" (for quiet) prints nothing, returns result as exit code.
+// "0"-"9" single-digit index for which BT controller to query (default 0).
+int main(int argc, char **argv) {
+  int sock, quiet, powered;
+  ssize_t expected, ret;
+  uint16_t index;
+  uint8_t buf[MAX_REPLY_SIZE];
+  uint32_t current_settings;
+  mgmt_request_t req;
+  mgmt_hdr_ptr reply_hdr;
+  mgmt_ev_cmd_complete_ptr reply_cmd_info;
+  mgmt_rp_read_info_ptr reply_info;
+
+  if (!parse_args(argc, argv, &quiet, &index)) die("BAD ARG");
+
+  sock = bind_raw_hci();
+
+  init_req(&req, MGMT_OP_READ_INFO, index);
+  send_req(sock, &req);
+
+  ret = read(sock, buf, MAX_REPLY_SIZE);
+  expected = mgmt_hdr_sz + mgmt_ev_cmd_complete_sz + mgmt_rp_read_info_sz;
+  if (ret < expected) {
+    printf("TOO SHORT (got %zd, wanted %zd)\n", ret, expected);
+    return 1;
+  }
+
+  // Parse the reply header.
+  reply_hdr = (mgmt_hdr_ptr)buf;
+  if (btohs(reply_hdr->opcode) != MGMT_EV_CMD_COMPLETE) die("BAD REPLY OP");
+  if (btohs(reply_hdr->index) != index) die("BAD REPLY INDEX");
+  if (btohs(reply_hdr->len) + mgmt_hdr_sz != expected) die("BAD REPLY LENGTH");
+
+  // Parse the reply command status.
+  reply_cmd_info = (mgmt_ev_cmd_complete_ptr)(buf + mgmt_hdr_sz);
+  if (btohs(reply_cmd_info->opcode) != MGMT_OP_READ_INFO) die("BAD CMD OP");
+  if (reply_cmd_info->status != 0) die("BAD CMD STATUS");
+
+  // Parse the actual read_info reply.
+  reply_info =
+      (mgmt_rp_read_info_ptr)(buf + mgmt_hdr_sz + mgmt_ev_cmd_complete_sz);
+  current_settings = le32toh(reply_info->current_settings);
+  powered = (current_settings & MGMT_SETTINGS_POWERED) != 0;
+
+  // Just exit with 0 (OK) or 1 (NOK) for `quiet` mode.
+  if (quiet) return powered ? 0 : 1;
+
+  // Print true or false for powered/not.
+  if (powered) print("true");
+  else print("false");
+
+  // Print Bluetooth address tab-separated.
+  write_char('\t');
+
+  // BT addr is stored in reverse order from what's normally printed.
+  for (int i=5; i>=0; i--) {
+    write_hex_byte(reply_info->bdaddr.b[i]);
+    write_char(i ? ':' : '\n');
+  }
+
+  return 0;
+}


Non-leading tab fixes

Non-leading tab fixes

--- api-testcases/test-types.c
+++ api-testcases/test-types.c
@@ -49,16 +49,16 @@
 		       (long) i, (long) typeval, (long) typemask);

 		switch(duk_get_type(ctx, i)) {
-		case DUK_TYPE_NONE:		printf("none"); break;
-		case DUK_TYPE_UNDEFINED:	printf("undefined"); break;
-		case DUK_TYPE_NULL:		printf("null"); break;
-		case DUK_TYPE_BOOLEAN:		printf("boolean"); break;
-		case DUK_TYPE_NUMBER:		printf("number"); break;
-		case DUK_TYPE_STRING:		printf("string"); break;
-		case DUK_TYPE_OBJECT:		printf("object"); break;
-		case DUK_TYPE_BUFFER:		printf("buffer"); break;
-		case DUK_TYPE_POINTER:		printf("pointer"); break;
-		default:			printf("unknown(%d)", (int) duk_get_type(ctx, i)); break;
+		case DUK_TYPE_NONE:       printf("none"); break;
+		case DUK_TYPE_UNDEFINED:  printf("undefined"); break;
+		case DUK_TYPE_NULL:       printf("null"); break;
+		case DUK_TYPE_BOOLEAN:    printf("boolean"); break;
+		case DUK_TYPE_NUMBER:     printf("number"); break;
+		case DUK_TYPE_STRING:     printf("string"); break;
+		case DUK_TYPE_OBJECT:     printf("object"); break;
+		case DUK_TYPE_BUFFER:     printf("buffer"); break;
+		case DUK_TYPE_POINTER:    printf("pointer"); break;
+		default:                  printf("unknown(%d)", (int) duk_get_type(ctx, i)); break;
 		}

 		printf(" bool=%d num=%lf str=%s buf-is-null=%d ptr=%p",


Added sysmenu and maximizebox styles to the main window.

--- thir.c
+++ thir.c
@@ -77,7 +77,7 @@
     return 0;
   }

-  w = CreateWindowEx(WS_EX_APPWINDOW, class, "THIR", WS_BORDER,
+  w = CreateWindowEx(WS_EX_APPWINDOW, class, "THIR", WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX,
     CW_USEDEFAULT, CW_USEDEFAULT, 515, 300,
     NULL, NULL, inst, NULL);


Added vertical scroll bar to the results listbox.

--- thir.c
+++ thir.c
@@ -123,7 +123,7 @@
 	y -= 80;

 	HWND list;
-	list = CreateWindowEx(WS_EX_CLIENTEDGE, "LISTBOX", "", WS_CHILD | WS_VISIBLE | LBS_NOSEL | LBS_HASSTRINGS,
+	list = CreateWindowEx(WS_EX_CLIENTEDGE, "LISTBOX", "", WS_CHILD | WS_VISIBLE | WS_VSCROLL | LBS_NOSEL | LBS_HASSTRINGS,
 	  x, y, 200, 160,
 	  w, (HMENU) IDC_RESULTS, GetModuleHandle(NULL), NULL);
 	SendMessage(list, WM_SETFONT, (WPARAM) font, MAKELPARAM(FALSE, 0));
@@ -298,7 +298,7 @@
     return 0;
   }

-  w = CreateWindowEx(WS_EX_APPWINDOW, class, "THIR", WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX,
+  w = CreateWindowEx(WS_EX_APPWINDOW | WS_EX_CONTROLPARENT, class, "THIR", WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX,
     CW_USEDEFAULT, CW_USEDEFAULT, 515, 320,
     NULL, NULL, inst, NULL);


Always use "#ifdef WIN32", not "#ifdef MINGW" in two single places.

--- tinc.c
+++ tinc.c
@@ -381,7 +381,7 @@

 	CONCAT(&buffer, "\n");
-#ifndef MINGW32
+#ifndef WIN32
 	CONCAT(&buffer, "[ -x \"$0.local\" ] && \"$0.local\" \"$@\"\n");
 #else
 	CONCAT_F(&buffer, "\"%s\\tinc-%s.local" SCRIPT "\"", config->base_path, up ? "up" : "down");
@@ -448,7 +448,7 @@
 	CONCAT(&buffer, COMMENT "this is an autogenerated file - do not edit!\n\n");

 	if (!config->use_dynamic_routes) {
-#ifndef MINGW32
+#ifndef WIN32
 		CONCAT(&buffer, "[ -x \"$0.local\" ] && \"$0.local\" \"$@\"\n");
 #else
 		CONCAT_F(&buffer, "\"%s\\subnet-%s.local" SCRIPT "\"", config->base_path, up ? "up" : "down");


trying to make macos implementation for checked/disabled

--- tray.h
+++ tray.h
@@ -125,7 +125,8 @@
 }

 static void tray_update(struct tray *tray) {
-  [statusBarButton setImage:[NSImage imageNamed:@"icon.png"]];
+  [statusBarButton
+      setImage:[NSImage imageNamed:[NSString stringWithUTF8String:tray->icon]]];

   NSMenu *menu = [NSMenu new];
   [menu autorelease];
@@ -139,7 +140,8 @@
       [menuItem initWithTitle:[NSString stringWithUTF8String:m->text]
                        action:@selector(menuCallback:)
                 keyEquivalent:@""];
-      [menuItem setEnabled:YES];
+      [menuItem setEnabled:(m->disabled ? NO : YES)];
+      [menuItem setState:(m->checked ? NSOnState : NSOffState)];
       [menuItem setRepresentedObject:[NSValue valueWithPointer:m]];

       [menu addItem:menuItem];


modified CAReceiveBlockWiseData() to skip unnecessary logic

Unless there is not error code on the received message,
it is not needed to create a CABlockDataID.

Change-Id: I8dfc581ca802f51d12a36c07644df24110eb7d06
Signed-off-by: Jaewook Jung <e30c770b7f9b30402e4d6c2240cd5b03cb3bf7f9@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/13605
Reviewed-by: Hyuna Jo <a3aecee2eabd6f87461b5d05d6fd0eaf35e269ed@samsung.com>
Tested-by: jenkins-iotivity <09cb29e8a2b473a2c978382eec13ee06fa017bda@opendaylight.org>
Reviewed-by: Ashok Babu Channa <72ac47ef856ca3d131a57cba474ebed48591eeff@samsung.com>

--- resource/csdk/connectivity/src/cablockwisetransfer.c
+++ resource/csdk/connectivity/src/cablockwisetransfer.c
@@ -391,20 +391,20 @@
     // if there is no block option in pdu, check if there is error code.
     if (!isBlock1 && !isBlock2)
     {
-        CABlockDataID_t* blockDataID = CACreateBlockDatablockId(
-                (CAToken_t)pdu->transport_hdr->udp.token,
-                pdu->transport_hdr->udp.token_length,
-                endpoint->addr, endpoint->port);
-        if (NULL == blockDataID || blockDataID->idLength < 1)
-        {
-            OIC_LOG(ERROR, TAG, "blockId is null");
-            CADestroyBlockID(blockDataID);
-            return CA_STATUS_FAILED;
-        }
-
         uint32_t code = CA_RESPONSE_CODE(pdu->transport_hdr->udp.code);
         if (CA_REQUEST_ENTITY_INCOMPLETE == code)
         {
+            CABlockDataID_t* blockDataID = CACreateBlockDatablockId(
+                                                        (CAToken_t)pdu->transport_hdr->udp.token,
+                                                        pdu->transport_hdr->udp.token_length,
+                                                        endpoint->addr, endpoint->port);
+            if (NULL == blockDataID || blockDataID->idLength < 1)
+            {
+                OIC_LOG(ERROR, TAG, "blockId is null");
+                CADestroyBlockID(blockDataID);
+                return CA_STATUS_FAILED;
+            }
+
             CABlockData_t *data = CAGetBlockDataFromBlockDataList(blockDataID);
             if (!data)
             {
@@ -453,9 +453,10 @@
             // and sent data remain in block data list, remove block data
             if (receivedData->responseInfo)
             {
-                CARemoveBlockDataFromList(blockDataID);
-            }
-            CADestroyBlockID(blockDataID);
+                CARemoveBlockDataFromListWithSeed((CAToken_t)pdu->transport_hdr->udp.token,
+                                                  pdu->transport_hdr->udp.token_length,
+                                                  endpoint->addr, endpoint->port);
+            }
             return CA_NOT_SUPPORTED;
         }
     }


cfq: remove extraneous '\n' in blktrace output

I noticed a blank line in blktrace output.  This patch fixes that.

Signed-off-by: Jeff Moyer <cd6badf7869d996b866599075536a600ed1910b5@redhat.com>
Signed-off-by: Jens Axboe <165ab144a3ccfd9429d5c6466b275f24fafdb114@oracle.com>

--- block/cfq-iosched.c
+++ block/cfq-iosched.c
@@ -1252,7 +1252,7 @@

 	BUG_ON(cfqd->busy_queues);

-	cfq_log(cfqd, "forced_dispatch=%d\n", dispatched);
+	cfq_log(cfqd, "forced_dispatch=%d", dispatched);
 	return dispatched;
 }


Implement std::clamp

Implement std::clamp

--- lib/algorithm.h
+++ lib/algorithm.h
@@ -381,5 +381,26 @@
 }
 #endif // ifndef CPP14

+#ifndef CPP17
+namespace cpp17
+{
+template< typename T, class Compare >
+const T& clamp(const T& value, const T& lo, const T& hi, Compare comp)
+{
+    if (comp(value, lo))
+        return lo;
+    if (comp(hi, v))
+        return hi;
+    return value;
+}
+
+template< typename T >
+const T& clamp(const T& value, const T& lo, const T& hi)
+{
+    return ::cpp17::clamp(value, lo, hi, std::less<>());
+}
+}
+#endif
+

 #endif // PBL_CPP_ALGORITHM_H


don't block on the serial binding if you never initiated it

also added a comment indicating why I think blocking here is the wrong thing to do

--- lib/barrelfish/terminal.c
+++ lib/barrelfish/terminal.c
@@ -368,7 +368,10 @@
         state->kbd_bound = true;
     }

-    while (state->serial == NULL) {
+    // XXX: I don't believe this waiting is correct. It changes this from a
+    // non-blocking to a blocking API call. The caller should dispatch
+    // the default waitset, and the bind will eventually complete. -AB
+    while ((sources & TERMINAL_SOURCE_SERIAL) && state->serial == NULL) {
         err = event_dispatch(get_default_waitset());
         if (err_is_fail(err)) {
             USER_PANIC_ERR(err, "event_dispatch on default waitset failed.");


Remove combine-diff.c::uninteresting()

Remove combine-diff.c::uninteresting()

A patch from David Rientjes made me realize we do not have to have
this function -- just call diff_unmodified_pair() directly.

Signed-off-by: Junio C Hamano <dc50d1021234060e53ec42a77d526afa2fe07479@cox.net>

--- combine-diff.c
+++ combine-diff.c
@@ -7,13 +7,6 @@
 #include "xdiff-interface.h"
 #include "log-tree.h"

-static int uninteresting(struct diff_filepair *p)
-{
-	if (diff_unmodified_pair(p))
-		return 1;
-	return 0;
-}
-
 static struct combine_diff_path *intersect_paths(struct combine_diff_path *curr, int n, int num_parent)
 {
 	struct diff_queue_struct *q = &diff_queued_diff;
@@ -25,7 +18,7 @@
 		for (i = 0; i < q->nr; i++) {
 			int len;
 			const char *path;
-			if (uninteresting(q->queue[i]))
+			if (diff_unmodified_pair(q->queue[i]))
 				continue;
 			path = q->queue[i]->two->path;
 			len = strlen(path);
@@ -57,7 +50,7 @@
 			const char *path;
 			int len;

-			if (uninteresting(q->queue[i]))
+			if (diff_unmodified_pair(q->queue[i]))
 				continue;
 			path = q->queue[i]->two->path;
 			len = strlen(path);


Added a test of non-blocking sockets sending data using
vpr::SocketAcceptor and vpr::SocketConnector.  This test still needs work,
but it passes every way I have tried it so far.

git-svn-id: 769d22dfa2d22aad706b9a451492fb87c0735f19@5248 08b38cba-cd3b-11de-854e-f91c5b6e4272

--- modules/vapor/test/TestSuite/TestCases/Socket/NonBlockingSocketsTest.h
+++ modules/vapor/test/TestSuite/TestCases/Socket/NonBlockingSocketsTest.h
@@ -4,13 +4,18 @@
 #include <stdio.h>
 #include <string.h>
 #include <iostream>
+#include <vector>

 #include <TestCase.h>
 #include <TestSuite.h>
 #include <TestCaller.h>
-
+#include <ThreadTestCase.h>
+
+#include <vpr/vpr.h>
 #include <vpr/IO/Socket/Socket.h>
 #include <vpr/IO/Socket/SocketStream.h>
+#include <vpr/IO/Socket/SocketAcceptor.h>
+#include <vpr/IO/Socket/SocketConnector.h>
 #include <vpr/IO/Socket/InetAddr.h>

 #include <vpr/IO/IOSys.h>
@@ -24,28 +29,17 @@
 #include <vpr/Sync/Mutex.h>
 #include <vpr/Sync/CondVar.h>

-#include <vector>

 namespace vprTest
 {

-class NonBlockingSocketTest : public TestCase
+class NonBlockingSocketTest : public ThreadTestCase
 {
 public:
-   NonBlockingSocketTest( std::string name ) : TestCase (name), mThreadAssertTest( true )
-   {
-   }
-
-   void threadAssertTest( bool testcase, std::string text=std::string("none") )
-   {
-      if (testcase == false)
-      {
-         mThreadAssertTest = false;
-         std::cerr << "threadAssertTest - failed: " << text << std::endl;
-      }
-      //assertTest( testcase );     -- Causes crash
-   }
-   bool mThreadAssertTest; // true for no error
+   NonBlockingSocketTest( std::string name )
+      : ThreadTestCase (name), mAcceptorPort(0)
+   {
+   }

    virtual ~NonBlockingSocketTest()
    {
@@ -91,7 +85,7 @@
       assertTest( acceptor_socket.getNonBlocking() );

       acceptor_socket.enableBlocking(); // for reads and writes
-      assertTest( acceptor_socket.getNonBlocking() );
+      assertTest( acceptor_socket.getBlocking() );

       result = acceptor_socket.close().success();
       assertTest( result );
@@ -161,6 +155,143 @@
       assertTest( status.failure() != true );
       status = spawned_socket.close();
       assertTest( status.failure() != true );
+   }
+
+   void testNonBlockingTransfer () {
+      testAssertReset();
+
+      mState        = NOT_READY;                        // Initialize
+      mAcceptorPort = 34567;
+      mMessage      = "The sixth shiek's sixth sheep's sick";
+      mMessageLen   = mMessage.length();
+
+      // Spawn acceptor thread
+      vpr::ThreadMemberFunctor<NonBlockingSocketTest>
+          acceptor_functor(this,
+                           &NonBlockingSocketTest::testNonBlockingTransfer_acceptor);
+      vpr::Thread acceptor_thread( &acceptor_functor);
+
+      // Spawn connector thread
+      vpr::ThreadMemberFunctor<NonBlockingSocketTest>
+          connector_functor(this,
+                            &NonBlockingSocketTest::testNonBlockingTransfer_connector);
+      vpr::Thread connector_thread( &connector_functor);
+
+      // Wait for threads
+      acceptor_thread.join();
+      connector_thread.join();
+
+      assertTest( mThreadAssertTest );
+   }
+
+   void testNonBlockingTransfer_acceptor (void* arg) {
+      vpr::Status status;
+      ssize_t bytes_written;
+      vpr::SocketAcceptor acceptor;
+      vpr::SocketStream client_sock;
+      vpr::InetAddr acceptor_addr(mAcceptorPort);
+
+      status = acceptor.open(acceptor_addr);
+      threadAssertTest(status.success(), "Failed to open acceptor");
+
+      // The acceptor must be non-blocking so that the connected socket it
+      // returns will also be non-blocking.  *sigh*
+      status = acceptor.getSocket().enableNonBlocking();
+      threadAssertTest(status.success(),
+                       "Failed to enable non-blocking for accepted socket");
+
+      mCondVar.acquire();
+      {
+         mState = ACCEPTOR_READY;
+         mCondVar.signal();
+      }
+      mCondVar.release();
+
+      // Wait until the acceptor is ready.
+      // XXX: Maybe this should be imporved upon once non-blocking acceptors
+      // work.
+      while ( acceptor.getSocket().isReadBlocked() ) {
+         vpr::System::usleep(50);
+      }
+
+      status = acceptor.accept(client_sock);
+      threadAssertTest(status.success(), "Accept failed");
+
+      threadAssertTest(client_sock.isOpen(), "Accepted socket should be open");
+      threadAssertTest(client_sock.getNonBlocking(),
+                       "Connected client socket should be non-blocking");
+
+      client_sock.setNoDelay(true);
+      status = client_sock.send(mMessage, mMessageLen, bytes_written);
+      threadAssertTest(! status.failure(),
+                       "Failed to send message to client");
+
+      mCondVar.acquire();
+      {
+         mState = DATA_SENT;
+         mCondVar.signal();
+      }
+      mCondVar.release();
+
+      status = client_sock.close();
+      threadAssertTest(status.success(),
+                       "Could not close acceptor side of client socket");
+   }
+
+   void testNonBlockingTransfer_connector (void* arg) {
+      vpr::Status status;
+      vpr::InetAddr remote_addr;
+      vpr::SocketConnector connector;
+      vpr::SocketStream con_sock;
+      std::string data;
+      ssize_t bytes_read;
+
+      remote_addr.setAddress("localhost", mAcceptorPort);
+
+      mCondVar.acquire();
+      {
+         while ( mState != ACCEPTOR_READY ) {
+            mCondVar.wait();
+         }
+      }
+      mCondVar.release();
+
+      status = con_sock.open();
+      threadAssertTest(status.success(), "Failed to open connector socket");
+
+      status = con_sock.enableNonBlocking();
+      threadAssertTest(status.success(),
+                       "Failed to enable non-blocking for connector");
+      threadAssertTest(con_sock.getNonBlocking(),
+                       "1: Connector should be non-blocking");
+
+      status = connector.connect(con_sock, remote_addr,
+                                 vpr::Interval(5, vpr::Interval::Sec));
+      threadAssertTest(status.success(), "Connector can't connect");
+
+      threadAssertTest(con_sock.getNonBlocking(),
+                       "2: Connector should be non-blocking");
+
+      mCondVar.acquire();
+      {
+         while ( mState != DATA_SENT ) {
+            mCondVar.wait();
+         }
+      }
+      mCondVar.release();
+
+      status = con_sock.recv(data, mMessageLen, bytes_read);
+      threadAssertTest(bytes_read == mMessageLen,
+                       "Connector received message of wrong size");
+
+/*
+      // Make sure we got all the data, then close.
+      while ( con_sock.isReadBlocked() ) {
+         vpr::System::usleep(10);
+      }
+*/
+
+      con_sock.close();
    }

    // 2 sockets... use select...
@@ -298,6 +429,7 @@
       test_suite->addTest( new TestCaller<NonBlockingSocketTest>("testSetOpenNonBlockingThenOpenThenClose", &NonBlockingSocketTest::testSetOpenNonBlockingThenOpenThenClose));
       test_suite->addTest( new TestCaller<NonBlockingSocketTest>("testSetOpenNonBlockingThenOpenThenEnableNonBlockThenClose", &NonBlockingSocketTest::testSetOpenNonBlockingThenOpenThenEnableNonBlockThenClose));
       test_suite->addTest( new TestCaller<NonBlockingSocketTest>("testConnect2NonBlockingSockets", &NonBlockingSocketTest::testConnect2NonBlockingSockets));
+      test_suite->addTest(new TestCaller<NonBlockingSocketTest>("testNonBlockingTransfer", &NonBlockingSocketTest::testNonBlockingTransfer));
       test_suite->addTest( new TestCaller<NonBlockingSocketTest>("testConnect2NonBlockingSocketsUsingSelect", &NonBlockingSocketTest::testConnect2NonBlockingSocketsUsingSelect));

       return test_suite;
@@ -305,6 +437,21 @@

 protected:
    vpr::Mutex     mMutex;
+
+   enum State {
+      ACCEPTOR_READY,
+      NOT_READY,
+      CONNECTOR_CLOSED,
+      DATA_SENT,
+      DONE_READING
+   };
+
+   State           mState;         // State variable
+   vpr::CondVar    mCondVar;       // Condition variable
+   vpr::Uint16     mAcceptorPort;
+
+   std::string     mMessage;
+   vpr::Uint16     mMessageLen;
 };

 }


Big: add LGC 3s battery info

Big: add LGC 3s battery info

BRANCH=big
BUG=chrome-os-partner:26533
TEST=build ec and flash to big board; verify battery works

Signed-off-by: Cloud Lin <cloud_lin@compal.com>
Signed-off-by: Katie Roberts-Hoffman <18b264b2ffd2bdd8a10fa2695b949fed75badc6b@chromium.org>

Change-Id: Ia005a549b8318b4f8df81e7b1341d50da28f4282
Reviewed-on: https://chromium-review.googlesource.com/188632
Reviewed-by: Katie Roberts-Hoffman <18b264b2ffd2bdd8a10fa2695b949fed75badc6b@chromium.org>
Commit-Queue: Katie Roberts-Hoffman <18b264b2ffd2bdd8a10fa2695b949fed75badc6b@chromium.org>
Tested-by: Katie Roberts-Hoffman <18b264b2ffd2bdd8a10fa2695b949fed75badc6b@chromium.org>

--- board/big/battery.c
+++ board/big/battery.c
@@ -74,6 +74,23 @@
 	.discharging_max_c    = 50,
 };

+static struct battery_info info_3s_LGC = {
+
+        .voltage_max    = 13140,
+        .voltage_normal = 11400, /* Average of max & min */
+        .voltage_min    =  9000,
+
+        /* Pre-charge values. */
+        .precharge_current  = 256,      /* mA */
+
+        .start_charging_min_c = 0,
+        .start_charging_max_c = 50,
+        .charging_min_c       = 0,
+        .charging_max_c       = 60,
+        .discharging_min_c    = 0,
+        .discharging_max_c    = 75,
+};
+
 static struct battery_info info_4s = {

 	.voltage_max    = 17520,
@@ -119,6 +136,13 @@
 		.design_mv		= 15200,
 		.battery_info		= &info_4s,
 		.support_cut_off	= 1,
+	},
+	{
+		.manuf                  = "LGC",
+		.device                 = "AC14B18J",
+		.design_mv              = 11400,
+		.battery_info           = &info_3s_LGC,
+		.support_cut_off        = 1,
 	},
 };


elemi: Tune Vconn_Swap delay

elemi: Tune Vconn_Swap delay

The Vconn source should ready before PS_RDY.

BUG=b:186079130
BRANCH=firmware-volteer-13672.B-main
TEST=PDtrace to make sure the timing of Vconn_Swap.

Signed-off-by: Devin Lu <052fe648504800b810f29702ef4f3db83fad68bf@quantatw.com>
Change-Id: I3c60ea73219497c661b6fec5add77c73a7f116b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2847714
Reviewed-by: Abe Levkoy <2e1ad7039298f93262cf06bbb457275fb3e2ecb5@chromium.org>

--- board/elemi/board.h
+++ board/elemi/board.h
@@ -42,6 +42,9 @@
 /* TODO: b/144165680 - measure and check these values on Volteer */
 #define PD_POWER_SUPPLY_TURN_ON_DELAY	30000 /* us */
 #define PD_POWER_SUPPLY_TURN_OFF_DELAY	30000 /* us */
+/* Experimentally determined. See b/186079130. */
+#undef CONFIG_USBC_VCONN_SWAP_DELAY_US
+#define CONFIG_USBC_VCONN_SWAP_DELAY_US	10000 /* us */

 /*
  * SN5S30 PPC supports up to 24V VBUS source and sink, however passive USB-C


kirby: Always assume adaptor power source

Until we can properly detect power source type, always assume adaptor
power source to allow more input current.

BUG=chrome-os-partner:22055
TEST=Plug in adaptor and see 0x84 from BQ24192's register 0x8.
BRANCH=None

Change-Id: Ic6adc0d459f9cc038870e3dd2b680549c4b5df39
Signed-off-by: Vic Yang <5fd92abeee651458f98e2856f4f200ee971cee4d@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/66934
Reviewed-by: Vincent Palatin <70a9964ec8fd10b0b08fcc8623c2add25ddf99ac@chromium.org>

--- board/kirby/board.c
+++ board/kirby/board.c
@@ -61,7 +61,7 @@
 	{"EC_INT2",       GPIO_B, (1<<4),  GPIO_ODR_HIGH, NULL},
 	{"ID_MUX",        GPIO_B, (1<<11), GPIO_ODR_HIGH, NULL},
 	{"BCHGR_OTG",     GPIO_B, (1<<12), GPIO_OUT_LOW, NULL},
-	{"BCHGR_PSEL",    GPIO_B, (1<<14), GPIO_OUT_HIGH, NULL},
+	{"BCHGR_PSEL",    GPIO_B, (1<<14), GPIO_OUT_LOW, NULL},
 	{"EN_PP3300",     GPIO_C, (1<<11), GPIO_OUT_LOW, NULL},
 	{"ENTERING_RW",   GPIO_B, (1<<15), GPIO_OUT_LOW, NULL},
 	{"BST_LED_EN",    GPIO_C, (1<<10), GPIO_OUT_LOW, NULL},


samus: change USB type-A ports to default to CDP

Change USB type-A ports to default to CDP. The port will
automatically revert back to SDP if it needs to.

BUG=chrome-os-partner:36876
BRANCH=samus
TEST=load on samus, make sure ports advertise as CDP by
connecting A to C port to charge itself (note this causes
other problems, but good enough to make sure we detect
CDP).

Change-Id: Ic09b31788557d2c6ff4292c62a2ac0168b136c64
Signed-off-by: Alec Berg <1a4429eeda29095a12e19a73405f80f5b7f37a63@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/251834
Reviewed-by: Duncan Laurie <70662b43bc1a20b57ded72a2b08be88dd0da4841@chromium.org>

--- board/samus/board.h
+++ board/samus/board.h
@@ -69,6 +69,7 @@
 #define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_PP3300_DSW_GATED_EN
 #define CONFIG_UART_HOST 2
 #define CONFIG_USB_PORT_POWER_SMART
+#define CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE USB_CHARGE_MODE_CDP
 #define CONFIG_USB_PORT_POWER_SMART_INVERTED
 #define CONFIG_VBOOT_HASH
 #define CONFIG_WIRELESS


updated and more debug

updated and more debug

darcs-hash:20061007230943-1b897-d1cf3be76bc34ed8074502e2d9ff099dc796c7f4.gz

--- libsofia-sip-ua/su/torture_su_root_osx.c
+++ libsofia-sip-ua/su/torture_su_root_osx.c
@@ -55,8 +55,22 @@
 #include "sofia-sip/su.h"
 #include "sofia-sip/su_wait.h"
 #include "sofia-sip/su_log.h"
+#include "sofia-sip/su_debug.h"

 #include "sofia-sip/su_osx_runloop.h"
+
+#if HAVE_FUNC
+#define enter (void)SU_DEBUG_9(("torture_su_root_osx: %s: entering\n", __func__))
+#define nh_enter (void)SU_DEBUG_9(("torture_su_root_osx %s(%p): entering\n", __func__, nh))
+#elif HAVE_FUNCTION
+#define enter (void)SU_DEBUG_9(("torture_su_root_osx: %s: entering\n", __FUNCTION__))
+#define nh_enter (void)SU_DEBUG_9(("torture_su_root_osx %s(%p): entering\n", __FUNCTION__, nh))
+#define __func__ __FUNCTION__
+#else
+#define enter ((void)0)
+#define nh_enter ((void)0)
+#define __func__ "torture_su_root_osx"
+#endif

 struct pinger {
   enum { PINGER = 1, PONGER = 2 } const sort;
@@ -84,6 +98,8 @@
   su_sockaddr_t su = { 0 };
   socklen_t sulen = sizeof(su);
   char nbuf[64];
+
+  enter;

   su.su_family = opt_family;

@@ -117,6 +133,8 @@
 {
   static char buf[24];

+  enter;
+
   su_time_print(buf, sizeof(buf), &now);

   return buf;
@@ -126,6 +144,10 @@
 do_ping(struct pinger *p, su_timer_t *t, void *p0)
 {
   char buf[1024];
+
+  enter;
+
+  printf("%s: pinger p == %x\n", __func__, (unsigned int) p);

   assert(p == su_root_magic(su_timer_root(t)));
   assert(p->sort == PINGER);
@@ -156,6 +178,8 @@
   su_time_t now = su_now();
   double rtt;

+  enter;
+
   assert(p0 == p);
   assert(p->sort == PINGER);

@@ -186,6 +210,8 @@
 do_pong(struct pinger *p, su_timer_t *t, void *p0)
 {
   char buf[1024];
+
+  enter;

   assert(p == su_root_magic(su_timer_root(t)));
   assert(p->sort == PONGER);
@@ -214,6 +240,8 @@
   int n;
   su_time_t now = su_now();

+  enter;
+
   assert(p0 == p);
   assert(p->sort == PONGER);

@@ -253,6 +281,8 @@
 void
 do_exit(struct pinger *x, su_timer_t *t, void *x0)
 {
+  enter;
+
   if (opt_verbatim)
     printf("do_exit at %s\n", snow(su_now()));
   su_root_break(su_timer_root(t));
@@ -268,6 +298,8 @@
   su_wakeup_f f;
   int index, index0;

+  enter;
+
   switch (p->sort) {
   case PINGER: f = do_rtt;  interval = 200; break;
   case PONGER: f = do_recv; interval = 40;  break;
@@ -280,6 +312,8 @@
   if (su_wait_create(&w, s, SU_WAIT_IN) == SOCKET_ERROR)
     su_perror("su_wait_create"), exit(1);

+  /* CFSocketEnableCallbacks(s, map_poll_revent_to_cf_event(su_wait_events(&w, s))); */
+
   p->s = s;
   p->t = t = su_timer_create(su_root_task(root), interval);
   if (t == NULL) {
@@ -309,16 +343,22 @@
 void
 do_destroy(su_root_t *root, struct pinger *p)
 {
+  enter;
+
   if (opt_verbatim)
     printf("do_destroy %s at %s\n", p->name, snow(su_now()));
+
   su_root_deregister(root, p->rindex);
   su_timer_destroy(p->t), p->t = NULL;
+
   p->running = 0;
 }

 void
 start_ping(struct pinger *p, su_msg_r msg, su_sockaddr_t *arg)
 {
+  enter;
+
   if (!p->running)
     return;

@@ -334,6 +374,8 @@
 start_pong(struct pinger *p, su_msg_r msg, su_sockaddr_t *arg)
 {
   su_msg_r reply;
+
+  enter;

   if (!p->running)
     return;
@@ -360,6 +402,8 @@
 {
   su_msg_r reply;

+  enter;
+
   if (opt_verbatim)
     printf("init_ping: %s\n", p->name);

@@ -378,6 +422,8 @@
 static
 RETSIGTYPE term(int n)
 {
+  enter;
+
   exit(1);
 }

@@ -387,6 +433,8 @@
   su_time_t now = su_now(), then = now;
   su_duration_t t1, t2;
   su_duration_t us;
+
+  enter;

   for (us = 0; us < 1000000; us += 300) {
     then.tv_sec = now.tv_sec;
@@ -434,6 +482,8 @@
     ponger = { PONGER, "pong", 1 };

   char *argv0 = argv[0];
+
+  enter;

   while (argv[1]) {
     if (strcmp(argv[1], "-v") == 0) {
@@ -469,11 +519,6 @@

   if (!root) perror("su_root_osx_runloop_create"), exit(1);

-#if 0
-  if (!g_source_attach(su_root_gsource(root), NULL))
-    perror("g_source_attach"), exit(1);
-  #endif
-
   su_root_threading(root, 0 && !opt_singlethread);

   if (su_clone_start(root, ping, &pinger, do_init, do_destroy) != 0)
@@ -491,7 +536,13 @@
 		init_ping, 0);
   su_msg_send(start_msg);

+#if 1
+  while (1) {
+    su_root_step(root, 20);
+  }
+#else
   su_root_run(root);
+#endif

   su_clone_wait(root, ping);
   su_clone_wait(root, pong);


Check arguments to public GVirConfigObject methods

GVirConfigObject public methods don't have g_return_if_fail checks
on their arguments. It happens that GNOME Boxes tries to call
gvir_config_object_to_xml with a NULL GVirConfigObject causing a
crash https://bugzilla.gnome.org/show_bug.cgi?id=676308
While GNOME Boxes needs to be fixed not to pass an invalid value
to gvir_config_object_to_xml, it's better if libvirt-gconfig sanity
checks the argument it is passed by the caller before using them.

--- libvirt-gconfig/libvirt-gconfig-object.c
+++ libvirt-gconfig/libvirt-gconfig-object.c
@@ -191,10 +191,15 @@
 void gvir_config_object_validate(GVirConfigObject *config,
                                  GError **err)
 {
-    GVirConfigObjectPrivate *priv = config->priv;
+    GVirConfigObjectPrivate *priv;
     xmlRelaxNGParserCtxtPtr rngParser = NULL;
     xmlRelaxNGPtr rng = NULL;
     xmlRelaxNGValidCtxtPtr rngValid = NULL;
+
+    g_return_if_fail(GVIR_CONFIG_IS_OBJECT(config));
+    g_return_if_fail(err == NULL || *err == NULL);
+
+    priv = config->priv;

     xmlSetGenericErrorFunc(NULL, gvir_xml_generic_error_nop);
     xmlSetStructuredErrorFunc(NULL, gvir_xml_structured_error_nop);
@@ -256,13 +261,16 @@

 gchar *gvir_config_object_to_xml(GVirConfigObject *config)
 {
+    g_return_val_if_fail(GVIR_CONFIG_IS_OBJECT(config), NULL);
+
     return gvir_config_xml_node_to_string(config->priv->node);
 }

 const gchar *gvir_config_object_get_schema(GVirConfigObject *config)
 {
-    GVirConfigObjectPrivate *priv = config->priv;
-    return priv->schema;
+    g_return_val_if_fail(GVIR_CONFIG_IS_OBJECT(config), NULL);
+
+    return config->priv->schema;
 }

 /* FIXME: will we always have one xmlNode per GConfig object? */


Fix typo in parameter annotation

Fix typo in parameter annotation

--- libvirt-sandbox/libvirt-sandbox-config.c
+++ libvirt-sandbox/libvirt-sandbox-config.c
@@ -690,7 +690,7 @@
 /**
  * gvir_sandbox_config_set_mounts:
  * @config: (transfer none): the sandbox config
- * @mounts: (transfer none)(array zero-terminate=1): the list of mounts
+ * @mounts: (transfer none)(array zero-terminated=1): the list of mounts
  *
  * Parses @mounts whose elements are in the format
  * GUEST-TARGET=ROOT-PATH, creating #GVirSandboxConfigMount


expander: pass offsets instead of gpio numbers

Reduce repetition by passing offsets rather than absolute GPIO numbers
to the gpio_initial_status and gpio_final_status functions.

--- linux_kernel_modules/expander/expander.c
+++ linux_kernel_modules/expander/expander.c
@@ -66,9 +66,11 @@

 static void gpio_initial_status(struct platform_device *pdev,
 				struct device_attribute *attr,
-				int gpio_num, int gpio_output_level,
+				int expander_gpio_offset, int gpio_output_level,
 				atomic_t *atomic_val)
 {
+	struct expander_device *exp = dev_get_drvdata(&pdev->dev);
+	const int gpio_num = exp->gpio_expander_base + expander_gpio_offset;
 	devm_gpio_request_one(
 		&pdev->dev, gpio_num,
 		(GPIOF_DIR_OUT |
@@ -80,8 +82,10 @@

 static void gpio_final_status(struct platform_device *pdev,
 			      struct device_attribute *attr,
-			      int gpio_num, int gpio_output_level)
+			      int expander_gpio_offset, int gpio_output_level)
 {
+	struct expander_device *exp = dev_get_drvdata(&pdev->dev);
+	const int gpio_num = exp->gpio_expander_base + expander_gpio_offset;
 	device_remove_file(&pdev->dev, attr);
 	gpio_set_value_cansleep(gpio_num, gpio_output_level);
 }
@@ -108,29 +112,22 @@

 	dev->pdev = pdev;
  	dev->gpio_expander_base = pdata->gpio_expander_base;
-	gpio_initial_status(pdev, &dev_attr_generic_led,
-			    dev->gpio_expander_base + GENERIC_LED, 0,
+	platform_set_drvdata(pdev, dev);
+
+	gpio_initial_status(pdev, &dev_attr_generic_led, GENERIC_LED, 0,
 			    &dev->generic_led_val);
-	gpio_initial_status(pdev, &dev_attr_pcm_sel,
-			    dev->gpio_expander_base + PCM_SEL, 0,
+	gpio_initial_status(pdev, &dev_attr_pcm_sel, PCM_SEL, 0,
 			    &dev->pcm_sel_val);
-	gpio_initial_status(pdev, &dev_attr_sdio_sel,
-			    dev->gpio_expander_base + SDIO_SEL, 0,
+	gpio_initial_status(pdev, &dev_attr_sdio_sel, SDIO_SEL, 0,
 			    &dev->sdio_sel_val);
-	gpio_initial_status(pdev, &dev_attr_tri_led_blu,
-			    dev->gpio_expander_base + TRI_LED_BLU, 0,
+	gpio_initial_status(pdev, &dev_attr_tri_led_blu, TRI_LED_BLU, 0,
 			    &dev->tri_led_blu_val);
-	gpio_initial_status(pdev, &dev_attr_tri_led_red,
-			    dev->gpio_expander_base + TRI_LED_RED, 0,
+	gpio_initial_status(pdev, &dev_attr_tri_led_red, TRI_LED_RED, 0,
 			    &dev->tri_led_red_val);
-	gpio_initial_status(pdev, &dev_attr_tri_led_grn,
-			    dev->gpio_expander_base + TRI_LED_GRN, 0,
+	gpio_initial_status(pdev, &dev_attr_tri_led_grn, TRI_LED_GRN, 0,
 			    &dev->tri_led_grn_val);
-	gpio_initial_status(pdev, &dev_attr_buzzer,
-			    dev->gpio_expander_base + BUZZER, 0,
+	gpio_initial_status(pdev, &dev_attr_buzzer, BUZZER, 0,
 			    &dev->buzzer_val);
-
-	platform_set_drvdata(pdev, dev);

 done:
 	return ret;
@@ -138,23 +135,14 @@

 static int expander_remove(struct platform_device *pdev)
 {
-	struct expander_device* dev = dev_get_drvdata(&pdev->dev);
-
 	/* remove sysfs files & set final state values for gpio expander */
-	gpio_final_status(pdev, &dev_attr_generic_led,
-			  dev->gpio_expander_base + GENERIC_LED, 0);
-	gpio_final_status(pdev, &dev_attr_pcm_sel,
-			  dev->gpio_expander_base + PCM_SEL, 0);
-	gpio_final_status(pdev, &dev_attr_sdio_sel,
-			  dev->gpio_expander_base + SDIO_SEL, 0);
-	gpio_final_status(pdev, &dev_attr_tri_led_blu,
-			  dev->gpio_expander_base + TRI_LED_BLU, 0);
-	gpio_final_status(pdev, &dev_attr_tri_led_red,
-			  dev->gpio_expander_base + TRI_LED_RED, 0);
-	gpio_final_status(pdev, &dev_attr_tri_led_grn,
-			  dev->gpio_expander_base + TRI_LED_GRN, 0);
-	gpio_final_status(pdev, &dev_attr_buzzer,
-			  dev->gpio_expander_base + BUZZER, 0);
+	gpio_final_status(pdev, &dev_attr_generic_led, GENERIC_LED, 0);
+	gpio_final_status(pdev, &dev_attr_pcm_sel, PCM_SEL, 0);
+	gpio_final_status(pdev, &dev_attr_sdio_sel, SDIO_SEL, 0);
+	gpio_final_status(pdev, &dev_attr_tri_led_blu, TRI_LED_BLU, 0);
+	gpio_final_status(pdev, &dev_attr_tri_led_red, TRI_LED_RED, 0);
+	gpio_final_status(pdev, &dev_attr_tri_led_grn, TRI_LED_GRN, 0);
+	gpio_final_status(pdev, &dev_attr_buzzer, BUZZER, 0);

 	return 0;
 }


Cleanup formatting of expander driver

Cleanup formatting of expander driver

--- linux_kernel_modules/expander/expander.c
+++ linux_kernel_modules/expander/expander.c
@@ -29,31 +29,30 @@

 #define CREATE_SYSFS_DEFN(_var, _offset)                                       \
-static ssize_t _var##_show(struct device *dev,               \
-				   struct device_attribute *attr,    \
-				   char *buf)                        \
+static ssize_t _var##_show(struct device *dev,  struct device_attribute *attr, \
+			   char *buf)                                          \
 {                                                                              \
-	struct expander_device* exp = dev_get_drvdata(dev);             \
-	return sprintf(buf, "%d\n", atomic_read(&exp->_var##_val));           \
-}\
-static int _var##_store(struct device *dev,                  \
-					  struct device_attribute *attr,       \
-					  const char *buf, size_t count)       \
+	struct expander_device* exp = dev_get_drvdata(dev);                    \
+	return sprintf(buf, "%d\n", atomic_read(&exp->_var##_val));            \
+}                                                                              \
+static int _var##_store(struct device *dev, struct device_attribute *attr,     \
+			const char *buf, size_t count)                         \
 {                                                                              \
-	struct expander_device* exp = dev_get_drvdata(dev);             \
+	struct expander_device* exp = dev_get_drvdata(dev);                    \
 	u8 val;                                                                \
-	int ret;							       \
-									       \
-	ret = kstrtou8(buf, 10, &val);					       \
-	if (ret || val > 1)						       \
-		return -EINVAL;						       \
-									       \
+	int ret;                                                               \
+                                                                               \
+	ret = kstrtou8(buf, 10, &val);                                         \
+	if (ret || val > 1)                                                    \
+		return -EINVAL;                                                \
+                                                                               \
 	gpio_set_value_cansleep(exp->gpio_expander_base + _offset, val);       \
-	atomic_set(&exp->_var##_val, val);				       \
-	dev_info(dev, "Setting GPIO %d to %d\n", exp->gpio_expander_base + _offset, val); \
-									       \
-	return count;							       \
-}									       \
+	atomic_set(&exp->_var##_val, val);                                     \
+	dev_info(dev, "Setting GPIO %d to %d\n",                               \
+		 exp->gpio_expander_base + _offset, val);                      \
+                                                                               \
+	return count;                                                          \
+}                                                                              \
 static DEVICE_ATTR_RW(_var)

 CREATE_SYSFS_DEFN(generic_led, GENERIC_LED);
@@ -65,63 +64,32 @@
 CREATE_SYSFS_DEFN(buzzer, BUZZER);

-static void  gpio_initial_status(struct platform_device *pdev,
-				 struct device_attribute *attr,
-			         int function_number,int function_val,
-			         atomic_t *atomic_val)
+static void gpio_initial_status(struct platform_device *pdev,
+				struct device_attribute *attr,
+				int function_number, int function_val,
+				atomic_t *atomic_val)
 {
-
-
-	//struct expander_device* exp = dev_get_drvdata(&pdev->dev);
-
-	dev_info(&pdev->dev, "%s(): initial_status\n", __func__);
-
-
-	devm_gpio_request(&pdev->dev, function_number,
-				dev_name(&pdev->dev));
-
-	dev_info(&pdev->dev, "%s(): initial_status_line2\n", __func__);
-      		atomic_set(atomic_val, function_val);
-        dev_info(&pdev->dev, "%s(): initial_status_line3\n", __func__);
-
-	 gpio_direction_output(function_number,
-				    function_val);
-	dev_info(&pdev->dev, "%s(): initial_status_line4\n", __func__);
-
+	devm_gpio_request(&pdev->dev, function_number, dev_name(&pdev->dev));
+	atomic_set(atomic_val, function_val);
+	gpio_direction_output(function_number, function_val);
 	device_create_file(&pdev->dev, attr);
-	dev_info(&pdev->dev, "%s(): initial_status_line5\n", __func__);
-
-
 }

-static void  gpio_final_status(struct platform_device *pdev,
-                               struct device_attribute *attr,
-			       int function_number,int function_val)
+static void gpio_final_status(struct platform_device *pdev,
+			      struct device_attribute *attr,
+			      int function_number, int function_val)
 {
-
-
-		dev_info(&pdev->dev, "%s(): final_status\n", __func__);
-
-
 	device_remove_file(&pdev->dev, attr);
-	dev_info(&pdev->dev, "%s(): final_status_line2\n", __func__);
-
 	gpio_set_value_cansleep(function_number, function_val);
-	dev_info(&pdev->dev, "%s(): final_status_line3\n", __func__);
-
-
 }
-
-

 static int expander_probe(struct platform_device *pdev)
 {
 	struct expander_device* dev;
 	int ret = 0;
-        //int *pass = NULL;
 	struct expander_platform_data *pdata = dev_get_platdata(&pdev->dev);

-	dev_info(&pdev->dev, "%s(): probe\n", __func__);
+	dev_dbg(&pdev->dev, "%s(): probe\n", __func__);

 	if (!pdata) {
 		ret = -EINVAL;
@@ -129,8 +97,6 @@
 		goto  done;
 	}

-	/* Create the driver data and remove the allocated memory when driver
-	   is removed */
 	dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
 	if (!dev) {
 		ret = -ENOMEM;
@@ -139,14 +105,28 @@

 	dev->pdev = pdev;
  	dev->gpio_expander_base = pdata->gpio_expander_base;
-        gpio_initial_status(pdev,&dev_attr_generic_led, dev->gpio_expander_base+GENERIC_LED, 0, &dev->generic_led_val);
-        gpio_initial_status(pdev,&dev_attr_pcm_sel, dev->gpio_expander_base+PCM_SEL, 0, &dev->pcm_sel_val);
-        gpio_initial_status( pdev,&dev_attr_sdio_sel,   dev->gpio_expander_base+SDIO_SEL, 0, &dev->sdio_sel_val);
-        gpio_initial_status(pdev,&dev_attr_tri_led_blu, dev->gpio_expander_base+TRI_LED_BLU, 0, &dev->tri_led_blu_val);
-        gpio_initial_status(pdev,&dev_attr_tri_led_red,  dev->gpio_expander_base+TRI_LED_RED, 0, &dev->tri_led_red_val);
- 	gpio_initial_status(pdev,&dev_attr_tri_led_grn, dev->gpio_expander_base+TRI_LED_GRN, 0, &dev->tri_led_grn_val);
-	gpio_initial_status(pdev,&dev_attr_buzzer, dev->gpio_expander_base+BUZZER, 0, &dev->buzzer_val);
-
+	gpio_initial_status(pdev, &dev_attr_generic_led,
+			    dev->gpio_expander_base + GENERIC_LED, 0,
+			    &dev->generic_led_val);
+	gpio_initial_status(pdev, &dev_attr_pcm_sel,
+			    dev->gpio_expander_base + PCM_SEL, 0,
+			    &dev->pcm_sel_val);
+	gpio_initial_status(pdev, &dev_attr_sdio_sel,
+			    dev->gpio_expander_base + SDIO_SEL, 0,
+			    &dev->sdio_sel_val);
+	gpio_initial_status(pdev, &dev_attr_tri_led_blu,
+			    dev->gpio_expander_base + TRI_LED_BLU, 0,
+			    &dev->tri_led_blu_val);
+	gpio_initial_status(pdev, &dev_attr_tri_led_red,
+			    dev->gpio_expander_base + TRI_LED_RED, 0,
+			    &dev->tri_led_red_val);
+	gpio_initial_status(pdev, &dev_attr_tri_led_grn,
+			    dev->gpio_expander_base + TRI_LED_GRN, 0,
+			    &dev->tri_led_grn_val);
+	gpio_initial_status(pdev, &dev_attr_buzzer,
+			    dev->gpio_expander_base + BUZZER, 0,
+			    &dev->buzzer_val);
+
 	platform_set_drvdata(pdev, dev);

 done:
@@ -155,17 +135,23 @@

 static int expander_remove(struct platform_device *pdev)
 {
-
-        struct expander_device* dev = dev_get_drvdata(&pdev->dev);
+	struct expander_device* dev = dev_get_drvdata(&pdev->dev);

-	/* remove sysfs files & set final state values for gpio expander*/
-	gpio_final_status(pdev,&dev_attr_generic_led,  dev->gpio_expander_base+GENERIC_LED, 0);
-        gpio_final_status(pdev,&dev_attr_pcm_sel, dev->gpio_expander_base+PCM_SEL, 0);
-	gpio_final_status(pdev,&dev_attr_sdio_sel, dev->gpio_expander_base+SDIO_SEL, 0);
-	gpio_final_status(pdev,&dev_attr_tri_led_blu,  dev->gpio_expander_base+TRI_LED_BLU, 0);
-	gpio_final_status(pdev,&dev_attr_tri_led_red,  dev->gpio_expander_base+TRI_LED_RED, 0);
-	gpio_final_status(pdev,&dev_attr_tri_led_grn,   dev->gpio_expander_base+TRI_LED_GRN, 0);
-	gpio_final_status(pdev,&dev_attr_buzzer,   dev->gpio_expander_base+BUZZER, 0);
+	/* remove sysfs files & set final state values for gpio expander */
+	gpio_final_status(pdev, &dev_attr_generic_led,
+			  dev->gpio_expander_base + GENERIC_LED, 0);
+	gpio_final_status(pdev, &dev_attr_pcm_sel,
+			  dev->gpio_expander_base + PCM_SEL, 0);
+	gpio_final_status(pdev, &dev_attr_sdio_sel,
+			  dev->gpio_expander_base + SDIO_SEL, 0);
+	gpio_final_status(pdev, &dev_attr_tri_led_blu,
+			  dev->gpio_expander_base + TRI_LED_BLU, 0);
+	gpio_final_status(pdev, &dev_attr_tri_led_red,
+			  dev->gpio_expander_base + TRI_LED_RED, 0);
+	gpio_final_status(pdev, &dev_attr_tri_led_grn,
+			  dev->gpio_expander_base + TRI_LED_GRN, 0);
+	gpio_final_status(pdev, &dev_attr_buzzer,
+			  dev->gpio_expander_base + BUZZER, 0);

 	return 0;
 }


Fix debug output when failing to get config file name

Don't print the config file name when it is null.

--- panel-plugin/stopwatch.c
+++ panel-plugin/stopwatch.c
@@ -39,7 +39,7 @@
 	filename = xfce_panel_plugin_save_location (plugin, TRUE);

 	if (G_UNLIKELY (filename == NULL)) {
-		DBG ("Failed to open config file %s", filename);
+		DBG ("Failed to get config file location");
 		return;
 	}

@@ -69,7 +69,7 @@
 	filename = xfce_panel_plugin_save_location (stopwatch->plugin, TRUE);

 	if (G_UNLIKELY (filename == NULL)) {
-		DBG ("Failed to open config file %s", filename);
+		DBG ("Failed to get config file location");
 		return;
 	}


add vector

add vector

error: pathspec 'test/bsp/lpc4357/vector.c' did not match any file(s) known to git

--- test/bsp/lpc4357/vector.c
+++ test/bsp/lpc4357/vector.c
@@ -0,0 +1,11 @@
+/*
+ * Copyright (c) 2016, TAKUYA Ohashi. All rights reserved.
+ */
+
+typedef void (*HandlerEntry)(void);
+
+extern void _Reset_Handler(void);
+
+const HandlerEntry handler_table[] __attribute__ ((section (".vector"))) = {
+	_Reset_Handler,
+};


Avoid a compilation warning (unused variable)

--- src/plugins/subversion.c
+++ src/plugins/subversion.c
@@ -106,7 +106,6 @@
 	SVN * svn;
 	PangoFontDescription * font;
 	GtkSizeGroup * group;
-	GtkSizeGroup * bgroup;
 	GtkWidget * widget;

 	if((svn = object_new(sizeof(*svn))) == NULL)
@@ -123,7 +122,6 @@
 	font = pango_font_description_new();
 	pango_font_description_set_weight(font, PANGO_WEIGHT_BOLD);
 	group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
-	bgroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
 	/* label */
 	svn->name = gtk_label_new("");
 	gtk_label_set_ellipsize(GTK_LABEL(svn->name), PANGO_ELLIPSIZE_MIDDLE);
@@ -140,20 +138,20 @@
 #else
 	svn->directory = gtk_vbox_new(FALSE, 4);
 #endif
-	widget = _init_button(bgroup, GTK_STOCK_FIND_AND_REPLACE,
+	widget = _init_button(group, GTK_STOCK_FIND_AND_REPLACE,
 			_("Request diff"), G_CALLBACK(_subversion_on_diff),
 			svn);
 	gtk_box_pack_start(GTK_BOX(svn->directory), widget, FALSE, TRUE, 0);
-	widget = _init_button(bgroup, GTK_STOCK_FIND, _("View log"),
+	widget = _init_button(group, GTK_STOCK_FIND, _("View log"),
 			G_CALLBACK(_subversion_on_log), svn);
 	gtk_box_pack_start(GTK_BOX(svn->directory), widget, FALSE, TRUE, 0);
-	widget = _init_button(bgroup, GTK_STOCK_PROPERTIES, _("Status"),
+	widget = _init_button(group, GTK_STOCK_PROPERTIES, _("Status"),
 			G_CALLBACK(_subversion_on_status), svn);
 	gtk_box_pack_start(GTK_BOX(svn->directory), widget, FALSE, TRUE, 0);
-	widget = _init_button(bgroup, GTK_STOCK_REFRESH, _("Update"),
+	widget = _init_button(group, GTK_STOCK_REFRESH, _("Update"),
 			G_CALLBACK(_subversion_on_update), svn);
 	gtk_box_pack_start(GTK_BOX(svn->directory), widget, FALSE, TRUE, 0);
-	widget = _init_button(bgroup, GTK_STOCK_JUMP_TO, _("Commit"),
+	widget = _init_button(group, GTK_STOCK_JUMP_TO, _("Commit"),
 			G_CALLBACK(_subversion_on_commit), svn);
 	gtk_box_pack_start(GTK_BOX(svn->directory), widget, FALSE, TRUE, 0);
 	gtk_widget_show_all(svn->directory);
@@ -166,30 +164,30 @@
 #else
 	svn->file = gtk_vbox_new(FALSE, 4);
 #endif
-	widget = _init_button(bgroup, GTK_STOCK_FIND_AND_REPLACE,
+	widget = _init_button(group, GTK_STOCK_FIND_AND_REPLACE,
 			_("Request diff"), G_CALLBACK(_subversion_on_diff),
 			svn);
 	gtk_box_pack_start(GTK_BOX(svn->file), widget, FALSE, TRUE, 0);
-	widget = _init_button(bgroup, GTK_STOCK_INDEX, _("Annotate"),
+	widget = _init_button(group, GTK_STOCK_INDEX, _("Annotate"),
 			G_CALLBACK(_subversion_on_blame), svn);
 	gtk_box_pack_start(GTK_BOX(svn->file), widget, FALSE, TRUE, 0);
-	widget = _init_button(bgroup, GTK_STOCK_FIND, _("View log"),
+	widget = _init_button(group, GTK_STOCK_FIND, _("View log"),
 			G_CALLBACK(_subversion_on_log), svn);
 	gtk_box_pack_start(GTK_BOX(svn->file), widget, FALSE, TRUE, 0);
-	widget = _init_button(bgroup, GTK_STOCK_PROPERTIES, _("Status"),
+	widget = _init_button(group, GTK_STOCK_PROPERTIES, _("Status"),
 			G_CALLBACK(_subversion_on_status), svn);
 	gtk_box_pack_start(GTK_BOX(svn->file), widget, FALSE, TRUE, 0);
-	widget = _init_button(bgroup, GTK_STOCK_REFRESH, _("Update"),
+	widget = _init_button(group, GTK_STOCK_REFRESH, _("Update"),
 			G_CALLBACK(_subversion_on_update), svn);
 	gtk_box_pack_start(GTK_BOX(svn->file), widget, FALSE, TRUE, 0);
-	widget = _init_button(bgroup, GTK_STOCK_JUMP_TO, _("Commit"),
+	widget = _init_button(group, GTK_STOCK_JUMP_TO, _("Commit"),
 			G_CALLBACK(_subversion_on_commit), svn);
 	gtk_box_pack_start(GTK_BOX(svn->file), widget, FALSE, TRUE, 0);
 	gtk_widget_show_all(svn->file);
 	gtk_widget_set_no_show_all(svn->file, TRUE);
 	gtk_box_pack_start(GTK_BOX(svn->widget), svn->file, FALSE, TRUE, 0);
 	/* additional actions */
-	svn->add = _init_button(bgroup, GTK_STOCK_ADD, _("Add to repository"),
+	svn->add = _init_button(group, GTK_STOCK_ADD, _("Add to repository"),
 			G_CALLBACK(_subversion_on_add), svn);
 	gtk_box_pack_start(GTK_BOX(svn->widget), svn->add, FALSE, TRUE, 0);
 	gtk_widget_show_all(svn->widget);


break long lines

break long lines

--- phSolver/common/phIO.h
+++ phSolver/common/phIO.h
@@ -3,15 +3,24 @@

 #include <FCMangle.h>

-#define phio_readheader FortranCInterface_GLOBAL_(phio_readheader, PHIO_READHEADER)
-#define phio_writeheader FortranCInterface_GLOBAL_(phio_writeheader, PHIO_WRITEHEADER)
-#define phio_readdatablock FortranCInterface_GLOBAL_(phio_readdatablock, PHIO_READDATABLOCK)
-#define phio_writedatablock FortranCInterface_GLOBAL_(phio_writedatablock, PHIO_WRITEDATABLOCK)
-#define phio_openfile_read FortranCInterface_GLOBAL_(phio_openfile_read, PHIO_OPENFILE_READ)
-#define phio_openfile_write FortranCInterface_GLOBAL_(phio_openfile_write, PHIO_OPENFILE_WRITE)
-#define phio_restartname FortranCInterface_GLOBAL_(phio_restartname, PHIO_RESTARTNAME)
-#define phio_closefile_read FortranCInterface_GLOBAL_(phio_closefile_read, PHIO_CLOSEFILE_READ)
-#define phio_closefile_write FortranCInterface_GLOBAL_(phio_closefile_write, PHIO_CLOSEFILE_WRITE)
+#define phio_readheader \
+  FortranCInterface_GLOBAL_(phio_readheader, PHIO_READHEADER)
+#define phio_writeheader \
+  FortranCInterface_GLOBAL_(phio_writeheader, PHIO_WRITEHEADER)
+#define phio_readdatablock \
+  FortranCInterface_GLOBAL_(phio_readdatablock, PHIO_READDATABLOCK)
+#define phio_writedatablock \
+  FortranCInterface_GLOBAL_(phio_writedatablock, PHIO_WRITEDATABLOCK)
+#define phio_openfile_read \
+  FortranCInterface_GLOBAL_(phio_openfile_read, PHIO_OPENFILE_READ)
+#define phio_openfile_write \
+  FortranCInterface_GLOBAL_(phio_openfile_write, PHIO_OPENFILE_WRITE)
+#define phio_restartname \
+  FortranCInterface_GLOBAL_(phio_restartname, PHIO_RESTARTNAME)
+#define phio_closefile_read \
+  FortranCInterface_GLOBAL_(phio_closefile_read, PHIO_CLOSEFILE_READ)
+#define phio_closefile_write \
+  FortranCInterface_GLOBAL_(phio_closefile_write, PHIO_CLOSEFILE_WRITE)

 #ifdef __cplusplus
 extern "C" {


ipv4 classful addressing pretty-printing

--- framespect.bin.c
+++ framespect.bin.c
@@ -31,6 +31,9 @@
 // fragmentation's flags & offset fields.
 #define IPFRAME_FRAG_OFFSET_MASK 0x1f

+// Max of 3 digits per 4 octets, plus 3 separating dots for said octets.
+#define MAX_DOTTED_DEC_STR_SIZE 15
+
 struct frame {
   // Source hex values from which below fields are parsed.
   unsigned char src[MAX_HEX_STREAM_LEN];
@@ -235,6 +238,18 @@
     *dst |= (0xff & src[i]) << ((end - i)*8);
   }
   return 0;
+}
+
+// Returns 'a', 'b', 'c', or '0' indicating no other classes are checked for.
+unsigned char getIPAddrClass(const unsigned char topOctet) {
+  if (topOctet < 128) {
+    return 'a';
+  } else if (topOctet >= 128 && topOctet < 192) {
+    return 'b';
+  } else if (topOctet >= 192 && topOctet < 224) {
+    return 'c';
+  }
+  return '0';
 }

 // isSource 1 or 0; 1 indicates source IP should be pretty-printed, else
@@ -250,6 +265,25 @@
   printf("%s IP address: %d.%d.%d.%d [%02X %02X %02X %02X]\n", label,
       addr[0], addr[1], addr[2], addr[3],
       addr[0], addr[1], addr[2], addr[3]);
+
+  const unsigned char klass = getIPAddrClass(addr[0]);
+  unsigned char netid[MAX_DOTTED_DEC_STR_SIZE], hostid[MAX_DOTTED_DEC_STR_SIZE];
+  switch (klass) {
+    case 'a':
+      snprintf(netid, MAX_DOTTED_DEC_STR_SIZE, "%d", addr[0]);
+      snprintf(hostid, MAX_DOTTED_DEC_STR_SIZE, "%d.%d.%d", addr[1], addr[2], addr[3]);
+      break;
+    case 'b':
+      snprintf(netid, MAX_DOTTED_DEC_STR_SIZE, "%d.%d", addr[0], addr[1]);
+      snprintf(hostid, MAX_DOTTED_DEC_STR_SIZE, "%d.%d", addr[2], addr[3]);
+      break;
+    case 'c':
+      snprintf(netid, MAX_DOTTED_DEC_STR_SIZE, "%d", addr[0]);
+      snprintf(hostid, MAX_DOTTED_DEC_STR_SIZE, "%d.%d.%d", addr[1], addr[2], addr[3]);
+      break;
+  }
+
+  printf("\tclass %c -> netid: %s, hostid: %s\n", klass, netid, hostid);
 }

 /** Pretty prints the contents of frm. Return less than 0 indicates failure. */


Release rsb's semaphore before queue_ast() since queue_ast() can free the rsb at any time. Patch from Daniel McNeil <daniel@osdl.org>

--- dlm-kernel/src/locking.c
+++ dlm-kernel/src/locking.c
@@ -717,8 +717,13 @@
 		lkb->lkb_retstatus = -EAGAIN;
 		if (lkb->lkb_lockqueue_flags & DLM_LKF_NOQUEUEBAST)
 			send_blocking_asts_all(rsb, lkb);
+		/*
+		 * up the res_lock before queueing ast, since the AST_DEL will
+		 * cause the rsb to be released and that can happen anytime.
+		 */
+		up_write(&rsb->res_lock);
 		queue_ast(lkb, AST_COMP | AST_DEL, 0);
-		goto out;
+		return;
 	}

 	/*
@@ -918,7 +923,13 @@
 	lkb->lkb_retstatus = flags & DLM_LKF_CANCEL ? -DLM_ECANCEL:-DLM_EUNLOCK;

 	if (!remote) {
+		/*
+		 * up the res_lock before queueing ast, since the AST_DEL will
+		 * cause the rsb to be released and that can happen anytime.
+		 */
+		up_write(&rsb->res_lock);
 		queue_ast(lkb, AST_COMP | AST_DEL, 0);
+		goto out2;
 	} else {
 		up_write(&rsb->res_lock);
 		release_lkb(rsb->res_ls, lkb);


probes: cast correctly

probes: cast correctly

--- dmce-probe-user-atexit.c
+++ dmce-probe-user-atexit.c
@@ -42,8 +42,8 @@
 static void dmce_probe_body(unsigned int probenbr) {

     if (!registered_at_exit) {
-        dmce_buffer = calloc(DMCE_NUM_PROBES, sizeof(uint32_t));
-        dmce_tmp_buffer = calloc(DMCE_NUM_PROBES, sizeof(uint32_t));
+        dmce_buffer = (uint32_t*)calloc(DMCE_NUM_PROBES, sizeof(uint32_t));
+        dmce_tmp_buffer = (uint32_t*)calloc(DMCE_NUM_PROBES, sizeof(uint32_t));
         atexit(dmce_atexit);
         registered_at_exit = 1;
     }


aix threads

aix threads

--- src/process/sysdep_AIX.c
+++ src/process/sysdep_AIX.c
@@ -197,6 +197,7 @@
                 pt[i].pid         = procs[i].pi_pid;
                 pt[i].ppid        = procs[i].pi_ppid;
                 pt[i].euid        = procs[i].pi_uid;
+                pt[i].threads     = procs[i].pi_thcount;
                 pt[i].starttime   = procs[i].pi_start;
                 pt[i].mem         = (procs[i].pi_drss + procs[i].pi_trss) * page_size;
                 pt[i].cputime     = (procs[i].pi_ru.ru_utime.tv_sec + procs[i].pi_ru.ru_utime.tv_usec * 1.0e-6 + procs[i].pi_ru.ru_stime.tv_sec + procs[i].pi_ru.ru_stime.tv_usec * 1.0e-6) * 10;


Set __MSVCRT_VERSION__ to make _ftime64 visible from time.h header when we need to workaround mingw bug.

--- numpy/random/mtrand/randomkit.c
+++ numpy/random/mtrand/randomkit.c
@@ -75,8 +75,10 @@

 #ifdef _WIN32
 /* Windows */
-#include <time.h>
 #ifdef NPY_NEEDS_MINGW_TIME_WORKAROUND
+/* FIXME: ideally, we should set this to the real version of MSVCRT. We need
+ * something higher than 0x601 to enable _ftime64 and co */
+#define __MSVCRT_VERSION__ 0x0700
 /* mingw msvcr lib import wrongly export _ftime, which does not exist in the
  * actual msvc runtime for version >= 8; we make it an alist to _ftime64, which
  * is available in those versions of the runtime and should be ABI compatible
@@ -85,6 +87,7 @@
 #else
 #define _FTIME(x) _ftime((x))
 #endif
+#include <time.h>
 #include <sys/timeb.h>
 #ifndef RK_NO_WINCRYPT
 /* Windows crypto */


Modify TVector3::Perp2 such that the function returns always a
quantity >= 0. This prevents a sqrt(negative value) in TVector3::Perp.

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


Fix  innodb_bug60229 (get the innodb change into xtradb)

--- storage/xtradb/dict/dict0dict.c
+++ storage/xtradb/dict/dict0dict.c
@@ -3140,10 +3140,15 @@
 		memcpy(ref, database_name, database_name_len);
 		ref[database_name_len] = '/';
 		memcpy(ref + database_name_len + 1, table_name, table_name_len + 1);
+
 	} else {
+#ifndef __WIN__
 		if (innobase_get_lower_case_table_names() == 1) {
 			innobase_casedn_str(ref);
 		}
+#else
+		innobase_casedn_str(ref);
+#endif /* !__WIN__ */
 		*table = dict_table_get_low(ref);
 	}


Update cvars before checking them

Update cvars before checking them

--- oa_mod/code/game/g_main.c
+++ oa_mod/code/game/g_main.c
@@ -933,6 +933,8 @@
     trap_Cvar_Set( "g_rageQuit", "0" );
     trap_Cvar_Set( "g_betsMade", "0" );

+    G_UpdateCvars();
+
     if ( g_gameStage.integer == FORMING_TEAMS ) {
         // at this stage, no bids should be active
         // but if the map was callvot'ed, it is still possible,


Adding a HWG_VERSION

Adding a HWG_VERSION

--- GrowlVersion.h
+++ GrowlVersion.h
@@ -1,8 +1,8 @@
 #define COMMENT_1 DO NOT EDIT THE VERSION IN THIS FILE! Change the version in Release/Makefile instead, then run make version while in the Release directory.
 #define COMMENT_2 In case you're wondering why we're using #define for comments: This header is #imported into both Objective-C code and XML Info.plist files.

-#define GROWL_VERSION 1.3.1
-#define GROWL_VERSION_STRING "1.3.1"
+#define GROWL_VERSION 1.3
+#define GROWL_VERSION_STRING "1.3"

 #include "hgRevision.h"


Up to 1.3.3b3

Up to 1.3.3b3

--HG--
branch : maintenance-1.3

--- GrowlVersion.h
+++ GrowlVersion.h
@@ -1,8 +1,8 @@
 #define COMMENT_1 DO NOT EDIT THE VERSION IN THIS FILE! Change the version in Release/Makefile instead, then run make version while in the Release directory.
 #define COMMENT_2 In case you're wondering why we're using #define for comments: This header is #imported into both Objective-C code and XML Info.plist files.

-#define GROWL_VERSION 1.3.3b2
-#define GROWL_VERSION_STRING "1.3.3b2"
+#define GROWL_VERSION 1.3.3b3
+#define GROWL_VERSION_STRING "1.3.3b3"

 #include "HgRevision.h"


changed check for __GNUC__ back to __CYGWIN__ for #defining of __cdecl

--- H/csoundCore.h
+++ H/csoundCore.h
@@ -760,7 +760,7 @@
 # define __cdecl
 #endif

-#if (!defined(__BEOS__) || defined(__MWERKS__)) && !defined(__GNUC__)
+#if (!defined(__BEOS__) || defined(__MWERKS__)) && !defined(__CYGWIN__)
 #  define __cdecl
 #endif


minor

minor

--- H/csoundCore.h
+++ H/csoundCore.h
@@ -50,8 +50,8 @@
 #include "version.h"
 #include <sndfile.h>

-#define OK (0)
-#define NOTOK (-1)
+#define OK        (0)
+#define NOTOK     (-1)

 #define INSTR     1
 #define ENDIN     2
@@ -70,9 +70,9 @@
 /* #define PGMINIT   17 */
 /* #define DPGMINIT  18 */

-#define MAXINSNO 200
-#define PMAX     1000
-#define VARGMAX  1001
+#define MAXINSNO   (200)
+#define PMAX       (1000)
+#define VARGMAX    (1001)
 /* IV - Oct 24 2002: max number of input/output args for user defined opcodes */
 #define OPCODENUMOUTS   24


Fix markup in a number of places.

Fix markup in a number of places.

git-svn-id: 31d9d2f6432a47c86a3640814024c107794ea77c@19684 0785d39b-7218-0410-832d-ea1e28bc413d

--- deal.II/deal.II/include/numerics/mesh_worker.h
+++ deal.II/deal.II/include/numerics/mesh_worker.h
@@ -59,8 +59,8 @@
  * assembling. In order to use it, follow this recipe: fist, create a
  * class responsible for the local integration:
  *
- * @begin{code}
- * @end{code}
+ * @code
+ * @endcode
  *
  * @author Guido Kanschat, 2009
  */
@@ -155,7 +155,7 @@
 					* eeffort. If no selectors
 					* are used, then values for
 					* all named vectors in
-					* #global_data will be
+					* DoFInfo::global_data will be
 					* computed in all quadrature
 					* points.
 					*
@@ -288,7 +288,7 @@
  * In order to use this class, it will be necessary to create an
  * INTEGRATOR class following this template:
  *
- * @begin{code}
+ * @code
  * template <int dim>
  * class MyLocalOperator : public Subscriptor
  * {
@@ -298,19 +298,19 @@
  *     void face(typename IntegrationWorker<dim>::FaceInfo& info1,
  *               typename IntegrationWorker<dim>::FaceInfo& info2) const;
  * };
- * @end{code}
+ * @endcode
  *
  * This class will do whatever your problem requires locally on each
  * cell and/or face. Once this class is defined, you choose a suitable
  * assembler for your problem from the Assembler namespace and set up
  * objects:
  *
- * @begin{code}
+ * @code
  * MyLocalOperator<dim> myop;
  *
  * AssemblingIntegrator<dim, Assembler::MyAssembler, MyLocalOperator<dim> >
  *   integrator(myop);
- * @end{code}
+ * @endcode
  *
  * You do the necessary initializations of this @p integrator and then
  * you have a worker object suitable for integration_loop().


No longer sort the trash first

No longer sort the trash first

--- src/account.c
+++ src/account.c
@@ -481,8 +481,6 @@
 		{
 			gtk_tree_model_get(model, &iter3, MFC_FOLDER, &ret, -1);
 			if(type == FT_INBOX && folder_get_type(ret) != FT_INBOX)
-				break;
-			if(type == FT_TRASH && folder_get_type(ret) != FT_TRASH)
 				break;
 			if(type < folder_get_type(ret))
 				break;


Prevent possible invalid free() with logging.

--- src/actions.c
+++ src/actions.c
@@ -274,20 +274,23 @@

 		LogInMemory = false;

-		if (!Descriptor)
-		{
-			SpitWarning("Cannot record logs to disk. Shutting down logging.");
-			EnableLogging = false;
-		}
-		else
-		{
-			fwrite(MemLogBuffer, 1, strlen(MemLogBuffer), Descriptor);
-			fflush(Descriptor);
-			fclose(Descriptor);
-
-			WriteLogLine(CONSOLE_COLOR_GREEN "Completed starting objects and services. Entering standby loop.\n" CONSOLE_ENDCOLOR, true);
-		}
-		free(MemLogBuffer);
+		if (MemLogBuffer != NULL)
+		{
+			if (!Descriptor)
+			{
+				SpitWarning("Cannot record logs to disk. Shutting down logging.");
+				EnableLogging = false;
+			}
+			else
+			{
+				fwrite(MemLogBuffer, 1, strlen(MemLogBuffer), Descriptor);
+				fflush(Descriptor);
+				fclose(Descriptor);
+
+				WriteLogLine(CONSOLE_COLOR_GREEN "Completed starting objects and services. Entering standby loop.\n" CONSOLE_ENDCOLOR, true);
+			}
+			free(MemLogBuffer);
+		}
 	}

 	if (!InitMemBus(true))


core: Fix concurrent authorizations

core: Fix concurrent authorizations

In case multiple authorizations happen it can trigger a second call to
agent_authorize_service while the first is still ongoing causing all
authorization to fail.

--- src/adapter.c
+++ src/adapter.c
@@ -4964,6 +4964,16 @@

 	g_free(auth);

+	/* Stop processing if queue is empty */
+	if (g_queue_is_empty(adapter->auths)) {
+		if (adapter->auth_idle_id > 0)
+			g_source_remove(adapter->auth_idle_id);
+		return;
+	}
+
+	if (adapter->auth_idle_id > 0)
+		return;
+
 	adapter->auth_idle_id = g_idle_add(process_auth_queue, adapter);
 }

@@ -4990,6 +5000,10 @@
 			auth->cb(NULL, auth->user_data);
 			goto next;
 		}
+
+		/* If agent is set authorization is already ongoing */
+		if (auth->agent)
+			return FALSE;

 		auth->agent = agent_get(NULL);
 		if (auth->agent == NULL) {


HMM_Rotate - normalize vec3 Axis

HMM_Rotate - normalize vec3 Axis

--- HandmadeMath.h
+++ HandmadeMath.h
@@ -802,6 +802,8 @@
 {
     hmm_mat4 Result = HMM_Mat4d(1.0f);

+    Axis = HMM_Normalize(Axis);
+
     float SinTheta = sinf(HMM_ToRadians(Angle));
     float CosTheta = cosf(HMM_ToRadians(Angle));
     float CosValue = 1.0f - CosTheta;


samples: x_nucleo_iks02a1: standard: Convert to use DEVICE_DT_GET_ONE

Move to use DEVICE_DT_GET_ONE instead of device_get_binding as
we work on phasing out use of DTS 'label' property.

Signed-off-by: Kumar Gala <383ef5577c6e1178b93f59ec8d0936f76d2a98c4@kernel.org>

--- samples/shields/x_nucleo_iks02a1/standard/src/main.c
+++ samples/shields/x_nucleo_iks02a1/standard/src/main.c
@@ -167,21 +167,21 @@
 	struct sensor_value accel1[3], accel2[3];
 	struct sensor_value gyro[3];
 	struct sensor_value magn[3];
-	const struct device *iis2dlpc = device_get_binding(DT_LABEL(DT_INST(0, st_iis2dlpc)));
-	const struct device *iis2mdc = device_get_binding(DT_LABEL(DT_INST(0, st_iis2mdc)));
-	const struct device *ism330dhcx = device_get_binding(DT_LABEL(DT_INST(0, st_ism330dhcx)));
+	const struct device *iis2dlpc = DEVICE_DT_GET_ONE(st_iis2dlpc);
+	const struct device *iis2mdc = DEVICE_DT_GET_ONE(st_iis2mdc);
+	const struct device *ism330dhcx = DEVICE_DT_GET_ONE(st_ism330dhcx);
 	int cnt = 1;

-	if (iis2dlpc == NULL) {
-		printf("Could not get IIS2DLPC device\n");
-		return;
-	}
-	if (iis2mdc == NULL) {
-		printf("Could not get IIS2MDC Magn device\n");
-		return;
-	}
-	if (ism330dhcx == NULL) {
-		printf("Could not get ISM330DHCX IMU device\n");
+	if (!device_is_ready(iis2dlpc)) {
+		printk("%s: device not ready.\n", iis2dlpc->name);
+		return;
+	}
+	if (!device_is_ready(iis2mdc)) {
+		printk("%s: device not ready.\n", iis2mdc->name);
+		return;
+	}
+	if (!device_is_ready(ism330dhcx)) {
+		printk("%s: device not ready.\n", ism330dhcx->name);
 		return;
 	}


inline getADCvalue

inline getADCvalue

--- src/adc/ADC.h
+++ src/adc/ADC.h
@@ -25,7 +25,7 @@
 /// \brief Get ADC value from last set ADC channel.
 /// \return Value from ADC registers (ADCH and ADCL).
 ///
-uint16_t getADCvalue()
+inline uint16_t getADCvalue()
 {
     //single conversion mode
     ADCSRA |= (1<<ADSC);


fixed ipmidi

fixed ipmidi

--- InOut/ipmidi.c
+++ InOut/ipmidi.c
@@ -153,7 +153,7 @@

 PUBLIC int csoundModuleCreate(CSOUND *csound)
 {
-     OPARMS parms;
+     OPARMS oparms;
      csound->GetOParms(csound, &oparms);
     /* nothing to do, report success */
     if (oparms->msglevel & 0x400)


rtalsa: define _DEFAULT_SOURCE

rtalsa: define _DEFAULT_SOURCE

This silences a warning as _BSD_SOURCE is deprecated in favor of the new name.
Do not drop the old name to keep compatibility with glibc < 2.19

--- InOut/rtalsa.c
+++ InOut/rtalsa.c
@@ -29,6 +29,10 @@
 #ifndef _POSIX_C_SOURCE
 #define _POSIX_C_SOURCE 200112L
 #endif
+#ifndef _DEFAULT_SOURCE
+#define _DEFAULT_SOURCE 1
+#endif
+/* _BSD_SOURCE definition can be dropped once support for glibc < 2.19 is dropped */
 #ifndef _BSD_SOURCE
 #define _BSD_SOURCE 1
 #endif


Remove unsafe this captures in lambdas-spree

--- src/rs-grpc/include/rs-grpc/rs_grpc.h
+++ src/rs-grpc/include/rs-grpc/rs_grpc.h
@@ -1259,7 +1259,7 @@
 class RsGrpcServerInvocation<
     grpc::ServerAsyncReaderWriter<ResponseType, RequestType>,
     ServerCallTraits,
-    Callback> : public RsGrpcTag {
+    Callback> : public RsGrpcTag, public SubscriberBase {
   using Stream = grpc::ServerAsyncReaderWriter<ResponseType, RequestType>;
   using Service = typename ServerCallTraits::Service;

@@ -1280,32 +1280,23 @@
           context_(*context),
           stream_(*stream) {}

-    template <typename Publisher>
-    void Subscribe(const Publisher &publisher) {
-      // TODO(peck): Don't hold weak unsafe refs to this
-      auto subscription = publisher.Subscribe(MakeSubscriber(
-          [this](auto &&response) {
-            enqueued_responses_.emplace_back(
-                std::forward<decltype(response)>(response));
-            RunEnqueuedOperation();
-          },
-          [this](std::exception_ptr &&error) {
-            OnError(error);
-          },
-          [this]() {
-            enqueued_finish_ = true;
-            RunEnqueuedOperation();
-          }));
-      // TODO(peck): Backpressure, cancellation
-      subscription.Request(ElementCount::Unbounded());
+    void OnNext(ResponseType &&response) {
+      enqueued_responses_.emplace_back(
+          std::forward<decltype(response)>(response));
+      RunEnqueuedOperation();
     }

     /**
      * Try to end the write stream with an error. If the write stream has
      * already finished, this is a no-op.
      */
-    void OnError(const std::exception_ptr &error) {
+    void OnError(std::exception_ptr &&error) {
       status_ = ExceptionToStatus(error);
+      enqueued_finish_ = true;
+      RunEnqueuedOperation();
+    }
+
+    void OnComplete() {
       enqueued_finish_ = true;
       RunEnqueuedOperation();
     }
@@ -1431,6 +1422,18 @@
     }
   }

+  void OnNext(ResponseType &&response) {
+    writer_.OnNext(std::move(response));
+  }
+
+  void OnError(std::exception_ptr &&error) {
+    writer_.OnError(std::move(error));
+  }
+
+  void OnComplete() {
+    writer_.OnComplete();
+  }
+
  private:
   enum class State {
     INIT,
@@ -1448,6 +1451,7 @@
   }

   void Init() {
+    // TODO(peck): I think this weak this capture in the lambda seems dangerous
     auto response = callback_(Publisher<RequestType>(MakePublisher(
         [this](auto &&subscriber) {
       if (subscriber_) {
@@ -1471,7 +1475,10 @@
     static_assert(
         IsPublisher<decltype(response)>,
         "Callback return type must be Publisher");
-    writer_.Subscribe(response);
+    auto subscription = response.Subscribe(MakeSubscriber(
+        std::weak_ptr<RsGrpcServerInvocation>(self_)));
+    // TODO(peck): Backpressure, cancellation
+    subscription.Request(ElementCount::Unbounded());

     Request(
         error_handler_,


Semantics fix

Semantics fix

--- Include/_A2D.h
+++ Include/_A2D.h
@@ -1,27 +1,18 @@

 // For internal use only

+#ifndef GRAPHICS__
 #ifdef _WIN32
-
-#ifndef GRAPHICS__
 #define	 GRAPHICS__	"../Windows/Graphics.h"
+#elif _LINUX
+#define	 GRAPHICS__	"../Linux/Graphics.h"
+#endif
 #endif

 #ifndef GRAPHICS
+#ifdef _WIN32
 #define	 GRAPHICS	"../../../Aurora-SDK/Include/Windows/Graphics.h"
-#endif
-
-#endif
-
-// Required for Linux
-#ifdef _LINUX
-
-#ifndef GRAPHICS__
-#define	 GRAPHICS__	"../Linux/Graphics.h"
-#endif
-
-#ifndef GRAPHICS
+#elif _LINUX
 #define	 GRAPHICS "../../../Aurora-SDK/Include/Linux/Graphics.h"
 #endif
-
 #endif


Display SN instead of ICCID on hello tool Octave screen

--- apps/Welcome/components/yellowCommandLine/octaveScreen.c
+++ apps/Welcome/components/yellowCommandLine/octaveScreen.c
@@ -39,35 +39,25 @@

 //--------------------------------------------------------------------------------------------------
 /**
- * Fetch the SIM's ICCID.
+ * Fetch the cellular module's serial number.
  */
 //--------------------------------------------------------------------------------------------------
-static const char* GetIccid
+static const char* GetSerialNumber
 (
     void
 )
 //--------------------------------------------------------------------------------------------------
 {
-    le_sim_Id_t simId = le_sim_GetSelectedCard();
+    static char serialNumber[LE_INFO_MAX_PSN_BYTES] = "unknown";

-    // Buffer to hold the ICCID (which is normally up to 20 characters long).
-    static char Iccid[32] = "unknown";
+    le_result_t result = le_info_GetPlatformSerialNumber(serialNumber, sizeof(serialNumber));

-    if (!le_sim_IsPresent(simId))
+    if (result != LE_OK)
     {
-        (void)snprintf(Iccid, sizeof(Iccid), "ERROR: SIM card not detected");
-    }
-    else
-    {
-        le_result_t result = le_sim_GetICCID(simId, Iccid, sizeof(Iccid));
-
-        if (result != LE_OK)
-        {
-            (void)snprintf(Iccid, sizeof(Iccid), "ERROR (%s)", LE_RESULT_TXT(result));
-        }
+        (void)snprintf(serialNumber, sizeof(serialNumber), "ERROR (%s)", LE_RESULT_TXT(result));
     }

-    return Iccid;
+    return serialNumber;
 }

@@ -117,11 +107,11 @@
            "your device with the Sierra Wireless Octave IoT data\n"
            "orchestration service:\n"
            "\n"
-           "   IMEI:  %s\n"
-           "   ICCID: %s\n"
+           "   IMEI: %s\n"
+           "     SN: %s\n"
            "\n",
            GetImei(),
-           GetIccid());
+           GetSerialNumber());

     if (instantGratification_IsEnabled())
     {


logging: log_backend_fs: Fix check for error on fs_sync() - coverity

Fixes #33791

Signed-off-by: David Leach <98707a1e43c521c5b5b81e36afef696dde6831a3@nxp.com>

--- subsys/logging/log_backend_fs.c
+++ subsys/logging/log_backend_fs.c
@@ -203,7 +203,11 @@
 			length = 0;
 		}

-		fs_sync(f);
+		rc = fs_sync(f);
+		if (rc < 0) {
+			/* Something is wrong */
+			goto on_error;
+		}
 	}

 	return length;


subsys/loggin/log_backend_fs: added recovery after file lost

Added recovery for case when log file was lost somehow.
Back-end will try to create new file if possible.

Signed-off-by: Andrzej Puzdrowski <0222c24e1773dd88269ed0e559909ec9bea3604a@nordicsemi.no>

--- subsys/logging/log_backend_fs.c
+++ subsys/logging/log_backend_fs.c
@@ -29,6 +29,7 @@

 static int allocate_new_file(struct fs_file_t *file);
 static int del_oldest_log(void);
+static int get_log_file_id(struct fs_dirent *ent);

 static int check_log_dir_available(void)
 {
@@ -51,6 +52,41 @@
 	return -ENOENT;
 }

+static int check_log_file_exist(int num)
+{
+	struct fs_dir_t dir;
+	struct fs_dirent ent;
+	int rc;
+
+	fs_dir_t_init(&dir);
+
+	rc = fs_opendir(&dir, CONFIG_LOG_BACKEND_FS_DIR);
+	if (rc) {
+		return -EIO;
+	}
+
+	while (1) {
+		rc = fs_readdir(&dir, &ent);
+		if (rc < 0) {
+			(void) fs_closedir(&dir);
+			return -EIO;
+		}
+		if (ent.name[0] == 0) {
+			break;
+		}
+
+		rc = get_log_file_id(&ent);
+
+		if (rc == num) {
+			return 1;
+		}
+	}
+
+	(void) fs_closedir(&dir);
+
+	return 0;
+}
+
 int write_log_to_file(uint8_t *data, size_t length, void *ctx)
 {
 	int rc;
@@ -84,18 +120,33 @@
 		}

 		rc = fs_write(f, data, length);
-		if (rc == -ENOSPC) {
-			if (IS_ENABLED(CONFIG_LOG_BACKEND_FS_OVERWRITE)) {
+		if (rc >= 0) {
+			if (IS_ENABLED(CONFIG_LOG_BACKEND_FS_OVERWRITE) &&
+			    (rc != length)) {
 				del_oldest_log();

 				return 0;
 			}
 			/* If overwrite is disabled, full memory
-			 * is equivalent of corrupted backend.
+			 * cause the log record abandonment.
 			 */
-			goto on_error;
-		} else if (rc < 0) {
-			return 0;
+			length = rc;
+		} else {
+			rc = check_log_file_exist(newest);
+			if (rc == 0) {
+				/* file was lost somehow
+				 * try to get a new one
+				 */
+				file_ctr--;
+				rc = allocate_new_file(f);
+				if (rc < 0) {
+					goto on_error;
+				}
+			} else if (rc < 0) {
+				/* fs is corrupted*/
+				goto on_error;
+			}
+			length = 0;
 		}

 		fs_sync(f);


* subversion/include/svn_client.h
  (svn_client_switch3): Fix Doxygen mark-up.

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

--- subversion/include/svn_client.h
+++ subversion/include/svn_client.h
@@ -1345,7 +1345,7 @@
  *              and returning #SVN_ERR_CLIENT_UNRELATED_RESOURCES if they
  *              do not. If @c TRUE, no such sanity checks are performed.
  *
- * @param [in] a apply_local_external_modifications If @c TRUE, local versions
+ * @param [in] apply_local_external_modifications  If @c TRUE, local versions
  *              of the svn:externals property are processed during switch
  *              instead of their committed version.
  *


post index: start indexing posts by categories

Signed-off-by: Josef 'Jeff' Sipek <a620f141433c70aa9e43778305a6c68cbfadfb25@josefsipek.net>

--- post_index.c
+++ post_index.c
@@ -230,7 +230,8 @@
 	return tmp;
 }

-static int __insert_post_tags(struct post *post, list_t *taglist)
+static int __insert_post_tags(avl_tree_t *index, struct post *post,
+			      list_t *taglist)
 {
 	struct post_index_entry *tag_entry;
 	struct post_subindex *sub;
@@ -243,7 +244,7 @@
 		};

 		/* find the right subindex, or... */
-		sub = avl_find(&index_by_tag, &key, &where);
+		sub = avl_find(index, &key, &where);
 		if (!sub) {
 			/* ...allocate one if it doesn't exist */
 			sub = malloc(sizeof(struct post_subindex));
@@ -253,7 +254,7 @@
 			sub->name = str_getref(tag->tag);
 			init_index_tree(&sub->subindex);

-			avl_insert(&index_by_tag, sub, where);
+			avl_insert(index, sub, where);
 		}

 		/* allocate & add a entry to the subindex */
@@ -315,27 +316,23 @@
 	/* add the post to the by-time index */
 	ASSERT3P(safe_avl_add(&index_by_time, by_time), ==, NULL);

-	ret = __insert_post_tags(post, &post->tags);
+	ret = __insert_post_tags(&index_by_tag, post, &post->tags);
 	if (ret)
 		goto err_free_tags;

-#if 0
-	ret = __insert_post_cats(post, &post->cats);
+	ret = __insert_post_tags(&index_by_cat, post, &post->cats);
 	if (ret)
 		goto err_free_cats;
-#endif

 	MXUNLOCK(&index_lock);

 	return 0;

-#if 0
 err_free_cats:
-	__remove_post_cats(post, &post->cats);
-#endif
+	// XXX: __remove_post_tags(&index_by_cat, &post->cats);

 err_free_tags:
-	// XXX: __remove_post_tags(post, &post->tags);
+	// XXX: __remove_post_tags(&index_by_tag, &post->tags);

 	avl_remove(&index_by_time, by_time);


Typo fix. Pointed out by Nuutti Kotivuori on #svn

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

--- subversion/include/svn_string.h
+++ subversion/include/svn_string.h
@@ -121,7 +121,7 @@
 /* Return true if a bytestring is empty (has length zero). */
 svn_boolean_t svn_string_isempty (const svn_string_t *str);

-/* Return a duplicate of ORIGNAL_STRING. */
+/* Return a duplicate of ORIGINAL_STRING. */
 svn_string_t *svn_string_dup (const svn_string_t *original_string,
                               apr_pool_t *pool);

@@ -203,7 +203,7 @@
 void svn_stringbuf_appendcstr (svn_stringbuf_t *targetstr,
                                const char *cstr);

-/* Return a duplicate of ORIGNAL_STRING. */
+/* Return a duplicate of ORIGINAL_STRING. */
 svn_stringbuf_t *svn_stringbuf_dup (const svn_stringbuf_t *original_string,
                                     apr_pool_t *pool);


qcom: Catch the unexpected case that POWER_GOOD up again after lost

When the POWER_GOOD was lost, it sets the shutdown_from_on flag. We
don't expect the POWER_GOOD up again. However, a hardware bug makes
this happen. Catch this unexpected case and go straight to turn off
the switchcap.

BRANCH=None
BUG=b:218878427
TEST=Typed "shutdown -P now" in userspace. Saw the EC warning message:
[41.599700 Warning: POWER_GOOD up again after lost]

Change-Id: Ieadffd5347f46070336cc608af2ed3cbc20c612c
Signed-off-by: Wai-Hong Tam <04b587fdf5845741a0c5a8b9cd59ca72d73ef8fc@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3466417
Reviewed-by: Alexandru Stan <1784cbba6d7675b1eba55eaefe41c7672ad9da3b@chromium.org>
Commit-Queue: Alexandru Stan <1784cbba6d7675b1eba55eaefe41c7672ad9da3b@chromium.org>

--- power/qcom.c
+++ power/qcom.c
@@ -612,15 +612,27 @@

 /**
  * Power off the AP
- */
-static void power_off_seq(void)
+ *
+ * @param shutdown_event	reason of shutdown, which is a return value of
+ *				check_for_power_off_event()
+ */
+static void power_off_seq(uint8_t shutdown_event)
 {
 	/* Check PMIC POWER_GOOD */
 	if (is_pmic_pwron()) {
-		/* Do a graceful way to shutdown PMIC/AP first */
-		set_pmic_pwron(0);
-		usleep(PMIC_POWER_OFF_DELAY);
-
+		if (shutdown_event == POWER_OFF_BY_POWER_GOOD_LOST) {
+			/*
+			 * The POWER_GOOD was lost previously, which sets the
+			 * shutdown_event flag. But now it is up again. This
+			 * is unexpected. Show the warning message. Then go
+			 * straight to turn off the switchcap.
+			 */
+			CPRINTS("Warning: POWER_GOOD up again after lost");
+		} else {
+			/* Do a graceful way to shutdown PMIC/AP first */
+			set_pmic_pwron(0);
+			usleep(PMIC_POWER_OFF_DELAY);
+		}
 	}

 	/*
@@ -1023,7 +1035,7 @@
 		hook_notify(HOOK_CHIPSET_PRE_INIT);

 		if (power_on_seq() != EC_SUCCESS) {
-			power_off_seq();
+			power_off_seq(shutdown_from_on);
 			boot_from_off = 0;
 			return POWER_S5;
 		}
@@ -1134,7 +1146,7 @@
 		/* Call hooks before we drop power rails */
 		hook_notify(HOOK_CHIPSET_SHUTDOWN);

-		power_off_seq();
+		power_off_seq(shutdown_from_on);
 		CPRINTS("power shutdown complete");

 		/* Call hooks after we drop power rails */