Restore cycle-usage optimization not in r22727, because that was prepared
before the code in trunk was optimized: the delta consumer already
calculates the MD5.

* subversion/libsvn_wc/adm_crawler.c
  (svn_wc_transmit_text_deltas2): Remove explicit MD5 calculation
   and use the result calculated by the delta stream.

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

--- subversion/libsvn_wc/adm_crawler.c
+++ subversion/libsvn_wc/adm_crawler.c
@@ -973,6 +973,8 @@
   if (basefile)
     SVN_ERR(svn_wc__close_text_base(basefile, path, 0, pool));

+  local_digest = svn_txdelta_md5_digest(txdelta_stream);
+
   if (digest)
     memcpy(digest, local_digest, APR_MD5_DIGESTSIZE);


usb: misc: Fix swapped properties in usb3503 DT parsing

The intn and connect GPIO properties are swapped in the code which will
cause failures at runtime if these are connected, fix the code.

There are currently no in-tree users of this device to check or update.

Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@linaro.org>
Acked-by: Olof Johansson <8c69ee23f3f44f8162a64d579c1fa25c2f55298a@lixom.net>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>


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

--- subversion/libsvn_wc/adm_crawler.c
+++ subversion/libsvn_wc/adm_crawler.c
@@ -206,13 +206,20 @@
                     svn_depth_t depth,
                     apr_pool_t *scratch_pool)
 {
+  apr_hash_t *props;
   const svn_string_t *val;

   SVN_ERR_ASSERT(external_func != NULL);

-  SVN_ERR(svn_wc__internal_propget(&val, db, local_abspath,
-                                   SVN_PROP_EXTERNALS,
-                                   scratch_pool, scratch_pool));
+  /* Directly use a DB api here as this code path is extensively used on
+     update. On top of that we already know that this an existing directory. */
+  SVN_ERR(svn_wc__db_read_props(&props, db, local_abspath,
+                                scratch_pool, scratch_pool));
+
+  if (!props)
+    return SVN_NO_ERROR;
+
+  val = apr_hash_get(props, SVN_PROP_EXTERNALS, APR_HASH_KEY_STRING);

   if (val)
     {


USB: visor: Match I330 phone more precisely

Samsung has just released a portable USB3 SSD, coming in a very small
and nice form factor. It's USB ID is 04e8:8001, which unfortunately is
already used by the Palm Visor driver for the Samsung I330 phone cradle.
Having pl2303 or visor pick up this device ID results in conflicts with
the usb-storage driver, which handles the newly released portable USB3
SSD.

To work around this conflict, I've dug up a mailing list post [1] from a
long time ago, in which a user posts the full USB descriptor
information. The most specific value in this appears to be the interface
class, which has value 255 (0xff). Since usb-storage requires an
interface class of 0x8, I believe it's correct to disambiguate the two
devices by matching on 0xff inside visor.

[1] http://permalink.gmane.org/gmane.linux.usb.user/4264

Signed-off-by: Jason A. Donenfeld <e7e312fea4c2c1aad2bb075d739111890e1ce08b@zx2c4.com>
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable <4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org>
Signed-off-by: Johan Hovold <759412786bc533369b22377bf83fb9056c5b25b2@kernel.org>


Related to issue #1520:  throw better mod_dav_svn error.

* mod_dav_svn/deadprops.c (save_value): use the error message text
  from the libsvn_repos error if possible, rather than a generic message.

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

--- subversion/mod_dav_svn/deadprops.c
+++ subversion/mod_dav_svn/deadprops.c
@@ -156,7 +156,8 @@
                                          propname, value, db->resource->pool);
   if (serr != NULL)
     return dav_svn_convert_err(serr, HTTP_INTERNAL_SERVER_ERROR,
-                               "could not change a property");
+                               serr->message ?
+                                serr->message : "could not change a property");

   /* a change to the props was made; make sure our cached copy is gone */
   db->props = NULL;


mod_dav_svn: Reject invalid transaction property change requests.

* subversion/mod_dav_svn/deadprops.c
  (change_txn_prop): New helper function that performs sanity checking.
  (save_value, db_remove): Use new helper.

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

--- subversion/mod_dav_svn/deadprops.c
+++ subversion/mod_dav_svn/deadprops.c
@@ -163,6 +163,23 @@
 }

+static svn_error_t *
+change_txn_prop(svn_fs_txn_t *txn,
+                const char *propname,
+                const svn_string_t *value,
+                apr_pool_t *scratch_pool)
+{
+  if (strcmp(propname, SVN_PROP_REVISION_AUTHOR) == 0)
+    return svn_error_create(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL,
+                            "Attempted to modify 'svn:author' property "
+                            "on a transaction");
+
+  SVN_ERR(svn_repos_fs_change_txn_prop(txn, propname, value, scratch_pool));
+
+  return SVN_NO_ERROR;
+}
+
+
 static dav_error *
 save_value(dav_db *db, const dav_prop_name *name,
            const svn_string_t *const *old_value_p,
@@ -213,9 +230,8 @@
     {
       if (resource->working)
         {
-          serr = svn_repos_fs_change_txn_prop(resource->info->root.txn,
-                                              propname, value,
-                                              subpool);
+          serr = change_txn_prop(resource->info->root.txn, propname,
+                                 value, subpool);
         }
       else
         {
@@ -254,8 +270,8 @@
     }
   else if (resource->info->restype == DAV_SVN_RESTYPE_TXN_COLLECTION)
     {
-      serr = svn_repos_fs_change_txn_prop(resource->info->root.txn,
-                                          propname, value, subpool);
+      serr = change_txn_prop(resource->info->root.txn, propname,
+                             value, subpool);
     }
   else
     {
@@ -560,8 +576,8 @@
   /* Working Baseline or Working (Version) Resource */
   if (db->resource->baselined)
     if (db->resource->working)
-      serr = svn_repos_fs_change_txn_prop(db->resource->info->root.txn,
-                                          propname, NULL, subpool);
+      serr = change_txn_prop(db->resource->info->root.txn, propname,
+                             NULL, subpool);
     else
       /* ### VIOLATING deltaV: you can't proppatch a baseline, it's
          not a working resource!  But this is how we currently


* subversion/mod_dav_svn/liveprops.c (dav_svn_insert_prop): Remove a   redundant conditional, it was responsible for a gcc warning.

--- subversion/mod_dav_svn/liveprops.c
+++ subversion/mod_dav_svn/liveprops.c
@@ -163,7 +163,7 @@
                expects, and rfc2518 demands it. */
             format = dav_svn_time_format_iso8601;
           }
-        else if (propid == DAV_PROPID_getlastmodified)
+        else /* propid == DAV_PROPID_getlastmodified */
           {
             format = dav_svn_time_format_rfc1123;
           }


No functional change.

No functional change.

* subversion/mod_dav_svn/liveprops.c
  (insert_prop_internal): Name a reused value.

--- subversion/mod_dav_svn/liveprops.c
+++ subversion/mod_dav_svn/liveprops.c
@@ -281,6 +281,7 @@
   const dav_liveprop_spec *info;
   int global_ns;
   svn_error_t *serr;
+  static const char *error_value = "###error###"; /* ### TODO proper errors */

   /*
   ** Almost none of the SVN provider properties are defined if the
@@ -385,7 +386,7 @@
                               resource->info->repos_path,
                               serr->message);
                 svn_error_clear(serr);
-                value = "###error###";
+                value = error_value;
                 break;
               }
           }
@@ -408,7 +409,7 @@
                           committed_rev,
                           serr->message);
             svn_error_clear(serr);
-            value = "###error###";
+            value = error_value;
             break;
           }

@@ -443,7 +444,7 @@
                           resource->info->repos_path,
                           serr->message);
             svn_error_clear(serr);
-            value = "###error###";
+            value = error_value;
             break;
           }

@@ -563,7 +564,7 @@
                                         scratch_pool),
                             serr->message);
               svn_error_clear(serr);
-              value = "###error###";
+              value = error_value;
               break;
             }
           s = dav_svn__build_uri(resource->info->repos,
@@ -642,7 +643,7 @@
                             resource->info->repos_path,
                             serr->message);
               svn_error_clear(serr);
-              value = "###error###";
+              value = error_value;
               break;
             }

@@ -690,7 +691,7 @@
                             resource->info->repos_path,
                             serr->message);
               svn_error_clear(serr);
-              value = "###error###";
+              value = error_value;
               break;
             }

@@ -718,7 +719,7 @@
                         svn_fs_path(resource->info->repos->fs, scratch_pool),
                         serr->message);
           svn_error_clear(serr);
-          value = "###error###";
+          value = error_value;
           break;
         }
       break;
@@ -743,7 +744,7 @@
                           resource->info->repos_path,
                           serr->message);
             svn_error_clear(serr);
-            value = "###error###";
+            value = error_value;
             break;
           }


debug

debug

--- Ymir/src/genesegment.h
+++ Ymir/src/genesegment.h
@@ -299,11 +299,13 @@
             _V.reset(new GeneSegmentAlphabet(other.V()));
             _J.reset(new GeneSegmentAlphabet(other.J()));

+            std::cout << "???" << std::endl;
             if (other._D) {
                 _D.reset(new GeneSegmentAlphabet(other.D()));
             } else {
                 _D.release();
             }
+            std::cout << "???" << std::endl;
         }


adding option for using blocking spi transfer

--- bsp/imxrt/libraries/drivers/drv_spi.c
+++ bsp/imxrt/libraries/drivers/drv_spi.c
@@ -347,7 +347,11 @@

     if(RT_FALSE == spi->dma_flag)
     {
+#ifdef(BSP_USING_BLOCKING_SPI)
+        status = LPSPI_MasterTransferBlocking(spi->base, &transfer);
+#else
         status = LPSPI_MasterTransferNonBlocking(spi->base, &spi->spi_normal, &transfer);
+#endif
     }
     else
     {


director: Fixed "doveadm director status user@domain" not to hang due to missing LF.

--- src/director/doveadm-connection.c
+++ src/director/doveadm-connection.c
@@ -510,7 +510,7 @@
 	host = mail_host_get_by_hash(conn->dir->orig_config_hosts,
 				     username_hash, tag);
 	if (host == NULL)
-		str_append(str, "\t");
+		str_append(str, "\t\n");
 	else
 		str_printfa(str, "\t%s\n", net_ip2addr(&host->ip));
 	o_stream_nsend(conn->output, str_data(str), str_len(str));


Revamp evp_generate_key_nif()

Revamp evp_generate_key_nif()

* Bug fix: Some EVP_PKEY_* calls return <= 0 on failure and 1 on success.

--- lib/crypto/c_src/evp.c
+++ lib/crypto/c_src/evp.c
@@ -106,38 +106,58 @@
     int type;
     EVP_PKEY_CTX *ctx = NULL;
     EVP_PKEY *pkey = NULL;
-    ERL_NIF_TERM ret_pub, ret_prv;
+    ERL_NIF_TERM ret_pub, ret_prv, ret;
     size_t key_len;
+    unsigned char *out_pub = NULL, *out_priv = NULL;

-    if (argv[0] == atom_x25519) type = EVP_PKEY_X25519;
-    else if (argv[0] == atom_x448) type = EVP_PKEY_X448;
-    else return enif_make_badarg(env);
+    if (argc != 1)
+        goto bad_arg;

-    if (!(ctx = EVP_PKEY_CTX_new_id(type, NULL))) return enif_make_badarg(env);
+    if (argv[0] == atom_x25519)
+        type = EVP_PKEY_X25519;
+    else if (argv[0] == atom_x448)
+        type = EVP_PKEY_X448;
+    else
+        goto bad_arg;

-    if (!EVP_PKEY_keygen_init(ctx)) goto return_error;
-    if (!EVP_PKEY_keygen(ctx, &pkey)) goto return_error;
+    if ((ctx = EVP_PKEY_CTX_new_id(type, NULL)) == NULL)
+        goto bad_arg;

-    if (!EVP_PKEY_get_raw_public_key(pkey, NULL, &key_len)) goto return_error;
-    if (!EVP_PKEY_get_raw_public_key(pkey,
-                                     enif_make_new_binary(env, key_len, &ret_pub),
-                                     &key_len))
-        goto return_error;
+    if (EVP_PKEY_keygen_init(ctx) != 1)
+        goto err;
+    if (EVP_PKEY_keygen(ctx, &pkey) != 1)
+        goto err;

-    if (!EVP_PKEY_get_raw_private_key(pkey, NULL, &key_len)) goto return_error;
-    if (!EVP_PKEY_get_raw_private_key(pkey,
-                                      enif_make_new_binary(env, key_len, &ret_prv),
-                                      &key_len))
-        goto return_error;
+    if (EVP_PKEY_get_raw_public_key(pkey, NULL, &key_len) != 1)
+        goto err;
+    if ((out_pub = enif_make_new_binary(env, key_len, &ret_pub)) == NULL)
+        goto err;
+    if (EVP_PKEY_get_raw_public_key(pkey, out_pub, &key_len) != 1)
+        goto err;

-    EVP_PKEY_free(pkey);
-    EVP_PKEY_CTX_free(ctx);
-    return enif_make_tuple2(env, ret_pub, ret_prv);
+    if (EVP_PKEY_get_raw_private_key(pkey, NULL, &key_len) != 1)
+        goto err;
+    if ((out_priv = enif_make_new_binary(env, key_len, &ret_prv)) == NULL)
+        goto err;
+    if (EVP_PKEY_get_raw_private_key(pkey, out_priv, &key_len) != 1)
+        goto err;

-return_error:
-    if (pkey) EVP_PKEY_free(pkey);
-    if (ctx)  EVP_PKEY_CTX_free(ctx);
-    return atom_error;
+    ret = enif_make_tuple2(env, ret_pub, ret_prv);
+    goto done;
+
+ bad_arg:
+    ret = enif_make_badarg(env);
+    goto done;
+
+ err:
+    ret = atom_error;
+
+ done:
+    if (pkey)
+        EVP_PKEY_free(pkey);
+    if (ctx)
+        EVP_PKEY_CTX_free(ctx);
+    return ret;

 #else
     return atom_notsup;


crypto: 3.0 API in rsa.c

crypto: 3.0 API in rsa.c

--- lib/crypto/c_src/rsa.c
+++ lib/crypto/c_src/rsa.c
@@ -21,15 +21,92 @@
 #include "rsa.h"
 #include "bn.h"

-//#define(CHK_RSA_3_0)
-
 static ERL_NIF_TERM rsa_generate_key(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
-#if !defined(HAS_3_0_API) || defined(CHK_RSA_3_0)
+#if !defined(HAS_3_0_API)
 static ERL_NIF_TERM put_rsa_private_key(ErlNifEnv* env, const RSA *rsa);
 #endif
 #if !defined(HAS_3_0_API)
 static int check_erlang_interrupt(int maj, int min, BN_GENCB *ctxt);
 #endif
+
+#define PUT1(env,bn,t) \
+    if (bn) {if ((t = bin_from_bn(env, bn)) == atom_error) goto err;}   \
+    else t = atom_undefined
+
+
+// ERL_NIF_TERM debug_put_pkey(ErlNifEnv* env, EVP_PKEY *pkey);
+// ERL_NIF_TERM debug_put_pkey(ErlNifEnv* env, EVP_PKEY *pkey)
+// {
+//     const BIGNUM *e1 = NULL, *n1 = NULL, *d1 = NULL;
+//     RSA *rsa = NULL;
+//     ERL_NIF_TERM result[3];
+//
+//     rsa = EVP_PKEY_get1_RSA(pkey);
+//     RSA_get0_key(rsa, &n1, &e1, &d1);
+//
+//     PUT1(env, e1, result[0]);  // Exponent E
+//     PUT1(env, n1, result[1]);  // Modulus N = p*q
+//     PUT1(env, d1, result[2]);
+//
+//     return enif_make_list_from_array(env,result,3);
+//
+//  err:
+//     return atom_error;
+// }
+
+
+#if !defined(HAS_3_0_API)
+/* Creates a term which can be parsed by get_rsa_private_key(). This is a list of plain integer binaries (not mpints). */
+static ERL_NIF_TERM put_rsa_private_key(ErlNifEnv* env, const RSA *rsa)
+{
+    ERL_NIF_TERM result[8];
+    const BIGNUM *n = NULL, *e = NULL, *d = NULL, *p = NULL, *q = NULL, *dmp1 = NULL, *dmq1 = NULL, *iqmp = NULL;
+
+    /* Return at least [E,N,D] */
+    RSA_get0_key(rsa, &n, &e, &d);
+
+    if ((result[0] = bin_from_bn(env, e)) == atom_error)  // Exponent E
+        goto err;
+    if ((result[1] = bin_from_bn(env, n)) == atom_error)  // Modulus N = p*q
+        goto err;
+    if ((result[2] = bin_from_bn(env, d)) == atom_error)  // Exponent D
+        goto err;
+
+    /* Check whether the optional additional parameters are available */
+    RSA_get0_factors(rsa, &p, &q);
+    RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp);
+
+    if (p && q && dmp1 && dmq1 && iqmp) {
+        if ((result[3] = bin_from_bn(env, p)) == atom_error)     // Factor p
+            goto err;
+        if ((result[4] = bin_from_bn(env, q)) == atom_error)     // Factor q
+            goto err;
+        if ((result[5] = bin_from_bn(env, dmp1)) == atom_error)  // D mod (p-1)
+            goto err;
+        if ((result[6] = bin_from_bn(env, dmq1)) == atom_error)  // D mod (q-1)
+            goto err;
+        if ((result[7] = bin_from_bn(env, iqmp)) == atom_error)  // (1/q) mod p
+            goto err;
+
+	return enif_make_list_from_array(env, result, 8);
+    } else {
+	return enif_make_list_from_array(env, result, 3);
+    }
+
+ err:
+    return enif_make_badarg(env);
+}
+
+static int check_erlang_interrupt(int maj, int min, BN_GENCB *ctxt)
+{
+    ErlNifEnv *env = BN_GENCB_get_arg(ctxt);
+
+    if (!enif_is_current_process_alive(env)) {
+	return 0;
+    } else {
+	return 1;
+    }
+}

 int get_rsa_private_key(ErlNifEnv* env, ERL_NIF_TERM key, EVP_PKEY **pkey)
 {
@@ -56,6 +133,7 @@
     if ((rsa = RSA_new()) == NULL)
         goto err;

+    *pkey = EVP_PKEY_new();
     if (!RSA_set0_key(rsa, n, e, d))
         goto err;
     /* rsa now owns n, e, and d */
@@ -135,6 +213,7 @@
     return 0;
 }

+
 int get_rsa_public_key(ErlNifEnv* env, ERL_NIF_TERM key, EVP_PKEY **pkey)
 {
     /* key=[E,N] */
@@ -162,9 +241,11 @@
     n = NULL;
     e = NULL;

+    *pkey = EVP_PKEY_new();
     if (EVP_PKEY_assign_RSA(*pkey, rsa) != 1)
         goto err;

+    // enif_fprintf(stderr, "pkey = %T\r\n", debug_put_pkey(env,*pkey));
     return 1;

  bad_arg:
@@ -177,63 +258,6 @@
         BN_free(n);

     return 0;
-}
-
-#if !defined(HAS_3_0_API) || defined(CHK_RSA_3_0)
-/* Creates a term which can be parsed by get_rsa_private_key(). This is a list of plain integer binaries (not mpints). */
-static ERL_NIF_TERM put_rsa_private_key(ErlNifEnv* env, const RSA *rsa)
-{
-    ERL_NIF_TERM result[8];
-    const BIGNUM *n = NULL, *e = NULL, *d = NULL, *p = NULL, *q = NULL, *dmp1 = NULL, *dmq1 = NULL, *iqmp = NULL;
-
-    /* Return at least [E,N,D] */
-    RSA_get0_key(rsa, &n, &e, &d);
-
-    if ((result[0] = bin_from_bn(env, e)) == atom_error)  // Exponent E
-        goto err;
-    if ((result[1] = bin_from_bn(env, n)) == atom_error)  // Modulus N = p*q
-        goto err;
-    if ((result[2] = bin_from_bn(env, d)) == atom_error)  // Exponent D
-        goto err;
-
-    /* Check whether the optional additional parameters are available */
-    RSA_get0_factors(rsa, &p, &q);
-    RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp);
-
-    if (p && q && dmp1 && dmq1 && iqmp) {
-        if ((result[3] = bin_from_bn(env, p)) == atom_error)     // Factor p
-            goto err;
-        if ((result[4] = bin_from_bn(env, q)) == atom_error)     // Factor q
-            goto err;
-        if ((result[5] = bin_from_bn(env, dmp1)) == atom_error)  // D mod (p-1)
-            goto err;
-        if ((result[6] = bin_from_bn(env, dmq1)) == atom_error)  // D mod (q-1)
-            goto err;
-        if ((result[7] = bin_from_bn(env, iqmp)) == atom_error)  // (1/q) mod p
-            goto err;
-
-	return enif_make_list_from_array(env, result, 8);
-    } else {
-	return enif_make_list_from_array(env, result, 3);
-    }
-
- err:
-    return enif_make_badarg(env);
-}
-#endif
-
-#if !defined(HAS_3_0_API)
-/* Legacy API deprecated from 3.0 is used */
-
-static int check_erlang_interrupt(int maj, int min, BN_GENCB *ctxt)
-{
-    ErlNifEnv *env = BN_GENCB_get_arg(ctxt);
-
-    if (!enif_is_current_process_alive(env)) {
-	return 0;
-    } else {
-	return 1;
-    }
 }

 static ERL_NIF_TERM rsa_generate_key(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
@@ -303,8 +327,126 @@
     return ret;
 }

