CONF: On VMS, treat VMS syntax inclusion paths correctly

non-VMS syntax inclusion paths get the same treatment as on Unix.

Reviewed-by: Tim Hudson <eb0be8e447f673b41b10eda09d63cd72526b0a42@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5587)

--- crypto/conf/conf_def.c
+++ crypto/conf/conf_def.c
@@ -685,6 +685,7 @@

         namelen = strlen(filename);

+
         if ((namelen > 5 && strcasecmp(filename + namelen - 5, ".conf") == 0)
             || (namelen > 4 && strcasecmp(filename + namelen - 4, ".cnf") == 0)) {
             size_t newlen;
@@ -697,10 +698,25 @@
                 CONFerr(CONF_F_GET_NEXT_FILE, ERR_R_MALLOC_FAILURE);
                 break;
             }
-            OPENSSL_strlcat(newpath, path, newlen);
-#ifndef OPENSSL_SYS_VMS
-            OPENSSL_strlcat(newpath, "/", newlen);
+#ifdef OPENSSL_SYS_VMS
+            /*
+             * If the given path isn't clear VMS syntax,
+             * we treat it as on Unix.
+             */
+            {
+                size_t pathlen = strlen(path);
+
+                if (path[pathlen - 1] == ']' || path[pathlen - 1] == '>'
+                    || path[pathlen - 1] == ':') {
+                    /* Clear VMS directory syntax, just copy as is */
+                    OPENSSL_strlcpy(newpath, path, newlen);
+                }
+            }
 #endif
+            if (newpath[0] == '\0') {
+                OPENSSL_strlcpy(newpath, path, newlen);
+                OPENSSL_strlcat(newpath, "/", newlen);
+            }
             OPENSSL_strlcat(newpath, filename, newlen);

             bio = BIO_new_file(newpath, "r");


added base_node_::simplify() which will merge the node with a lone value_node if there are no children

--- PlantGenerator/src/plant_generator.h
+++ PlantGenerator/src/plant_generator.h
@@ -63,6 +63,23 @@

             add_children(n.children);
             value_nodes.insert(value_nodes.end(), n.value_nodes.begin(), n.value_nodes.end());
+        }
+
+        void simplify(size_t depth = 0, size_t level = 0)
+        {
+            if(depth > 0 && level > depth)
+                return;
+
+            if(children.empty() && value_nodes.size() == 1)
+            {
+                merge_with(value_nodes[0]);
+                value_nodes.clear();
+            }
+
+            for(auto& child : children)
+                child.simplify(depth, level + 1);
+            for(auto& vn : value_nodes)
+                vn.simplify(depth, level + 1);
         }
     };


move active property to abstract tool

move active property to abstract tool

--- Plugin/CppApi/include/AbstractTool.h
+++ Plugin/CppApi/include/AbstractTool.h
@@ -33,6 +33,9 @@
 class TOOLKIT_EXPORT AbstractTool : public QObject
 {
   Q_OBJECT
+
+  Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
+
 public:
   AbstractTool(QObject* parent = nullptr);
   virtual ~AbstractTool();


AM3517 EVM: correct typo - tca6416 mispelt as tca6516

Correct instances where tca6416 is misspelt as tca6516 in
the board-am3517evm file.

Signed-off-by: Sriramakrishnan <59e8b83587ff69352fc901bcb4b505e679cea1a9@ti.com>
Signed-off-by: Tony Lindgren <1001e8702733cced254345e193c88aaa47a4f5de@atomide.com>

--- arch/arm/mach-omap2/board-am3517evm.c
+++ arch/arm/mach-omap2/board-am3517evm.c
@@ -80,7 +80,7 @@
 static struct pca953x_platform_data am3517evm_gpio_expander_info_0 = {
 	.gpio_base	= OMAP_MAX_GPIO_LINES,
 };
-static struct i2c_board_info __initdata am3517evm_tca6516_info_0[] = {
+static struct i2c_board_info __initdata am3517evm_tca6416_info_0[] = {
 	{
 		I2C_BOARD_INFO("tca6416", 0x21),
 		.platform_data = &am3517evm_gpio_expander_info_0,
@@ -94,7 +94,7 @@
 static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_2 = {
 	.gpio_base	= OMAP_MAX_GPIO_LINES + 32,
 };
-static struct i2c_board_info __initdata am3517evm_ui_tca6516_info[] = {
+static struct i2c_board_info __initdata am3517evm_ui_tca6416_info[] = {
 	{
 		I2C_BOARD_INFO("tca6416", 0x20),
 		.platform_data = &am3517evm_ui_gpio_expander_info_1,
@@ -108,10 +108,10 @@
 static int __init am3517_evm_i2c_init(void)
 {
 	omap_register_i2c_bus(1, 400, NULL, 0);
-	omap_register_i2c_bus(2, 400, am3517evm_tca6516_info_0,
-			ARRAY_SIZE(am3517evm_tca6516_info_0));
-	omap_register_i2c_bus(3, 400, am3517evm_ui_tca6516_info,
-			ARRAY_SIZE(am3517evm_ui_tca6516_info));
+	omap_register_i2c_bus(2, 400, am3517evm_tca6416_info_0,
+			ARRAY_SIZE(am3517evm_tca6416_info_0));
+	omap_register_i2c_bus(3, 400, am3517evm_ui_tca6416_info,
+			ARRAY_SIZE(am3517evm_ui_tca6416_info));

 	return 0;
 }


[ARM] 3047/1: SMDK2440 - add framebuffer platform data

Patch from Ben Dooks

Add platform data for framebuffer for the
onboard LCD module

Signed-off-by: Ben Dooks <1177f64998f284a7348354b8e91cbbe575d9858a@fluff.org>
Signed-off-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>

--- arch/arm/mach-s3c2410/mach-smdk2440.c
+++ arch/arm/mach-s3c2410/mach-smdk2440.c
@@ -19,6 +19,7 @@
  *	10-Mar-2005 LCVR  Replaced S3C2410_VA by S3C24XX_VA
  *	14-Mar-2005 BJD	  void __iomem fixes
  *	20-Sep-2005 BJD   Added static to non-exported items
+ *	26-Oct-2005 BJD   Added framebuffer data
 */

 #include <linux/kernel.h>
@@ -41,7 +42,10 @@
 //#include <asm/debug-ll.h>
 #include <asm/arch/regs-serial.h>
 #include <asm/arch/regs-gpio.h>
+#include <asm/arch/regs-lcd.h>
+
 #include <asm/arch/idle.h>
+#include <asm/arch/fb.h>

 #include "s3c2410.h"
 #include "s3c2440.h"
@@ -86,6 +90,70 @@
 	}
 };

+/* LCD driver info */
+
+static struct s3c2410fb_mach_info smdk2440_lcd_cfg __initdata = {
+	.regs	= {
+
+		.lcdcon1	= S3C2410_LCDCON1_TFT16BPP |
+				  S3C2410_LCDCON1_TFT |
+				  S3C2410_LCDCON1_CLKVAL(0x04),
+
+		.lcdcon2	= S3C2410_LCDCON2_VBPD(7) |
+				  S3C2410_LCDCON2_LINEVAL(319) |
+				  S3C2410_LCDCON2_VFPD(6) |
+				  S3C2410_LCDCON2_VSPW(3),
+
+		.lcdcon3	= S3C2410_LCDCON3_HBPD(19) |
+				  S3C2410_LCDCON3_HOZVAL(239) |
+				  S3C2410_LCDCON3_HFPD(7),
+
+		.lcdcon4	= S3C2410_LCDCON4_MVAL(0) |
+				  S3C2410_LCDCON4_HSPW(3),
+
+		.lcdcon5	= S3C2410_LCDCON5_FRM565 |
+				  S3C2410_LCDCON5_INVVLINE |
+				  S3C2410_LCDCON5_INVVFRAME |
+				  S3C2410_LCDCON5_PWREN |
+				  S3C2410_LCDCON5_HWSWP,
+	},
+
+#if 0
+	/* currently setup by downloader */
+	.gpccon		= 0xaa940659,
+	.gpccon_mask	= 0xffffffff,
+	.gpcup		= 0x0000ffff,
+	.gpcup_mask	= 0xffffffff,
+	.gpdcon		= 0xaa84aaa0,
+	.gpdcon_mask	= 0xffffffff,
+	.gpdup		= 0x0000faff,
+	.gpdup_mask	= 0xffffffff,
+#endif
+
+	.lpcsel		= ((0xCE6) & ~7) | 1<<4,
+
+	.width		= 240,
+	.height		= 320,
+
+	.xres		= {
+		.min	= 240,
+		.max	= 240,
+		.defval	= 240,
+	},
+
+	.yres		= {
+		.min	= 320,
+		.max	= 320,
+		.defval = 320,
+	},
+
+	.bpp		= {
+		.min	= 16,
+		.max	= 16,
+		.defval = 16,
+	},
+};
+
 static struct platform_device *smdk2440_devices[] __initdata = {
 	&s3c_device_usb,
 	&s3c_device_lcd,
@@ -121,6 +189,8 @@
 	s3c2410_gpio_setpin(S3C2410_GPF6, 0);
 	s3c2410_gpio_setpin(S3C2410_GPF7, 0);

+	s3c24xx_fb_set_platdata(&smdk2440_lcd_cfg);
+
 	s3c2410_pm_init();
 }


PR: 2063
Submitted by: Julia Lawall <julia@diku.dk>
Approved by: steve@openssl.org

Correct BIO_write error handling in ocsp_prn.c

--- crypto/ocsp/ocsp_prn.c
+++ crypto/ocsp/ocsp_prn.c
@@ -266,12 +266,12 @@
 			if (!ASN1_GENERALIZEDTIME_print(bp,single->nextUpdate))
 				goto err;
 			}
-		if (!BIO_write(bp,"\n",1)) goto err;
+		if (BIO_write(bp,"\n",1) <= 0) goto err;
 		if (!X509V3_extensions_print(bp,
 					"Response Single Extensions",
 					single->singleExtensions, flags, 8))
 							goto err;
-		if (!BIO_write(bp,"\n",1)) goto err;
+		if (BIO_write(bp,"\n",1) <= 0) goto err;
 		}
 	if (!X509V3_extensions_print(bp, "Response Extensions",
 					rd->responseExtensions, flags, 4))


ARM: shmobile: marzen: fixup regulator id for smsc911x

regulator id = 0 is used for sh_mobile_sdhi.
smsc911x's regulator can use id = 1

Signed-off-by: Kuninori Morimoto <a3b51ccb87d18302c1692defcfbf83319d1737eb@renesas.com>
Signed-off-by: Simon Horman <a105fd58f578dea0be108941d4c59d15396e1855@verge.net.au>

--- arch/arm/mach-shmobile/board-marzen.c
+++ arch/arm/mach-shmobile/board-marzen.c
@@ -120,7 +120,7 @@
 {
 	regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
 				ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
-	regulator_register_fixed(0, dummy_supplies,
+	regulator_register_fixed(1, dummy_supplies,
 				ARRAY_SIZE(dummy_supplies));

 	r8a7779_pinmux_init();


In ocsp_match_issuerid() we are passed the CA that signed the responder certificate so need to match its subject with the certificate IDs in the response.

--- crypto/ocsp/ocsp_vfy.c
+++ crypto/ocsp/ocsp_vfy.c
@@ -305,7 +305,7 @@
 		if ((cid->issuerNameHash->length != mdlen) ||
 		   (cid->issuerKeyHash->length != mdlen))
 			return 0;
-		iname = X509_get_issuer_name(cert);
+		iname = X509_get_subject_name(cert);
 		if (!X509_NAME_digest(iname, dgst, md, NULL))
 			return -1;
 		if (memcmp(md, cid->issuerNameHash->data, mdlen))


m68knommu: add CPU reset code for the 5249 ColdFire

Signed-off-by: Greg Ungerer <ed22c22dbde360207569092e60b4298397efb8da@uclinux.org>


Hack around macro conflict problems in KURL.h.
Review URL: http://codereview.chromium.org/7041

git-svn-id: dd90618784b6a4b323ea0c23a071cb1c9e6f2ac7@3159 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

--- webkit/pending/KURL.h
+++ webkit/pending/KURL.h
@@ -32,6 +32,11 @@
 #include "CString.h"
 #include "googleurl/src/url_canon.h"
 #include "googleurl/src/url_parse.h"
+// TODO(brettw): Crazy hack.  Because these headers pull in base/basictypes.h,
+// which redefines COMPILE_ASSERT, restore it here to the definition in
+// wtf/Assertions.h.
+#undef COMPILE_ASSERT
+#define COMPILE_ASSERT(exp, name) typedef int dummy##name [(exp) ? 1 : -1];
 #endif

 #if PLATFORM(CF)


Ensure any default_properties still apply even in the event of a provider load failure

We don't treat a failure to load a provider as a fatal error. If it is fatal then
we give up attempting to load the config file - including reading any default
properties. Additionally if an attempt has been made to load a provider then we
disable fallback loading.

Fixes #16166

Reviewed-by: Tim Hudson <eb0be8e447f673b41b10eda09d63cd72526b0a42@openssl.org>
Reviewed-by: Paul Dale <ddec78389666b4f7c9b4d110380c848489a3e4aa@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16168)

--- crypto/provider_conf.c
+++ crypto/provider_conf.c
@@ -156,6 +156,16 @@
     }

     if (activate) {
+        /*
+        * There is an attempt to activate a provider, so we should disable
+        * loading of fallbacks. Otherwise a misconfiguration could mean the
+        * intended provider does not get loaded. Subsequent fetches could then
+        * fallback to the default provider - which may be the wrong thing.
+        */
+        if (!ossl_provider_disable_fallback_loading(libctx)) {
+            ERR_raise(ERR_LIB_CRYPTO, ERR_R_INTERNAL_ERROR);
+            return 0;
+        }
         prov = ossl_provider_find(libctx, name, 1);
         if (prov == NULL)
             prov = ossl_provider_new(libctx, name, NULL, 1);
@@ -215,7 +225,11 @@

     }

-    return ok;
+    /*
+     * Even if ok is 0, we still return success. Failure to load a provider is
+     * not fatal. We want to continue to load the rest of the config file.
+     */
+    return 1;
 }

 static int provider_conf_init(CONF_IMODULE *md, const CONF *cnf)


number->string: remove trailing 0s

number->string: remove trailing 0s

--- extlib/benz/number.c
+++ extlib/benz/number.c
@@ -549,7 +549,12 @@

     buf = pic_malloc(pic, s);

+
     snprintf(buf, s, "%f", f);
+
+    while(buf[s - 2] == '0')
+      s -= 1;
+
   }
   str = pic_make_str(pic, buf, s - 1);


SH: shmobile: Consolidate time keeping and irq enable

Enable core cpuidle timekeeping and irq enabling and remove that
handling from this code.

Signed-off-by: Robert Lee <14266a2468b11f81a24f9277452466814aad6c80@linaro.org>
Reviewed-by: Kevin Hilman <f9849b02abe18c1ece6bd40346458ed53f49d31b@ti.com>
Reviewed-by: Daniel Lezcano <e9fa45941f2ebe89c1b9d6c5f339ab42eadb8567@linaro.org>
Acked-by: Jean Pihet <24e638326d55c866138eb393a278ce90676b0635@ti.com>
Signed-off-by: Len Brown <b060cfa1096cc6e8be83699ddb4ed8a77dd63af5@intel.com>

--- arch/sh/kernel/cpu/shmobile/cpuidle.c
+++ arch/sh/kernel/cpu/shmobile/cpuidle.c
@@ -29,7 +29,6 @@
 				int index)
 {
 	unsigned long allowed_mode = SUSP_SH_SLEEP;
-	ktime_t before, after;
 	int requested_state = index;
 	int allowed_state;
 	int k;
@@ -47,19 +46,16 @@
 	 */
 	k = min_t(int, allowed_state, requested_state);

-	before = ktime_get();
 	sh_mobile_call_standby(cpuidle_mode[k]);
-	after = ktime_get();
-
-	dev->last_residency = (int)ktime_to_ns(ktime_sub(after, before)) >> 10;

 	return k;
 }

 static struct cpuidle_device cpuidle_dev;
 static struct cpuidle_driver cpuidle_driver = {
-	.name =		"sh_idle",
-	.owner =	THIS_MODULE,
+	.name			= "sh_idle",
+	.owner			= THIS_MODULE,
+	.en_core_tk_irqen	= 1,
 };

 void sh_mobile_setup_cpuidle(void)


