Added a half finished baro driver

Added a half finished baro driver

--- firmware/baro_ms5611.c
+++ firmware/baro_ms5611.c
@@ -20,11 +20,12 @@
  * The driver uses libopemcm3/spi.h
  * (documentation: http://libopencm3.github.io/docs/latest/stm32f0/html/group__spi__file.html)
  *
- */
-
-//#define MS5611_SPID        SPID2
-//#define MS5611_SPI_CS_PORT GPIOB
-//#define MS5611_SPI_CS_PIN  GPIOB_BARO_CS
+ * SPI interface page 9
+ */
+
+#define MS5611_SPID          SPI1  //TODO ?? SPID2  //Unsigned int32. SPI peripheral identifier SPI Register base address.
+//#define MS5611_SPI_CS_PORT         //TDOO ?? GPIOB  //
+//#define MS5611_SPI_CS_PIN          //TODO ?? GPIOB_BARO_CS //

@@ -45,11 +46,225 @@
  */
 static void ms5611_reset()
 {
-    uint8_t adr = 0x1E;
+    uint8_t adr = 0x1E;         // Wgat is stored here?
+    spi_enable(MS5611_SPID);    // The SPI peripheral is enabled. // CHIBIOS spiSelect(&MS5611_SPID);
+    spi_send8(MS5611_SPID, adr); // Data is written to the SPI interface after the previous write transfer has finished.
+                                // Note that in chibios an adress is sent, while here the origenal data is sent??
+                                //    spiSend(&MS5611_SPID, 1, (void*)&adr);
+    for (i = 0; i < 10000; i++)
+    {
+        __asm__("nop");  //Not a pretty way of doing this, but will do for now //    chThdSleepMilliseconds(5);
+    }
+
+    spi_disable(MS5611_SPID); //    spiUnselect(&MS5611_SPID);
+}
+
+/*
+ * Reads a uint16 from the MS5611 address `adr`, stores it to `c`.
+ */
+static void ms5611_read_u16(uint8_t adr, uint16_t* c)
+{
+    /* adr must be 0xA0 to 0xAE */
+
+    uint16_t data_received;
+    spi_enable(MS5611_SPID);    // The SPI peripheral is enabled. // CHIBIOS spiSelect(&MS5611_SPID);
+    spi_send8(MS5611_SPID, adr); // Data is written to the SPI interface after the previous write transfer has finished.
+    data_received = spi_read(MS5611_SPID); //A PROM read returns a 2 byte result
+    spi_disable(MS5611_SPID); //    spiUnselect(&MS5611_SPID);
+    *c = data_received;
+
+//   uint8_t rx[2];
+//   spiSelect(&MS5611_SPID);
+//   spiSend(&MS5611_SPID, 1, (void*)&adr);
+//   spiReceive(&MS5611_SPID, 2, (void*)rx);
+//   spiUnselect(&MS5611_SPID);
+//   *c = rx[0] << 8 | rx[1];
+}
+
+
+/*
+ * Reads an int24 from the MS5611 address `adr`, stores it to `d`.
+ */
+static void ms5611_read_s24(uint8_t adr, int32_t* d)
+{
+    uint32_t data_received; //To store result
+    uint8_t adc_adr = 0x00; //Command to read ADC from baro
+
+    spi_enable(MS5611_SPID);    // The SPI peripheral is enabled. // CHIBIOS spiSelect(&MS5611_SPID);
+    spi_send8(MS5611_SPID, adr); // Data is written to the SPI interface after the previous write transfer has finished.
+
+    //TODO: Sleep for 1 ms
+    /*
+     * Wait for conversion to complete. There doesn't appear to be any way
+     * to do this without timing it, unfortunately.
+     *
+     * If we just watch the clock we'll consume enormous CPU time for little
+     * gain. Instead we'll sleep for "roughly" 1ms and then wait until at least
+     * the desired 0.6ms have passed.
+     */
+
+    spi_send8(MS5611_SPID, adc_adr); // Asks the device to send the results from the ADC.
+    data_received = spi_read(MS5611_SPID); //A ADC_READ command returns a 3 byte result
+
+    *d = data_received;
+
+    /*
+    //OLD CODE:
+    uint8_t adc_adr = 0x00, rx[3];
+    int32_t t0;
+
+    */
+    /* Start conversion */
+    //spiSelect(&MS5611_SPID);
+    //spiSend(&MS5611_SPID, 1, (void*)&adr);
+
+    /*
+     * Wait for conversion to complete. There doesn't appear to be any way
+     * to do this without timing it, unfortunately.
+     *
+     * If we just watch the clock we'll consume enormous CPU time for little
+     * gain. Instead we'll sleep for "roughly" 1ms and then wait until at least
+     * the desired 0.6ms have passed.
+     */
+   // t0 = halGetCounterValue();
+    //chThdSleepMilliseconds(1);
+    //while(halGetCounterValue() - t0 < US2RTT(600)) {
+   //     chThdYield();
+    //}
+
+    /* Deassert CS */
+    //spiUnselect(&MS5611_SPID);
+
+    /* Read ADC result */
 //    spiSelect(&MS5611_SPID);
-//    spiSend(&MS5611_SPID, 1, (void*)&adr);
-//    chThdSleepMilliseconds(5);
-//    spiUnselect(&MS5611_SPID);
-}
-
-
+  //  spiSend(&MS5611_SPID, 1, (void*)&adc_adr);
+   // spiReceive(&MS5611_SPID, 3, (void*)rx);
+    //spiUnselect(&MS5611_SPID);
+
+   // *d = rx[0] << 16 | rx[1] << 8 | rx[2];
+}
+
+/*
+ * Reads MS5611 calibration data, writes it to `cal_data`.
+ */
+static void ms5611_read_cal(MS5611CalData* cal_data)
+{
+    uint16_t d0, d7;
+    ms5611_read_u16(0xA0, &d0);
+    ms5611_read_u16(0xA2, &(cal_data->c1));
+    ms5611_read_u16(0xA4, &(cal_data->c2));
+    ms5611_read_u16(0xA6, &(cal_data->c3));
+    ms5611_read_u16(0xA8, &(cal_data->c4));
+    ms5611_read_u16(0xAA, &(cal_data->c5));
+    ms5611_read_u16(0xAC, &(cal_data->c6));
+    ms5611_read_u16(0xAE, &d7);
+
+   // TODO: LOG
+//    log_u16(CHAN_CAL_BARO1, d0, cal_data->c1, cal_data->c2, cal_data->c3);
+//    log_u16(CHAN_CAL_BARO2, cal_data->c4, cal_data->c5, cal_data->c6, d7);
+}
+
+
+/*
+ * Initialise the MS5611.
+ * Sends a RESET and then reads in the calibration data.
+ *
+ * Call this once system startup, before attempting ms5611_read.
+ *
+ * cal_data should be a pointer to some memory to store the calibration in.
+ */
+static void ms5611_init(MS5611CalData* cal_data)
+{
+    ms5611_reset();
+    ms5611_read_cal(cal_data);
+}
+
+/*
+ * Read and compensate a temperature and pressure from the MS5611.
+ *
+ * `cal_data` is previously read calibration data.
+ * `temperature` and `pressure` are written to.
+ *
+ * `temperature` is in centidegrees Celcius,
+ * `pressure` is in Pascals.
+ */
+static void ms5611_read(MS5611CalData* cal_data,
+                        int32_t* temperature, int32_t* pressure)
+{
+    int32_t d1, d2;
+    int64_t off, sens, dt;
+    ms5611_read_s24(0x40, &d1);
+    ms5611_read_s24(0x50, &d2);
+
+    dt = (int64_t)d2 - (int64_t)cal_data->c5 * (1<<8);
+    *temperature = 2000 + (dt * (int64_t)cal_data->c6) / (1<<23);
+
+    off = (int64_t)cal_data->c2 * (1<<16) + \
+          ((int64_t)cal_data->c4 * dt) / (1<<7);
+
+    sens = (int64_t)cal_data->c1 * (1<<15) + \
+           ((int64_t)cal_data->c3 * dt) / (1<<8);
+
+    *pressure = ((d1 * sens) / (1<<21) - off) / (1<<15);
+
+    /*update the global variables with the pressure and temperature information*/
+    global_pressure = *pressure;
+    global_temperature = *temperature;
+
+
+    //TODO: Check what the tweeter is supposed to output + log
+//    tweeter_set_error(ERROR_BARO, *pressure < 1000 || *pressure > 120000);
+
+//    log_s32(CHAN_IMU_BARO, *pressure, *temperature);
+}
+
+
+
+/*
+ * MS5611 main thread.
+ * Resets the MS5611, reads cal data, then reads a pressure and temperature
+ * in a loop.
+ */
+msg_t ms5611_thread(void *arg)
+{
+    (void)arg;
+
+
+    static MS5611CalData cal_data;
+    static int32_t temperature, pressure;
+
+    int spi_init_master 	(
+        uint32_t  	spi,
+		uint32_t  	br,
+		uint32_t  	cpol,
+		uint32_t  	cpha,
+		uint32_t  	crcl,
+		uint32_t  	lsbfirst
+	)
+
+    //OLD CODE:
+
+    static const SPIConfig spi_cfg = {
+        NULL,
+        MS5611_SPI_CS_PORT,
+        MS5611_SPI_CS_PIN,
+        SPI_CR1_BR_1 | SPI_CR1_CPOL | SPI_CR1_CPHA
+    };
+
+    static MS5611CalData cal_data;
+    static int32_t temperature, pressure;
+
+    chRegSetThreadName("MS5611");
+
+    spiStart(&MS5611_SPID, &spi_cfg);
+    ms5611_init(&cal_data);
+
+    while (TRUE) {
+        ms5611_read(&cal_data, &temperature, &pressure);
+        state_estimation_new_pressure((float)pressure);
+    }
+}
+
+
+
+


prefix fmin/fmax with bnd_ to prevent clashing definitions.

--- blendish.h
+++ blendish.h
@@ -579,34 +579,32 @@

 #include <float.h>

-#ifndef MSC_FMINF_DEFINED
-#define MSC_FMINF_DEFINED
-static float fminf ( float a, float b )
+static float bnd_fminf ( float a, float b )
 {
     return _isnan(a) ? b : ( _isnan(b) ? a : ((a < b) ? a : b));
 }

-static float fmaxf ( float a, float b )
+static float bnd_fmaxf ( float a, float b )
 {
     return _isnan(a) ? b : ( _isnan(b) ? a : ((a > b) ? a : b));
 }
-#endif // MSC_FMINF_DEFINED
-
-#ifndef MSC_FMIN_DEFINED
-#define MSC_FMIN_DEFINED
-static double fmin ( double a, double b )
+
+static double bnd_fmin ( double a, double b )
 {
     return _isnan(a) ? b : ( _isnan(b) ? a : ((a < b) ? a : b));
 }

-static double fmax ( double a, double b )
+static double bnd_fmax ( double a, double b )
 {
     return _isnan(a) ? b : ( _isnan(b) ? a : ((a > b) ? a : b));
 }
-#endif // MSC_FMIN_DEFINED

 #else
     #define BND_INLINE inline
+    #define bnd_fminf(a, b) fminf(a, b)
+    #define bnd_fmaxf(a, b) fmaxf(a, b)
+    #define bnd_fmin(a, b) fmin(a, b)
+    #define bnd_fmax(a, b) fmax(a, b)
 #endif

 ////////////////////////////////////////////////////////////////////////////////
@@ -1351,15 +1349,15 @@
     float cr0, float cr1, float cr2, float cr3) {
     float d;

-    w = fmaxf(0, w);
-    h = fmaxf(0, h);
-    d = fminf(w, h);
+    w = bnd_fmaxf(0, w);
+    h = bnd_fmaxf(0, h);
+    d = bnd_fminf(w, h);

     nvgMoveTo(ctx, x,y+h*0.5f);
-    nvgArcTo(ctx, x,y, x+w,y, fminf(cr0, d/2));
-    nvgArcTo(ctx, x+w,y, x+w,y+h, fminf(cr1, d/2));
-    nvgArcTo(ctx, x+w,y+h, x,y+h, fminf(cr2, d/2));
-    nvgArcTo(ctx, x,y+h, x,y, fminf(cr3, d/2));
+    nvgArcTo(ctx, x,y, x+w,y, bnd_fminf(cr0, d/2));
+    nvgArcTo(ctx, x+w,y, x+w,y+h, bnd_fminf(cr1, d/2));
+    nvgArcTo(ctx, x+w,y+h, x,y+h, bnd_fminf(cr2, d/2));
+    nvgArcTo(ctx, x,y+h, x,y, bnd_fminf(cr3, d/2));
     nvgClosePath(ctx);
 }

@@ -1409,9 +1407,9 @@
     float d;

     y -= 0.5f;
-    d = fminf(w, h);
-    cr2 = fminf(cr2, d/2);
-    cr3 = fminf(cr3, d/2);
+    d = bnd_fminf(w, h);
+    cr2 = bnd_fminf(cr2, d/2);
+    cr3 = bnd_fminf(cr3, d/2);

     nvgBeginPath(ctx);
     nvgMoveTo(ctx, x+w,y+h-cr2);
@@ -1424,7 +1422,7 @@
     nvgStrokeWidth(ctx, 1);
     nvgStrokePaint(ctx,
         nvgLinearGradient(ctx,
-            x,y+h-fmaxf(cr2,cr3)-1,
+            x,y+h-bnd_fmaxf(cr2,cr3)-1,
             x,y+h-1,
         nvgRGBAf(bevelColor.r, bevelColor.g, bevelColor.b, 0),
         bevelColor));
@@ -1489,8 +1487,8 @@
     float cr0, float cr1, float cr2, float cr3,
     NVGcolor shade_top, NVGcolor shade_down) {
     nvgBeginPath(ctx);
-    bndRoundedBox(ctx,x+1,y+1,w-2,h-3,
-        fmaxf(0,cr0-1),fmaxf(0,cr1-1),fmaxf(0,cr2-1),fmaxf(0,cr3-1));
+    bndRoundedBox(ctx,x+1,y+1,w-2,h-3,bnd_fmaxf(0,cr0-1),
+        bnd_fmaxf(0,cr1-1),bnd_fmaxf(0,cr2-1),bnd_fmaxf(0,cr3-1));
     nvgFillPaint(ctx,((h-2)>w)?
         nvgLinearGradient(ctx,x,y,x+w,y,shade_top,shade_down):
         nvgLinearGradient(ctx,x,y,x,y+h,shade_top,shade_down));
@@ -1718,11 +1716,11 @@
     size = bnd_clamp(size,0,1);
     offset = bnd_clamp(offset,0,1);
     if ((*h) > (*w)) {
-        float hs = fmaxf(size*(*h), (*w)+1);
+        float hs = bnd_fmaxf(size*(*h), (*w)+1);
         *y = (*y) + ((*h)-hs)*offset;
         *h = hs;
     } else {
-        float ws = fmaxf(size*(*w), (*h)-1);
+        float ws = bnd_fmaxf(size*(*w), (*h)-1);
         *x = (*x) + ((*w)-ws)*offset;
         *w = ws;
     }


widget: Improve debug output

widget: Improve debug output

--- gtk/gtkwidget.c
+++ gtk/gtkwidget.c
@@ -5431,8 +5431,9 @@
 	}

       name = g_type_name (G_OBJECT_TYPE (G_OBJECT (widget)));