+int rsa_privkey_to_pubkey(ErlNifEnv* env,  EVP_PKEY *pkey, ERL_NIF_TERM *ret)
+{
+    const BIGNUM *n = NULL, *e = NULL, *d = NULL;
+    ERL_NIF_TERM result[2];
+    RSA *rsa = NULL;
+
+    if ((rsa = EVP_PKEY_get1_RSA(pkey)) == NULL)
+        goto err;
+
+    RSA_get0_key(rsa, &n, &e, &d);
+
+    // Exponent E
+    if ((result[0] = bin_from_bn(env, e)) == atom_error)
+        goto err;
+    // Modulus N = p*q
+    if ((result[1] = bin_from_bn(env, n)) == atom_error)
+        goto err;
+
+    *ret = enif_make_list_from_array(env, result, 2);
+    RSA_free(rsa);
+    return 1;
+
+ err:
+    if (rsa)
+        RSA_free(rsa);
+    return 0;
+}
+
+
 #else
 /* New 3.0 API is used */
+
+int get_rsa_private_key(ErlNifEnv* env, ERL_NIF_TERM key, EVP_PKEY **pkey)
+{
+    /* key=[E,N,D]|[E,N,D,P1,P2,E1,E2,C] */
+    ERL_NIF_TERM head, tail;
+    OSSL_PARAM params[9];
+    EVP_PKEY_CTX *ctx = NULL;
+    int i = 0;
+
+    head = key;
+
+    if (!get_ossl_param_from_bin_in_list(env, "e", &head, &params[i++]) || // Exponent E
+        !get_ossl_param_from_bin_in_list(env, "n", &head, &params[i++]) ||  // N = p*q
+        !get_ossl_param_from_bin_in_list(env, "d", &head, &params[i++]))  // Exponent D
+        goto bad_arg;
+
+    tail = head;
+
+    if (!enif_is_empty_list(env, tail)) {
+        if (!get_ossl_param_from_bin_in_list(env, "rsa-factor1", &head, &params[i++]) || // p, Factor p
+            !get_ossl_param_from_bin_in_list(env, "rsa-factor2", &head, &params[i++]) || // q, Factor q
+            !get_ossl_param_from_bin_in_list(env, "rsa-exponent1", &head, &params[i++]) || // dmp1, D mod (p-1)
+            !get_ossl_param_from_bin_in_list(env, "rsa-exponent2", &head, &params[i++]) || // dmq1, D mod (q-1)
+            !get_ossl_param_from_bin_in_list(env, "rsa-coefficient1", &head, &params[i++]) ) // iqmp, (1/q) mod p
+            goto bad_arg;
+
+        tail = head;
+
+        if (!enif_is_empty_list(env, tail))
+            goto bad_arg;
+    }
+
+    params[i++] = OSSL_PARAM_construct_end();
+
+    if ((ctx = EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL)) == NULL)
+        goto err;
+    if (EVP_PKEY_fromdata_init(ctx) <= 0)
+        goto err;
+    if (EVP_PKEY_fromdata(ctx, pkey, EVP_PKEY_KEYPAIR, params) <= 0)
+        goto bad_arg;
+
+    if (ctx) EVP_PKEY_CTX_free(ctx);
+    return 1;
+
+ bad_arg:
+ err:
+    if (ctx) EVP_PKEY_CTX_free(ctx);
+    return 0;
+}
+
+
+int get_rsa_public_key(ErlNifEnv* env, ERL_NIF_TERM key, EVP_PKEY **pkey)
+{
+    ERL_NIF_TERM head, tail;
+    OSSL_PARAM params[3];
+    EVP_PKEY_CTX *ctx = NULL;
+
+    head = key;
+    if (!get_ossl_param_from_bin_in_list(env, "e", &head, &params[0]) )
+        goto bad_arg;
+
+    if (!get_ossl_param_from_bin_in_list(env, "n", &head, &params[1]) )
+        goto bad_arg;
+
+    tail = head;
+    if (!enif_is_empty_list(env, tail))
+        goto bad_arg;
+
+    params[2] = OSSL_PARAM_construct_end();
+
+    if ((ctx = EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL)) == NULL)
+        goto err;
+    if (EVP_PKEY_fromdata_init(ctx) <= 0)
+        goto err;
+    if (EVP_PKEY_fromdata(ctx, pkey, EVP_PKEY_PUBLIC_KEY, params) <= 0)
+        goto bad_arg;
+
+    /* enif_fprintf(stderr, "pkey = %T\r\nn = %T\r\n", */
+    /*              debug_put_pkey(env,*pkey), */
+    /*              enif_make_binary(env,&tmp) */
+    /*              ); */
+    if (ctx) EVP_PKEY_CTX_free(ctx);
+    return 1;
+
+ bad_arg:
+ err:
+    if (ctx) EVP_PKEY_CTX_free(ctx);
+    return 0;
+}

 static ERL_NIF_TERM rsa_generate_key(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
 {/* (ModulusSize, PublicExponent/binary, PublicExponent) */
@@ -378,56 +520,54 @@
             || ((result[7] = bin_from_bn(env, iqmp)) == atom_error)
             ) {
             ret = EXCP_ERROR(env, "Can't get RSA keys");
-            goto ret;
+            goto local_ret;
         }
-
         ret =  enif_make_list_from_array(env, result, 8);
-
-#ifdef CHK_RSA_3_0
-        {RSA *rsa = EVP_PKEY_get1_RSA(pkey);
-            if (!rsa)
-                ret = enif_make_tuple2(env, ret, atom_error);
-            else
-                ret = enif_make_tuple2(env, ret, put_rsa_private_key(env,rsa));
-        }
-#endif
+    local_ret:
+        if (e) BN_free(e);
+        if (n) BN_free(n);
+        if (d) BN_free(d);
+        if (p) BN_free(p);
+        if (q) BN_free(q);
+        if (dmp1) BN_free(dmp1);
+        if (dmq1) BN_free(dmq1);
+        if (iqmp) BN_free(iqmp);
     }

  ret:
+    if (pkey) EVP_PKEY_free(pkey);
     if (pctx) EVP_PKEY_CTX_free(pctx);
     return ret;
 }