A cast is needed or Borland C will complain.

--- crypto/rand/rand_win.c
+++ crypto/rand/rand_win.c
@@ -236,7 +236,7 @@
 		if (cursor)
 			{
 			/* cursor position */
-			cursor(buf);
+			cursor((PCURSORINFO)buf);
 			RAND_add(buf, sizeof(buf), 0);
 			}


extmod/moduhashlib: Prefix all Python methods and objects with uhashlib.

For consistency with other modules, and to help avoid clashes with the
actual underlying functions that do the hashing (eg
crypto-algorithms/sha256.c:sha256_update).

--- extmod/moduhashlib.c
+++ extmod/moduhashlib.c
@@ -50,44 +50,44 @@
     char state[0];
 } mp_obj_hash_t;

-STATIC mp_obj_t hash_update(mp_obj_t self_in, mp_obj_t arg);
-
-STATIC mp_obj_t hash_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t uhashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg);
+
+STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_arg_check_num(n_args, n_kw, 0, 1, false);
     mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(CRYAL_SHA256_CTX));
     o->base.type = type;
     sha256_init((CRYAL_SHA256_CTX*)o->state);
     if (n_args == 1) {
-        hash_update(MP_OBJ_FROM_PTR(o), args[0]);
+        uhashlib_sha256_update(MP_OBJ_FROM_PTR(o), args[0]);
     }
     return MP_OBJ_FROM_PTR(o);
 }

 #if MICROPY_PY_UHASHLIB_SHA1
-STATIC mp_obj_t sha1_update(mp_obj_t self_in, mp_obj_t arg);
-
-#if MICROPY_SSL_AXTLS
-STATIC mp_obj_t sha1_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg);
+
+#if MICROPY_SSL_AXTLS
+STATIC mp_obj_t uhashlib_sha1_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_arg_check_num(n_args, n_kw, 0, 1, false);
     mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(SHA1_CTX));
     o->base.type = type;
     SHA1_Init((SHA1_CTX*)o->state);
     if (n_args == 1) {
-        sha1_update(MP_OBJ_FROM_PTR(o), args[0]);
+        uhashlib_sha1_update(MP_OBJ_FROM_PTR(o), args[0]);
     }
     return MP_OBJ_FROM_PTR(o);
 }
 #endif

 #if MICROPY_SSL_MBEDTLS
-STATIC mp_obj_t sha1_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t uhashlib_sha1_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_arg_check_num(n_args, n_kw, 0, 1, false);
     mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(mbedtls_sha1_context));
     o->base.type = type;
     mbedtls_sha1_init((mbedtls_sha1_context*)o->state);
     mbedtls_sha1_starts((mbedtls_sha1_context*)o->state);
     if (n_args == 1) {
-        sha1_update(MP_OBJ_FROM_PTR(o), args[0]);
+        uhashlib_sha1_update(MP_OBJ_FROM_PTR(o), args[0]);
     }
     return MP_OBJ_FROM_PTR(o);
 }
@@ -95,19 +95,19 @@

 #endif

-STATIC mp_obj_t hash_update(mp_obj_t self_in, mp_obj_t arg) {
+STATIC mp_obj_t uhashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg) {
     mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in);
     mp_buffer_info_t bufinfo;
     mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ);
     sha256_update((CRYAL_SHA256_CTX*)self->state, bufinfo.buf, bufinfo.len);
     return mp_const_none;
 }
-MP_DEFINE_CONST_FUN_OBJ_2(hash_update_obj, hash_update);
-
-#if MICROPY_PY_UHASHLIB_SHA1
-
-#if MICROPY_SSL_AXTLS
-STATIC mp_obj_t sha1_update(mp_obj_t self_in, mp_obj_t arg) {
+MP_DEFINE_CONST_FUN_OBJ_2(uhashlib_sha256_update_obj, uhashlib_sha256_update);
+
+#if MICROPY_PY_UHASHLIB_SHA1
+
+#if MICROPY_SSL_AXTLS
+STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg) {
     mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in);
     mp_buffer_info_t bufinfo;
     mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ);
@@ -117,7 +117,7 @@
 #endif

 #if MICROPY_SSL_MBEDTLS
-STATIC mp_obj_t sha1_update(mp_obj_t self_in, mp_obj_t arg) {
+STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg) {
     mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in);
     mp_buffer_info_t bufinfo;
     mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ);
@@ -126,22 +126,22 @@
 }
 #endif

-MP_DEFINE_CONST_FUN_OBJ_2(sha1_update_obj, sha1_update);
-#endif
-
-STATIC mp_obj_t hash_digest(mp_obj_t self_in) {
+MP_DEFINE_CONST_FUN_OBJ_2(uhashlib_sha1_update_obj, uhashlib_sha1_update);
+#endif
+
+STATIC mp_obj_t uhashlib_sha256_digest(mp_obj_t self_in) {
     mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in);
     vstr_t vstr;
     vstr_init_len(&vstr, SHA256_BLOCK_SIZE);
     sha256_final((CRYAL_SHA256_CTX*)self->state, (byte*)vstr.buf);
     return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
 }