-      g_print ("gtk_widget_size_allocate: %*s%s %d %d",
+      g_print ("gtk_widget_size_allocate: %*s%s %d %d %d %d",
 	       2 * depth, " ", name,
+	       allocation->x, allocation->y,
 	       allocation->width, allocation->height);
       if (baseline != -1)
 	g_print (" baseline: %d", baseline);


Increase number of buffers

Increase number of buffers

--- firmware/xmega/xgrid.h
+++ firmware/xmega/xgrid.h
@@ -47,7 +47,7 @@
 #define XGRID_COMPARE_BUFFER_SIZE 16
 #define XGRID_BUFFER_SIZE 64

-#define XGRID_SM_BUFFER_COUNT   8
+#define XGRID_SM_BUFFER_COUNT   10
 #define XGRID_SM_BUFFER_SIZE    64
 #define XGRID_LG_BUFFER_COUNT   2
 #define XGRID_LG_BUFFER_SIZE    (512+2)


colored wire outline inherits alpha

colored wire outline inherits alpha

--- blendish.h
+++ blendish.h
@@ -1689,7 +1689,9 @@
         x0 + delta, y0,
         x1 - delta, y1,
         x1, y1);
-    nvgStrokeColor(ctx, bnd_theme.nodeTheme.wiresColor);
+    NVGcolor colorw = bnd_theme.nodeTheme.wiresColor;
+    colorw.a = (color0.a<color1.a)?color0.a:color1.a;
+    nvgStrokeColor(ctx, colorw);
     nvgStrokeWidth(ctx, BND_NODE_WIRE_OUTLINE_WIDTH);
     nvgStroke(ctx);
     nvgStrokePaint(ctx, nvgLinearGradient(ctx,


GtkWidget: Set screen info in GtkStyleContext.

--- gtk/gtkwidget.c
+++ gtk/gtkwidget.c
@@ -7294,6 +7294,9 @@
       path = gtk_widget_get_path (widget);
       gtk_style_context_set_path (context, path);
       gtk_widget_path_free (path);
+
+      gtk_style_context_set_screen (context,
+                                    gtk_widget_get_screen (widget));
     }
 }

@@ -7895,6 +7898,8 @@
 {
   if (old_screen != new_screen)
     {
+      GtkStyleContext *context;
+
       if (old_screen)
 	{
 	  PangoContext *context = g_object_get_qdata (G_OBJECT (widget), quark_pango_context);
@@ -7903,6 +7908,10 @@
 	}

       _gtk_tooltip_hide (widget);
+
+      context = gtk_widget_get_style_context (widget);
+      gtk_style_context_set_screen (context, new_screen);
+
       g_signal_emit (widget, widget_signals[SCREEN_CHANGED], 0, old_screen);
     }
 }
@@ -13283,6 +13292,9 @@
           path = gtk_widget_get_path (widget);
           gtk_style_context_set_path (context, path);
           gtk_widget_path_free (path);
+
+          gtk_style_context_set_screen (context,
+                                        gtk_widget_get_screen (widget));
         }
     }


Switch #defs to const chars.

Switch #defs to const chars.

--- engine/data.c
+++ engine/data.c
@@ -45,9 +45,9 @@

 /* -- Constants -- */
-#define DPI_LIST_FILTER_MARKER ':'
-#define DPI_LIST_FILTER_PREFIX '/'
-#define DPI_LIST_FILTER_SUFFIX '/'
+const char DPI_LIST_FILTER_MARKER = ':';
+const char DPI_LIST_FILTER_PREFIX = '/';
+const char DPI_LIST_FILTER_SUFFIX = '/';

 /* -- Exported Data Access Routines -- */


Removed old enumerator

Removed old enumerator

--- src/shogun/labels/LabelTypes.h
+++ src/shogun/labels/LabelTypes.h
@@ -24,9 +24,7 @@
 	LT_STRUCTURED = 4,
 	/// latent latent labels
 	LT_LATENT = 5,
-	/// multiple output multiclass
-	LT_MULTICLASS_MULTIPLE_OUTPUT = 6,
 	/// sparse label class for multilabel classification (sets of labels)
-	LT_SPARSE_MULTILABEL = 7,
+	LT_SPARSE_MULTILABEL = 6,
 };
 #endif


Removed the nonsensical parameter from the traceTASK_CREATE_FAILED() macro in tasks.c.

git-svn-id: 43aea61533866f88f23079d48f4f5dc2d5288937@1169 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

--- Source/tasks.c
+++ Source/tasks.c
@@ -513,7 +513,7 @@
 	else
 	{
 		xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;
-		traceTASK_CREATE_FAILED( pxNewTCB );
+		traceTASK_CREATE_FAILED();
 	}

 	if( xReturn == pdPASS )


widget: Unset widget on accessibles

widget: Unset widget on accessibles

--- gtk/gtkwidget.c
+++ gtk/gtkwidget.c
@@ -10101,6 +10101,11 @@
   /* gtk_object_destroy() will already hold a refcount on object */
   GtkWidget *widget = GTK_WIDGET (object);
   GtkWidgetPrivate *priv = widget->priv;
+  GtkAccessible *accessible;
+
+  accessible = g_object_steal_qdata (G_OBJECT (widget), quark_accessible_object);
+  if (GTK_IS_ACCESSIBLE (accessible))
+    gtk_accessible_set_widget (accessible, NULL);

   /* wipe accelerator closures (keep order) */
   g_object_set_qdata (G_OBJECT (widget), quark_accel_path, NULL);


Move error statements to print_s2n_error (#843)

--- bin/s2nd.c
+++ bin/s2nd.c
@@ -32,7 +32,6 @@
 #include <getopt.h>

 #include <errno.h>
-#include <error.h>

 #include <error/s2n_errno.h>

@@ -751,13 +750,13 @@
         if (session_ticket_key_file_path) {
             int fd = open(session_ticket_key_file_path, O_RDONLY);
             if (fd < 0) {
-                error(1, errno, "Error opening session ticket key file");
+                print_s2n_error("Error opening session ticket key file");
                 exit(1);
             }

             struct stat st;
             if (fstat(fd, &st) < 0) {
-                error(1, errno, "Error fstat-ing session ticket key file");
+                print_s2n_error("Error fstat-ing session ticket key file");
                 exit(1);
             }


Add usage of portREMOVE_STATIC_QUALIFIER.

git-svn-id: 43aea61533866f88f23079d48f4f5dc2d5288937@387 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

--- Source/tasks.c
+++ Source/tasks.c
@@ -59,7 +59,6 @@
  * Macro to define the amount of stack available to the idle task.
  */
 #define tskIDLE_STACK_SIZE	configMINIMAL_STACK_SIZE
-

 /*
  * Task control block.  A task control block (TCB) is allocated to each task,
@@ -91,6 +90,14 @@
 	#endif

 } tskTCB;
+
+/*
+ * Some kernel aware debuggers require data to be viewed to be global, rather
+ * than file scope.
+ */
+#ifdef portREMOVE_STATIC_QUALIFIER
+	#define static
+#endif

 /*lint -e956 */


Fixed an ordering problem in environment search

--- environment.c
+++ environment.c
@@ -55,9 +55,10 @@
 lval *search_env( lenv *e, const char *sym ){

   lenv *env = e;
-  lval *curr = env->data;
+  lval *curr;

   while( env != NULL ){
+    curr = env->data;
     while( curr != NULL ){

       if( strcmp( curr->str, sym ) == 0 ){
@@ -66,7 +67,6 @@
       curr = curr->next;
     }
     env = env->parent;
-    curr = env->data;
   }
   char err[256];
   sprintf( err, "Symbol \"%s\" not bound in this environment", sym );


Fix a typo

Fix a typo

--- gtk/gtkwindow.c
+++ gtk/gtkwindow.c
@@ -5090,7 +5090,7 @@
   GtkStyleContext *context;
   const gchar *title;

-  /* Clien decorations already created */
+  /* Client decorations already created */
   if (priv->client_decorated)
     return;


update MVC

update MVC

--- Sources/eobj.c
+++ Sources/eobj.c
@@ -298,7 +298,6 @@
                         c->c_widget.w_read(x, s, 1, av);
                     return;
                 }
-#ifndef _MSC_VER
                 // Look in the search path
                 var = sys_searchpath;
                 while (var)
@@ -313,8 +312,6 @@
                     }
                     var = var->nl_next;
                 }
-#endif
-
                 // Nothing work but we don't care
                 if(c->c_widget.w_read)
                     c->c_widget.w_read(x, s, 1, av);


Create SudokuSolver.c

Create SudokuSolver.c

Import of SudokuSolver.c

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

--- SudokuSolver.c
+++ SudokuSolver.c
@@ -0,0 +1,81 @@
+#include <stdio.h>
+
+int isAvailable(int puzzle[][9], int row, int col, int num)
+{
+    int rowStart = (row/3) * 3;
+    int colStart = (col/3) * 3;
+    int i, j;
+
+    for(i=0; i<9; ++i)
+    {
+        if (puzzle[row][i] == num) return 0;
+        if (puzzle[i][col] == num) return 0;
+        if (puzzle[rowStart + (i%3)][colStart + (i/3)] == num) return 0;
+    }
+    return 1;
+}
+
+int fillSudoku(int puzzle[][9], int row, int col)
+{
+    int i;
+    if(row<9 && col<9)
+    {
+        if(puzzle[row][col] != 0)
+        {
+            if((col+1)<9) return fillSudoku(puzzle, row, col+1);
+            else if((row+1)<9) return fillSudoku(puzzle, row+1, 0);
+            else return 1;
+        }
+        else
+        {
+            for(i=0; i<9; ++i)
+            {
+                if(isAvailable(puzzle, row, col, i+1))
+                {
+                    puzzle[row][col] = i+1;
+                    if((col+1)<9)
+                    {
+                        if(fillSudoku(puzzle, row, col +1)) return 1;
+                        else puzzle[row][col] = 0;
+                    }
+                    else if((row+1)<9)
+                    {
+                        if(fillSudoku(puzzle, row+1, 0)) return 1;
+                        else puzzle[row][col] = 0;
+                    }
+                    else return 1;
+                }
+            }
+        }
+        return 0;
+    }
+    else return 1;
+}
+
+int main()
+{
+    int i, j;
+    int puzzle[9][9]={{0, 0, 0, 0, 0, 0, 0, 9, 0},
+                      {1, 9, 0, 4, 7, 0, 6, 0, 8},
+                      {0, 5, 2, 8, 1, 9, 4, 0, 7},
+                      {2, 0, 0, 0, 4, 8, 0, 0, 0},
+                      {0, 0, 9, 0, 0, 0, 5, 0, 0},
+                      {0, 0, 0, 7, 5, 0, 0, 0, 9},
+                      {9, 0, 7, 3, 6, 4, 1, 8, 0},
+                      {5, 0, 6, 0, 8, 1, 0, 7, 4},
+                      {0, 8, 0, 0, 0, 0, 0, 0, 0}};
+
+    if(fillSudoku(puzzle, 0, 0))
+    {
+        printf("\n+-----+-----+-----+\n");
+        for(i=1; i<10; ++i)
+        {
+            for(j=1; j<10; ++j) printf("|%d", puzzle[i-1][j-1]);
+            printf("|\n");
+            if (i%3 == 0) printf("+-----+-----+-----+\n");
+        }
+    }
+    else printf("\n\nNO SOLUTION\n\n");
+
+    return 0;
+}


count BROADCAST MAC errors (malformed MAC)

--- hcxpcapngtool.c
+++ hcxpcapngtool.c
@@ -160,6 +160,7 @@
 static long int beaconssidoversizedcount;
 static long int beaconhcxcount;
 static long int beaconerrorcount;
+static long int broadcastmacerrorcount;
 static long int pagcount;
 static long int proberesponsecount;
 static long int proberesponsessidunsetcount;
@@ -455,6 +456,7 @@
 beaconssidoversizedcount = 0;
 beaconhcxcount = 0;
 beaconerrorcount = 0;
+broadcastmacerrorcount = 0;
 pagcount = 0;
 proberesponsecount = 0;
 proberesponsessidunsetcount = 0;
@@ -732,9 +734,11 @@
 if(radiotaperrorcount > 0)		printf("packet with damaged radiotap header......: %ld\n", radiotaperrorcount);
 if(zeroedtimestampcount > 0)		printf("packets with zeroed timestamps...........: %ld\n", zeroedtimestampcount);
 if(eapolmsgtimestamperrorcount > 0)	printf("EAPOL frames with wrong timestamp........: %ld\n", eapolmsgtimestamperrorcount);
-malformedcount = beaconerrorcount +taglenerrorcount +essiderrorcount +eapolmsgerrorcount;
+malformedcount = beaconerrorcount +broadcastmacerrorcount +taglenerrorcount +essiderrorcount +eapolmsgerrorcount;
 if(malformedcount > 0)			printf("malformed packets (total)................: %ld\n", malformedcount);
-if(beaconerrorcount > 0)		printf("BROADCAST MAC error (malformed packets)..: %ld\n", beaconerrorcount);
+beaconerrorcount += broadcastmacerrorcount;
+if(beaconerrorcount > 0)		printf("BEACON error (total malformed packets)...: %ld\n", beaconerrorcount);
+if(broadcastmacerrorcount > 0)		printf("BROADCAST MAC error (malformed packets)..: %ld\n", broadcastmacerrorcount);
 if(taglenerrorcount > 0)		printf("IE TAG length error (malformed packets)..: %ld\n", taglenerrorcount);
 if(essiderrorcount > 0)			printf("ESSID error (malformed packets)..........: %ld\n", essiderrorcount);
 eapolmsgerrorcount = eapolmsgerrorcount +eapolm1errorcount +eapolm2errorcount +eapolm3errorcount +eapolm4errorcount;
@@ -4162,7 +4166,7 @@
 beaconcount++;
 if(memcmp(&mac_broadcast, macbc, 6) != 0)
 	{
-	beaconerrorcount++;
+	broadcastmacerrorcount++;
 	return;
 	}
 apinfoptr = beaconptr +CAPABILITIESAP_SIZE;
@@ -4232,14 +4236,13 @@
 return;
 }
 /*===========================================================================*/
