take two

take two

--- crap/eq_const_T420.h
+++ crap/eq_const_T420.h
@@ -55,18 +55,16 @@
 adjust(personal *data, ulong fs)
 {
 	biquad *filters = data->filters[0];
-	// TODO: reduce ~3dB peaks at 1680, 2200
-	// TODO: reduce small peak at 600, 3780, 10600
-	filters[ 0] = biquad_gen(FILT_PEAKING,    150.,  12., 1.50, fs);
-	filters[ 1] = biquad_gen(FILT_PEAKING,    640.,  7.0, 0.80, fs);
+	filters[ 0] = biquad_gen(FILT_PEAKING,    180.,  11., 1.40, fs);
+	filters[ 1] = biquad_gen(FILT_PEAKING,    740.,  5.5, 0.70, fs);
 	filters[ 2] = biquad_gen(FILT_PEAKING,    1220, -12., 0.70, fs);
-	filters[ 3] = biquad_gen(FILT_PEAKING,    1670,  9.0, 0.18, fs);
-	filters[ 4] = biquad_gen(FILT_PEAKING,    2270,  9.0, 0.20, fs);
-	filters[ 5] = biquad_gen(FILT_PEAKING,    2470, -7.0, 0.16, fs);
-	filters[ 6] = biquad_gen(FILT_PEAKING,    3200, -0.1, 0.25, fs);
-	filters[ 7] = biquad_gen(FILT_PEAKING,    6200, -3.5, 0.25, fs);
-	filters[ 8] = biquad_gen(FILT_PEAKING,    6000, -9.0, 4.00, fs);
-	filters[ 9] = biquad_gen(FILT_PEAKING,   11560,  6.0, 0.12, fs);
-	filters[10] = biquad_gen(FILT_HIGHSHELF, 11000,  5.0, 0.50, fs);
-	filters[11] = biquad_gen(FILT_HIGHPASS,    120,  0.0, 1.00, fs);
+	filters[ 3] = biquad_gen(FILT_PEAKING,    1670,  6.0, 0.18, fs);
+	filters[ 4] = biquad_gen(FILT_PEAKING,    2080, -2.5, 0.30, fs);
+	filters[ 5] = biquad_gen(FILT_PEAKING,    2270,  6.0, 0.20, fs);
+	filters[ 6] = biquad_gen(FILT_PEAKING,    2470, -7.0, 0.16, fs);
+	filters[ 7] = biquad_gen(FILT_PEAKING,    3780, -1.5, 0.38, fs);
+	filters[ 8] = biquad_gen(FILT_PEAKING,    6200, -3.5, 0.25, fs);
+	filters[ 9] = biquad_gen(FILT_PEAKING,    6000, -9.0, 4.00, fs);
+	filters[10] = biquad_gen(FILT_HIGHSHELF, 12000,  4.0, 0.40, fs);
+	filters[11] = biquad_gen(FILT_HIGHPASS,    150,  0.0, 1.00, fs);
 }


enable setting address information manually

--- krb5module.c
+++ krb5module.c
@@ -1045,6 +1045,52 @@
     {
       return PyString_FromString(addr);
     }
+}
+
+typedef struct addr_storage
+{
+  struct in_addr ip4;
+  struct in6_addr ip6;
+} addr_storage;
+
+/* Convert a string representation of an address to a krb5_address */
+static int
+str_to_addr(const char* address, krb5_address *krb5addr, addr_storage *as)
+{
+  struct in_addr ipv4addr;
+  struct in6_addr ipv6addr;
+
+  /* First try ipv4, and if that fails, try ipv6 */
+  if (inet_pton(AF_INET, address, &ipv4addr)) {
+    krb5addr->addrtype = ADDRTYPE_INET;
+    as->ip4 = ipv4addr;
+    krb5addr->length = sizeof(as->ip4.s_addr);
+    krb5addr->contents = (krb5_octet *) &(as->ip4.s_addr);
+    return 1;
+  } else if (inet_pton(AF_INET6, address, &ipv6addr)) {
+    krb5addr->addrtype = ADDRTYPE_INET6;
+    as->ip6 = ipv6addr;
+    krb5addr->length = sizeof(as->ip6.s6_addr);
+    krb5addr->contents = (krb5_octet *) &(as->ip6.s6_addr);
+    return 1;
+  }
+
+  return 0;
+}
+
+/* Convert an unsigned short port to a krb5_address */
+static int
+port_to_addr(unsigned short port, krb5_address *krb5addr)
+{
+  /* If port == 0, don't set anything and return 0 */
+  if (port > 0) {
+    krb5addr->addrtype = ADDRTYPE_IPPORT;
+    krb5addr->length = sizeof(port);
+    krb5addr->contents = (krb5_octet *) &port;
+    return 1;
+  }
+
+  return 0;
 }

 /*********************** AuthContext **********************/
@@ -1152,7 +1198,7 @@
   krb5_context ctx = NULL;
   krb5_auth_context ac = NULL;
   krb5_error_code rc;
-
+
   if(!PyArg_ParseTuple(args, "OO!O:__setattr__", &self, &PyString_Type, &nameo, &value))
     return NULL;
   inst = (PyInstanceObject *)self;
@@ -1213,10 +1259,56 @@
       if(rc)
 	return pk_error(rc);
     }
-  else if(!strcmp(name, "addrs")
-	  || (!strcmp(name, "context") && ctx)
-	  || (!strcmp(name, "_ac") && ac)
-	  )
+  else if(!strcmp(name, "addrs"))
+    {
+      krb5_address localaddr, remoteaddr, localport, remoteport;
+      krb5_address *la = NULL, *ra = NULL, *lp = NULL, *rp = NULL;
+      unsigned int lport, rport;
+      char *laddr, *raddr;
+      addr_storage local_as, remote_as;
+
+      if(!PyArg_ParseTuple(value, "zIzI", &laddr, &lport, &raddr, &rport))
+        return NULL;
+
+      if(laddr) {
+        if (str_to_addr(laddr, &localaddr, &local_as)) {
+          la = &localaddr;
+        } else {
+          PyErr_Format(PyExc_AttributeError, "invalid address: %.400s", laddr);
+          return NULL;
+        }
+      }
+
+      if(raddr) {
+        if (str_to_addr(raddr, &remoteaddr, &remote_as)) {
+          ra = &remoteaddr;
+        } else {
+          PyErr_Format(PyExc_AttributeError, "invalid address: %.400s", raddr);
+          return NULL;
+        }
+      }
+
+      if(lport > 65535 || rport > 65535) {
+        PyErr_Format(PyExc_AttributeError, "port numbers cannot be greater than 65535");
+        return NULL;
+      }
+
+      if (port_to_addr((unsigned short) lport, &localport))
+        lp = &localport;
+
+      if (port_to_addr((unsigned short) rport, &remoteport))
+        rp = &remoteport;
+
+      rc = krb5_auth_con_setaddrs(ctx, ac, la, ra);
+      if(rc)
+        return pk_error(rc);
+
+      rc = krb5_auth_con_setports(ctx, ac, lp, rp);
+      if(rc)
+        return pk_error(rc);
+    }
+  else if((!strcmp(name, "context") && ctx) ||
+          (!strcmp(name, "_ac") && ac))
     {
       PyErr_Format(PyExc_AttributeError, "You cannot set attribute '%.400s'", name);
       return NULL;


Check input size before NULL pointer test inside mem_write()

Checking is performed after the read-only test so it catches such errors
earlier.

CLA: trivial

Reviewed-by: Dmitry Belyavskiy <38c64d6e24766247aad56af3a6ddb0056ad36a44@gmail.com>
Reviewed-by: Tomas Mraz <2bc6038c3dfca09b2da23c8b6da8ba884dc2dcc2@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13786)

--- crypto/bio/bss_mem.c
+++ crypto/bio/bss_mem.c
@@ -221,17 +221,17 @@
     int blen;
     BIO_BUF_MEM *bbm = (BIO_BUF_MEM *)b->ptr;

+    if (b->flags & BIO_FLAGS_MEM_RDONLY) {
+        ERR_raise(ERR_LIB_BIO, BIO_R_WRITE_TO_READ_ONLY_BIO);
+        goto end;
+    }
+    BIO_clear_retry_flags(b);
+    if (inl == 0)
+        return 0;
     if (in == NULL) {
         ERR_raise(ERR_LIB_BIO, ERR_R_PASSED_NULL_PARAMETER);
         goto end;
     }
-    if (b->flags & BIO_FLAGS_MEM_RDONLY) {
-        ERR_raise(ERR_LIB_BIO, BIO_R_WRITE_TO_READ_ONLY_BIO);
-        goto end;
-    }
-    BIO_clear_retry_flags(b);
-    if (inl == 0)
-        return 0;
     blen = bbm->readp->length;
     mem_buf_sync(b);
     if (BUF_MEM_grow_clean(bbm->buf, blen + inl) == 0)


Remove some dead code from EC_GROUP_check()

EC_GROUP_check() was obtaining a temporary BIGNUM from the BN_CTX, but
then not using it.

Reviewed-by: Rich Salz <c04971a99e5a9ee80eaab4b1deb37e845b0bd697@openssl.org>

--- crypto/ec/ec_check.c
+++ crypto/ec/ec_check.c
@@ -73,9 +73,6 @@
             goto err;
         }
     }
