test passes, Antioch in SI, units are corrected

--- src/core/include/planet/atmospheric_mixture.h
+++ src/core/include/planet/atmospheric_mixture.h
@@ -71,17 +71,17 @@

         /*! \return scale height of species s at altitude z, H = kb * T / (g * Ms)
          *
-         * \param  Ms: molar mass in g/mol
+         * \param  Ms: molar mass in kg/mol
          * \param  temp: temperature in K
          * \param  alt: altitude in km
          * \return scale height in km
          */
         template<typename StateType>
         ANTIOCH_AUTO(StateType)
-        H(const StateType &Ms, const StateType &temp, const StateType &alt) const
-        ANTIOCH_AUTOFUNC(StateType, Constants::Universal::kb<StateType>() * Antioch::Constants::Avogadro<StateType>() * temp /
-                                    ( Ms // in g/mol
-                                     * Constants::g(Constants::Titan::radius<StateType>(), alt, Constants::Titan::mass<StateType>()))
+        H(const CoeffType &Ms, const StateType &T, const StateType &alt) const
+        ANTIOCH_AUTOFUNC(StateType, Antioch::constant_clone(T,1e-3) * // m -> km
+                                    Constants::Universal::kb<StateType>() * Antioch::Constants::Avogadro<StateType>() * T /
+                                    ( Ms * Constants::g(Constants::Titan::radius<StateType>(), alt, Constants::Titan::mass<StateType>()))
                         )

         template<typename StateType>
@@ -137,14 +137,14 @@
         //! \return Jeans' escape flux (cm-3.km.s-1)
         //
         // \param ms: mass of molecule (kg)
-        // \param ns: molecular density (cm-3)
+        // \param ns: molecular density (density)
         // \param T: temperature (K)
         // \param z: altitude (km)
-        // \return Jeans' escape flux in cm-3.km/s
+        // \return Jeans' escape flux in density.km/s
         template<typename StateType>
         ANTIOCH_AUTO(StateType)
         Jeans_flux(const StateType &ms, const StateType &ns, const StateType &T, const StateType &z) const
-        ANTIOCH_AUTOFUNC(StateType, Antioch::constant_clone(T,1e-3) * //ns m -> km
+        ANTIOCH_AUTOFUNC(StateType, Antioch::constant_clone(T,1e-3) * // m -> km
                                     ns * Antioch::ant_sqrt(Constants::Universal::kb<StateType>() * T / (Antioch::constant_clone(T,2.) * ms * Constants::pi<StateType>()))
                                        * Antioch::ant_exp(- ms * Constants::Universal::G<StateType>() * Constants::Titan::mass<StateType>()
                                                          / (Antioch::constant_clone(T,1e3) * (Constants::Titan::radius<StateType>() + z) * Constants::Universal::kb<StateType>() * T)
@@ -163,7 +163,7 @@
         template<typename StateType>
         ANTIOCH_AUTO(StateType)
         Jeans_velocity(const StateType &ms, const StateType &T, const StateType &z) const
-        ANTIOCH_AUTOFUNC(StateType, Antioch::constant_clone(T,1e-3) * //ns m -> km
+        ANTIOCH_AUTOFUNC(StateType, //Antioch::constant_clone(T,1e-3) * //ns m -> km
                                          Antioch::ant_sqrt(Constants::Universal::kb<StateType>() * T / (Antioch::constant_clone(T,2.) * ms * Constants::pi<StateType>()))
                                        * Antioch::ant_exp(- ms * Constants::Universal::G<StateType>() * Constants::Titan::mass<StateType>()
                                                          / (Antioch::constant_clone(T,1e3) * (Constants::Titan::radius<StateType>() + z) * Constants::Universal::kb<StateType>() * T)
@@ -233,14 +233,17 @@
   AtmosphericMixture<CoeffType,VectorCoeffType,MatrixCoeffType>::AtmosphericMixture(Antioch::ChemicalMixture<CoeffType> &neutral,
                                                                     Antioch::ChemicalMixture<CoeffType> &ion,
                                                                     AtmosphericTemperature<CoeffType,VectorCoeffType> &temp):
-  iH(neutral.species_name_map().at("H")),
-  iH2(neutral.species_name_map().at("H2")),
+  iH(neutral.n_species()+1),
+  iH2(neutral.n_species()+1),
   _zmin(0.L),
   _zmax(0.L),
   _neutral_composition(neutral),
   _ionic_composition(ion),
   _temperature(temp)
   {
+    if(neutral.species_name_map().count("H"))iH = neutral.species_name_map().at("H");
+    if(neutral.species_name_map().count("H2"))iH2 = neutral.species_name_map().at("H2");
+
     return;
   }

@@ -450,8 +453,6 @@
          Mm += _neutral_molar_fraction_bottom[s] * _neutral_composition.M(s);
       }

-      Mm *= 1e-3L; //to kg
-
       CoeffType nTot = this->barometry_density(z, _zmin, _total_bottom_density, _temperature.neutral_temperature(z), Mm);

       for(unsigned int s = 0; s < _neutral_composition.n_species(); s++)
@@ -473,8 +474,6 @@
       {
          Mm += _neutral_molar_fraction_bottom[s] * _neutral_composition.M(s);
       }
-
-      Mm *= 1e-3L; //to kg

       CoeffType nTot = this->barometry_density(z, _zmin, _total_bottom_density, _temperature.neutral_temperature(z), Mm);

@@ -532,8 +531,8 @@
       {
           if(_neutral_composition.species_list()[s] != iH &&
              _neutral_composition.species_list()[s] != iH2)continue;
-          CoeffType ms = _neutral_composition.M(s) * Antioch::constant_clone(ms,1e-3) / Antioch::Constants::Avogadro<CoeffType>(); //to kg.mol-1 then kg
-          upper_fluxes[s] = - this->Jeans_flux(ms,molar_concentrations[s],_temperature.neutral_temperature(_zmax),_zmax) * Antioch::constant_clone(ms,1e-3); // cm-3.km/s, escaping flux, term < 0
+          CoeffType ms = _neutral_composition.M(s) / Antioch::Constants::Avogadro<CoeffType>(); //from kg.mol-1 to kg
+          upper_fluxes[s] = - this->Jeans_flux(ms,molar_concentrations[s],_temperature.neutral_temperature(_zmax),_zmax); // cm-3.km/s, escaping flux, term < 0
       }
   }

@@ -544,10 +543,10 @@
       antioch_assert_less(s,_neutral_composition.n_species());
       antioch_assert_less(s,molar_concentrations.size());

-      CoeffType ms = _neutral_composition.M(s) * 1e-3 / Antioch::Constants::Avogadro<CoeffType>(); //to kg.mol-1 then kg
+      CoeffType ms = _neutral_composition.M(s) / Antioch::Constants::Avogadro<CoeffType>(); //from kg.mol-1 to kg
       CoeffType value = (_neutral_composition.species_list()[s] != iH && _neutral_composition.species_list()[s] != iH2)?
                         0.:
-                        - this->Jeans_flux(ms, molar_concentrations[s],_temperature.neutral_temperature(_zmax),_zmax) * Antioch::constant_clone(ms,1e-3); // to cm-3.km.s-1, escaping flux, term < 0;
+                        - this->Jeans_flux(ms, molar_concentrations[s],_temperature.neutral_temperature(_zmax),_zmax); // cm-3.km.s-1, escaping flux, term < 0;
       return value;
   }

@@ -556,10 +555,10 @@
   CoeffType AtmosphericMixture<CoeffType,VectorCoeffType,MatrixCoeffType>::upper_boundary_velocity(unsigned int s) const
   {

-      CoeffType ms = _neutral_composition.M(s) * 1e-3 / Antioch::Constants::Avogadro<CoeffType>(); //to kg.mol-1 then kg
+      CoeffType ms = _neutral_composition.M(s) / Antioch::Constants::Avogadro<CoeffType>(); //from kg.mol-1 to kg
       CoeffType value =  (_neutral_composition.species_list()[s] != iH && _neutral_composition.species_list()[s] != iH2)?
                         0.:
-                        - this->Jeans_velocity(ms, _temperature.neutral_temperature(_zmax),_zmax) * Antioch::constant_clone(ms,1e-3); // to cm-3.km.s-1, escaping flux, term < 0
+                        - this->Jeans_velocity(ms, _temperature.neutral_temperature(_zmax),_zmax); // cm-3.km.s-1, escaping flux, term < 0
       return value;
   }


Fix cursor position in the UI module

Fix cursor position in the UI module

--- src/engine/sys/sdl_input.c
+++ src/engine/sys/sdl_input.c
@@ -678,6 +678,15 @@

 		SDL_SetWindowGrab( window, SDL_FALSE );
 		SDL_SetRelativeMouseMode( SDL_FALSE );
+
+		if ( uivm )
+		{
+			// TODO (after no compatibility needed with alpha 9): remove argument
+			int mousepos = VM_Call( uivm, UI_MOUSE_POSITION, 0 );
+			int cursorx = mousepos & 0xFFFF;
+			int cursory = mousepos >> 16;
+			SDL_WarpMouseInWindow( window, cursorx, cursory );
+		}

 		mouseActive = qfalse;
 	}


TARGET_NRF52/serial_api.c: Fix style

TARGET_NRF52/serial_api.c: Fix style

--- targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/serial_api.c
+++ targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/serial_api.c
@@ -105,8 +105,7 @@
 /**
  * Missing event typedefs.
  */
-typedef enum
-{
+typedef enum {
     NRF_UARTE_EVENT_TXDRDY    = offsetof(NRF_UARTE_Type, EVENTS_TXDRDY),
 } nrf_uarte_event_extra_t;

@@ -505,8 +504,7 @@
 static void nordic_nrf5_uart_event_handler(int instance)
 {
     /* DMA buffer is full or has been swapped out by idle timeout. */
-    if (nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_ENDRX))
-    {
+    if (nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_ENDRX)) {
         nrf_uarte_event_clear(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_ENDRX);

 #if DEVICE_SERIAL_ASYNCH
@@ -528,16 +526,14 @@
      * will setup the wrong DMA buffer and cause data to be lost.
      */
     if (nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_RXSTARTED) &&
-            !nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_ENDRX))
-    {
+            !nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_ENDRX)) {
         nrf_uarte_event_clear(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_RXSTARTED);

         nordic_nrf5_uart_event_handler_rxstarted(instance);
     }

     /* Tx DMA buffer has been sent. */
-    if (nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_ENDTX))
-    {
+    if (nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_ENDTX)) {
         nrf_uarte_event_clear(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_ENDTX);

         /* Use SWI to de-prioritize callback. */
@@ -691,7 +687,7 @@
 {
     /* Disable interrupts during confiration. */
     nrf_uarte_int_disable(nordic_nrf5_uart_register[instance], NRF_UARTE_INT_RXSTARTED_MASK |
-                                                               NRF_UARTE_INT_ENDRX_MASK);
+                          NRF_UARTE_INT_ENDRX_MASK);

     /* Clear FIFO buffer. */
     nrf_atfifo_clear(nordic_nrf5_uart_state[instance].fifo);
@@ -720,7 +716,7 @@

     /* Enable interrupts again. */
     nrf_uarte_int_enable(nordic_nrf5_uart_register[instance], NRF_UARTE_INT_RXSTARTED_MASK |
-                                                              NRF_UARTE_INT_ENDRX_MASK);
+                         NRF_UARTE_INT_ENDRX_MASK);
 }

 #if DEVICE_SERIAL_ASYNCH