-static void process80211actionmeasurement(uint64_t actiontimestamp, uint8_t *macclient, uint8_t to_ds, uint8_t from_ds, uint32_t packetlen, uint8_t *packetptr)
+static void process80211actionmeasurement(uint64_t actiontimestamp, uint8_t *macclient, uint32_t packetlen, uint8_t *packetptr)
 {
 static maclist_t *aplistnew;
 static tags_t tags;

 static actmm_t *actmm;

-if((to_ds != 1) && (from_ds != 0)) return;
 if(packetlen < ACTIONMEASUREMENTFRAME_SIZE) return;
 actmm = (actmm_t*)packetptr;
 if(actmm->actioncode != ACT_MM_NRREQ) return;
@@ -4283,7 +4286,7 @@
 return;
 }
 /*===========================================================================*/
-static void process80211action(uint64_t actiontimestamp, uint8_t *macclient, uint8_t to_ds, uint8_t from_ds, uint32_t packetlen, uint8_t *packetptr)
+static void process80211action(uint64_t actiontimestamp, uint8_t *macclient, uint32_t packetlen, uint8_t *packetptr)
 {
 static actf_t *actf;

@@ -4291,7 +4294,7 @@
 actf = (actf_t*)packetptr;
 actioncount++;
 if(actf->categoriecode == CAT_VENDOR) process80211actionvendor(packetlen, packetptr);
-else if(actf->categoriecode == CAT_RADIO_MEASUREMENT) process80211actionmeasurement(actiontimestamp, macclient, to_ds, from_ds, packetlen, packetptr);
+else if(actf->categoriecode == CAT_RADIO_MEASUREMENT) process80211actionmeasurement(actiontimestamp, macclient, packetlen, packetptr);
 return;
 }
 /*===========================================================================*/
@@ -4331,7 +4334,7 @@
 		if(memcmp(&mac_broadcast, macfrx->addr1, 6) == 0) process80211probe_req(packetimestamp, macfrx->addr2, payloadlen, payloadptr);
 		else process80211probe_req_direct(packetimestamp, macfrx->addr2, macfrx->addr1, payloadlen, payloadptr);
 		}
-	else if(macfrx->subtype == IEEE80211_STYPE_ACTION) process80211action(packetimestamp, macfrx->addr2, macfrx->to_ds, macfrx->from_ds, payloadlen, payloadptr);
+	else if(macfrx->subtype == IEEE80211_STYPE_ACTION) process80211action(packetimestamp, macfrx->addr2, payloadlen, payloadptr);
 	else if(macfrx->subtype == IEEE80211_STYPE_DEAUTH) deauthenticationcount++;
 	else if(macfrx->subtype == IEEE80211_STYPE_DISASSOC) disassociationcount++;
 	else if(macfrx->subtype == IEEE80211_STYPE_MGTRESERVED) mgtreservedcount++;


added ESSID to device info list

added ESSID to device info list

--- hcxpcapngtool.c
+++ hcxpcapngtool.c
@@ -1026,6 +1026,7 @@
 		fprintf(fh_deviceinfo, "\t");
 		for(p = 0; p < zeigermac->enrolleelen; p++) fprintf(fh_deviceinfo, "%02x", zeigermac->enrollee[p]);
 		}
+	fwritedeviceinfostr(zeigermac->essidlen, zeigermac->essid, fh_deviceinfo);
 	fprintf(fh_deviceinfo, "\n");
 	deviceinfocount++;
 	}


Update helper.h

Update helper.h

--- header/helper.h
+++ header/helper.h
@@ -32,8 +32,8 @@
 		COLOR_S								= MAKE_SOURCETYPE(0x0100000),
 		DEPTH_S								= MAKE_SOURCETYPE(0x0010000),
 		IR_S								= MAKE_SOURCETYPE(0x0001000),
-		LONG_EXPOSURE_IR_S					= MAKE_SOURCETYPE(0x0000100),
-		BODY_INDEX_S						= MAKE_SOURCETYPE(0x0000010),
+		LONG_EXPOSURE_IR_S						= MAKE_SOURCETYPE(0x0000100),
+		BODY_INDEX_S							= MAKE_SOURCETYPE(0x0000010),
 		AUDIO_S								= MAKE_SOURCETYPE(0x0000001)
 	};

@@ -42,17 +42,17 @@
 	 /*************      Available Face Features     ****************/
 	 enum FaceFeatures {
 		 //Ignore Warning C4309
-		BOUNDING_BOX_IN_COLOR_SAPCE			= MAKE_SOURCETYPE(0x10000000000),
-		POINTS_IN_COLOR_SPACE				= MAKE_SOURCETYPE(0x01000000000),
-		ROTATION_ORIENTATION				= MAKE_SOURCETYPE(0x00100000000),
+		BOUNDING_BOX_IN_COLOR_SAPCE					= MAKE_SOURCETYPE(0x10000000000),
+		POINTS_IN_COLOR_SPACE						= MAKE_SOURCETYPE(0x01000000000),
+		ROTATION_ORIENTATION						= MAKE_SOURCETYPE(0x00100000000),
 		HAPPY								= MAKE_SOURCETYPE(0x00010000000),
-		RIGHT_EYE_CLOSED					= MAKE_SOURCETYPE(0x00001000000),
-		LEFT_EYE_CLOSED						= MAKE_SOURCETYPE(0x00000100000),
+		RIGHT_EYE_CLOSED						= MAKE_SOURCETYPE(0x00001000000),
+		LEFT_EYE_CLOSED							= MAKE_SOURCETYPE(0x00000100000),
 		MOUTH_OPEN							= MAKE_SOURCETYPE(0x00000010000),
 		MOUTH_MOVED							= MAKE_SOURCETYPE(0x00000001000),
-		LOOKING_AWAY						= MAKE_SOURCETYPE(0x00000000100),
+		LOOKING_AWAY							= MAKE_SOURCETYPE(0x00000000100),
 		GLASSES								= MAKE_SOURCETYPE(0x00000000010),
-		FACE_ENGAGEMENT						= MAKE_SOURCETYPE(0x00000000001)
+		FACE_ENGAGEMENT							= MAKE_SOURCETYPE(0x00000000001)
 	};

@@ -66,7 +66,7 @@
 		FACE_F			= MAKE_SOURCETYPE(0x0001000),
 		HDFACE_F		= MAKE_SOURCETYPE(0x0000100),
 		BODY_F			= MAKE_SOURCETYPE(0x0000010),
-		BODY_INDEX_F	= MAKE_SOURCETYPE(0x0000001),
+		BODY_INDEX_F		= MAKE_SOURCETYPE(0x0000001),
 	};

@@ -80,4 +80,4 @@
 			pInterfaceToRelease->Release();
 			pInterfaceToRelease = NULL;
 		}
-	}+	}


examples/l3fwd-acl: fix possible memory leak

At error app_acl_init() can return without freeing dynamically allocated memory.
Not really a big problem, as if app_acl_init() fails,
then application would terminate immediately anyway.
Though it is a good coding practise to make a function to cleanup after itself.

Signed-off-by: Konstantin Ananyev <cbd5212b59ab42a210d72992d23a3aa17cfd3eaf@intel.com>

--- examples/l3fwd-acl/main.c
+++ examples/l3fwd-acl/main.c
@@ -1247,6 +1247,10 @@
 				acl_log("Socket %d of lcore %u is out "
 					"of range %d\n",
 					socketid, lcore_id, NB_SOCKETS);
+				free(route_base_ipv4);
+				free(route_base_ipv6);
+				free(acl_base_ipv4);
+				free(acl_base_ipv6);
 				return -1;
 			}


crypt-bcrypt: Fix cast increases required alignment of target type on ARM

--- crypt-bcrypt.c
+++ crypt-bcrypt.c
@@ -484,7 +484,7 @@
 #else
 /* Architectures with no complicated addressing modes supported */
 #define BF_INDEX(S, i) \
-        (*((BF_word *)(((unsigned char *)S) + (i))))
+        (*((BF_word *)((void *)(((unsigned char *)S) + (i)))))
 #define BF_ROUND(L, R, N) \
         tmp1 = L & 0xFF; \
         tmp1 <<= 2; \


crypt-bcrypt: Remove runtime check for endianness

--- crypt-bcrypt.c
+++ crypt-bcrypt.c
@@ -454,22 +454,26 @@
   while (sptr < end);
 }

+#if IS_BIGENDIAN
+static void
+BF_swap (ARG_UNUSED(BF_word * x), ARG_UNUSED(int count))
+{
+}
+#else
 static void
 BF_swap (BF_word * x, int count)
 {
-  static const int endianness_check = 1;
-  const char *is_little_endian = (const char *) &endianness_check;
   BF_word tmp;

-  if (*is_little_endian)
-    do
-      {
-        tmp = *x;
-        tmp = (tmp << 16) | (tmp >> 16);
-        *x++ = ((tmp & 0x00FF00FF) << 8) | ((tmp >> 8) & 0x00FF00FF);
-      }
-    while (--count);
-}
+  do
+    {
+      tmp = *x;
+      tmp = (tmp << 16) | (tmp >> 16);
+      *x++ = ((tmp & 0x00FF00FF) << 8) | ((tmp >> 8) & 0x00FF00FF);
+    }
+  while (--count);
+}
+#endif

 #if BF_SCALE
 /* Architectures which can shift addresses left by 2 bits with no extra cost */


The #error message must match a very specific regexp (see mkdef.pl, currently line 470).

--- crypto/ec/ec.h
+++ crypto/ec/ec.h
@@ -57,7 +57,7 @@
 #define HEADER_EC_H

 #ifdef OPENSSL_NO_EC
-#error Elliptic curves are disabled.
+#error EC is disabled.
 #endif

 #include <openssl/bn.h>


crypto: seqiv - Ensure that IV size is at least 8 bytes

Since seqiv is designed for IPsec we need to be able to accomodate
the whole IPsec sequence number in order to ensure the uniqueness
of the IV.

This patch forbids any algorithm with an IV size of less than 8
from using it.  This should have no impact on existing users since
they all have an IV size of 8.

Reported-by: Maciej ?enczykowski <23d77e835500d7cc667a641ad107cf75562cea0c@gmail.com>
Signed-off-by: Herbert Xu <ef65de1c7be0aa837fe7b25ba9a7739905af6a55@gondor.apana.org.au>
Acked-by: Maciej ?enczykowski <23d77e835500d7cc667a641ad107cf75562cea0c@gmail.com>


trace: remove some magic numbers

trace: remove some magic numbers

Reviewed-by: Paul Dale <bc4a6b4cd7a8395c734c8eb5aef04a9c30188c85@oracle.com>
Reviewed-by: Richard Levitte <5fb523282dd7956571c80524edc2dccfa0bd8234@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8463)

--- crypto/trace.c
+++ crypto/trace.c
@@ -169,18 +169,25 @@
 #endif

 #ifndef OPENSSL_NO_TRACE