-    BN_CTX_start(ctx);
-    if ((order = BN_CTX_get(ctx)) == NULL)
-        goto err;

     /* check the discriminant */
     if (!EC_GROUP_check_discriminant(group, ctx)) {
@@ -114,8 +111,6 @@
     ret = 1;

  err:
-    if (ctx != NULL)
-        BN_CTX_end(ctx);
     BN_CTX_free(new_ctx);
     EC_POINT_free(point);
     return ret;


Increase offset for BIO_f_enc() to avoid problems with overlapping buffers when decrypting data.

--- crypto/evp/bio_enc.c
+++ crypto/evp/bio_enc.c
@@ -71,7 +71,7 @@
 static int enc_free(BIO *data);
 static long enc_callback_ctrl(BIO *h, int cmd, bio_info_cb *fps);
 #define ENC_BLOCK_SIZE	(1024*4)
-#define BUF_OFFSET	EVP_MAX_BLOCK_LENGTH
+#define BUF_OFFSET	(EVP_MAX_BLOCK_LENGTH*2)

 typedef struct enc_struct
 	{


Initialize outl in evp_enc.c to 0, protect against NULL

Fixes #12734

Reviewed-by: Matt Caswell <1fa2ef4755a9226cb9a0a4840bd89b158ac71391@openssl.org>
Reviewed-by: Tomas Mraz <973cc78d8b4cb00714230ba9be0225e917ab4ac6@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/13268)

--- crypto/evp/evp_enc.c
+++ crypto/evp/evp_enc.c
@@ -535,6 +535,13 @@
     size_t soutl;
     int blocksize;

+    if (outl != NULL) {
+        *outl = 0;
+    } else {
+        EVPerr(EVP_F_EVP_ENCRYPTUPDATE, ERR_R_PASSED_NULL_PARAMETER);
+        return 0;
+    }
+
     /* Prevent accidental use of decryption context when encrypting */
     if (!ctx->encrypt) {
         EVPerr(EVP_F_EVP_ENCRYPTUPDATE, EVP_R_INVALID_OPERATION);
@@ -588,6 +595,13 @@
     unsigned int i, b, bl;
     size_t soutl;
     int blocksize;
+
+    if (outl != NULL) {
+        *outl = 0;
+    } else {
+        EVPerr(EVP_F_EVP_ENCRYPTFINAL_EX, ERR_R_PASSED_NULL_PARAMETER);
+        return 0;
+    }

     /* Prevent accidental use of decryption context when encrypting */
     if (!ctx->encrypt) {
@@ -669,6 +683,13 @@
     unsigned int b;
     size_t soutl;
     int blocksize;
+
+    if (outl != NULL) {
+        *outl = 0;
+    } else {
+        EVPerr(EVP_F_EVP_DECRYPTUPDATE, ERR_R_PASSED_NULL_PARAMETER);
+        return 0;
+    }

     /* Prevent accidental use of encryption context when decrypting */
     if (ctx->encrypt) {
@@ -783,6 +804,13 @@
     size_t soutl;
     int ret;
     int blocksize;
+
+    if (outl != NULL) {
+        *outl = 0;
+    } else {
+        EVPerr(EVP_F_EVP_DECRYPTFINAL_EX, ERR_R_PASSED_NULL_PARAMETER);
+        return 0;
+    }

     /* Prevent accidental use of encryption context when decrypting */
     if (ctx->encrypt) {


--- libIP2Location/IP2Loc_DBInterface.c
+++ libIP2Location/IP2Loc_DBInterface.c
@@ -271,9 +271,13 @@
     {
         fseek(handle, position-1, 0);
         temp = fread(&byte1, 1, 1, handle);
+	if (temp) { }; // make -Wunused-but-set-variable happy for now
         temp = fread(&byte2, 1, 1, handle);
+	if (temp) { }; // make -Wunused-but-set-variable happy for now
         temp = fread(&byte3, 1, 1, handle);
+	if (temp) { }; // make -Wunused-but-set-variable happy for now
         temp = fread(&byte4, 1, 1, handle);
+	if (temp) { }; // make -Wunused-but-set-variable happy for now
     }
     else
     {
@@ -295,6 +299,7 @@
     {
         fseek(handle, position-1, 0);
         temp = fread(&ret, 1, 1, handle);
+	if (temp) { }; // make -Wunused-but-set-variable happy for now
     }
     else
     {
@@ -309,13 +314,16 @@
     char *str = 0;
     uint8_t *cache_shm = cache_shm_ptr;
     size_t temp;
+
     if (DB_access_type == IP2LOCATION_FILE_IO && handle != NULL)
     {
         fseek(handle, position, 0);
         temp = fread(&size, 1, 1, handle);
+	if (temp) { }; // make -Wunused-but-set-variable happy for now
         str = (char *)malloc(size+1);
         memset(str, 0, size+1);
         temp = fread(str, size, 1, handle);
+	if (temp) { }; // make -Wunused-but-set-variable happy for now
     }
     else
     {
@@ -341,9 +349,13 @@
     {
         fseek(handle, position-1, 0);
         temp = fread(p+3, 1, 1, handle);
+	if (temp == NULL) { }; // make -Wunused-but-set-variable happy for now
         temp = fread(p+2, 1, 1, handle);
+	if (temp) { }; // make -Wunused-but-set-variable happy for now
         temp = fread(p+1, 1, 1, handle);
+	if (temp) { }; // make -Wunused-but-set-variable happy for now
         temp = fread(p,   1, 1, handle);
+	if (temp) { }; // make -Wunused-but-set-variable happy for now
     }
     else
     {
@@ -357,6 +369,7 @@
     {
         fseek(handle, position-1, 0);
         temp = fread(&ret, 4, 1, handle);
+	if (temp) { }; // make -Wunused-but-set-variable happy for now
     }
     else
     {
@@ -365,5 +378,3 @@
 #endif
     return ret;
 }
-
-


Define threads_lib.c functions only for OPENSSL_SYS_UNIX

This matches the declaration in <openssl/crypto.h>.

Reviewed-by: Hugo Landau <ce9fa1e55a72fc9b85dd06e47ea2c07848fb7d2c@openssl.org>
Reviewed-by: Tomas Mraz <2bc6038c3dfca09b2da23c8b6da8ba884dc2dcc2@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19322)

--- crypto/threads_lib.c
+++ crypto/threads_lib.c
@@ -8,7 +8,8 @@
  */
 #include <openssl/crypto.h>

-#ifndef OPENSSL_NO_DEPRECATED_3_0
+#ifdef OPENSSL_SYS_UNIX
+# ifndef OPENSSL_NO_DEPRECATED_3_0

 void OPENSSL_fork_prepare(void)
 {
@@ -22,4 +23,5 @@
 {
 }

+# endif
 #endif


Fixup function prototypes

Fixup function prototypes

GCC complains that we are aliasing to functions with the wrong prototype,
so create the default functions with the right prototype and use them
in the aliases to get GCC to shut up.

--- libc/misc/internals/__uClibc_main.c
+++ libc/misc/internals/__uClibc_main.c
@@ -395,15 +395,41 @@
  * if it gets linked in.
  */

-static int __pthread_return_0 (void) { return 0; }
+/* Threading functions internal to uClibc.  Make these thread functions
+ * weak so that we can elide them from single-threaded processes.  */
+static int __pthread_mutex_init_0 (pthread_mutex_t *__mutex,
+                __const pthread_mutexattr_t *__mutex_attr) { return 0; }
+static int __pthread_mutex_lock_0 (pthread_mutex_t *__mutex) { return 0; }
+static int __pthread_mutex_unlock_0 (pthread_mutex_t *__mutex) { return 0; }
+static int __pthread_mutex_trylock_0 (pthread_mutex_t *__mutex) { return 0; }
+
+# ifndef __UCLIBC_HAS_THREADS_NATIVE__
+static void _pthread_cleanup_push_defer_0 (
+                struct _pthread_cleanup_buffer *__buffer,
+                void (*__routine) (void *), void *__arg) { return; }
+static void _pthread_cleanup_pop_restore_0 (
+                struct _pthread_cleanup_buffer *__buffer,
+                int __execute) { return; }
+# endif
+
+#if 0
+static int __pthread_return_0 (void) { return 0; }
+static void __pthread_return_void (void) { return; }
+extern __typeof (__pthread_return_0) __pthread_mutex_trylock __attribute__ ((weak, alias ("__pthread_return_0")));
+#endif
+
+#if 0
+static int __pthread_return_0 (pthread_mutex_t *__mutex) { return 0; }
+/*static int __pthread_return_0 (void) { return 0; }*/
 static void __pthread_return_void (void) { return; }
-
-weak_alias (__pthread_return_0, __pthread_mutex_init)
-weak_alias (__pthread_return_0, __pthread_mutex_lock)
-weak_alias (__pthread_return_0, __pthread_mutex_trylock)
-weak_alias (__pthread_return_0, __pthread_mutex_unlock)
-weak_alias (__pthread_return_void, _pthread_cleanup_push_defer)
-weak_alias (__pthread_return_void, _pthread_cleanup_pop_restore)
+#endif
+
+weak_alias (__pthread_mutex_init_0, __pthread_mutex_init)
+weak_alias (__pthread_mutex_lock_0, __pthread_mutex_lock)
+weak_alias (__pthread_mutex_trylock_0, __pthread_mutex_trylock)
+weak_alias (__pthread_mutex_unlock_0, __pthread_mutex_unlock)
+weak_alias (_pthread_cleanup_push_defer_0, _pthread_cleanup_push_defer)
+weak_alias (_pthread_cleanup_pop_restore_0, _pthread_cleanup_pop_restore)
 # ifdef __UCLIBC_HAS_THREADS_NATIVE__
 weak_alias (__pthread_return_0, __pthread_mutexattr_init)
 weak_alias (__pthread_return_0, __pthread_mutexattr_destroy)


Remove use of the old CRYPTO_LOCK_X5O9_STORE

The locking here is a bit strange and unclear. Rather than refactor
anything and possibly break stuff I have just moved to using the new
thread API following as closely as possible what was there previously.

Reviewed-by: Richard Levitte <5fb523282dd7956571c80524edc2dccfa0bd8234@openssl.org>

--- crypto/x509/by_dir.c
+++ crypto/x509/by_dir.c
@@ -71,6 +71,7 @@

 #include <openssl/lhash.h>
 #include <openssl/x509.h>
+#include "internal/threads.h"
 #include "internal/x509_int.h"
 #include "x509_lcl.h"

@@ -88,6 +89,7 @@
 typedef struct lookup_dir_st {
     BUF_MEM *buffer;
     STACK_OF(BY_DIR_ENTRY) *dirs;
+    CRYPTO_RWLOCK *lock;
 } BY_DIR;

 static int dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
@@ -148,14 +150,20 @@
     BY_DIR *a;

     if ((a = OPENSSL_malloc(sizeof(*a))) == NULL)
-        return (0);
+        return 0;
     if ((a->buffer = BUF_MEM_new()) == NULL) {
         OPENSSL_free(a);
-        return (0);
+        return 0;
     }
     a->dirs = NULL;
+    a->lock = CRYPTO_THREAD_lock_new();
+    if (a->lock == NULL) {
+        BUF_MEM_free(a->buffer);
+        OPENSSL_free(a);
+        return 0;
+    }
     lu->method_data = (char *)a;
-    return (1);
+    return 1;
 }

 static void by_dir_hash_free(BY_DIR_HASH *hash)
@@ -187,6 +195,7 @@
     a = (BY_DIR *)lu->method_data;
     sk_BY_DIR_ENTRY_pop_free(a->dirs, by_dir_entry_free);
     BUF_MEM_free(a->buffer);
+    CRYPTO_THREAD_lock_free(a->lock);
     OPENSSL_free(a);
 }

@@ -297,7 +306,7 @@
         }
         if (type == X509_LU_CRL && ent->hashes) {
             htmp.hash = h;
-            CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE);
+            CRYPTO_THREAD_read_lock(ctx->lock);
             idx = sk_BY_DIR_HASH_find(ent->hashes, &htmp);
             if (idx >= 0) {
                 hent = sk_BY_DIR_HASH_value(ent->hashes, idx);
@@ -306,7 +315,7 @@
                 hent = NULL;
                 k = 0;
             }
-            CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE);
+            CRYPTO_THREAD_unlock(ctx->lock);
         } else {
             k = 0;
             hent = NULL;
@@ -363,18 +372,18 @@
         /*
          * we have added it to the cache so now pull it out again
          */
-        CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
+        CRYPTO_THREAD_write_lock(ctx->lock);
         j = sk_X509_OBJECT_find(xl->store_ctx->objs, &stmp);
         if (j != -1)
             tmp = sk_X509_OBJECT_value(xl->store_ctx->objs, j);
         else
             tmp = NULL;
-        CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
+        CRYPTO_THREAD_unlock(ctx->lock);

         /* If a CRL, update the last file suffix added for this */

         if (type == X509_LU_CRL) {
-            CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
+            CRYPTO_THREAD_write_lock(ctx->lock);
             /*
              * Look for entry again in case another thread added an entry
              * first.
@@ -388,7 +397,7 @@
             if (!hent) {
                 hent = OPENSSL_malloc(sizeof(*hent));
                 if (hent == NULL) {
-                    CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
+                    CRYPTO_THREAD_unlock(ctx->lock);
                     X509err(X509_F_GET_CERT_BY_SUBJECT, ERR_R_MALLOC_FAILURE);
                     ok = 0;
                     goto finish;
@@ -396,15 +405,16 @@
                 hent->hash = h;
                 hent->suffix = k;
                 if (!sk_BY_DIR_HASH_push(ent->hashes, hent)) {
-                    CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
+                    CRYPTO_THREAD_unlock(ctx->lock);
                     OPENSSL_free(hent);
                     ok = 0;
                     goto finish;
                 }
-            } else if (hent->suffix < k)
+            } else if (hent->suffix < k) {
                 hent->suffix = k;
-
-            CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
+            }
+
+            CRYPTO_THREAD_unlock(ctx->lock);

         }


mips/loongson_1b: fix rt_interrupt_dispatch

--- libcpu/mips/loongson_1b/interrupt.c
+++ libcpu/mips/loongson_1b/interrupt.c
@@ -159,7 +159,7 @@
                 param = irq_handle_table[irq].param;

 				/* do interrupt */
-                (*irq_func)(irq, param);
+                irq_func(irq, param);

 #ifdef RT_USING_INTERRUPT_INFO
                 irq_handle_table[irq].counter++;


Revert "revertme! Try to make system tests reliable"

This reverts commit 4399b3eeb13be96a077169e32308c45655750207.

refs: #1072

--- test/system/blobgen.c
+++ test/system/blobgen.c
@@ -176,9 +176,6 @@
   OmlValueU v[3];
   omlc_zero_array(v, 3);

-  /* XXX: Need to wait some time in order not to confuse... something? See #1072. */
-  usleep(1000000);
-
   /* Piggyback on v[0] which should later contain a string */
   omlc_set_string(v[0], "v1");
   omlc_inject_metadata(mp, "k1", &v[0], OML_STRING_VALUE, NULL);


fixes some (not all) buffer overreads during decoding pentax makernote entries.

This should fix:
https://sourceforge.net/p/libexif/bugs/125/ CVE-2016-6328

--- libexif/pentax/mnote-pentax-entry.c
+++ libexif/pentax/mnote-pentax-entry.c
@@ -425,24 +425,34 @@
 		case EXIF_FORMAT_SHORT:
 		  {
 			const unsigned char *data = entry->data;
-		  	size_t k, len = strlen(val);
+		  	size_t k, len = strlen(val), sizeleft;
+
+			sizeleft = entry->size;
 		  	for(k=0; k<entry->components; k++) {
+				if (sizeleft < 2)
+					break;
 				vs = exif_get_short (data, entry->order);
 				snprintf (val+len, maxlen-len, "%i ", vs);
 				len = strlen(val);
 				data += 2;
+				sizeleft -= 2;
 			}
 		  }
 		  break;
 		case EXIF_FORMAT_LONG:
 		  {
 			const unsigned char *data = entry->data;
-		  	size_t k, len = strlen(val);
+		  	size_t k, len = strlen(val), sizeleft;
+
+			sizeleft = entry->size;
 		  	for(k=0; k<entry->components; k++) {
+				if (sizeleft < 4)
+					break;
 				vl = exif_get_long (data, entry->order);
 				snprintf (val+len, maxlen-len, "%li", (long int) vl);
 				len = strlen(val);
 				data += 4;
+				sizeleft -= 4;
 			}
 		  }
 		  break;
@@ -455,5 +465,5 @@
 		break;
 	}

-	return (val);
+	return val;
 }


fix a few warnings by defining var in adequate block

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

--- libgphoto2/gphoto2-abilities-list.c
+++ libgphoto2/gphoto2-abilities-list.c
@@ -367,7 +367,7 @@
 {
 	GPPortInfo info;
 	GPPort *port;
-	int i, info_count, ability;
+	int i, info_count;

 	CHECK_NULL (list && info_list && l);

@@ -382,7 +382,8 @@
 		CHECK_RESULT (gp_port_info_list_get_info (info_list, i, &info));
 		CHECK_RESULT (gp_port_set_info (port, info));
 		switch (info.type) {
-		case GP_PORT_USB:
+		case GP_PORT_USB: {
+			int ability;
 			res = gp_abilities_list_detect_usb (list, &ability, port);
 			if (res == GP_OK) {
 				gp_list_append(l,
@@ -392,7 +393,7 @@
 				gp_port_set_error (port, NULL);

 			break;
-
+		}
 		default:
 			/*
 			 * We currently cannot detect any cameras on this


Untabify cbits/float.c

Untabify cbits/float.c

--- libraries/integer-gmp/cbits/float.c
+++ libraries/integer-gmp/cbits/float.c
@@ -72,15 +72,15 @@

     /* Convert MP_INT to a double; knows a lot about internal rep! */
     for(r = 0.0, i = __abs(size)-1; i >= 0; i--)
-	r = (r * GMP_BASE) + arr[i];
+        r = (r * GMP_BASE) + arr[i];

     /* Now raise to the exponent */
     if ( r != 0.0 ) /* Lennart suggests this avoids a bug in MIPS's ldexp */
-	r = ldexp(r, e);
+        r = ldexp(r, e);

     /* sign is encoded in the size */
     if (size < 0)
-	r = -r;
+        r = -r;

     return r;
 }
@@ -94,15 +94,15 @@

     /* Convert MP_INT to a float; knows a lot about internal rep! */
     for(r = 0.0, i = __abs(size)-1; i >= 0; i--)
-	r = (r * GMP_BASE) + arr[i];
+        r = (r * GMP_BASE) + arr[i];

     /* Now raise to the exponent */
     if ( r != 0.0 ) /* Lennart suggests this avoids a bug in MIPS's ldexp */
-	r = ldexp(r, e);
+        r = ldexp(r, e);

     /* sign is encoded in the size */
     if (size < 0)
-	r = -r;
+        r = -r;

     return r;
 }
@@ -113,58 +113,58 @@
 integer_cbits_decodeDouble (MP_INT *man, I_ *exp, StgDouble dbl)
 {
     /* Do some bit fiddling on IEEE */
-    unsigned int low, high; 	     	/* assuming 32 bit ints */
+    unsigned int low, high;                      /* assuming 32 bit ints */
     int sign, iexp;
-    union { double d; unsigned int i[2]; } u;	/* assuming 32 bit ints, 64 bit double */
+    union { double d; unsigned int i[2]; } u;    /* assuming 32 bit ints, 64 bit double */

     ASSERT(sizeof(unsigned int ) == 4            );
     ASSERT(sizeof(dbl          ) == SIZEOF_DOUBLE);
     ASSERT(sizeof(man->_mp_d[0]) == SIZEOF_LIMB_T);
     ASSERT(DNBIGIT*SIZEOF_LIMB_T >= SIZEOF_DOUBLE);

-    u.d = dbl;	    /* grab chunks of the double */
+    u.d = dbl;            /* grab chunks of the double */
     low = u.i[L];
     high = u.i[H];

     /* we know the MP_INT* passed in has size zero, so we realloc
-    	no matter what.
+            no matter what.
     */
     man->_mp_alloc = DNBIGIT;

     if (low == 0 && (high & ~DMSBIT) == 0) {
-	man->_mp_size = 0;
-	*exp = 0L;
+        man->_mp_size = 0;
+        *exp = 0L;
     } else {
-	man->_mp_size = DNBIGIT;
-	iexp = ((high >> 20) & 0x7ff) + MY_DMINEXP;
-	sign = high;
+        man->_mp_size = DNBIGIT;
+        iexp = ((high >> 20) & 0x7ff) + MY_DMINEXP;
+        sign = high;

-	high &= DHIGHBIT-1;
-	if (iexp != MY_DMINEXP)	/* don't add hidden bit to denorms */
-	    high |= DHIGHBIT;
-	else {
-	    iexp++;
-	    /* A denorm, normalize the mantissa */
-	    while (! (high & DHIGHBIT)) {
-		high <<= 1;
-		if (low & DMSBIT)
-		    high++;
-		low <<= 1;
-		iexp--;
-	    }
-	}
+        high &= DHIGHBIT-1;
+        if (iexp != MY_DMINEXP)        /* don't add hidden bit to denorms */
+            high |= DHIGHBIT;
+        else {
+            iexp++;
+            /* A denorm, normalize the mantissa */
+            while (! (high & DHIGHBIT)) {
+                high <<= 1;
+                if (low & DMSBIT)
+                    high++;
+                low <<= 1;
+                iexp--;
+            }
+        }
         *exp = (I_) iexp;
 #if DNBIGIT == 2
-	man->_mp_d[0] = (mp_limb_t)low;
-	man->_mp_d[1] = (mp_limb_t)high;
+        man->_mp_d[0] = (mp_limb_t)low;
+        man->_mp_d[1] = (mp_limb_t)high;
 #else
 #if DNBIGIT == 1
-	man->_mp_d[0] = ((mp_limb_t)high) << 32 | (mp_limb_t)low;
+        man->_mp_d[0] = ((mp_limb_t)high) << 32 | (mp_limb_t)low;
 #else
 #error Cannot cope with DNBIGIT
 #endif
 #endif
-	if (sign < 0)
-	    man->_mp_size = -man->_mp_size;
+        if (sign < 0)
+            man->_mp_size = -man->_mp_size;
     }
 }


Fix compiler warnings.

Fix compiler warnings.

--- cups/raster-stream.c
+++ cups/raster-stream.c
@@ -1139,7 +1139,7 @@
                         r->header.cupsColorSpace == CUPS_CSPACE_RGB ? 5 :
                         r->header.cupsColorSpace == CUPS_CSPACE_CMYK ? 6 : 0;
     appleheader[2]  = r->header.Duplex ? (r->header.Tumble ? 2 : 3) : 1;
-    appleheader[3]  = r->header.cupsInteger[CUPS_RASTER_PWG_PrintQuality];
+    appleheader[3]  = (unsigned char)(r->header.cupsInteger[CUPS_RASTER_PWG_PrintQuality]);
     appleheader[5]  = (unsigned char)(r->header.MediaPosition);
     appleheader[12] = (unsigned char)(r->header.cupsWidth >> 24);
     appleheader[13] = (unsigned char)(r->header.cupsWidth >> 16);
@@ -1158,7 +1158,7 @@
     {
       if (!strcmp(r->header.MediaType, apple_media_types[i]))
       {
-        appleheader[4] = i;
+        appleheader[4] = (unsigned char)i;
         break;
       }
     }


su/torture_su_tag.c: fixed whitespace

su/torture_su_tag.c: fixed whitespace

darcs-hash:20081127130748-db55f-043107f21f2f276179d2ab8eb03006389f404dbc.gz

--- libsofia-sip-ua/su/torture_su_tag.c
+++ libsofia-sip-ua/su/torture_su_tag.c
@@ -28,7 +28,7 @@
  * Testing functions for su_tag module.
  *
  * @author Pekka Pessi <Pekka.Pessi@nokia.com>
- *
+ *
  * @date Created: Tue Mar  6 18:33:42 2001 ppessi
  */

@@ -47,7 +47,7 @@
 #define DEVNULL "/dev/null"
 #else
 #define DEVNULL "nul"
-#endif
+#endif

 int tstflags = 0;

@@ -127,27 +127,27 @@

   tag_typedef_t _tag_b = STRTAG_TYPEDEF(b);
   tag_typedef_t _tag_b_ref = REFTAG_TYPEDEF(tag_b);
-
+
   tag_typedef_t _tag_i = INTTAG_TYPEDEF(i);
   tag_typedef_t _tag_i_ref = REFTAG_TYPEDEF(tag_i);
-
+
   tag_typedef_t _tag_j = INTTAG_TYPEDEF(j);
   tag_typedef_t _tag_j_ref = REFTAG_TYPEDEF(tag_j);
-
+
   tag_typedef_t _tag_k = INTTAG_TYPEDEF(k);
   tag_typedef_t _tag_k_ref = REFTAG_TYPEDEF(tag_k);
-
+
   tag_typedef_t _tag_n = INTTAG_TYPEDEF(n);
   tag_typedef_t _tag_n_ref = REFTAG_TYPEDEF(tag_n);

 #undef TAG_NAMESPACE
 #define TAG_NAMESPACE "pq"
-
+
   tag_typedef_t _tag_any_pq = NSTAG_TYPEDEF(*);

   tag_typedef_t _tag_p = BOOLTAG_TYPEDEF(p);
   tag_typedef_t _tag_p_ref = REFTAG_TYPEDEF(tag_p);
-
+
   tag_typedef_t _tag_q = BOOLTAG_TYPEDEF(q);
   tag_typedef_t _tag_q_ref = REFTAG_TYPEDEF(tag_q);

@@ -237,22 +237,22 @@
 	       (tv)1, (tv)2, (tv)3, (tv)4, (tv)5,
 	       (tv)6, (tv)7, (tv)8, (tv)9, (tv)10);
 }
-],
+],
 SAC_SU_DEFINE(SU_HAVE_TAGSTACK, 1, [
-Define this as 1 if your compiler puts the variable argument list nicely in memory]),
+Define this as 1 if your compiler puts the variable argument list nicely in memory]),
 )

 */

 static int test_stackargs(int l, ...)
 {
-  va_list ap;
+  va_list ap;
   int i, *p;

   BEGIN();

   va_start(ap, l);
-
+
   p = &l;

   for (i = l; i <= 10; i++) {
@@ -287,10 +287,10 @@

   BEGIN();

-  lst = tl_list(TAG_A("Moro"),
-		TAG_A("Vaan"),
-		TAG_I(1),
-		TAG_SKIP(2),
+  lst = tl_list(TAG_A("Moro"),
+		TAG_A("Vaan"),
+		TAG_I(1),
+		TAG_SKIP(2),
 		TAG_NEXT(rest));

   TEST_P(lst[0].t_tag, tag_a);
@@ -379,12 +379,12 @@

   home = su_home_new(sizeof *home); TEST_1(home);

-  lst = tl_list(TAG_A("Moro"),
+  lst = tl_list(TAG_A("Moro"),
 		TAG_I(2),
 		TAG_Q(3),
-		TAG_SKIP(2),
-		TAG_A("vaan"),
-		TAG_I(1),
+		TAG_SKIP(2),
+		TAG_A("vaan"),
+		TAG_I(1),
 		TAG_P(2),
 		TAG_NULL());

@@ -420,7 +420,7 @@
   su_free(NULL, b1); su_free(NULL, b2); su_free(NULL, b3); su_free(NULL, b4);

   nsfilter = tl_list(TAG_ANY_PQ(), TAG_END());
-
+
   b5 = tl_afilter(NULL, nsfilter, lst);
   TEST_SIZE(tl_len(b5), 3 * sizeof(tagi_t));
   TEST_SIZE(tl_xtra(b5, 0), 0);
@@ -437,7 +437,7 @@
   b = tl_afilter(home, filter6, lst); TEST_1(b);
   TEST_P(b[0].t_tag, 0);

-  tl_vfree(filter1); tl_vfree(filter2); tl_vfree(filter3);
+  tl_vfree(filter1); tl_vfree(filter2); tl_vfree(filter3);
   tl_vfree(filter4); tl_vfree(filter5); tl_vfree(filter6);

   tl_vfree(lst);
@@ -455,14 +455,14 @@
   tagi_t *lst;
   FILE *out;

-  lst = tl_list(TAG_A("Moro"),
-		TAG_I(2),
+  lst = tl_list(TAG_A("Moro"),
+		TAG_I(2),
 		TAG_J(3),
 		TAG_K(5),
-		TAG_SKIP(2),
-		TAG_A("Vaan"),
+		TAG_SKIP(2),
+		TAG_A("Vaan"),
 		TAG_B("b"),
-		TAG_I(1),
+		TAG_I(1),
 		TAG_NULL());

   if (tstflags & tst_verbatim)
@@ -524,15 +524,15 @@

   BEGIN();

-  lst = tl_list(TAG_A("Moro"),
-		TAG_I(2),
+  lst = tl_list(TAG_A("Moro"),
+		TAG_I(2),
 		TAG_J(3),
 		TAG_K(5),
 		TAG_P(3),
-		TAG_SKIP(2),
-		TAG_A("Vaan"),
+		TAG_SKIP(2),
+		TAG_A("Vaan"),
 		TAG_B("b"),
-		TAG_I(1),
+		TAG_I(1),
 		TAG_NULL());

   TEST_1(lst);
@@ -540,7 +540,7 @@
   TEST_1(t = tl_find(lst, tag_i)); TEST(t->t_value, 2);
   TEST_1(t = tl_find_last(lst, tag_i)); TEST(t->t_value, 1);

-  TEST(tl_gets(lst,
+  TEST(tl_gets(lst,
 	       TAG_A_REF(a),
 	       TAG_B_REF(b),
 	       TAG_I_REF(i),
@@ -566,7 +566,7 @@
   lst = tl_list(TAG_A_REF(a),
 		TAG_I_REF(i),
 		TAG_NULL());
-
+
   TEST(tl_tgets(lst, TAG_A("Foo"), TAG_I(-1), TAG_END()), 2);

   TEST_S(a, "Foo");
@@ -629,8 +629,8 @@

 void usage(int exitcode)
 {
-  fprintf(stderr,
-	  "usage: %s [-v] [-a]\n",
+  fprintf(stderr,
+	  "usage: %s [-v] [-a]\n",
 	  name);
   exit(exitcode);
 }


websockets: fix 32-bit build

websockets: fix 32-bit build

https://bugzilla.gnome.org/show_bug.cgi?id=745509

--- libsoup/soup-websocket-connection.c
+++ libsoup/soup-websocket-connection.c
@@ -354,10 +354,14 @@
 		bytes->len = 4;
 	} else {
 		outer[1] = 127; /* mask | 64-bit-len */
+#if GLIB_SIZEOF_SIZE_T > 4
 		outer[2] = (length >> 56) & 0xFF;
 		outer[3] = (length >> 48) & 0xFF;
 		outer[4] = (length >> 40) & 0xFF;
 		outer[5] = (length >> 32) & 0xFF;
+#else
+		outer[2] = outer[3] = outer[4] = outer[5] = 0;
+#endif
 		outer[6] = (length >> 24) & 0xFF;
 		outer[7] = (length >> 16) & 0xFF;
 		outer[8] = (length >> 8) & 0xFF;
@@ -488,7 +492,7 @@

 static void
 too_big_error_and_close (SoupWebsocketConnection *self,
-                         gsize payload_len)
+                         guint64 payload_len)
 {
 	GError *error;


Fix per comments @e05f475f8cb94f9fda940ac5d4b8dcd23d509b4e

--- link-grammar/dict-file/dictionary.c
+++ link-grammar/dict-file/dictionary.c
@@ -522,6 +522,10 @@
 		          "Using current program locale \"%s\"", dict->locale);
 	}

+	/* setlocale() returns a string owned by the system. Copy it. */
+	dict->locale = string_set_add(dict->locale, dict->string_set);
+
+
 #ifdef HAVE_LOCALE_T
 	dict->lctype = newlocale_LC_CTYPE(dict->locale);

@@ -532,9 +536,6 @@
 #endif /* HAVE_LOCALE_T */

 	set_utf8_program_locale();
-
-	/* Previous setlocale() result is not valid after this next call. (???) */
-	dict->locale = string_set_add(dict->locale, dict->string_set);

 	dict->affix_table = dictionary_six(lang, affix_name, NULL, NULL, NULL, NULL);
 	if (dict->affix_table == NULL)


test/update_handler: extend hook tests

test/update_handler: extend hook tests

This now performs hook script error return checks for each single hook
type to assure that all hooks will be executed as intended.

Signed-off-by: Enrico Jorns <a2e5f936c390f36494e46e71bcfbe365bb1e8c49@pengutronix.de>

--- test/update_handler.c
+++ test/update_handler.c
@@ -19,7 +19,11 @@
 	TEST_UPDATE_HANDLER_NO_IMAGE_FILE = 1 << 1,
 	TEST_UPDATE_HANDLER_NO_TARGET_DEV = 1 << 2,
 	TEST_UPDATE_HANDLER_HOOKS         = 1 << 3,
-	TEST_UPDATE_HANDLER_NO_HOOK_FILE  = 1 << 4,
+	TEST_UPDATE_HANDLER_PRE_HOOK      = 1 << 4,
+	TEST_UPDATE_HANDLER_POST_HOOK     = 1 << 5,
+	TEST_UPDATE_HANDLER_INSTALL_HOOK  = 1 << 6,
+	TEST_UPDATE_HANDLER_NO_HOOK_FILE  = 1 << 7,
+	TEST_UPDATE_HANDLER_HOOK_FAIL     = 1 << 8,
 } TestUpdateHandlerParams;

 typedef struct {
@@ -261,11 +265,15 @@
 	image->slotclass = g_strdup("rootfs");
 	image->filename = g_strdup(imagepath);
 	image->checksum.size = IMAGE_SIZE;
+	image->checksum.digest = g_strdup("0xdeadbeef");
 	if (test_pair->params & TEST_UPDATE_HANDLER_HOOKS) {
-		const gchar *hook_content = "#!/bin/sh\nexit 0";
+		const gchar *hook_content_success = "#!/bin/sh\nexit 0";
+		const gchar *hook_content_fail = "#!/bin/sh\nexit 1";
+		const gchar *hook_content = (test_pair->params & TEST_UPDATE_HANDLER_HOOK_FAIL) ? hook_content_fail : hook_content_success;
 		hookpath = g_build_filename(fixture->tmpdir, "hook.sh", NULL);
-		image->hooks.pre_install = TRUE;
-		image->hooks.post_install = TRUE;
+		image->hooks.pre_install = (test_pair->params & TEST_UPDATE_HANDLER_PRE_HOOK);
+		image->hooks.install = (test_pair->params & TEST_UPDATE_HANDLER_INSTALL_HOOK);
+		image->hooks.post_install = (test_pair->params & TEST_UPDATE_HANDLER_POST_HOOK);
 		if (!(test_pair->params & TEST_UPDATE_HANDLER_NO_HOOK_FILE)) {
 				g_assert_true(write_tmp_file(fixture->tmpdir, "hook.sh", hook_content, NULL));
 				test_do_chmod(hookpath);
@@ -319,6 +327,11 @@
 	} else {
 		g_assert_no_error(ierror);
 		g_assert_true(res);
+	}
+
+	/* If the custom update handler ran, skip default write tests */
+	if (test_pair->params & TEST_UPDATE_HANDLER_INSTALL_HOOK) {
+		goto out;
 	}

 	/* Sanity check updated slot */
@@ -388,8 +401,37 @@
 		{"raw", "ext4", TEST_UPDATE_HANDLER_NO_TARGET_DEV | TEST_UPDATE_HANDLER_EXPECT_FAIL, R_UPDATE_ERROR, R_UPDATE_ERROR_FAILED},
 		{"ext4", "ext4", TEST_UPDATE_HANDLER_NO_TARGET_DEV | TEST_UPDATE_HANDLER_EXPECT_FAIL, R_UPDATE_ERROR, R_UPDATE_ERROR_FAILED},

-		{"ext4", "tar.bz2", TEST_UPDATE_HANDLER_HOOKS, 0, 0},
-		{"ext4", "tar.bz2", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_NO_HOOK_FILE | TEST_UPDATE_HANDLER_EXPECT_FAIL, G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT},
+		{"ext4", "tar.bz2", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_PRE_HOOK, 0, 0},
+		{"raw", "img", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_PRE_HOOK , 0, 0},
+		{"raw", "ext4", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_PRE_HOOK, 0, 0},
+		{"ext4", "ext4", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_PRE_HOOK, 0, 0},
+
+		{"ext4", "tar.bz2", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_POST_HOOK, 0, 0},
+		{"raw", "img", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_POST_HOOK , 0, 0},
+		{"raw", "ext4", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_POST_HOOK, 0, 0},
+		{"ext4", "ext4", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_POST_HOOK, 0, 0},
+
+		{"ext4", "tar.bz2", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_INSTALL_HOOK, 0, 0},
+		{"raw", "img", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_INSTALL_HOOK , 0, 0},
+		{"raw", "ext4", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_INSTALL_HOOK, 0, 0},
+		{"ext4", "ext4", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_INSTALL_HOOK, 0, 0},
+
+		{"ext4", "tar.bz2", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_PRE_HOOK | TEST_UPDATE_HANDLER_HOOK_FAIL | TEST_UPDATE_HANDLER_EXPECT_FAIL, G_SPAWN_EXIT_ERROR, 1},
+		{"raw", "img", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_PRE_HOOK | TEST_UPDATE_HANDLER_HOOK_FAIL | TEST_UPDATE_HANDLER_EXPECT_FAIL, G_SPAWN_EXIT_ERROR, 1},
+		{"raw", "ext4", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_PRE_HOOK | TEST_UPDATE_HANDLER_HOOK_FAIL | TEST_UPDATE_HANDLER_EXPECT_FAIL, G_SPAWN_EXIT_ERROR, 1},
+		{"ext4", "ext4", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_PRE_HOOK | TEST_UPDATE_HANDLER_HOOK_FAIL | TEST_UPDATE_HANDLER_EXPECT_FAIL, G_SPAWN_EXIT_ERROR, 1},
+
+		{"ext4", "tar.bz2", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_POST_HOOK | TEST_UPDATE_HANDLER_HOOK_FAIL | TEST_UPDATE_HANDLER_EXPECT_FAIL, G_SPAWN_EXIT_ERROR, 1},
+		{"raw", "img", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_POST_HOOK | TEST_UPDATE_HANDLER_HOOK_FAIL | TEST_UPDATE_HANDLER_EXPECT_FAIL, G_SPAWN_EXIT_ERROR, 1},
+		{"raw", "ext4", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_POST_HOOK | TEST_UPDATE_HANDLER_HOOK_FAIL | TEST_UPDATE_HANDLER_EXPECT_FAIL, G_SPAWN_EXIT_ERROR, 1},
+		{"ext4", "ext4", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_POST_HOOK | TEST_UPDATE_HANDLER_HOOK_FAIL | TEST_UPDATE_HANDLER_EXPECT_FAIL, G_SPAWN_EXIT_ERROR, 1},
+
+		{"ext4", "tar.bz2", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_INSTALL_HOOK | TEST_UPDATE_HANDLER_HOOK_FAIL | TEST_UPDATE_HANDLER_EXPECT_FAIL, G_SPAWN_EXIT_ERROR, 1},
+		{"raw", "img", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_INSTALL_HOOK | TEST_UPDATE_HANDLER_HOOK_FAIL | TEST_UPDATE_HANDLER_EXPECT_FAIL, G_SPAWN_EXIT_ERROR, 1},
+		{"raw", "ext4", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_INSTALL_HOOK | TEST_UPDATE_HANDLER_HOOK_FAIL | TEST_UPDATE_HANDLER_EXPECT_FAIL, G_SPAWN_EXIT_ERROR, 1},
+		{"ext4", "ext4", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_INSTALL_HOOK | TEST_UPDATE_HANDLER_HOOK_FAIL | TEST_UPDATE_HANDLER_EXPECT_FAIL, G_SPAWN_EXIT_ERROR, 1},
+
+		{"ext4", "tar.bz2", TEST_UPDATE_HANDLER_HOOKS | TEST_UPDATE_HANDLER_PRE_HOOK | TEST_UPDATE_HANDLER_NO_HOOK_FILE | TEST_UPDATE_HANDLER_EXPECT_FAIL, G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT},

 		{0}
 	};
@@ -504,19 +546,162 @@
 			test_update_handler,
 			update_handler_fixture_tear_down);

-	g_test_add("/update_handler/update_handler/img_to_ext4/hooks",
+	g_test_add("/update_handler/update_handler/tar_to_ext4/pre-hook",
 			UpdateHandlerFixture,
 			&testpair_matrix[16],
 			update_handler_fixture_set_up,
 			test_update_handler,
 			update_handler_fixture_tear_down);
-
-	g_test_add("/update_handler/update_handler/img_to_ext4/hooks/no-file",
+	g_test_add("/update_handler/update_handler/img_to_raw/pre-hook",
 			UpdateHandlerFixture,
 			&testpair_matrix[17],
 			update_handler_fixture_set_up,
 			test_update_handler,
 			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_raw/pre-hook",
+			UpdateHandlerFixture,
+			&testpair_matrix[18],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/pre-hook",
+			UpdateHandlerFixture,
+			&testpair_matrix[19],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+
+	g_test_add("/update_handler/update_handler/tar_to_ext4/post-hook",
+			UpdateHandlerFixture,
+			&testpair_matrix[20],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/img_to_raw/post-hook",
+			UpdateHandlerFixture,
+			&testpair_matrix[21],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_raw/post-hook",
+			UpdateHandlerFixture,
+			&testpair_matrix[22],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/post-hook",
+			UpdateHandlerFixture,
+			&testpair_matrix[23],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+
+	g_test_add("/update_handler/update_handler/tar_to_ext4/install-hook",
+			UpdateHandlerFixture,
+			&testpair_matrix[24],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/img_to_raw/install-hook",
+			UpdateHandlerFixture,
+			&testpair_matrix[25],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_raw/install-hook",
+			UpdateHandlerFixture,
+			&testpair_matrix[26],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/install-hook",
+			UpdateHandlerFixture,
+			&testpair_matrix[27],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/pre-hook/fail",
+			UpdateHandlerFixture,
+			&testpair_matrix[28],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/pre-hook/fail",
+			UpdateHandlerFixture,
+			&testpair_matrix[29],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/pre-hook/fail",
+			UpdateHandlerFixture,
+			&testpair_matrix[30],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/pre-hook/fail",
+			UpdateHandlerFixture,
+			&testpair_matrix[31],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/post-hook/fail",
+			UpdateHandlerFixture,
+			&testpair_matrix[32],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/post-hook/fail",
+			UpdateHandlerFixture,
+			&testpair_matrix[33],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/post-hook/fail",
+			UpdateHandlerFixture,
+			&testpair_matrix[34],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/post-hook/fail",
+			UpdateHandlerFixture,
+			&testpair_matrix[35],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/install-hook/fail",
+			UpdateHandlerFixture,
+			&testpair_matrix[36],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/install-hook/fail",
+			UpdateHandlerFixture,
+			&testpair_matrix[37],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/install-hook/fail",
+			UpdateHandlerFixture,
+			&testpair_matrix[38],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/install-hook/fail",
+			UpdateHandlerFixture,
+			&testpair_matrix[39],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);
+
+	g_test_add("/update_handler/update_handler/ext4_to_ext4/hooks/no-file",
+			UpdateHandlerFixture,
+			&testpair_matrix[40],
+			update_handler_fixture_set_up,
+			test_update_handler,
+			update_handler_fixture_tear_down);

 	return g_test_run();
 }


read-regex.c: Convert escaped slash to just slash

\/ is needed in 4.0.regex because regexes there are terminated by a
bare /. However, \/ may not be defined (depending on the regex package).
Solve it by storing in the regex a bare / in that case.
(Alternatively it could be solved by a more complex code that allows
unescaped / inside a 4.0.regex expression).

--- link-grammar/dict-file/read-regex.c
+++ link-grammar/dict-file/read-regex.c
@@ -141,7 +141,10 @@
 			}
 			prev = c;
 			c = fgetc(fp);
-			regex[i++] = c;
+			if ((c == '/') && (prev == '\\'))
+				regex[i-1] = '/'; /* \/ is undefined */
+			else
+				regex[i++] = c;
 		}
 		while ((c != '/' || prev == '\\') && (c != EOF));
 		regex[i-1] = '\0';


Type traits fence comment typo

Type traits fence comment typo

--- cxxstd/type_traits.h
+++ cxxstd/type_traits.h
@@ -3,4 +3,4 @@

 #include <type_traits>

-#endif // CXXSTD_STRING_H
+#endif // CXXSTD_TYPE_TRAITS_H


MB-15356: Add missing connection properties to 'connections' stats

Change-Id: I51fd35c8c966a8b05ee71a7cb25203dbc804cba6
Reviewed-on: http://review.couchbase.org/52160
Tested-by: buildbot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>
Reviewed-by: Trond Norbye <60edd2ef23891a753f231b0c6f161dc634079a93@gmail.com>

--- daemon/connections.c
+++ daemon/connections.c
@@ -17,6 +17,7 @@

 #include "connections.h"
 #include "runtime.h"
+#include "utilities/protocol2text.h"

 #include <cJSON.h>

@@ -833,14 +834,18 @@
 /* cJSON uses double for all numbers, so only has 53 bits of precision.
  * Therefore encode 64bit integers as string.
  */
+static cJSON* json_create_uintptr(uintptr_t value) {
+    char buffer[32];
+    if (snprintf(buffer, sizeof(buffer), "0x%"PRIxPTR, value) >= sizeof(buffer)) {
+        return cJSON_CreateString("<too long>");
+    } else {
+        return cJSON_CreateString(buffer);
+    }
+}
+
 static void json_add_uintptr_to_object(cJSON *obj, const char *name,
                                        uintptr_t value) {
-    char buffer[32];
-    if (snprintf(buffer, sizeof(buffer), "0x%"PRIxPTR, value) >= sizeof(buffer)) {
-        cJSON_AddStringToObject(obj, name, "<too long>");
-    } else {
-        cJSON_AddStringToObject(obj, name, buffer);
-    }
+    cJSON_AddItemToObject(obj, name, json_create_uintptr(value));
 }

 static void json_add_bool_to_object(cJSON *obj, const char *name, bool value) {
@@ -867,7 +872,10 @@
         if (c->sockname) {
             cJSON_AddStringToObject(obj, "sockname", c->sockname);
         }
+        cJSON_AddNumberToObject(obj, "max_reqs_per_event",
+                                c->max_reqs_per_event);
         cJSON_AddNumberToObject(obj, "nevents", c->nevents);
+        json_add_bool_to_object(obj, "admin", c->admin);
         if (c->sasl_conn != NULL) {
             json_add_uintptr_to_object(obj, "sasl_conn",
                                        (uintptr_t)c->sasl_conn);
@@ -882,8 +890,8 @@
         }
         json_add_bool_to_object(obj, "registered_in_libevent",
                                 c->registered_in_libevent);
-        cJSON_AddNumberToObject(obj, "ev_flags", c->ev_flags);
-        cJSON_AddNumberToObject(obj, "which", c->which);
+        json_add_uintptr_to_object(obj, "ev_flags", (uintptr_t)c->ev_flags);
+        json_add_uintptr_to_object(obj, "which", (uintptr_t)c->which);
         {
             cJSON *read = cJSON_CreateObject();
             json_add_uintptr_to_object(read, "buf", (uintptr_t)c->read.buf);
@@ -953,6 +961,15 @@
         json_add_bool_to_object(obj, "nodelay", c->nodelay);
         cJSON_AddNumberToObject(obj, "refcount", c->refcount);
         {
+            cJSON *features = cJSON_CreateObject();
+            json_add_bool_to_object(features, "datatype",
+                                    c->supports_datatype);
+            json_add_bool_to_object(features, "mutation_extras",
+                                    c->supports_mutation_extras);
+
+            cJSON_AddItemToObject(obj, "features", features);
+        }
+        {
             cJSON* dy_buf = cJSON_CreateObject();
             json_add_uintptr_to_object(dy_buf, "buffer",
                                        (uintptr_t)c->dynamic_buffer.buffer);
@@ -965,7 +982,17 @@
                                    (uintptr_t)c->engine_storage);
         /* @todo we should decode the binary header */
         json_add_uintptr_to_object(obj, "cas", c->cas);
-        cJSON_AddNumberToObject(obj, "cmd", c->cmd);
+        {
+            cJSON *cmd = cJSON_CreateArray();
+            cJSON_AddItemToArray(cmd, json_create_uintptr(c->cmd));
+            const char* cmd_name = memcached_opcode_2_text(c->cmd);
+            if (cmd_name == NULL) {
+                cmd_name = "";
+            }
+            cJSON_AddItemToArray(cmd, cJSON_CreateString(cmd_name));
+
+            cJSON_AddItemToObject(obj, "cmd", cmd);
+        }
         json_add_uintptr_to_object(obj, "opaque", c->opaque);
         cJSON_AddNumberToObject(obj, "keylen", c->keylen);
         cJSON_AddNumberToObject(obj, "list_state", c->list_state);
@@ -975,6 +1002,18 @@
         json_add_bool_to_object(obj, "ewouldblock", c->ewouldblock);
         json_add_uintptr_to_object(obj, "tap_iterator",
                                    (uintptr_t)c->tap_iterator);
+        cJSON_AddNumberToObject(obj, "parent_port", c->parent_port);
+        json_add_bool_to_object(obj, "dcp", c->dcp);
+
+        {
+            cJSON* ssl = cJSON_CreateObject();
+            json_add_bool_to_object(ssl, "enabled", c->ssl.enabled);
+            if (c->ssl.enabled) {
+                json_add_bool_to_object(ssl, "connected", c->ssl.connected);
+            }
+
+            cJSON_AddItemToObject(obj, "ssl", ssl);
+        }
     }
     return obj;
 }


Update RingRayLib - raylib.c - Add Function : void DrawCube(Vector3 position, float width, float height, float length, Color color)


daemon: Set callback to avoid endless loop during unmount

It is not possible to respond to unmount dialog after 2 sec timeout,
because the callback isn't set properly. The dialog reopens every 2
seconds until the daemon is killed.

Because a dbus method is called every 2 seconds, we may get multiple
replies (e.g. one normal reply and several error replies due to a closed
connection).  Handle this by ignoring all but the first reply.

Based on a patch by Ondrej Holy.

https://bugzilla.gnome.org/show_bug.cgi?id=688471

--- daemon/gvfsbackend.c
+++ daemon/gvfsbackend.c
@@ -793,7 +793,7 @@
   const gchar *message;
   const gchar *choices[3];

-  gboolean no_more_processes;
+  gboolean completed;

   GAsyncReadyCallback callback;
   gpointer            user_data;
@@ -802,7 +802,7 @@
 } UnmountWithOpData;

 static void
-complete_unmount_with_op (UnmountWithOpData *data)
+complete_unmount_with_op (UnmountWithOpData *data, gboolean no_more_processes)
 {
   gboolean ret;
   GSimpleAsyncResult *simple;
@@ -816,7 +816,7 @@
                                       data->user_data,
                                       NULL);

-  if (data->no_more_processes)
+  if (no_more_processes)
     {
       /* do nothing, e.g. return TRUE to signal we should unmount */
     }
@@ -837,6 +837,7 @@
         }
     }

+  data->completed = TRUE;
   g_simple_async_result_set_op_res_gboolean (simple, ret);
   g_simple_async_result_complete (simple);
   g_object_unref (simple);
@@ -850,7 +851,7 @@
   UnmountWithOpData *data = user_data;

   /* Do nothing if we've handled this already */
-  if (data->no_more_processes)
+  if (data->completed)
     return;

   data->ret = g_mount_source_show_processes_finish (mount_source,
@@ -858,7 +859,7 @@
                                                     &data->aborted,
                                                     &data->choice);

-  complete_unmount_with_op (data);
+  complete_unmount_with_op (data, FALSE);
 }

 static gboolean
@@ -872,19 +873,17 @@
     {
       /* no more processes, abort mount op */
       g_mount_source_abort (data->mount_source);
-      data->no_more_processes = TRUE;
-      complete_unmount_with_op (data);
+      complete_unmount_with_op (data, TRUE);
     }
   else
     {
-      /* ignore reply */
       processes = g_vfs_daemon_get_blocking_processes (daemon);
       g_mount_source_show_processes_async (data->mount_source,
                                            data->message,
                                            processes,
                                            data->choices,
-                                           NULL,
-                                           NULL);
+                                           (GAsyncReadyCallback) on_show_processes_reply,
+                                           data);
       g_array_unref (processes);
     }


Update RingRayLib - raylib.c - Add Function : void SetWindowIcon(Image image)


Fix -Wdocumentation warning: use a correct Doxygen comment marker

git-svn-id: f6089bf0e6284f307027cef4f64114ee9ebb0424@176494 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/ReaderWriter/ELF/Chunk.h
+++ lib/ReaderWriter/ELF/Chunk.h
@@ -34,12 +34,12 @@

   /// \brief Describes the type of Chunk
   enum Kind {
-    K_Header, // ELF Header
-    K_ProgramHeader, // Program Header
-    K_ELFSegment, // Segment
-    K_ELFSection, // Section
-    K_AtomSection, //< A section containing atoms.
-    K_SectionHeader // Section header
+    K_Header, ///< ELF Header
+    K_ProgramHeader, ///< Program Header
+    K_ELFSegment, ///< Segment
+    K_ELFSection, ///< Section
+    K_AtomSection, ///< A section containing atoms.
+    K_SectionHeader ///< Section header
   };
   Chunk(StringRef name, Kind kind, const ELFTargetInfo &ti)
       : _name(name), _kind(kind), _fsize(0), _msize(0), _align2(0), _order(0),


improved sync

improved sync

--- daemons/hw_default.c
+++ daemons/hw_default.c
@@ -1,4 +1,4 @@
-/*      $Id: hw_default.c,v 5.5 1999/08/13 18:53:16 columbus Exp $      */
+/*      $Id: hw_default.c,v 5.6 1999/08/15 18:17:14 columbus Exp $      */

 /****************************************************************************
  ** hw_default.c ************************************************************
@@ -760,20 +760,22 @@
 	deltas=get_next_space();
 	if(deltas==0) return(0);

-	logprintf(0,"%ld\n",deltas);
-	while(deltas<remote->remaining_gap*(100-remote->eps)/100
-	      && deltas<remote->remaining_gap-remote->aeps)
-	{
-		deltap=get_next_pulse();
-		if(deltap==0) return(0);
-		deltas=get_next_space();
-		logprintf(0,"%ld\n",deltas);
-		if(deltas==0) return(0);
-		count++;
-		if(count>REC_SYNC) /* no sync found,
-				      let's try a diffrent remote */
-		{
-			return(0);
+	if(last_remote!=NULL)
+	{
+		while(deltas<last_remote->remaining_gap*
+		      (100-last_remote->eps)/100 &&
+		      deltas<last_remote->remaining_gap-last_remote->aeps)
+		{
+			deltap=get_next_pulse();
+			if(deltap==0) return(0);
+			deltas=get_next_space();
+			if(deltas==0) return(0);
+			count++;
+			if(count>REC_SYNC) /* no sync found,
+					      let's try a diffrent remote */
+			{
+				return(0);
+			}
 		}
 	}
 	rec_buffer.sum=0;
@@ -1162,7 +1164,7 @@
 				logprintf(1,"pre: %lx\n",pre);
 #                               endif
 #                               endif
-		}
+			}

 			code=get_data(remote,remote->bits);
 			if(code==(ir_code) -1)


Update RingRayLib - raylib.c - Add Function : void SetCameraPanControl(int panKey)


Update RingRayLib - raylib.c - Add Function : void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, Vector2 origin, float rotation, Color tint)


fix stringbuffer appending for special numeric values

--- lib/ShapedJson/shaped-json.c
+++ lib/ShapedJson/shaped-json.c
@@ -1476,7 +1476,23 @@
   int res;

   v = * (TRI_shape_number_t const*) data;
-  res = TRI_AppendDoubleStringBuffer(buffer, v);
+  // check for special values
+
+  if (v != v) {
+    // NaN
+    res = TRI_AppendStringStringBuffer(buffer, "null");
+  }
+  else if (v == HUGE_VAL) {
+    // +inf
+    res = TRI_AppendStringStringBuffer(buffer, "null");
+  }
+  else if (v == -HUGE_VAL) {
+    // -inf
+    res = TRI_AppendStringStringBuffer(buffer, "null");
+  }
+  else {
+    res = TRI_AppendDoubleStringBuffer(buffer, v);
+  }

   if (res != TRI_ERROR_NO_ERROR) {
     return false;


Explicitly specify null rejection threshold.

--- Xcode/Audio/src/user_color_sensor.h
+++ Xcode/Audio/src/user_color_sensor.h
@@ -27,6 +27,6 @@

     pipeline.addPreProcessingModule(MovingAverageFilter(5, 3));
     //pipeline.addFeatureExtractionModule(TimeDomainFeatures(10, 1, 3, false, true, true, false, false));
-    pipeline.setClassifier(ANBC(false, true)); // don't use scaling; use null rejection
+    pipeline.setClassifier(ANBC(false, true, 10.0)); // don't use scaling; use null rejection
     usePipeline(pipeline);
 }


Destroy MDNodes while destructing llvm context.

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

--- lib/VMCore/LLVMContextImpl.h
+++ lib/VMCore/LLVMContextImpl.h
@@ -224,7 +224,10 @@
       if (I->second->use_empty())
         delete I->second;
     }
-    MDNodeSet.clear();
+    while (!MDNodeSet.empty()) {
+      MDNode *N = &(*MDNodeSet.begin());
+      N->destroy();
+    }
     AlwaysOpaqueTy->dropRef();
     for (OpaqueTypesTy::iterator I = OpaqueTypes.begin(), E = OpaqueTypes.end();
         I != E; ++I) {


fix warning uint64_t < 0

fix warning uint64_t < 0

--- fflas-ffpack/field/modular-uint64.h
+++ fflas-ffpack/field/modular-uint64.h
@@ -98,14 +98,14 @@
 		Element &init (Element &x, const uint32_t &y ) const
 		{
 			x = (Element) (labs (y) % (int64_t) (_modulus));
-			if (y < 0) x = _modulus - x;
+			// if (y < 0) x = _modulus - x;
 			return x;
 		}

 		Element &init (Element &x, const int32_t &y ) const
 		{
 			x = abs (y) % (int64_t) (_modulus);
-			if (y < 0) x = _modulus - x;
+			// if (y < 0) x = _modulus - x;
 			return x;
 		}


changed frameContentSize field to pledgedSrcSizePlusOne

pledgedSrcSize is proper : it's a promise, not yet fulfilled.
It will be controlled at the end.

PlusOne is meant to have 0 (default) == unknown

--- lib/compress/zstd_compress.c
+++ lib/compress/zstd_compress.c
@@ -98,7 +98,7 @@
     void* workSpace;
     size_t workSpaceSize;
     size_t blockSize;
-    U64 frameContentSize;
+    U64 pledgedSrcSizePlusOne;  /* this way, 0 (default) == unknown */
     U64 consumedSrcSize;
     XXH64_state_t xxhState;
     ZSTD_customMem customMem;
@@ -152,6 +152,8 @@
     if (!cctx) return NULL;
     cctx->customMem = customMem;
     cctx->compressionLevel = ZSTD_CLEVEL_DEFAULT;
+    ZSTD_STATIC_ASSERT(zcss_init==0);
+    ZSTD_STATIC_ASSERT(ZSTD_CONTENTSIZE_UNKNOWN==-(1ULL));
     return cctx;
 }

@@ -233,7 +235,7 @@
 {
     if (cctx->compressionLevel==ZSTD_CLEVEL_CUSTOM) return;
     cctx->requestedParams.cParams = ZSTD_getCParams(cctx->compressionLevel,
-                                                    cctx->frameContentSize, 0);
+                                            cctx->pledgedSrcSizePlusOne-1, 0);
     cctx->compressionLevel = ZSTD_CLEVEL_CUSTOM;
 }