-#endif /* #else-part of #if !defined(HAS_3_0_API) */
-
-
 int rsa_privkey_to_pubkey(ErlNifEnv* env,  EVP_PKEY *pkey, ERL_NIF_TERM *ret)
 {
-    const BIGNUM *n = NULL, *e = NULL, *d = NULL;
+    BIGNUM *e = NULL, *n = NULL;
     ERL_NIF_TERM result[2];
-    RSA *rsa = NULL;
-
-    if ((rsa = EVP_PKEY_get1_RSA(pkey)) == NULL)
-        goto err;
-
-    RSA_get0_key(rsa, &n, &e, &d);
-
-    // Exponent E
-    if ((result[0] = bin_from_bn(env, e)) == atom_error)
-        goto err;
-    // Modulus N = p*q
-    if ((result[1] = bin_from_bn(env, n)) == atom_error)
-        goto err;
-
-    *ret = enif_make_list_from_array(env, result, 2);
-    RSA_free(rsa);
+
+    /* https://www.openssl.org/docs/man3.0/man7/EVP_PKEY-RSA.html */
+    if (
+        !EVP_PKEY_get_bn_param(pkey, "e", &e)                       // Exponent E
+        || !EVP_PKEY_get_bn_param(pkey, "n", &n)                    // Modulus N = p*q
+        || ((result[0] = bin_from_bn(env, e)) == atom_error)
+        || ((result[1] = bin_from_bn(env, n)) == atom_error)
+        )
+        goto err;
+
+    *ret =  enif_make_list_from_array(env, result, 2);
+    if (e) BN_free(e);
+    if (n) BN_free(n);
     return 1;

  err:
-    if (rsa)
-        RSA_free(rsa);
+    if (e) BN_free(e);
+    if (n) BN_free(n);
     return 0;
-}
+
+}
+
+
+#endif /* #else-part of #if !defined(HAS_3_0_API)   (That is, end of defined(HAS_3_0_API)) */

 ERL_NIF_TERM rsa_generate_key_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])


Set addresses in auth_context if there aren't any

git-svn-id: 193148810cf65385f3a195dbc9a8b504846da3a2@2953 ec53bebd-3082-4978-b11e-865c3cabbd6b


libllbuild: fix definition of `LLBUILD_EXPORT`

The Windows build requires more careful handling of the exports macro.
WHen building the library as a static library, no dll storage should be
specified.  When building the library dynamic, DLL storage must be
applied.  This corrects the exported interfaces from the executable
(`llbuild`) exporting the interfaces for `libllbuild`.  Unix would
prevent the exporting of the symbols as `-rdynamic` is not the default.

--- products/libllbuild/include/llbuild/llbuild.h
+++ products/libllbuild/include/llbuild/llbuild.h
@@ -18,17 +18,24 @@
 #define LLBUILD_PUBLIC_LLBUILD_H

 #if defined(__cplusplus)
-#if defined(_WIN32)
-#define LLBUILD_EXPORT extern "C" __declspec(dllexport)
+#define LLBUILD_EXTERN extern "C"
 #else
-#define LLBUILD_EXPORT extern "C" __attribute__((visibility("default")))
+#define LLBUILD_EXTERN extern
 #endif
-#elif __GNUC__
-#define LLBUILD_EXPORT extern __attribute__((visibility("default")))
-#elif defined(_WIN32)
-#define LLBUILD_EXPORT extern __declspec(dllexport)
+
+#if defined(__ELF__) || (defined(__APPLE__) && defined(__MACH__))
+#define LLBUILD_EXPORT LLBUILD_EXTERN __attribute__((__visibility__("default")))
 #else
-#define LLBUILD_EXPORT extern
+// asume PE/COFF
+#if defined(_DLL)
+#if defined(libllbuild_EXPORTS)
+#define LLBUILD_EXPORT LLBUILD_EXTERN __declspec(dllexport)
+#else
+#define LLBUILD_EXPORT LLBUILD_EXTERN __declspec(dllimport)
+#endif
+#else
+#define LLBUILD_EXPORT LLBUILD_EXTERN
+#endif
 #endif

 #ifndef __has_attribute


Update prototype.h

Update prototype.h

--- algorithms/prototype.h
+++ algorithms/prototype.h
@@ -1,5 +1,7 @@
 #include <iostream>
 #include <string>
+
+void trimStr(std::string&);

 std::string ADD(std::string, std::string);
 std::string SUB(std::string, std::string);


HHD forgot to update/commit this

HHD forgot to update/commit this

--- PWG2/PWG2forward2LinkDef.h
+++ PWG2/PWG2forward2LinkDef.h
@@ -63,6 +63,11 @@
 #pragma link C++ class AliForwardMCCorrectionsTask+;
 #pragma link C++ class AliForwarddNdetaTask+;

+#pragma link C++ class AliCentralMultiplicityTask+;
+#pragma link C++ class AliAODCentralMult+;
+#pragma link C++ class AliCentralCorrSecondaryMap+;
+#pragma link C++ class AliCentralCorrAcceptance+;
+
 #else
 # error Not for compilation
 #endif


In TrendsAlgorithmModel.h delete commented out statements about ag15

--- BGCompass/TrendsAlgorithmModel.h
+++ BGCompass/TrendsAlgorithmModel.h
@@ -21,14 +21,12 @@
 + (id) sharedInstance;

 - (void) computeHA1c:(NSDate*) timeStamp;
-//- (void) calculateAg15:(BGReading*) reading;

 - (NSNumber*) ha1cArrayCount;
 - (NSNumber*) bgArrayCount;
-//- (NSNumber*) ag15ArrayCount;
+
 - (Ha1cReading*) getFromHa1cArray:(NSUInteger)index;
 - (BGReading*) getFromBGArray:(NSUInteger)index;
-//- (AG15Reading*) getFromAg15Array:(NSUInteger)index;

 //Just for demo purpose. Should not be public usually. Delete after.
 //- (void) correctTrendReadingsAfterDate:(NSDate*) lowerBound;


more exploration of possible interface for ciny test

--- CTestArena/CTestArenaTests/Modules/binary_tree_tests.c
+++ CTestArena/CTestArenaTests/Modules/binary_tree_tests.c
@@ -192,6 +192,10 @@
     // ct_teardown(function_ptr)
     // ct_fixture_teardown(f_ptr)
     // ct_run_suite(name:, array_of_f_ptr) use function name if no suite name defined?
+    // ct_make_suite(setup, array_of_f_ptr, teardown)
+    // ct_make_fixture(setup, suite, teardown)
+    // ct_run_suite(suite)
+    // ct_run_fixture(fixture)

     const UnitTest tests[] = {
         unit_test_setup_teardown(btcreate_CreatesEmptyTree, setup, teardown),


Minor eigen introp cleanup

Minor eigen introp cleanup

--- inc/osvr/Util/EigenInterop.h
+++ inc/osvr/Util/EigenInterop.h
@@ -273,21 +273,17 @@
 				BasePoseMap(BasePoseMap const&) = delete;
 				BasePoseMap(BasePoseMap && other) : m_pose(other.m_pose) {}
 #endif
-				typedef Eigen::Isometry3d TransformType;
-				typedef typename TransformType::MatrixType MatrixType;
+                typedef Eigen::Isometry3d TransformType;
+                typedef typename TransformType::MatrixType MatrixType;

                 /// Read-only accessor for the pose as an Eigen transform.
-                Eigen::Isometry3d transform() const {
-                    return fromPose(*m_pose);
-                }
+                TransformType transform() const { return fromPose(*m_pose); }
                 /// Read-only conversion operator for the pose as an Eigen
                 /// transform.
-                operator Eigen::Isometry3d() const { return transform(); }
-
-				/// Read-only accessor for the pose as an Eigen Matrix4d
-				Eigen::Matrix4d matrix() const {
-					return fromPose(*m_pose).matrix();
-				}
+                operator TransformType() const { return transform(); }
+
+                /// Read-only accessor for the pose as an Eigen Matrix
+                MatrixType matrix() const { return fromPose(*m_pose).matrix(); }

                 /// Read-only accessor for the translation as an Eigen vector
                 /// map.


Summary:Optimization of Mul routines
Reviewer: kkalyanj, pass

Additional reviewers:

Details:

git-svn-id: cdea853903caa9ee65c80dcf130ba33bcefa680f@34 f364fc6c-7e41-0410-b16c-eb8c68fe7df8

--- Framewave/domain/common/include/Arithmetic/Impl/MulImpl.h
+++ Framewave/domain/common/include/Arithmetic/Impl/MulImpl.h
@@ -590,9 +590,22 @@
 				template <int scaleType>
 				ISV Mul_8u_unit( const XMM128& src1, const XMM128& src2, XMM128& dst, const XMM128 *scaleMasks)
 				{
-						__m128i srcLo = src1.i, srcHi, tlo, thi, zero;
-
-						srcHi = CBL_SSE2::Multiply_8u_16s_Lo(srcLo, src2.i);
+						__m128i tlo, thi;
+
+                        __m128i srcLo, srcHi, src2Lo, src2Hi;
+
+						const __m128i zero =  _mm_setzero_si128();
+
+	                    srcHi   = _mm_unpackhi_epi8( src1.i, zero );
+	                    srcLo   = _mm_unpacklo_epi8( src1.i, zero );
+
+                        src2Hi  = _mm_unpackhi_epi8( src2.i, zero );
+	                    src2Lo  = _mm_unpacklo_epi8( src2.i, zero );
+
+                        srcLo	= _mm_mullo_epi16(srcLo, src2Lo);
+                        srcHi	= _mm_mullo_epi16(srcHi, src2Hi);
+
+

 						switch (scaleType)
 						{
@@ -603,8 +616,28 @@
 							srcLo	= _mm_xor_si128(_mm_srai_epi16(srcLo, 15), srcLo);
 							srcHi	= _mm_xor_si128(_mm_srai_epi16(srcHi, 15), srcHi);
 							break;
+
+                        case 1://;
+
+                            __m128i mask;
+                            mask	= _mm_and_si128(srcLo,  scaleMasks[2].i);		// 111 mask (for scale 2)
+		                    mask	= _mm_cmpgt_epi16(mask, scaleMasks[1].i);		// 010		(for scale 2)
+
+		                    srcLo	= _mm_srl_epi16(srcLo, scaleMasks[0].i);		// rsh by scale - 1
+		                    srcLo	= _mm_sub_epi16(srcLo, mask);				// i.e., if mask true, then +1
+
+		                    srcLo =	  _mm_srli_epi16(srcLo, 1);					// rsh one more to make total rsh by scale
+
+                            mask	= _mm_and_si128(srcHi,  scaleMasks[2].i);		// 111 mask (for scale 2)
+		                    mask	= _mm_cmpgt_epi16(mask, scaleMasks[1].i);		// 010		(for scale 2)
+
+		                    srcHi	= _mm_srl_epi16(srcHi, scaleMasks[0].i);		// rsh by scale - 1
+		                    srcHi	= _mm_sub_epi16(srcHi, mask);				// i.e., if mask true, then +1
+
+		                    srcHi =	  _mm_srli_epi16(srcHi, 1);					// rsh one more to make total rsh by scale
+                            break;
+
 						case -1:
-							zero	= _mm_setzero_si128();
 							tlo		= _mm_unpacklo_epi16(srcLo, zero);
 							thi		= _mm_unpackhi_epi16(srcLo, zero);

@@ -622,12 +655,14 @@
 							srcHi	= _mm_packs_epi32(tlo, thi);

 							break;
-						default:;
-							srcLo	= CBL_SSE2::Scale_16s<scaleType>(srcLo, (__m128i*) scaleMasks);
-							srcHi	= CBL_SSE2::Scale_16s<scaleType>(srcHi, (__m128i*) scaleMasks);
+
+
 						}
 						dst.i	= _mm_packus_epi16(srcLo, srcHi);
 				}
+
+
+

 				template <int scaleType>
@@ -1427,6 +1462,58 @@
 	}
 }

+template<class TSD, CH c, IsAlign ia>
+ISV Mul_8u_unit_PosScale_Custom(const TSD *s1, const TSD *s2, TSD *d, U32 &pixCount, int /*scale*/, const XMM128* scaleMasks)
+    {
+    TSD  *end	  = d + pixCount * ChannelCount(c);
+    XMM128 src1, src2;
+    const __m128i scaleMask0 = scaleMasks[0].i, scaleMask1 = scaleMasks[1].i, scaleMask2 = scaleMasks[2].i;
+
+    for( ; d < end; s1+=16, s2+=16, d+=16)
+        {
+            LoadStoreModules::LOAD<16, DT_SSE2, ia, STREAM_TRUE>(&src1, (const void*)s1);
+            LoadStoreModules::LOAD<16, DT_SSE2, ia, STREAM_TRUE>(&src2, (const void*)s2);
+
+            __m128i srcHi, &src2Lo = src2.i , src2Hi;
+            XMM128 &srcLo = src1;
+
+            srcHi   = _mm_unpackhi_epi8( srcLo.i, _mm_setzero_si128() );
+            srcLo.i   = _mm_unpacklo_epi8( srcLo.i, _mm_setzero_si128() );
+
+            src2Hi  = _mm_unpackhi_epi8( src2Lo, _mm_setzero_si128() );
+            src2Lo  = _mm_unpacklo_epi8( src2Lo, _mm_setzero_si128() );
+
+            srcLo.i	= _mm_mullo_epi16(srcLo.i, src2Lo);
+            srcHi	= _mm_mullo_epi16(srcHi, src2Hi);
+
+            __m128i mask;
+
+
+            mask	= _mm_and_si128(srcLo.i,  scaleMask2);		// 111 mask (for scale 2)
+            mask	= _mm_cmpgt_epi16(mask, scaleMask1);		// 010		(for scale 2)
+
+            srcLo.i	= _mm_srl_epi16(srcLo.i, scaleMask0);		// rsh by scale - 1
+            srcLo.i	= _mm_sub_epi16(srcLo.i, mask);				// i.e., if mask true, then +1
+
+            srcLo.i =	  _mm_srli_epi16(srcLo.i, 1);					// rsh one more to make total rsh by scale
+
+            mask	= _mm_and_si128(srcHi,  scaleMask2);		// 111 mask (for scale 2)
+            mask	= _mm_cmpgt_epi16(mask, scaleMask1);		// 010		(for scale 2)
+
+            srcHi	= _mm_srl_epi16(srcHi, scaleMask0);		// rsh by scale - 1
+            srcHi	= _mm_sub_epi16(srcHi, mask);				// i.e., if mask true, then +1
+
+            srcHi =	  _mm_srli_epi16(srcHi, 1);					// rsh one more to make total rsh by scale
+
+            srcLo.i	= _mm_packus_epi16(srcLo.i, srcHi);
+
+           //XMM128 &dst = srcLo;
+
+           LoadStoreModules::STORE<16, DT_SSE2, ia, STREAM_FLSE>(&srcLo, (void*)(d));
+        }
+    }
+
+
 } // namespace OPT_LEVEL