@@ -733,7 +729,7 @@
 {
     /* Disable Rx related interrupts. */
     nrf_uarte_int_disable(nordic_nrf5_uart_register[instance], NRF_UARTE_INT_RXSTARTED_MASK |
-                                                               NRF_UARTE_INT_ENDRX_MASK);
+                          NRF_UARTE_INT_ENDRX_MASK);

     /* Clear Rx related events. */
     nrf_uarte_event_clear(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_RXSTARTED);
@@ -803,7 +799,7 @@
         nrf_uarte_task_trigger(nordic_nrf5_uart_register[instance],
                                NRF_UARTE_TASK_STARTRX);

-    /* Owner hasn't changed but mode has. Reconfigure. */
+        /* Owner hasn't changed but mode has. Reconfigure. */
     } else if ((uart_object->rx_asynch == true) && (nordic_nrf5_uart_state[instance].rx_asynch == false)) {

         nordic_nrf5_uart_configure_rx_asynch(instance);
@@ -942,8 +938,8 @@
         bool done = false;
         do {
             done = nrf_uarte_event_check(nordic_nrf5_uart_register[instance],
-                                (nrf_uarte_event_t) NRF_UARTE_EVENT_TXDRDY);
-        } while(done == false);
+                                         (nrf_uarte_event_t) NRF_UARTE_EVENT_TXDRDY);
+        } while (done == false);
     }

     /* Store pins in serial object. */
@@ -1370,7 +1366,7 @@
     /* Wait until UART is ready to send next character. */
     do {
         done = nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDRDY);
-    } while(done == false);
+    } while (done == false);

     nrf_uarte_event_clear(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDRDY);


trace hook which displays current thread id

--- vdpau-entry.c
+++ vdpau-entry.c
@@ -7,6 +7,7 @@
  */

 #define _XOPEN_SOURCE   500
+#define _GNU_SOURCE
 #include <ctype.h>
 #include <vdpau/vdpau.h>
 #include <stdio.h>
@@ -18,6 +19,16 @@
 #include "vdpau-trace.h"
 #include "globals.h"

+#include <sys/syscall.h>
+#include <unistd.h>
+
+void
+trc_hk(void *param, int origin)
+{
+    (void)param;
+    (void)origin;
+    printf("[%5d] ", (pid_t)syscall(__NR_gettid));
+}

 static
 void


Don't listen to root property changes

Don't listen to root property changes

--- velox/velox.c
+++ velox/velox.c
@@ -308,8 +308,7 @@
                 XCB_EVENT_MASK_LEAVE_WINDOW |
                 XCB_EVENT_MASK_STRUCTURE_NOTIFY |
                 XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
-                XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
-                XCB_EVENT_MASK_PROPERTY_CHANGE;
+                XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY;
     values[1] = cursors[POINTER];

     xcb_change_window_attributes(c, screen->root, mask, values);


fix fmpz_is_prime_pseudosquare on 32 bit

--- fmpz/is_prime_pseudosquare.c
+++ fmpz/is_prime_pseudosquare.c
@@ -206,9 +206,9 @@
    {
       fmpz_set_ui(f, flint_fmpz_pseudosquares[i][2]);
       fmpz_mul_2exp(f, f, 32);
-      fmpz_add_ui(f, flint_fmpz_pseudosquares[i][1]);
+      fmpz_add_ui(f, f, flint_fmpz_pseudosquares[i][1]);
       fmpz_mul_2exp(f, f, 32);
-      fmpz_add_ui(f, flint_fmpz_pseudosquares[i][1]);
+      fmpz_add_ui(f, f, flint_fmpz_pseudosquares[i][1]);
    }
 #else
    if (i < 58)


fixed sprintf bug

fixed sprintf bug

--- OOps/str_ops.c
+++ OOps/str_ops.c
@@ -349,7 +349,16 @@
         case 'u':
         case 'c':
 #ifdef HAVE_SNPRINTF
-          n = snprintf(outstring, maxChars, strseg, (int) MYFLT2LRND(*parm));
+        if(strlen(strseg) + 24 > maxChars) {
+           int offs = outstring - str->data;
+            str->data = mrealloc(csound, str->data,
+                                 str->size  + 13);
+            str->size += 24;
+            maxChars += 24;
+            outstring = str->data + offs;
+            //printf("maxchars = %d  %s\n", maxChars, strseg);
+	  }
+          n = snprintf(outstring, maxChars, strseg, (int) MYFLT2LRND(*parm));
 #else
           n = sprintf(outstring, strseg, (int) MYFLT2LRND(*parm));
 #endif
@@ -361,6 +370,15 @@
         case 'g':
         case 'G':
 #ifdef HAVE_SNPRINTF
+          if(strlen(strseg) + 24 > maxChars) {
+           int offs = outstring - str->data;
+            str->data = mrealloc(csound, str->data,
+                                 str->size  + 13);
+            str->size += 24;
+            maxChars += 24;
+            outstring = str->data + offs;
+            //printf("maxchars = %d  %s\n", maxChars, strseg);
+	  }
           n = snprintf(outstring, maxChars, strseg, (double)*parm);
 #else
           n = sprintf(outstring, strseg, (double)*parm);
@@ -379,17 +397,19 @@
             maxChars += ((STRINGDAT*)parm)->size;
             outstring = str->data + offs;
           }