+
+enum {
+    CHANNEL,
+    PREFIX,
+    SUFFIX
+};
+
 static int trace_attach_cb(int category, int type, const void *data)
 {
     switch (type) {
-    case 0:                      /* Channel */
+    case CHANNEL:
         OSSL_TRACE2(TRACE, "Attach channel %p to category '%s'\n",
                     data, trace_categories[category].name);
         break;
-    case 1:                      /* Prefix */
+    case PREFIX:
         OSSL_TRACE2(TRACE, "Attach prefix \"%s\" to category '%s'\n",
                     (const char *)data, trace_categories[category].name);
         break;
-    case 2:                      /* Suffix */
+    case SUFFIX:
         OSSL_TRACE2(TRACE, "Attach suffix \"%s\" to category '%s'\n",
                     (const char *)data, trace_categories[category].name);
         break;
@@ -193,15 +200,15 @@
 static int trace_detach_cb(int category, int type, const void *data)
 {
     switch (type) {
-    case 0:                      /* Channel */
+    case CHANNEL:
         OSSL_TRACE2(TRACE, "Detach channel %p from category '%s'\n",
                     data, trace_categories[category].name);
         break;
-    case 1:                      /* Prefix */
+    case PREFIX:
         OSSL_TRACE2(TRACE, "Detach prefix \"%s\" from category '%s'\n",
                     (const char *)data, trace_categories[category].name);
         break;
-    case 2:                      /* Suffix */
+    case SUFFIX:
         OSSL_TRACE2(TRACE, "Detach suffix \"%s\" from category '%s'\n",
                     (const char *)data, trace_categories[category].name);
         break;
@@ -222,15 +229,15 @@

     /* Make sure to run the detach callback first on all data */
     if (prefix != NULL && curr_prefix != NULL) {
-        detach_cb(category, 1, curr_prefix);
+        detach_cb(category, PREFIX, curr_prefix);
     }

     if (suffix != NULL && curr_suffix != NULL) {
-        detach_cb(category, 2, curr_suffix);
+        detach_cb(category, SUFFIX, curr_suffix);
     }

     if (channel != NULL && curr_channel != NULL) {
-        detach_cb(category, 0, curr_channel);
+        detach_cb(category, CHANNEL, curr_channel);
     }

     /* After detach callbacks are done, clear data where appropriate */
@@ -268,15 +275,15 @@

     /* Finally, run the attach callback on the new data */
     if (channel != NULL && *channel != NULL) {
-        attach_cb(category, 0, *channel);
+        attach_cb(category, CHANNEL, *channel);
     }

     if (prefix != NULL && *prefix != NULL) {
-        attach_cb(category, 1, *prefix);
+        attach_cb(category, PREFIX, *prefix);
     }

     if (suffix != NULL && *suffix != NULL) {
-        attach_cb(category, 2, *suffix);
+        attach_cb(category, SUFFIX, *suffix);
     }

     return 1;
@@ -332,16 +339,16 @@
 static int trace_attach_w_callback_cb(int category, int type, const void *data)
 {
     switch (type) {
-    case 0:                      /* Channel */
+    case CHANNEL:
         OSSL_TRACE2(TRACE,
                     "Attach channel %p to category '%s' (with callback)\n",
                     data, trace_categories[category].name);
         break;
-    case 1:                      /* Prefix */
+    case PREFIX:
         OSSL_TRACE2(TRACE, "Attach prefix \"%s\" to category '%s'\n",
                     (const char *)data, trace_categories[category].name);
         break;
-    case 2:                      /* Suffix */
+    case SUFFIX:
         OSSL_TRACE2(TRACE, "Attach suffix \"%s\" to category '%s'\n",
                     (const char *)data, trace_categories[category].name);
         break;


trace: fix out-of-bound memory access

trace: fix out-of-bound memory access

When OSSL_trace_get_category_num() is called with an unknown category
name, it returns -1. This case needs to be considered in order to
avoid out-of-bound memory access to the `trace_channels` array.

Reviewed-by: Paul Dale <bc4a6b4cd7a8395c734c8eb5aef04a9c30188c85@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8552)

--- crypto/trace.c
+++ crypto/trace.c
@@ -431,7 +431,8 @@
     int ret = 0;
 #ifndef OPENSSL_NO_TRACE
     category = ossl_trace_get_category(category);
-    ret = trace_channels[category].bio != NULL;
+    if (category >= 0)
+        ret = trace_channels[category].bio != NULL;
 #endif
     return ret;
 }
@@ -443,6 +444,9 @@
     char *prefix = NULL;

     category = ossl_trace_get_category(category);
+    if (category < 0)
+        return NULL;
+
     channel = trace_channels[category].bio;
     prefix = trace_channels[category].prefix;


--- Test/MathLib.h
+++ Test/MathLib.h
@@ -4,6 +4,6 @@
 #ifndef _MATHLIB_
 #define _MATHLIB_

-
+//Make some change to check if new branch is created.

 #endif


refs #5189 fix tests from xstillopen(prepared) "must assert begin was logged" changes

git-svn-id: b5c078ec0b4d3a50497e9dd3081db18a5b4f16e5@45261 c7de825b-a66e-492c-adef-691d508d4ae1

--- ft/tests/test_logcursor.c
+++ ft/tests/test_logcursor.c
@@ -210,7 +210,7 @@
    //xstillopen                's': lsn=10 txnid=7 parent=0 crc=00061816 len=37 <- obsolete
     {
         FILENUMS filenums = {0, NULL};
-        r = toku_log_xstillopen(logger, &lsn, NO_FSYNC, txnid, 0,
+        r = toku_log_xstillopen(logger, &lsn, NO_FSYNC, NULL, txnid, 0,
                                 0, filenums, 0, 0, 0,
                                 ROLLBACK_NONE, ROLLBACK_NONE, ROLLBACK_NONE);
         assert(r==0);


possible compilation fix

possible compilation fix

--- src/store/naive/atomic_items.h
+++ src/store/naive/atomic_items.h
@@ -54,6 +54,7 @@
 class QNameItemImpl : public AtomicItem
 {
   friend class QNamePool;
+  friend class QNamePoolHashSet;

 private:
   xqpStringStore_t  theNamespace;


ui: Export a function that's used by a test.

BUG=90078
TEST=none
TBR=sky

Review URL: http://codereview.chromium.org/9699080

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@126969 0039d316-1c4b-4281-b951-d872f2087c98

--- ui/gfx/mac/nsimage_cache.h
+++ ui/gfx/mac/nsimage_cache.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.

@@ -28,7 +28,7 @@
 UI_EXPORT NSImage* GetCachedImageWithName(NSString* name);

 // Clears the image cache.
-void ClearCachedImages(void);
+UI_EXPORT void ClearCachedImages(void);

 }  // namespace gfx


supervise: set down&ready (D) even on LASTFINISH

Signed-off-by: Olivier Brunel <52c98c6f56e858393e8e050301367f217ae08fd5@jjacky.com>

--- src/supervision/s6-supervise.c
+++ src/supervision/s6-supervise.c
@@ -448,6 +448,12 @@
   finish_x() ;
 }

+static void lastfinish_z (void)
+{
+    finish_z() ;
+    bail ();
+}
+
 static action_t_ref const actions[5][25] =
 {
   { &downtimeout, &nop, &bail, &bail, &bail,
@@ -462,7 +468,7 @@
   { &uptimeout, &lastup_z, &up_d, &nop, &closethem,
     &killa, &killb, &killq, &killh, &killk, &killt, &killi, &kill1, &kill2, &nop, &nop, &killp, &killc, &killy,
     &up_o, &up_d, &nop, &nop, &up_o, &closethem },
-  { &finishtimeout, &bail, &nop, &nop, &closethem,
+  { &finishtimeout, &lastfinish_z, &nop, &nop, &closethem,
     &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop,
     &nop, &nop, &nop, &nop, &nop, &closethem }
 } ;


Added methods to record SPOffsets from LowerFORMAL_ARGUMENTS

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@41525 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Target/Mips/MipsMachineFunction.h
+++ lib/Target/Mips/MipsMachineFunction.h
@@ -14,7 +14,9 @@
 #ifndef MIPS_MACHINE_FUNCTION_INFO_H
 #define MIPS_MACHINE_FUNCTION_INFO_H

+#include "llvm/ADT/VectorExtras.h"
 #include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/MachineFrameInfo.h"

 namespace llvm {

@@ -31,9 +33,34 @@
   /// the Return Address must be saved
   int RAStackOffset;

+  /// MipsFIHolder - Holds a FrameIndex and it's Stack Pointer Offset
+  struct MipsFIHolder {
+
+    int FI;
+    int SPOffset;
+
+    MipsFIHolder(int FrameIndex, int StackPointerOffset)
+      : FI(FrameIndex), SPOffset(StackPointerOffset) {}
+  };
+
+  // On LowerFORMAL_ARGUMENTS the stack size is unknown,
+  // so the Stack Pointer Offset calculation of "not in
+  // register arguments" must be postponed to emitPrologue.
+  SmallVector<MipsFIHolder, 16> FnLoadArgs;
+  bool HasLoadArgs;
+
+  // When VarArgs, we must write registers back to caller
+  // stack, preserving on register arguments. Since the
+  // stack size is unknown on LowerFORMAL_ARGUMENTS,
+  // the Stack Pointer Offset calculation must be
+  // postponed to emitPrologue.
+  SmallVector<MipsFIHolder, 4> FnStoreVarArgs;
+  bool HasStoreVarArgs;
+
 public:
   MipsFunctionInfo(MachineFunction& MF)
-  : FPStackOffset(0), RAStackOffset(0)
+  : FPStackOffset(0), RAStackOffset(0),
+    HasLoadArgs(false), HasStoreVarArgs(false)
   {}

   int getFPStackOffset() const { return FPStackOffset; }
@@ -46,9 +73,32 @@
     return (RAStackOffset > FPStackOffset) ?
            (RAStackOffset) : (FPStackOffset);
   }
+
+  bool hasLoadArgs() const { return HasLoadArgs; }
+  bool hasStoreVarArgs() const { return HasStoreVarArgs; }
+
+  void recordLoadArgsFI(int FI, int SPOffset) {
+    if (!HasLoadArgs) HasLoadArgs=true;
+    FnLoadArgs.push_back(MipsFIHolder(FI, SPOffset));
+  }
+  void recordStoreVarArgsFI(int FI, int SPOffset) {
+    if (!HasStoreVarArgs) HasStoreVarArgs=true;
+    FnStoreVarArgs.push_back(MipsFIHolder(FI, SPOffset));
+  }
+
+  void adjustLoadArgsFI(MachineFrameInfo *MFI) const {
+    if (!hasLoadArgs()) return;
+    for (unsigned i = 0, e = FnLoadArgs.size(); i != e; ++i)
+      MFI->setObjectOffset( FnLoadArgs[i].FI, FnLoadArgs[i].SPOffset );
+  }
+  void adjustStoreVarArgsFI(MachineFrameInfo *MFI) const {
+    if (!hasStoreVarArgs()) return;
+    for (unsigned i = 0, e = FnStoreVarArgs.size(); i != e; ++i)
+      MFI->setObjectOffset( FnStoreVarArgs[i].FI, FnStoreVarArgs[i].SPOffset );
+  }
+
 };

 } // end of namespace llvm

-
-#endif
+#endif // MIPS_MACHINE_FUNCTION_INFO_H


Include what you use in PPCFrameLowering.h

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@362590 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Target/PowerPC/PPCFrameLowering.h
+++ lib/Target/PowerPC/PPCFrameLowering.h
@@ -12,7 +12,6 @@
 #ifndef LLVM_LIB_TARGET_POWERPC_PPCFRAMELOWERING_H
 #define LLVM_LIB_TARGET_POWERPC_PPCFRAMELOWERING_H

-#include "PPC.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/CodeGen/TargetFrameLowering.h"
 #include "llvm/Target/TargetMachine.h"


Remove dead prototype.

Remove dead prototype.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@184173 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Target/R600/AMDGPUTargetMachine.h
+++ lib/Target/R600/AMDGPUTargetMachine.h
@@ -24,8 +24,6 @@
 #include "llvm/IR/DataLayout.h"

 namespace llvm {
-
-MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT);

 class AMDGPUTargetMachine : public LLVMTargetMachine {


Bug fix: Need to include the stack offset "bias" in assembly code itself.
Added class UltraSparcCacheInfo.
Added function to convert float to int by copying via memory.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@1224 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Target/SparcV9/SparcV9Internals.h
+++ lib/Target/SparcV9/SparcV9Internals.h
@@ -16,8 +16,9 @@
 #include "SparcRegClassInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/MachineInstrInfo.h"
+#include "llvm/Target/MachineSchedInfo.h"
 #include "llvm/Target/MachineFrameInfo.h"
-#include "llvm/Target/MachineSchedInfo.h"
+#include "llvm/Target/MachineCacheInfo.h"
 #include "llvm/CodeGen/RegClass.h"
 #include "llvm/Type.h"

@@ -115,13 +116,24 @@
                                       vector<TmpInstruction*>& tempVec) const;

-  // Create an instruction sequence to copy an integer value `val' from an
-  // integer to a floating point register `dest'.  val must be an integral
-  // type.  dest must be a Float or Double.
+  // Create an instruction sequence to copy an integer value `val'
+  // to a floating point value `dest' by copying to memory and back.
+  // val must be an integral type.  dest must be a Float or Double.
   // The generated instructions are returned in `minstrVec'.
   // Any temp. registers (TmpInstruction) created are returned in `tempVec'.
   //
   virtual void  CreateCodeToCopyIntToFloat(Method* method,
+                                           Value* val,
+                                           Instruction* dest,
+                                           vector<MachineInstr*>& minstrVec,
+                                           vector<TmpInstruction*>& tempVec,
+                                           TargetMachine& target) const;
+
+  // Similarly, create an instruction sequence to copy an FP value
+  // `val' to an integer value `dest' by copying to memory and back.
+  // See the previous function for information about return values.
+  //
+  virtual void  CreateCodeToCopyFloatToInt(Method* method,
                                            Value* val,
                                            Instruction* dest,
                                            vector<MachineInstr*>& minstrVec,
@@ -1229,16 +1241,33 @@
   }

 private:
+  // All stack addresses must be offset by 0x7ff (2047) on Sparc V9.
+  static const int OFFSET                                  = (int) 0x7ff;
   static const int StackFrameSizeAlignment                 =  16;
   static const int MinStackFrameSize                       = 176;
   static const int NumFixedOutgoingArgs                    =   6;
   static const int SizeOfEachArgOnStack                    =   8;
-  static const int StaticAreaOffsetFromFP                  =  -1;
-  static const int FirstIncomingArgOffsetFromFP            = 126;
-  static const int FirstOutgoingArgOffsetFromSP            = 128;
-  static const int FirstOptionalOutgoingArgOffsetFromSP    = 176;
-};
-
+  static const int StaticAreaOffsetFromFP                  =  -1 + OFFSET;
+  static const int FirstIncomingArgOffsetFromFP            = 128 + OFFSET;
+  static const int FirstOptionalIncomingArgOffsetFromFP    = 176 + OFFSET;
+  static const int FirstOutgoingArgOffsetFromSP            = 128 + OFFSET;
+  static const int FirstOptionalOutgoingArgOffsetFromSP    = 176 + OFFSET;
+};
+
+
+//---------------------------------------------------------------------------
+// class UltraSparcCacheInfo
+//
+// Purpose:
+//   Interface to cache parameters for the UltraSPARC.
+//   Just use defaults for now.
+//---------------------------------------------------------------------------
+
+class UltraSparcCacheInfo: public MachineCacheInfo {
+public:
+  /*ctor*/          UltraSparcCacheInfo  (const TargetMachine& target) :
+    MachineCacheInfo(target) {}
+};

 //---------------------------------------------------------------------------
@@ -1257,6 +1286,7 @@
   UltraSparcSchedInfo schedInfo;
   UltraSparcRegInfo   regInfo;
   UltraSparcFrameInfo frameInfo;
+  UltraSparcCacheInfo cacheInfo;
 public:
   UltraSparc();
   virtual ~UltraSparc() {}
@@ -1265,6 +1295,7 @@
   virtual const MachineSchedInfo &getSchedInfo() const { return schedInfo; }
   virtual const MachineRegInfo   &getRegInfo()   const { return regInfo; }
   virtual const MachineFrameInfo &getFrameInfo() const { return frameInfo; }
+  virtual const MachineCacheInfo &getCacheInfo() const { return cacheInfo; }

   // compileMethod - For the sparc, we do instruction selection, followed by
   // delay slot scheduling, then register allocation.


digest::sha2: memory initialization bugs fixed

--- lib/extensions/digest-sha2/ext/sha2.c
+++ lib/extensions/digest-sha2/ext/sha2.c
@@ -632,7 +632,7 @@
 	}

 	/* Clean up state data: */
-	MEMSET_BZERO(context, sizeof(context));
+    MEMSET_BZERO(context, sizeof(*context));
 	usedspace = 0;
 }

@@ -652,7 +652,7 @@
 		}
 		*buffer = (char)0;
 	} else {
-		MEMSET_BZERO(context, sizeof(context));
+        MEMSET_BZERO(context, sizeof(*context));
 	}
 	MEMSET_BZERO(digest, SHA256_DIGEST_LENGTH);
 	return buffer;
@@ -961,7 +961,7 @@
 	}

 	/* Zero out state data */
-	MEMSET_BZERO(context, sizeof(context));
+    MEMSET_BZERO(context, sizeof(*context));
 }

 char *SHA512_End(SHA512_CTX* context, char buffer[]) {
@@ -980,7 +980,7 @@
 		}
 		*buffer = (char)0;
 	} else {
-		MEMSET_BZERO(context, sizeof(context));
+        MEMSET_BZERO(context, sizeof(*context));
 	}
 	MEMSET_BZERO(digest, SHA512_DIGEST_LENGTH);
 	return buffer;
@@ -1035,7 +1035,7 @@
 	}

 	/* Zero out state data */
-	MEMSET_BZERO(context, sizeof(context));
+    MEMSET_BZERO(context, sizeof(*context));
 }

 char *SHA384_End(SHA384_CTX* context, char buffer[]) {
@@ -1054,7 +1054,7 @@
 		}
 		*buffer = (char)0;
 	} else {
-		MEMSET_BZERO(context, sizeof(context));
+        MEMSET_BZERO(context, sizeof(*context));
 	}
 	MEMSET_BZERO(digest, SHA384_DIGEST_LENGTH);
 	return buffer;