@@ -374,7 +376,7 @@
 {
     DEBUGLOG(5, " setting pledgedSrcSize to %u", (U32)pledgedSrcSize);
     if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
-    cctx->frameContentSize = pledgedSrcSize;
+    cctx->pledgedSrcSizePlusOne = pledgedSrcSize+1;
     return 0;
 }

@@ -421,7 +423,7 @@
 void ZSTD_CCtx_reset(ZSTD_CCtx* cctx)
 {
     cctx->streamStage = zcss_init;
-    cctx->frameContentSize = ZSTD_CONTENTSIZE_UNKNOWN;
+    cctx->pledgedSrcSizePlusOne = 0;
     cctx->cdict = NULL;
 }

@@ -531,7 +533,7 @@
     U32 const end = (U32)(cctx->nextSrc - cctx->base);
     DEBUGLOG(5, "continue mode");
     cctx->appliedParams = params;
-    cctx->frameContentSize = frameContentSize;
+    cctx->pledgedSrcSizePlusOne = frameContentSize+1;
     cctx->consumedSrcSize = 0;
     if (frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN)
         cctx->appliedParams.fParams.contentSizeFlag = 0;
@@ -554,7 +556,7 @@
 /*! ZSTD_resetCCtx_internal() :
     note : `params` are assumed fully validated at this stage */
 static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc,