-          n = sprintf(outstring, strseg, ((STRINGDAT*)parm)->data);
+	   n = sprintf(outstring, strseg, ((STRINGDAT*)parm)->data);
           break;
         default:
           return StrOp_ErrMsg(p, "invalid format string");
         }
-        if (UNLIKELY(n < 0 || n >= maxChars)) {
+        if (n < 0 || n >= maxChars) {
           /* safely detected excess string length */
             int offs = outstring - str->data;
             str->data = mrealloc(csound, str->data, maxChars*2);
             outstring = str->data + offs;
             str->size = maxChars*2;
+            maxChars += str->size;
+
         }
         outstring += n;
         len += n;


esc35-v1 bootloader uses upstream NuttX's new struct packing

--- src/drivers/boards/esc35-v1/bootloader/boot.c
+++ src/drivers/boards/esc35-v1/bootloader/boot.c
@@ -191,12 +191,12 @@
  ****************************************************************************/
 #define led(n, code, r , g , b, h) {.red = (r),.green = (g), .blue = (b),.hz = (h)}

-typedef struct packed_struct led_t {
+typedef begin_packed_struct struct led_t {
 	uint16_t red    :       5;
 	uint16_t green  :       6;
 	uint16_t blue   :       5;
 	uint8_t hz;
-} led_t;
+} end_packed_struct led_t;

 static const  led_t i2l[] = {


devcgroup: use kmemdup()

devcgroup: use kmemdup()

This saves 40 bytes on my x86_32 box.

Signed-off-by: Li Zefan <5dc16b054e85ffba6c8d314d8e55ae95dcab12a5@cn.fujitsu.com>
Acked-by: Serge Hallyn <dd6cacb2d07f0aa354aa6e74c149a3580e5a1db1@us.ibm.com>
Cc: Paul Menage <a4e32ff3ad614f63c49bddfcf4b7598c6857b687@google.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- security/device_cgroup.c
+++ security/device_cgroup.c
@@ -84,13 +84,9 @@
 	struct dev_whitelist_item *wh, *tmp, *new;

 	list_for_each_entry(wh, orig, list) {
-		new = kmalloc(sizeof(*wh), GFP_KERNEL);
+		new = kmemdup(wh, sizeof(*wh), GFP_KERNEL);
 		if (!new)
 			goto free_and_exit;
-		new->major = wh->major;
-		new->minor = wh->minor;
-		new->type = wh->type;
-		new->access = wh->access;
 		list_add_tail(&new->list, dest);
 	}

@@ -114,11 +110,10 @@
 {
 	struct dev_whitelist_item *whcopy, *walk;

-	whcopy = kmalloc(sizeof(*whcopy), GFP_KERNEL);
+	whcopy = kmemdup(wh, sizeof(*wh), GFP_KERNEL);
 	if (!whcopy)
 		return -ENOMEM;

-	memcpy(whcopy, wh, sizeof(*whcopy));
 	spin_lock(&dev_cgroup->lock);
 	list_for_each_entry(walk, &dev_cgroup->whitelist, list) {
 		if (walk->type != wh->type)


Handle issues with raw keys not being visible.

--- security/nss/cmd/pp/pp.c
+++ security/nss/cmd/pp/pp.c
@@ -152,8 +152,10 @@
 			     SECU_PrintCertificateRequest);
     } else if (PORT_Strcmp (typeTag, SEC_CT_CRL) == 0) {
 	rv = SECU_PrintSignedData (outFile, &data, "CRL", 0, SECU_PrintCrl);
+#ifdef HAVE_EPV_TEMPLATE
     } else if (PORT_Strcmp(typeTag, SEC_CT_PRIVATE_KEY) == 0) {
 	rv = SECU_PrintPrivateKey(outFile, &data, "Private Key", 0);
+#endif
     } else if (PORT_Strcmp(typeTag, SEC_CT_PUBLIC_KEY) == 0) {
 	rv = SECU_PrintPublicKey(outFile, &data, "Public Key", 0);
     } else if (PORT_Strcmp(typeTag, SEC_CT_PKCS7) == 0) {


[PATCH] SELinux: cleanup stray variable in selinux_inode_init_security()

Remove an unneded pointer variable in selinux_inode_init_security().

Signed-off-by: James Morris <10d11de3abc355eabe955bb734f0f8e71da56e16@namei.org>
Acked-by: Stephen Smalley <d6e1285e1c84d3d5885c2124fdacc780e9fc0a94@tycho.nsa.gov>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@osdl.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@osdl.org>

--- security/selinux/hooks.c
+++ security/selinux/hooks.c
@@ -1929,7 +1929,6 @@
 	struct task_security_struct *tsec;
 	struct inode_security_struct *dsec;
 	struct superblock_security_struct *sbsec;
-	struct inode_security_struct *isec;
 	u32 newsid, clen;
 	int rc;
 	char *namep = NULL, *context;
@@ -1937,7 +1936,6 @@
 	tsec = current->security;
 	dsec = dir->i_security;
 	sbsec = dir->i_sb->s_security;
-	isec = inode->i_security;

 	if (tsec->create_sid && sbsec->behavior != SECURITY_FS_USE_MNTPOINT) {
 		newsid = tsec->create_sid;


Eliminate randomness in test.

Eliminate randomness in test.

--- test/unit/test_bus_send.c
+++ test/unit/test_bus_send.c
@@ -22,7 +22,6 @@
 #include "send_internal.h"
 #include "atomic.h"

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

 #include "mock_bus.h"
@@ -94,9 +93,9 @@
 }

 static void expect_handle_failure(void) {
-    backpressure = random();
+    backpressure = 54321;
     bus_process_boxed_message_ExpectAndReturn(b, box, &backpressure, true);
-    bus_backpressure_delay_Expect(b, backpressure, LISTENER_EXPECT_BACKPRESSURE_SHIFT);
+    bus_backpressure_delay_Expect(b, 54321, LISTENER_EXPECT_BACKPRESSURE_SHIFT);
 }

 void test_send_do_blocking_send_should_set_TX_FAILURE_if_second_timestamp_failure(void) {


smack: make smk_cipso_doi() and smk_unlbl_ambient()

The functions smk_cipso_doi and smk_unlbl_ambient are not used outside
smackfs.c and should hence be static.

Signed-off-by: Casey Schaufler <77bc9a9984e6786c5799d7a71768cf023120ef76@schaufler-ca.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- security/smack/smackfs.c
+++ security/smack/smackfs.c
@@ -317,7 +317,7 @@
 /**
  * smk_cipso_doi - initialize the CIPSO domain
  */
-void smk_cipso_doi(void)
+static void smk_cipso_doi(void)
 {
 	int rc;
 	struct cipso_v4_doi *doip;
@@ -350,7 +350,7 @@
 /**
  * smk_unlbl_ambient - initialize the unlabeled domain
  */
-void smk_unlbl_ambient(char *oldambient)
+static void smk_unlbl_ambient(char *oldambient)
 {
 	int rc;
 	struct netlbl_audit audit_info;


cso: rename fragment sampler-related fields

To better distinguish from vertex sampler fields.

--- src/gallium/auxiliary/cso_cache/cso_context.c
+++ src/gallium/auxiliary/cso_cache/cso_context.c
@@ -52,21 +52,21 @@
    struct cso_cache *cache;

    struct {
-      void *samplers[PIPE_MAX_SAMPLERS];
-      unsigned nr_samplers;
+      void *fragment_samplers[PIPE_MAX_SAMPLERS];
+      unsigned nr_fragment_samplers;

       void *vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS];
       unsigned nr_vertex_samplers;
    } hw;

-   void *samplers[PIPE_MAX_SAMPLERS];
-   unsigned nr_samplers;
+   void *fragment_samplers[PIPE_MAX_SAMPLERS];
+   unsigned nr_fragment_samplers;

    void *vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS];
    unsigned nr_vertex_samplers;

-   unsigned nr_samplers_saved;
-   void *samplers_saved[PIPE_MAX_SAMPLERS];
+   unsigned nr_fragment_samplers_saved;
+   void *fragment_samplers_saved[PIPE_MAX_SAMPLERS];

    unsigned nr_vertex_samplers_saved;
    void *vertex_samplers_saved[PIPE_MAX_VERTEX_SAMPLERS];
@@ -431,7 +431,7 @@
       }
    }

-   ctx->samplers[idx] = handle;
+   ctx->fragment_samplers[idx] = handle;
    return PIPE_OK;
 }

@@ -482,21 +482,24 @@

    /* find highest non-null sampler */
    for (i = PIPE_MAX_SAMPLERS; i > 0; i--) {
-      if (ctx->samplers[i - 1] != NULL)
+      if (ctx->fragment_samplers[i - 1] != NULL)
          break;
    }

-   ctx->nr_samplers = i;
-
-   if (ctx->hw.nr_samplers != ctx->nr_samplers ||
-       memcmp(ctx->hw.samplers,
-              ctx->samplers,
-              ctx->nr_samplers * sizeof(void *)) != 0)
+   ctx->nr_fragment_samplers = i;
+
+   if (ctx->hw.nr_fragment_samplers != ctx->nr_fragment_samplers ||
+       memcmp(ctx->hw.fragment_samplers,
+              ctx->fragment_samplers,
+              ctx->nr_fragment_samplers * sizeof(void *)) != 0)
    {
-      memcpy(ctx->hw.samplers, ctx->samplers, ctx->nr_samplers * sizeof(void *));
-      ctx->hw.nr_samplers = ctx->nr_samplers;
-
-      ctx->pipe->bind_fragment_sampler_states(ctx->pipe, ctx->nr_samplers, ctx->samplers);
+      memcpy(ctx->hw.fragment_samplers, ctx->fragment_samplers,
+             ctx->nr_fragment_samplers * sizeof(void *));
+      ctx->hw.nr_fragment_samplers = ctx->nr_fragment_samplers;
+
+      ctx->pipe->bind_fragment_sampler_states(ctx->pipe,
+                                              ctx->nr_fragment_samplers,
+                                              ctx->fragment_samplers);
    }
 }