py/asmx64: Support use of top 8 regs in src_r64 argument.

Signed-off-by: Damien George <99e6b749acbfbe2a596df99e91d24d6e1fdbee00@micropython.org>

--- py/asmx64.c
+++ py/asmx64.c
@@ -285,31 +285,28 @@
 }

 void asm_x64_mov_mem8_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) {
-    assert(src_r64 < 8);
-    if (dest_r64 < 8) {
+    if (src_r64 < 8 && dest_r64 < 8) {
         asm_x64_write_byte_2(as, 0x0f, OPCODE_MOVZX_RM8_TO_R64);
     } else {
-        asm_x64_write_byte_3(as, REX_PREFIX | REX_R, 0x0f, OPCODE_MOVZX_RM8_TO_R64);
+        asm_x64_write_byte_3(as, REX_PREFIX | REX_R_FROM_R64(dest_r64) | REX_B_FROM_R64(src_r64), 0x0f, OPCODE_MOVZX_RM8_TO_R64);
     }
     asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp);
 }

 void asm_x64_mov_mem16_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) {
-    assert(src_r64 < 8);
-    if (dest_r64 < 8) {
+    if (src_r64 < 8 && dest_r64 < 8) {
         asm_x64_write_byte_2(as, 0x0f, OPCODE_MOVZX_RM16_TO_R64);
     } else {
-        asm_x64_write_byte_3(as, REX_PREFIX | REX_R, 0x0f, OPCODE_MOVZX_RM16_TO_R64);
+        asm_x64_write_byte_3(as, REX_PREFIX | REX_R_FROM_R64(dest_r64) | REX_B_FROM_R64(src_r64), 0x0f, OPCODE_MOVZX_RM16_TO_R64);
     }
     asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp);
 }

 void asm_x64_mov_mem32_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) {
-    assert(src_r64 < 8);
-    if (dest_r64 < 8) {
+    if (src_r64 < 8 && dest_r64 < 8) {
         asm_x64_write_byte_1(as, OPCODE_MOV_RM64_TO_R64);
     } else {
-        asm_x64_write_byte_2(as, REX_PREFIX | REX_R, OPCODE_MOV_RM64_TO_R64);
+        asm_x64_write_byte_2(as, REX_PREFIX | REX_R_FROM_R64(dest_r64) | REX_B_FROM_R64(src_r64), OPCODE_MOV_RM64_TO_R64);
     }
     asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp);
 }


fix big-endian packing to 8 bytes

fix big-endian packing to 8 bytes

--- py/binary.c
+++ py/binary.c
@@ -302,8 +302,14 @@
                 val = mp_obj_get_int(val_in);
                 // zero/sign extend if needed
                 if (BYTES_PER_WORD < 8 && size > sizeof(val)) {
-                    int c = (is_signed(val_type) && (mp_int_t)val < 0) ? 0xff : 0x00;
-                    memset(p + sizeof(val), c, size - sizeof(val));
+                    if (struct_type == '>') {
+                        int c = (is_signed(val_type) && (mp_int_t)val < 0) ? 0xff : 0x00;
+                        memset(p, c, size - sizeof(val));
+                        p += size - sizeof(val);
+                    } else {
+                        int c = (is_signed(val_type) && (mp_int_t)val < 0) ? 0xff : 0x00;
+                        memset(p + sizeof(val), c, size - sizeof(val));
+                    }
                 }
             }
     }


py/objstr: More faithful and optimal implementation of empty format spec.

The old code translated "{}" into "{!s}". It was thus implemented by
allocating auxiliary vstr, printing an object into it, then printing
aux vstr into the main vstr. This is unnecessary though, as an object
can be printed directly into the main vstr. This is especially true as
it's not allowed to specify arbitrary formatting features (field width,
etc.) when printing arbitrary objects, e.g. following is not allowed:

"{:.2}".format([1, 2])

(Unlike modulo operator, where "%.2s" % [1, 2] produces "[1").

--- py/objstr.c
+++ py/objstr.c
@@ -1095,9 +1095,7 @@
             arg = args[(*arg_i) + 1];
             (*arg_i)++;
         }
-        if (!format_spec && !conversion) {
-            conversion = 's';
-        }
+
         if (conversion) {
             mp_print_kind_t print_kind;
             if (conversion == 's') {
@@ -1120,7 +1118,16 @@
         char type = '\0';
         int flags = 0;

-        if (format_spec) {
+        if (!format_spec) {
+            // https://docs.python.org/3/library/functions.html#format
+            // "The default format_spec is an empty string which usually
+            // gives the same effect as calling str(value)."
+            // https://docs.python.org/3/reference/datamodel.html#object.__format__
+            // "object.__format__(x, '') is now equivalent to str(x) rather
+            // than format(str(self), '')."
+            mp_obj_print_helper(&print, arg, PRINT_STR);
+            continue;
+        } else {
             // The format specifier (from http://docs.python.org/2/library/string.html#formatspec)
             //
             // [[fill]align][sign][#][0][width][,][.precision][type]


Switch arg check back to allow ignored args for strings

--- py/objstr.c
+++ py/objstr.c
@@ -212,10 +212,6 @@
         return mp_const_empty_bytes;
     }

-    if (n_args > 1) {
-        goto wrong_args;
-    }
-
     if (MP_OBJ_IS_STR(args[0])) {
         if (n_args < 2 || n_args > 3) {
             goto wrong_args;
@@ -240,6 +236,10 @@
         vstr_init_len(&vstr, len);
         memset(vstr.buf, 0, len);
         return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
+    }
+
+    if (n_args > 1) {
+        goto wrong_args;
     }

     // check if __bytes__ exists, and if so delegate to it


Do not assume that vstr buf is the same after it was extended.

--- py/stream.c
+++ py/stream.c
@@ -88,6 +88,7 @@
         }
     }
     vstr_set_size(vstr, total_size + 1); // TODO: for \0
+    buf = vstr_str(vstr);
     buf[total_size] = 0;
     return mp_obj_new_str(qstr_from_str_take(buf, total_size + 1));
 }


fix SYMBOL_DOWN

fix SYMBOL_DOWN

--- lv_objx/lv_ddlist.c
+++ lv_objx/lv_ddlist.c
@@ -580,7 +580,7 @@
 				new_style.text.opa = sel_style->text.opa;
 				lv_area_t area_arrow;
 				area_arrow.x2 = ddlist->coords.x2 - style->body.padding.hor;
-				area_arrow.x1 = area_arrow.x2 - lv_txt_get_width(strlen(SYMBOL_DOWN), 1, sel_style->text.font, 0, 0);
+				area_arrow.x1 = area_arrow.x2 - lv_txt_get_width(SYMBOL_DOWN, (strlen(SYMBOL_DOWN), sel_style->text.font, 0, 0);

 				area_arrow.y1 = ddlist->coords.y1 + style->text.line_space;
 				area_arrow.y2 = area_arrow.y1 + font_h;


JStringRef: ensure string is null terminated so c_str() works correctly.

--- wpiutil/include/support/jni_util.h
+++ wpiutil/include/support/jni_util.h
@@ -115,6 +115,9 @@
       llvm::errs() << "JStringRef was passed a null pointer at \n"
                    << GetJavaStackTrace(env);
     }
+    // Ensure str is null-terminated.
+    m_str.push_back('\0');
+    m_str.pop_back();
   }

   operator llvm::StringRef() const { return m_str; }


bug fix

bug fix


no message

no message

git-svn-id: cf55bc44fb097054a32fc70455a459c940dbbffc@6354 c9849af7-e679-4ec6-a44e-fc146a885bd3

--- algorithms/fastQP.h
+++ algorithms/fastQP.h
@@ -3,7 +3,7 @@
 #define __FAST_QP__
 #include <Eigen/Dense>
 #include <vector>
-
+#include <set>

 // todo: template this
 template <typename tA, typename tB, typename tC, typename tD, typename tE, typename tF, typename tG>


Style

Style