-MP_DEFINE_CONST_FUN_OBJ_1(hash_digest_obj, hash_digest);
-
-#if MICROPY_PY_UHASHLIB_SHA1
-
-#if MICROPY_SSL_AXTLS
-STATIC mp_obj_t sha1_digest(mp_obj_t self_in) {
+MP_DEFINE_CONST_FUN_OBJ_1(uhashlib_sha256_digest_obj, uhashlib_sha256_digest);
+
+#if MICROPY_PY_UHASHLIB_SHA1
+
+#if MICROPY_SSL_AXTLS
+STATIC mp_obj_t uhashlib_sha1_digest(mp_obj_t self_in) {
     mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in);
     vstr_t vstr;
     vstr_init_len(&vstr, SHA1_SIZE);
@@ -151,7 +151,7 @@
 #endif

 #if MICROPY_SSL_MBEDTLS
-STATIC mp_obj_t sha1_digest(mp_obj_t self_in) {
+STATIC mp_obj_t uhashlib_sha1_digest(mp_obj_t self_in) {
     mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in);
     vstr_t vstr;
     vstr_init_len(&vstr, 20);
@@ -161,51 +161,51 @@
 }
 #endif

-MP_DEFINE_CONST_FUN_OBJ_1(sha1_digest_obj, sha1_digest);
-#endif
-
-STATIC const mp_rom_map_elem_t hash_locals_dict_table[] = {
-    { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&hash_update_obj) },
-    { MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&hash_digest_obj) },
-};
-
-STATIC MP_DEFINE_CONST_DICT(hash_locals_dict, hash_locals_dict_table);
-
-STATIC const mp_obj_type_t sha256_type = {
+MP_DEFINE_CONST_FUN_OBJ_1(uhashlib_sha1_digest_obj, uhashlib_sha1_digest);
+#endif
+
+STATIC const mp_rom_map_elem_t uhashlib_sha256_locals_dict_table[] = {
+    { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&uhashlib_sha256_update_obj) },
+    { MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&uhashlib_sha256_digest_obj) },
+};
+
+STATIC MP_DEFINE_CONST_DICT(uhashlib_sha256_locals_dict, uhashlib_sha256_locals_dict_table);
+
+STATIC const mp_obj_type_t uhashlib_sha256_type = {
     { &mp_type_type },
     .name = MP_QSTR_sha256,
-    .make_new = hash_make_new,
-    .locals_dict = (void*)&hash_locals_dict,
-};
-
-#if MICROPY_PY_UHASHLIB_SHA1
-STATIC const mp_rom_map_elem_t sha1_locals_dict_table[] = {
-    { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&sha1_update_obj) },
-    { MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&sha1_digest_obj) },
-};
-STATIC MP_DEFINE_CONST_DICT(sha1_locals_dict, sha1_locals_dict_table);
-
-STATIC const mp_obj_type_t sha1_type = {
+    .make_new = uhashlib_sha256_make_new,
+    .locals_dict = (void*)&uhashlib_sha256_locals_dict,
+};
+
+#if MICROPY_PY_UHASHLIB_SHA1
+STATIC const mp_rom_map_elem_t uhashlib_sha1_locals_dict_table[] = {
+    { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&uhashlib_sha1_update_obj) },
+    { MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&uhashlib_sha1_digest_obj) },
+};
+STATIC MP_DEFINE_CONST_DICT(uhashlib_sha1_locals_dict, uhashlib_sha1_locals_dict_table);
+
+STATIC const mp_obj_type_t uhashlib_sha1_type = {
     { &mp_type_type },
     .name = MP_QSTR_sha1,
-    .make_new = sha1_make_new,
-    .locals_dict = (void*)&sha1_locals_dict,
-};
-#endif
-
-STATIC const mp_rom_map_elem_t mp_module_hashlib_globals_table[] = {
+    .make_new = uhashlib_sha1_make_new,
+    .locals_dict = (void*)&uhashlib_sha1_locals_dict,
+};
+#endif
+
+STATIC const mp_rom_map_elem_t mp_module_uhashlib_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uhashlib) },
-    { MP_ROM_QSTR(MP_QSTR_sha256), MP_ROM_PTR(&sha256_type) },
+    { MP_ROM_QSTR(MP_QSTR_sha256), MP_ROM_PTR(&uhashlib_sha256_type) },
     #if MICROPY_PY_UHASHLIB_SHA1
-    { MP_ROM_QSTR(MP_QSTR_sha1), MP_ROM_PTR(&sha1_type) },
+    { MP_ROM_QSTR(MP_QSTR_sha1), MP_ROM_PTR(&uhashlib_sha1_type) },
     #endif
 };

-STATIC MP_DEFINE_CONST_DICT(mp_module_hashlib_globals, mp_module_hashlib_globals_table);
+STATIC MP_DEFINE_CONST_DICT(mp_module_uhashlib_globals, mp_module_uhashlib_globals_table);

 const mp_obj_module_t mp_module_uhashlib = {
     .base = { &mp_type_module },
-    .globals = (mp_obj_dict_t*)&mp_module_hashlib_globals,
+    .globals = (mp_obj_dict_t*)&mp_module_uhashlib_globals,
 };

 #include "crypto-algorithms/sha256.c"


Don't leak memory on X509_TRUST_add() error path

The X509_TRUST_add() function was leaking an X509_TRUST object on error.

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

--- crypto/x509/x509_trs.c
+++ crypto/x509/x509_trs.c
@@ -148,7 +148,7 @@
     /* dup supplied name */
     if ((trtmp->name = OPENSSL_strdup(name)) == NULL) {
         X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE);
-        return 0;
+        goto err;
     }
     /* Keep the dynamic flag of existing entry */
     trtmp->flags &= X509_TRUST_DYNAMIC;
@@ -165,14 +165,20 @@
         if (trtable == NULL
             && (trtable = sk_X509_TRUST_new(tr_cmp)) == NULL) {
             X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE);
-            return 0;
+            goto err;;
         }
         if (!sk_X509_TRUST_push(trtable, trtmp)) {
             X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE);
-            return 0;
+            goto err;
         }
     }
     return 1;
+ err:
+    if (idx == -1) {
+        OPENSSL_free(trtmp->name);
+        OPENSSL_free(trtmp);
+    }
+    return 0;
 }

 static void trtable_free(X509_TRUST *p)


switched on inplace vector for string stream for linux platforms again (was turned off due stack limitation on os21, please disable it on failing platform instead)

--- stingraykit/string/string_stream.h
+++ stingraykit/string/string_stream.h
@@ -8,7 +8,8 @@
 // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 // WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

-#define STRING_STREAM_USES_INPLACE_VECTOR 0
+#define STRING_STREAM_USES_INPLACE_VECTOR (PLATFORM_LINUX)
+
 #if STRING_STREAM_USES_INPLACE_VECTOR
 #	include <stingraykit/collection/inplace_vector.h>
 #else


Change Cut-Off to 8 KB

Change Cut-Off to 8 KB

--- lib/compress/zstd_compress.c
+++ lib/compress/zstd_compress.c
@@ -1208,7 +1208,7 @@
      * context, or referencing the dictionary context from the working context
      * in-place. We decide here which strategy to use. */
     /* TODO: pick reasonable cut-off size, handle ZSTD_CONTENTSIZE_UNKNOWN */
-    int attachDict = pledgedSrcSize < 64 KB
+    int attachDict = pledgedSrcSize <= 8 KB
                   && cdict->cParams.strategy == ZSTD_fast
                   && ZSTD_equivalentCParams(cctx->appliedParams.cParams,
                                             cdict->cParams);


egl/dri2: Properly dereference array.

egl/dri2: Properly dereference array.

Fixes a regression that broke EGL since

commit 858f2f2ae6d72f338fdd6d544b0c733814e22724
Author: Emil Velikov <emil.l.velikov@gmail.com>
Date:   Sun Sep 13 12:25:27 2015 +0100

    egl/dri2: ease srgb __DRIconfig conditionals

--- src/egl/drivers/dri2/egl_dri2.c
+++ src/egl/drivers/dri2/egl_dri2.c
@@ -1010,10 +1010,10 @@
        * doubleBufferMode check in
        * src/mesa/main/context.c:check_compatible()
        */
-      if (dri2_config->dri_double_config)
-         dri_config = dri2_config->dri_double_config;
+      if (dri2_config->dri_double_config[0])
+         dri_config = dri2_config->dri_double_config[0];
       else
-         dri_config = dri2_config->dri_single_config;
+         dri_config = dri2_config->dri_single_config[0];

       /* EGL_WINDOW_BIT is set only when there is a dri_double_config.  This
        * makes sure the back buffer will always be used.


Reduce size of ZSTD_CDict

Reduce size of ZSTD_CDict

Shaves 492,076 B off of the `ZSTD_CDict`.
The size of a `ZSTD_CDict` created from a 112,640 B dictionary is:

| Level | Before (B) | After (B) |
|-------|------------|-----------|
| 1     | 648,448    | 156,412   |
| 3     | 1,140,008  | 647,932   |

--- lib/compress/zstd_compress.c
+++ lib/compress/zstd_compress.c
@@ -49,7 +49,13 @@
     void* dictBuffer;
     const void* dictContent;
     size_t dictContentSize;
-    ZSTD_CCtx* refContext;
+    void* workspace;
+    size_t workspaceSize;
+    ZSTD_matchState_t matchState;
+    ZSTD_compressedBlockState_t cBlockState;
+    ZSTD_compressionParameters cParams;
+    ZSTD_customMem customMem;
+    U32 dictID;
 };  /* typedef'd to ZSTD_CDict within "zstd.h" */

 ZSTD_CCtx* ZSTD_createCCtx(void)
@@ -799,7 +805,7 @@
            ZSTD_sufficientBuff(buffSize1, blockSize1, buffPol2, params2.cParams, pledgedSrcSize);
 }

-static void ZSTD_resetBlockState(ZSTD_compressedBlockState_t* bs)
+static void ZSTD_reset_compressedBlockState(ZSTD_compressedBlockState_t* bs)
 {
     int i;
     for (i = 0; i < ZSTD_REP_NUM; ++i)
@@ -846,12 +852,73 @@
     cctx->stage = ZSTDcs_init;
     cctx->dictID = 0;
     ZSTD_invalidateMatchState(&cctx->blockState.matchState);
-    ZSTD_resetBlockState(cctx->blockState.prevCBlock);
+    ZSTD_reset_compressedBlockState(cctx->blockState.prevCBlock);
     XXH64_reset(&cctx->xxhState, 0);
     return 0;
 }

 typedef enum { ZSTDcrp_continue, ZSTDcrp_noMemset } ZSTD_compResetPolicy_e;