@@ -550,7 +553,7 @@
          error = temp;
    }

-   for ( ; i < ctx->nr_samplers; i++) {
+   for ( ; i < ctx->nr_fragment_samplers; i++) {
       temp = cso_single_sampler( ctx, i, NULL );
       if (temp != PIPE_OK)
          error = temp;
@@ -563,14 +566,16 @@

 void cso_save_samplers(struct cso_context *ctx)
 {
-   ctx->nr_samplers_saved = ctx->nr_samplers;
-   memcpy(ctx->samplers_saved, ctx->samplers, sizeof(ctx->samplers));
+   ctx->nr_fragment_samplers_saved = ctx->nr_fragment_samplers;
+   memcpy(ctx->fragment_samplers_saved, ctx->fragment_samplers,
+          sizeof(ctx->fragment_samplers));
 }

 void cso_restore_samplers(struct cso_context *ctx)
 {
-   ctx->nr_samplers = ctx->nr_samplers_saved;
-   memcpy(ctx->samplers, ctx->samplers_saved, sizeof(ctx->samplers));
+   ctx->nr_fragment_samplers = ctx->nr_fragment_samplers_saved;
+   memcpy(ctx->fragment_samplers, ctx->fragment_samplers_saved,
+          sizeof(ctx->fragment_samplers));
    cso_single_sampler_done( ctx );
 }


Fix the USB bulk input loop. (dm)

Fix the USB bulk input loop. (dm)

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

--- Programs/usb.c
+++ Programs/usb.c
@@ -678,16 +678,28 @@
     unsigned char *buffer = malloc(size);
     if (buffer) {
       int count;
-      while ((count = usbReadEndpoint(device, endpointNumber, buffer, size,
-                                      MAX(interval, timeout))) != -1) {
-        if (count) {
+
+      if (timeout) hasTimedOut(0);
+      while (1) {
+        while ((count = usbReadEndpoint(device, endpointNumber, buffer, size,
+                                        MAX(interval, timeout))) != -1) {
+          if (!count) {
+            errno = EAGAIN;
+            break;
+          }
+
           endpoint->direction.input.buffer = buffer;
           endpoint->direction.input.length = count;
           endpoint->direction.input.completed = buffer;
           return 1;
         }
-      }
-      if (errno == ETIMEDOUT) errno = EAGAIN;
+        if (errno == ETIMEDOUT) errno = EAGAIN;
+
+        if (errno != EAGAIN) break;
+        if (!timeout) break;
+        if (hasTimedOut(timeout)) break;
+        approximateDelay(interval);
+      }

       free(buffer);
     }


radeonsi: add new depth_needs_decompression() helper

v2: - rename to depth_needs_decompression() instead

Signed-off-by: Samuel Pitoiset <506e97eed81d9e59d22f4c73fb51123bb62b4a30@gmail.com>
Reviewed-by: Marek Olšák <8c7344a1abdb103e79ecfd488098373070c3c70e@amd.com>

--- src/gallium/drivers/radeonsi/si_descriptors.c
+++ src/gallium/drivers/radeonsi/si_descriptors.c
@@ -559,6 +559,13 @@
 	       (rtex->dcc_offset && rtex->dirty_level_mask);
 }

+static bool depth_needs_decompression(struct r600_texture *rtex,
+				      struct si_sampler_view *sview)
+{
+	return rtex->db_compatible &&
+	       (!rtex->tc_compatible_htile || sview->is_stencil_sampler);
+}
+
 static void si_update_compressed_tex_shader_mask(struct si_context *sctx,
 						 unsigned shader)
 {
@@ -602,8 +609,7 @@
 				(struct r600_texture*)views[i]->texture;
 			struct si_sampler_view *rview = (struct si_sampler_view *)views[i];

-			if (rtex->db_compatible &&
-			    (!rtex->tc_compatible_htile || rview->is_stencil_sampler)) {
+			if (depth_needs_decompression(rtex, rview)) {
 				samplers->depth_texture_mask |= 1u << slot;
 			} else {
 				samplers->depth_texture_mask &= ~(1u << slot);


wfreerdp-server: fixed corruption issue

wfreerdp-server: fixed corruption issue

--- server/Windows/wf_peer.c
+++ server/Windows/wf_peer.c
@@ -95,6 +95,7 @@
 	SURFACE_BITS_COMMAND* cmd;
 	GETCHANGESBUF* buf;
 	long height, width;
+	long offset;
 	int dRes;

 	update = client->update;
@@ -145,14 +146,16 @@
 		rect.width = width;
 		rect.height = height;

-
+		offset = (4 * wfi->invalid_x1) + (wfi->invalid_y1 * wfi->width * 4);
+
+		printf("width = %d, height = %d\n", width, height);
 		rfx_compose_message(wfp->rfx_context, s, &rect, 1,
-				(uint8*) buf->Userbuffer, width, height, width * 4);
+				((uint8*) (buf->Userbuffer)) + offset, width, height, wfi->width * 4);

 		cmd->destLeft = wfi->invalid_x1;
 		cmd->destTop = wfi->invalid_y1;
 		cmd->destRight = wfi->invalid_x1 + width;
-		cmd->destBottom = wfi->invalid_y2 + height;
+		cmd->destBottom = wfi->invalid_y1 + height;

 		cmd->bpp = 32;
@@ -220,10 +223,9 @@
 	printf("Client requested desktop: %dx%dx%d\n",
 		client->settings->width, client->settings->height, client->settings->color_depth);

-	printf("But we will try resizing to %dx%dx%d\n",
-		wf_info_get_height(wfInfoSingleton),
+	printf("But we will try resizing to %dx%d\n",
 		wf_info_get_width(wfInfoSingleton),
-		32
+		wf_info_get_height(wfInfoSingleton)
 		);

 	client->settings->width = wf_info_get_width(wfInfoSingleton);
@@ -267,7 +269,10 @@

 		wf_info_updated(wfInfoSingleton);
 		printf("\tSend...");
-		printf("\t(%d, %d), (%d, %d)\n", wfInfoSingleton->invalid_x1, wfInfoSingleton->invalid_y1, wfInfoSingleton->invalid_x2, wfInfoSingleton->invalid_y2);
+		printf("\t(%d, %d), (%d, %d) [%dx%d]\n",
+			update->surface_bits_command.destLeft, update->surface_bits_command.destTop,
+			update->surface_bits_command.destRight, update->surface_bits_command.destBottom,
+			update->surface_bits_command.width, update->surface_bits_command.height);
 		update->SurfaceBits(update->context, &update->surface_bits_command);
 		//wf_info_clear_invalid_region(wfInfoSingleton);
 		wfInfoSingleton->enc_data = false;


* context.c
  (serf_context_run): Return the explicitly documented error on timeouts
    instead of just any error that APR documents as being timeup. On Windows
    this allows seeing the difference between a timed out connection (reported
    as error via the poll) and no events within the timespan.

Note from Bert: this patch accidently contains a new error code description
which should have been part of r2184 instead.

--- context.c
+++ context.c
@@ -285,6 +285,12 @@
            ### look at the potential return codes. map to our defined
            ### return values? ...
         */
+
+        /* Use the strict documented error for poll timeouts, to allow proper
+           handling of the other timeout types when returned from
+           serf_event_trigger */
+        if (APR_STATUS_IS_TIMEUP(status))
+            return APR_TIMEUP; /* Return the documented error */
         return status;
     }

@@ -366,6 +372,8 @@
         return "The HTTP response status line too long";
     case SERF_ERROR_RESPONSE_HEADER_TOO_LONG:
         return "The HTTP response header too long";
+    case SERF_ERROR_CONNECTION_TIMEDOUT:
+        return "The connection timed out";
     case SERF_ERROR_SSL_COMM_FAILED:
         return "An error occurred during SSL communication";
     case SERF_ERROR_SSL_CERT_FAILED:


Don't try to flood the server with pipelined requests until we have an idea
of its limits.

* context.c
  (serf_connection_t): Add three fields to help us track how hard we're
  pounding the server.
  (write_to_connection): If we have a 'discovered' keepalive limit and we've
  hit the max already, hold off; count the number of requests we've sent and
  purposely send one more than the limit each time as a trial balloon.
  (read_from_connection): Update each time we get a completed response without
  getting a Conn: Close; if we go past our previous keepalive limit, then
  release the cap.
  (process_connection): Deal with HUP and ERR earlier for now.
  (link_requests): Move earlier in file.
  (serf_connection_reset): Clear out request count; insert held, but not
  delivered, requests *after* we've cancelled the previous requests - this
  preserves the ordering.

git-svn-id: 683495cb1553624b05a54e2ba9533425f69cf277@871 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845

--- context.c
+++ context.c
@@ -75,6 +75,15 @@
     /* are we a dirty connection that needs its poll status updated? */
     int dirty_conn;

+    /* number of completed requests we've sent */
+    apr_size_t completed_requests;
+
+    /* number of completed responses we've got */
+    apr_size_t completed_responses;
+
+    /* keepalive */
+    apr_size_t probable_keepalive_limit;
+
     /* someone has told us that the connection is closing
      * so, let's start a new socket.
      */
@@ -247,6 +256,12 @@
 static apr_status_t write_to_connection(serf_connection_t *conn)
 {
     serf_request_t *request = conn->requests;
+
+    if (conn->probable_keepalive_limit &&
+        conn->completed_requests > conn->probable_keepalive_limit) {
+        /* backoff for now. */
+        return APR_SUCCESS;
+    }

     /* Find a request that has data which needs to be delivered. */
     while (request != NULL && request->req_bkt == NULL)
@@ -355,6 +370,14 @@
                ### data is hanging out in the unwritten field. */
             serf_bucket_destroy(request->req_bkt);
             request->req_bkt = NULL;
+
+            conn->completed_requests++;
+
+            if (conn->probable_keepalive_limit &&
+                conn->completed_requests > conn->probable_keepalive_limit) {
+                /* backoff for now. */
+                stop_reading = 1;
+            }
         }

         if (stop_reading) {
@@ -430,6 +453,25 @@
         apr_pool_destroy(request->respool);

         request = conn->requests;
+
+        /* This means that we're being advised that the connection is done. */
+        if (status == SERF_ERROR_CLOSING) {
+            serf_connection_reset(conn);
+            status = APR_SUCCESS;
+            goto error;
+        }
+
+        conn->completed_responses++;
+
+        /* The server is suddenly deciding to serve more responses than we've
+         * seen before.
+         *
+         * Let our requests go.
+         */
+        if (conn->probable_keepalive_limit &&
+            conn->completed_responses > conn->probable_keepalive_limit) {
+            conn->probable_keepalive_limit = 0;
+        }

         /* If we just ran out of requests, then update the pollset. We
          * don't want to read from this socket any more. We are definitely
@@ -441,14 +483,6 @@
             status = APR_SUCCESS;
             goto error;
         }
-
-        /* This means that we're being advised that the connection is done. */
-        if (status == SERF_ERROR_CLOSING) {
-            serf_connection_reset(conn);
-            status = APR_SUCCESS;
-            goto error;
-        }
-
     }

   error:
@@ -462,6 +496,14 @@
 {
     apr_status_t status;

+    if ((events & APR_POLLHUP) != 0) {
+        /* ### needs work */
+        abort();
+    }
+    if ((events & APR_POLLERR) != 0) {
+        /* ### needs work */
+        puts("Hit APR_POLLERR: what to do?\n");
+    }
     if ((events & APR_POLLOUT) != 0) {
         if ((status = write_to_connection(conn)) != APR_SUCCESS)
             return status;
@@ -469,14 +511,6 @@
     if ((events & APR_POLLIN) != 0) {
         if ((status = read_from_connection(conn)) != APR_SUCCESS)
             return status;
-    }
-    if ((events & APR_POLLHUP) != 0) {
-        /* ### needs work */
-        abort();
-    }
-    if ((events & APR_POLLERR) != 0) {
-        /* ### needs work */
-        puts("Hit APR_POLLERR: what to do?\n");
     }
     return APR_SUCCESS;
 }
@@ -633,21 +667,43 @@
     return conn;
 }

+void link_requests(serf_request_t **list, serf_request_t *request)
+{
+    if (*list == NULL) {
+        *list = request;
+    }
+    else {
+        serf_request_t *scan = *list;
+
+        while (scan->next != NULL) {
+            scan = scan->next;
+        }
+
+        scan->next = request;
+    }
+}
+
 SERF_DECLARE(apr_status_t) serf_connection_reset(
     serf_connection_t *conn)
 {
     int i;
     serf_context_t *ctx = conn->ctx;
     apr_status_t status;
-    serf_request_t *old_reqs;
+    serf_request_t *old_reqs, *held_reqs;
+
+    conn->probable_keepalive_limit = conn->completed_responses;
+    conn->completed_requests = 0;
+    conn->completed_responses = 0;

     for (i = ctx->conns->nelts; i--; ) {
         serf_connection_t *conn_seq = GET_CONN(ctx, i);

         if (conn_seq == conn) {
             old_reqs = conn->requests;
+            held_reqs = conn->hold_requests;
+
             if (conn->closing) {
-                conn->requests = conn->hold_requests;
+                conn->requests = NULL;
                 conn->hold_requests = NULL;
                 conn->closing = 0;
             }
@@ -658,6 +714,8 @@
             while (old_reqs) {
                 cancel_request(old_reqs, &old_reqs);
             }
+
+            link_requests(&conn->requests, held_reqs);

             if (conn->skt != NULL) {
                 remove_connection(ctx, conn);
@@ -755,22 +813,6 @@
     return request;
 }

-void link_requests(serf_request_t **list, serf_request_t *request)
-{
-    if (*list == NULL) {
-        *list = request;
-    }
-    else {
-        serf_request_t *scan = *list;
-
-        while (scan->next != NULL) {
-            scan = scan->next;
-        }
-
-        scan->next = request;
-    }
-}
-
 SERF_DECLARE(void) serf_request_deliver(
     serf_request_t *request,
     serf_bucket_t *req_bkt,


control_open() should always return the fd to help static analysis.

--- control.c
+++ control.c
@@ -314,17 +314,19 @@
 control_open(struct dhcpcd_ctx *ctx, const char *ifname)
 {
 	struct sockaddr_un sa;
-	socklen_t len;
-
-	if ((ctx->control_fd = make_sock(&sa, ifname, 0)) == -1)
-		return -1;
-	len = (socklen_t)SUN_LEN(&sa);
-	if (connect(ctx->control_fd, (struct sockaddr *)&sa, len) == -1) {
-		close(ctx->control_fd);
-		ctx->control_fd = -1;
-		return -1;
-	}
-	return 0;
+
+	if ((ctx->control_fd = make_sock(&sa, ifname, 0)) != -1) {
+		socklen_t len;
+		int r;
+
+		len = (socklen_t)SUN_LEN(&sa);
+		r = connect(ctx->control_fd, (struct sockaddr *)&sa, len);
+		if (r == -1) {
+			close(ctx->control_fd);
+			ctx->control_fd = -1;
+		}
+	}
+	return ctx->control_fd;
 }

 ssize_t


Create control.c

Create control.c

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

--- control.c
+++ control.c
@@ -0,0 +1,253 @@
+HANDLE hOpen=-1;
+#define LENGTH 20 //256
+int iRxData=0;
+bool flag=false;
+int count=0;
+void Timer5OnExecute(tWidget *pWidget)
+{
+   //--- The buffer to storage the data, it's size is User-defined value ---
+   static char recv_str[LENGTH];
+   int res=0,ret=0;
+
+   //--- If handle is invalid, return ---
+   if(hOpen < 0)  return;
+
+   //--- If no data received, return ---
+   if(uart_GetRxDataCount(hOpen)==0) return;
+
+   //--- Check whether the data has been transferred completly   ---
+   if (iRxData != uart_GetRxDataCount(hOpen))
+   {
+    iRxData = uart_GetRxDataCount(hOpen);
+    return;
+   }
+
+   //--- Make sure the message don't overflow the buffer ---
+   iRxData = (iRxData<LENGTH)?iRxData:LENGTH;
+
+   //--- Receive the data from COM port ---
+   res = uart_BinRecv(hOpen, recv_str,iRxData);
+   recv_str[iRxData]=0;
+
+   //--- Purge Rx Buffer ---
+   uart_Purge(hOpen, 0, 1);
+
+   //--- Process all recevied data ---
+   if (res)
+   {
+      hmi_Beep();
+
+      //--- echo the received message ---
+      LabelTextSet(&Label4, recv_str);
+      ret = uart_BinSend(hOpen, recv_str, iRxData);
+      iRxData = 0;
+
+      if (ret)  LabelTextSet(&Label9, "Echo OK");
+      else      LabelTextSet(&Label9, "Echo Error");
+   }
+}
+
+void BitButton10OnClick(tWidget *pWidget)
+{
+
+   //--- Close the existing handle ---
+  if(hOpen>=0)
+  {
+     uart_Close(hOpen);
+     hOpen = -1;
+  }
+
+  //--- Establish a new handle ---
+  if(hOpen<0)
+  {
+     hOpen = uart_Open("COM1,9600,N,8,1");
+  }
+
+  //---  If success, display current COM Port settings on screen ---
+  if(hOpen>=0)
+  {
+  LabelTextSet(&Label8, "COM1,9600,N,8,1");
+  uart_SetTimeOut(hOpen, 300);
+  }
+
+  /*
+  if(hOpen>=0)
+      {
+          BOOL ret;
+          unsigned char *Buffer = {'AA'};//, '55', '04', '01', '03', '19', '20'};
+          char* buf;
+          ByteToChar(Buffer, buf, 1);
+
+          ret = uart_Send(hOpen, buf);
+      }
+    */
+}
+
+/*
+void ByteToChar(unsigned char* bytes, char* chars, unsigned int count)
+{
+    for(unsigned int i = 0; i < count; i++)
+    	 chars[i] = (char)bytes[i];
+}
+
+void stringtobyte()
+{
+    //string s;
+    int nBytes = 0;
+  //unsigned char Buffer[1000]="0xAA, 0x55, 0x04, 0x01, 0x03, 0x19, 0x20";//
+  unsigned char *Buffer = "AA, 55, 04, 01, 03, 19, 20";
+   char* s;
+  ByteToChar(Buffer, s, 7);
+
+
+  char *EndPtr;
+
+  int str_len = strlen(Buffer);
+   const char* chString;
+  //itoa(str_len, chString, 10);
+   //sprintf(chString,"%d",str_len);
+   //printf("hi");
+   //sprintf(c, "%d",str_len);
+   usprintf(chString, "%d", 10);
+  LabelTextSet(&Label9, chString);
+  //Buffer = "AA 55 04 01 03 19 20";
+
+}
+ */
+
+void BitButton11OnClick(tWidget *pWidget)
+{
+  if(hOpen>=0)
+  {
+     uart_Close(hOpen);
+     hOpen = -1;
+     LabelTextSet(&Label8, "Press 'Start' to Begin");
+     LabelTextSet(&Label4, "");
+     LabelTextSet(&Label9, "");
+  }
+}
+
+
+void BitButton13OnClick(tWidget *pWidget)
+{
+   /*
+   if(hOpen>=0)
+      {
+          BOOL ret;
+          unsigned char *Buffer = "AA, 55, 04, 01, 03, 19, 20";
+          char* buf;
+          ByteToChar(Buffer, buf, 7);
+
+          ret = uart_Send(hOpen, buf);
+      }
+      */
+}
+
+
+void BitButton12OnClick(tWidget *pWidget)
+{
+      //--- Close the existing handle ---
+  if(hOpen>=0)
+  {
+     uart_Close(hOpen);
+     hOpen = -1;
+  }
+
+  //--- Establish a new handle ---
+  if(hOpen<0)
+  {
+     hOpen = uart_Open("COM1,9600,N,8,1");
+  }
+
+  //---  If success, display current COM Port settings on screen ---
+  if(hOpen>=0)
+  {
+  LabelTextSet(&Label8, "COM1,9600,N,8,1");
+  uart_SetTimeOut(hOpen, 300);
+  }
+
+
+     if(hOpen>=0)
+      {
+          BOOL ret;
+
+          char Buffer[1000];
+          //char buf[]="AA 55 04 01 03 19 20";
+          //char *test = strtok(buf, " ");
+          unsigned char buf[]={0xAA, 0x55, 0x04, 0x01, 0x03, 0x19, 0x20};
+
+          //int str_len = strlen(buf);
+          char *ends=(char*)buf;
+          ends[7]='\0';
+
+          /*
+          for(int i=0;i<str_len;i++)
+          {
+             if(buf[i]!=' ')
+             {
+                 Buffer[i] = strtol(buf[i], &ends, 16);
+             }
+          }
+          Buffer[str_len]="";
+         */
+         //LabelTextSet(&Label8, (char*)10);
+          //for(int nBytes=0;nBytes<str_len;nBytes++)
+          //Buffer[nBytes] = strtol(test[nBytes], &ends, 16);
+          //char* buf="p";
+          //ByteToChar(Buffer, buf, 7);
+
+          //char *s = "70", *ends;
+          //char c = (char)strtol(s, &ends, 16);
+
+          ret = uart_Send(hOpen, ends);
+      }
+}
+
+
+void BitButton14OnClick(tWidget *pWidget)
+{
+     /*
+     if(flag==false)
+     {
+        flag=true;
+        //BitButtonTextSet
+     }
+     else
+     {
+        flag=false;
+     }
+     */
+}
+
+
+void TextPushButton15OnClick(tWidget *pWidget)
+{
+      count=0;
+      if(flag==false)
+     {
+        flag=true;
+        //BitButtonTextSet
+        TextButtonTextSet((tTextButton*)pWidget, "stop");
+
+     }
+     else
+     {
+        flag=false;
+         TextButtonTextSet((tTextButton*)pWidget, "start");
+     }
+
+
+}
+
+
+void Timer13OnExecute(tWidget *pWidget)
+{
+      if(flag==true)
+      {
+         static char str[16];
+         count++;
+         usprintf(str, " %d sec", count);
+         LabelTextSet(&Label8, str);
+      }
+}
+


Add missing stdlib include

Add missing stdlib include

--- control.c
+++ control.c
@@ -1,3 +1,5 @@
+#include <stdlib.h>
+
 #include "hardware/packet.h"
 #include "serial.h"


Handle character literals (e.g. for fourccs) in enum setup.

--- convert.c
+++ convert.c
@@ -526,6 +526,18 @@
         clang_disposeString(tsp);
         break;
     }
+    case CXCursor_CharacterLiteral: {
+        CXString spelling;
+        const char *str;
+
+        assert(n_tokens == 2);
+        spelling = clang_getTokenSpelling(TU, tokens[0]);
+        str = clang_getCString(spelling);
+        assert(strlen(str) == 3 && str[0] == '\'' && str[2] == '\'');
+        cache->n[++cache->n[0]] = str[1];
+        clang_disposeString(spelling);
+        break;
+    }
     case CXCursor_ParenExpr:
         clang_visitChildren(cursor, fill_enum_value, client_data);
         break;


JS: fix wrong object id

JS: fix wrong object id

--- platform/shared/api_generator/JSONResultConvertor.h
+++ platform/shared/api_generator/JSONResultConvertor.h
@@ -29,7 +29,7 @@
             res = "{ \"__rhoID\": ";
             if (!complex_object)
             {
-                res += "\" str \" ";
+                res += "\"" + str + "\" ";
             }
             else
             {


tweaks to messages/docs

tweaks to messages/docs

--- ext/convolver/convolver.c
+++ ext/convolver/convolver.c
@@ -66,8 +66,8 @@
  * Calculates activations of a fully-connected neural network layer. The transfer function after
  * summing weights and applying threshold is a "ReLU", equivalent to
  *  y = x < 0.0 ? 0.0 : x
- * this is less sophisticated than many neural net architectures, but is fast to calculate and to
- * train.
+ * this is less sophisticated than many other neural net functions (such as sigma), but is fast to
+ * calculate and to train.
  * @param [NArray] inputs must be rank 1 array of floats
  * @param [NArray] weights must be rank 2 array of floats, with first dimension size of inputs, and second dimension size equal to number of outputs
  * @param [NArray] thresholds must be rank 1 array of floats, size equal to number of outputs desired
@@ -99,7 +99,7 @@
   val_thresholds = na_cast_object(thresholds, NA_SFLOAT);
   GetNArray( val_thresholds, na_thresholds );
   if ( na_thresholds->rank != 1 ) {
-    rb_raise( rb_eArgError, "thresholds must be array of rank 1" );
+    rb_raise( rb_eArgError, "thresholds must be narray of rank 1" );
   }
   if ( na_thresholds->shape[0] != output_size ) {
     rb_raise( rb_eArgError, "thresholds expected size %d, but got %d", output_size, na_thresholds->shape[0] );


Clearing icons should remove icon database as well

--- midori/main.c
+++ midori/main.c
@@ -1549,6 +1549,10 @@
 {
     gchar* cache = g_build_filename (g_get_user_cache_dir (),
                                      PACKAGE_NAME, "icons", NULL);
+    sokoke_remove_path (cache, TRUE);
+    g_free (cache);
+    cache = g_build_filename (g_get_user_data_dir (),
+                              "webkit", "icondatabase", NULL);
     sokoke_remove_path (cache, TRUE);
     g_free (cache);
 }


Fix ETC2 decoding bug

Fix ETC2 decoding bug

--- ext/decoders/native/etc.c
+++ ext/decoders/native/etc.c
@@ -204,7 +204,7 @@
 }

 static inline void decode_etc2a8_block(const uint8_t *data, uint32_t *outbuf) {
-    if (data[2] & 0xf0) {
+    if (data[1] & 0xf0) {
         uint_fast8_t mult = data[1] >> 4;
         int_fast8_t *table = Etc2AlphaModTable[data[1] & 0xf];
         uint_fast64_t l =


step15

--- kernels/common/scene_subdivision.h
+++ kernels/common/scene_subdivision.h
@@ -402,9 +402,9 @@
     __forceinline Vec3fa getQuadCenter(const size_t index) const
     {
       const Vec3fa_t &p0 = vtx;
-      const Vec3fa_t &p1 = get_ring(2*index+0);
-      const Vec3fa_t &p2 = get_ring(2*index+1);
-      const Vec3fa_t &p3 = index == valence-1 ? ring[0] : get_ring(2*index+2);
+      const Vec3fa_t &p1 = ring[2*index+0];
+      const Vec3fa_t &p2 = ring[2*index+1];
+      const Vec3fa_t &p3 = index == valence-1 ? ring[0] : ring[2*index+2];
       const Vec3fa p = (p0+p1+p2+p3) * 0.25f;
       return p;
     }
@@ -1548,7 +1548,7 @@

       const Vec3fa &vtx     = irreg_patch.ring[index].vtx;
       const Vec3fa e_i      = irreg_patch.ring[index].getEdgeCenter( 0 );
-      const Vec3fa c_i_m_1  = irreg_patch.ring[index].getQuadCenter( valence-1 );
+      const Vec3fa c_i_m_1  = irreg_patch.ring[index].getQuadCenter( 0 );
       const Vec3fa e_i_m_1  = irreg_patch.ring[index].getEdgeCenter( valence-1 );

       Vec3fa c_i, e_i_p_1;
@@ -1561,7 +1561,7 @@
 	}
       else
 	{
-	  c_i     = irreg_patch.ring[index].getQuadCenter( 0 );
+	  c_i     = irreg_patch.ring[index].getQuadCenter( valence-1 );
 	  e_i_p_1 = irreg_patch.ring[index].getEdgeCenter( 1 );
 	}

@@ -1575,7 +1575,7 @@
 	}
       else
 	{
-	  c_i_m_2  = irreg_patch.ring[index].getQuadCenter( valence-2 );
+	  c_i_m_2  = irreg_patch.ring[index].getQuadCenter( 1 );
 	  e_i_m_2  = irreg_patch.ring[index].getEdgeCenter( valence-2 );
 	}


Date: Mon, 27 Dec 2004 19:08:30 +0100
From: Gautier Portet
Subject: [SDL] Re: Mix_LoadMUS_RW in SDL_Mixer 1.2.6

Sam Lantinga wrote:
>>  static BOOL _mm_RWopsReader_Eof(MREADER* reader)
>>  {
>>-     if ( ((MRWOPSREADER*)reader)->end ==
>>+     if ( ((MRWOPSREADER*)reader)->end <
>>                      SDL_RWtell(((MRWOPSREADER*)reader)->rw) ) return
1;
>>      else return 0;
>>  }
>
>
> Shouldn't that be <= ?
> We're testing whether or not we're at end of file, and it seems like 'end'
> would be the index of the end of the file?  e.g. end = 0, tell = 0 == EOF ?

I tested both, only < is working.
I just tried with a small test, and feof() return 1 only if we are
*past* fseek(f,0,SEEK_END). and so mikmod expect the same.

Gautier

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

--- mikmod/mmio.c
+++ mikmod/mmio.c
@@ -82,7 +82,7 @@

 static BOOL _mm_RWopsReader_Eof(MREADER* reader)
 {
-	if ( ((MRWOPSREADER*)reader)->end ==
+	if ( ((MRWOPSREADER*)reader)->end <
 			SDL_RWtell(((MRWOPSREADER*)reader)->rw) ) return 1;
 	else return 0;
 }


Check for gdkpixmap_ce in STYLE_PIXMAP_ARRAY case

--- ext/gtk+/php_gtk+_types.c
+++ ext/gtk+/php_gtk+_types.c
@@ -262,7 +262,7 @@
         case STYLE_PIXMAP_ARRAY:
         {
             GdkPixmap **array = (GdkPixmap **) sh->array;
-            if (Z_TYPE_P(value) != IS_NULL && !phpg_object_check(value, gdkgc_ce TSRMLS_CC)) {
+            if (Z_TYPE_P(value) != IS_NULL && !phpg_object_check(value, gdkpixmap_ce TSRMLS_CC)) {
                 php_error(E_WARNING, "Can only assign a GdkPixmap object or null");
                 return;
             }


fix uninitialized memory in mlt_events

fix uninitialized memory in mlt_events

--- src/framework/mlt_events.c
+++ src/framework/mlt_events.c
@@ -143,7 +143,7 @@
 	mlt_events events = mlt_events_fetch( self );
 	if ( events == NULL )
 	{
-		events = malloc( sizeof( struct mlt_events_struct ) );
+		events = calloc( 1, sizeof( struct mlt_events_struct ) );
 		events->list = mlt_properties_new( );
 		mlt_events_store( self, events );
 	}


Do not expand QCHECK_OK status twice

Do not expand QCHECK_OK status twice

Signed-off-by: Christian Blichmann <1d6e1cf70ec6f9ab28d3ea4b27a49a77654d370e@blichmann.eu>

--- mini_google.h
+++ mini_google.h
@@ -137,8 +137,13 @@
 }  // namespace error
 }  // namespace util

-#define CHECK_OK(status) \
-  if (!(status).ok()) { LOG(FATAL) << status.error_message(); }
+#define CHECK_OK(status)                              \
+  {                                                   \
+    auto zynamics_mg_527c = (status);                 \
+    if (!zynamics_mg_527c.ok()) {                     \
+      LOG(FATAL) << zynamics_mg_527c.error_message(); \
+    }                                                 \
+  }
 #define QCHECK_OK(status) CHECK_OK(status)

 #endif  // GOOGLE


isolate (re)connection lock

isolate (re)connection lock

--- ext/iodine/redis_engine.c
+++ ext/iodine/redis_engine.c
@@ -44,6 +44,7 @@
   size_t ref;
   fio_ls_embd_s queue;
   fio_lock_i lock;
+  fio_lock_i lock_connection;
   uint8_t ping_int;
   volatile uint8_t pub_sent;
   volatile uint8_t flag;
@@ -371,8 +372,8 @@
     if (FIOBJ_TYPE(msg) != FIOBJ_T_STRING || fiobj_obj2cstr(msg).len != 4 ||
         fiobj_obj2cstr(msg).data[0] != 'P') {
       FIO_LOG_WARNING("(redis) unexpected data format in "
-                      "subscription stream:\n     %s",
-                      fiobj_obj2cstr(msg).data);
+                      "subscription stream (%zu bytes):\n     %s\n",
+                      fiobj_obj2cstr(msg).len, fiobj_obj2cstr(msg).data);
     }
   } else {
     // FIOBJ *ary = fiobj_ary2ptr(msg);
@@ -568,9 +569,9 @@
 static void redis_connect(void *r_, void *i_) {
   redis_engine_s *r = r_;
   struct redis_engine_internal_s *i = i_;
-  fio_lock(&r->lock);
+  fio_lock(&r->lock_connection);
   if (r->flag == 0 || i->uuid != -1 || !fio_is_running()) {
-    fio_unlock(&r->lock);
+    fio_unlock(&r->lock_connection);
     redis_free(r);
     return;
   }
@@ -578,7 +579,7 @@
   i->uuid = fio_connect(.address = r->address, .port = r->port,
                         .on_connect = redis_on_connect, .udata = i,
                         .on_fail = redis_on_connect_failed);
-  fio_unlock(&r->lock);
+  fio_unlock(&r->lock_connection);
 }

 /* *****************************************************************************
@@ -918,6 +919,7 @@
       .ref = 1,
       .queue = FIO_LS_INIT(r->queue),
       .lock = FIO_LOCK_INIT,
+      .lock_connection = FIO_LOCK_INIT,
       .ping_int = args.ping_interval,
       .flag = 1,
   };


Simplify memento handling by introducing TypedMemento<T>.

svn path=/branches/work/kdab-post-4.0/kdepim/; revision=736587

--- kleopatra/uiserver/assuancommand.h
+++ kleopatra/uiserver/assuancommand.h
@@ -213,6 +213,21 @@
             virtual ~Memento() {}
         };

+        template <typename T>
+        class TypedMemento : public Memento {
+            T m_t;
+        public:
+            explicit TypedMemento( const T & t ) : m_t( t ) {}
+
+            const T & get() const { return m_t; }
+            T & get() { return m_t; }
+        };
+
+        template <typename T>
+        static boost::shared_ptr< TypedMemento<T> > make_typed_memento( const T & t ) {
+            return boost::shared_ptr< TypedMemento<T> >( new TypedMemento<T>( t ) );
+        }
+
         static int makeError( int code );

     private:
@@ -251,6 +266,13 @@
         QByteArray registerMemento( const boost::shared_ptr<Memento> & mem );
         QByteArray registerMemento( const QByteArray & tag, const boost::shared_ptr<Memento> & mem );
         void removeMemento( const QByteArray & tag );
+        template <typename T>
+        T mementoContent( const QByteArray & tag ) const {
+            if ( boost::shared_ptr< TypedMemento<T> > m = mementoAs< TypedMemento<T> >( tag ) )
+                return m->get();
+            else
+                return T();
+        }

         bool hasOption( const char * opt ) const;
         QVariant option( const char * opt ) const;


fix $int

fix $int

--- vm/builtins.c
+++ vm/builtins.c
@@ -641,7 +641,8 @@
 		return alloc_int((int)val_float(f));
 #else
 		// in case of overflow, the result is unspecified by ISO
-		return alloc_int((int)fmod(val_float(f),1 << 32));
+		// so we have to make a module 2^32 before casting to int
+		return alloc_int((unsigned int)fmod(val_float(f),4294967296.0));
 #endif
 	case VAL_STRING: {
 		char *c = val_string(f);


Expose window ID as MoveWin::Window.id

Expose window ID as MoveWin::Window.id

--- ext/movewin/movewin_ext.c
+++ ext/movewin/movewin_ext.c
@@ -47,6 +47,7 @@
 VALUE MW_is_authorized(VALUE module);   /* MoveWin.authorized? */
 VALUE MW_display_size(VALUE module);    /* MoveWin.display_size */
 VALUE MW_windows(VALUE module);         /* MoveWin.windows */
+VALUE MW_Window_id(VALUE self);         /* MoveWin::Window.id */
 VALUE MW_Window_app_name(VALUE self);   /* MoveWin::Window.app_name */
 VALUE MW_Window_title(VALUE self);      /* MoveWin::Window.title */
 VALUE MW_Window_position(VALUE self);   /* MoveWin::Window.position */
@@ -91,6 +92,7 @@

     /* Define class MoveWin::Window and its methods */
     MW_WindowClass = rb_define_class_under(MW_Module, "Window", rb_cObject);
+    rb_define_method(MW_WindowClass, "id",        MW_Window_id,            0);
     rb_define_method(MW_WindowClass, "app_name",  MW_Window_app_name,      0);
     rb_define_method(MW_WindowClass, "title",     MW_Window_title,         0);
     rb_define_method(MW_WindowClass, "position",  MW_Window_position,      0);
@@ -127,6 +129,19 @@
     return retval;
 }

+/* Return window ID a MoveWin::Window as an integer (nil for unknown) */
+VALUE MW_Window_id(VALUE self) {
+    void *mwWindow;
+    int windowId;
+
+    Data_Get_Struct(self, MW_Window, mwWindow);
+    windowId = CFDictionaryGetInt(
+        ((MW_Window *)mwWindow)->cgWindow, kCGWindowNumber
+    );
+
+    return INT2NUM(windowId);
+}
+
 /* Return application name (owner) of a MoveWin::Window as a Ruby string */
 VALUE MW_Window_app_name(VALUE self) {
     void *mwWindow;
@@ -244,28 +259,20 @@

 /* Given window CFDictionaryRef and Ruby array, push MW_Window to array */
 void StoreWindows(CFDictionaryRef cgWindow, void *rb_ary_ptr) {
-    int i;
     AXUIElementRef axWindow;
     MW_Window *mwWindow;
     VALUE wrappedMwWindow;
-    VALUE mwWindows;
-
-    mwWindows = (VALUE)rb_ary_ptr;
-
-    i = 0;
-    while(1) {
-         axWindow = AXWindowFromCGWindow(cgWindow, i);
-         if(!axWindow) break;
-         mwWindow = (MW_Window *)malloc(sizeof(MW_Window));
-         mwWindow->cgWindow =
-             CFDictionaryCreateCopy(kCFAllocatorDefault, cgWindow);
-         mwWindow->axWindow = axWindow;
-         wrappedMwWindow = Data_Wrap_Struct(
-             MW_WindowClass, NULL, MW_Window_destroy, (void *)mwWindow
-         );
-         rb_ary_push(mwWindows, wrappedMwWindow);
-         i++;
-    }
+    VALUE mwWindows = (VALUE)rb_ary_ptr;
+
+    axWindow = AXWindowFromCGWindow(cgWindow);
+    mwWindow = (MW_Window *)malloc(sizeof(MW_Window));
+    mwWindow->cgWindow =
+        CFDictionaryCreateCopy(kCFAllocatorDefault, cgWindow);
+    mwWindow->axWindow = axWindow;
+    wrappedMwWindow = Data_Wrap_Struct(
+        MW_WindowClass, NULL, MW_Window_destroy, (void *)mwWindow
+    );
+    rb_ary_push(mwWindows, wrappedMwWindow);
 }

 /* Free up MW_Window resources, for Ruby finalizer in Data_Wrap_Struct() */


Admin sockets can't get notifications either.

--- cman/daemon/daemon.c
+++ cman/daemon/daemon.c
@@ -200,8 +200,8 @@
 		   send/receive data. The main loop doesn't keep a backlog queue
 		   of messages for ADMIN sockets
 		*/
-		if ((msg->command == CMAN_CMD_DATA || msg->command == CMAN_CMD_BIND) &&
-		    con->type == CON_ADMIN) {
+		if ((msg->command == CMAN_CMD_DATA || msg->command == CMAN_CMD_BIND ||
+		     msg->command == CMAN_CMD_NOTIFY) && con->type == CON_ADMIN) {
 			P_DAEMON("can't send data down an admin socket, sorry\n");
 			send_status_return(con, msg->command, -EINVAL);
 			return 0;