Update lua_api.h

Update lua_api.h

--- src/map/include/lua_api.h
+++ src/map/include/lua_api.h
@@ -12,6 +12,11 @@
         bool on_init() { return safe_lua_call<bool>("OnInit"); }
         bool on_create() { return safe_lua_call<bool>("OnCreate"); }
         bool on_delete() { return safe_lua_call<bool>("OnDelete"); }
+
+        template <typename T, typename... Args>
+        void register_function(const std::string& name, std::function<T(Args...)>&& func) {
+            env.set_function(name, std::forward<std::function<T(Args...)>>(func));
+        }

     protected:
         template <typename T, typename... Args>
@@ -48,6 +53,14 @@
         bool on_drop(RoseCommon::Entity entity) { return safe_lua_call<bool>("OnDrop", entity); }
         bool on_pickup(RoseCommon::Entity entity) { return safe_lua_call<bool>("OnPickup", entity); }
         bool on_use(RoseCommon::Entity entity) { return safe_lua_call<bool>("OnUse", entity); }
+
+        void register_add_bonus_attr(std::function<void(RoseCommon::Entity, int, int)>&& func) {
+            register_function("addBonusAttr", std::forward<decltype(func)>(func));
+        }
+
+        void register_remove_bonus_attr(std::function<void(RoseCommon::Entity, int, int)>&& func) {
+            register_function("removeBonusAttr", std::forward<decltype(func)>(func));
+        }
 };

 class NpcLuaApi : public LuaApi {


gobex: Refactor transfer unit test IO callbacks

--- unit/test-gobex-transfer.c
+++ unit/test-gobex-transfer.c
@@ -81,12 +81,19 @@
 	return FALSE;
 }

+struct test_buf {
+	const void *data;
+	gssize len;
+};
+
 struct test_data {
 	guint count;
 	GError *err;
+	struct test_buf recv[3];
+	struct test_buf send[3];
 };

-static gboolean put_srv(GIOChannel *io, GIOCondition cond, gpointer user_data)
+static gboolean io_cb(GIOChannel *io, GIOCondition cond, gpointer user_data)
 {
 	struct test_data *d = user_data;
 	GIOStatus status;
@@ -94,30 +101,23 @@
 	char buf[255];
 	const char *send_buf, *expect;

+	expect = d->recv[d->count].data;
+	expect_len = d->recv[d->count].len;
+	send_buf = d->send[d->count].data;
+	send_buf_len = d->send[d->count].len;
+
 	d->count++;
-
-	if (d->count > 1) {
-		send_buf = (const char *) put_rsp_last;
-		send_buf_len = sizeof(put_rsp_last);
-		expect = (const char *) put_req_last;
-		expect_len = sizeof(put_req_last);
-	} else {
-		send_buf = (const char *) put_rsp_first;
-		send_buf_len = sizeof(put_rsp_first);
-		expect = (const char *) put_req_first;
-		expect_len = sizeof(put_req_first);
-	}

 	status = g_io_channel_read_chars(io, buf, sizeof(buf), &rbytes, NULL);
 	if (status != G_IO_STATUS_NORMAL) {
-		g_print("put_srv count %u\n", d->count);
+		g_print("io_cb count %u\n", d->count);
 		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
 				"Reading data failed with status %d", status);
 		goto failed;
 	}

 	if (rbytes < expect_len) {
-		g_print("put_srv count %u\n", d->count);
+		g_print("io_cb count %u\n", d->count);
 		dump_bufs(expect, expect_len, buf, rbytes);
 		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
 					"Not enough data from socket");
@@ -125,7 +125,7 @@
 	}

 	if (memcmp(buf, expect, expect_len) != 0) {
-		g_print("put_srv count %u\n", d->count);
+		g_print("io_cb count %u\n", d->count);
 		dump_bufs(expect, expect_len, buf, rbytes);
 		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
 					"Received data is not correct");
@@ -135,7 +135,7 @@
 	g_io_channel_write_chars(io, send_buf, send_buf_len, &bytes_written,
 									NULL);
 	if (bytes_written != send_buf_len) {
-		g_print("put_srv count %u\n", d->count);
+		g_print("io_cb count %u\n", d->count);
 		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
 						"Unable to write to socket");
 		goto failed;
@@ -183,12 +183,16 @@
 	GIOCondition cond;
 	guint io_id, timer_id;
 	GObex *obex;
-	struct test_data d = { 0, NULL };
+	struct test_data d = { 0, NULL, {
+				{ put_req_first, sizeof(put_req_first) },
+				{ put_req_last, sizeof(put_req_last) } }, {
+				{ put_rsp_first, sizeof(put_rsp_first) },
+				{ put_rsp_last, sizeof(put_rsp_last) } } };

 	create_endpoints(&obex, &io, SOCK_STREAM);

 	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
-	io_id = g_io_add_watch(io, cond, put_srv, &d);
+	io_id = g_io_add_watch(io, cond, io_cb, &d);

 	mainloop = g_main_loop_new(NULL, FALSE);

@@ -247,83 +251,22 @@
 		g_main_loop_quit(mainloop);
 }

-static gboolean put_cli(GIOChannel *io, GIOCondition cond, gpointer user_data)
-{
-	struct test_data *d = user_data;
-	GIOStatus status;
-	gsize bytes_written, rbytes, send_buf_len, expect_len;
-	char buf[255];
-	const char *send_buf, *expect;
-
-	d->count++;
-
-	if (d->count > 1) {
-		expect = (const char *) put_rsp_last;
-		expect_len = sizeof(put_rsp_last);
-		send_buf = NULL;
-		send_buf_len = 0;
-	} else {
-		expect = (const char *) put_rsp_first;
-		expect_len = sizeof(put_rsp_first);
-		send_buf = (const char *) put_req_last;
-		send_buf_len = sizeof(put_req_last);
-	}
-
-	status = g_io_channel_read_chars(io, buf, sizeof(buf), &rbytes, NULL);
-	if (status != G_IO_STATUS_NORMAL) {
-		g_print("put_cli count %u\n", d->count);
-		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
-				"Reading data failed with status %d", status);
-		goto failed;
-	}
-
-	if (rbytes < expect_len) {
-		g_print("put_cli count %u\n", d->count);
-		dump_bufs(expect, expect_len, buf, rbytes);
-		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
-					"Not enough data from socket");
-		goto failed;
-	}
-
-	if (memcmp(buf, expect, expect_len) != 0) {
-		g_print("put_cli count %u\n", d->count);
-		dump_bufs(expect, expect_len, buf, rbytes);
-		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
-					"Received data is not correct");
-		goto failed;
-	}
-
-	if (send_buf == NULL)
-		return TRUE;
-
-	g_io_channel_write_chars(io, send_buf, send_buf_len, &bytes_written,
-									NULL);
-	if (bytes_written != send_buf_len) {
-		g_print("put_cli count %u\n", d->count);
-		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
-						"Unable to write to socket");
-		goto failed;
-	}
-
-	return TRUE;
-
-failed:
-	g_main_loop_quit(mainloop);
-	return FALSE;
-}
-
 static void test_put_rsp(void)
 {
 	GIOChannel *io;
 	GIOCondition cond;
 	guint io_id, timer_id;
 	GObex *obex;
-	struct test_data d = { 0, NULL };
+	struct test_data d = { 0, NULL, {
+				{ put_rsp_first, sizeof(put_rsp_first) },
+				{ put_rsp_last, sizeof(put_rsp_last) } }, {
+				{ put_req_last, sizeof(put_req_last) },
+				{ NULL, 0 } } };

 	create_endpoints(&obex, &io, SOCK_STREAM);

 	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
-	io_id = g_io_add_watch(io, cond, put_cli, &d);
+	io_id = g_io_add_watch(io, cond, io_cb, &d);

 	mainloop = g_main_loop_new(NULL, FALSE);

@@ -348,80 +291,22 @@
 	g_assert_no_error(d.err);
 }

-static gboolean get_srv(GIOChannel *io, GIOCondition cond, gpointer user_data)
-{
-	struct test_data *d = user_data;
-	GIOStatus status;
-	gsize bytes_written, rbytes, send_buf_len, expect_len;
-	char buf[255];
-	const char *send_buf, *expect;
-
-	d->count++;
-
-	if (d->count > 1) {
-		send_buf = (const char *) get_rsp_last;
-		send_buf_len = sizeof(get_rsp_last);
-		expect = (const char *) get_req_last;
-		expect_len = sizeof(get_req_last);
-	} else {
-		send_buf = (const char *) get_rsp_first;
-		send_buf_len = sizeof(get_rsp_first);
-		expect = (const char *) get_req_first;
-		expect_len = sizeof(get_req_first);
-	}
-
-	status = g_io_channel_read_chars(io, buf, sizeof(buf), &rbytes, NULL);
-	if (status != G_IO_STATUS_NORMAL) {
-		g_print("put_srv count %u\n", d->count);
-		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
-				"Reading data failed with status %d", status);
-		goto failed;
-	}
-
-	if (rbytes < expect_len) {
-		g_print("put_srv count %u\n", d->count);
-		dump_bufs(expect, expect_len, buf, rbytes);
-		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
-					"Not enough data from socket");
-		goto failed;
-	}
-
-	if (memcmp(buf, expect, expect_len) != 0) {
-		g_print("put_srv count %u\n", d->count);
-		dump_bufs(expect, expect_len, buf, rbytes);
-		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
-					"Received data is not correct");
-		goto failed;
-	}
-
-	g_io_channel_write_chars(io, send_buf, send_buf_len, &bytes_written,
-									NULL);
-	if (bytes_written != send_buf_len) {
-		g_print("put_srv count %u\n", d->count);
-		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
-						"Unable to write to socket");
-		goto failed;
-	}
-
-	return TRUE;
-
-failed:
-	g_main_loop_quit(mainloop);
-	return FALSE;
-}
-
 static void test_get_req(void)
 {
 	GIOChannel *io;
 	GIOCondition cond;
 	guint io_id, timer_id;
 	GObex *obex;
-	struct test_data d = { 0, NULL };
+	struct test_data d = { 0, NULL, {
+				{ get_req_first, sizeof(get_req_first) },
+				{ get_req_last, sizeof(get_req_last) } }, {
+				{ get_rsp_first, sizeof(get_rsp_first) },
+				{ get_rsp_last, sizeof(get_rsp_last) } } };

 	create_endpoints(&obex, &io, SOCK_STREAM);

 	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
-	io_id = g_io_add_watch(io, cond, get_srv, &d);
+	io_id = g_io_add_watch(io, cond, io_cb, &d);

 	mainloop = g_main_loop_new(NULL, FALSE);

@@ -442,71 +327,6 @@
 	g_obex_unref(obex);

 	g_assert_no_error(d.err);
-}
-
-static gboolean get_cli(GIOChannel *io, GIOCondition cond, gpointer user_data)
-{
-	struct test_data *d = user_data;
-	GIOStatus status;
-	gsize bytes_written, rbytes, send_buf_len, expect_len;
-	char buf[255];
-	const char *send_buf, *expect;
-
-	d->count++;
-
-	if (d->count > 1) {
-		expect = (const char *) get_rsp_last;
-		expect_len = sizeof(get_rsp_last);
-		send_buf = NULL;
-		send_buf_len = 0;
-	} else {
-		expect = (const char *) get_rsp_first;
-		expect_len = sizeof(get_rsp_first);
-		send_buf = (const char *) get_req_last;
-		send_buf_len = sizeof(get_req_last);
-	}
-
-	status = g_io_channel_read_chars(io, buf, sizeof(buf), &rbytes, NULL);
-	if (status != G_IO_STATUS_NORMAL) {
-		g_print("get_cli count %u\n", d->count);
-		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
-				"Reading data failed with status %d", status);
-		goto failed;
-	}
-
-	if (rbytes < expect_len) {
-		g_print("get_cli count %u\n", d->count);
-		dump_bufs(expect, expect_len, buf, rbytes);
-		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
-					"Not enough data from socket");
-		goto failed;
-	}
-
-	if (memcmp(buf, expect, expect_len) != 0) {
-		g_print("get_cli count %u\n", d->count);
-		dump_bufs(expect, expect_len, buf, rbytes);
-		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
-					"Received data is not correct");
-		goto failed;
-	}
-
-	if (send_buf == NULL)
-		return TRUE;
-
-	g_io_channel_write_chars(io, send_buf, send_buf_len, &bytes_written,
-									NULL);
-	if (bytes_written != send_buf_len) {
-		g_print("get_cli count %u\n", d->count);
-		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
-						"Unable to write to socket");
-		goto failed;
-	}
-
-	return TRUE;
-
-failed:
-	g_main_loop_quit(mainloop);
-	return FALSE;
 }

 static void handle_get(GObex *obex, GObexPacket *req, gpointer user_data)
@@ -534,12 +354,16 @@
 	GIOCondition cond;
 	guint io_id, timer_id;
 	GObex *obex;
-	struct test_data d = { 0, NULL };
+	struct test_data d = { 0, NULL, {
+				{ get_rsp_first, sizeof(get_rsp_first) },
+				{ get_rsp_last, sizeof(get_rsp_last) } }, {
+				{ get_req_last, sizeof(get_req_last) },
+				{ NULL, 0 } } };

 	create_endpoints(&obex, &io, SOCK_STREAM);

 	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
-	io_id = g_io_add_watch(io, cond, get_cli, &d);
+	io_id = g_io_add_watch(io, cond, io_cb, &d);

 	mainloop = g_main_loop_new(NULL, FALSE);


cribbage_score.c: docs

cribbage_score.c: docs

--- cribbage_score.c
+++ cribbage_score.c
@@ -16,8 +16,26 @@
            face_counts[4][0],face_counts[4][1]);
 }

-static const score_t PAIR_SCORES[5] = {0, 0, 2, 6, 12};
+/*
+ * The values of having a set of card face_values of the given size:
+ * 0 of a kind - 0 points
+ * 1 of a kind - 0 points
+ * 2 of a kind - 2 points
+ * 3 of a kind - 6 points (2 x 3)
+ * 4 of a kind - 12 points (3 x 4)
+ */
+static const score_t PAIR_SCORES[5] = { 0, 0, 2, 6, 12 };
+
+/*
+ * The values of each face_value, for adding up to 15.
+ */
 static const score_t CARD_VALUES[13] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10 };
+
+/*
+ * The ways to combine two or more cards from a set of five cards,
+ * specified in indices into a 5-element array.
+ * 0xFF indicates a blank.
+ */
 static const int NUM_COMBINATIONS = 26;
 static const unsigned char COMBINATIONS[NUM_COMBINATIONS][5] = {
     { 0, 1, 0xFF, 0xFF, 0xFF },
@@ -48,6 +66,14 @@
     { 0, 1, 2, 3, 4 },
 };