+
+static size_t ZSTD_sizeof_matchState(ZSTD_compressionParameters const* cParams, const U32 opt)
+{
+    size_t const chainSize = (cParams->strategy == ZSTD_fast) ? 0 : ((size_t)1 << cParams->chainLog);
+    size_t const hSize = ((size_t)1) << cParams->hashLog;
+    U32    const hashLog3 = (cParams->searchLength>3) ? 0 : MIN(ZSTD_HASHLOG3_MAX, cParams->windowLog);
+    size_t const h3Size = ((size_t)1) << hashLog3;
+    size_t const tableSpace = (chainSize + hSize + h3Size) * sizeof(U32);
+    size_t const optPotentialSpace = ((MaxML+1) + (MaxLL+1) + (MaxOff+1) + (1<<Litbits)) * sizeof(U32)
+                          + (ZSTD_OPT_NUM+1) * (sizeof(ZSTD_match_t)+sizeof(ZSTD_optimal_t));
+    size_t const optSpace = (opt && ((cParams->strategy == ZSTD_btopt) ||
+                                     (cParams->strategy == ZSTD_btultra)))
+                                ? optPotentialSpace
+                                : 0;
+    DEBUGLOG(4, "chainSize: %u - hSize: %u - h3Size: %u",
+                (U32)chainSize, (U32)hSize, (U32)h3Size);
+    return tableSpace + optSpace;
+}
+
+static void* ZSTD_reset_matchState(ZSTD_matchState_t* ms, void* ptr, ZSTD_compressionParameters const* cParams, ZSTD_compResetPolicy_e const crp, U32 const opt)
+{
+    size_t const chainSize = (cParams->strategy == ZSTD_fast) ? 0 : ((size_t)1 << cParams->chainLog);
+    size_t const hSize = ((size_t)1) << cParams->hashLog;
+    U32    const hashLog3 = (cParams->searchLength>3) ? 0 : MIN(ZSTD_HASHLOG3_MAX, cParams->windowLog);
+    size_t const h3Size = ((size_t)1) << hashLog3;
+    size_t const tableSpace = (chainSize + hSize + h3Size) * sizeof(U32);
+
+    assert(((size_t)ptr & 3) == 0);
+
+    ms->nextSrc = NULL;
+    ms->base = NULL;
+    ms->dictBase = NULL;
+    ms->hashLog3 = hashLog3;
+    ZSTD_invalidateMatchState(ms);
+
+    /* opt parser space */
+    if (opt && ((cParams->strategy == ZSTD_btopt) | (cParams->strategy == ZSTD_btultra))) {
+        DEBUGLOG(4, "reserving optimal parser space");
+        ms->opt.litFreq = (U32*)ptr;
+        ms->opt.litLengthFreq = ms->opt.litFreq + (1<<Litbits);
+        ms->opt.matchLengthFreq = ms->opt.litLengthFreq + (MaxLL+1);
+        ms->opt.offCodeFreq = ms->opt.matchLengthFreq + (MaxML+1);
+        ptr = ms->opt.offCodeFreq + (MaxOff+1);
+        ms->opt.matchTable = (ZSTD_match_t*)ptr;
+        ptr = ms->opt.matchTable + ZSTD_OPT_NUM+1;
+        ms->opt.priceTable = (ZSTD_optimal_t*)ptr;
+        ptr = ms->opt.priceTable + ZSTD_OPT_NUM+1;
+    }
+
+    /* table Space */
+    DEBUGLOG(4, "reset table : %u", crp!=ZSTDcrp_noMemset);
+    assert(((size_t)ptr & 3) == 0);  /* ensure ptr is properly aligned */
+    if (crp!=ZSTDcrp_noMemset) memset(ptr, 0, tableSpace);   /* reset tables only */
+    ms->hashTable = (U32*)(ptr);
+    ms->chainTable = ms->hashTable + hSize;
+    ms->hashTable3 = ms->chainTable + chainSize;
+    ptr = ms->hashTable3 + h3Size;
+
+    assert(((size_t)ptr & 3) == 0);
+    return ptr;
+}

 /*! ZSTD_resetCCtx_internal() :
     note : `params` are assumed fully validated at this stage */
@@ -860,7 +927,6 @@
                                       ZSTD_compResetPolicy_e const crp,
                                       ZSTD_buffered_policy_e const zbuff)
 {
-    ZSTD_matchState_t* const ms = &zc->blockState.matchState;
     DEBUGLOG(4, "ZSTD_resetCCtx_internal: pledgedSrcSize=%u, wlog=%u",
                 (U32)pledgedSrcSize, params.cParams.windowLog);
     assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
@@ -891,35 +957,23 @@
         U32    const divider = (params.cParams.searchLength==3) ? 3 : 4;
         size_t const maxNbSeq = blockSize / divider;
         size_t const tokenSpace = blockSize + 11*maxNbSeq;
-        size_t const chainSize = (params.cParams.strategy == ZSTD_fast) ?
-                                0 : ((size_t)1 << params.cParams.chainLog);
-        size_t const hSize = ((size_t)1) << params.cParams.hashLog;
-        U32    const hashLog3 = (params.cParams.searchLength>3) ?
-                                0 : MIN(ZSTD_HASHLOG3_MAX, params.cParams.windowLog);
-        size_t const h3Size = ((size_t)1) << hashLog3;
-        size_t const tableSpace = (chainSize + hSize + h3Size) * sizeof(U32);
         size_t const buffOutSize = (zbuff==ZSTDb_buffered) ? ZSTD_compressBound(blockSize)+1 : 0;
         size_t const buffInSize = (zbuff==ZSTDb_buffered) ? windowSize + blockSize : 0;
+        size_t const matchStateSize = ZSTD_sizeof_matchState(&params.cParams, /* opt */ 1);
         void* ptr;

         /* Check if workSpace is large enough, alloc a new one if needed */
         {   size_t const entropySpace = HUF_WORKSPACE_SIZE;
             size_t const blockStateSpace = 2 * sizeof(ZSTD_compressedBlockState_t);
-            size_t const optPotentialSpace = ((MaxML+1) + (MaxLL+1) + (MaxOff+1) + (1<<Litbits)) * sizeof(U32)
-                                  + (ZSTD_OPT_NUM+1) * (sizeof(ZSTD_match_t)+sizeof(ZSTD_optimal_t));
-            size_t const optSpace = ( (params.cParams.strategy == ZSTD_btopt)
-                                    || (params.cParams.strategy == ZSTD_btultra)) ?
-                                    optPotentialSpace : 0;
             size_t const bufferSpace = buffInSize + buffOutSize;
             size_t const ldmSpace = params.ldmParams.enableLdm
                 ? ZSTD_ldm_getTableSize(params.ldmParams.hashLog, params.ldmParams.bucketSizeLog)
                 : 0;
-            size_t const neededSpace = entropySpace + blockStateSpace + optSpace + ldmSpace +
-                                       tableSpace + tokenSpace + bufferSpace;
-            DEBUGLOG(4, "Need %uKB workspace, including %uKB for tables, and %uKB for buffers",
-                        (U32)(neededSpace>>10), (U32)(tableSpace>>10), (U32)(bufferSpace>>10));
-            DEBUGLOG(4, "chainSize: %u - hSize: %u - h3Size: %u - windowSize: %u - blockSize: %u",
-                        (U32)chainSize, (U32)hSize, (U32)h3Size, (U32)windowSize, (U32)blockSize);
+            size_t const neededSpace = entropySpace + blockStateSpace + ldmSpace +
+                                       matchStateSize + tokenSpace + bufferSpace;
+            DEBUGLOG(4, "Need %uKB workspace, including %uKB for match state, and %uKB for buffers",
+                        (U32)(neededSpace>>10), (U32)(matchStateSize>>10), (U32)(bufferSpace>>10));
+            DEBUGLOG(4, "windowSize: %u - blockSize: %u", (U32)windowSize, (U32)blockSize);

             if (zc->workSpaceSize < neededSpace) {  /* too small : resize */
                 DEBUGLOG(4, "Need to update workSpaceSize from %uK to %uK",
@@ -958,31 +1012,9 @@
         zc->stage = ZSTDcs_init;
         zc->dictID = 0;

-        ms->nextSrc = NULL;
-        ms->base = NULL;
-        ms->dictBase = NULL;
-        ms->hashLog3 = hashLog3;
-        ZSTD_invalidateMatchState(ms);
-
-        ZSTD_resetBlockState(zc->blockState.prevCBlock);
+        ZSTD_reset_compressedBlockState(zc->blockState.prevCBlock);

         ptr = zc->entropyWorkspace + HUF_WORKSPACE_SIZE_U32;
-
-        /* opt parser space */
-        if ((params.cParams.strategy == ZSTD_btopt) | (params.cParams.strategy == ZSTD_btultra)) {
-            optState_t* opt = &zc->blockState.matchState.opt;
-            DEBUGLOG(4, "reserving optimal parser space");
-            assert(((size_t)ptr & 3) == 0);  /* ensure ptr is properly aligned */
-            opt->litFreq = (U32*)ptr;
-            opt->litLengthFreq = opt->litFreq + (1<<Litbits);
-            opt->matchLengthFreq = opt->litLengthFreq + (MaxLL+1);
-            opt->offCodeFreq = opt->matchLengthFreq + (MaxML+1);
-            ptr = opt->offCodeFreq + (MaxOff+1);
-            opt->matchTable = (ZSTD_match_t*)ptr;
-            ptr = opt->matchTable + ZSTD_OPT_NUM+1;
-            opt->priceTable = (ZSTD_optimal_t*)ptr;
-            ptr = opt->priceTable + ZSTD_OPT_NUM+1;
-        }

         /* ldm hash table */
         /* initialize bucketOffsets table later for pointer alignment */
@@ -994,14 +1026,7 @@
             ptr = zc->ldmState.hashTable + ldmHSize;
         }

-        /* table Space */
-        DEBUGLOG(4, "reset table : %u", crp!=ZSTDcrp_noMemset);
-        if (crp!=ZSTDcrp_noMemset) memset(ptr, 0, tableSpace);   /* reset tables only */
-        assert(((size_t)ptr & 3) == 0);  /* ensure ptr is properly aligned */
-        ms->hashTable = (U32*)(ptr);
-        ms->chainTable = ms->hashTable + hSize;
-        ms->hashTable3 = ms->chainTable + chainSize;
-        ptr = ms->hashTable3 + h3Size;
+        ptr = ZSTD_reset_matchState(&zc->blockState.matchState, ptr, &params.cParams, crp, /* opt */ 1);

         /* sequences storage */
         zc->seqStore.sequencesStart = (seqDef*)ptr;
@@ -1042,6 +1067,54 @@
     assert(/* !extDict */ cctx->blockState.matchState.lowLimit == cctx->blockState.matchState.dictLimit);
 }

+static size_t ZSTD_resetCCtx_usingCDict(ZSTD_CCtx* cctx,
+                            const ZSTD_CDict* cdict,
+                            unsigned windowLog,
+                            ZSTD_frameParameters fParams,
+                            U64 pledgedSrcSize,
+                            ZSTD_buffered_policy_e zbuff)
+{
+    {   ZSTD_CCtx_params params = cctx->requestedParams;
+        /* Copy only compression parameters related to tables. */
+        params.cParams = cdict->cParams;
+        if (windowLog) params.cParams.windowLog = windowLog;
+        params.fParams = fParams;
+        ZSTD_resetCCtx_internal(cctx, params, pledgedSrcSize,
+                                ZSTDcrp_noMemset, zbuff);
+    }
+
+    /* copy tables */
+    {   size_t const chainSize = (cctx->appliedParams.cParams.strategy == ZSTD_fast) ? 0 : ((size_t)1 << cctx->appliedParams.cParams.chainLog);
+        size_t const hSize =  (size_t)1 << cctx->appliedParams.cParams.hashLog;
+        size_t const h3Size = (size_t)1 << cctx->blockState.matchState.hashLog3;
+        size_t const tableSpace = (chainSize + hSize + h3Size) * sizeof(U32);
+        assert((U32*)cctx->blockState.matchState.chainTable == (U32*)cctx->blockState.matchState.hashTable + hSize);  /* chainTable must follow hashTable */
+        assert((U32*)cctx->blockState.matchState.hashTable3 == (U32*)cctx->blockState.matchState.chainTable + chainSize);
+        assert((U32*)cdict->matchState.chainTable == (U32*)cdict->matchState.hashTable + hSize);  /* chainTable must follow hashTable */
+        assert((U32*)cdict->matchState.hashTable3 == (U32*)cdict->matchState.chainTable + chainSize);
+        memcpy(cctx->blockState.matchState.hashTable, cdict->matchState.hashTable, tableSpace);   /* presumes all tables follow each other */
+    }
+
+    /* copy dictionary offsets */
+    {
+        ZSTD_matchState_t const* srcMatchState = &cdict->matchState;
+        ZSTD_matchState_t* dstMatchState = &cctx->blockState.matchState;
+        dstMatchState->nextToUpdate = srcMatchState->nextToUpdate;
+        dstMatchState->nextToUpdate3= srcMatchState->nextToUpdate3;
+        dstMatchState->nextSrc      = srcMatchState->nextSrc;
+        dstMatchState->base         = srcMatchState->base;
+        dstMatchState->dictBase     = srcMatchState->dictBase;
+        dstMatchState->dictLimit    = srcMatchState->dictLimit;
+        dstMatchState->lowLimit     = srcMatchState->lowLimit;
+        dstMatchState->loadedDictEnd= srcMatchState->loadedDictEnd;
+    }
+    cctx->dictID = cdict->dictID;
+
+    /* copy block state */
+    memcpy(cctx->blockState.prevCBlock, &cdict->cBlockState, sizeof(cdict->cBlockState));
+
+    return 0;
+}

 /*! ZSTD_copyCCtx_internal() :
  *  Duplicate an existing context `srcCCtx` into another one `dstCCtx`.
@@ -2172,22 +2245,26 @@
 }

 /** ZSTD_compress_insertDictionary() :
-*   @return : 0, or an error code */
-static size_t ZSTD_compress_insertDictionary(ZSTD_CCtx* cctx,
+*   @return : dictID, or an error code */
+static size_t ZSTD_compress_insertDictionary(ZSTD_compressedBlockState_t* bs, ZSTD_matchState_t* ms,
+                                             ZSTD_CCtx_params const* params,
                                        const void* dict, size_t dictSize,
-                                             ZSTD_dictMode_e dictMode)
+                                             ZSTD_dictMode_e dictMode,
+                                             void* workspace)
 {
     DEBUGLOG(4, "ZSTD_compress_insertDictionary (dictSize=%u)", (U32)dictSize);
     if ((dict==NULL) || (dictSize<=8)) return 0;

+    ZSTD_reset_compressedBlockState(bs);
+
     /* dict restricted modes */
     if (dictMode==ZSTD_dm_rawContent)
-        return ZSTD_loadDictionaryContent(&cctx->blockState.matchState, &cctx->appliedParams, dict, dictSize);
+        return ZSTD_loadDictionaryContent(ms, params, dict, dictSize);

     if (MEM_readLE32(dict) != ZSTD_MAGIC_DICTIONARY) {
         if (dictMode == ZSTD_dm_auto) {
             DEBUGLOG(4, "raw content dictionary detected");
-            return ZSTD_loadDictionaryContent(&cctx->blockState.matchState, &cctx->appliedParams, dict, dictSize);
+            return ZSTD_loadDictionaryContent(ms, params, dict, dictSize);
         }
         if (dictMode == ZSTD_dm_fullDict)
             return ERROR(dictionary_wrong);
@@ -2195,12 +2272,7 @@
     }

     /* dict as full zstd dictionary */
-    {
-        size_t const dictID = ZSTD_loadZstdDictionary(cctx->blockState.prevCBlock, &cctx->blockState.matchState, &cctx->appliedParams, dict, dictSize, cctx->entropyWorkspace);
-        if (ZSTD_isError(dictID)) return dictID;
-        cctx->dictID = (U32)dictID;
-    }
-    return 0;
+    return ZSTD_loadZstdDictionary(bs, ms, params, dict, dictSize, workspace);
 }

 /*! ZSTD_compressBegin_internal() :
@@ -2219,14 +2291,21 @@

     if (cdict && cdict->dictContentSize>0) {
         cctx->requestedParams = params;
-        return ZSTD_copyCCtx_internal(cctx, cdict->refContext,
-                                      params.cParams.windowLog, params.fParams, pledgedSrcSize,
-                                      zbuff);
+        return ZSTD_resetCCtx_usingCDict(cctx, cdict, params.cParams.windowLog,
+                                         params.fParams, pledgedSrcSize, zbuff);
     }

     CHECK_F( ZSTD_resetCCtx_internal(cctx, params, pledgedSrcSize,
                                      ZSTDcrp_continue, zbuff) );
-    return ZSTD_compress_insertDictionary(cctx, dict, dictSize, dictMode);
+    {
+        size_t const dictID = ZSTD_compress_insertDictionary(
+                cctx->blockState.prevCBlock, &cctx->blockState.matchState,
+                &params, dict, dictSize, dictMode, cctx->entropyWorkspace);
+        if (ZSTD_isError(dictID)) return dictID;
+        assert(dictID <= (size_t)(U32)-1);
+        cctx->dictID = (U32)dictID;
+    }
+    return 0;
 }

 size_t ZSTD_compressBegin_advanced_internal(ZSTD_CCtx* cctx,
@@ -2417,9 +2496,7 @@
         ZSTD_dictLoadMethod_e dictLoadMethod)
 {
     DEBUGLOG(5, "sizeof(ZSTD_CDict) : %u", (U32)sizeof(ZSTD_CDict));
-    DEBUGLOG(5, "CCtx estimate : %u",
-             (U32)ZSTD_estimateCCtxSize_usingCParams(cParams));
-    return sizeof(ZSTD_CDict) + ZSTD_estimateCCtxSize_usingCParams(cParams)
+    return sizeof(ZSTD_CDict) + HUF_WORKSPACE_SIZE + ZSTD_sizeof_matchState(&cParams, /* opt */ 0)
            + (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize);
 }