-                                      ZSTD_parameters params, U64 frameContentSize,
+                                      ZSTD_parameters params, U64 pledgedSrcSize,
                                       ZSTD_compResetPolicy_e const crp,
                                       ZSTD_buffered_policy_e const zbuff)
 {
@@ -565,7 +567,7 @@
             DEBUGLOG(5, "ZSTD_equivalentParams()==1");
             zc->fseCTables_ready = 0;
             zc->hufCTable_repeatMode = HUF_repeat_none;
-            return ZSTD_continueCCtx(zc, params, frameContentSize);
+            return ZSTD_continueCCtx(zc, params, pledgedSrcSize);
     }   }

     {   size_t const blockSize = MIN(ZSTD_BLOCKSIZE_MAX, (size_t)1 << params.cParams.windowLog);
@@ -626,9 +628,9 @@

         /* init params */
         zc->appliedParams = params;
-        zc->frameContentSize = frameContentSize;
+        zc->pledgedSrcSizePlusOne = pledgedSrcSize+1;
         zc->consumedSrcSize = 0;
-        if (frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN)
+        if (pledgedSrcSize == ZSTD_CONTENTSIZE_UNKNOWN)
             zc->appliedParams.fParams.contentSizeFlag = 0;
         DEBUGLOG(5, "content size : %u ; flag : %u",
             (U32)frameContentSize, zc->appliedParams.fParams.contentSizeFlag);
@@ -2873,7 +2875,8 @@
     if (cctx->stage==ZSTDcs_created) return ERROR(stage_wrong);   /* missing init (ZSTD_compressBegin) */

     if (frame && (cctx->stage==ZSTDcs_init)) {
-        fhSize = ZSTD_writeFrameHeader(dst, dstCapacity, cctx->appliedParams, cctx->frameContentSize, cctx->dictID);
+        fhSize = ZSTD_writeFrameHeader(dst, dstCapacity, cctx->appliedParams,
+                                cctx->pledgedSrcSizePlusOne-1, cctx->dictID);
         if (ZSTD_isError(fhSize)) return fhSize;
         dstCapacity -= fhSize;
         dst = (char*)dst + fhSize;
@@ -3208,7 +3211,7 @@
     if (ZSTD_isError(endResult)) return endResult;
     if (cctx->appliedParams.fParams.contentSizeFlag) {  /* control src size */
         DEBUGLOG(5, "end of frame : controlling src size");
-        if (cctx->frameContentSize != cctx->consumedSrcSize) {
+        if (cctx->pledgedSrcSizePlusOne != cctx->consumedSrcSize+1) {
             DEBUGLOG(5, "error : pledgedSrcSize = %u, while realSrcSize = %u",
                 (U32)cctx->frameContentSize, (U32)cctx->consumedSrcSize);
             return ERROR(srcSize_wrong);
@@ -3697,7 +3700,7 @@
                         DEBUGLOG(5, "Frame completed directly in outBuffer");
                         someMoreWork = 0;
                         zcs->streamStage = zcss_init;
-                        zcs->frameContentSize = ZSTD_CONTENTSIZE_UNKNOWN;
+                        zcs->pledgedSrcSizePlusOne = 0;
                     }
                     break;
                 }
@@ -3724,7 +3727,7 @@
                     DEBUGLOG(5, "Frame completed on flush");
                     someMoreWork = 0;
                     zcs->streamStage = zcss_init;
-                    zcs->frameContentSize = ZSTD_CONTENTSIZE_UNKNOWN;
+                    zcs->pledgedSrcSizePlusOne = 0;
                     break;
                 }
                 zcs->streamStage = zcss_load;
@@ -3782,27 +3785,29 @@
         ZSTD_parameters params = cctx->requestedParams;
         if (cctx->compressionLevel != ZSTD_CLEVEL_CUSTOM)
             params.cParams = ZSTD_getCParams(cctx->compressionLevel,
-                                    cctx->frameContentSize, 0 /* dictSize */);
+                                    cctx->pledgedSrcSizePlusOne+1, 0 /* dictSize */);

 #ifdef ZSTD_MULTITHREAD
         if (cctx->nbThreads > 1) {
-            CHECK_F( ZSTDMT_initCStream_internal(cctx->mtctx, NULL, 0, cctx->cdict, params, cctx->frameContentSize) );
+            CHECK_F( ZSTDMT_initCStream_internal(cctx->mtctx, NULL, 0, cctx->cdict, params, cctx->pledgedSrcSizePlusOne-1) );
             cctx->streamStage = zcss_load;
         } else
 #endif
         {
-            CHECK_F( ZSTD_resetCStream_internal(cctx, params, cctx->frameContentSize) );
+            CHECK_F( ZSTD_resetCStream_internal(cctx, params, cctx->pledgedSrcSizePlusOne+1) );
     }   }

 #ifdef ZSTD_MULTITHREAD
     if (cctx->nbThreads > 1) {
-        DEBUGLOG(5, "calling ZSTDMT_compressStream_generic(%i,...)", endOp);
         size_t const flushMin = ZSTDMT_compressStream_generic(cctx->mtctx, output, input, endOp);
         DEBUGLOG(5, "ZSTDMT result : %u", (U32)flushMin);
-        if (ZSTD_isError(flushMin)) cctx->streamStage = zcss_init;
-        if (endOp == ZSTD_e_end && flushMin==0) {
+        if (ZSTD_isError(flushMin)) {
+            cctx->streamStage = zcss_init;
+            cctx->pledgedSrcSizePlusOne = 0;
+        }
+        if (endOp == ZSTD_e_end && flushMin == 0) {
             cctx->streamStage = zcss_init;   /* compression completed */
-            cctx->frameContentSize = ZSTD_CONTENTSIZE_UNKNOWN;
+            cctx->pledgedSrcSizePlusOne = 0;
         }
         return flushMin;
     }


Bump Split Log Support to ZSTD_btlazy2

Bump Split Log Support to ZSTD_btlazy2

--- lib/compress/zstd_compress.c
+++ lib/compress/zstd_compress.c
@@ -1320,6 +1320,8 @@
     8 KB /* ZSTD_btultra */
 };