+/*
+ * Scores a cribbage hand.
+ *
+ * Hand is specified with card values card1 through card4; the draw
+ * card is given in draw_card.
+ *
+ * Returns the number of points to score for the given hand and draw.
+ */
 score_t score_hand(card_t card1, card_t card2, card_t card3, card_t card4, card_t draw_card)
 {
     // sanity check


Move param.h before systm.h so vax macros are picked up properly.

--- crypto/deflate.c
+++ crypto/deflate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: deflate.c,v 1.2 2001/07/05 17:52:59 deraadt Exp $ */
+/* $OpenBSD: deflate.c,v 1.3 2001/08/20 02:45:22 hugh Exp $ */

 /*
  * Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org)
@@ -34,8 +34,8 @@

 #include <sys/types.h>
 #include <sys/malloc.h>
+#include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/param.h>
 #include <net/zlib.h>
 #include <crypto/deflate.h>


Fix windows build

Fix windows build

Move #include's inside the #ifdef.

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

--- crypto/sec_mem.c
+++ crypto/sec_mem.c
@@ -12,13 +12,13 @@
  */
 #include <openssl/crypto.h>
 #include <e_os.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <assert.h>

 #if defined(OPENSSL_SYS_LINUX) || defined(OPENSSL_SYS_UNIX)
 # define IMPLEMENTED
+# include <stdlib.h>
+# include <string.h>
+# include <assert.h>
+# include <unistd.h>
 # include <sys/mman.h>
 # include <sys/param.h>
 #endif


crypto: testmgr - add test vector for fcrypt

fcrypt is used only as pcbc(fcrypt), but testmgr does not know this.
Use the zero key, zero plaintext pcbc(fcrypt) test vector for
testing plain 'fcrypt' to hide "no test for fcrypt" warnings.

Signed-off-by: Jussi Kivilinna <1f0aa498f7c1bee2bd6061b97aca51d7b122cec0@mbnet.fi>
Acked-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>
Signed-off-by: Herbert Xu <ef65de1c7be0aa837fe7b25ba9a7739905af6a55@gondor.apana.org.au>

--- crypto/testmgr.c
+++ crypto/testmgr.c
@@ -2269,6 +2269,21 @@
 			}
 		}
 	}, {
+		.alg = "ecb(fcrypt)",
+		.test = alg_test_skcipher,
+		.suite = {
+			.cipher = {
+				.enc = {
+					.vecs = fcrypt_pcbc_enc_tv_template,
+					.count = 1
+				},
+				.dec = {
+					.vecs = fcrypt_pcbc_dec_tv_template,
+					.count = 1
+				}
+			}
+		}
+	}, {
 		.alg = "ecb(khazad)",
 		.test = alg_test_skcipher,
 		.suite = {


imap_logout_format setting wasn't passed to imap process.

--- src/master/mail-process.c
+++ src/master/mail-process.c
@@ -308,6 +308,8 @@
 		}
 		env_put(t_strconcat("IMAP_CLIENT_WORKAROUNDS=",
 				    set->imap_client_workarounds, NULL));
+		env_put(t_strconcat("IMAP_LOGOUT_FORMAT=",
+				    set->imap_logout_format, NULL));
 	}
 	if (set->protocol == MAIL_PROTOCOL_POP3) {
 		env_put(t_strconcat("POP3_CLIENT_WORKAROUNDS=",


Comment on abstract-polling-reporter to handle the shutdown followed by start racing to modify thread before it can be joined, it is not a valid usecase anyway, so handling it thru comment.

--- src/medida/reporting/abstract_polling_reporter.h
+++ src/medida/reporting/abstract_polling_reporter.h
@@ -20,6 +20,8 @@

             virtual void Shutdown();

+            // start should never be called after calling shutdown on this class
+            //    (behavior if start after shutdown is undefined).
             virtual void Start(Clock::duration period = std::chrono::seconds(5));

             virtual void Run();


msm: camera2: cpp: Release vb2 buffer in cpp driver on error

When duplicate output is enabled, there is potential issue if
error is encountered in second output buffer. Under error condition
related to second output buffer is hit, the first output buffer is
not released properly.

Change-Id: I56f375a5783c54c450f5673818d15b393f469ef1
Signed-off-by: Rajakumar Govindaram <aab05e6259de3a52b162d43c59fd49d810c4daac@codeaurora.org>

--- drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c
+++ drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c
@@ -1225,7 +1225,7 @@
 	uint32_t *cpp_frame_msg;
 	unsigned long in_phyaddr, out_phyaddr0, out_phyaddr1;
 	uint16_t num_stripes = 0;
-	struct msm_buf_mngr_info buff_mgr_info;
+	struct msm_buf_mngr_info buff_mgr_info, dup_buff_mgr_info;
 	struct msm_cpp_frame_info_t *u_frame_info =
 		(struct msm_cpp_frame_info_t *)ioctl_ptr->ioctl_ptr;
 	int32_t status = 0;
@@ -1317,19 +1317,20 @@
 			new_frame->duplicate_identity);
 		memset(&new_frame->output_buffer_info[1], 0,
 			sizeof(struct msm_cpp_buffer_info_t));
-		memset(&buff_mgr_info, 0, sizeof(struct msm_buf_mngr_info));
-		buff_mgr_info.session_id =
+		memset(&dup_buff_mgr_info, 0, sizeof(struct msm_buf_mngr_info));
+		dup_buff_mgr_info.session_id =
 			((new_frame->duplicate_identity >> 16) & 0xFFFF);
-		buff_mgr_info.stream_id =
+		dup_buff_mgr_info.stream_id =
 			(new_frame->duplicate_identity & 0xFFFF);
 		rc = msm_cpp_buffer_ops(cpp_dev, VIDIOC_MSM_BUF_MNGR_GET_BUF,
-			&buff_mgr_info);
+			&dup_buff_mgr_info);
 		if (rc < 0) {
 			rc = -EAGAIN;
 			pr_debug("error getting buffer rc:%d\n", rc);
-			goto ERROR2;
-		}
-		new_frame->output_buffer_info[1].index = buff_mgr_info.index;
+			goto ERROR3;
+		}
+		new_frame->output_buffer_info[1].index =
+			dup_buff_mgr_info.index;
 		out_phyaddr1 = msm_cpp_fetch_buffer_info(cpp_dev,
 			&new_frame->output_buffer_info[1],
 			((new_frame->duplicate_identity >> 16) & 0xFFFF),
@@ -1338,6 +1339,8 @@
 		if (!out_phyaddr1) {
 			pr_err("error gettting output physical address\n");
 			rc = -EINVAL;
+			msm_cpp_buffer_ops(cpp_dev, VIDIOC_MSM_BUF_MNGR_PUT_BUF,
+				&dup_buff_mgr_info);
 			goto ERROR3;
 		}
 		/* set duplicate enable bit */


i965: Fix assertion for surface tile offset usage on Ironlake.

Fixes assertion failure in fbo-generatemipmap-npot.

--- src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -588,7 +588,7 @@
 	    tile_base = ((key.draw_y / 32) * (32 * pitch));
 	    tile_base += (key.draw_x - tile_x) / (128 / key.cpp) * 4096;
 	 }
-	 assert(intel->is_g4x || (tile_x == 0 && tile_y == 0));
+	 assert(brw->has_surface_tile_offset || (tile_x == 0 && tile_y == 0));
 	 assert(tile_x % 4 == 0);
 	 assert(tile_y % 2 == 0);
 	 /* Note that the low bits of these fields are missing, so


From: Hayashi Naoyuki

From: Hayashi Naoyuki

I tried to compile with gcc on Tru64, and got the following error.
SDL_systimer.c:45:45: error: operator '&&' has no right operand

It succeeds if changing
#if (defined _POSIX_TIMERS && _POSIX_TIMERS > 0)
to
#if (defined _POSIX_TIMERS && _POSIX_TIMERS + 0 > 0)

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401329

--- src/timer/linux/SDL_systimer.c
+++ src/timer/linux/SDL_systimer.c
@@ -34,7 +34,7 @@
    for __USE_POSIX199309
    Tommi Kyntola (tommi.kyntola@ray.fi) 27/09/2005
 */
-#if (defined _POSIX_TIMERS && _POSIX_TIMERS > 0)
+#if (defined _POSIX_TIMERS && _POSIX_TIMERS + 0 > 0)
 #include <time.h>
 /*
  * clock_gettime() is missing in my system's glibc, and apparently isn't


Had missed a call to updateConfig that should have been updateConfigInternal. Was causing unnecessary scary warning.

--HG--
extra : convert_revision : svn%3Aeb33c2ac-9c88-4c90-87e0-44a10359b0c3/stacks/driver_common/trunk%4027346

--- dynamic_reconfigure/include/dynamic_reconfigure/server.h
+++ dynamic_reconfigure/include/dynamic_reconfigure/server.h
@@ -128,7 +128,7 @@
     ConfigType init_config = ConfigType::__getDefault__();
     init_config.__fromServer__(node_handle_);
     init_config.__clamp__();
-    updateConfig(init_config);
+    updateConfigInternal(init_config);
   }

   void callCallback(ConfigType &config, int level)


provide scratch button to start from scratch at the wizard. :)

SVN revision: 74578

--- src/modules/conf_dialogs/e_int_config_profiles.c
+++ src/modules/conf_dialogs/e_int_config_profiles.c
@@ -8,6 +8,7 @@
 static void         _ilist_cb_selected(void *data);
 static void         _cb_add(void *data, void *data2);
 static void         _cb_delete(void *data, void *data2);
+static void         _cb_scratch(void *data, void *data2);
 static void         _cb_reset(void *data, void *data2);
 static void         _cb_dialog_yes(void *data);
 static void         _cb_dialog_destroy(void *data);
@@ -22,6 +23,7 @@
    E_Config_Dialog *cfd;
    Evas_Object     *o_list;
    Evas_Object     *o_delete;
+   Evas_Object     *o_scratch;
    Evas_Object     *o_reset;
    Evas_Object     *o_text;
    Evas_Object     *o_textlabel;
@@ -135,14 +137,18 @@
    cfdata->o_delete = e_widget_button_add(evas, _("Delete"), "list-remove",
                                           _cb_delete, cfdata, NULL);
    e_widget_table_object_append(ot, cfdata->o_delete, 1, 0, 1, 1, 1, 1, 0, 0);
+   cfdata->o_scratch = e_widget_button_add(evas, _("Scratch"), "system-restart",
+                                           _cb_scratch, cfdata, NULL);
+   e_widget_table_object_align_append(ot, cfdata->o_scratch, 2, 0, 1, 1, 0, 1, 1, 1, 0.5, 0.5);
    cfdata->o_reset = e_widget_button_add(evas, _("Reset"), "system-restart",
                                          _cb_reset, cfdata, NULL);
-   e_widget_table_object_align_append(ot, cfdata->o_reset, 2, 0, 1, 1, 0, 1, 1, 1, 1.0, 0.5);
+   e_widget_table_object_align_append(ot, cfdata->o_reset, 3, 0, 1, 1, 0, 1, 1, 1, 1.0, 0.5);

    e_widget_list_object_append(o, of, 1, 1, 0.5);

    // if there is a system version of the profile - allow reset
-   e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s/", e_config_profile_get());
+   e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s/",
+                          e_config_profile_get());
    if (ecore_file_is_dir(buf))
      e_widget_disabled_set(cfdata->o_reset, 0);
    else
@@ -324,6 +330,26 @@
 }

 static void
+_cb_scratch(void *data __UNUSED__, void *data2 __UNUSED__)
+{
+   E_Action *a;
+   char *pdir;
+
+   e_config_save_flush();
+   e_config_save_block_set(1);
+
+   pdir = e_config_profile_dir_get(e_config_profile_get());
+   if (pdir)
+     {
+        ecore_file_recursive_rm(pdir);
+        free(pdir);
+     }
+   e_config_profile_set("default");
+   a = e_action_find("restart");
+   if ((a) && (a->func.go)) a->func.go(NULL, NULL);
+}
+
+static void
 _cb_reset(void *data __UNUSED__, void *data2 __UNUSED__)
 {
    E_Action *a;


fix a case where the encoding buffer was not exchanged

--- src/ua_types_encoding_binary.c
+++ src/ua_types_encoding_binary.c
@@ -515,6 +515,15 @@

     /* Encode the array length */
     UA_StatusCode retval = Int32_encodeBinary(&signed_length);
+
+    /* The buffer limit was reached during encoding of the length */
+    if(retval == UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED) {
+        retval = exchangeBuffer();
+        if(retval == UA_STATUSCODE_GOOD)
+            retval = Int32_encodeBinary(&signed_length);
+    }
+
+    /* Quit early? */
     if(retval != UA_STATUSCODE_GOOD || length == 0)
         return retval;


fix(core): Fix buffer exchange in ExtensionObject encoding

--- src/ua_types_encoding_binary.c
+++ src/ua_types_encoding_binary.c
@@ -408,6 +408,7 @@
         ctx->pos += possible;
         ptr += possible;
         status ret = exchangeBuffer(ctx);
+        UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
         if(ret != UA_STATUSCODE_GOOD)
             return ret;
         memSize -= possible;
@@ -426,6 +427,7 @@
     for(size_t i = 0; i < length; ++i) {
         status ret = encodeWithExchangeBuffer((const void*)ptr, type, ctx);
         ptr += type->memSize;
+        UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
         if(ret != UA_STATUSCODE_GOOD)
             return ret; /* Unrecoverable fail */
     }
@@ -593,6 +595,7 @@
         ret |= ENCODE_DIRECT(&src->namespaceIndex, UInt16);
         if(ret != UA_STATUSCODE_GOOD)
             return ret;
+        /* Can exchange the buffer */
         ret = ENCODE_DIRECT(&src->identifier.string, String);
         UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
         break;
@@ -608,6 +611,7 @@
         ret |= ENCODE_DIRECT(&src->namespaceIndex, UInt16);
         if(ret != UA_STATUSCODE_GOOD)
             return ret;
+        /* Can exchange the buffer */
         ret = ENCODE_DIRECT(&src->identifier.byteString, String); /* ByteString */
         UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
         break;
@@ -685,12 +689,14 @@
     if(src->serverIndex > 0)
         encoding |= UA_EXPANDEDNODEID_SERVERINDEX_FLAG;

-    /* Encode the NodeId */
+    /* Encode the NodeId. Can exchange the buffer. */
     status ret = NodeId_encodeBinaryWithEncodingMask(&src->nodeId, encoding, ctx);
     if(ret != UA_STATUSCODE_GOOD)
         return ret;