@@ -2433,8 +2510,7 @@
 {
     if (cdict==NULL) return 0;   /* support sizeof on NULL */
     DEBUGLOG(5, "sizeof(*cdict) : %u", (U32)sizeof(*cdict));
-    DEBUGLOG(5, "ZSTD_sizeof_CCtx : %u", (U32)ZSTD_sizeof_CCtx(cdict->refContext));
-    return ZSTD_sizeof_CCtx(cdict->refContext) + (cdict->dictBuffer ? cdict->dictContentSize : 0) + sizeof(*cdict);
+    return cdict->workspaceSize + (cdict->dictBuffer ? cdict->dictContentSize : 0) + sizeof(*cdict);
 }

 static size_t ZSTD_initCDict_internal(
@@ -2445,11 +2521,12 @@
                     ZSTD_compressionParameters cParams)
 {
     DEBUGLOG(3, "ZSTD_initCDict_internal, mode %u", (U32)dictMode);
+    cdict->cParams = cParams;
     if ((dictLoadMethod == ZSTD_dlm_byRef) || (!dictBuffer) || (!dictSize)) {
         cdict->dictBuffer = NULL;
         cdict->dictContent = dictBuffer;
     } else {
-        void* const internalBuffer = ZSTD_malloc(dictSize, cdict->refContext->customMem);
+        void* const internalBuffer = ZSTD_malloc(dictSize, cdict->customMem);
         cdict->dictBuffer = internalBuffer;
         cdict->dictContent = internalBuffer;
         if (!internalBuffer) return ERROR(memory_allocation);
@@ -2457,13 +2534,29 @@
     }
     cdict->dictContentSize = dictSize;

-    {   ZSTD_CCtx_params cctxParams = cdict->refContext->requestedParams;
-        cctxParams.cParams = cParams;
-        CHECK_F( ZSTD_compressBegin_internal(cdict->refContext,
-                                        cdict->dictContent, dictSize, dictMode,
-                                        NULL,
-                                        cctxParams, ZSTD_CONTENTSIZE_UNKNOWN,
-                                        ZSTDb_not_buffered) );
+    {
+        void* const end = ZSTD_reset_matchState(
+                &cdict->matchState,
+                (U32*)cdict->workspace + HUF_WORKSPACE_SIZE_U32,
+                &cParams, ZSTDcrp_continue, /* opt */ 0);
+        assert(end == (char*)cdict->workspace + cdict->workspaceSize);
+        (void)end;
+    }
+    {
+        ZSTD_CCtx_params params;
+        memset(&params, 0, sizeof(params));
+        params.compressionLevel = ZSTD_CLEVEL_DEFAULT;
+        params.fParams.contentSizeFlag = 1;
+        params.cParams = cParams;
+        {
+            size_t const dictID = ZSTD_compress_insertDictionary(
+                    &cdict->cBlockState, &cdict->matchState,&params,
+                    cdict->dictContent, cdict->dictContentSize,
+                    dictMode, cdict->workspace);
+            if (ZSTD_isError(dictID)) return dictID;
+            assert(dictID <= (size_t)(U32)-1);
+            cdict->dictID = (U32)dictID;
+        }
     }

     return 0;
@@ -2478,14 +2571,17 @@
     if (!customMem.customAlloc ^ !customMem.customFree) return NULL;

     {   ZSTD_CDict* const cdict = (ZSTD_CDict*)ZSTD_malloc(sizeof(ZSTD_CDict), customMem);
-        ZSTD_CCtx* const cctx = ZSTD_createCCtx_advanced(customMem);
-
-        if (!cdict || !cctx) {
+        size_t const workspaceSize = HUF_WORKSPACE_SIZE + ZSTD_sizeof_matchState(&cParams, /* opt */ 0);
+        void* const workspace = ZSTD_malloc(workspaceSize, customMem);
+
+        if (!cdict || !workspace) {
             ZSTD_free(cdict, customMem);
-            ZSTD_freeCCtx(cctx);
+            ZSTD_free(workspace, customMem);
             return NULL;
         }
-        cdict->refContext = cctx;
+        cdict->customMem = customMem;
+        cdict->workspace = workspace;
+        cdict->workspaceSize = workspaceSize;
         if (ZSTD_isError( ZSTD_initCDict_internal(cdict,
                                         dictBuffer, dictSize,
                                         dictLoadMethod, dictMode,
@@ -2517,8 +2613,8 @@
 size_t ZSTD_freeCDict(ZSTD_CDict* cdict)
 {
     if (cdict==NULL) return 0;   /* support free on NULL */
-    {   ZSTD_customMem const cMem = cdict->refContext->customMem;
-        ZSTD_freeCCtx(cdict->refContext);
+    {   ZSTD_customMem const cMem = cdict->customMem;
+        ZSTD_free(cdict->workspace, cMem);
         ZSTD_free(cdict->dictBuffer, cMem);
         ZSTD_free(cdict, cMem);
         return 0;
@@ -2544,9 +2640,9 @@
                                  ZSTD_dictMode_e dictMode,
                                  ZSTD_compressionParameters cParams)
 {
-    size_t const cctxSize = ZSTD_estimateCCtxSize_usingCParams(cParams);
+    size_t const matchStateSize = ZSTD_sizeof_matchState(&cParams, /* opt */ 0);
     size_t const neededSize = sizeof(ZSTD_CDict) + (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize)
-                            + cctxSize;
+                            + HUF_WORKSPACE_SIZE + matchStateSize;
     ZSTD_CDict* const cdict = (ZSTD_CDict*) workspace;
     void* ptr;
     if ((size_t)workspace & 7) return NULL;  /* 8-aligned */
@@ -2561,7 +2657,8 @@
     } else {
         ptr = cdict+1;
     }
-    cdict->refContext = ZSTD_initStaticCCtx(ptr, cctxSize);
+    cdict->workspace = ptr;
+    cdict->workspaceSize = HUF_WORKSPACE_SIZE + matchStateSize;

     if (ZSTD_isError( ZSTD_initCDict_internal(cdict,
                                               dict, dictSize,
@@ -2573,7 +2670,7 @@
 }

 ZSTD_compressionParameters ZSTD_getCParamsFromCDict(const ZSTD_CDict* cdict) {
-    return cdict->refContext->appliedParams.cParams;
+    return cdict->cParams;
 }

 /* ZSTD_compressBegin_usingCDict_advanced() :


updated cLevels

updated cLevels


Clamp compression level in ZSTD_getCParams_internal() function

--- lib/compress/zstd_compress.c
+++ lib/compress/zstd_compress.c
@@ -4681,13 +4681,21 @@
 {
     U64 const rSize = ZSTD_getCParamRowSize(srcSizeHint, dictSize, mode);
     U32 const tableID = (rSize <= 256 KB) + (rSize <= 128 KB) + (rSize <= 16 KB);
-    int row = compressionLevel;
+    int row;
     DEBUGLOG(5, "ZSTD_getCParams_internal (cLevel=%i)", compressionLevel);
+
+    /* row */
     if (compressionLevel == 0) row = ZSTD_CLEVEL_DEFAULT;   /* 0 == default */
-    if (compressionLevel < 0) row = 0;   /* entry 0 is baseline for fast mode */
-    if (compressionLevel > ZSTD_MAX_CLEVEL) row = ZSTD_MAX_CLEVEL;
+    else if (compressionLevel < 0) row = 0;   /* entry 0 is baseline for fast mode */
+    else if (compressionLevel > ZSTD_MAX_CLEVEL) row = ZSTD_MAX_CLEVEL;
+    else row = compressionLevel;
+
     {   ZSTD_compressionParameters cp = ZSTD_defaultCParameters[tableID][row];
-        if (compressionLevel < 0) cp.targetLength = (unsigned)(-compressionLevel);   /* acceleration factor */
+        /* acceleration factor */
+        if (compressionLevel < 0) {
+            int const clampedCompressionLevel = MAX(ZSTD_minCLevel(), compressionLevel);
+            cp.targetLength = (unsigned)(-clampedCompressionLevel);
+        }
         /* refine parameters based on srcSize & dictSize */
         return ZSTD_adjustCParams_internal(cp, srcSizeHint, dictSize, mode);
     }


Explicitly call destructor of Mutex to release resources.

Change-Id: I808f4a3689e723d4490aa9ba6f1c14e3936ddcec

--- src/google/protobuf/map_field.h
+++ src/google/protobuf/map_field.h
@@ -68,7 +68,11 @@
         repeated_field_(NULL),
         entry_descriptor_(NULL),
         assign_descriptor_callback_(NULL),
-        state_(STATE_MODIFIED_MAP) {}
+        state_(STATE_MODIFIED_MAP) {
+    // Mutex's destructor needs to be called explicitly to release resources
+    // acquired in its constructor.
+    arena->OwnDestructor(&mutex_);
+  }
   virtual ~MapFieldBase();

   // Returns reference to internal repeated field. Data written using


remove REQUIRE(mctx != NULL) from tostruct

--- lib/dns/rdata/generic/ns_2.c
+++ lib/dns/rdata/generic/ns_2.c
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */

-/* $Id: ns_2.c,v 1.28 2000/05/05 17:24:21 gson Exp $ */
+/* $Id: ns_2.c,v 1.29 2000/05/18 06:27:07 marka Exp $ */

 /* Reviewed: Wed Mar 15 18:15:00 PST 2000 by bwelling */

@@ -144,7 +144,6 @@

 	REQUIRE(rdata->type == 2);
 	REQUIRE(target != NULL);
-	REQUIRE(mctx != NULL);

 	ns->common.rdclass = rdata->rdclass;
 	ns->common.rdtype = rdata->type;


uninitialized variables could lead to a core dump.

--- lib/dns/sec/dst/bsafe_link.c
+++ lib/dns/sec/dst/bsafe_link.c
@@ -19,7 +19,7 @@

 /*
  * Principal Author: Brian Wellington
- * $Id: bsafe_link.c,v 1.34 2000/08/16 00:30:53 bwelling Exp $
+ * $Id: bsafe_link.c,v 1.35 2000/09/07 12:10:36 bwelling Exp $
  */

 #if defined(DNSSAFE)
@@ -300,8 +300,8 @@

 static isc_result_t
 dnssafersa_generate(dst_key_t *key, int exp) {
-	B_KEY_OBJ private;
-	B_KEY_OBJ public;
+	B_KEY_OBJ private = NULL;
+	B_KEY_OBJ public = NULL;
 	B_ALGORITHM_OBJ keypairGenerator = NULL;
 	B_ALGORITHM_OBJ randomAlgorithm = NULL;
 	A_RSA_KEY_GEN_PARAMS keygenParams;


Fix forward declaration.

Fix forward declaration.

--- searchlib/src/vespa/searchlib/queryeval/global_filter.h
+++ searchlib/src/vespa/searchlib/queryeval/global_filter.h
@@ -5,7 +5,7 @@
 #include <memory>
 #include <vector>

-namespace vespalib { class ThreadBundle; }
+namespace vespalib { struct ThreadBundle; }
 namespace search { class BitVector; }

 namespace search::queryeval {


NovelChapterParser inheritance NovelProcessTool.

--- src/header/NovelChapterParser.h
+++ src/header/NovelChapterParser.h
@@ -16,7 +16,7 @@

 using namespace std;

-class NovelChapterParser {
+class NovelChapterParser: public NovelProcessTool {
 public:
 	NovelChapterParser();
 	virtual ~NovelChapterParser();


style fix

style fix

--- src/http/ngx_http_core_module.c
+++ src/http/ngx_http_core_module.c
@@ -72,7 +72,7 @@
 static char *ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data);

 static ngx_conf_post_t  ngx_http_core_lowat_post =
-                                                 { ngx_http_core_lowat_check };
+    { ngx_http_core_lowat_check };

 static ngx_conf_deprecated_t  ngx_conf_deprecated_optimize_host_names = {
     ngx_conf_deprecated, "optimize_host_names", "optimize_server_names"


listenning port

listenning port

--- src/http/ngx_http_core_module.h
+++ src/http/ngx_http_core_module.h
@@ -178,7 +178,7 @@

     ngx_hash_keys_arrays_t    *variables_keys;

-    ngx_array_t               *ports;
+    ngx_array_t               *ports;           /* 保存各主机监听端口 */

     ngx_uint_t                 try_files;       /* unsigned  try_files:1 */

@@ -277,16 +277,20 @@

 typedef struct {
     ngx_int_t                  family;
-    in_port_t                  port;
+    in_port_t                  port;      /* 监听端口 */
     ngx_array_t                addrs;     /* array of ngx_http_conf_addr_t */
+                               /* 同一主机可能监听多个域名,就有多个地址 */
 } ngx_http_conf_port_t;

 typedef struct {
     ngx_http_listen_opt_t      opt;

+    /* 完全匹配主机名 hash  */
     ngx_hash_t                 hash;
+    /* 前置通配符匹配主机名 hash */
     ngx_hash_wildcard_t       *wc_head;
+    /* 后置通配符匹配主机名 hash */
     ngx_hash_wildcard_t       *wc_tail;

 #if (NGX_PCRE)
@@ -295,7 +299,9 @@
 #endif

     /* the default server configuration for this address:port */
+    /* 对应 ngx_http_conf_port_t 中默认主机 */
     ngx_http_core_srv_conf_t  *default_server;
+    /* 主机列表 */
     ngx_array_t                servers;  /* array of ngx_http_core_srv_conf_t */
 } ngx_http_conf_addr_t;

@@ -462,8 +468,8 @@

 typedef struct {
     ngx_queue_t                      queue;
-    ngx_http_core_loc_conf_t        *exact;
-    ngx_http_core_loc_conf_t        *inclusive;
+    ngx_http_core_loc_conf_t        *exact;  /* 精确匹配对应的配置 */
+    ngx_http_core_loc_conf_t        *inclusive; /* 正则匹配对应的配置 */
     ngx_str_t                       *name;
     u_char                          *file_name;
     ngx_uint_t                       line;


uptime: fix buffer destroy with proper api (#1664)

Signed-off-by: Eduardo Silva <81f705dc2ce1a61a2621e0e4b442a9474e1d0c70@treasure-data.com>

--- src/http_server/api/v1/uptime.c
+++ src/http_server/api/v1/uptime.c
@@ -100,7 +100,7 @@
     mk_http_send(request, out_buf, out_size, NULL);
     mk_http_done(request);

-    flb_free(out_buf);
+    flb_sds_destroy(out_buf);
 }

 /* Perform registration */


io_uring.h: sync with 5.19 io_uring release

A few missing bits due to the topic branches not being synced.

Signed-off-by: Jens Axboe <cd8c6775e60d6f67a6984377324e5290df3d5358@kernel.dk>

--- src/include/liburing/io_uring.h
+++ src/include/liburing/io_uring.h
@@ -76,7 +76,7 @@
  * in. The picked direct descriptor will be returned in cqe->res, or -ENFILE
  * if the space is full.
  */
-#define IORING_FILE_INDEX_ALLOC         (~0U)
+#define IORING_FILE_INDEX_ALLOC		(~0U)

 enum {
 	IOSQE_FIXED_FILE_BIT,
@@ -181,6 +181,8 @@
 	IORING_OP_SETXATTR,
 	IORING_OP_FGETXATTR,
 	IORING_OP_GETXATTR,
+	IORING_OP_SOCKET,
+	IORING_OP_URING_CMD,

 	/* this goes last, obviously */
 	IORING_OP_LAST,
@@ -244,6 +246,11 @@
  *				the initial transfer attempt.
  */
 #define IORING_RECVSEND_POLL_FIRST	(1U << 0)
+
+/*
+ * accept flags stored in sqe->ioprio
+ */
+#define IORING_ACCEPT_MULTISHOT	(1U << 0)

 /*
  * IO completion data structure (Completion Queue Entry)


removed proto for Trspi_LoadBlob_PUBKEY, which doesn't exist

--- src/include/trousers/trousers.h
+++ src/include/trousers/trousers.h
@@ -58,7 +58,6 @@
 void Trspi_LoadBlob_KEY_PARMS(UINT16 *offset, BYTE *blob, TCPA_KEY_PARMS *keyInfo);
 void Trspi_LoadBlob_STORE_PUBKEY(UINT16 *offset, BYTE *blob, TCPA_STORE_PUBKEY *store);
 void Trspi_LoadBlob_UUID(UINT16 *offset, BYTE *blob, TSS_UUID uuid);
-void Trspi_LoadBlob_PUBKEY(UINT16 *offset, BYTE *blob, TCPA_PUBKEY pubKey);
 void Trspi_LoadBlob_CERTIFY_INFO(UINT16 *offset, BYTE *blob, TCPA_CERTIFY_INFO *certify);
 void Trspi_LoadBlob_STORE_ASYMKEY(UINT16 *offset, BYTE *blob, TCPA_STORE_ASYMKEY *store);
 void Trspi_LoadBlob_PCR_EVENT(UINT16 *offset, BYTE *blob, TSS_PCR_EVENT *event);


indexer-worker: verbose_proctitle=yes now shows username+mailbox.

--- src/indexer/master-connection.c
+++ src/indexer/master-connection.c
@@ -5,7 +5,9 @@
 #include "istream.h"
 #include "write-full.h"
 #include "strescape.h"
+#include "process-title.h"
 #include "master-service.h"
+#include "master-service-settings.h"
 #include "mail-namespace.h"
 #include "mail-storage.h"
 #include "mail-storage-service.h"
@@ -29,6 +31,18 @@

 	unsigned int version_received:1;
 };
+
+static void
+indexer_worker_refresh_proctitle(const char *username, const char *mailbox)
+{
+	if (!master_service_settings_get(master_service)->verbose_proctitle)
+		return;
+
+	if (username != NULL)
+		process_title_set(t_strdup_printf("[%s %s]", username, mailbox));
+	else
+		process_title_set("[idling]");
+}

 static int index_mailbox(struct mail_user *user, const char *mailbox)
 {
@@ -90,7 +104,9 @@
 		i_error("User %s lookup failed: %s", args[0], error);
 		ret = -1;
 	} else {
+		indexer_worker_refresh_proctitle(user->username, args[1]);
 		ret = index_mailbox(user, args[1]);
+		indexer_worker_refresh_proctitle(NULL, NULL);
 		mail_user_unref(&user);
 		mail_storage_service_user_free(&service_user);
 	}


Fix segmentation fault in GetFactors function

--- src/inference/graph_inference.h
+++ src/inference/graph_inference.h
@@ -92,13 +92,13 @@
   }

   void GetFactors(Factor& giv_labels, int current_depth, int next_level_label, std::vector<Factor>* candidates, size_t beam_size) {
-    if (factor_features.size() < beam_size || next_level.empty()) {
+    if (factor_features.size() < beam_size || next_level.empty() || giv_labels.empty()) {
       for (auto it = factor_features.begin(); it != factor_features.end(); ++it) {
         candidates->push_back(it->second);
       }
     } else {
       auto it = giv_labels.begin();
-      std::advance(it, current_depth - 1);
+      std::advance(it, current_depth);
       if (next_level.count(next_level_label) > 0) {
         next_level[next_level_label]->GetFactors(giv_labels, current_depth + 1, *it, candidates, beam_size);
       }


Fix wrong return type in saveload for parse_object, the parser already handles wrapping it in an array for parse_string

--- mud/home/Game/sys/saveload.c
+++ mud/home/Game/sys/saveload.c
@@ -454,15 +454,15 @@

 /* parse and print helpers */

-object *parse_object(string input)
+object parse_object(string input)
 {
 	int on;
 	string username;

 	if (sscanf(input, "O:%d", on)) {
-		return ({ on2ob->query_element(on) });
+		return on2ob->query_element(on);
 	} else if (sscanf(input, "U:%s", username)) {
-		return ({ TEXT_USERD->find_user(username) });
+		return TEXT_USERD->find_user(username);
 	} else {
 		error("Cannot parse: " + input);
 	}


QuarkFspPkg/Pei: Fix build error

QuarkFspPkg/Pei: Fix build error

Fix build error detected by GCC 4.8
Remove dead code

Change-Id: I3d8d0186ffbd24c1421e55af766f5caba2496a80
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Lee Leahy <5db40003354dc1c142019712d90bc051b3fe1c17@intel.com>

--- QuarkFspPkg/FspInit/Pei/MrcWrapper.c
+++ QuarkFspPkg/FspInit/Pei/MrcWrapper.c
@@ -554,11 +554,6 @@
   EFI_RESOURCE_ATTRIBUTE_TYPE           Attribute;
   EFI_PHYSICAL_ADDRESS                  BadMemoryAddress;
   EFI_SMRAM_DESCRIPTOR                  DescriptorAcpiVariable;
-  //VOID                                  *CapsuleBuffer;
-  //UINTN                                 CapsuleBufferLength;
-  //PEI_CAPSULE_PPI                       *Capsule;
-  VOID                                  *LargeMemRangeBuf;
-  UINTN                                 LargeMemRangeBufLen;
   UINT8                                 MorControl;
   UINTN                                 DataSize;

@@ -669,72 +664,6 @@
       PeiMemoryIndex = Index;
     }
   }
-
-  //
-  // Find the largest memory range excluding that given to PEI.
-  //
-  LargeMemRangeBuf = NULL;
-  LargeMemRangeBufLen = 0;
-  for (Index = 0; Index < NumRanges; Index++) {
-    if ((MemoryMap[Index].Type == DualChannelDdrMainMemory) &&
-        (MemoryMap[Index].PhysicalAddress + MemoryMap[Index].RangeLength < MAX_ADDRESS)) {
-          if (Index != PeiMemoryIndex) {
-            if (MemoryMap[Index].RangeLength > LargeMemRangeBufLen) {
-              LargeMemRangeBuf = (VOID *) ((UINTN) MemoryMap[Index].PhysicalAddress);
-              LargeMemRangeBufLen = (UINTN) MemoryMap[Index].RangeLength;
-            }
-          } else {
-            if ((MemoryMap[Index].RangeLength - PeiMemoryLength) >= LargeMemRangeBufLen) {
-              LargeMemRangeBuf = (VOID *) ((UINTN) MemoryMap[Index].PhysicalAddress);
-              LargeMemRangeBufLen = (UINTN) (MemoryMap[Index].RangeLength - PeiMemoryLength);
-            }
-          }
-    }
-  }
-
-  //Capsule             = NULL;
-  //CapsuleBuffer       = NULL;
-  //CapsuleBufferLength = 0;
-  //if (BootMode == BOOT_ON_FLASH_UPDATE) {
-  //  Status = PeiServicesLocatePpi (
-  //             &gPeiCapsulePpiGuid,  // GUID
-  //             0,                    // INSTANCE
-  //             NULL,                 // EFI_PEI_PPI_DESCRIPTOR
-  //             (VOID **)&Capsule     // PPI
-  //             );
-  //  ASSERT_EFI_ERROR (Status);
-
-  //  if (Status == EFI_SUCCESS) {
-  //    CapsuleBuffer = LargeMemRangeBuf;
-  //    CapsuleBufferLength = LargeMemRangeBufLen;
-
-  //    //
-  //    // Call the Capsule PPI Coalesce function to coalesce the capsule data.
-  //    //
-  //    Status = Capsule->Coalesce (
-  //                        PeiServices,
-  //                        &CapsuleBuffer,
-  //                        &CapsuleBufferLength
-  //                        );
-  //    //
-  //    // If it failed, then NULL out our capsule PPI pointer so that the capsule
-  //    // HOB does not get created below.
-  //    //
-  //    if (Status != EFI_SUCCESS) {
-  //      Capsule = NULL;
-  //    }
-  //  }
-  //}
-
-  //
-  // Set up the IMR policy required for this platform
-  //
-  //Status = SetPlatformImrPolicy (
-  //            PeiMemoryBaseAddress,
-  //            PeiMemoryLength,
-  //            RequiredMemSize
-  //            );
-  //ASSERT_EFI_ERROR (Status);

   //
   // Carve out the top memory reserved for ACPI
@@ -1085,7 +1014,6 @@
   OUT     UINTN                             *Size
   )
 {
-  EFI_STATUS                     Status;
   EFI_PEI_HOB_POINTERS           Hob;
   EFI_MEMORY_TYPE_INFORMATION    *MemoryData;
   UINT8                          Index;
@@ -1095,7 +1023,7 @@
   TempPageNum = 0;
   Index       = 0;

-  Status      = PeiServicesGetHobList ((VOID **)&Hob.Raw);
+  PeiServicesGetHobList ((VOID **)&Hob.Raw);
   while (!END_OF_HOB_LIST (Hob)) {
     if (Hob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION &&
         CompareGuid (&Hob.Guid->Name, &gEfiMemoryTypeInformationGuid)
@@ -1167,7 +1095,6 @@
   PEI_MEMORY_RANGE_SMRAM            SmramMask;
   PEI_MEMORY_RANGE_SMRAM            TsegMask;
   UINT32                            BlockNum;
-  UINT8                             EsmramcRegister;
   UINT8                             ExtendedMemoryIndex;
   UINT32                            Register;

@@ -1190,7 +1117,6 @@
   //
   // Generate Memory ranges for the memory map.
   //
-  EsmramcRegister = 0;
   MemorySize = 0;

   RowLength = TotalMemorySize;
@@ -1472,135 +1398,6 @@
 Done:
   return EFI_SUCCESS;
 }
-
-/**
-
-  This function sets up the platform specific IMR protection for the various
-  memory regions.
-
-  @param  PeiMemoryBaseAddress  Base address of memory allocated for PEI.
-  @param  PeiMemoryLength       Length in bytes of the PEI memory (includes ACPI memory).
-  @param  RequiredMemSize       Size in bytes of the ACPI/Runtime memory
-
-  @return EFI_SUCCESS           The function completed successfully.
-          EFI_ACCESS_DENIED     Access to IMRs failed.
-
-**/
-//EFI_STATUS
-//SetPlatformImrPolicy (
-//  IN      EFI_PHYSICAL_ADDRESS    PeiMemoryBaseAddress,
-//  IN      UINT64                  PeiMemoryLength,
-//  IN      UINTN                   RequiredMemSize
-//  )
-//{
-//  UINT8         Index;
-//  UINT32        Register;
-//  UINT16        DeviceId;
-//
-//  //
-//  // Check what Soc we are running on (read Host bridge DeviceId)
-//  //
-//  DeviceId = QNCMmPci16(0, MC_BUS, MC_DEV, MC_FUN, PCI_DEVICE_ID_OFFSET);
-//
-//  //
-//  // If any IMR register is locked then we cannot proceed
-//  //
-//  for (Index = (QUARK_NC_MEMORY_MANAGER_IMR0+QUARK_NC_MEMORY_MANAGER_IMRXL); Index <=(QUARK_NC_MEMORY_MANAGER_IMR7+QUARK_NC_MEMORY_MANAGER_IMRXL); Index=Index+4)
-//  {
-//    Register = QNCPortRead (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID, Index);
-//    if (Register & IMR_LOCK) {
-//      return EFI_ACCESS_DENIED;
-//    }
-//  }
-//
-//  //
-//  // Add IMR0 protection for the 'PeiMemory'
-//  //
-//  QncImrWrite (
-//            QUARK_NC_MEMORY_MANAGER_IMR0,
-//            (UINT32)(((RShiftU64(PeiMemoryBaseAddress, 8)) & IMRL_MASK) | IMR_EN),
-//            (UINT32)((RShiftU64((PeiMemoryBaseAddress+PeiMemoryLength-RequiredMemSize + EFI_PAGES_TO_SIZE(EDKII_DXE_MEM_SIZE_PAGES-1) - 1), 8)) & IMRL_MASK),
-//            (UINT32)(CPU_SNOOP + CPU0_NON_SMM),
-//            (UINT32)(CPU_SNOOP + CPU0_NON_SMM)
-//        );
-//
-//  //
-//  // Add IMR2 protection for shadowed RMU binary.
-//  //
-//  QncImrWrite (
-//            QUARK_NC_MEMORY_MANAGER_IMR2,
-//            (UINT32)(((RShiftU64((PeiMemoryBaseAddress+PeiMemoryLength), 8)) & IMRH_MASK) | IMR_EN),
-//            (UINT32)((RShiftU64((PeiMemoryBaseAddress+PeiMemoryLength+PcdGet32(PcdFlashQNCMicrocodeSize)-1), 8)) & IMRH_MASK),
-//            (UINT32)(CPU_SNOOP + RMU + CPU0_NON_SMM),
-//            (UINT32)(CPU_SNOOP + RMU + CPU0_NON_SMM)
-//        );
-//
-//  //
-//  // Add IMR3 protection for the default SMRAM.
-//  //
-//  QncImrWrite (
-//            QUARK_NC_MEMORY_MANAGER_IMR3,
-//            (UINT32)(((RShiftU64((SMM_DEFAULT_SMBASE), 8)) & IMRL_MASK) | IMR_EN),
-//            (UINT32)((RShiftU64((SMM_DEFAULT_SMBASE+SMM_DEFAULT_SMBASE_SIZE_BYTES-1), 8)) & IMRH_MASK),
-//            (UINT32)(CPU_SNOOP + CPU0_NON_SMM),
-//            (UINT32)(CPU_SNOOP + CPU0_NON_SMM)
-//        );
-//
-//  //
-//  // Add IMR5 protection for the legacy S3 and AP Startup Vector region (below 1MB).
-//  //
-//  QncImrWrite (
-//            QUARK_NC_MEMORY_MANAGER_IMR5,
-//            (UINT32)(((RShiftU64(AP_STARTUP_VECTOR, 8)) & IMRL_MASK) | IMR_EN),
-//            (UINT32)((RShiftU64((AP_STARTUP_VECTOR + EFI_PAGE_SIZE - 1), 8)) & IMRH_MASK),
-//            (UINT32)(CPU_SNOOP + CPU0_NON_SMM),
-//            (UINT32)(CPU_SNOOP + CPU0_NON_SMM)
-//        );
-//
-//  //
-//  // Add IMR6 protection for the ACPI Reclaim/ACPI/Runtime Services.
-//  //
-//  QncImrWrite (
-//            QUARK_NC_MEMORY_MANAGER_IMR6,
-//            (UINT32)(((RShiftU64((PeiMemoryBaseAddress+PeiMemoryLength-RequiredMemSize+EFI_PAGES_TO_SIZE(EDKII_DXE_MEM_SIZE_PAGES-1)), 8)) & IMRL_MASK) | IMR_EN),
-//            (UINT32)((RShiftU64((PeiMemoryBaseAddress+PeiMemoryLength-EFI_PAGE_SIZE-1), 8)) & IMRH_MASK),
-//            (UINT32)(CPU_SNOOP + CPU0_NON_SMM),
-//            (UINT32)(CPU_SNOOP + CPU0_NON_SMM)
-//        );
-//
-//  //
-//  // Enable IMR4 protection of eSRAM.
-//  //
-//  QncImrWrite (
-//            QUARK_NC_MEMORY_MANAGER_IMR4,
-//            (UINT32)(((RShiftU64((UINTN)PcdGet32 (PcdEsramStage1Base), 8)) & IMRL_MASK) | IMR_EN),
-//            (UINT32)((RShiftU64(((UINTN)PcdGet32 (PcdEsramStage1Base) + (UINTN)PcdGet32 (PcdESramMemorySize) - 1), 8)) & IMRH_MASK),
-//            (UINT32)(CPU_SNOOP + CPU0_NON_SMM),
-//            (UINT32)(CPU_SNOOP + CPU0_NON_SMM)
-//        );
-//
-//  //
-//  // Enable Interrupt on IMR/SMM Violation
-//  //
-//  QNCPortWrite (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID, QUARK_NC_MEMORY_MANAGER_BIMRVCTL, (UINT32)(EnableIMRInt));
-//  if (DeviceId == QUARK2_MC_DEVICE_ID) {
-//    QNCPortWrite (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID, QUARK_NC_MEMORY_MANAGER_BSMMVCTL, (UINT32)(EnableSMMInt));
-//  }
-//
-//  //
-//  // Disable IMR7 memory protection (eSRAM + DDR3 memory) since our policies
-//  // are now setup.
-//  //
-//  QncImrWrite (
-//            QUARK_NC_MEMORY_MANAGER_IMR7,
-//            (UINT32)(IMRL_RESET & ~IMR_EN),
-//            (UINT32)IMRH_RESET,
-//            (UINT32)IMRX_ALL_ACCESS,
-//            (UINT32)IMRX_ALL_ACCESS
-//        );
-//
-//  return EFI_SUCCESS;
-//}

 /** Return info derived from Installing Memory by MemoryInit.


selftests/seccomp: Get page size from sysconf

The commit fd88d16c58c2 ("selftests/seccomp: Be more precise with
syscall arguments.") use PAGE_SIZE directly which lead to build
failure on arm64.

Replace it with generic interface(sysconf(_SC_PAGESIZE)) to fix this
failure.

Build and test successful on x86_64 and arm64.

Signed-off-by: Bamvor Jian Zhang <dfc0de41528c027b50fd22770760a372c0edde22@linaro.org>
Acked-by: Kees Cook <50cb10d2be062154b17ab4d66a4eab34f1cf1c84@chromium.org>
Tested-by: Michael Ellerman <864f124608374e06e4da1fa5d2e47ed839b95411@ellerman.id.au>
Signed-off-by: Shuah Khan <c62751f8c6ce7eb0639cab80a821801931863a4b@osg.samsung.com>

--- tools/testing/selftests/seccomp/seccomp_bpf.c
+++ tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -492,6 +492,9 @@
 	pid_t parent = getppid();
 	int fd;
 	void *map1, *map2;
+	int page_size = sysconf(_SC_PAGESIZE);
+
+	ASSERT_LT(0, page_size);

 	ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
 	ASSERT_EQ(0, ret);
@@ -504,16 +507,16 @@

 	EXPECT_EQ(parent, syscall(__NR_getppid));
 	map1 = (void *)syscall(sysno,
-		NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd, PAGE_SIZE);
+		NULL, page_size, PROT_READ, MAP_PRIVATE, fd, page_size);
 	EXPECT_NE(MAP_FAILED, map1);
 	/* mmap2() should never return. */
 	map2 = (void *)syscall(sysno,
-		 NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd, 0x0C0FFEE);
+		 NULL, page_size, PROT_READ, MAP_PRIVATE, fd, 0x0C0FFEE);
 	EXPECT_EQ(MAP_FAILED, map2);

 	/* The test failed, so clean up the resources. */
-	munmap(map1, PAGE_SIZE);
-	munmap(map2, PAGE_SIZE);
+	munmap(map1, page_size);
+	munmap(map2, page_size);
 	close(fd);
 }


u3: refactors +repn jet using u3i_slab api

--- pkg/urbit/jets/c/repn.c
+++ pkg/urbit/jets/c/repn.c
@@ -28,19 +28,8 @@
   c3_w num_blox_w = u3qb_lent(blox);
   c3_w bit_widt_w = num_blox_w * bits;
   c3_w wor_widt_w = DIVCEIL(bit_widt_w, 32);
-
-  //
-  //  Allocate a proto-atom. This is u3a_slab without initialization.
-  //
-  c3_w* buf_w;
-  {
-    c3_w*     nov_w = u3a_walloc(wor_widt_w + c3_wiseof(u3a_atom));
-    u3a_atom* pug_u = (void *)nov_w;
-
-    pug_u->mug_w = 0;
-    pug_u->len_w = wor_widt_w;
-    buf_w        = pug_u->buf_w;
-  }
+  u3i_slab  sab_u;
+  u3i_slab_bare(&sab_u, 5, wor_widt_w);

   //
   //  Fill the atom buffer with bits from each block.
@@ -53,7 +42,7 @@
   //  cur_w  next buffer word to flush into.
   //
   {
-    c3_w acc_w=0, use_w=0, *cur_w=buf_w;
+    c3_w acc_w=0, use_w=0, *cur_w=sab_u.buf_w;

 #   define FLUSH() *cur_w++=acc_w; acc_w=use_w=0
 #   define SLICE(sz,off,val) TAKEBITS(sz, val) << off
@@ -98,7 +87,7 @@
     }
   }

-  return u3a_malt(buf_w);
+  return u3i_slab_mint(&sab_u);
 }

 u3_noun


xfreerdp: fix segfault

xfreerdp: fix segfault

codec contexts are now generated and freed within core/codecs.c

--- client/X11/xf_client.c
+++ client/X11/xf_client.c
@@ -863,16 +863,6 @@
 		xfc->srcBpp = settings->ColorDepth;
 		xf_gdi_register_update_callbacks(instance->update);
 		xfc->hdc = gdi_CreateDC(xfc->clrconv, xfc->bpp);
-
-		if (settings->RemoteFxCodec)
-		{
-			xfc->codecs->rfx = rfx_context_new(FALSE);
-		}
-
-		if (settings->NSCodec)
-		{
-			xfc->codecs->nsc = nsc_context_new();
-		}
 	}

 	xfc->originalWidth = settings->DesktopWidth;
@@ -1106,24 +1096,6 @@
 	{
 		rail_free(context->rail);
 		context->rail = NULL;
-	}
-
-	if (xfc->codecs->rfx)
-	{
-		rfx_context_free(xfc->codecs->rfx);
-		xfc->codecs->rfx = NULL;
-	}
-
-	if (xfc->codecs->nsc)
-	{
-		nsc_context_free(xfc->codecs->nsc);
-		xfc->codecs->nsc = NULL;
-	}
-
-	if (xfc->codecs->clear)
-	{
-		clear_context_free(xfc->codecs->clear);
-		xfc->codecs->clear = NULL;
 	}

 	if (xfc->clrconv)


fix indentation and comment

fix indentation and comment

--- ogl3-triangle-color.c
+++ ogl3-triangle-color.c
@@ -89,17 +89,17 @@

-	/* Draw the scene. These examples draw triangles, but OpenGL can
-	 * draw other simple shapes too. The images on this page should
-	 * help you understand the different options (note: you may see
-	 * some non-OpenGL images in the results too!):
-	 * https://www.google.com/search?q=opengl+primitive+types&tbm=isch
-	 */
-	kuhl_errorcheck();
-	glBindVertexArray(triangleVAO);
-	kuhl_errorcheck();
-	glDrawArrays(GL_TRIANGLES, 0, 3);
-	kuhl_errorcheck();
+		/* Draw the scene. These examples draw triangles, but OpenGL can
+		 * draw other simple shapes too. The images on this page should
+		 * help you understand the different options (note: you may see
+		 * some non-OpenGL images in the results too!):
+		 * https://www.google.com/search?q=opengl+primitive+types&tbm=isch
+		 */
+		kuhl_errorcheck();
+		glBindVertexArray(triangleVAO);
+		kuhl_errorcheck();
+		glDrawArrays(GL_TRIANGLES, 0, 3);
+		kuhl_errorcheck();
 	} // finish viewport loop
 	/* Check for errors. If there are errors, consider adding more
 	 * calls to kuhl_errorcheck() in your code. */
@@ -155,7 +155,7 @@
 	glBindBuffer(GL_ARRAY_BUFFER, cbuffer);
 	kuhl_errorcheck();

-	/* The texture coordinate data that we want to draw */
+	/* The color data that we want to draw */
 	GLfloat colorData[] = {1, 0, 0,
 	                       0, 1, 0,
 	                       0, 0, 1 };


Fix is_select_query() in EXPLAIN case. EXPLAIN without ANALYZE can be load balanced but actually it was not. Also add checking for the case EXPLAIN ANALYZE SELECT... If the SELECT uses writing functions, it should not be load balanced. Problem reported by Nicolas Amato: Subject: [pgpool-general: 625] exclude EXPLAIN from the pgpool.


Fix deStrnlen fall-back implementation am: 54ebe093a9
am: 7595269a79

Change-Id: Ia25c802d2e44c303f4a806f5d1a4192d57812def

--- framework/delibs/debase/deString.c
+++ framework/delibs/debase/deString.c
@@ -185,7 +185,7 @@
 	return strnlen_s(string, maxSize);
 #else
 	size_t len = 0;
-	while (len < maxSize || string[len] != 0)
+	while (len < maxSize && string[len] != 0)
 		++len;
 	return len;
 #endif