+static const ZSTD_strategy splitLogCutoffStrategy = ZSTD_btlazy2;
+
 static int ZSTD_shouldAttachDict(ZSTD_CCtx* cctx,
                             const ZSTD_CDict* cdict,
                             ZSTD_CCtx_params params,
@@ -1332,8 +1334,8 @@
         && params.attachDictPref != ZSTD_dictForceCopy
         && !params.forceWindow /* dictMatchState isn't correctly
                                 * handled in _enforceMaxDist */
-        && ( (cdict->matchState.cParams.strategy <= ZSTD_dfast)
-          || (cdict->matchState.cParams.strategy > ZSTD_dfast &&
+        && ( (cdict->matchState.cParams.strategy <= splitLogCutoffStrategy)
+          || (cdict->matchState.cParams.strategy > splitLogCutoffStrategy &&
               ZSTD_equivalentCParams(cctx->appliedParams.cParams,
                                      cdict->matchState.cParams)));
 }
@@ -1351,7 +1353,7 @@
         /* Copy only compression parameters related to tables. */
         params.cParams = *cdict_cParams;
         params.cParams.windowLog = windowLog;
-        if (params.cParams.strategy <= ZSTD_dfast) {
+        if (params.cParams.strategy <= splitLogCutoffStrategy) {
             DEBUGLOG(4, "Overriding hashLog from %d to %d", params.cParams.hashLog, cctx->requestedParams.cParams.hashLog);
             DEBUGLOG(4, "Overriding chainLog from %d to %d", params.cParams.chainLog, cctx->requestedParams.cParams.chainLog);
             if (cctx->requestedParams.cParams.hashLog)
@@ -1362,7 +1364,7 @@
         ZSTD_resetCCtx_internal(cctx, params, pledgedSrcSize,
                                 ZSTDcrp_continue, zbuff);
         assert(cctx->appliedParams.cParams.strategy == cdict_cParams->strategy);
-        if (params.cParams.strategy > ZSTD_dfast) {
+        if (params.cParams.strategy > splitLogCutoffStrategy) {
             assert(cctx->appliedParams.cParams.hashLog == cdict_cParams->hashLog);
             assert(cctx->appliedParams.cParams.chainLog == cdict_cParams->chainLog);
         }


Restore ZSTD_noCompressBlock() for clarity

--- lib/compress/zstd_compress.c
+++ lib/compress/zstd_compress.c
@@ -1531,6 +1531,15 @@

 /* See doc/zstd_compression_format.md for detailed format description */

+static size_t ZSTD_noCompressBlock (void* dst, size_t dstCapacity, const void* src, size_t srcSize, U32 lastBlock)
+{
+    U32 const cBlockHeader24 = lastBlock + (((U32)bt_raw)<<1) + (U32)(srcSize << 3);
+    if (srcSize + ZSTD_blockHeaderSize > dstCapacity) return ERROR(dstSize_tooSmall);
+    MEM_writeLE24(dst, cBlockHeader24);
+    memcpy((BYTE*)dst + ZSTD_blockHeaderSize, src, srcSize);
+    return ZSTD_blockHeaderSize + srcSize;
+}
+
 static size_t ZSTD_noCompressLiterals (void* dst, size_t dstCapacity, const void* src, size_t srcSize)
 {
     BYTE* const ostart = (BYTE* const)dst;
@@ -2485,11 +2494,8 @@
             if (ZSTD_isError(cSize)) return cSize;

             if (cSize == 0) {  /* block is not compressible */
-                U32 const cBlockHeader24 = lastBlock + (((U32)bt_raw)<<1) + (U32)(blockSize << 3);
-                if (blockSize + ZSTD_blockHeaderSize > dstCapacity) return ERROR(dstSize_tooSmall);
-                MEM_writeLE32(op, cBlockHeader24);   /* 4th byte will be overwritten */
-                memcpy(op + ZSTD_blockHeaderSize, ip, blockSize);
-                cSize = ZSTD_blockHeaderSize + blockSize;
+                cSize = ZSTD_noCompressBlock(op, dstCapacity, ip, blockSize, lastBlock);
+                if (ZSTD_isError(cSize)) return cSize;
             } else {
                 U32 const cBlockHeader24 = lastBlock + (((U32)bt_compressed)<<1) + (U32)(cSize << 3);
                 MEM_writeLE24(op, cBlockHeader24);


More adjustments to improve code clarity

--- lib/compress/zstd_compress.c
+++ lib/compress/zstd_compress.c
@@ -4526,7 +4526,7 @@
     DEBUGLOG(4, "endPosInSequence begin val: %u", endPosInSequence);
     while (endPosInSequence && idx < inSeqsSize) {
         ZSTD_Sequence currSeq = inSeqs[idx];
-        DEBUGLOG(4, "curr Seq: idx: %u ll: %u ml: %u, of: %u", idx, currSeq.litLength, currSeq.matchLength, currSeq.offset);
+        DEBUGLOG(5, "curr Seq: idx: %u ll: %u ml: %u, of: %u", idx, currSeq.litLength, currSeq.matchLength, currSeq.offset);
         if (endPosInSequence >= currSeq.litLength + currSeq.matchLength) {
             endPosInSequence -= currSeq.litLength + currSeq.matchLength;
             idx++;
@@ -4537,7 +4537,6 @@

     if (format == ZSTD_sf_noBlockDelimiters) {
         assert(endPosInSequence <= inSeqs[idx].litLength + inSeqs[idx].matchLength);
-        DEBUGLOG(4, "idx: %u", idx);
         if (idx != inSeqsSize && endPosInSequence > inSeqs[idx].litLength) {
             DEBUGLOG(4, "Endpos is in the match");
             if (inSeqs[idx].matchLength >= blockSize) {
@@ -4576,8 +4575,8 @@

 /* Returns size of sequences range copied, otherwise ZSTD error code */
 static size_t ZSTD_copySequencesToSeqStore(seqStore_t* seqStore, const ZSTD_sequenceRange* seqRange,
-                                         const ZSTD_Sequence* const inSeqs, size_t inSeqsSize,
-                                         const void* src, size_t srcSize, ZSTD_sequenceFormat_e format) {
+                                           const ZSTD_Sequence* const inSeqs, size_t inSeqsSize,
+                                           const void* src, size_t srcSize, ZSTD_sequenceFormat_e format) {
     DEBUGLOG(4, "ZSTD_copySequencesToSeqStore: numSeqs: %zu srcSize: %zu", inSeqsSize, srcSize);
     size_t idx = seqRange->startIdx;
     BYTE const* istart = (BYTE const*)src;
@@ -4589,79 +4588,84 @@
         U32 matchLength = inSeqs[idx].matchLength;
         U32 offCode = inSeqs[idx].offset + ZSTD_REP_MOVE;

-        /* Adjust litLength and matchLength for the sequence at startIdx */
+        /* Adjust litLength and matchLength if we're at either the start or end index of the range */
         if (seqRange->startIdx == seqRange->endIdx) {
+            /* The sequence spans the entire block */
             U32 seqLength = seqRange->endPosInSequence - seqRange->startPosInSequence;
-            RETURN_ERROR_IF(seqLength > litLength + matchLength, corruption_detected, "SeqLength cannot be bigger than sequence length!");
+            RETURN_ERROR_IF(seqLength > litLength + matchLength, corruption_detected,
+                            "range length cannot be bigger than sequence length!");
             if (seqLength <= litLength) {
-                /* Sequence is entirely literals, break and store last literals */
+                /* Spanned range is entirely literals, store as last literals */
                 break;
-            } else if (seqLength <= litLength + matchLength) {
+            } else {
+                /* Spanned range ends in the match section */
                 matchLength = seqLength - litLength;
             }
         } else if (idx == seqRange->startIdx) {
             U32 posInSequence = seqRange->startPosInSequence;
-            DEBUGLOG(4, "At startIdx: idx: %u PIS: %u", idx, posInSequence);
+            DEBUGLOG(4, "startIdx: %u PIS: %u", idx, posInSequence);
+            DEBUGLOG(4, "startIdx seq initial: (of: %u ml: %u ll: %u) rep: %u", offCode, matchLength, litLength, inSeqs[idx].rep);
             assert(posInSequence <= litLength + matchLength);
+            RETURN_ERROR_IF(format == ZSTD_sf_explicitBlockDelimiters && posInSequence != 0,
+                            corruption_detected, "pos in sequence must == 0 when using block delimiters!");
+
             if (posInSequence >= litLength) {
-                /* position is within the match */
+                /* Start position within sequence is within the match */
                 posInSequence -= litLength;
                 litLength = 0;
                 matchLength -= posInSequence;
             } else {
-                /* position is within the literals */
+                /* Start position within sequence is within the literals */
                 litLength -= posInSequence;
             }
-            if (matchLength <= MINMATCH && offCode != ZSTD_REP_MOVE /* dont trigger this in lastLL case */) {
-                DEBUGLOG(4, "start idx: %zu, seq: (ll: %u, ml: %u, of: %u)", idx, litLength, matchLength, offCode);
-                RETURN_ERROR_IF(matchLength < MINMATCH, corruption_detected, "Matchlength too small! Start Idx");
-            }
-            DEBUGLOG(4, "startIdx seq finalized: ll: %u ml: %u", litLength, matchLength);
+
+            /* ZSTD_updateSequenceRange should never give us a position such that we generate a match too small */
+            RETURN_ERROR_IF(matchLength < MINMATCH && offCode != ZSTD_REP_MOVE, corruption_detected,
+                            "Matchlength too small at start of range!");
+            DEBUGLOG(4, "startIdx seq finalized: (of: %u ml: %u ll: %u) rep: %u", offCode, matchLength, litLength, inSeqs[idx].rep);
         } else if (idx == seqRange->endIdx) {
             U32 posInSequence = seqRange->endPosInSequence;
-            DEBUGLOG(4, "Reached endIdx. idx: %u PIS: %u", idx, posInSequence);
-            if (posInSequence == 0) {
-                RETURN_ERROR_IF(inSeqs[seqRange->endIdx - 1].matchLength != 0 || inSeqs[seqRange->endIdx - 1].matchLength != 0,
-                                corruption_detected, "Contract violation");
-            }
+            DEBUGLOG(4, "endIdx: %u PIS: %u", idx, posInSequence);
+            DEBUGLOG(4, "endIdx seq initial: (of: %u ml: %u ll: %u) rep: %u", offCode, matchLength, litLength, inSeqs[idx].rep);
             assert(posInSequence <= litLength + matchLength);
+            RETURN_ERROR_IF(format == ZSTD_sf_explicitBlockDelimiters && posInSequence != 0,
+                            corruption_detected, "pos in sequence must == 0 when using block delimiters!");
+
             if (posInSequence <= litLength) {
-                /* position is within the last literals, break and store last literals */
+                /* End position within is within the literals, break and store last literals if any */
                 break;
             } else {
-                /* position is within the match */
+                /* End position is within the match */
                 matchLength = posInSequence - litLength;
-                /* ZSTD_updateSequenceRange should never give us a position such that we generate a match too small */
-                if (matchLength <= MINMATCH && offCode != ZSTD_REP_MOVE) {
-                    DEBUGLOG(4, "start idx: %zu, seq: (ll: %u, ml: %u, of: %u)", idx, litLength, matchLength, offCode);
-                    RETURN_ERROR_IF(matchLength < MINMATCH, corruption_detected, "Matchlength too small! Start Idx");
-                }
             }
-            DEBUGLOG(4, "endIdx seq finalized: ll:%u ml: %u", litLength, matchLength);
+
+            /* ZSTD_updateSequenceRange should never give us a position such that we generate a match too small */
+            RETURN_ERROR_IF(matchLength < MINMATCH && offCode != ZSTD_REP_MOVE, corruption_detected,
+                            "Matchlength too small at end of range!");
+            DEBUGLOG(4, "endIdx seq finalized: (of: %u ml: %u ll: %u) rep: %u", offCode, matchLength, litLength, inSeqs[idx].rep);
         }

         /* ML == 0 and Offset == 0 (or offCode == ZSTD_REP_MOVE) signals block delimiters */
         if (matchLength == 0 && offCode == ZSTD_REP_MOVE) {
             RETURN_ERROR_IF(format == ZSTD_sf_noBlockDelimiters, corruption_detected, "No block delimiters allowed!");
-            /* Handle last literals case */
             if (litLength > 0) {
-                DEBUGLOG(4, "Storing last literals: %u bytes, idx: %u", litLength, idx);
+                DEBUGLOG(4, "Storing block delim last literals: %u bytes, idx: %u", litLength, idx);
                 const BYTE* const lastLiterals = (const BYTE*)src + srcSize - litLength;
                 ZSTD_storeLastLiterals(seqStore, lastLiterals, litLength);
             }
-            continue;
-        }
-
-        DEBUGLOG(4, "Storing in actual seqStore idx: %zu, seq: (ll: %u, ml: %u, of: %u), rep: %u", idx, litLength, matchLength - MINMATCH, offCode, inSeqs[idx].rep);
-        RETURN_ERROR_IF(matchLength < MINMATCH, corruption_detected, "Matchlength too small! of: %u ml: %u ll: %u", offCode, matchLength, litLength);
-        if (inSeqs[idx].rep) {
-            ZSTD_storeSeq(seqStore, litLength, ip, iend, inSeqs[idx].rep - 1, matchLength - MINMATCH);
         } else {
-            ZSTD_storeSeq(seqStore, litLength, ip, iend, offCode, matchLength - MINMATCH);
+            DEBUGLOG(4, "Storing: idx: %zu (ll: %u, ml: %u, of: %u) rep: %u", idx, litLength, matchLength - MINMATCH, offCode, inSeqs[idx].rep);
+            RETURN_ERROR_IF(matchLength < MINMATCH, corruption_detected, "Matchlength too small! of: %u ml: %u ll: %u", offCode, matchLength, litLength);
+            if (inSeqs[idx].rep) {
+                ZSTD_storeSeq(seqStore, litLength, ip, iend, inSeqs[idx].rep - 1, matchLength - MINMATCH);
+            } else {
+                ZSTD_storeSeq(seqStore, litLength, ip, iend, offCode, matchLength - MINMATCH);
+            }
         }
         ip += matchLength + litLength;
     }
-
+
+    /* Store any last literals for ZSTD_sf_noBlockDelimiters mode */
     if (format == ZSTD_sf_noBlockDelimiters && ip != iend) {
         assert(ip <= iend);
         U32 lastLLSize = (U32)(iend - ip);
@@ -4687,7 +4691,6 @@
     seqStore_t blockSeqStore;
     blockSeqStore.longLengthID = 0;
     blockSeqStore.longLengthPos = 0;
-
     size_t origDstCapacity = dstCapacity;

     DEBUGLOG(4, "ZSTD_compressSequences_ext_internal srcSize: %zu, inSeqsSize: %zu", srcSize, inSeqsSize);
@@ -4705,7 +4708,7 @@
         blockSize += additionalByteAdjustment;
         DEBUGLOG(4, "Working on new block. Blocksize: %u", blockSize);

-        /* Skip over uncompressible blocks */
+        /* If blocks are too small, emit as a nocompress block */
         if (blockSize < MIN_CBLOCK_SIZE+ZSTD_blockHeaderSize+1) {
             cBlockSize = ZSTD_noCompressBlock(op, dstCapacity, ip, blockSize, lastBlock);
             FORWARD_IF_ERROR(cBlockSize, "Nocompress block failed");
@@ -4718,16 +4721,17 @@
             continue;
         }

-        ZSTD_copySequencesToSeqStore(&blockSeqStore, &seqRange, inSeqs, inSeqsSize, ip, blockSize, format);
+        FORWARD_IF_ERROR(ZSTD_copySequencesToSeqStore(&blockSeqStore, &seqRange, inSeqs, inSeqsSize, ip, blockSize, format),
+                         "Sequence copying failed");
         compressedSeqsSize = ZSTD_compressSequences(&blockSeqStore,
                                 &cctx->blockState.prevCBlock->entropy, &cctx->blockState.nextCBlock->entropy,
                                 &cctx->appliedParams,
-                                op + ZSTD_blockHeaderSize, dstCapacity - ZSTD_blockHeaderSize,
+                                op + ZSTD_blockHeaderSize /* Leave space for block header */, dstCapacity - ZSTD_blockHeaderSize,
                                 blockSize,
                                 cctx->entropyWorkspace, ENTROPY_WORKSPACE_SIZE /* statically allocated in resetCCtx */,
                                 cctx->bmi2);
-        FORWARD_IF_ERROR(compressedSeqsSize, "Compressing block errored");
-        DEBUGLOG(4, "Compressed sequences size : %u", compressedSeqsSize);
+        FORWARD_IF_ERROR(compressedSeqsSize, "Compressing sequences of block failed");
+        DEBUGLOG(4, "Compressed sequences size: %u", compressedSeqsSize);

         if (compressedSeqsSize == 0) {
             /* ZSTD_noCompressBlock writes the block header as well */
@@ -4736,25 +4740,25 @@
             DEBUGLOG(4, "Block uncompressible, writing out nocompress block, size: %u", cBlockSize);
         } else {
             /* Error checking and repcodes update */
-            if (!ZSTD_isError(compressedSeqsSize) && compressedSeqsSize > 1) {
+            if (compressedSeqsSize > 1) {
                 ZSTD_confirmRepcodesAndEntropyTables(cctx);
             }
-            /* Write block header */
+            if (cctx->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid)
+                cctx->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check;
+
+            /* Write block header into beginning of block*/
             U32 const cBlockHeader = compressedSeqsSize == 1 ?
                                 lastBlock + (((U32)bt_rle)<<1) + (U32)(blockSize << 3):
                                 lastBlock + (((U32)bt_compressed)<<1) + (U32)(compressedSeqsSize << 3);
             MEM_writeLE24(op, cBlockHeader);
             cBlockSize = ZSTD_blockHeaderSize + compressedSeqsSize;
             DEBUGLOG(4, "Writing out compressed block, size: %u", cBlockSize);
-
-            if (cctx->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid)
-                cctx->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check;
         }
+
         cSize += cBlockSize;
         DEBUGLOG(4, "cumulative cSize: %u", cSize);

         if (lastBlock) {
-            DEBUGLOG(4, "reached last block, stopping");
             break;
         } else {
             ip += blockSize;
@@ -4786,7 +4790,7 @@
     if (dstCapacity < ZSTD_compressBound(srcSize))
         RETURN_ERROR(dstSize_tooSmall, "Destination buffer too small!");

-    /* Begin writing output */
+    /* Begin writing output, starting with frame header */
     frameHeaderSize = ZSTD_writeFrameHeader(op, dstCapacity, &cctx->appliedParams, srcSize, cctx->dictID);
     op += frameHeaderSize;
     dstCapacity -= frameHeaderSize;
@@ -4798,11 +4802,9 @@

     /* cSize includes block header size and compressed sequences size */
     compressedBlocksSize = ZSTD_compressSequences_ext_internal(op, dstCapacity,
-                                                cctx, inSeqs, inSeqsSize,
-                                                src, srcSize, format);
-    if (ZSTD_isError(compressedBlocksSize)) {
-        return compressedBlocksSize;
-    }
+                                                               cctx, inSeqs, inSeqsSize,
+                                                               src, srcSize, format);
+    FORWARD_IF_ERROR(compressedBlocksSize, "Block compression failed!");
     cSize += compressedBlocksSize;
     dstCapacity -= compressedBlocksSize;
     DEBUGLOG(4, "cSize after compressSequences_internal: %zu", cSize);


Use different settings for R300 and non-R300 when setting MC_FB_LOCATION.

--- gfxdrivers/radeon/radeon.c
+++ gfxdrivers/radeon/radeon.c
@@ -1470,9 +1470,14 @@
           rdev->fb_offset = tom << 16;
           rdev->fb_size   = ((tom >> 16) - (tom & 0xffff) + 1) << 16;
      }
-     else {
-          rdev->fb_offset = 0; /* CONFIG_APER_0_BASE makes R300 crash */
-          rdev->fb_size   = radeon_in32( mmio, CONFIG_APER_SIZE );
+     else {
+          if (rdev->chipset >= CHIP_R300) {
+               rdev->fb_offset = 0;
+               rdev->fb_size   = radeon_in32( mmio, CONFIG_MEMSIZE );
+          } else {
+               rdev->fb_offset = radeon_in32( mmio, CONFIG_APER_0_BASE );
+               rdev->fb_size   = radeon_in32( mmio, CONFIG_APER_SIZE );
+          }
      }

      radeon_out32( mmio, MC_FB_LOCATION, (rdev->fb_offset>>16) |


gwin32networkmonitor: fix build with MSVC

Don't include unistd.h unconditionally.

--- gio/gwin32networkmonitor.c
+++ gio/gwin32networkmonitor.c
@@ -21,7 +21,10 @@
 #include "config.h"

 #include <errno.h>
+
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif

 #include <winsock2.h>
 #include <ws2tcpip.h>


xdgmime: Prevent infinite loops from badly-formed MIME registrations

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1875

--- gio/xdgmime/xdgmimecache.c
+++ gio/xdgmime/xdgmimecache.c
@@ -965,7 +965,9 @@
 	      for (j = 0; j < n_parents; j++)
 		{
 		  parent_offset = GET_UINT32 (cache->buffer, offset + 4 + 4 * j);
-		  if (_xdg_mime_cache_mime_type_subclass (cache->buffer + parent_offset, ubase))
+		  if (strcmp (cache->buffer + parent_offset, mime) != 0 &&
+		      strcmp (cache->buffer + parent_offset, umime) != 0 &&
+		      _xdg_mime_cache_mime_type_subclass (cache->buffer + parent_offset, ubase))
 		    return 1;
 		}


Fix a fatal typo in latest fix.

Fix a fatal typo in latest fix.

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

--- gl/inc/TGLContextPrivate.h
+++ gl/inc/TGLContextPrivate.h
@@ -1,4 +1,4 @@
-// @(#)root/gl:$Name$:$Id$
+// @(#)root/gl:$Name:  $:$Id: TGLContextPrivate.h,v 1.2 2007/06/18 07:02:16 brun Exp $
 // Author:  Timur Pocheptsov, Matevz Tadel, June 2007

 #ifndef ROOT_TGLContextPrivate
@@ -65,8 +65,6 @@
 private:
    TGLContextPrivate(const TGLContextPrivate &);
    TGLContextPrivate &operator = (const TGLContextPrivate &);
-};
-
    static std::map<GLXContext, TGLContext *> fContexts;
 };


panel-widget: fix build warnings

panel-widget: fix build warnings

--- gnome-panel/panel-widget.c
+++ gnome-panel/panel-widget.c
@@ -801,8 +801,9 @@
 		for(list = g_list_last(panel->applet_list);
 		    list!=NULL;
 		    list = g_list_previous(list)) {
+			int cells;
+
 			ad = list->data;
-			int cells;

 			if (ad->constrained + ad->min_cells > i)
 				ad->constrained = MAX (i - ad->min_cells, 0);
@@ -1394,9 +1395,11 @@
 		for(list = panel->applet_list;
 		    list!=NULL;
 		    list = g_list_next(list)) {
-			ad = list->data;
 			GtkAllocation challoc;
 			GtkRequisition chreq;
+
+			ad = list->data;
+
 			gtk_widget_get_preferred_size (ad->applet, &chreq, NULL);

 			ad->constrained = i;
@@ -1445,8 +1448,9 @@
 		for (list = panel->applet_list;
 		     list != NULL;
 		     list = g_list_next (list)) {
+			GtkRequisition chreq;
+
 			ad = list->data;
-			GtkRequisition chreq;

 			gtk_widget_get_preferred_size (ad->applet, &chreq, NULL);

@@ -1469,9 +1473,11 @@
 		for(list = panel->applet_list;
 		    list!=NULL;
 		    list = g_list_next(list)) {
-			ad = list->data;
 			GtkAllocation challoc;
 			GtkRequisition chreq;
+
+			ad = list->data;
+
 			gtk_widget_get_preferred_size (ad->applet, &chreq, NULL);
 			challoc.width = chreq.width;
 			challoc.height = chreq.height;
@@ -2049,6 +2055,8 @@
 	case PANEL_PUSH_MOVE:
 		panel_widget_push_move (panel, ad, 0);
 		break;
+	default:
+		break;
 	}
 }

@@ -2230,24 +2238,17 @@
 	g_return_val_if_fail(GTK_IS_WIDGET(widget),FALSE);
 	g_return_val_if_fail(event!=NULL,FALSE);

-	switch (event->type) {
-		/*pass these to the parent!*/
-		case GDK_BUTTON_PRESS:
-		case GDK_BUTTON_RELEASE:
-		case GDK_MOTION_NOTIFY: {
-			GdkEventButton *bevent = (GdkEventButton *)event;
-
-			if (bevent->button != 1 || panel_applet_in_drag)
-				return gtk_widget_event (data, event);
-
-			}
-			break;
-		case GDK_KEY_PRESS:
-			if (panel_applet_in_drag)
-				return gtk_widget_event(data, event);
-			break;
-		default:
-			break;
+	/*pass these to the parent!*/
+	if (event->type == GDK_BUTTON_PRESS ||
+	    event->type == GDK_BUTTON_RELEASE ||
+	    event->type == GDK_MOTION_NOTIFY) {
+		GdkEventButton *bevent = (GdkEventButton *) event;
+
+		if (bevent->button != 1 || panel_applet_in_drag)
+			return gtk_widget_event (data, event);
+	} else if (event->type == GDK_KEY_PRESS) {
+		if (panel_applet_in_drag)
+			return gtk_widget_event(data, event);
 	}

 	return FALSE;
@@ -2362,15 +2363,15 @@
 	if (!use_pack_index || pack_index < 0) {
 		if (panel->packed) {
 			/* add at the end of packed panels */
-			AppletData *ad;
+			AppletData *tmp;
 			GList *list,*l;

 			list = get_applet_list_pack (panel, PANEL_OBJECT_PACK_END);
 			if (list) {
 				for (l = list; l; l = l->next) {
-					ad = l->data;
-					ad->pack_index += 1;
-					emit_applet_moved (panel, ad);
+					tmp = l->data;
+					tmp->pack_index += 1;
+					emit_applet_moved (panel, tmp);
 				}
 				pack_type = PANEL_OBJECT_PACK_END;
 				pack_index = 0;
@@ -2384,9 +2385,9 @@
 					pack_index = 0;
 				} else {
 					l = g_list_last (list);
-					AppletData *ad = l->data;
-					pack_type = ad->pack_type;
-					pack_index = ad->pack_index + 1;
+					tmp = l->data;
+					pack_type = tmp->pack_type;
+					pack_index = tmp->pack_index + 1;
 				}
 			}

@@ -2412,8 +2413,8 @@
 			if (!l)
 				pack_index = 0;
 			else {
-				AppletData *ad = l->data;
-				pack_index = ad->pack_index + 1;
+				AppletData *tmp = l->data;
+				pack_index = tmp->pack_index + 1;
 			}

 			g_list_free (list);
@@ -2597,6 +2598,8 @@
 	case GTK_DIR_DOWN:
 		direction = 1;
 		break;
+	case GTK_DIR_TAB_FORWARD:
+	case GTK_DIR_TAB_BACKWARD:
 	default:
 		return;
 	}
@@ -2626,6 +2629,8 @@
 	case GTK_DIR_DOWN:
 		panel_widget_switch_applet_right (panel, list, -1, TRUE);
 		break;
+	case GTK_DIR_TAB_FORWARD:
+	case GTK_DIR_TAB_BACKWARD:
 	default:
 		return;
 	}


Check return value from system() function.

Pointed out some months ago by: Bruce

--- gnu/usr.bin/man/lib/util.c
+++ gnu/usr.bin/man/lib/util.c
@@ -139,6 +139,16 @@
   else
     status = system (command);

+  /* check return value from system() function first */
+  if (status == -1) {
+    fprintf(stderr,
+	    "wait() for exit status of shell failed in function system()\n");
+    return 0;
+  } else if (status == 127 || status == (127 << 8)) {
+    fprintf(stderr, "execution of the shell failed in function system()\n");
+    return 0;
+  }
+
   if (WIFSIGNALED(status))
     return -1;
   else if (WEXITSTATUS(status)) {


Fix a nasty bug exposed by mktime() when time_t is significantly bigger than 32 bits.  It was trying to figure out things like the day of week of when time_t is roughly 2^62 etc.  Make a better guess for the starting point for the binary search that works on both 32 and 64 bit types.  I have been using this for a while now.

--- lib/libc/stdtime/localtime.c
+++ lib/libc/stdtime/localtime.c
@@ -1476,6 +1476,12 @@
 	*/
 	bits = TYPE_BIT(time_t) - 1;
 	/*
+	 * Limit to 32 bits or the things go crazy
+	 * when it tries to figure out times near 2^62 etc.
+	 */
+	if (bits > 31)
+		bits = 31;
+	/*
 	** If time_t is signed, then 0 is just above the median,
 	** assuming two's complement arithmetic.
 	** If time_t is unsigned, then (1 << bits) is just above the median.


Use clockid parameter instead of hard-coded CLOCK_REALTIME.

Reported by:	pjd

--- lib/libthr/thread/thr_umtx.c
+++ lib/libthr/thread/thr_umtx.c
@@ -202,7 +202,7 @@
 		tm_p = NULL;
 		tm_size = 0;
 	} else {
-		timeout._clockid = CLOCK_REALTIME;
+		timeout._clockid = clockid;
 		timeout._flags = UMTX_ABSTIME;
 		timeout._timeout = *abstime;
 		tm_p = &timeout;


Added prototypes.

Added prototypes.

--- lib/bbexit.c
+++ lib/bbexit.c
@@ -31,11 +31,11 @@
 	} *funcs;
 } tail, *_bblist = &tail;

-_epilogue(callee) struct func *callee; {
+void _epilogue(struct func *callee) {
 	_caller = 0;
 }

-_prologue(callee, yylink) struct func *callee; struct _bbdata *yylink; {
+void _prologue(struct func *callee, struct _bbdata *yylink) {
 	static struct caller callers[4096];
 	static int next;
 	struct caller *p;
@@ -59,7 +59,7 @@
 	_caller = 0;
 }

-static void profout(p, fp) struct _bbdata *p; FILE *fp; {
+static void profout(struct _bbdata *p, FILE *fp) {
 	int i;
 	struct func *f;
 	struct caller *q;
@@ -95,7 +95,7 @@
 			p->coords[i].c.y, p->counts[i]);
 }

-exit(code) {
+void exit(int code) {
 	FILE *fp;

 	if (_bblist != &tail && (fp = fopen("prof.out", "a"))) {
@@ -103,8 +103,8 @@
 			profout(_bblist, fp);
 		fclose(fp);
 	}
-#if mips || vax || sparc
-	_cleanup();
+#if mips || sparc
+	{ extern void _cleanup(void); _cleanup(); }
 #endif
-	_exit(code);
+	{ extern void _exit(int); _exit(code); }
 }


Remove an unnecessary pointer to array

Remove an unnecessary pointer to array

Be a little more explicit instead of relying on the compiler to optimize
the variable away.

Signed-off-by: Miloslav Trmač <9c008e38982a5397deb855345fb164f0558459ae@redhat.com>


column: add explicit casts to suppress warnings

--- lib/column.c
+++ lib/column.c
@@ -222,7 +222,7 @@
   }
   grn_obj inspected_key;
   GRN_TEXT_INIT(&inspected_key, 0);
-  grn_inspect_key(ctx, &inspected_key, table, key, key_size);
+  grn_inspect_key(ctx, &inspected_key, table, key, (uint32_t)key_size);
   GRN_LOG(ctx,
           GRN_LOG_WARNING,
           "[column][copy][%.*s] "
@@ -379,7 +379,7 @@
     grn_id to_id;

     key_size = grn_table_cursor_get_key(ctx, cursor, &key);
-    to_id = grn_table_add(ctx, to_table, key, key_size, NULL);
+    to_id = grn_table_add(ctx, to_table, key, (uint32_t)key_size, NULL);
     if (to_id == GRN_ID_NIL) {
       char from_name[GRN_TABLE_MAX_KEY_SIZE];
       int from_name_size;
@@ -401,7 +401,7 @@
       } else {
         GRN_VALUE_FIX_SIZE_INIT(&key_buffer, 0, from_table->header.domain);
       }
-      grn_bulk_write(ctx, &key_buffer, key, key_size);
+      grn_bulk_write(ctx, &key_buffer, key, (size_t)key_size);
       grn_inspect(ctx, &inspected_key, &key_buffer);
       ERR(GRN_INVALID_ARGUMENT,
           "[column][copy] failed to copy key: <%.*s>: "
@@ -465,7 +465,7 @@
     GRN_BULK_REWIND(&to_key_buffer);

     key_size = grn_table_cursor_get_key(ctx, cursor, &key);
-    grn_bulk_write(ctx, &from_key_buffer, key, key_size);
+    grn_bulk_write(ctx, &from_key_buffer, key, (size_t)key_size);
     cast_rc = grn_obj_cast(ctx, &from_key_buffer, &to_key_buffer, GRN_FALSE);
     if (cast_rc != GRN_SUCCESS) {
       char from_name[GRN_TABLE_MAX_KEY_SIZE];
@@ -504,7 +504,7 @@
     }
     to_id = grn_table_add(ctx, to_table,
                           GRN_BULK_HEAD(&to_key_buffer),
-                          GRN_BULK_VSIZE(&to_key_buffer),
+                          (unsigned int)GRN_BULK_VSIZE(&to_key_buffer),
                           NULL);
     if (to_id == GRN_ID_NIL) {
       continue;


vaapidecode: intersect filter from query caps

According to documentation[1] when receiving a GST_QUERY_CAPS
the return value should be all formats that this elements supports,
taking into account limitations of peer elements further downstream
or upstream, sorted by order of preference, highest preference first.

This patch add those limitations intersecting with the received
filter in the query. Also takes into account the already negotiated
caps. Also adds the processing of the query on the SRC pad.

1. http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/section-nego-getcaps.html

https://bugzilla.gnome.org/show_bug.cgi?id=744406

--- gst/vaapi/gstvaapidecode.c
+++ gst/vaapi/gstvaapidecode.c
@@ -990,7 +990,24 @@
         switch (GST_QUERY_TYPE(query)) {
 #if GST_CHECK_VERSION(1,0,0)
         case GST_QUERY_CAPS: {
-            GstCaps * const caps = gst_vaapidecode_get_caps(pad);
+            GstCaps *filter, *caps = NULL;
+
+            gst_query_parse_caps(query, &filter);
+            if (!decode->sinkpad_caps)
+                caps = gst_vaapidecode_get_caps(pad);
+            else
+                caps = gst_caps_ref(decode->sinkpad_caps);
+
+            if (filter) {
+                GstCaps *tmp = caps;
+                caps = gst_caps_intersect_full(filter, tmp,
+                   GST_CAPS_INTERSECT_FIRST);
+                gst_caps_unref(tmp);
+            }
+
+            GST_DEBUG_OBJECT(decode, "Returning sink caps %" GST_PTR_FORMAT,
+               caps);
+
             gst_query_set_caps_result(query, caps);
             gst_caps_unref(caps);
             res = TRUE;
@@ -1003,9 +1020,40 @@
             break;
         }
     }
-    else
-        res = GST_PAD_QUERY_FUNCTION_CALL(plugin->srcpad_query, pad,
-            parent, query);
+    else {
+        switch (GST_QUERY_TYPE(query)) {
+#if GST_CHECK_VERSION(1,0,0)
+        case GST_QUERY_CAPS: {
+            GstCaps *filter, *caps = NULL;
+
+            gst_query_parse_caps(query, &filter);
+            if (!decode->srcpad_caps)
+                caps = gst_pad_get_pad_template_caps(pad);
+            else
+                caps = gst_caps_ref(decode->srcpad_caps);
+
+            if (filter) {
+                GstCaps *tmp = caps;
+                caps = gst_caps_intersect_full(filter, tmp,
+                   GST_CAPS_INTERSECT_FIRST);
+                gst_caps_unref(tmp);
+            }
+
+            GST_DEBUG_OBJECT(decode, "Returning src caps %" GST_PTR_FORMAT,
+               caps);
+
+            gst_query_set_caps_result(query, caps);
+            gst_caps_unref(caps);
+            res = TRUE;
+            break;
+        }
+#endif
+        default:
+            res = GST_PAD_QUERY_FUNCTION_CALL(plugin->srcpad_query, pad,
+                parent, query);
+            break;
+        }
+    }

     gst_object_unref(decode);
     return res;