-    /* Encode the namespace. */
+    /* Encode the namespace. Internally uses encodeWithExchangeBuffer
+     * everywhere. So it will never return
+     * UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED. */
     if((void*)src->namespaceUri.data > UA_EMPTY_ARRAY_SENTINEL) {
         ret = ENCODE_DIRECT(&src->namespaceUri, String);
         UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
@@ -820,10 +826,12 @@

     /* No content or already encoded content. */
     if(encoding <= UA_EXTENSIONOBJECT_ENCODED_XML) {
+        /* Can exchange the buffer */
         status ret = ENCODE_DIRECT(&src->content.encoded.typeId, NodeId);
         if(ret != UA_STATUSCODE_GOOD)
             return ret;
         ret = encodeWithExchangeBuffer(&encoding, &UA_TYPES[UA_TYPES_BYTE], ctx);
+        UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
         if(ret != UA_STATUSCODE_GOOD)
             return ret;
         switch(src->encoding) {
@@ -831,7 +839,8 @@
             break;
         case UA_EXTENSIONOBJECT_ENCODED_BYTESTRING:
         case UA_EXTENSIONOBJECT_ENCODED_XML:
-            ret = ENCODE_DIRECT(&src->content.encoded.body, String); /* ByteString */
+            /* ByteString in disguise. Array encoding can exchange the buffer */
+            ret = ENCODE_DIRECT(&src->content.encoded.body, String);
             break;
         default:
             ret = UA_STATUSCODE_BADINTERNALERROR;
@@ -845,15 +854,15 @@
         return UA_STATUSCODE_BADENCODINGERROR;

     /* Write the NodeId for the binary encoded type. This could perform a buffer
-     * exchange. */
+     * exchange, but can also return UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED. */
     status ret = ENCODE_DIRECT(&src->content.decoded.type->binaryEncodingId, NodeId);
-    UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
     if(ret != UA_STATUSCODE_GOOD)
         return ret;

     /* Encode the encoding byte */
     encoding = UA_EXTENSIONOBJECT_ENCODED_BYTESTRING;
     ret = encodeWithExchangeBuffer(&encoding, &UA_TYPES[UA_TYPES_BYTE], ctx);
+    UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
     if(ret != UA_STATUSCODE_GOOD)
         return ret;

@@ -864,15 +873,19 @@
         return UA_STATUSCODE_BADENCODINGERROR;
     i32 signed_len = (i32)len;
     ret = encodeWithExchangeBuffer(&signed_len, &UA_TYPES[UA_TYPES_INT32], ctx);
+    UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
     if(ret != UA_STATUSCODE_GOOD)
         return ret;

     /* Encode the content */
-    return encodeWithExchangeBuffer(src->content.decoded.data, contentType, ctx);
+    ret = encodeWithExchangeBuffer(src->content.decoded.data, contentType, ctx);
+    UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
+    return ret;
 }

 static status
-ExtensionObject_decodeBinaryContent(UA_ExtensionObject *dst, const UA_NodeId *typeId, Ctx *ctx) {
+ExtensionObject_decodeBinaryContent(UA_ExtensionObject *dst, const UA_NodeId *typeId,
+                                    Ctx *ctx) {
     /* Lookup the datatype */
     const UA_DataType *type = UA_findDataTypeByBinaryInternal(typeId, ctx);

@@ -967,6 +980,7 @@
     for(size_t i = 0; i < length && ret == UA_STATUSCODE_GOOD; ++i) {
         eo.content.decoded.data = (void*)ptr;
         ret = encodeWithExchangeBuffer(&eo, &UA_TYPES[UA_TYPES_EXTENSIONOBJECT], ctx);
+        UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
         ptr += memSize;
     }
     return ret;
@@ -1008,14 +1022,20 @@
     if(ret != UA_STATUSCODE_GOOD)
         return ret;

-    /* Encode the content */
-    if(!isBuiltin && !isEnum)
+    /* Encode the content. This can exchange the buffer. */
+    if(!isBuiltin && !isEnum) {
+        /* This could return UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED. But we
+         * have not exchanged the buffer so far. */
         ret = Variant_encodeBinaryWrapExtensionObject(src, isArray, ctx);
-    else if(!isArray)
+    } else if(!isArray) {
         ret = encodeWithExchangeBuffer(src->data, src->type, ctx);
-    else
+        UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
+    } else {
         ret = Array_encodeBinary(src->data, src->arrayLength, src->type, ctx);
-    UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
+        UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
+    }
+    if(ret != UA_STATUSCODE_GOOD)
+        return ret;

     /* Encode the array dimensions */
     if(hasDimensions && ret == UA_STATUSCODE_GOOD)
@@ -1232,9 +1252,10 @@
     if(ret != UA_STATUSCODE_GOOD)
         return ret;

-    /* Encode the additional info */
+    /* Encode the additional info. Can exchange the buffer. */
     if(src->hasAdditionalInfo) {
         ret = ENCODE_DIRECT(&src->additionalInfo, String);
+        UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
         if(ret != UA_STATUSCODE_GOOD)
             return ret;
     }
@@ -1242,14 +1263,17 @@
     /* Encode the inner status code */
     if(src->hasInnerStatusCode) {
         ret = encodeWithExchangeBuffer(&src->innerStatusCode, &UA_TYPES[UA_TYPES_UINT32], ctx);
+        UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
         if(ret != UA_STATUSCODE_GOOD)
             return ret;
     }

     /* Encode the inner diagnostic info */
-    if(src->hasInnerDiagnosticInfo)
+    if(src->hasInnerDiagnosticInfo) {
         ret = encodeWithExchangeBuffer(src->innerDiagnosticInfo,
                                        &UA_TYPES[UA_TYPES_DIAGNOSTICINFO], ctx);
+        UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
+    }

     return ret;
 }
@@ -1304,6 +1328,10 @@
     }
     return ret;
 }
+
+/********************/
+/* Structured Types */
+/********************/

 static status
 encodeBinaryStruct(const void *src, const UA_DataType *type, Ctx *ctx) {
@@ -1326,15 +1354,16 @@
             const size_t length = *((const size_t*)ptr);
             ptr += sizeof(size_t);
             ret = Array_encodeBinary(*(void *UA_RESTRICT const *)ptr, length, mt, ctx);
+            UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
             ptr += sizeof(void*);
             continue;
         }

         /* Scalar */
         ret = encodeWithExchangeBuffer((const void*)ptr, mt, ctx);
+        UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
         ptr += mt->memSize;
     }
-    UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);

     ctx->depth--;
     return ret;
@@ -1372,7 +1401,7 @@
     }

     /* Encode the mask */
-    status ret = UInt32_encodeBinary(&encodingMask, &UA_TYPES[UA_TYPES_UINT32], ctx);
+    status ret = ENCODE_DIRECT(&encodingMask, UInt32);
     if(ret != UA_STATUSCODE_GOOD) {
         ctx->depth--;
         return ret;
@@ -1452,10 +1481,6 @@
     (void)src, (void)type, (void)ctx;
     return UA_STATUSCODE_BADNOTIMPLEMENTED;
 }
-
-/********************/
-/* Structured Types */
-/********************/

 const encodeBinarySignature encodeBinaryJumpTable[UA_DATATYPEKINDS] = {
     (encodeBinarySignature)Boolean_encodeBinary,


Date: Wed, 1 Mar 2006 23:52:09 +0100
From: Sam Hocevar
Subject: [SDL] [patch] aalib driver

   Hi there. The attached patch fixes a buffer overflow in the aalib
driver and also adds a workaround for a conflict between arrow keys and
the numeric keypad that have the same scancode on aalib. The patch gives
precedence to the arrow keys.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401462

--- src/video/aalib/SDL_aaevents.c
+++ src/video/aalib/SDL_aaevents.c
@@ -126,12 +126,6 @@
 	for ( i=0; i<SDL_arraysize(keymap); ++i )
 		keymap[i] = SDLK_UNKNOWN;

-	keymap[AA_ESC] = SDLK_ESCAPE;
-	keymap[AA_UP] = SDLK_UP;
-	keymap[AA_DOWN] = SDLK_DOWN;
-	keymap[AA_LEFT] = SDLK_LEFT;
-	keymap[AA_RIGHT] = SDLK_RIGHT;
-
 	/* Alphabet keys */
 	for ( i = 0; i<26; ++i ){
 		keymap['a' + i] = SDLK_a+i;
@@ -179,10 +173,20 @@
 	keymap[293] = SDLK_KP7;
 	keymap[295] = SDLK_KP8;
 	keymap[298] = SDLK_KP9;
+
+	keymap[AA_ESC] = SDLK_ESCAPE;
+	keymap[AA_UP] = SDLK_UP;
+	keymap[AA_DOWN] = SDLK_DOWN;
+	keymap[AA_LEFT] = SDLK_LEFT;
+	keymap[AA_RIGHT] = SDLK_RIGHT;
 }

 static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym)
 {
+	/* Sanity check */
+	if ( scancode >= SDL_arraysize(keymap) )
+		scancode = AA_UNKNOWN;
+
 	/* Set the keysym information */
 	keysym->scancode = scancode;
 	keysym->sym = keymap[scancode];


mesa: added _mesa_clone_vertex/fragment_program()

To reduce casting elsewhere...

--- src/mesa/shader/program.h
+++ src/mesa/shader/program.h
@@ -108,6 +108,22 @@
 extern struct gl_program *
 _mesa_clone_program(GLcontext *ctx, const struct gl_program *prog);

+static INLINE struct gl_vertex_program *
+_mesa_clone_vertex_program(GLcontext *ctx,
+                           const struct gl_vertex_program *prog)
+{
+   return (struct gl_vertex_program *) _mesa_clone_program(ctx, &prog->Base);
+}
+
+
+static INLINE struct gl_fragment_program *
+_mesa_clone_fragment_program(GLcontext *ctx,
+                             const struct gl_fragment_program *prog)
+{
+   return (struct gl_fragment_program *) _mesa_clone_program(ctx, &prog->Base);
+}
+
+
 extern  GLboolean
 _mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count);


s/getenv/_mesa_getenv/

--- src/mesa/x86/common_x86.c
+++ src/mesa/x86/common_x86.c
@@ -1,9 +1,8 @@
-
 /*
  * Mesa 3-D graphics library
- * Version:  5.0
- *
- * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
+ * Version:  6.0.1
+ *
+ * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -32,8 +31,7 @@
  * new Katmai functions.
  */

-#include <stdlib.h>
-#include <stdio.h>
+/* XXX these includes should probably go into imports.h or glheader.h */
 #if defined(USE_SSE_ASM) && defined(__linux__)
 #include <signal.h>
 #endif
@@ -63,7 +61,7 @@
 #ifdef DEBUG
    debug = GL_TRUE;
 #else