--- lib/facil/core/facil.c
+++ lib/facil/core/facil.c
@@ -428,9 +428,9 @@
 }

 static void listener_on_data(intptr_t uuid, protocol_s *plistener) {
-  intptr_t new_client;
   for (int i = 0; i < 4; ++i) {
-    if ((new_client = sock_accept(uuid)) == -1) {
+    intptr_t new_client = sock_accept(uuid);
+    if (new_client == -1) {
       if (errno == EWOULDBLOCK || errno == EAGAIN || errno == ECONNABORTED ||
           errno == ECONNRESET)
         return;
@@ -1752,7 +1752,7 @@
           "      Avoid this message by setting threads / workers manually.\n"
           "      To increase auto-detection limit, recompile with:\n"
           "             -DFACIL_CPU_CORES_LIMIT=%zu \n",
-          cpu_count, (size_t)FACIL_CPU_CORES_LIMIT, cpu_count);
+          (size_t)cpu_count, (size_t)FACIL_CPU_CORES_LIMIT, cpu_count);
       cpu_count = FACIL_CPU_CORES_LIMIT;
     }
 #endif


Delay the disposal of stream state until RST_STREAM is being sent.
Doing so prevents `h2o_req_t` (and therefore generators being
attached to the request object) while the generator is invoking the
`proceed_req` callback.

Separately, the scheduler is disactivated so that DATA frames would
not be sent after the RST_STREAM frame.

--- lib/http2/connection.c
+++ lib/http2/connection.c
@@ -738,7 +738,12 @@
     if (send_state == H2O_SEND_STATE_ERROR) {
         finish_body_streaming(stream);
         if (conn->state < H2O_HTTP2_CONN_STATE_IS_CLOSING) {
+            /* Send error and close. State disposal is delayed so as to avoid freeing `req` within this function, which might
+             * trigger the destruction of the generator being the caller. */
             stream_send_error(conn, stream->stream_id, H2O_HTTP2_ERROR_STREAM_CLOSED);
+            h2o_http2_scheduler_deactivate(&stream->_scheduler);
+            if (!h2o_linklist_is_linked(&stream->_link))
+                h2o_linklist_insert(&conn->_write.streams_to_proceed, &stream->_link);
             h2o_http2_stream_reset(conn, stream);
         }
         return;


Return the correct environment name for 64-bit platforms in the _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS case.

--- lib/libc/gen/confstr.c
+++ lib/libc/gen/confstr.c
@@ -105,8 +105,9 @@
 		goto docopy;

 	case _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS:
+		/* XXX - should have more complete coverage */
 		if (sizeof(long) * CHAR_BIT >= 64)
-			p = "_POSIX_V6_LPBIG_OFFBIG";
+			p = "_POSIX_V6_LP64_OFF64";
 		else
 			p = "_POSIX_V6_ILP32_OFFBIG";
 		goto docopy;


Revert to old ttyname_r behavior that when _ioctl() returns 0 (SUCCEEDED),
return the buffer immediately.  This will permit ssh and/or PAM logins
broken by previous commit.

The (potential) underlying problem is still under investigation.

Point hat to:	me

--- lib/libc/gen/ttyname.c
+++ lib/libc/gen/ttyname.c
@@ -83,7 +83,7 @@
 	fgn.len = len - strlen(buf);
 	fgn.buf = buf + strlen(buf);
 	if (!_ioctl(fd, FIODGNAME, &fgn))
-		return (EINVAL);
+		return (0);
 	devname_r(sb.st_rdev, S_IFCHR,
 	    buf + strlen(buf), sizeof(buf) - strlen(buf));
 	return (0);


Import NetBSD readline.c,v 1.104: do not crash with add_history(NULL).

MFC after:	3 days
Approved by:	re (gjb)

--- lib/libedit/readline.c
+++ lib/libedit/readline.c
@@ -1363,6 +1363,9 @@
 	TYPE(HistEvent) ev;
 	const Char *wline;

+	if (line == NULL)
+		return 0;
+
 	if (h == NULL || e == NULL)
 		rl_initialize();


Remove use of alloca in liblustreapi_hsm.c

--- lib/liblustreapi_hsm.c
+++ lib/liblustreapi_hsm.c
@@ -579,7 +579,6 @@
 {
 	int				rc;
 	int				msg_len;
-	char				*msg = NULL;
 	va_list				args2;
 	struct llapi_json_item_list	*json_items;

@@ -609,11 +608,7 @@
 	msg_len = vsnprintf(NULL, 0, fmt, args2) + 1;
 	va_end(args2);
 	if (msg_len >= 0) {
-		msg = (char *) alloca(msg_len);
-		if (msg == NULL) {
-			rc = -ENOMEM;
-			goto err;
-		}
+		char msg[msg_len];

 		rc = vsnprintf(msg, msg_len, fmt, args);
 		if (rc < 0)


director has been a vmod for a while

director has been a vmod for a while

Also remove OBE comment.

--- lib/libvcc/vcc_parse.c
+++ lib/libvcc/vcc_parse.c
@@ -272,18 +272,6 @@
  */

 static void
-vcc_ParseDirector(struct vcc *tl)
-{
-	VSB_printf(tl->sb, "\ndirectors are now in directors VMOD.\n");
-	vcc_ErrWhere(tl, tl->t);
-}
-
-/*--------------------------------------------------------------------
- * TODO when bumping the vcl version:
- * #1603 remove return(fetch) from vcl_hit{}
- */
-
-static void
 vcc_ParseVcl(struct vcc *tl)
 {
 	struct token *tok;
@@ -324,7 +312,6 @@
 	{ "acl",		vcc_ParseAcl },
 	{ "sub",		vcc_ParseFunction },
 	{ "backend",		vcc_ParseBackend },
-	{ "director",		vcc_ParseDirector },
 	{ "probe",		vcc_ParseProbe },
 	{ "import",		vcc_ParseImport },
 	{ "vcl",		vcc_ParseVcl },


locking-selftests: Handle unexpected failures more strictly

When CONFIG_PROVE_LOCKING is not enabled, more tests are
expected to pass unexpectedly, but there no tests that should
start to fail that pass with CONFIG_PROVE_LOCKING enabled.

Signed-off-by: Maarten Lankhorst <743c2818a341d71b99ed2b566f9f80c2fc288f93@canonical.com>
Acked-by: Peter Zijlstra <645ca7d3a8d3d4f60557176cd361ea8351edc32b@chello.nl>
Cc: e29a046d56d20477d35c94c7163db1056870c39f@lists.freedesktop.org
Cc: 9e2c36873478ce209476a03c76518463b9fc904b@lists.linaro.org
Cc: 43232e92d70cc7aa53504ad0397085ee47bad87f@goodmis.org
Cc: 3d0f3b9ddcacec30c4008c5e030e6c13a478cb4f@ffwll.ch
Cc: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>
Cc: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Cc: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>
Link: 47546b6f36a72f5f7a2325d86623032de7cccf80@patser
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@kernel.org>

--- lib/locking-selftest.c
+++ lib/locking-selftest.c
@@ -976,16 +976,18 @@
 	/*
 	 * Filter out expected failures:
 	 */
-	if (debug_locks != expected) {
 #ifndef CONFIG_PROVE_LOCKING
+	if (expected == FAILURE && debug_locks) {
 		expected_testcase_failures++;
 		printk("failed|");
-#else
+	}
+	else
+#endif
+	if (debug_locks != expected) {
 		unexpected_testcase_failures++;
 		printk("FAILED|");

 		dump_stack();
-#endif
 	} else {
 		testcase_successes++;
 		printk("  ok  |");


^$^%&$%^$^ Alt key timeout on PPC....

git-svn-id: 03f0f1727258f1959b7b485b30a676bafdb78148@1821 0101bb08-14d6-0310-b084-bc0e0c8e3800


[GFS2] Unlock page on prepare_write try lock failure

When the try lock of the glock failed in prepare_write we were
incorrectly exiting this function with the page still locked.
This was resulting in further I/O to this page hanging.

Signed-off-by: Steven Whitehouse <9801c4ef11586b619a1c43ac9377eea2aee672dd@redhat.com>

--- fs/gfs2/ops_address.c
+++ fs/gfs2/ops_address.c
@@ -360,8 +360,10 @@
 	gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME|LM_FLAG_TRY_1CB, &ip->i_gh);
 	error = gfs2_glock_nq_atime(&ip->i_gh);
 	if (unlikely(error)) {
-		if (error == GLR_TRYFAILED)
+		if (error == GLR_TRYFAILED) {
+			unlock_page(page);
 			error = AOP_TRUNCATED_PAGE;
+		}
 		goto out_uninit;
 	}


[PATCH] fix rescan_partitions to return errors properly

The only error code which comes from the partition checkers is -1, when
they finds an EIO.  As per the discussion, ENOMEM values were ignored,
as they might scare the users.

So, with the current code, we end up returning -1 and not EIO for the
ioctl() calls.  Which doesn't give any clue to the user of what went
wrong.

Signed-off-by: Suzuki K P <2d5cd350c7a48263c670a6374c5c55bca8d1a68a@in.ibm.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- fs/partitions/check.c
+++ fs/partitions/check.c
@@ -541,7 +541,7 @@
 	if (!get_capacity(disk) || !(state = check_partition(disk, bdev)))
 		return 0;
 	if (IS_ERR(state))	/* I/O error reading the partition table */
-		return PTR_ERR(state);
+		return -EIO;
 	for (p = 1; p < state->limit; p++) {
 		sector_t size = state->parts[p].size;
 		sector_t from = state->parts[p].from;


PUD: introduce positionValid

PUD: introduce positionValid

Signed-off-by: Ferry Huberts <1f083df4a0371a8eba2ce71fc6b0e214b2551710@mindef.nl>

--- lib/pud/src/receiver.c
+++ lib/pud/src/receiver.c
@@ -102,20 +102,31 @@
  * Functions
  */

+/**
+ Determine whether s position is valid.
+
+ @param position
+ a pointer to a position
+
+ @return
+ - true when valid
+ - false otherwise
+ */
+static bool positionValid(PositionUpdateEntry * position){
+	return (nmeaInfoHasField(position->nmeaInfo.smask, FIX)
+			&& (position->nmeaInfo.fix != NMEA_FIX_BAD));
+}
+
 /** Send the transmit buffer out over all OLSR interfaces, called as a timer
  * callback and also immediately on an external state change */
 static void txToAllOlsrInterfaces(void) {
 	unsigned char txBuffer[TX_BUFFER_SIZE_FOR_OLSR];
 	unsigned int aligned_size = 0;
-	bool invalid = false;

 	(void) pthread_mutex_lock(&transmitGpsInformation.mutex);

-	invalid = (transmitGpsInformation.txPosition.nmeaInfo.fix == NMEA_FIX_BAD);
-
-	if (!transmitGpsInformation.updated && !invalid) {
-		/* fix the timestamp when the transmitGpsInformation was not updated
-		 * while it is valid */
+	if (!transmitGpsInformation.updated
+			&& positionValid(&transmitGpsInformation.txPosition)) {
 		struct timeb tp;
 		struct tm nowStruct;

@@ -197,7 +208,7 @@
 	 */

 	/*
-	 * Fix
+	 * Valid
 	 *
 	 * avg  last  movingNow
 	 *  0     0   UNKNOWN
@@ -206,21 +217,19 @@
 	 *  1     1   determine via other parameters
 	 */

-	/* when avg has no valid fix then can't determine whether we're moving */
-	if (!(nmeaInfoHasField(posAvgEntry->nmeaInfo.smask, FIX)
-			&& (posAvgEntry->nmeaInfo.fix != NMEA_FIX_BAD))) {
+	/* when avg is not valid then can't determine whether we're moving */
+	if (!positionValid(posAvgEntry)) {
 		return UNKNOWN;
 	}

-	/* avg has a valid fix here */
-
-	/* when lastTx has no valid fix, then we are moving */
-	if (!(nmeaInfoHasField(lastTxEntry->nmeaInfo.smask, FIX)
-			&& (lastTxEntry->nmeaInfo.fix != NMEA_FIX_BAD))) {
+	/* avg is valid here */
+
+	/* when lastTx is not valid, then we are moving */
+	if (!positionValid(lastTxEntry)) {
 		return SET;
 	}

-	/* both avg and lastTx have a valid fix here */
+	/* both avg and lastTx are valid here */

 	/*
 	 * Speed
@@ -592,18 +601,18 @@
 	 * Update transmitGpsInformation
 	 */

-	(void) pthread_mutex_lock(&transmitGpsInformation.mutex);
-
 	updateTransmitGpsInformation = externalStateChange
-			|| (state.externalState == MOVING);
+			|| (state.externalState == MOVING)
+			|| (positionValid(posAvgEntry) && !positionValid(&txPosition));

 	if (updateTransmitGpsInformation) {
 		memcpy(&txPosition.nmeaInfo, &posAvgEntry->nmeaInfo, sizeof(nmeaINFO));
+		(void) pthread_mutex_lock(&transmitGpsInformation.mutex);
 		memcpy(&transmitGpsInformation.txPosition.nmeaInfo,
 				&posAvgEntry->nmeaInfo, sizeof(nmeaINFO));
 		transmitGpsInformation.updated = true;
-	}
-	(void) pthread_mutex_unlock(&transmitGpsInformation.mutex);
+		(void) pthread_mutex_unlock(&transmitGpsInformation.mutex);
+	}

 #if defined(PUD_DUMP_AVERAGING)
 	dump_nmeaInfo(&transmitGpsInformation.txPosition.nmeaInfo,


xfs: lock the AIL before removing the buffer item

Regression introduced by commit 46f9d2e ("xfs: aborted buf items can
be in the AIL") which fails to lock the AIL before removing the
item. Spinlock debugging throws a warning about this.

Signed-off-by: Dave Chinner <4d9e23a041ac966f5316a7481300d4ae12e806fe@redhat.com>
Reviewed-by: Mark Tinguely <f35e083611655abff224a5492605bc52368a36d2@sgi.com>
Signed-off-by: Ben Myers <46e490cac450e85a9cba3059365826296771cc03@sgi.com>


Debug

Debug

--- snapshot.c
+++ snapshot.c
@@ -241,18 +241,18 @@

 STATUS purge_entry(char *key, entry *entry_head, snapshot *snapshot_head)
 {
-	STATUS del_command_status = del_command(command, entry_head);
-	if(del_command_status != OK && del_command_status != NO_KEY)
-	{
-		return del_command_status;
+	STATUS del_status = delete_entry_by_key(key, entry_head);
+	if(del_status != OK && del_status != NO_KEY)
+	{
+		return del_status;
 	}
 	snapshot *snapshot_cursor = snapshot_head->next;
 	while(snapshot_cursor)
 	{
-		del_command_status = delete_entry_by_key(key, snapshot_cursor->entries);
-		if(del_command_status != OK && del_command_status != NO_KEY)
-		{
-			return del_command_status;
+		del_status = delete_entry_by_key(key, snapshot_cursor->entries);
+		if(del_status != OK && del_status != NO_KEY)
+		{
+			return del_status;
 		}
 		snapshot_cursor = snapshot_cursor->next;
 	}


Debug

Debug

--- snapshot.c
+++ snapshot.c
@@ -4,7 +4,7 @@
 #include <ctype.h>
 #include "snapshot.h"

-#define TESTING 0
+#define TESTING 1
 #if TESTING
 #define DEBUG(str)(printf("%s", str))
 #else


Fix shim include paths after reorg two commits ago

--- lib/src/backend_shim.c
+++ lib/src/backend_shim.c
@@ -38,7 +38,7 @@
 #include <warpcore/warpcore.h>

 #if defined(HAVE_SENDMMSG) || defined(HAVE_RECVMMSG)
-// IWYU pragma: no_include "config.h"
+// IWYU pragma: no_include "warpcore/config.h"
 #include <limits.h>
 #include <sys/param.h>
 #endif
@@ -46,7 +46,6 @@
 #include "backend.h"
 #include "ip.h"
 #include "udp.h"
-#include "warpcore/config.h"

 /// The backend name.


locking/static_keys: Make verify_keys() static

Signed-off-by: Fengguang Wu <24f7fe9d205c8a9f6ade0c2894e14303ca16087f@intel.com>
Cc: Jason Baron <af9bd1db766a43cb09b647251c97dbddcd2e59dc@akamai.com>
Cc: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>
Cc: Peter Zijlstra (Intel) <3fddac958924aef220f202ca567388ddab3f14a8@infradead.org>
Cc: Peter Zijlstra <3fddac958924aef220f202ca567388ddab3f14a8@infradead.org>
Cc: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>
Link: f7a2a2a03a9536552fafbc8d6e1cc2e03fd8fdea@lkp-ib04
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@kernel.org>

--- lib/test_static_keys.c
+++ lib/test_static_keys.c
@@ -70,7 +70,7 @@
 	}
 }

-int verify_keys(struct test_key *keys, int size, bool invert)
+static int verify_keys(struct test_key *keys, int size, bool invert)
 {
 	int i;
 	bool ret, init;


Allow resetting existing entries in arch_locator_set()

--- libarchivist/locator.c
+++ libarchivist/locator.c
@@ -79,23 +79,27 @@
 bool arch_locator_set(arch_locator_t *locator, arch_uuid_t uuid, arch_size_t offset)
 {
   arch_size_t index = (arch_hash_uuid(uuid) & ARCH_HASH_MASK(locator->size));
-  if(!ARCH_UUID_IS_NIL(locator->slots[index].uuid)) {
-    while(locator->slots[index].next) {
-      index = locator->slots[index].next;
+  if(!arch_uuid_eq(locator->slots[index].uuid, uuid)) {
+    if(!ARCH_UUID_IS_NIL(locator->slots[index].uuid)) {
+      while(locator->slots[index].next) {
+	index = locator->slots[index].next;
+      }
+      arch_size_t collision_index = 0;
+      while(!ARCH_UUID_IS_NIL(locator->slots[collision_index].uuid) && (collision_index < locator->size)) {
+	collision_index++;
+      }
+      if(collision_index == locator->size) {
+	return false;
+      } else {
+	locator->slots[index].next = collision_index;
+	index = collision_index;
+      }
     }
-    arch_size_t collision_index = 0;
-    while(!ARCH_UUID_IS_NIL(locator->slots[collision_index].uuid) && (collision_index < locator->size)) {
-      collision_index++;
-    }
-    if(collision_index == locator->size) {
-      return false;
-    } else {
-      locator->slots[index].next = collision_index;
-      index = collision_index;
-    }
+    locator->entries++;
+    locator->slots[index].next = 0;
   }
-  locator->slots[index] = (arch_locator_bucket_t){ uuid, offset, 0 };
-  locator->entries++;
+  locator->slots[index].uuid = uuid;
+  locator->slots[index].offset = offset;

   return true;
 }


minor optimization

minor optimization

git-svn-id: a4d7c1866f8397a4106e0b57fc4fbf792bbdaaaf@3386 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

--- libavcodec/mpegvideo.c
+++ libavcodec/mpegvideo.c
@@ -3484,15 +3484,15 @@
     s->block_index[5]= s->mb_stride*(s->mb_y + s->mb_height + 2) + s->b8_stride*s->mb_height*2 + s->mb_x - 1;
     //block_index is not used by mpeg2, so it is not affected by chroma_format

-    s->dest[0] = s->current_picture.data[0] + (s->mb_x - 1)*16;
-    s->dest[1] = s->current_picture.data[1] + (s->mb_x - 1)*(16 >> s->chroma_x_shift);
-    s->dest[2] = s->current_picture.data[2] + (s->mb_x - 1)*(16 >> s->chroma_x_shift);
-
+    s->dest[0] = s->current_picture.data[0] + ((s->mb_x - 1) << 4);
+    s->dest[1] = s->current_picture.data[1] + ((s->mb_x - 1) << (4 - s->chroma_x_shift));
+    s->dest[2] = s->current_picture.data[2] + ((s->mb_x - 1) << (4 - s->chroma_x_shift));
+
     if(!(s->pict_type==B_TYPE && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME))
     {
-        s->dest[0] += s->mb_y *   linesize * 16;
-        s->dest[1] += s->mb_y * uvlinesize * (16 >> s->chroma_y_shift);
-        s->dest[2] += s->mb_y * uvlinesize * (16 >> s->chroma_y_shift);
+        s->dest[0] += s->mb_y *   linesize << 4;
+        s->dest[1] += s->mb_y * uvlinesize << (4 - s->chroma_y_shift);
+        s->dest[2] += s->mb_y * uvlinesize << (4 - s->chroma_y_shift);
     }
 }


utent.c: go back to use static __X() functions without size increase

__X() {...} and strong_alias(__X,X) keeps size the same as X() {...}

Signed-off-by: Peter S. Mazinger <1f4071d9f342c1637b13af9bc258f2ff72e96758@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <ce1ac9e9ad16abccd7821f371ad381197b4768ac@gmail.com>

--- libc/misc/utmp/utent.c
+++ libc/misc/utmp/utent.c
@@ -24,27 +24,14 @@
 #include <bits/uClibc_mutex.h>
 __UCLIBC_MUTEX_STATIC(utmplock, PTHREAD_MUTEX_INITIALIZER);

-
-/* Do not create extra unlocked functions if no locking is needed */
-#if defined __UCLIBC_HAS_THREADS__
-# define static_if_threaded static
-#else
-# define static_if_threaded /* nothing */
-# define __setutent setutent
-# define __getutent getutent
-# define __getutid getutid
-#endif
-
-
 /* Some global crap */
 static int static_fd = -1;
 static struct utmp static_utmp;
 static const char default_file_name[] = _PATH_UTMP;
 static const char *static_ut_name = default_file_name;

-
 /* This function must be called with the LOCK held */
-static_if_threaded void __setutent(void)
+static void __setutent(void)
 {
     if (static_fd < 0) {
 	static_fd = open_not_cancel_2(static_ut_name, O_RDWR | O_CLOEXEC);
@@ -69,11 +56,13 @@
     __setutent();
     __UCLIBC_MUTEX_UNLOCK(utmplock);
 }
+#else
+strong_alias(__setutent,setutent)
 #endif
 libc_hidden_def(setutent)

 /* This function must be called with the LOCK held */
-static_if_threaded struct utmp *__getutent(void)
+static struct utmp *__getutent(void)
 {
     if (static_fd < 0) {
 	__setutent();
@@ -98,10 +87,12 @@
     __UCLIBC_MUTEX_UNLOCK(utmplock);
     return ret;
 }
+#else
+strong_alias(__getutent,getutent)
 #endif
 libc_hidden_def(getutent)

-void endutent(void)
+static void __endutent(void)
 {
     __UCLIBC_MUTEX_LOCK(utmplock);
     if (static_fd >= 0)
@@ -109,10 +100,11 @@
     static_fd = -1;
     __UCLIBC_MUTEX_UNLOCK(utmplock);
 }
+strong_alias(__endutent,endutent)
 libc_hidden_def(endutent)

 /* This function must be called with the LOCK held */
-static_if_threaded struct utmp *__getutid(const struct utmp *utmp_entry)
+static struct utmp *__getutid(const struct utmp *utmp_entry)
 {
     struct utmp *lutmp;
     unsigned type;
@@ -145,10 +137,12 @@
     __UCLIBC_MUTEX_UNLOCK(utmplock);
     return ret;
 }
+#else
+strong_alias(__getutid,getutid)
 #endif
 libc_hidden_def(getutid)

-struct utmp *getutline(const struct utmp *utmp_entry)
+static struct utmp *__getutline(const struct utmp *utmp_entry)
 {
     struct utmp *lutmp;

@@ -163,9 +157,10 @@
     __UCLIBC_MUTEX_UNLOCK(utmplock);
     return lutmp;
 }
+strong_alias(__getutline,getutline)
 libc_hidden_def(getutline)

-struct utmp *pututline(const struct utmp *utmp_entry)
+static struct utmp *__pututline(const struct utmp *utmp_entry)
 {
     __UCLIBC_MUTEX_LOCK(utmplock);
     /* Ignore the return value.  That way, if they've already positioned
@@ -182,9 +177,10 @@
     __UCLIBC_MUTEX_UNLOCK(utmplock);
     return (struct utmp *)utmp_entry;
 }
+strong_alias(__pututline,pututline)
 libc_hidden_def(pututline)

-int utmpname(const char *new_ut_name)
+static int __utmpname(const char *new_ut_name)
 {
     __UCLIBC_MUTEX_LOCK(utmplock);
     if (new_ut_name != NULL) {
@@ -205,4 +201,5 @@
     __UCLIBC_MUTEX_UNLOCK(utmplock);
     return 0; /* or maybe return -(static_ut_name != new_ut_name)? */
 }
+strong_alias(__utmpname,utmpname)
 libc_hidden_def(utmpname)


utent.c: fix a few bugs, and shrink a bit

bug #1:
    static_fd = -1;
    close(static_fd);
DOH!

bug #2:
    if (utmp_fd == -1) {
        __setutent();
    }
    if (utmp_fd == -1) {
        return NULL;
    }
if utmp_fd == -1, we call _setutent().
if __setutent() opens a fd, utmp_fd (a parameter)
wouldn't change, the second check is bogus.
We need to use static_fd instead in second check.
Which makes clear that having utmp_fd parameter
is wrong. See the patch for a complete fix.

Shrink comes from simplifying fcntl(static_fd, F_SETFD, FD_CLOEXEC):

    text           data     bss     dec     hex filename
-    661              8     384    1053     41d libc/misc/utmp/utent.o
+    604              8     384     996     3e4 libc/misc/utmp/utent.o

Signed-off-by: Denys Vlasenko <42afb3a19136e88700e8b77002ea6a5a94c16782@googlemail.com>

--- libc/misc/utmp/utent.c
+++ libc/misc/utmp/utent.c
@@ -20,55 +20,43 @@
 #include <string.h>
 #include <utmp.h>

-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strdup) */
-/* Experimentally off - libc_hidden_proto(strncmp) */
-/* libc_hidden_proto(read) */
-/* libc_hidden_proto(write) */
-/* libc_hidden_proto(open) */
-/* libc_hidden_proto(fcntl) */
-/* libc_hidden_proto(close) */
-/* libc_hidden_proto(lseek) */
-
 #include <bits/uClibc_mutex.h>
 __UCLIBC_MUTEX_STATIC(utmplock, PTHREAD_MUTEX_INITIALIZER);
-

 /* Some global crap */
 static int static_fd = -1;
 static struct utmp static_utmp;
 static const char default_file_name[] = _PATH_UTMP;
-static const char *static_ut_name = (const char *) default_file_name;
+static const char *static_ut_name = default_file_name;

 /* This function must be called with the LOCK held */
 static void __setutent(void)
 {
-    int ret;
-
-    if (static_fd == -1) {
-	if ((static_fd = open(static_ut_name, O_RDWR)) < 0) {
-	    if ((static_fd = open(static_ut_name, O_RDONLY)) < 0) {
-		goto bummer;
+    if (static_fd < 0) {
+	static_fd = open(static_ut_name, O_RDWR);
+	if (static_fd < 0) {
+	    static_fd = open(static_ut_name, O_RDONLY);
+	    if (static_fd < 0) {
+		return; /* static_fd remains < 0 */
 	    }
 	}
 	/* Make sure the file will be closed on exec()  */
-	ret = fcntl(static_fd, F_GETFD, 0);
-	if (ret >= 0) {
-	    ret = fcntl(static_fd, F_SETFD, ret | FD_CLOEXEC);
-	}
-	if (ret < 0) {
-bummer:
-	    static_fd = -1;
-	    close(static_fd);
-	    return;
-	}
+	fcntl(static_fd, F_SETFD, FD_CLOEXEC);
+	// thus far, {G,S}ETFD only has this single flag,
+	// and setting it never fails.
+	//int ret = fcntl(static_fd, F_GETFD, 0);
+	//if (ret >= 0) {
+	//    ret = fcntl(static_fd, F_SETFD, ret | FD_CLOEXEC);
+	//}
+	//if (ret < 0) {
+	//    static_fd = -1;
+	//}
+	return;
     }
     lseek(static_fd, 0, SEEK_SET);
-    return;
 }

-/* libc_hidden_proto(setutent) */
 void setutent(void)
 {
     __UCLIBC_MUTEX_LOCK(utmplock);
@@ -78,19 +66,18 @@
 libc_hidden_def(setutent)

 /* This function must be called with the LOCK held */
-static struct utmp *__getutent(int utmp_fd)
+static struct utmp *__getutent(void)
 {
     struct utmp *ret = NULL;

-    if (utmp_fd == -1) {
+    if (static_fd < 0) {
 	__setutent();
-    }
-    if (utmp_fd == -1) {
-	return NULL;
+	if (static_fd < 0) {
+	    return NULL;
+	}
     }

-    if (read(utmp_fd, (char *) &static_utmp, sizeof(struct utmp)) == sizeof(struct utmp))
-    {
+    if (read(static_fd, &static_utmp, sizeof(static_utmp)) == sizeof(static_utmp)) {
 	ret = &static_utmp;
     }

@@ -100,7 +87,7 @@
 void endutent(void)
 {
     __UCLIBC_MUTEX_LOCK(utmplock);
-    if (static_fd != -1)
+    if (static_fd >= 0)
 	close(static_fd);
     static_fd = -1;
     __UCLIBC_MUTEX_UNLOCK(utmplock);
@@ -111,7 +98,7 @@
     struct utmp *ret = NULL;

     __UCLIBC_MUTEX_LOCK(utmplock);
-    ret = __getutent(static_fd);
+    ret = __getutent();
     __UCLIBC_MUTEX_UNLOCK(utmplock);
     return ret;
 }
@@ -121,7 +108,7 @@
 {
     struct utmp *lutmp;

-    while ((lutmp = __getutent(static_fd)) != NULL) {
+    while ((lutmp = __getutent()) != NULL) {
 		if (	(utmp_entry->ut_type == RUN_LVL ||
 				 utmp_entry->ut_type == BOOT_TIME ||
 				 utmp_entry->ut_type == NEW_TIME ||
@@ -143,7 +130,6 @@
     return NULL;
 }

-/* libc_hidden_proto(getutid) */
 struct utmp *getutid(const struct utmp *utmp_entry)
 {
     struct utmp *ret = NULL;
@@ -160,7 +146,7 @@
     struct utmp *lutmp = NULL;

     __UCLIBC_MUTEX_LOCK(utmplock);
-    while ((lutmp = __getutent(static_fd)) != NULL) {
+    while ((lutmp = __getutent()) != NULL) {
 	if ((lutmp->ut_type == USER_PROCESS || lutmp->ut_type == LOGIN_PROCESS) &&
 		!strcmp(lutmp->ut_line, utmp_entry->ut_line)) {
 	    break;
@@ -170,7 +156,7 @@
     return lutmp;
 }

-struct utmp *pututline (const struct utmp *utmp_entry)
+struct utmp *pututline(const struct utmp *utmp_entry)
 {
     __UCLIBC_MUTEX_LOCK(utmplock);
     /* Ignore the return value.  That way, if they've already positioned
@@ -188,7 +174,7 @@
     return (struct utmp *)utmp_entry;
 }

-int utmpname (const char *new_ut_name)
+int utmpname(const char *new_ut_name)
 {
     __UCLIBC_MUTEX_LOCK(utmplock);
     if (new_ut_name != NULL) {
@@ -202,9 +188,10 @@
 	}
     }

-    if (static_fd != -1)
+    if (static_fd >= 0) {
 	close(static_fd);
-    static_fd = -1;
+	static_fd = -1;
+    }
     __UCLIBC_MUTEX_UNLOCK(utmplock);
-    return 0;
+    return 0; /* or maybe return -(static_ut_name != new_ut_name)? */
 }


Extended test for backup.c

Extended test for backup.c

--- test/backup.c
+++ test/backup.c
@@ -118,6 +118,26 @@
   return count;
 }

+/** Counts the items in the specified directory, excluding "." and "..".
+
+  @param path The path to a valid directory.
+
+  @return The amount of files in the specified directory.
+*/
+static size_t countFilesInDir(const char *path)
+{
+  size_t counter = 0;
+  DIR *dir = sOpenDir(path);
+
+  while(sReadDir(dir, path) != NULL)
+  {
+    counter++;
+  }
+
+  sCloseDir(dir, path);
+  return counter;
+}
+
 /** Simplified wrapper around mustHaveRegular(). It extracts additional
   informations via stat() and passes them to mustHaveRegular().

@@ -158,16 +178,16 @@
                     stats.st_mtime, stats.st_mode);
 }

-int main(void)
-{
-  testGroupStart("discovering new files");
-  String cwd = getCwd();
-  size_t cwd_depth = countPathElements(cwd);
-
-  Metadata *metadata = metadataNew();
-  SearchNode *root_node = searchTreeLoad("generated-config-files/backup-search-test.txt");
-  initiateBackup(metadata, root_node);
-
+/** Checks a metadata tree containing files found using
+  "generated-config-files/backup-search-test.txt".
+
+  @param metadata A valid metadata tree.
+  @param cwd The path to the current working directory.
+  @param cwd_depth The amount of elements in the given cwd.
+*/
+static void checkBackupSearchData(Metadata *metadata, String cwd,
+                                  size_t cwd_depth)
+{
   checkMetadata(metadata, 0, false);
   assert_true(metadata->current_backup.ref_count == cwd_depth + 10);
   assert_true(metadata->backup_history_length == 0);
@@ -206,5 +226,22 @@

   PathNode *three_txt = findSubnode(bar, "3.txt", BPOL_track, 1, 0);
   mustHaveRegularStat(three_txt, &metadata->current_backup, NULL, 0);
+}
+
+int main(void)
+{
+  testGroupStart("discovering new files");
+  String cwd = getCwd();
+  size_t cwd_depth = countPathElements(cwd);
+
+  Metadata *metadata = metadataNew();
+  SearchNode *root_node = searchTreeLoad("generated-config-files/backup-search-test.txt");
+
+  initiateBackup(metadata, root_node);
+  checkBackupSearchData(metadata, cwd, cwd_depth);
+  finishBackup(metadata, "tmp", "tmp/tmp-file");
+  checkBackupSearchData(metadata, cwd, cwd_depth);
+  assert_true(countFilesInDir("tmp/") == 0);
+
   testGroupEnd();
 }


Add a FIXME and fix a capability declaration.

--- modules/codec/ffmpeg/imgresample.c
+++ modules/codec/ffmpeg/imgresample.c
@@ -45,13 +45,13 @@

     /* crop/padd submodule */
     add_submodule();
-    set_capability( "crop padd", 10 );
+    set_capability( "crop padd", 10 ); /* FIXME / Remove */
     set_callbacks( OpenCropPadd, CloseFilter );
     set_description( N_("FFmpeg crop padd filter") );

     /* chroma conversion submodule */
     add_submodule();
-    set_capability( "chroma", 50 );
+    set_capability( "video filter2", 50 );
     set_callbacks( OpenChroma, CloseChroma );
     set_description( N_("FFmpeg chroma conversion") );
 vlc_module_end();


dbus: fix volume setting (fix #9628)

dbus: fix volume setting (fix #9628)

--- modules/control/dbus/dbus_player.c
+++ modules/control/dbus/dbus_player.c
@@ -179,10 +179,7 @@
     if( VLC_SUCCESS != DemarshalSetPropertyValue( p_from, &d_dbus_vol ) )
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

-    d_dbus_vol *= AOUT_VOLUME_DEFAULT;
-    if( d_dbus_vol < 0. )
-        d_dbus_vol = 0.;
-    playlist_VolumeSet( PL, d_dbus_vol );
+    playlist_VolumeSet( PL, fmaxf( d_dbus_vol, 0.f ) );

     REPLY_SEND;
 }


Update comment on placeholder and text input color keys

--- ApptentiveConnect/source/Apptentive.h
+++ ApptentiveConnect/source/Apptentive.h
@@ -640,10 +640,10 @@
 /// The background color for table- and collection views.
 extern NSString *const ApptentiveColorCollectionBackground;

-/// The background color for text input fields. Changing this may render placeholder invisible.
+/// The background color for text input fields.
 extern NSString *const ApptentiveColorTextInputBackground;

-/// The background color for text input fields. Changing this may render placeholder invisible.
+/// The color for text input placeholder text.
 extern NSString *const ApptentiveColorTextInputPlaceholder;

 /// The background color for message cells in Message Center.


Fix a wrong comment on (hopefully) right code.

MFC after:	3 days


Move language tag parser into the block so it only gets invoked on index 0.

--- uip/mhparse.c
+++ uip/mhparse.c
@@ -3358,7 +3358,8 @@
 	     */
 	    if (index == 0) {
 	    	vp = dp;
-		while (*vp != '\'' && !isspace((unsigned char) *vp))
+		while (*vp != '\'' && !isspace((unsigned char) *vp) &&
+							*vp != '\0')
 		    vp++;
 		if (*vp == '\'') {
 		    if (vp != dp) {
@@ -3377,30 +3378,31 @@
 		    free(nameptr);
 		    return NOTOK;
 		}
-	    }
-
-	    vp = (dp = vp);
-	    while (*vp != '\'' && !isspace((unsigned char) *vp))
-		vp++;
-
-	    if (*vp == '\'') {
-		if (vp != dp) {
-		    len = vp - dp;
-		    lang = mh_xmalloc(len + 1);
-		    strncpy(lang, dp, len);
-		    lang[len] = '\0';
+		dp = vp;
+
+		while (*vp != '\'' && !isspace((unsigned char) *vp) &&
+							*vp != '\0')
+		    vp++;
+
+		if (*vp == '\'') {
+		    if (vp != dp) {
+			len = vp - dp;
+			lang = mh_xmalloc(len + 1);
+			strncpy(lang, dp, len);
+			lang[len] = '\0';
+		    } else {
+			lang = NULL;
+		    }
+		    vp++;
 		} else {
-		    lang = NULL;
+		    advise(NULL, "missing language tag in message %s's %s: "
+			   "field\n%*s(parameter %s)", filename, fieldname,
+			   strlen(invo_name) + 2, "", nameptr);
+		    free(nameptr);
+		    if (charset)
+			free(charset);
+		    return NOTOK;
 		}
-		vp++;
-	    } else {
-		advise(NULL, "missing language tag in message %s's %s: "
-		       "field\n%*s(parameter %s)", filename, fieldname,
-		       strlen(invo_name) + 2, "", nameptr);
-		free(nameptr);
-		if (charset)
-		     free(charset);
-		return NOTOK;
 	    }

 	    /*


app/testpmd: fix port id allocation

app/testpmd: fix port id allocation

In the feature of increasing port_id range from 8 bits to 16 bits,
vlan port_id allocation function was forget to substitute UINT8 with
UINT16, so the vlan port_id was allocated as a inccrete number.

Fixes: 28caa76aea71 ("app/testpmd: fix port id type")
Cc: stable@dpdk.org

Signed-off-by: Yanglong Wu <fcfcf244e78343d0fd57dab4546690065eab06ec@intel.com>
Reviewed-by: Zhiyong Yang <fbdb847fac8e5e50b588eb93d9ff9fd811b7568c@intel.com>
Acked-by: Wenzhuo Lu <58cb9036bdff9a5412edc3b9f70e105ccf59954f@intel.com>

--- app/test-pmd/cmdline.c
+++ app/test-pmd/cmdline.c
@@ -3352,7 +3352,7 @@
 			      tp_id, UINT16);
 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
-			      port_id, UINT8);
+			      port_id, UINT16);

 cmdline_parse_inst_t cmd_vlan_tpid = {
 	.f = cmd_vlan_tpid_parsed,


GUI Layout change some types to avoid some warnings

--- include/GUI/Control/Layout.h
+++ include/GUI/Control/Layout.h
@@ -67,13 +67,13 @@
    Align       vert_align{Align::TOP};  //!< Vertical alignment mode for children

 public:
-   unsigned getX() const { return pos.x; }
-   unsigned getY() const { return pos.y; }
+   signed getX() const { return pos.x; }
+   signed getY() const { return pos.y; }

-   unsigned getWidth() const { return size.x; }
-   unsigned getHeight() const { return size.y; }
+   signed getWidth() const { return size.x; }
+   signed getHeight() const { return size.y; }

-   bool isHit(unsigned x_, unsigned y_) const
+   bool isHit(signed x_, signed y_) const
    {
       return (x_ >= pos.x) && (x_ < (pos.x + size.x)) && (y_ >= pos.y) && (y_ < (pos.y + size.y));
    }


replicate: attempt re-open of files before performing openfd selfheal

in cases where subvolume state gets swapped between open and write
opening file on the remaining subvolumes is necessary before attempting
a self-heal. previously files were opened after self heal.

Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>

BUG: 918 (AFR write fails when subvolumes' state is swapped)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=918

--- xlators/cluster/afr/src/afr-open.c
+++ xlators/cluster/afr/src/afr-open.c
@@ -359,6 +359,51 @@
 }

+static int
+afr_prepare_loc (call_frame_t *frame, fd_t *fd)
+{
+        afr_local_t    *local = NULL;
+        char           *name = NULL;
+        char           *path = NULL;
+        int             ret = 0;
+
+        if (!fd)
+                return -1;
+
+        local = frame->local;
+        ret = inode_path (fd->inode, NULL, (char **)&path);
+        if (ret == -1)
+                return -1;
+
+        if (local->loc.path) {
+                if (strcmp (path, local->loc.path))
+                        gf_log (frame->this->name, GF_LOG_DEBUG,
+                                "overwriting old loc->path %s with %s",
+                                local->loc.path, path);
+                GF_FREE ((char *)local->loc.path);
+        }
+        local->loc.path = path;
+
+        name = strrchr (local->loc.path, '/');
+        if (name)
+                name++;
+        local->loc.name = name;
+
+        if (local->loc.inode) {
+                inode_unref (local->loc.inode);
+        }
+        local->loc.inode = inode_ref (fd->inode);
+
+        if (local->loc.parent) {
+                inode_unref (local->loc.parent);
+        }
+
+        local->loc.parent = inode_parent (local->loc.inode, 0, NULL);
+
+        return 0;
+}
+
+
 int
 afr_openfd_sh (call_frame_t *frame, xlator_t *this)
 {
@@ -369,10 +414,7 @@
         local = frame->local;
         sh    = &local->self_heal;

-        inode_path (local->fd->inode, NULL, (char **)&local->loc.path);
-        local->loc.name   = strrchr (local->loc.path, '/');
-        local->loc.inode  = inode_ref (local->fd->inode);
-        local->loc.parent = inode_parent (local->fd->inode, 0, NULL);
+        afr_prepare_loc (frame, local->fd);

         /* forcibly trigger missing-entries self-heal */

@@ -440,8 +482,9 @@
 }

-int
-afr_openfd_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
+
+int
+afr_openfd_xaction (call_frame_t *frame, xlator_t *this, fd_t *fd)
 {
 	afr_local_t   * local = NULL;

@@ -453,8 +496,6 @@

         local->op = GF_FOP_FLUSH;

-        local->fd = fd_ref (fd);
-
         local->transaction.fop          = afr_openfd_sh;
         local->transaction.done         = afr_openfd_flush_done;

@@ -471,3 +512,131 @@
 	return 0;
 }

+
+
+int
+afr_openfd_xaction_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+                             int32_t op_ret, int32_t op_errno, fd_t *fd)
+{
+        afr_internal_lock_t *int_lock = NULL;
+        afr_local_t         *local    = NULL;
+        afr_private_t       *priv     = NULL;
+
+        int ret = 0;
+
+        uint64_t      ctx = 0;
+        afr_fd_ctx_t *fd_ctx = NULL;
+
+        int call_count  = 0;
+        int child_index = (long) cookie;
+
+        priv     = this->private;
+        local    = frame->local;
+        int_lock = &local->internal_lock;
+
+        LOCK (&frame->lock);
+        {
+                if (op_ret >= 0) {
+                        ret = fd_ctx_get (fd, this, &ctx);
+
+                        if (ret < 0) {
+                                goto out;
+                        }
+
+                        fd_ctx = (afr_fd_ctx_t *)(long) ctx;
+
+                        fd_ctx->opened_on[child_index] = 1;
+
+                        gf_log (this->name, GF_LOG_TRACE,
+                                "fd for %s opened successfully on subvolume %s",
+                                local->loc.path, priv->children[child_index]->name);
+                }
+        }
+out:
+        UNLOCK (&frame->lock);
+
+        call_count = afr_frame_return (frame);
+
+        if (call_count == 0) {
+                afr_openfd_xaction (frame, this, local->fd);
+        }
+
+        return 0;
+}
+
+
+int
+afr_openfd_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
+{
+        afr_local_t *local  = NULL;
+        afr_private_t *priv = NULL;
+
+        uint64_t      ctx;
+        afr_fd_ctx_t *fd_ctx;
+
+        int no_open = 0;
+        int ret = 0;
+        int i;
+        int call_count = 0;
+
+        priv  = this->private;
+        local = frame->local;
+
+        /*
+         * Some subvolumes might have come up on which we never
+         * opened this fd in the first place. Re-open fd's on those
+         * subvolumes now.
+         */
+
+        local->fd = fd_ref (fd);
+
+        ret = fd_ctx_get (fd, this, &ctx);
+
+        if (ret < 0) {
+                no_open = 1;
+                goto out;
+        }
+
+        fd_ctx = (afr_fd_ctx_t *)(long) ctx;
+
+        LOCK (&local->fd->lock);
+        {
+                call_count = __unopened_count (priv->child_count,
+                                               fd_ctx->opened_on,
+                                               local->child_up);
+        }
+        UNLOCK (&local->fd->lock);
+
+        if (call_count == 0) {
+                no_open = 1;
+                goto out;
+        }
+
+        afr_prepare_loc (frame, fd);
+
+        local->call_count = call_count;
+
+        for (i = 0; i < priv->child_count; i++) {
+                if (!fd_ctx->opened_on[i] && local->child_up[i]) {
+                        gf_log (this->name, GF_LOG_TRACE,
+                                "opening fd for %s on subvolume %s",
+                                local->loc.path, priv->children[i]->name);
+
+                        STACK_WIND_COOKIE (frame, afr_openfd_xaction_open_cbk,
+                                           (void *)(long) i,
+                                           priv->children[i],
+                                           priv->children[i]->fops->open,
+                                           &local->loc, fd_ctx->flags, fd,
+                                           fd_ctx->wbflags);
+
+                        if (!--call_count)
+                                break;
+                }
+        }
+
+out:
+        if (no_open)
+                afr_openfd_xaction (frame, this, fd);
+
+        return 0;
+}


Change Skeleton default

Change Skeleton default

--- magick/morphology.c
+++ magick/morphology.c
@@ -883,7 +883,7 @@
 %         Type 1: Tradional Skeleton kernel (4 connected skeleton)
 %         Type 2: HIPR2 Skeleton kernel (8 connected skeleton)
 %         Type 3: Thinning skeleton based on a ressearch paper by
-%                 Dan S. Bloomberg
+%                 Dan S. Bloomberg (Default Type)
 %    ThinSE:type
 %       A huge variety of Thinning Kernels designed to preserve conectivity.
 %       many other kernel sets use these kernels as source definitions.
@@ -1981,7 +1981,6 @@
         {
           switch ( (int) args->rho ) {
             case 1:
-            default:
               /* Traditional Skeleton...
               ** A cyclically rotated single kernel
               */
@@ -2006,6 +2005,7 @@
               ExpandRotateKernelInfo(kernel, 90.0); /* 4 rotations of the 2 kernels */
               break;
             case 3:
+            default:
               /* Dan Bloomberg Skeleton, from his paper on 3x3 thinning SE's
               ** "Connectivity-Preserving Morphological Image Thransformations"
               ** by Dan S. Bloomberg, available on Leptonica, Selected Papers,


CMSIS-Core(A): Removed duplicate RESERVED members.

--- CMSIS/Core_A/Include/core_ca.h
+++ CMSIS/Core_A/Include/core_ca.h
@@ -543,8 +543,8 @@
     uint32_t WnR:1;                      /*!< \brief bit:    11  Write not Read bit */
     uint32_t ExT:1;                      /*!< \brief bit:    12  External abort type */
     uint32_t CM:1;                       /*!< \brief bit:    13  Cache maintenance fault */
-    RESERVED(1:18, uint32_t)
-  } l                                    /*!< \brief Structure used for bit  access in long format */
+    RESERVED(2:18, uint32_t)
+  } l;                                   /*!< \brief Structure used for bit  access in long format */
   uint32_t w;                            /*!< \brief Type      used for word access */
 } DFSR_Type;

@@ -590,7 +590,7 @@
     uint32_t STATUS:6;                   /*!< \brief bit: 0.. 5  Fault Status bits */
     RESERVED(0:3, uint32_t)
     uint32_t LPAE:1;                     /*!< \brief bit:     9  Large Physical Address Extension */
-    RESERVED(0:2, uint32_t)
+    RESERVED(1:2, uint32_t)
     uint32_t ExT:1;                      /*!< \brief bit:    12  External abort type */
     RESERVED(2:19, uint32_t)
   } l;                                   /*!< \brief Structure used for bit access in long format */


error: pathspec 'C/Array/AccidentMultidimensial.c' did not match any file(s) known to git

--- C/Array/AccidentMultidimensial.c
+++ C/Array/AccidentMultidimensial.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int main() {
+    int vetor[4][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}};
+    printf("%d", vetor[1][0] + 1 + vetor[3][0]);
+}
+
+//https://pt.stackoverflow.com/q/332158/101


1. fix an issue .

1. fix an issue .

--- CCExtensionKit/CCExtensionKit/CCOrigin/CCOriginCustom.h
+++ CCExtensionKit/CCExtensionKit/CCOrigin/CCOriginCustom.h
@@ -21,6 +21,7 @@
     #import "CCTaskManager.h"
     #import "CCCrashCatcher.h"
     #import "CCPointMarker.h"
+    #import "CCNull.h"

 // Media
     #import "CCPhotoManager.h"


reset player

reset player

--- games/textdng1/game.c
+++ games/textdng1/game.c
@@ -80,7 +80,8 @@
     CH_P_MAX
 };

-struct game_character           player = {0, 0, CHAR_PLAYER, 0, 0};
+struct game_character           player;
+struct game_character           player_init = {0, 0, CHAR_PLAYER, 0, 0};

 struct game_map*                current_level = NULL;

@@ -341,6 +342,8 @@
         ERROR("Unable to open level file");
         return -1;
     }
+
+    player = player_init;

     while (!feof(fp) && !ferror(fp)) {
         if (fgets(line,sizeof(line)-1,fp) == NULL) break;


app/testpmd: fix fdir ipv4 filter

app/testpmd: fix fdir ipv4 filter

Signed-off-by: Intel

--- app/test-pmd/cmdline.c
+++ app/test-pmd/cmdline.c
@@ -217,7 +217,7 @@
 		       "    ip_src_address port_src dst ip_dst_address port_dst\n"
 		       "    flexbytes flexbytes_values vlan vlan_id soft soft_id\n"
 		       "- set_masks_filter port_id only_ip_flow 0|1 src_mask\n"
-		       "    ip_src_mask  port_src_mask dst_mask ip_dst_mask\n"
+		       "    ip_src_mask port_src_mask dst_mask ip_dst_mask\n"
 		       "    port_dst_mask flexbytes 0|1 vlan_id 0|1 vlan_prio 0|1\n"
 		       "- set_ipv6_masks_filter port_id only_ip_flow 0|1 src_mask\n"
 		       "    ip_src_mask port_src_mask dst_mask ip_dst_mask\n"
@@ -1481,7 +1481,7 @@
 			      port_src_mask, UINT16);
 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
 	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
-				 src_mask, "dst_mask");
+				 dst_mask, "dst_mask");
 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
 	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
 			      ip_dst_mask, UINT32);


small changes

small changes


features/locks: free fdctx in release.

features/locks: free fdctx in release.

Signed-off-by: Raghavendra G <raghavendra@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>

BUG: 1438 (memory leaks)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1438

--- xlators/features/locks/src/posix.c
+++ xlators/features/locks/src/posix.c
@@ -71,6 +71,45 @@
 }

 static pl_fdctx_t *
+pl_check_n_create_fdctx (xlator_t *this, fd_t *fd)
+{
+        int         ret   = 0;
+        uint64_t    tmp   = 0;
+        pl_fdctx_t *fdctx = NULL;
+
+        if ((this == NULL) || (fd == NULL)) {
+                goto out;
+        }
+
+        LOCK (&fd->lock);
+        {
+                ret = __fd_ctx_get (fd, this, &tmp);
+                if ((ret != 0) || (tmp == 0)) {
+                        fdctx = pl_new_fdctx ();
+                        if (fdctx == NULL) {
+                                gf_log (this->name, GF_LOG_ERROR,
+                                        "out of memory");
+                                goto unlock;
+                        }
+                }
+
+                ret = __fd_ctx_set (fd, this, (uint64_t)(long)fdctx);
+                if (ret != 0) {
+                        GF_FREE (fdctx);
+                        fdctx = NULL;
+                        gf_log (this->name, GF_LOG_DEBUG,
+                                "failed to set fd ctx");
+                }
+        }
+unlock:
+        UNLOCK (&fd->lock);
+
+out:
+        return fdctx;
+}
+
+/*
+static pl_fdctx_t *
 pl_get_fdctx (xlator_t *this, fd_t *fd)
 {
         int ret = 0;
@@ -109,6 +148,7 @@
         return ret;

 }
+*/

 int
 pl_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
@@ -368,32 +408,17 @@
 		     fd_t *fd)
 {
         pl_fdctx_t *fdctx = NULL;
-        int ret = -1;

         if (op_ret < 0)
                 goto unwind;

-        fdctx = pl_get_fdctx (this, fd);
+        fdctx = pl_check_n_create_fdctx (this, fd);
         if (!fdctx) {
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "fdctx not present");
-                fdctx = pl_new_fdctx ();
-                if (!fdctx) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "Out of memory");
-                        op_errno = ENOMEM;
-                        op_ret   = -1;
-                        goto unwind;
-                }
-
-                ret = pl_set_fdctx (this, fd, fdctx);
-                if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "could not set fdctx");
-                        op_ret = -1;
-                        op_errno = ENOMEM;
-                        goto unwind;
-                }
+                gf_log (this->name, GF_LOG_ERROR,
+                        "Out of memory");
+                op_errno = ENOMEM;
+                op_ret   = -1;
+                goto unwind;
         }

 unwind:
@@ -481,32 +506,17 @@
              int32_t op_ret, int32_t op_errno, fd_t *fd)
 {
         pl_fdctx_t *fdctx = NULL;
-        int ret = -1;

         if (op_ret < 0)
                 goto unwind;

-        fdctx = pl_get_fdctx (this, fd);
+        fdctx = pl_check_n_create_fdctx (this, fd);
         if (!fdctx) {
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "fdctx not present");
-                fdctx = pl_new_fdctx ();
-                if (!fdctx) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "Out of memory");
-                        op_errno = ENOMEM;
-                        op_ret   = -1;
-                        goto unwind;
-                }
-
-                ret = pl_set_fdctx (this, fd, fdctx);
-                if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "could not set fdctx");
-                        op_ret = -1;
-                        op_errno = ENOMEM;
-                        goto unwind;
-                }
+                gf_log (this->name, GF_LOG_ERROR,
+                        "Out of memory");
+                op_errno = ENOMEM;
+                op_ret   = -1;
+                goto unwind;
         }

 unwind:
@@ -536,32 +546,17 @@
                struct iatt *preparent, struct iatt *postparent)
 {
         pl_fdctx_t *fdctx = NULL;
-        int ret = -1;

         if (op_ret < 0)
                 goto unwind;

-        fdctx = pl_get_fdctx (this, fd);
+        fdctx = pl_check_n_create_fdctx (this, fd);
         if (!fdctx) {
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "fdctx not present");
-                fdctx = pl_new_fdctx ();
-                if (!fdctx) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "Out of memory");
-                        op_errno = ENOMEM;
-                        op_ret   = -1;
-                        goto unwind;
-                }
-
-                ret = pl_set_fdctx (this, fd, fdctx);
-                if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "could not set fdctx");
-                        op_ret = -1;
-                        op_errno = ENOMEM;
-                        goto unwind;
-                }
+                gf_log (this->name, GF_LOG_ERROR,
+                        "Out of memory");
+                op_errno = ENOMEM;
+                op_ret   = -1;
+                goto unwind;
         }

 unwind:
@@ -975,6 +970,7 @@

         return ret;
 }
+
 static int
 pl_getlk_fd (xlator_t *this, pl_inode_t *pl_inode,
              fd_t *fd, posix_lock_t *reqlock)
@@ -996,7 +992,7 @@
                         "There are active locks on fd");

                 ret = fd_ctx_get (fd, this, &tmp);
-                fdctx = (pl_fdctx_t *) tmp;
+                fdctx = (pl_fdctx_t *)(long) tmp;

                 if (list_empty (&fdctx->locks_list)) {
                         gf_log (this->name, GF_LOG_TRACE,
@@ -1330,6 +1326,12 @@
         pl_inode_t *pl_inode     = NULL;
         uint64_t    tmp_pl_inode = 0;
         int         ret          = -1;
+        uint64_t    tmp          = 0;
+        pl_fdctx_t *fdctx        = NULL;
+
+        if (fd == NULL) {
+                goto out;
+        }

 	ret = inode_ctx_get (fd->inode, this, &tmp_pl_inode);
         if (ret != 0)
@@ -1344,9 +1346,45 @@

         delete_locks_of_fd (this, pl_inode, fd);

+        ret = fd_ctx_del (fd, this, &tmp);
+        if (ret) {
+                gf_log (this->name, GF_LOG_DEBUG,
+                        "Could not get fdctx");
+                goto out;
+        }
+
+        fdctx = (pl_fdctx_t *)(long)tmp;
+
+        GF_FREE (fdctx);
 out:
         return ret;
 }
+
+int
+pl_releasedir (xlator_t *this, fd_t *fd)
+{
+        int         ret          = -1;
+        uint64_t    tmp          = 0;
+        pl_fdctx_t *fdctx        = NULL;
+
+        if (fd == NULL) {
+                goto out;
+        }
+
+        ret = fd_ctx_del (fd, this, &tmp);
+        if (ret) {
+                gf_log (this->name, GF_LOG_DEBUG,
+                        "Could not get fdctx");
+                goto out;
+        }
+
+        fdctx = (pl_fdctx_t *)(long)tmp;
+
+        GF_FREE (fdctx);
+out:
+        return ret;
+}
+
 static int32_t
 __get_posixlk_count (xlator_t *this, pl_inode_t *pl_inode)
 {
@@ -1936,6 +1974,7 @@
 struct xlator_cbks cbks = {
         .forget      = pl_forget,
         .release     = pl_release,
+        .releasedir  = pl_releasedir,
 };


Connection: inline enqueueing messages

Connection: inline enqueueing messages

_add_msg_to_queue() is only called from one place; moving it into
_send_with_priority() makes the code marginally smaller and easier to
follow.

--- src/idle-connection.c
+++ src/idle-connection.c
@@ -88,10 +88,17 @@
 	guint64 id;
 };

-static IdleOutputPendingMsg *idle_output_pending_msg_new() {
+/* Steals @message. */
+static IdleOutputPendingMsg *
+idle_output_pending_msg_new (
+    gchar *message,
+    guint priority)
+{
 	IdleOutputPendingMsg *msg = g_slice_new(IdleOutputPendingMsg);
 	static guint64 last_id = 0;

+	msg->message = message;
+	msg->priority = priority;
 	msg->id = last_id++;

 	return msg;
@@ -861,18 +868,6 @@
 	return TRUE;
 }

-static void _add_msg_to_queue(IdleConnection *conn, gchar *msg, guint priority) {
-	IdleConnectionPrivate *priv = IDLE_CONNECTION_GET_PRIVATE(conn);
-	IdleOutputPendingMsg *output_msg;
-
-	output_msg = idle_output_pending_msg_new();
-	output_msg->message = msg;
-	output_msg->priority = priority;
-
-	g_queue_insert_sorted(priv->msg_queue, output_msg, pending_msg_compare, NULL);
-	idle_connection_add_queue_timeout (conn);
-}
-
 static void
 idle_connection_add_queue_timeout (IdleConnection *self)
 {
@@ -913,6 +908,7 @@
  * Queue a IRC command for sending, clipping it to IRC_MSG_MAXLEN bytes and appending the required <CR><LF> to it
  */
 static void _send_with_priority(IdleConnection *conn, const gchar *msg, guint priority) {
+	IdleConnectionPrivate *priv = IDLE_CONNECTION_GET_PRIVATE(conn);
 	gchar cmd[IRC_MSG_MAXLEN + 3];
 	int len;
 	gchar *converted;
@@ -939,7 +935,10 @@
 		converted = g_strdup(cmd);
 	}

-	_add_msg_to_queue(conn, converted, priority);
+	g_queue_insert_sorted(priv->msg_queue,
+		idle_output_pending_msg_new(converted, priority),
+		pending_msg_compare, NULL);
+	idle_connection_add_queue_timeout (conn);
 }

 void idle_connection_send(IdleConnection *conn, const gchar *msg) {


android/bluetooth: Fix not setting expected discovery type

The code was not setting the expected discovery type for the next round
when discovering is active.

--- android/bluetooth.c
+++ android/bluetooth.c
@@ -1292,8 +1292,11 @@

 	adapter.cur_discovery_type = type;

-	if (ev->discovering)
-		return;
+	if (ev->discovering) {
+		adapter.exp_discovery_type = adapter.le_scanning ?
+						SCAN_TYPE_LE : SCAN_TYPE_NONE;
+		return;
+	}

 	/* One shot notification about discovery stopped */
 	if (gatt_discovery_stopped_cb) {