-   if ( getenv( "MESA_DEBUG" ) ) {
+   if ( _mesa_getenv( "MESA_DEBUG" ) ) {
       debug = GL_TRUE;
    } else {
       debug = GL_FALSE;
@@ -320,7 +318,7 @@

    }

-   if ( getenv( "MESA_NO_ASM" ) ) {
+   if ( _mesa_getenv( "MESA_NO_ASM" ) ) {
       _mesa_x86_cpu_features = 0;
    }

@@ -330,7 +328,7 @@

 #ifdef USE_MMX_ASM
    if ( cpu_has_mmx ) {
-      if ( getenv( "MESA_NO_MMX" ) == 0 ) {
+      if ( _mesa_getenv( "MESA_NO_MMX" ) == 0 ) {
          message( "MMX cpu detected.\n" );
       } else {
          _mesa_x86_cpu_features &= ~(X86_FEATURE_MMX);
@@ -340,7 +338,7 @@

 #ifdef USE_3DNOW_ASM
    if ( cpu_has_3dnow ) {
-      if ( getenv( "MESA_NO_3DNOW" ) == 0 ) {
+      if ( _mesa_getenv( "MESA_NO_3DNOW" ) == 0 ) {
          message( "3DNow! cpu detected.\n" );
          _mesa_init_3dnow_transform_asm();
       } else {
@@ -350,11 +348,11 @@
 #endif

 #ifdef USE_SSE_ASM
-   if ( cpu_has_xmm && getenv( "MESA_FORCE_SSE" ) == 0 ) {
+   if ( cpu_has_xmm && _mesa_getenv( "MESA_FORCE_SSE" ) == 0 ) {
       check_os_sse_support();
    }
    if ( cpu_has_xmm ) {
-      if (getenv( "MESA_NO_SSE" ) == 0 ) {
+      if (_mesa_getenv( "MESA_NO_SSE" ) == 0 ) {
          message( "SSE cpu detected.\n" );
          _mesa_init_sse_transform_asm();
       } else {


msg: MMDSBeacon has a private destructor

--- src/messages/MMDSBeacon.h
+++ src/messages/MMDSBeacon.h
@@ -37,7 +37,10 @@
     PaxosServiceMessage(MSG_MDS_BEACON, les),
     fsid(f), global_id(g), name(n), state(st), seq(se),
     standby_for_rank(-1) { }
+private:
+  ~MMDSBeacon() {}

+public:
   ceph_fsid_t& get_fsid() { return fsid; }
   __u64 get_global_id() { return global_id; }
   string& get_name() { return name; }


Added a swap() method.

Added a swap() method.

--- src/mimetypes/qmimetype.h
+++ src/mimetypes/qmimetype.h
@@ -50,6 +50,10 @@
     }
 #endif

+    void swap(QMimeType &other)
+    {
+        qSwap(d, other.d);
+    }
     explicit QMimeType(const QMimeTypeData &dd);
     ~QMimeType();


Update to fix additional errors appearing with invalid WMTS request exception.

--- src/mod_onearth/mod_wms.c
+++ src/mod_onearth/mod_wms.c
@@ -1317,17 +1317,6 @@
 		  ++tilecol;
    }

-	// check for correct time format
-	static char* timearg="time=";
-	char *targ=0;
-	if ((targ=ap_strcasestr(r->args,timearg))) {
-		targ+=5; // Skip the time= part
-		if (!(strlen(targ)==10 || strlen(targ)==0)) {
-			ap_log_error(APLOG_MARK,APLOG_ERR,0,r->server,"Invalid TIME format: %s",targ);
-			wmts_add_error(r,400,"InvalidParameterValue","TIME", "Invalid time format (must be YYYY-MM-DD)");
-		}
-	}
-
 }

 static int mrf_handler(request_rec *r)
@@ -1370,6 +1359,11 @@
   r->args=order_args(r);
   // DEBUG
 //  ap_log_error(APLOG_MARK,APLOG_ERR,0,r->server,"Ordered args: %s",r->args);
+
+  // short-circuit if there is already a problem
+  if (errors > 0) {
+	  return wmts_return_all_errors(r);
+  }

   // Count is the number of caches
   while (count--) {


Roll the larger of the start/end chars first.
This fixes a potential issue when their roll position is the same.

	modified:   src/modules/mirrorfield.c

--- src/modules/mirrorfield.c
+++ src/modules/mirrorfield.c
@@ -276,28 +276,37 @@
 		endRollCharPos = (endRollCharPos + GRID_SIZE) % (GRID_SIZE * 4);
 	}

-	// Characters can't roll to the same position
-	if (startRollCharPos == endRollCharPos) {
-		// do nothing for now...
-	} else {
+	// Roll the larger of the start/end chars first. This only matters if their
+	// roll position is the same.
+	if ((int)perimeterChars[startCharPos] > (int)perimeterChars[endCharPos]) {

 		// Roll start char
 		tempChar = perimeterChars[startCharPos];
 		perimeterChars[startCharPos] = perimeterChars[startRollCharPos];
 		perimeterChars[startRollCharPos] = tempChar;

-		// Remember start position for next char
-		lastStartCharPos = startCharPos;
-
 		// Roll end char
 		tempChar = perimeterChars[endCharPos];
 		perimeterChars[endCharPos] = perimeterChars[endRollCharPos];
 		perimeterChars[endRollCharPos] = tempChar;

-		// Remember end position for next char
-		lastEndCharPos = endCharPos;
-
-	}
+	} else {
+
+		// Roll end char
+		tempChar = perimeterChars[endCharPos];
+		perimeterChars[endCharPos] = perimeterChars[endRollCharPos];
+		perimeterChars[endRollCharPos] = tempChar;
+
+		// Roll start char
+		tempChar = perimeterChars[startCharPos];
+		perimeterChars[startCharPos] = perimeterChars[startRollCharPos];
+		perimeterChars[startRollCharPos] = tempChar;
+	}
+
+	// Remember start/end position for next char
+	lastStartCharPos = startCharPos;
+	lastEndCharPos = endCharPos;
+
 }

 void mirrorfield_draw(int pos_r, int pos_c) {


fix problem with make-syntax-delta-introducer

svn: r14198

--- src/mzscheme/src/stxobj.c
+++ src/mzscheme/src/stxobj.c
@@ -3629,7 +3629,8 @@
   }
 }

-static int check_matching_marks(Scheme_Object *p, Scheme_Object *orig_id, Scheme_Object **marks_cache, int depth)
+static int check_matching_marks(Scheme_Object *p, Scheme_Object *orig_id, Scheme_Object **marks_cache, int depth,
+                                int *_skipped)
 {
   int l1, l2;
   Scheme_Object *m1, *m2;
@@ -3638,6 +3639,7 @@
   p = SCHEME_CDR(p); /* skip phase_export */
   if (SCHEME_PAIRP(p)) {
     /* has marks */
+    int skip = 0;

     EXPLAIN(fprintf(stderr, "%d       has marks\n", depth));

@@ -3658,25 +3660,30 @@
     while (l2 > l1) {
       m2 = SCHEME_CDR(m2);
       l2--;
-    }
-
-    if (scheme_equal(m1, m2))
+      skip++;
+    }
+
+    if (scheme_equal(m1, m2)) {
+      if (_skipped ) *_skipped = skip;
       return l1; /* matches */
-    else
+    } else
       return -1; /* no match */
-  } else
+  } else {
+    if (_skipped) *_skipped = -1;
     return 0; /* match empty mark set */
+  }
 }

 static Scheme_Object *search_shared_pes(Scheme_Object *shared_pes,
                                         Scheme_Object *glob_id, Scheme_Object *orig_id,
                                         Scheme_Object **get_names, int get_orig_name,
-                                        int depth)
+                                        int depth,
+                                        int *_skipped)
 {
   Scheme_Object *pr, *idx, *pos, *src, *best_match = NULL;
   Scheme_Module_Phase_Exports *pt;
   Scheme_Hash_Table *ht;
-  int i, phase, best_match_len = -1;
+  int i, phase, best_match_len = -1, skip;
   Scheme_Object *marks_cache = NULL;

   for (pr = shared_pes; !SCHEME_NULLP(pr); pr = SCHEME_CDR(pr)) {
@@ -3699,10 +3706,11 @@
       /* Found it, maybe. Check marks. */
       int mark_len;
       EXPLAIN(fprintf(stderr, "%d     found %p\n", depth, pos));
-      mark_len = check_matching_marks(SCHEME_CAR(pr), orig_id, &marks_cache, depth);
+      mark_len = check_matching_marks(SCHEME_CAR(pr), orig_id, &marks_cache, depth, &skip);
       if (mark_len > best_match_len) {
         /* Marks match and improve on previously found match. Build suitable rename: */
         best_match_len = mark_len;
+        if (_skipped) *_skipped = skip;

         idx = SCHEME_CAR(SCHEME_CAR(pr));

@@ -3752,11 +3760,12 @@
       kpr = scheme_hash_get(krn->ht, glob_id);
       if (kpr) {
         /* Found it, maybe. Check marks. */
-        int mark_len;
-        mark_len = check_matching_marks(SCHEME_CAR(pr), orig_id, &marks_cache, depth);
+        int mark_len, skip;
+        mark_len = check_matching_marks(SCHEME_CAR(pr), orig_id, &marks_cache, depth, &skip);
         if (mark_len > best_match_len) {
           /* Marks match and improve on previously found match. Build suitable rename: */
           best_match_len = mark_len;
+          if (_skipped) *_skipped = skip;

           if (get_orig_name)
             best_match = glob_id;
@@ -4168,7 +4177,7 @@
           get_names_done = 0;
           if (!rename) {
             EXPLAIN(fprintf(stderr, "%d    in pes\n", depth));
-            rename = search_shared_pes(mrn->shared_pes, glob_id, a, get_names, 0, depth);
+            rename = search_shared_pes(mrn->shared_pes, glob_id, a, get_names, 0, depth, &skipped);
             if (rename)
               get_names_done = 1;
           }
@@ -4646,7 +4655,7 @@
 	    rename = scheme_hash_get(krn->ht, glob_id);

           if (!rename)
-            result = search_shared_pes(mrn->shared_pes, glob_id, a, NULL, 1, 0);
+            result = search_shared_pes(mrn->shared_pes, glob_id, a, NULL, 1, 0, NULL);
 	  else {
 	    /* match; set result: */
 	    if (mrn->kind == mzMOD_RENAME_MARKED)


staging: tidspbridge: remove unnecessary include of <plat/clock.h>

The DSPBridge driver includes arch/arm/plat-omap/include/plat/clock.h.
All of the <plat/ ...> includes are causing problems with the ARM
single image kernel effort.  Remove this one.

Signed-off-by: Paul Walmsley <a027184a55211cd23e3f3094f1fdc728df5e0500@pwsan.com>
Signed-off-by: Tony Lindgren <1001e8702733cced254345e193c88aaa47a4f5de@atomide.com>

--- drivers/staging/tidspbridge/include/dspbridge/host_os.h
+++ drivers/staging/tidspbridge/include/dspbridge/host_os.h
@@ -40,7 +40,6 @@
 #include <linux/vmalloc.h>
 #include <linux/ioport.h>
 #include <linux/platform_device.h>
-#include <plat/clock.h>
 #include <linux/clk.h>
 #include <plat/mailbox.h>
 #include <linux/pagemap.h>


Cleaned out old comments

Cleaned out old comments

--- src/foflc/Lyric_storage.h
+++ src/foflc/Lyric_storage.h
@@ -388,18 +388,6 @@
 	//A wrapper function that gets the string, automatically checking for and throwing any error given
 void fputs_err(const char *str,FILE *stream);
 	//A wrapper function that writes the string, automatically checking for and throwing any error given
-//v2.0	Rewrote this to return a list of detected formats
-//int DetectLyricFormat(char *file);
-	//Determines and returns the lyric type of the input file, as defined in the macros earlier in this header file
-	//If the file being detected is a valid MIDI, and both a track named "PART VOCALS" (RB style MIDI) and one named "Words" (Soft Karaoke),
-	//whichever is read first is the deciding factor in the detected lyric format.  If neither are found, but an instrument track
-	//(such as "PART GUITAR") is found, Vocal Rhythm is assumed, otherwise KAR is assumed.
-	//-1 is returned if the file type was determined, but validation failed (import would fail)
-	//0 is returned if the file type could not be determined
-	//	If Vocal Rhythm is detected, the correlating pitched lyric file needs to be provided for import
-	//	If KAR is detected, the correct MIDI track to import lyrics from needs to be provided for import
-	//	If Soft Karaoke is detected, it's possible that pitches and durations are available in another MIDI track, possibly prompt for which track to import
-	//	If Pitched Lyric format is detected, the correlating vocal rhythm MIDI needs to be provided for import
 struct Lyric_Format *DetectLyricFormat(char *file);
 	//Determines and returns information (as a linked list) about lyrics detected in the input file
 	//If the file matches multiple lyric types (one of the MIDI based formats), multiple links in the list will exist.


Fix HMAC.c include

Fix HMAC.c include

Signed-off-by: Etienne CHAMPETIER <9ab2752ef511330cc7c7e4a3c6ccf1c368d285da@gmail.com>

--- src/native/openssl/HMAC.c
+++ src/native/openssl/HMAC.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */

-#include "Digest.h"
+#include "HMAC.h"

 #include <openssl/evp.h>
 #include <openssl/hmac.h>


tcp: Fix sendmsg for non block socket in case of a crowded window

--- src/net/socket/tcp_sock.c
+++ src/net/socket/tcp_sock.c
@@ -317,6 +317,7 @@
 		return 0;
 	}
 }
+
 static int tcp_write(struct tcp_sock *tcp_sk, char *buff, size_t len) {
 	size_t bytes;
 	struct sk_buff *skb;
@@ -354,7 +355,7 @@
 	struct tcp_sock *tcp_sk;
 	char *buff;
 	size_t len;
-	int timeout;
+	int ret, timeout;

 	(void)flags;

@@ -379,7 +380,11 @@
 				timeout = SCHED_TIMEOUT_INFINITE;
 			}
 			while (tcp_sk->rem.wind <= tcp_sk->self.seq - tcp_sk->last_ack) {
-				sock_wait(sk, POLLOUT | POLLERR, timeout);
+				ret = sock_wait(sk, POLLOUT | POLLERR, timeout);
+				if (ret != 0) {
+					softirq_unlock();
+					return ret;
+				}
 			}
 		}
 		softirq_unlock();


Fix an accouting bug where control stuff was counted twice when
on the read queue and the ordered or unordered queue.

While there, improve the checking under INVARIANTs.

--- src/netinet/sctp_indata.c
+++ src/netinet/sctp_indata.c
@@ -32,7 +32,7 @@

 #ifdef __FreeBSD__
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.c 324730 2017-10-18 21:08:35Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.c 325434 2017-11-05 11:59:33Z tuexen $");
 #endif

 #include <netinet/sctp_os.h>
@@ -95,12 +95,14 @@
 		return (calc);
 	}

+	KASSERT(asoc->cnt_on_reasm_queue > 0 || asoc->size_on_reasm_queue == 0,
+	        ("size_on_reasm_queue is %u", asoc->size_on_reasm_queue));
+	KASSERT(asoc->cnt_on_all_streams > 0 || asoc->size_on_all_streams == 0,
+	        ("size_on_all_streams is %u", asoc->size_on_all_streams));
 	if (stcb->asoc.sb_cc == 0 &&
-	    asoc->size_on_reasm_queue == 0 &&
-	    asoc->size_on_all_streams == 0) {
+	    asoc->cnt_on_reasm_queue == 0 &&
+	    asoc->cnt_on_all_streams == 0) {
 		/* Full rwnd granted */
-		KASSERT(asoc->cnt_on_reasm_queue == 0, ("cnt_on_reasm_queue is %u", asoc->cnt_on_reasm_queue));
-		KASSERT(asoc->cnt_on_all_streams == 0, ("cnt_on_all_streams is %u", asoc->cnt_on_all_streams));
 		calc = max(SCTP_SB_LIMIT_RCV(stcb->sctp_socket), SCTP_MINIMAL_RWND);
 		return (calc);
 	}
@@ -1245,6 +1247,19 @@
 			}
 			done = (control->end_added) && (control->last_frag_seen);
 			if (control->on_read_q == 0) {
+				if (!done) {
+					if (asoc->size_on_all_streams >= control->length) {
+						asoc->size_on_all_streams -= control->length;
+					} else {
+#ifdef INVARIANTS
+						panic("size_on_all_streams = %u smaller than control length %u", asoc->size_on_all_streams, control->length);
+#else
+						asoc->size_on_all_streams = 0;
+#endif
+					}
+					strm->pd_api_started = 1;
+					control->pdapi_started = 1;
+				}
 				sctp_add_to_readq(stcb->sctp_ep, stcb,
 						  control,
 						  &stcb->sctp_socket->so_rcv, control->end_added,
@@ -1254,10 +1269,6 @@
 			if (done) {
 				control = nctl;
 				goto deliver_more;
-			} else {
-				/* We are now doing PD API */
-				strm->pd_api_started = 1;
-				control->pdapi_started = 1;
 			}
 		}
 	}
@@ -1318,15 +1329,10 @@
 			} else if (control->on_strm_q == SCTP_ON_ORDERED) {
 				/* Ordered */
 				TAILQ_REMOVE(&strm->inqueue, control, next_instrm);
-				if (asoc->size_on_all_streams >= control->length) {
-					asoc->size_on_all_streams -= control->length;
-				} else {
-#ifdef INVARIANTS
-					panic("size_on_all_streams = %u smaller than control length %u", asoc->size_on_all_streams, control->length);
-#else
-					asoc->size_on_all_streams = 0;
-#endif
-				}
+				/*
+				 * Don't need to decrement size_on_all_streams,
+				 * since control is on the read queue.
+				 */
 				sctp_ucount_decr(asoc->cnt_on_all_streams);
 				control->on_strm_q = 0;
 #ifdef INVARIANTS


plugins/evolution: Fixed a race condition, added a lock for it

--- src/plugins/evolution/tracker-evolution-plugin.c
+++ src/plugins/evolution/tracker-evolution-plugin.c
@@ -448,9 +448,11 @@
 static void
 thread_pool_push (ThreadPool *pool, gpointer item, gpointer user_data)
 {
+	g_mutex_lock (pool->mutex);
 	pool->items = g_list_prepend (pool->items, item);
 	if (!pool->dying)
 		g_thread_pool_push (pool->pool, item, user_data);
+	g_mutex_unlock (pool->mutex);
 }

 static gpointer