Added support for generic getopt() function instead of getopt_long(). Because not all platforms have getopt_long().

git-svn-id: 75429ccc2030f235ccf16e6b9b7f8e83d5edd22e@5285 c70aab31-4412-0410-b14c-859654838e24

--- test/automated/testsdl.c
+++ test/automated/testsdl.c
@@ -16,11 +16,17 @@
 #include "render/render.h"
 #include "audio/audio.h"

+#if defined(__QNXNTO__)
+#define NO_GETOPT_LONG 1
+#endif /* __QNXNTO__ */
+
 #include <stdio.h> /* printf */
 #include <stdlib.h> /* exit */
 #include <unistd.h> /* getopt */
+#include <string.h> /* strcmp */
+#if !defined(NO_GETOPT_LONG)
 #include <getopt.h> /* getopt_long */
-#include <string.h> /* strcmp */
+#endif /* !NO_GETOPT_LONG */

 /*
@@ -45,34 +51,53 @@
 /**
  * @brief Displays program usage.
  */
+#if !defined(NO_GETOPT_LONG)
 static void print_usage( const char *name )
 {
    printf("Usage: %s [OPTIONS]\n", name);
    printf("Options are:\n");
-   printf("   -m, --manual    enables tests that require user interaction\n");
-   printf("   --noplatform    do not run the platform tests\n");
-   printf("   --norwops       do not run the rwops tests\n");
-   printf("   --nosurface     do not run the surface tests\n");
-   printf("   --norender      do not run the render tests\n");
-   printf("   --noaudio       do not run the audio tests\n");
-   printf("   -v, --verbose   increases verbosity level by 1 for each -v\n");
-   printf("   -q, --quiet     only displays errors\n");
-   printf("   -h, --help      display this message and exit\n");
-}
-
+   printf("   -m, --manual        enables tests that require user interaction\n");
+   printf("   -p, --noplatform    do not run the platform tests\n");
+   printf("   -o, --norwops       do not run the rwops tests\n");
+   printf("   -s, --nosurface     do not run the surface tests\n");
+   printf("   -r, --norender      do not run the render tests\n");
+   printf("   -a, --noaudio       do not run the audio tests\n");
+   printf("   -v, --verbose       increases verbosity level by 1 for each -v\n");
+   printf("   -q, --quiet         only displays errors\n");
+   printf("   -h, --help          display this message and exit\n");
+}
+#endif /* !NO_GETOPT_LONG */
+
+#if defined(NO_GETOPT_LONG)
+static void print_usage( const char *name )
+{
+   printf("Usage: %s [OPTIONS]\n", name);
+   printf("Options are:\n");
+   printf("   -m,     enables tests that require user interaction\n");
+   printf("   -p,     do not run the platform tests\n");
+   printf("   -o,     do not run the rwops tests\n");
+   printf("   -s,     do not run the surface tests\n");
+   printf("   -r,     do not run the render tests\n");
+   printf("   -a,     do not run the audio tests\n");
+   printf("   -v,     increases verbosity level by 1 for each -v\n");
+   printf("   -q,     only displays errors\n");
+   printf("   -h,     display this message and exit\n");
+}
+#endif /* NO_GETOPT_LONG */

 /**
  * @brief Handles the options.
  */
+#if !defined(NO_GETOPT_LONG)
 static void parse_options( int argc, char *argv[] )
 {
    static struct option long_options[] = {
       { "manual", no_argument, 0, 'm' },
-      { "noplatform", no_argument, 0, 0 },
-      { "norwops", no_argument, 0, 0 },
-      { "nosurface", no_argument, 0, 0 },
-      { "norender", no_argument, 0, 0 },
-      { "noaudio", no_argument, 0, 0 },
+      { "noplatform", no_argument, 0, 'p' },
+      { "norwops", no_argument, 0, 'o' },
+      { "nosurface", no_argument, 0, 's' },
+      { "norender", no_argument, 0, 'r' },
+      { "noaudio", no_argument, 0, 'a' },
       { "verbose", no_argument, 0, 'v' },
       { "quiet", no_argument, 0, 'q' },
       { "help", no_argument, 0, 'h' },
@@ -85,7 +110,7 @@

    /* Iterate over options. */
    while ((c = getopt_long( argc, argv,
-               "vqh",
+               "mposravqh",
                long_options, &option_index)) != -1) {

       /* Handle options. */
@@ -109,6 +134,31 @@
             run_manual = 1;
             break;

+         /* No platform. */
+         case 'p':
+            run_platform = 0;
+            break;
+
+         /* No rwops. */
+         case 'o':
+            run_rwops = 0;
+            break;
+
+         /* No surface. */
+         case 's':
+            run_surface = 0;
+            break;
+
+         /* No render. */
+         case 'r':
+            run_render = 0;
+            break;
+
+         /* No audio. */
+         case 'a':
+            run_audio = 0;
+            break;
+
          /* Verbosity. */
          case 'v':
             SDL_ATgeti( SDL_AT_VERBOSE, &i );
@@ -126,9 +176,69 @@
             exit(EXIT_SUCCESS);
       }
    }
-
-}
-
+}
+#endif /* !NO_GETOPT_LONG */
+
+#if defined(NO_GETOPT_LONG)
+static void parse_options( int argc, char *argv[] )
+{
+   static char* short_options="mposravqh";
+   int c = 0;
+   int i;
+
+   /* Iterate over options. */
+   while ((c = getopt(argc, argv, short_options)) != -1) {
+      /* Handle options. */
+      switch (c) {
+         /* Manual. */
+         case 'm':
+            run_manual = 1;
+            break;
+
+         /* No platform. */
+         case 'p':
+            run_platform = 0;
+            break;
+
+         /* No rwops. */
+         case 'o':
+            run_rwops = 0;
+            break;
+
+         /* No surface. */
+         case 's':
+            run_surface = 0;
+            break;
+
+         /* No render. */
+         case 'r':
+            run_render = 0;
+            break;
+
+         /* No audio. */
+         case 'a':
+            run_audio = 0;
+            break;
+
+         /* Verbosity. */
+         case 'v':
+            SDL_ATgeti( SDL_AT_VERBOSE, &i );
+            SDL_ATseti( SDL_AT_VERBOSE, i+1 );
+            break;
+
+         /* Quiet. */
+         case 'q':
+            SDL_ATseti( SDL_AT_QUIET, 1 );
+            break;
+
+         /* Help. */
+         case 'h':
+            print_usage( argv[0] );
+            exit(EXIT_SUCCESS);
+      }
+   }
+}
+#endif /* NO_GETOPT_LONG */

 /**
  * @brief Main entry point.


Fix typo

Fix typo

--- objc/PromiseKit/Promise.h
+++ objc/PromiseKit/Promise.h
@@ -128,7 +128,7 @@
  in fact will often only consume the first parameter. Thus ensure the
  order of parameters is: from most-important to least-important.

- Note that attempts to reject with `PMKMany` will `@throw`.
+ Note that attempts to reject with `PMKManifold` will `@throw`.
 */
 id PMKManifold(NSArray *arguments);
 #define PMKManifold(...) PMKManifold(@[__VA_ARGS__])


Omit default values when saving things

Omit default values when saving things

--- mud/home/Game/lib/thing.c
+++ mud/home/Game/lib/thing.c
@@ -34,20 +34,26 @@
 {
 	mapping map;
 	object lwo;
+	mixed v;

 	map = ([
+		"name": query_object_name(),
+		"id": query_id(),
+
 		"archetype": query_archetype(),
-		"capacity": query_capacity(),
-		"density": query_density(),
+
 		"environment": query_environment(),
-		"flexible": query_flexible(),
-		"id": query_id(),
 		"inventory": query_inventory(),
-		"mass": query_mass(),
-		"max_mass": query_max_mass(),
-		"name": query_object_name(),
+
+		"virtual": query_virtual() ? 1 : 0
+
+		"mass": (v = query_mass()) ? v : nil,
+		"density": query_density()),
+		"flexible": query_flexible() ? 1 : 0,
+		"capacity": (v = query_capacity()) ? v : nil,
+		"max_mass": (v = query_max_mass()) ? v : nil,
+
 		"properties": query_local_properties(),
-		"virtual": query_virtual()
 	]);

 	if (lwo = query_character_lwo()) {


remove trailing ;

remove trailing ;

Summary:
Latest clang reported `-Wextra-semi` in `BOOST_MPL_HAS_XXX_TRAIT_DEF` uses with the trailing `;`. Codemod them away before the upgrade.
```lang=bash
fbgr -sl 'BOOST_MPL_HAS_XXX_TRAIT_DEF\(.*\);$' | xargs perl -pi -e 's,(BOOST_MPL_HAS_XXX_TRAIT_DEF\(.*\));$,\1,'
```

Reviewed By: yfeldblum

Differential Revision: D7383619

fbshipit-source-id: f7f9415617cf6d4a876ebe8bf782d0115cd01c23

--- folly/DynamicConverter.h
+++ folly/DynamicConverter.h
@@ -56,10 +56,10 @@

 namespace dynamicconverter_detail {

-BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type);
-BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator);
-BOOST_MPL_HAS_XXX_TRAIT_DEF(mapped_type);
-BOOST_MPL_HAS_XXX_TRAIT_DEF(key_type);
+BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type)
+BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator)
+BOOST_MPL_HAS_XXX_TRAIT_DEF(mapped_type)
+BOOST_MPL_HAS_XXX_TRAIT_DEF(key_type)

 template <typename T> struct iterator_class_is_container {
   typedef std::reverse_iterator<typename T::iterator> some_iterator;


Extracted searches into a common method, added std:: where possibly needed.

--- lexlib/SparseState.h
+++ lexlib/SparseState.h
@@ -24,9 +24,18 @@
 		inline bool operator<(const State &other) const {
 			return position < other.position;
 		}
+		inline bool operator==(const State &other) const {
+			return (position == other.position) && (value == other.value);
+		}
 	};
 	typedef std::vector<State> stateVector;
 	stateVector states;
+
+	typename stateVector::iterator Find(int position) {
+		State searchValue(position, T());
+		return std::lower_bound(states.begin(), states.end(), searchValue);
+	}
+
 public:
 	void Set(int position, T value) {
 		Delete(position);
@@ -39,9 +48,7 @@
 			return T();
 		if (position < states[0].position)
 			return T();
-		State searchValue(position, T());
-		typename stateVector::iterator low =
-			lower_bound(states.begin(), states.end(), searchValue);
+		typename stateVector::iterator low = Find(position);
 		if (low == states.end()) {
 			return states[states.size()-1].value;
 		} else {
@@ -52,16 +59,14 @@
 		}
 	}
 	bool Delete(int position) {
-		State searchValue(position, T());
-		typename stateVector::iterator low =
-			lower_bound(states.begin(), states.end(), searchValue);
+		typename stateVector::iterator low = Find(position);
 		if (low != states.end()) {
 			states.erase(low, states.end());
 			return true;
 		}
 		return false;
 	}
-	size_t size() {
+	size_t size() const {
 		return states.size();
 	}
 };


Volume Rendering: Bugfix for a normal calculation in the MC interpolation

--HG--
branch : v1-9

--- Components/Volume/include/OgreVolumeIsoSurfaceMC.h
+++ Components/Volume/include/OgreVolumeIsoSurfaceMC.h
@@ -60,9 +60,9 @@
             // Don't use Math::RealEqual here as it isn't inlined and this function is performance critical.
             if (fabs(val0.w - ISO_LEVEL) <= FLT_EPSILON)
             {
-                normal.x = val1.x;
-                normal.y = val1.y;
-                normal.z = val1.z;
+                normal.x = val0.x;
+                normal.y = val0.y;
+                normal.z = val0.z;
                 return v0;
             }
             if (fabs(val1.w - ISO_LEVEL) <= FLT_EPSILON)


Set buffer-modified to true on editing stdin/stream

--- windows.c
+++ windows.c
@@ -75,6 +75,7 @@

 		if(!strcmp(argv[0], "-")){
 			buf = buffer_new_file_nofind(stdin);
+			buf->modified = true; /* editing a stream */
 			/* no filename */

 			if(ferror(stdin))


gvfs: return an error when file size is unknown

--- modules/access/gnomevfs.c
+++ modules/access/gnomevfs.c
@@ -359,6 +359,9 @@
             break;

         case ACCESS_GET_SIZE:
+            if( !(p_sys->p_file_info->valid_fields
+                    & GNOME_VFS_FILE_INFO_FIELDS_SIZE) )
+                return VLC_EGENERIC;
             *va_arg( args, uint64_t * ) = p_sys->p_file_info->size;
             break;


Comments

Comments

--- Library/Sources/Stroika/Foundation/Debug/Trace.h
+++ Library/Sources/Stroika/Foundation/Debug/Trace.h
@@ -143,7 +143,11 @@

             /**
-            */
+             *  \par Example Usage
+             *      \code
+             *      Debug::TraceContextBumper ctx ("MyXercesMemMgr_::DUMPCurMemStats");
+             *      \endcode
+             */
             class   TraceContextBumper {
             public:
                 /**


Fix typo

Fix typo

--- lang.cpp/Algorithms/Abstractions/TypePredicates.h
+++ lang.cpp/Algorithms/Abstractions/TypePredicates.h
@@ -5,7 +5,7 @@

 /*
 	PROPER_SORTING_ALGORITHM:
-	Part 1: Declaration of the used algorithm
+	Part 1: Declaration of an algorithm
 	Part 2: Partial template specialization for the algorithm
 */


perror.c:   BUG#11999, incorrect --help on perror with ndb

--- extra/perror.c
+++ extra/perror.c
@@ -41,7 +41,7 @@
   {"info", 'I', "Synonym for --help.",  0, 0, 0, GET_NO_ARG,
    NO_ARG, 0, 0, 0, 0, 0, 0},
 #ifdef HAVE_NDBCLUSTER_DB
-  {"ndb", 0, "Ndbcluster storage engine specific error codes.",  (gptr*) &ndb_code,
+  {"ndb", 257, "Ndbcluster storage engine specific error codes.",  (gptr*) &ndb_code,
    (gptr*) &ndb_code, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 #endif
 #ifdef HAVE_SYS_ERRLIST


intel: set Length/Offset fields in intel_bufferobj_map()

--- src/mesa/drivers/dri/intel/intel_buffer_objects.c
+++ src/mesa/drivers/dri/intel/intel_buffer_objects.c
@@ -267,6 +267,9 @@
    }

    obj->Pointer = intel_obj->buffer->virtual;
+   obj->Length = obj->Size;
+   obj->Offset = 0;
+
    return obj->Pointer;
 }


better formatting of xalt_initialize.c

better formatting of xalt_initialize.c

--- compiled/xalt_initialize.c
+++ compiled/xalt_initialize.c
@@ -66,9 +66,9 @@
 static long            compute_value(const char **envA);
 static void            abspath(char * path, int sz);
 static volatile double epoch();
+
 void myinit(int argc, char **argv);
 void myfini();
-

 #define STR(x)   StR1_(x)
 #define StR1_(x) #x


sys.args.inout is a tinyint column, so create bat with type bte.

--- sql/storage/bat/bat_logger.c
+++ sql/storage/bat/bat_logger.c
@@ -112,7 +112,7 @@
 		if (!b)
 			return;
 		bi = bat_iterator(b);
-		b1 = BATnew(TYPE_void, TYPE_bit, BATcount(b), PERSISTENT);
+		b1 = BATnew(TYPE_void, TYPE_bte, BATcount(b), PERSISTENT);
 		if (!b1)
 			return;
         	BATseqbase(b1, b->hseqbase);


restructure and comment the code

restructure and comment the code

--- roa-lib/roa_validate.c
+++ roa-lib/roa_validate.c
@@ -31,18 +31,19 @@
 */
 #define MINMAXBUFSIZE 20

-static int gen_hash(uchar *inbufp, int bsize, uchar *outbufp, int alg)
+static int gen_hash(uchar *inbufp, int bsize, uchar *outbufp,
+		    CRYPT_ALGO_TYPE alg)
   { // used for manifests      alg = 1 for SHA-1; alg = 2 for SHA2
   CRYPT_CONTEXT hashContext;
   uchar hash[40];
   int ansr = -1;

+  if (alg != CRYPT_ALGO_SHA && alg != CRYPT_ALGO_SHA2)
+      return ERR_SCM_BADALG;
+
   memset(hash, 0, 40);
   cryptInit();
-  if (alg == 2) cryptCreateContext(&hashContext, CRYPT_UNUSED, CRYPT_ALGO_SHA2);
-  else if (alg == 1) cryptCreateContext(&hashContext, CRYPT_UNUSED,
-    CRYPT_ALGO_SHA);
-  else return ERR_SCM_BADALG;
+  cryptCreateContext(&hashContext, CRYPT_UNUSED, alg);
   cryptEncrypt(hashContext, inbufp, bsize);
   cryptEncrypt(hashContext, inbufp, 0);
   cryptGetAttributeString(hashContext, CRYPT_CTXINFO_HASHVALUE, hash, &ansr);
@@ -58,85 +59,103 @@
   CRYPT_PKCINFO_RSA rsakey;
   // CRYPT_KEYSET cryptKeyset;
   struct RSAPubKey rsapubkey;
-  int bsize, tmp, sidsize;
+  int bsize, ret, sidsize;
   uchar *c, *buf, hash[40], sid[40];

-  memset(hash, 0, 40);
+  // get SID and generate the sha-1 hash
+  // (needed for cryptlib; see below)
   memset(sid, 0, 40);
-  RSAPubKey(&rsapubkey, 0);
-    // get hash of SubjectPublicKeyInfo to put in block for CheckSignature
-  if ((bsize = size_casn(&certp->toBeSigned.subjectPublicKeyInfo.self)) < 0)
-    return ERR_SCM_INVALSIG;;
+  bsize = size_casn(&certp->toBeSigned.subjectPublicKeyInfo.self);
+  if (bsize < 0) return ERR_SCM_INVALSIG;;
   buf = (uchar *)calloc(1, bsize);
   encode_casn(&certp->toBeSigned.subjectPublicKeyInfo.self, buf);
-  sidsize = gen_hash(buf, bsize, sid, 1);
+  sidsize = gen_hash(buf, bsize, sid, CRYPT_ALGO_SHA);
   free(buf);

-  readvsize_casn(&certp->toBeSigned.subjectPublicKeyInfo.subjectPublicKey, &c);
-  decode_casn(&rsapubkey.self, &c[1]);  // [1] to skip 1st byte in BIT STRING
-  free(c);
-  struct SignerInfo *sigInfop = (struct SignerInfo *)member_casn(&rp->content.signedData.signerInfos.self, 0);
-
+  // generate the sha256 hash of the signed attributes. We don't call
+  // gen_hash because we need the hashContext for later use (below).
+  struct SignerInfo *sigInfop = (struct SignerInfo *)
+      member_casn(&rp->content.signedData.signerInfos.self, 0);
+  memset(hash, 0, 40);
   bsize = size_casn(&sigInfop->signedAttrs.self);
+  if (bsize < 0) return ERR_SCM_INVALSIG;;
   buf = (uchar *)calloc(1, bsize);
   encode_casn(&sigInfop->signedAttrs.self, buf);
   *buf = ASN_SET;

+  // (re)init the crypt library
   cryptInit();
-  if (cryptCreateContext(&hashContext, CRYPT_UNUSED, CRYPT_ALGO_SHA2) != 0)
-    return ERR_SCM_INVALSIG;
-    // make the hash
+  cryptCreateContext(&hashContext, CRYPT_UNUSED, CRYPT_ALGO_SHA2);
   cryptEncrypt(hashContext, buf, bsize);
   cryptEncrypt(hashContext, buf, 0);
-  cryptGetAttributeString(hashContext, CRYPT_CTXINFO_HASHVALUE, hash, &tmp);
-      // set up public key
-  if (cryptCreateContext(&pubkeyContext, CRYPT_UNUSED, CRYPT_ALGO_RSA) != 0) {
-    cryptDestroyContext(hashContext);
-    return ERR_SCM_INVALSIG;
-  }
+  cryptGetAttributeString(hashContext, CRYPT_CTXINFO_HASHVALUE, hash, &ret);
+  assert(ret == 32);		/* size of hash; should never fail */
+  free(buf);
+
+  // get the public key from the certificate and decode it into an RSAPubKey
+  readvsize_casn(&certp->toBeSigned.subjectPublicKeyInfo.subjectPublicKey, &c);
+  RSAPubKey(&rsapubkey, 0);
+  decode_casn(&rsapubkey.self, &c[1]);  // skip 1st byte (tag?) in BIT STRING
+  free(c);
+
+  // set up the key by reading the modulus and exponent
+  cryptCreateContext(&pubkeyContext, CRYPT_UNUSED, CRYPT_ALGO_RSA);
   cryptSetAttributeString(pubkeyContext, CRYPT_CTXINFO_LABEL, "label", 5);
   cryptInitComponents(&rsakey, CRYPT_KEYTYPE_PUBLIC);
-  free(buf);
+
+  // read the modulus from rsapubkey
   bsize = readvsize_casn(&rsapubkey.modulus, &buf);
   c = buf;
+  // if the first byte is a zero, skip it
   if (!*buf)
     {
     c++;
-    bsize --;
+    bsize--;
     }
   cryptSetComponent((&rsakey)->n, c, bsize * 8);
   free(buf);

+  // read the exponent from the rsapubkey
   bsize = readvsize_casn(&rsapubkey.exponent, &buf);
   cryptSetComponent((&rsakey)->e, buf, bsize * 8);
   free(buf);

+  // set the modulus and exponent on the key
   cryptSetAttributeString(pubkeyContext, CRYPT_CTXINFO_KEY_COMPONENTS, &rsakey,
 			  sizeof(CRYPT_PKCINFO_RSA));
-
+  // all done with this now, free the storage
   cryptDestroyComponents(&rsakey);
-  // make the structure cryptlib likes.  Copy everything but SignedAttrs
+
+  // make the structure cryptlib likes.
+  // we discovered through detective work that cryptlib wants the
+  // signature's SID field to be the sha-1 hash of the SID.
   struct SignerInfo sigInfo;
-  SignerInfo(&sigInfo, (ushort)0);
-  copy_casn(&sigInfo.version.self, &sigInfop->version.self);
-  copy_casn(&sigInfo.sid.self, &sigInfop->sid.self);
-  write_casn(&sigInfo.sid.subjectKeyIdentifier, sid, sidsize);
+  SignerInfo(&sigInfo, (ushort)0); /* init sigInfo */
+  copy_casn(&sigInfo.version.self, &sigInfop->version.self); /* copy over */
+  copy_casn(&sigInfo.sid.self, &sigInfop->sid.self); /* copy over */
+  write_casn(&sigInfo.sid.subjectKeyIdentifier, sid, sidsize); /* sid * hash */
+
+  // copy over digest algorithm, signature algorithm, signature
   copy_casn(&sigInfo.digestAlgorithm.self, &sigInfop->digestAlgorithm.self);
   copy_casn(&sigInfo.signatureAlgorithm.self, &sigInfop->signatureAlgorithm.self);
   copy_casn(&sigInfo.signature, &sigInfop->signature);
+
+  // now encode as asn1, and check the signature
   bsize = size_casn(&sigInfo.self);
   buf = (uchar *)calloc(1, bsize);
   encode_casn(&sigInfo.self, buf);
-  tmp = cryptCheckSignature(buf, bsize, pubkeyContext, hashContext);
+  ret = cryptCheckSignature(buf, bsize, pubkeyContext, hashContext);
   free(buf);

+  // all done, clean up
   cryptDestroyContext(pubkeyContext);
   cryptDestroyContext(hashContext);
   cryptEnd();
   delete_casn(&rsapubkey.self);
   delete_casn(&sigInfo.self);
-  if (tmp) return ERR_SCM_INVALSIG;
-  return 0;
+
+  // if the value returned from crypt above != 0, it's invalid
+  return (ret != 0) ? ERR_SCM_INVALSIG : 0;
   }

 static void fill_max(uchar *max)
@@ -172,7 +191,7 @@
   uchar *pubkey;
   tmp = readvsize_casn(spkeyp, &pubkey);
   uchar khash[22];
-  tmp = gen_hash(&pubkey[1], tmp - 1, khash, 1);
+  tmp = gen_hash(&pubkey[1], tmp - 1, khash, CRYPT_ALGO_SHA);
   free(pubkey);
   int err = 1;  // require SKI
   struct Extension *extp;
@@ -205,7 +224,7 @@
   lseek(ffd, 0, SEEK_SET);
   contentsp = (uchar *)calloc(1, name_lth + 2);
   if (read(ffd, contentsp, name_lth + 2) != name_lth) err = ERR_SCM_BADFILE;
-  else if ((hash_lth = gen_hash(contentsp, name_lth, contentsp, 2)) < 0)
+  else if ((hash_lth = gen_hash(contentsp, name_lth, contentsp, CRYPT_ALGO_SHA2)) < 0)
     err = ERR_SCM_BADHASH;
   else
     {
@@ -307,9 +326,11 @@
       roaAddrp = (struct ROAIPAddress *)next_of(&roaAddrp->self))
       {
       if ((err = test_maxLength(roaAddrp)) < 0 ||
-        (err = setup_roa_minmax(&roaAddrp->address, rmin, rmax, i)) < 0) return err;
+	  (err = setup_roa_minmax(&roaAddrp->address, rmin, rmax, i)) < 0)
+	  return err;
       if (memcmp(&rmin[3], &oldmax[3], sizeof(rmin) - 3) < 0 ||
-	memcmp(&rmax[3], &rmin[3],   sizeof(rmin) - 3) < 0) return ERR_SCM_INVALIPB;
+	  memcmp(&rmax[3], &rmin[3],   sizeof(rmin) - 3) < 0)
+	  return ERR_SCM_INVALIPB;
       }
     }
   return 0;
@@ -385,7 +406,7 @@
     tbs_lth = readvsize_casn(&rp->content.signedData.encapContentInfo.eContent.self, &tbsp);

     // hash it, make sure it's the right length and it matches the digest
-    if (gen_hash(tbsp, tbs_lth, hashbuf, 2) != 32 ||
+    if (gen_hash(tbsp, tbs_lth, hashbuf, CRYPT_ALGO_SHA2) != 32 ||
 	memcmp(digestbuf, hashbuf, 32) != 0) {
 	ret =  ERR_SCM_BADHASH;
     }


add const to isReading in TcpConnection.h

--- muduo/net/TcpConnection.h
+++ muduo/net/TcpConnection.h
@@ -73,9 +73,9 @@
   void forceClose();
   void forceCloseWithDelay(double seconds);
   void setTcpNoDelay(bool on);
-  void startRead(); // Start read from socketfd
-  void stopRead(); // Stop read from socketfd
-  bool isReading() { return reading_; }; // NOT thread safe, may race with start/stopReadInLoop
+  void startRead();
+  void stopRead();
+  bool isReading() const { return reading_; }; // NOT thread safe, may race with start/stopReadInLoop

   void setContext(const boost::any& context)
   { context_ = context; }


moving out processCallsForHeat

moving out processCallsForHeat

--- content/OTRadioLink/utility/OTRadValve_BoilerDriver.h
+++ content/OTRadioLink/utility/OTRadValve_BoilerDriver.h
@@ -34,96 +34,199 @@
 namespace OTRadValve
     {

-// Ticks until locally-controlled boiler should be turned off; boiler should be on while this is positive.
-// Ticks are of the main loop, ie 2s (almost always).
-// Used in hub mode only.
-static uint16_t boilerCountdownTicks;
-// True if boiler should be on.
-static bool isBoilerOn() { return(0 != boilerCountdownTicks); }
-// Minutes that the boiler has been off for, allowing minimum off time to be enforced.
-// Does not roll once at its maximum value (255).
-// DHD20160124: starting at zero forces at least for off time after power-up before firing up boiler (good after power-cut).
-static uint8_t boilerNoCallM;
-// Reducing listening if quiet for a while helps reduce self-heating temperature error
-// (~2C as of 2013/12/24 at 100% RX, ~100mW heat dissipation in V0.2 REV1 box) and saves some energy.
-// Time thresholds could be affected by eco/comfort switch.
-//#define RX_REDUCE_MIN_M 20 // Minimum minutes quiet before considering reducing RX duty cycle listening for call for heat; [1--255], 10--60 typical.
-// IF DEFINED then give backoff threshold to minimise duty cycle.
-//#define RX_REDUCE_MAX_M 240 // Minutes quiet before considering maximally reducing RX duty cycle; ]RX_REDUCE_MIN_M--255], 30--240 typical.
-
-// Set true on receipt of plausible call for heat,
-// to be polled, evaluated and cleared by the main control routine.
-// Marked volatile to allow thread-safe lock-free access.
-static volatile bool receivedCallForHeat;
-// ID of remote caller-for-heat; only valid if receivedCallForHeat is true.
-// Marked volatile to allow access from an ISR,
-// but note that access may only be safe with interrupts disabled as not a byte value.
-static volatile uint16_t receivedCallForHeatID;
-
-// Raw notification of received call for heat from remote (eg FHT8V) unit.
-// This form has a 16-bit ID (eg FHT8V housecode) and percent-open value [0,100].
-// Note that this may include 0 percent values for a remote unit explicitly confirming
-// that is is not, or has stopped, calling for heat (eg instead of replying on a timeout).
-// This is not filtered, and can be delivered at any time from RX data, from a non-ISR thread.
-// Does not have to be thread-/ISR- safe.
-void remoteCallForHeatRX(const uint16_t id, const uint8_t percentOpen)
-  {
-  // TODO: Should be filtering first by housecode
-  // then by individual and tracked aggregate valve-open percentage.
-  // Only individual valve levels used here; no state is retained.
-
-  // Normal minimum single-valve percentage open that is not ignored.
-  // Somewhat higher than typical per-valve minimum,
-  // to help provide boiler with an opportunity to dump heat before switching off.
-  // May be too high to respond to valves with restricted max-open / range.
-  const uint8_t default_minimum = OTRadValve::DEFAULT_VALVE_PC_SAFER_OPEN;
-#ifdef ENABLE_NOMINAL_RAD_VALVE
-  const uint8_t minvro = OTV0P2BASE::fnmax(default_minimum, NominalRadValve.getMinValvePcReallyOpen());
-#else
-  const uint8_t minvro = default_minimum;
-#endif
-
-  // TODO-553: after over an hour of continuous boiler running
-  // raise the percentage threshold to successfully call for heat (for a while).
-  // The aim is to allow a (combi) boiler to have reached maximum efficiency
-  // and to have potentially made a significant difference to room temperature
-  // but then turn off for a short while if demand is a little lower
-  // to allow it to run a little harder/better when turned on again.
-  // Most combis have power far higher than needed to run rads at full blast
-  // and have only limited ability to modulate down,
-  // so may end up cycling anyway while running the circulation pump if left on.
-  // Modelled on DHD habit of having many 15-minute boiler timer segments
-  // in 'off' period even during the day for many many years!
-  //
-  // Note: could also consider pause if mains frequency is low indicating grid stress.
-  const uint8_t boilerCycleWindowMask = 0x3f;
-  const uint8_t boilerCycleWindow = (minuteCount & boilerCycleWindowMask);
-  const bool considerPause = (boilerCycleWindow < (boilerCycleWindowMask >> 2));
-
-  // Equally the threshold could be lowered in the period after a possible pause (TODO-593, TODO-553)
-  // to encourage the boiler to start and run harder
-  // and to get a little closer to target temperatures.
-  const bool encourageOn = !considerPause && (boilerCycleWindow < (boilerCycleWindowMask >> 1));
-
-  // TODO-555: apply some basic hysteresis to help reduce boiler short-cycling.
-  // Try to force a higher single-valve-%age threshold to start boiler if off,
-  // at a level where at least a single valve is moderately open.
-  // Selecting "quick heat" at a valve should immediately pass this,
-  // as should normal warm in cold but newly-occupied room (TODO-593).
-  // (This will not provide hysteresis for very high minimum really-open valve values.)
-  // Be slightly tolerant with the 'moderately open' threshold
-  // to allow quick start from a range of devices (TODO-593)
-  // and in the face of imperfect rounding/conversion to/from percentages over the air.
-  const uint8_t threshold = (!considerPause && (encourageOn || isBoilerOn())) ?
-      minvro : OTV0P2BASE::fnmax(minvro, (uint8_t) (OTRadValve::DEFAULT_VALVE_PC_MODERATELY_OPEN-1));
-
-  if(percentOpen >= threshold)
-    // && FHT8VHubAcceptedHouseCode(command.hc1, command.hc2))) // Accept if house code OK.
+class BoilerCallForHeat
+{
+private:
+    // Set true on receipt of plausible call for heat,
+    // to be polled, evaluated and cleared by the main control routine.
+    // Marked volatile to allow thread-safe lock-free access.
+    volatile bool receivedCallForHeat;
+    // ID of remote caller-for-heat; only valid if receivedCallForHeat is true.
+    // Marked volatile to allow access from an ISR,
+    // but note that access may only be safe with interrupts disabled as not a byte value.
+    volatile uint16_t receivedCallForHeatID;
+
+public:
+    // Minutes that the boiler has been off for, allowing minimum off time to be enforced.
+    // Does not roll once at its maximum value (255).
+    // DHD20160124: starting at zero forces at least for off time after power-up before firing up boiler (good after power-cut).
+    uint8_t boilerNoCallM;
+    // Reducing listening if quiet for a while helps reduce self-heating temperature error
+    // (~2C as of 2013/12/24 at 100% RX, ~100mW heat dissipation in V0.2 REV1 box) and saves some energy.
+    // Time thresholds could be affected by eco/comfort switch.
+    //#define RX_REDUCE_MIN_M 20 // Minimum minutes quiet before considering reducing RX duty cycle listening for call for heat; [1--255], 10--60 typical.
+    // IF DEFINED then give backoff threshold to minimise duty cycle.
+    //#define RX_REDUCE_MAX_M 240 // Minutes quiet before considering maximally reducing RX duty cycle; ]RX_REDUCE_MIN_M--255], 30--240 typical.
+
+    // Ticks until locally-controlled boiler should be turned off; boiler should be on while this is positive.
+    // Ticks are of the main loop, ie 2s (almost always).
+    // Used in hub mode only.
+    uint16_t boilerCountdownTicks;
+
+public:
+    BoilerCallForHeat() : receivedCallForHeat(false), receivedCallForHeatID(0), boilerNoCallM(0), boilerCountdownTicks(0) {}
+    // True if boiler should be on.
+    inline bool isBoilerOn() { return(0 != boilerCountdownTicks); }
+    inline bool isCallForHeatRXed() { return receivedCallForHeat; }
+    inline void setCallForHeatRXed(const bool callForHeat) { receivedCallForHeat = callForHeat; }
+    inline uint16_t getCallForHeatID() { return receivedCallForHeatID; }
+
+    // Raw notification of received call for heat from remote (eg FHT8V) unit.
+    // This form has a 16-bit ID (eg FHT8V housecode) and percent-open value [0,100].
+    // Note that this may include 0 percent values for a remote unit explicitly confirming
+    // that is is not, or has stopped, calling for heat (eg instead of replying on a timeout).
+    // This is not filtered, and can be delivered at any time from RX data, from a non-ISR thread.
+    // Does not have to be thread-/ISR- safe.
+    void remoteCallForHeatRX(const uint16_t id, const uint8_t percentOpen,
+                             const uint8_t minuteCount)
     {
-    receivedCallForHeat = true; // FIXME
-    receivedCallForHeatID = id;
+        // TODO: Should be filtering first by housecode
+        // then by individual and tracked aggregate valve-open percentage.
+        // Only individual valve levels used here; no state is retained.
+
+        // Normal minimum single-valve percentage open that is not ignored.
+        // Somewhat higher than typical per-valve minimum,
+        // to help provide boiler with an opportunity to dump heat before switching off.
+        // May be too high to respond to valves with restricted max-open / range.
+        const uint8_t default_minimum = OTRadValve::DEFAULT_VALVE_PC_SAFER_OPEN;
+//#ifdef ENABLE_NOMINAL_RAD_VALVE  // XXX
+//        const uint8_t minvro = OTV0P2BASE::fnmax(default_minimum, rv.getMinValvePcReallyOpen());
+//#else
+        const uint8_t minvro = default_minimum;
+//#endif
+
+        // TODO-553: after over an hour of continuous boiler running
+        // raise the percentage threshold to successfully call for heat (for a while).
+        // The aim is to allow a (combi) boiler to have reached maximum efficiency
+        // and to have potentially made a significant difference to room temperature
+        // but then turn off for a short while if demand is a little lower
+        // to allow it to run a little harder/better when turned on again.
+        // Most combis have power far higher than needed to run rads at full blast
+        // and have only limited ability to modulate down,
+        // so may end up cycling anyway while running the circulation pump if left on.
+        // Modelled on DHD habit of having many 15-minute boiler timer segments
+        // in 'off' period even during the day for many many years!
+        //
+        // Note: could also consider pause if mains frequency is low indicating grid stress.
+        const uint8_t boilerCycleWindowMask = 0x3f;
+        const uint8_t boilerCycleWindow = (minuteCount & boilerCycleWindowMask);
+        const bool considerPause = (boilerCycleWindow < (boilerCycleWindowMask >> 2));
+
+        // Equally the threshold could be lowered in the period after a possible pause (TODO-593, TODO-553)
+        // to encourage the boiler to start and run harder
+        // and to get a little closer to target temperatures.
+        const bool encourageOn = !considerPause && (boilerCycleWindow < (boilerCycleWindowMask >> 1));
+
+        // TODO-555: apply some basic hysteresis to help reduce boiler short-cycling.
+        // Try to force a higher single-valve-%age threshold to start boiler if off,
+        // at a level where at least a single valve is moderately open.
+        // Selecting "quick heat" at a valve should immediately pass this,
+        // as should normal warm in cold but newly-occupied room (TODO-593).
+        // (This will not provide hysteresis for very high minimum really-open valve values.)
+        // Be slightly tolerant with the 'moderately open' threshold
+        // to allow quick start from a range of devices (TODO-593)
+        // and in the face of imperfect rounding/conversion to/from percentages over the air.
+        const uint8_t threshold = (!considerPause && (encourageOn || isBoilerOn())) ?
+          minvro : OTV0P2BASE::fnmax(minvro, (uint8_t) (OTRadValve::DEFAULT_VALVE_PC_MODERATELY_OPEN-1));
+
+        if(percentOpen >= threshold) {
+        // && FHT8VHubAcceptedHouseCode(command.hc1, command.hc2))) // Accept if house code OK.
+            receivedCallForHeat = true; // FIXME
+            receivedCallForHeatID = id;
+        }
     }
-  }
+
+//    // Process calls for heat, ie turn boiler on and off as appropriate.
+//    // Has control of OUT_HEATCALL if defined(ENABLE_BOILER_HUB).
+//    static void processCallsForHeat(const bool second0)
+//      {
+//      if(inHubMode())
+//        {
+//        // Check if call-for-heat has been received, and clear the flag.
+//        bool _h;
+//        uint16_t _hID; // Only valid if _h is true.
+//        ATOMIC_BLOCK (ATOMIC_RESTORESTATE)
+//          {
+//          _h = receivedCallForHeat;
+//          if(_h)
+//            {
+//            _hID = boilerHub.getCallForHeatID();
+//            receivedCallForHeat = false;
+//            }
+//          }
+//        const bool heardIt = _h;
+//        const uint16_t hcRequest = heardIt ? _hID : 0; // Only valid if heardIt is true.
+//
+//    //    // Don't log call for hear if near overrun,
+//    //    // and leave any error queued for next time.
+//    //    if(OTV0P2BASE::getSubCycleTime() >= nearOverrunThreshold) { } // { tooNearOverrun = true; }
+//    //    else
+//          {
+//          if(heardIt)
+//            {
+//    //        DEBUG_SERIAL_TIMESTAMP();
+//    //        DEBUG_SERIAL_PRINT(' ');
+//            OTV0P2BASE::serialPrintAndFlush(F("CfH ")); // Call for heat from
+//            OTV0P2BASE::serialPrintAndFlush((hcRequest >> 8) & 0xff);
+//            OTV0P2BASE::serialPrintAndFlush(' ');
+//            OTV0P2BASE::serialPrintAndFlush(hcRequest & 0xff);
+//            OTV0P2BASE::serialPrintlnAndFlush();
+//            }
+//          }
+//
+//        // Record call for heat, both to start boiler-on cycle and possibly to defer need to listen again.
+//        // Ignore new calls for heat until minimum off/quiet period has been reached.
+//        // Possible optimisation: may be able to stop RX if boiler is on for local demand (can measure local temp better: less self-heating) and not collecting stats.
+//        if(heardIt)
+//          {
+//          const uint8_t minOnMins = getMinBoilerOnMinutes();
+//          bool ignoreRCfH = false;
+//          if(!isBoilerOn())
+//            {
+//            // Boiler was off.
+//            // Ignore new call for heat if boiler has not been off long enough,
+//            // forcing a time longer than the specified minimum,
+//            // regardless of when second0 happens to be.
+//            // (The min(254, ...) is to ensure that the boiler can come on even if minOnMins == 255.)
+//            // TODO: randomly extend the off-time a little (eg during grid stress) partly to randmonise whole cycle length.
+//            if(boilerNoCallM <= min(254, minOnMins)) { ignoreRCfH = true; }
+//    //        if(OTV0P2BASE::getSubCycleTime() >= nearOverrunThreshold) { } // { tooNearOverrun = true; }
+//    //        else
+//              if(ignoreRCfH) { OTV0P2BASE::serialPrintlnAndFlush(F("RCfH-")); } // Remote call for heat ignored.
+//            else { OTV0P2BASE::serialPrintlnAndFlush(F("RCfH1")); } // Remote call for heat on.
+//            }
+//          if(!ignoreRCfH)
+//            {
+//            const uint16_t onTimeTicks = minOnMins * (uint16_t) (60U / OTV0P2BASE::MAIN_TICK_S);
+//            // Restart count-down time (keeping boiler on) with new call for heat.
+//            boilerCountdownTicks = onTimeTicks;
+//            boilerNoCallM = 0; // No time has passed since the last call.
+//            }
+//          }
+//
+//        // If boiler is on, then count down towards boiler off.
+//        if(isBoilerOn())
+//          {
+//          if(0 == --boilerCountdownTicks)
+//            {
+//            // Boiler should now be switched off.
+//    //        if(OTV0P2BASE::getSubCycleTime() >= nearOverrunThreshold) { } // { tooNearOverrun = true; }
+//    //        else
+//              { OTV0P2BASE::serialPrintlnAndFlush(F("RCfH0")); } // Remote call for heat off
+//            }
+//          }
+//        // Else boiler is off so count up quiet minutes until at max...
+//        else if(second0 && (boilerNoCallM < 255))
+//            { ++boilerNoCallM; }
+//
+//        // Set BOILER_OUT as appropriate for calls for heat.
+//        // Local calls for heat come via the same route (TODO-607).
+//        fastDigitalWrite(OUT_HEATCALL, (isBoilerOn() ? HIGH : LOW));
+//        }
+//      // Force boiler off when not in hub mode.
+//      else { fastDigitalWrite(OUT_HEATCALL, LOW); }
+//      }
+};

 //// Smarter logic for simple on/off boiler output, fully testable.
 //class OnOffBoilerDriverLogic


Staging: comedi: addi-data: tidy up digital input register map defines in hwdrv_apci1564.c

This patch fixes the register map defines for the digital input registers
such that they are all the real offsets to each register, rather than a
mix of real offsets and adders to those offsets.

Further, some of the old defines were being used incorrectly in the
i_APCI1564_Reset() function.  Upon swapping the old defines out for the
new ones in this function, their use has been corrected.

Signed-off-by: Chase Southwood <a63925e3ab29e90ed35149cfe020cfe5d57dbd06@yahoo.com>
Reviewed-by: H Hartley Sweeten <382ff55d8e07d1082d179e669636cd1552da4f36@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
+++ drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
@@ -47,11 +47,6 @@
 #define APCI1564_ADDRESS_RANGE				128

 /* DIGITAL INPUT-OUTPUT DEFINE */
-/* Input defines */
-#define APCI1564_DIGITAL_IP				0x04
-#define APCI1564_DIGITAL_IP_INTERRUPT_MODE1		4
-#define APCI1564_DIGITAL_IP_INTERRUPT_MODE2		8
-#define APCI1564_DIGITAL_IP_IRQ				16

 /* Output defines */
 #define APCI1564_DIGITAL_OP				0x18
@@ -62,9 +57,6 @@
 /* Digital Input IRQ Function Selection */
 #define ADDIDATA_OR					0
 #define ADDIDATA_AND					1
-
-/* Digital Input Interrupt Status */
-#define APCI1564_DIGITAL_IP_INTERRUPT_STATUS		12

 /* Digital Output Interrupt Status */
 #define APCI1564_DIGITAL_OP_INTERRUPT_STATUS		8
@@ -99,6 +91,15 @@
 #define APCI1564_TCW_WARN_TIMEVAL			24
 #define APCI1564_TCW_WARN_TIMEBASE			28

+/*
+ * devpriv->i_IobaseAmcc Register Map
+ */
+#define APCI1564_DI_REG						0x04
+#define APCI1564_DI_INT_MODE1_REG				0x08
+#define APCI1564_DI_INT_MODE2_REG				0x0c
+#define APCI1564_DI_INT_STATUS_REG				0x10
+#define APCI1564_DI_IRQ_REG					0x14
+
 /* Global variables */
 static unsigned int ui_InterruptStatus_1564;
 static unsigned int ui_InterruptData, ui_Type;
@@ -143,31 +144,17 @@
 	if (data[0] == ADDIDATA_ENABLE) {
 		data[2] = data[2] << 4;
 		data[3] = data[3] << 4;
-		outl(data[2],
-			devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-			APCI1564_DIGITAL_IP_INTERRUPT_MODE1);
-		outl(data[3],
-			devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-			APCI1564_DIGITAL_IP_INTERRUPT_MODE2);
+		outl(data[2], devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE1_REG);
+		outl(data[3], devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE2_REG);
 		if (data[1] == ADDIDATA_OR) {
-			outl(0x4,
-				devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-				APCI1564_DIGITAL_IP_IRQ);
+			outl(0x4, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
 		} else {
-			outl(0x6,
-				devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-				APCI1564_DIGITAL_IP_IRQ);
+			outl(0x6, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
 		}
 	} else {
-		outl(0x0,
-			devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-			APCI1564_DIGITAL_IP_INTERRUPT_MODE1);
-		outl(0x0,
-			devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-			APCI1564_DIGITAL_IP_INTERRUPT_MODE2);
-		outl(0x0,
-			devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-			APCI1564_DIGITAL_IP_IRQ);
+		outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE1_REG);
+		outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE2_REG);
+		outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
 	}

 	return insn->n;
@@ -180,7 +167,7 @@
 {
 	struct addi_private *devpriv = dev->private;

-	data[1] = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP);
+	data[1] = inl(devpriv->i_IobaseAmcc + APCI1564_DI_REG);

 	return insn->n;
 }
@@ -329,9 +316,7 @@
 		devpriv->b_TimerSelectMode = ADDIDATA_TIMER;
 		if (data[1] == 1) {
 			outl(0x02, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG);	/* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */
-			outl(0x0,
-				devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-				APCI1564_DIGITAL_IP_IRQ);
+			outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
 			outl(0x0,
 				devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
 				APCI1564_DIGITAL_OP_IRQ);
@@ -648,8 +633,7 @@
 	unsigned int ui_C1, ui_C2, ui_C3, ui_C4;
 	unsigned int ul_Command2 = 0;

-	ui_DI = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-		APCI1564_DIGITAL_IP_IRQ) & 0x01;
+	ui_DI = inl(devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG) & 0x01;
 	ui_DO = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
 		APCI1564_DIGITAL_OP_IRQ) & 0x01;
 	ui_Timer =
@@ -669,17 +653,14 @@
 	}

 	if (ui_DI == 1) {
-		ui_DI = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-			APCI1564_DIGITAL_IP_IRQ);
-		outl(0x0,
-			devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-			APCI1564_DIGITAL_IP_IRQ);
+		ui_DI = inl(devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
+		outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
 		ui_InterruptStatus_1564 =
-			inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +
-			APCI1564_DIGITAL_IP_INTERRUPT_STATUS);
+			inl(devpriv->i_IobaseAmcc + APCI1564_DI_INT_STATUS_REG);
 		ui_InterruptStatus_1564 = ui_InterruptStatus_1564 & 0X000FFFF0;
 		send_sig(SIGIO, devpriv->tsk_Current, 0);	/*  send signal to the sample */
-		outl(ui_DI, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ);	/* enable the interrupt */
+		/* enable the interrupt */
+		outl(ui_DI, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
 		return;
 	}

@@ -829,10 +810,13 @@
 {
 	struct addi_private *devpriv = dev->private;

-	outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_IRQ);	/* disable the interrupts */
-	inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_INTERRUPT_STATUS);	/* Reset the interrupt status register */
-	outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_INTERRUPT_MODE1);	/* Disable the and/or interrupt */
-	outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP_INTERRUPT_MODE2);
+	/* disable the interrupts */
+	outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG);
+	/* Reset the interrupt status register */
+	inl(devpriv->i_IobaseAmcc + APCI1564_DI_INT_STATUS_REG);
+	/* Disable the and/or interrupt */
+	outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE1_REG);
+	outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE2_REG);
 	devpriv->b_DigitalOutputRegister = 0;
 	ui_Type = 0;
 	outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP);	/* Resets the output channels */


NLPUC: Nelder-Mead-c: Fix alignment. And that is all for "c" for the moment.

--- nlp-unconstrained-core/nelder-mead/c/src/nelmin.c
+++ nlp-unconstrained-core/nelder-mead/c/src/nelmin.c
@@ -113,7 +113,7 @@
     rq     = reqmin * dn;

     /* Construction of initial simplex. */
-    L1000:;
+L1000:;

     for (i = 0; i < n; i++) {
         p[i][nn] = start[i];
@@ -153,7 +153,7 @@
         }
     }

-    L2000:;
+L2000:;

     ynewlo = y[INDEX_0];
     ihi    =   INDEX_0;


unused

unused

git-svn-id: ae92b08b608af1c8cefa3e10d2325ea527204e07@19511 3eda493b-6a19-0410-b2e0-ec8ea4dd8fda

--- share/priv.c
+++ share/priv.c
@@ -39,7 +39,7 @@
 }

 void
-sl_drop_privs(int allow_root_uid)
+sl_drop_privs(__unusedx int allow_root_uid)
 {
 	struct passwd *pw;


Fix RR policy connectivity state upon subchannels shutdown

--- src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c
+++ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c
@@ -126,6 +126,8 @@
   size_t num_ready;
   /** how many subchannels are in state TRANSIENT_FAILURE */
   size_t num_transient_failures;
+  /** how many subchannels are in state SHUTDOWN */
+  size_t num_shutdown;
   /** how many subchannels are in state IDLE */
   size_t num_idle;

@@ -425,14 +427,20 @@
   } else if (sd->prev_connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
     GPR_ASSERT(subchannel_list->num_transient_failures > 0);
     --subchannel_list->num_transient_failures;
+  } else if (sd->prev_connectivity_state == GRPC_CHANNEL_SHUTDOWN) {
+    GPR_ASSERT(subchannel_list->num_shutdown > 0);
+    --subchannel_list->num_shutdown;
   } else if (sd->prev_connectivity_state == GRPC_CHANNEL_IDLE) {
     GPR_ASSERT(subchannel_list->num_idle > 0);
     --subchannel_list->num_idle;
   }
+
   if (sd->curr_connectivity_state == GRPC_CHANNEL_READY) {
     ++subchannel_list->num_ready;
   } else if (sd->curr_connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
     ++subchannel_list->num_transient_failures;
+  } else if (sd->curr_connectivity_state == GRPC_CHANNEL_SHUTDOWN) {
+    ++subchannel_list->num_shutdown;
   } else if (sd->curr_connectivity_state == GRPC_CHANNEL_IDLE) {
     ++subchannel_list->num_idle;
   }
@@ -455,7 +463,8 @@
    *    CHECK: sd->curr_connectivity_state == CONNECTING.
    *
    * 3) RULE: ALL subchannels are SHUTDOWN => policy is SHUTDOWN.
-   *    CHECK: p->subchannel_list->num_subchannels = 0.
+   *    CHECK: p->subchannel_list->num_shutdown ==
+   *           p->subchannel_list->num_subchannels.
    *
    * 4) RULE: ALL subchannels are TRANSIENT_FAILURE => policy is
    *    TRANSIENT_FAILURE.
@@ -464,37 +473,38 @@
    * 5) RULE: ALL subchannels are IDLE => policy is IDLE.
    *    CHECK: p->num_idle == p->subchannel_list->num_subchannels.
    */
+  grpc_connectivity_state new_state = sd->curr_connectivity_state;
   rr_subchannel_list *subchannel_list = sd->subchannel_list;
   round_robin_lb_policy *p = subchannel_list->policy;
   if (subchannel_list->num_ready > 0) { /* 1) READY */
     grpc_connectivity_state_set(exec_ctx, &p->state_tracker, GRPC_CHANNEL_READY,
                                 GRPC_ERROR_NONE, "rr_ready");
-    return GRPC_CHANNEL_READY;
+    new_state =  GRPC_CHANNEL_READY;
   } else if (sd->curr_connectivity_state ==
              GRPC_CHANNEL_CONNECTING) { /* 2) CONNECTING */
     grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
                                 GRPC_CHANNEL_CONNECTING, GRPC_ERROR_NONE,
                                 "rr_connecting");
-    return GRPC_CHANNEL_CONNECTING;
-  } else if (p->subchannel_list->num_subchannels == 0) { /* 3) SHUTDOWN */
+    new_state =  GRPC_CHANNEL_CONNECTING;
+  } else if (p->subchannel_list->num_shutdown ==
+             p->subchannel_list->num_subchannels) { /* 3) SHUTDOWN */
     grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
-                                GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error),
-                                "rr_shutdown");
-    return GRPC_CHANNEL_SHUTDOWN;
+                                GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error), "rr_shutdown");
+    new_state =  GRPC_CHANNEL_SHUTDOWN;
   } else if (subchannel_list->num_transient_failures ==
              p->subchannel_list->num_subchannels) { /* 4) TRANSIENT_FAILURE */
     grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
-                                GRPC_CHANNEL_TRANSIENT_FAILURE,
-                                GRPC_ERROR_REF(error), "rr_transient_failure");
-    return GRPC_CHANNEL_TRANSIENT_FAILURE;
+                                GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_ERROR_REF(error),
+                                "rr_transient_failure");
+    new_state =  GRPC_CHANNEL_TRANSIENT_FAILURE;
   } else if (subchannel_list->num_idle ==
              p->subchannel_list->num_subchannels) { /* 5) IDLE */
     grpc_connectivity_state_set(exec_ctx, &p->state_tracker, GRPC_CHANNEL_IDLE,
                                 GRPC_ERROR_NONE, "rr_idle");
-    return GRPC_CHANNEL_IDLE;
-  }
-  /* no change */
-  return sd->curr_connectivity_state;
+    new_state =  GRPC_CHANNEL_IDLE;
+  }
+  GRPC_ERROR_UNREF(error);
+  return new_state;
 }

 static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
@@ -657,8 +667,9 @@
     grpc_connected_subchannel_ping(exec_ctx, target, closure);
     GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, target, "rr_picked");
   } else {
-    GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
-                                              "Round Robin not connected"));
+    GRPC_CLOSURE_SCHED(
+        exec_ctx, closure,
+        GRPC_ERROR_CREATE_FROM_STATIC_STRING("Round Robin not connected"));
   }
 }


ALSA: allocation may fail in	snd_pcm_oss_change_params()

Allocation may fail, show if it did.

Signed-off-by: Roel Kluin <aa9c6213291cec1ff07688554fb7b904b9ffe4e3@gmail.com>
[Additional fix for invalid runtime->oss.prepare flag set by tiwai]
Signed-off-by: Takashi Iwai <4596b3305151c7ee743192a95d394341e3d3b644@suse.de>

--- sound/core/oss/pcm_oss.c
+++ sound/core/oss/pcm_oss.c
@@ -1043,10 +1043,15 @@
 	runtime->oss.channels = params_channels(params);
 	runtime->oss.rate = params_rate(params);

+	vfree(runtime->oss.buffer);
+	runtime->oss.buffer = vmalloc(runtime->oss.period_bytes);
+	if (!runtime->oss.buffer) {
+		err = -ENOMEM;
+		goto failure;
+	}
+
 	runtime->oss.params = 0;
 	runtime->oss.prepare = 1;
-	vfree(runtime->oss.buffer);
-	runtime->oss.buffer = vmalloc(runtime->oss.period_bytes);
 	runtime->oss.buffer_used = 0;
 	if (runtime->dma_area)
 		snd_pcm_format_set_silence(runtime->format, runtime->dma_area, bytes_to_samples(runtime, runtime->dma_bytes));


fix invalid mem access in constant_propagation

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@11880 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

--- compilers/imcc/optimizer.c
+++ compilers/imcc/optimizer.c
@@ -478,7 +478,7 @@
 static int
 constant_propagation(Interp *interpreter, IMC_Unit * unit)
 {
-    Instruction *ins, *ins2, *tmp;
+    Instruction *ins, *ins2, *tmp, *prev;
     int op;
     int i;
     char fullname[128];
@@ -530,21 +530,28 @@
                                 unit, ins2->op, ins2->r, ins2->opsize,
                                 &found);
                             if (found) {
-                                subst_ins(unit, ins2, tmp, 1);
-                                any = 1;
-                                IMCC_debug(interpreter, DEBUG_OPT2," reduced to %I\n", tmp);
+                                prev = ins2->prev;
+                                if (prev) {
+                                    subst_ins(unit, ins2, tmp, 1);
+                                    any = 1;
+                                    IMCC_debug(interpreter, DEBUG_OPT2,
+                                            " reduced to %I\n", tmp);
+                                    ins2 = prev->next;
+                                }
                             } else {
                                 op = check_op(interpreter, fullname, ins2->op,
                                     ins2->r, ins2->n_r, ins2->keys);
                                 if (op < 0) {
                                     ins2->r[i] = old;
-                                    IMCC_debug(interpreter, DEBUG_OPT2," - no %s\n", fullname);
+                                    IMCC_debug(interpreter, DEBUG_OPT2,
+                                            " - no %s\n", fullname);
                                 }
                                 else {
                                     --old->use_count;
                                     ins2->opnum = op;
                                     any = 1;
-                                    IMCC_debug(interpreter, DEBUG_OPT2," -> %I\n", ins2);
+                                    IMCC_debug(interpreter, DEBUG_OPT2,
+                                            " -> %I\n", ins2);
                                 }
                             }
                         }


ASoC: sti: Add uniperipheral header file

Add the Uniperipheral header file for uniperipheral IPs registers definition.

Signed-off-by: Arnaud Pouliquen <b379f9d268ae6bc79bae62bbf7d1708239982b68@st.com>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@kernel.org>


Fixed a bug in dislreagent.c causing crashes on JVMTI class file load event without class name.
Thanks to Peter Junos <petoju@gmail.com> for reporting.

git-svn-id: 9828a123601097aec97c9db06897c34ab9021696@926 f1b219a8-1381-427d-9730-7f2851dc2a88

--- src-shvm-agent/dislreagent.c
+++ src-shvm-agent/dislreagent.c
@@ -1347,6 +1347,13 @@
 	printf("Sending new class (thread %ld)\n", tld_get()->id);
 #endif

+	if (name == NULL) {
+#ifdef DEBUG
+		printf("Skipped class with no name (thread %ld)\n", tld_get()->id);
+#endif
+		return;
+	}
+
 	// *** send new class message ***

 	// tag the class loader - with lock


ALSA: snd-usb: re-order some quirk entries

No code change, just a cosmetic cleanup to keep entries ordered by the
device ID within a block of unique vendor IDs.

Signed-off-by: Daniel Mack <70806a71956ed8873ecff8522779dae1401a1b4a@gmail.com>
Signed-off-by: Takashi Iwai <4596b3305151c7ee743192a95d394341e3d3b644@suse.de>


[pirc] Fix a 64-bitness issue (opcode_t does change size).

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@36097 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

--- compilers/pirc/src/bcgen.c
+++ compilers/pirc/src/bcgen.c
@@ -416,9 +416,9 @@
 */
 void
 create_codesegment(bytecode * const bc, int codesize) {
-    /* allocate enough space. XXX I *think* bytes is /always/ codesize * 4. */
+    /* allocate enough space. */
     bc->interp->code->base.data = (opcode_t *)mem_sys_realloc(bc->interp->code->base.data,
-                                                              codesize * 4);
+                                                              codesize * sizeof (opcode_t));
     /* store the size of the code-segment */
     bc->interp->code->base.size = codesize;


COMP: ITK_DISALLOW_COPY_AND_ASSIGN now unconditionally does '= delete'

ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) deleted the copy constructor and
assignment by means of ITK_DELETED_FUNCTION, whose definition was platform
dependent. With this commit, it does unconditionally do '= delete', without
using ITK_DELETED_FUNCTION. Any C++11 compiler should support '= delete'.

This commit also changed the return type of the deleted assignment operator
from void to TypeName&, which is according to common practice, also in the
C++ std library.

Change-Id: Ia58b98031b3fa57e6b47308f5910da7c2fee58b9

--- Modules/Core/Common/include/itkMacro.h
+++ Modules/Core/Common/include/itkMacro.h
@@ -213,7 +213,7 @@
 //NOTE DEPRECATED should be ITK_NOEXCEPT
 #define ITK_NOEXCEPT_OR_THROW error "Replace ITK_NOEXCEPT_OR_THROW with ITK_NOEXCEPT"
 //NOTE DEPRECATED!  should be ITK_COMPILER_CXX_STATIC_ASSERT
-#define ITK_DELETE_FUNCTION error "Replace ITK_DELETE_FUNCTION with ITK_DELETED_FUNCTION"
+#define ITK_DELETE_FUNCTION error "Replace ITK_DELETE_FUNCTION with = delete"
 //-*-*-*

 // DEPRECATED: These macros are left here for compatibility with remote modules.
@@ -332,8 +332,8 @@
 // prohibits the use of copy construction and operator= functions.
 //
 #define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName)         \
-  TypeName(const TypeName&) ITK_DELETED_FUNCTION;      \
-  void operator=(const TypeName&) ITK_DELETED_FUNCTION
+  TypeName(const TypeName&) = delete;                  \
+  TypeName& operator=(const TypeName&) = delete

 /** Macro used to add standard methods to all classes, mainly type
  * information. */


fix: Remove unused argument declaration [Image]

--- Modules/Image/include/mirtkBinaryVoxelFunction.h
+++ Modules/Image/include/mirtkBinaryVoxelFunction.h
@@ -203,7 +203,7 @@
   Erode(const NeighborhoodOffsets &offsets) : _Offsets(offsets) {}

   template <class T>
-  void operator ()(int i, int j, int k, int l, const T *in, T *out)
+  void operator ()(int i, int j, int k, int, const T *in, T *out)
   {
     const T *ptr2offset;
     T &value = *out;
@@ -231,7 +231,7 @@
   Dilate(const NeighborhoodOffsets &offsets) : _Offsets(offsets) {}

   template <class T>
-  void operator ()(int i, int j, int k, int l, const T *in, T *out)
+  void operator ()(int i, int j, int k, int, const T *in, T *out)
   {
     const T *ptr2offset;
     T &value = *out;


Patching msclr/marshal.h out, since apparently VC++ EE doesn't include it for some reason.

--- source/InternalHelpers.h
+++ source/InternalHelpers.h
@@ -21,8 +21,12 @@
 */
 #pragma once

-#include <msclr/marshal.h>
-#include <msclr/marshal_windows.h>
+//For some dumbass reason, VC++ EE does not include these headers.
+//SlimDX does not need them right now; if it does, just write a
+//new marshal_as based on the header version.
+//#include <msclr/marshal.h>
+//#include <msclr/marshal_windows.h>
+#include <windows.h>

 #define SLIMDX_UNREFERENCED_PARAMETER(P) (P)

@@ -36,6 +40,9 @@
 {
 	namespace interop
 	{
+		template<typename ToType, typename FromType>
+		inline ToType marshal_as(const FromType& from);
+
 		template<>
 		inline System::Drawing::Rectangle marshal_as<System::Drawing::Rectangle, RECT>( const RECT &from )
 		{
@@ -46,7 +53,7 @@
 		inline _To_Type marshal_as(System::Drawing::Rectangle _from_object);

 		template<>
-		inline RECT marshal_as( System::Drawing::Rectangle from )
+		inline RECT marshal_as<RECT>( System::Drawing::Rectangle from )
 		{
 			RECT to;
 			to.left = from.Left;


Add assignment operator for raw pointer

Add assignment operator for raw pointer

--- Modules/Core/include/mitkWeakPointer.h
+++ Modules/Core/include/mitkWeakPointer.h
@@ -71,9 +71,6 @@
       if (this != &other)
       {
         this->RemoveDeleteEventObserver();
-
-        // m_RawPointer is guaranteed not to be nullptr as nullptr assignment
-        // is handled in a separate implementation of the assignment operator.
         m_RawPointer = other.m_RawPointer;
         this->AddDeleteEventObserver();
       }
@@ -85,6 +82,18 @@
     {
       this->RemoveDeleteEventObserver();
       m_RawPointer = nullptr;
+
+      return *this;
+    }
+
+    WeakPointer & operator =(T *other)
+    {
+      if (m_RawPointer != other)
+      {
+        this->RemoveDeleteEventObserver();
+        m_RawPointer = other;
+        this->AddDeleteEventObserver();
+      }

       return *this;
     }


Make uxPortCompareSet into a macro. 25uS -> 24uS

--- components/freertos/port.c
+++ components/freertos/port.c
@@ -263,17 +263,14 @@
  * *bitwise inverse* of the old mem if the mem wasn't written. This doesn't seem to happen on the
  * ESP32, though. (Would show up directly if it did because the magic wouldn't match.)
  */
-uint32_t uxPortCompareSet(volatile uint32_t *mux, uint32_t compare, uint32_t set)
-{
-	__asm__ __volatile__ (
-		"WSR 	    %2,SCOMPARE1 \n" //initialize SCOMPARE1
-		"ISYNC      \n" //wait sync
-		"S32C1I     %0, %1, 0	 \n" //store id into the lock, if the lock is the same as comparel. Otherwise, no write-access
-		:"=r"(set) \
-		:"r"(mux), "r"(compare), "0"(set) \
-		);
-	return set;
-}
+#define uxPortCompareSet(mux, compare, set) \
+		__asm__ __volatile__( \
+			"WSR 	    %2,SCOMPARE1 \n" \
+			"ISYNC      \n" \
+			"S32C1I     %0, %1, 0	 \n"  \
+			:"=r"(*set) \
+			:"r"(mux), "r"(compare), "0"(*set) \
+			); \

 /*
  * For kernel use: Initialize a per-CPU mux. Mux will be initialized unlocked.
@@ -310,7 +307,8 @@
 	irqStatus=portENTER_CRITICAL_NESTED();
 	do {
 		//Lock mux if it's currently unlocked
-		res=uxPortCompareSet(&mux->mux, portMUX_FREE_VAL, (xPortGetCoreID()<<portMUX_VAL_SHIFT)|portMUX_MAGIC_VAL);
+		res=(xPortGetCoreID()<<portMUX_VAL_SHIFT)|portMUX_MAGIC_VAL;
+		uxPortCompareSet(&mux->mux, portMUX_FREE_VAL, &res);
 		//If it wasn't free and we're the owner of the lock, we are locking recursively.
 		if ( (res != portMUX_FREE_VAL) && (((res&portMUX_VAL_MASK)>>portMUX_VAL_SHIFT) == xPortGetCoreID()) ) {
 			//Mux was already locked by us. Just bump the recurse count by one.
@@ -362,7 +360,8 @@
 	if ( (mux->mux & portMUX_MAGIC_MASK) != portMUX_MAGIC_VAL ) ets_printf("ERROR: vPortCPUReleaseMutex: mux %p is uninitialized (0x%X)!\n", mux, mux->mux);
 #endif
 	//Unlock mux if it's currently locked with a recurse count of 0
-	res=uxPortCompareSet(&mux->mux, (xPortGetCoreID()<<portMUX_VAL_SHIFT)|portMUX_MAGIC_VAL, portMUX_FREE_VAL);
+	res=portMUX_FREE_VAL;
+	uxPortCompareSet(&mux->mux, (xPortGetCoreID()<<portMUX_VAL_SHIFT)|portMUX_MAGIC_VAL, &res);

 	if ( res == portMUX_FREE_VAL ) {
 #ifdef CONFIG_FREERTOS_PORTMUX_DEBUG


Update NSDictionary+Extension.h

Update NSDictionary+Extension.h

--- LPExts/NSDictionary+Extension.h
+++ LPExts/NSDictionary+Extension.h
@@ -11,7 +11,7 @@

 #pragma mark -
 - (NSString *)KVStr;
-- (NSDictionary *)sortWithComparisonType:(NSComparisonResult)comparisonType;
+- (NSArray *)sortWithComparisonType:(NSComparisonResult)comparisonType;
 + (NSDictionary *)dictFromStr:(NSString *)str;

 @end


Reserved some future HIC IDs.

Reserved some future HIC IDs.

--- source/daplink/daplink.h
+++ source/daplink/daplink.h
@@ -50,6 +50,8 @@
 #define DAPLINK_BUILD_KEY_IF        0x9B939E8F
 #define DAPLINK_BUILD_KEY_BL        0x9B939D93

+//! @name HIC IDs
+//@{
 #define DAPLINK_HIC_ID_K20DX        0x97969900
 #define DAPLINK_HIC_ID_KL26         0x97969901
 #define DAPLINK_HIC_ID_LPC11U35     0x97969902
@@ -59,6 +61,14 @@
 #define DAPLINK_HIC_ID_MAX32625     0x97969906
 #define DAPLINK_HIC_ID_MAX32550     0x97969907
 #define DAPLINK_HIC_ID_STM32F103XB  0x97969908
+#define DAPLINK_HIC_ID_K26F         0x97969909
+#define DAPLINK_HIC_ID_K22F         0x9796990A
+#define DAPLINK_HIC_ID_KL27Z        0x9796990B // reserving for future use
+#define DAPLINK_HIC_ID_LPC54606     0x9796990C // reserving for future use
+#define DAPLINK_HIC_ID_STM32F723IE  0x9796990D // reserving for future use
+#define DAPLINK_HIC_ID_LPC55S69     0x97969920 // reserving for future use
+#define DAPLINK_HIC_ID_PSOC5        0x2E127069
+//@}

 #define DAPLINK_INFO_OFFSET         0x20


Fix for error: comma at end of enumerator list

--- PWG3/vertexingHF/AliCFHeavyFlavourTaskMultiVar.h
+++ PWG3/vertexingHF/AliCFHeavyFlavourTaskMultiVar.h
@@ -37,7 +37,7 @@

   enum {
     kStepGenerated       = 0,
-    kStepReconstructed   = 1,
+    kStepReconstructed   = 1
   };

   AliCFHeavyFlavourTaskMultiVar();


Corrected doxygen [ci skip]

Corrected doxygen [ci skip]

--- OpenSim/Actuators/CoordinateActuator.h
+++ OpenSim/Actuators/CoordinateActuator.h
@@ -38,9 +38,9 @@
 //                           COORDINATE ACTUATOR
 //==============================================================================
 /**
- * An actuator that applies a generalized force to along a generalized
- * a generalized coordinate, which is proportional to its input control.
- * It replaces the GeneralizeForce class implemented by Frank C. Anderson
+ * An actuator that applies a generalized force in the direction of a
+ * generalized coordinate. The applied generalized force is proportional to the
+ * input control of the CoordinateActuator. Replaces the GeneralizedForce class.
  *
  * @author Ajay Seth
  * @author Frank C. Anderson


[CpmlPrimitive] Doc typos

[CpmlPrimitive] Doc typos

--- cpml/cpml-segment.c
+++ cpml/cpml-segment.c
@@ -174,8 +174,8 @@
  * @cr: the destination cairo context
  *
  * Appends the path of @segment to @cr. The segment is "flattened",
- * that is the %CAIRO_PATH_ARC_TO primitive are approximated by one
- * or more %CAIRO_PATH_CURVE_TO throught cpml_arc_to_cairo(). Check
+ * that is %CAIRO_PATH_ARC_TO primitives are approximated by one
+ * or more %CAIRO_PATH_CURVE_TO using cpml_arc_to_cairo(). Check
  * its documentation for further details.
  **/
 void


thread debug

thread debug

--- cpneural/cp-optim.h
+++ cpneural/cp-optim.h
@@ -196,22 +196,34 @@
     return test(x, &states, batchsize);
 }

+void statePr(string s) {
+    cerr << s << endl;
+    std::flush(cerr);
+}
+
 t_cppl Layer::workerThread(MatrixN *pxb, t_cppl* pstates, int id) {
     t_cppl cache;
     t_cppl grads;
+    string ns="<"+std::to_string(id)+">:";
+    statePr(ns+"Enter");
     if (pstates->find("y") == pstates->end()) {
         cerr << "pstates does not contain y -> fatal!" << endl;
     }
     MatrixN yb=*((*pstates)["y"]);
+    statePr(ns+"Forward");
     forward(*pxb, &cache, pstates, id);
+    statePr(ns+"Loss");
     floatN thisloss=loss(&cache, pstates);
     lossQueueMutex.lock();
     lossQueue.push(thisloss);
     lossQueueMutex.unlock();
+    statePr(ns+"Backward");
     backward(yb, &cache, pstates, &grads, id);
+    statePr(ns+"Delete");
     cppl_delete(&cache);
     cppl_delete(pstates);
     free(pxb);
+    statePr(ns+"Exit");
     return grads;
 }


NULL pointer close 해도 에러나지 않는다.

NULL pointer close 해도 에러나지 않는다.

--- modules/mod_ifs/mod_ifs.c
+++ modules/mod_ifs/mod_ifs.c
@@ -314,6 +314,11 @@

 	if ( ifs_set == NULL || !ifs_set[indexdb->set].set )
 		return DECLINE;
+
+	if ( indexdb == NULL ) {
+		warn("indexdb is NULL. nothing to close");
+		return SUCCESS;
+	}
 	ifs = (ifs_t*) indexdb->db;

     for(i = 0; i < MAX_SEGMENT_COUNT*MAX_SECTOR_COUNT; i++) {


* h264: bug fix (give valid date + split at the right place).

--- modules/packetizer/h264.c
+++ modules/packetizer/h264.c
@@ -67,10 +67,6 @@
     vlc_bool_t b_slice;
     block_t    *p_frame;

-    int64_t      i_dts;
-    int64_t      i_pts;
-    unsigned int i_flags;
-
     vlc_bool_t   b_sps;

     /* avcC data */
@@ -103,7 +99,8 @@
     NAL_SLICE_IDR   = 5,    /* ref_idc != 0 */
     NAL_SEI         = 6,    /* ref_idc == 0 */
     NAL_SPS         = 7,
-    NAL_PPS         = 8
+    NAL_PPS         = 8,
+    NAL_AU_DELIMITER= 9
     /* ref_idc == 0 for 6,9,10,11,12 */
 };

@@ -152,9 +149,6 @@
     p_sys->bytestream = block_BytestreamInit( p_dec );
     p_sys->b_slice = VLC_FALSE;
     p_sys->p_frame = NULL;
-    p_sys->i_dts   = 0;
-    p_sys->i_pts   = 0;
-    p_sys->i_flags = 0;
     p_sys->b_sps   = VLC_FALSE;

     p_sys->i_nal_type = -1;
@@ -294,6 +288,10 @@
                     p_sys->i_state = STATE_NOSYNC;
                     break;
                 }
+#if 0
+                msg_Dbg( p_dec, "pts="I64Fd" dts="I64Fd,
+                         p_pic->i_pts, p_pic->i_dts );
+#endif

                 /* So p_block doesn't get re-added several times */
                 *pp_block = block_BytestreamPop( &p_sys->bytestream );
@@ -418,6 +416,16 @@

     const int i_nal_ref_idc = (p_frag->p_buffer[3] >> 5)&0x03;
     const int i_nal_type = p_frag->p_buffer[3]&0x1f;
+
+#define OUTPUT \
+    do {                                                \
+        p_pic = block_ChainGather( p_sys->p_frame );    \
+        p_pic->i_length = 0;    /* FIXME */             \
+                                                        \
+        p_sys->p_frame = NULL;                          \
+        p_sys->b_slice = VLC_FALSE;                     \
+    } while(0)
+

     if( p_sys->b_slice && !p_sys->b_sps )
     {
@@ -507,22 +515,9 @@
         p_sys->i_nal_type = i_nal_type;

         if( b_pic && p_sys->b_slice )
-        {
-            p_pic = block_ChainGather( p_sys->p_frame );
-            p_pic->i_dts = p_sys->i_dts;
-            p_pic->i_pts = p_sys->i_pts;
-            p_pic->i_length = 0;    /* FIXME */
-            p_pic->i_flags = p_sys->i_flags;
-
-            /* Reset context */
-            p_sys->p_frame = NULL;
-            p_sys->b_slice = VLC_FALSE;
-        }
+            OUTPUT;

         p_sys->b_slice = VLC_TRUE;
-        p_sys->i_flags = i_pic_flags;
-        p_sys->i_dts   = p_frag->i_dts;
-        p_sys->i_pts   = p_frag->i_pts;

         free( dec );
     }
@@ -639,6 +634,10 @@
         }

         free( dec );
+
+
+        if( p_sys->b_slice )
+            OUTPUT;
     }
     else if( i_nal_type == NAL_PPS )
     {
@@ -647,7 +646,19 @@

         /* TODO */
         msg_Dbg( p_dec, "found NAL_PPS" );
-    }
+
+        if( p_sys->b_slice )
+            OUTPUT;
+    }
+    else if( i_nal_type == NAL_AU_DELIMITER ||
+             i_nal_type == NAL_SEI ||
+             ( i_nal_type >= 13 && i_nal_type <= 18 ) )
+    {
+        if( p_sys->b_slice )
+            OUTPUT;
+    }
+
+#undef OUTPUT

     /* Append the block */
     block_ChainAppend( &p_sys->p_frame, p_frag );


Fix 700140: Ask LCMS transform to copy alpha channels.

--- source/fitz/colorspace.c
+++ source/fitz/colorspace.c
@@ -1945,7 +1945,7 @@
 }

 static void
-icc_conv_pixmap(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots)
+icc_conv_pixmap(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_extras)
 {
 	fz_colorspace *srcs = src->colorspace;
 	fz_colorspace *dsts = dst->colorspace;
@@ -1957,7 +1957,7 @@
 	/* Handle DeviceGray to CMYK as K only. See note in Section 6.3 of PDF spec 1.7. */
 	if (fz_colorspace_is_device_gray(ctx, srcs) && fz_colorspace_is_cmyk(ctx, dsts))
 	{
-		fast_gray_to_cmyk(ctx, dst, src, prf, default_cs, color_params, copy_spots);
+		fast_gray_to_cmyk(ctx, dst, src, prf, default_cs, color_params, copy_extras);
 		return;
 	}

@@ -1986,7 +1986,11 @@
 	inputpos = src->samples;
 	outputpos = dst->samples;

-	link = fz_get_icc_link(ctx, dsts, dst->s + dst->alpha, srcs, src->s + src->alpha, prf, color_params, 1, copy_spots, &src_n);
+	/* If we have alpha channels, set copy_extras so that the LCMS transform also copies the alpha channels. */
+	if (src->alpha || dst->alpha)
+		copy_extras = 1;
+
+	link = fz_get_icc_link(ctx, dsts, dst->s + dst->alpha, srcs, src->s + src->alpha, prf, color_params, 1, copy_extras, &src_n);

 	if (link->is_identity)
 	{


Bug 696648: Send -sm output to stderr.

Bug 696648: Send -sm output to stderr.

Thanks to Marcos for spotting the missing case.

--- source/fitz/draw-glyph.c
+++ source/fitz/draw-glyph.c
@@ -453,8 +453,8 @@
 {
 	fz_glyph_cache *cache = ctx->glyph_cache;

-	printf("Glyph Cache Size: %d\n", cache->total);
+	fprintf(stderr, "Glyph Cache Size: %d\n", cache->total);
 #ifndef NDEBUG
-	printf("Glyph Cache Evictions: %d (%d bytes)\n", cache->num_evictions, cache->evicted);
+	fprintf(stderr, "Glyph Cache Evictions: %d (%d bytes)\n", cache->num_evictions, cache->evicted);
 #endif
 }


Fix compile error

Fix compile error

--- search/ConstrainedEnvironment.h
+++ search/ConstrainedEnvironment.h
@@ -118,7 +118,7 @@
   public:
     CollisionDetector(double radius):ConflictDetector<State>(),agentRadius(radius){}
     inline virtual bool HasConflict(unsigned agentA, State const& A1, State const& A2, unsigned agentB, State const& B1, State const& B2)const{
-      return collisionCheck3D(A1,A2,B1,B2);
+      return collisionCheck3D(A1,A2,B1,B2,agentRadius);
     }
     inline virtual Constraint<State>* GetConstraint(State const& A1, State const& A2, State const& B1, State const& B2)const{
        return new Collision<State>(B1,B2,agentRadius);


Fix path.

Fix path.

--- crypto/libdes/rpw.c
+++ crypto/libdes/rpw.c
@@ -54,10 +54,12 @@
  * derivative of this code cannot be changed.  i.e. this code cannot simply be
  * copied and put under another distribution licence
  * [including the GNU Public Licence.]
+ *
+ * $FreeBSD$
  */

 #include <stdio.h>
-#include <openssl/des.h>
+#include <des.h>

 int main(int argc, char *argv[])
 	{


Remove useless assignments

Remove useless assignments

--- test/default/xchacha20.c
+++ test/default/xchacha20.c
@@ -54,7 +54,7 @@
     sodium_hex2bin(out, crypto_core_hchacha20_OUTPUTBYTES,
                    "934d941d78eb9bfc2f0376f7ccd4a11ecf0c6a44104618a9749ef47fe97037a2",
                    crypto_core_hchacha20_OUTPUTBYTES * 2 + 1, NULL, NULL, NULL);
-    tv = &tvs[0];
+
     crypto_core_hchacha20(out2, in, key, constant);
     assert(memcmp(out, out2, crypto_core_hchacha20_OUTPUTBYTES) == 0);

@@ -128,7 +128,7 @@
         assert(sodium_is_zero(out, out_len));
         sodium_free(out2);
     }
-    tv = &tvs[0];
+
     out2 = (unsigned char *) sodium_malloc(0);
     crypto_stream_xchacha20(out2, 0, nonce, key);
     crypto_stream_xchacha20_xor(out2, out2, 0, nonce, key);


1.add: 新增 listDup/listSearchKey 实现和测试代码

1.add: 新增 listDup/listSearchKey 实现和测试代码

--- zhack_test/hello_adlist.c
+++ zhack_test/hello_adlist.c
@@ -259,8 +259,104 @@
     zfree(iter);
 }

-// list *listDup(list *orig);
-// listNode *listSearchKey(list *list, void *key);
+/*
+ * 复制整个链表, 内存不足时返回 NULL，成功饭返回副本。
+ *
+ * 如果链表结构的 `dup` （list->dup）函数设置了拷贝函数(. listSetDupMethod(m) ，则使用拷贝函数复制结点值。
+ * 否则，新节点和原结点共同使用同一指针。
+ *
+ * 无论结果成功或失败，都不修改原来的链表。
+ *
+ * Duplicate the whole list. On out of memory NULL is returned.
+ * On success a copy of the original list is returned.
+ *
+ * The 'Dup' method set with listSetDupMethod() function is used
+ * to copy the node value. Otherwise the same pointer value of
+ * the original node is used as value of the copied node.
+ *
+ * The original list both on success or error is never modified. */
+list *listDup(list *orig)
+{
+    list *copy;
+    listIter *iter;
+    listNode *node;
+    copy = listCreate();
+    if (copy == NULL) return NULL;
+
+    copy->dup = orig->dup;
+    copy->free = orig->free;
+    copy->match = orig->match;
+
+    iter = listGetIterator(orig, AL_START_HEAD);
+    while((node = listNext(iter)) != NULL) {
+        void *value;
+        if (copy->dup) {
+            value = copy->dup(node->value);
+            // 拷贝失败，返回 NULL
+            if (value == NULL) {
+                listRelease(copy);
+                listReleaseIterator(iter);
+                return NULL;
+            }
+        } else {
+            //没有 指定拷贝函数，则共享数据指针
+            value = node->value;
+        }
+
+        //添加结点到链表尾部
+        if (listAddNodeTail(copy, value) == NULL){
+            listRelease(copy);
+            listReleaseIterator(iter);
+            return NULL;
+        }
+    }
+
+    listReleaseIterator(iter);
+
+    return copy;
+}
+
+/**
+ * 链表的查找函数，在链表的节点中查找含有给定key值的结点。
+ * 匹配算法使用'list->match'函数（如果设置了match函数的话）。
+ * 如果没有指定'match'函数，则所有结点的比较都使用`value`指针来和key指针比较
+ *
+ * 如果成功，返回第一个匹配节点的指针，否则返回NULL。
+ *
+ * Search the list for a node matching a given key.
+ * The match is performed using the 'match' method
+ * set with listSetMatchMethod(). If no 'match' method
+ * is set, the 'value' pointer of every node is directly
+ * compared with the 'key' pointer.
+ *
+ * On success the first matching node pointer is returned
+ * (search starts from head). If no matching node exists
+ * NULL is returned.
+ */
+listNode *listSearchKey(list *list, void *key)
+{
+    listNode *node;
+    listIter *iter = listGetIterator(list,AL_START_HEAD);
+    if (iter == NULL) return NULL;
+
+    while((node = listNext(iter)) != NULL) {
+        // 使用 match 自定义比较函数来判断
+        if (list->match && list->match(node->value, key) == 0) {
+            // printf("Find-1->%s\n", (char *)node->value);
+            break;
+        } else if(node->value == key) {
+            // printf("Find-2->%s\n", (char *)node->value);
+            break;
+        }
+        // else{
+        //     printf("not found\n");
+        // }
+    }
+
+    listReleaseIterator(iter);
+
+    return node;
+}
 // listNode *listIndex(list *list, long index);
 // void listRewind(list *list, listIter *li);
 // void listRewindTail(list *list, listIter *li);
@@ -280,6 +376,12 @@
     sdsfree((sds)value);
     return 1;
 }
+
+void* sdsdup_wapper(void *ptr)
+{
+    return sdsdup((const sds)ptr);
+}
+

 int main()
 {
@@ -361,6 +463,42 @@
         && pList->head == NULL)
     listRelease(pList);

+    //7. listDup() test
+    pList = listCreate();
+    pList->free = sdsfree_wrapper;
+    pList->dup = sdsdup_wapper;
+    pList = listAddNodeHead(pList,sdsnew("Hello"));
+    pList = listAddNodeTail(pList,sdsnew("world"));
+    pList = listInsertNode(pList,pList->head,sdsnew("goodbyte"), 1);
+    list *pList2 = listDup(pList);
+    test_cond_ext("listDup() test",
+        pList->len == pList2->len
+        && pList != pList2
+        && pList->match == pList2->match
+        && pList->dup == pList2->dup
+        && pList->free == pList2->free
+        && pList->match == pList2->match
+        && memcmp(pList2->head->next->value, "goodbyte\0", 9) == 0
+        && memcmp(pList2->head->value, "Hello\0", 6) == 0
+        && memcmp(pList2->tail->value, "world\0", 6) == 0
+        )
+    // printf("%s\n", (char*)pList2->head->next->value);
+    // 8. listSearchKey(list, key) test
+    {
+        printf("%s,%s,%s\n",
+             (char*) pList->head->value
+            ,(char*) pList->head->next->value
+            ,(char*) pList->head->next->next->value
+            );
+
+        listNode* key = pList->head->next;
+
+        listNode* node = listSearchKey(pList, key->value);
+        if(node)
+            printf("%s,%s\n",(char*) key->value, (char*)node->value);
+    }
+    listRelease(pList);
+    listRelease(pList2);
     return 0;
 }
 #endif


Improve documentation on Kronecker product module.

--- unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h
+++ unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h
@@ -12,8 +12,15 @@
 #ifndef KRONECKER_TENSOR_PRODUCT_H
 #define KRONECKER_TENSOR_PRODUCT_H

-namespace Eigen {
-
+namespace Eigen {
+
+/*!
+ * \ingroup KroneckerProduct_Module
+ *
+ * \brief The base class of dense and sparse Kronecker product.
+ *
+ * \tparam Derived is the derived type.
+ */
 template<typename Derived>
 class KroneckerProductBase : public ReturnByValue<Derived>
 {
@@ -27,6 +34,7 @@
     typedef typename Traits::Index Index;

   public:
+    /*! \brief Constructor. */
     KroneckerProductBase(const Lhs& A, const Rhs& B)
       : m_A(A), m_B(B)
     {}
@@ -34,12 +42,20 @@
     inline Index rows() const { return m_A.rows() * m_B.rows(); }
     inline Index cols() const { return m_A.cols() * m_B.cols(); }

+    /*!
+     * This overrides ReturnByValue::coeff because this function is
+     * efficient enough.
+     */
     Scalar coeff(Index row, Index col) const
     {
       return m_A.coeff(row / m_B.rows(), col / m_B.cols()) *
              m_B.coeff(row % m_B.rows(), col % m_B.cols());
     }

+    /*!
+     * This overrides ReturnByValue::coeff because this function is
+     * efficient enough.
+     */
     Scalar coeff(Index i) const
     {
       EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
@@ -52,6 +68,8 @@
 };

 /*!
+ * \ingroup KroneckerProduct_Module
+ *
  * \brief Kronecker tensor product helper class for dense matrices
  *
  * This class is the return value of kroneckerProduct(MatrixBase,
@@ -80,6 +98,8 @@
 };

 /*!
+ * \ingroup KroneckerProduct_Module
+ *
  * \brief Kronecker tensor product helper class for sparse matrices
  *
  * If at least one of the operands is a sparse matrix expression,


disabled signal-base event handler temporarily

--- package/konoha.eventlistener/eventlistener_glue.c
+++ package/konoha.eventlistener/eventlistener_glue.c
@@ -391,15 +391,15 @@
 	SignalEventQueue = (LocalQueue *)PLATAPI malloc_i(sizeof(LocalQueue));
 	LocalQueue_init(kctx, SignalEventQueue);

-	FILE *pid;
+	//FILE *pid;
 	pthread_t t;
-	if(!(pid = fopen("/usr/local/minikonoha/dse/pid", "w"))) {
-		fprintf(stderr, "cannot open pid file\n");
-		exit(1);
-	}
-	fprintf(pid, "%d", getpid());
-	fflush(pid);
-	fclose(pid);
+	//if(!(pid = fopen("/usr/local/minikonoha/dse/pid", "w"))) {
+	//	fprintf(stderr, "cannot open pid file\n");
+	//	exit(1);
+	//}
+	//fprintf(pid, "%d", getpid());
+	//fflush(pid);
+	//fclose(pid);
 	pthread_create(&t, NULL, signalEventListener, (void *)kctx);
 }


(toString(int)) : Fix a bug.

(toString(int)) : Fix a bug.

--- www/utf.h
+++ www/utf.h
@@ -221,7 +221,7 @@
 inline std::u16string toString(int value)
 {
     if (value < 0)
-        return u"-" + toString(-value);
+        return u"-" + toString(static_cast<unsigned int>(-value));
     else
         return toString(static_cast<unsigned int>(value));
 }


untested: fix for locking

untested: fix for locking

--- zipscript/src/race-file.c
+++ zipscript/src/race-file.c
@@ -883,7 +883,7 @@
  * Not yet fully functional, but we're getting there.
  * progtype == a code for what program calls the lock is found in constants.h
  * force_lock == int used to suggest/force a lock on the file.
- *		set to 1 to suggest a lock, >1 to force a lock.
+ *		set to 1 to suggest a lock,2 to force a lock, 3 to put in queue.
  */

 int
@@ -911,6 +911,7 @@
 		hd.data_qcurrent = 0;
 		write(fd, &hd, sizeof(HEADDATA));
 		close(fd);
+		d_log("create_lock: lock set.\n");
 		return 0;
 	} else {
 		read(fd, &hd, sizeof(HEADDATA));
@@ -922,8 +923,8 @@
 					d_log("create_lock: Data is already locked - putting you in queue.\n");
 					hd.data_queue++;
 					raceI->data_queue = hd.data_queue;
-				} else
-					d_log("create_lock: Data is already locked.\n");
+				} // else
+					// d_log("create_lock: Data is already locked.\n");
 				lseek(fd, 0L, SEEK_SET);
 				write(fd, &hd, sizeof(HEADDATA));
 				close(fd);
@@ -931,12 +932,12 @@
 			}
 		}
 		if (!hd.data_in_use) {
-			if (force_lock == 3 && queue) {
+			if (force_lock == 3 && hd.data_queue) {
 				d_log("create_lock: Data is already locked - putting you in queue.\n");
 				hd.data_queue++;
 				raceI->data_queue = hd.data_queue;
 			} else if (hd.data_queue && queue != hd.data_qcurrent && force_lock != 2) {
-				d_log("create_lock: You are still queued - please wait.\n");
+				// d_log("create_lock: You are still queued - please wait.\n");
 				lseek(fd, 0L, SEEK_SET);
 				write(fd, &hd, sizeof(HEADDATA));
 				close(fd);
@@ -961,6 +962,7 @@
 		close(fd);
 		raceI->data_in_use = progtype;
 		raceI->data_type = 0;
+		d_log("create_lock: lock set.\n");
 		return 0;
 	}
 }
@@ -986,7 +988,7 @@
 		hd.data_qcurrent++;
 	if (hd.data_queue <= hd.data_qcurrent)
 		hd.data_queue = hd.data_qcurrent = 0;
-d_log("queue: %d - qcurrent: %d\n", hd.data_queue, hd.data_qcurrent);
+	d_log("remove_lock: queue: %d/%d\n", hd.data_qcurrent, hd.data_queue);
 	lseek(fd, 0L, SEEK_SET);
 	write(fd, &hd, sizeof(HEADDATA));
 	close(fd);


erthink: add and use `__nosanitize_enum` for `DEFINE_ENUM_FLAG_OPERATORS` ops.

--- erthink_defs.h
+++ erthink_defs.h
@@ -720,6 +720,14 @@

 //------------------------------------------------------------------------------

+#ifndef __nosanitize_enum
+#if __has_attribute(no_sanitize)
+#define __nosanitize_enum __attribute((__no_sanitize__("enum")))
+#else
+#define __nosanitize_enum
+#endif
+#endif /* __nosanitize_enum */
+
 /* Oh, below are some songs and dances since:
  *  - C++ requires explicit definition of the necessary operators.
  *  - the proper implementation of DEFINE_ENUM_FLAG_OPERATORS for C++ required
@@ -739,32 +747,40 @@
 #else
 /* C always allows these operators for enums */
 #define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
-#endif /* __cpp_constexpr */
+#endif /* CONSTEXPR_ENUM_FLAGS_OPERATIONS */

 /// Define operator overloads to enable bit operations on enum values that are
 /// used to define flags (based on Microsoft's DEFINE_ENUM_FLAG_OPERATORS).
 #define DEFINE_ENUM_FLAG_OPERATORS(ENUM)                                       \
   extern "C++" {                                                               \
-  cxx01_constexpr ENUM operator|(ENUM a, ENUM b) {                             \
+  __nosanitize_enum cxx01_constexpr ENUM operator|(ENUM a, ENUM b) {           \
     return ENUM(unsigned(a) | unsigned(b));                                    \
   }                                                                            \
-  cxx14_constexpr ENUM &operator|=(ENUM &a, ENUM b) { return a = a | b; }      \
-  cxx01_constexpr ENUM operator&(ENUM a, ENUM b) {                             \
+  __nosanitize_enum cxx14_constexpr ENUM &operator|=(ENUM &a, ENUM b) {        \
+    return a = a | b;                                                          \
+  }                                                                            \
+  __nosanitize_enum cxx01_constexpr ENUM operator&(ENUM a, ENUM b) {           \
     return ENUM(unsigned(a) & unsigned(b));                                    \
   }                                                                            \
-  cxx01_constexpr ENUM operator&(ENUM a, unsigned b) {                         \
+  __nosanitize_enum cxx01_constexpr ENUM operator&(ENUM a, unsigned b) {       \
     return ENUM(unsigned(a) & b);                                              \
   }                                                                            \
-  cxx01_constexpr ENUM operator&(unsigned a, ENUM b) {                         \
+  __nosanitize_enum cxx01_constexpr ENUM operator&(unsigned a, ENUM b) {       \
     return ENUM(a & unsigned(b));                                              \
   }                                                                            \
-  cxx14_constexpr ENUM &operator&=(ENUM &a, ENUM b) { return a = a & b; }      \
-  cxx14_constexpr ENUM &operator&=(ENUM &a, unsigned b) { return a = a & b; }  \
+  __nosanitize_enum cxx14_constexpr ENUM &operator&=(ENUM &a, ENUM b) {        \
+    return a = a & b;                                                          \
+  }                                                                            \
+  __nosanitize_enum cxx14_constexpr ENUM &operator&=(ENUM &a, unsigned b) {    \
+    return a = a & b;                                                          \
+  }                                                                            \
   cxx01_constexpr unsigned operator~(ENUM a) { return ~unsigned(a); }          \
-  cxx01_constexpr ENUM operator^(ENUM a, ENUM b) {                             \
+  __nosanitize_enum cxx01_constexpr ENUM operator^(ENUM a, ENUM b) {           \
     return ENUM(unsigned(a) ^ unsigned(b));                                    \
   }                                                                            \
-  cxx14_constexpr ENUM &operator^=(ENUM &a, ENUM b) { return a = a ^ b; }      \
+  __nosanitize_enum cxx14_constexpr ENUM &operator^=(ENUM &a, ENUM b) {        \
+    return a = a ^ b;                                                          \
+  }                                                                            \
   }
 #else /* __cplusplus */
 /* nope for C since it always allows these operators for enums */


esp32/moduos: Add uos.ilistdir() function.

--- esp32/moduos.c
+++ esp32/moduos.c
@@ -102,6 +102,7 @@
     { MP_ROM_QSTR(MP_QSTR_dupterm_notify), MP_ROM_PTR(&os_dupterm_notify_obj) },
     #endif
     #if MICROPY_VFS
+    { MP_ROM_QSTR(MP_QSTR_ilistdir), MP_ROM_PTR(&mp_vfs_ilistdir_obj) },
     { MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&mp_vfs_listdir_obj) },
     { MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&mp_vfs_mkdir_obj) },
     { MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&mp_vfs_rmdir_obj) },


debug

debug

--- simplefork.c
+++ simplefork.c
@@ -206,11 +206,11 @@

 PHP_METHOD(Process, start)
 {
-	zval is_alive = call_user_function(NULL, *getThis(), isAlive, NULL, 0 ,NULL TSRMLS_CC);
-	zend_bool alive = Z_BVAL_P(is_alive);
-	if(alive){
-		zend_throw_exception(simplefork_exception_entry, "the process is running already", 0 TSRMLS_CC);
-	}
+//	zval is_alive = call_user_function(NULL, *getThis(), isAlive, NULL, 0 ,NULL TSRMLS_CC);
+//	zend_bool alive = Z_BVAL_P(is_alive);
+//	if(alive){
+//		zend_throw_exception(simplefork_exception_entry, "the process is running already", 0 TSRMLS_CC);
+//	}
 }

 PHP_METHOD(Process, on)


Patch for 107323 - fix compiler warnings

--- security/nss/lib/base/tracker.c
+++ security/nss/lib/base/tracker.c
@@ -298,7 +298,6 @@
 )
 {
   PZLock *lock;
-  PRIntn count;

   if( (nssPointerTracker *)NULL == tracker ) {
     nss_SetError(NSS_ERROR_INVALID_POINTER);


now checking more data

now checking more data

--- nc_test4/tst_gfs_data_1.c
+++ nc_test4/tst_gfs_data_1.c
@@ -154,6 +154,10 @@
 	value_pfull_loc[i] = mpi_rank * 100 + i;
     for (i = 0; i < phalf_loc_size; i++)
 	value_phalf_loc[i] = mpi_rank * 100 + i;
+    for (i = 0; i < grid_xt_loc_size; i++)
+	value_grid_xt_loc[i] = mpi_rank * 100 + i;
+    for (i = 0; i < grid_yt_loc_size; i++)
+	value_grid_yt_loc[i] = mpi_rank * 100 + i;
     for (j = 0; j < lon_yt_loc_size; j++)
     {
 	for(i = 0; i < lon_xt_loc_size; i++)
@@ -364,9 +368,13 @@

 		    /* Check grid_xt data. */
 		    if (nc_get_vara_double(ncid, varid[0], &grid_xt_start, &grid_xt_loc_size, value_grid_xt_loc_in)) ERR;
+		    for (i = 0; i < grid_xt_loc_size; i++)
+			if (value_grid_xt_loc_in[i] != value_grid_xt_loc[i]) ERR;

 		    /* Check grid_yt data. */
 		    if (nc_get_vara_double(ncid, varid[2], &grid_yt_start, &grid_yt_loc_size, value_grid_yt_loc_in)) ERR;
+		    for (i = 0; i < grid_yt_loc_size; i++)
+			if (value_grid_yt_loc_in[i] != value_grid_yt_loc[i]) ERR;

                     /* /\* Check state of compression. *\/ */
                     /* if (!f) */


Bug 526231: Fix the leak of newStr in sdb_GetAttributeValueNoLock. TBR=rrelyea.

--- security/nss/lib/softoken/sdb.c
+++ security/nss/lib/softoken/sdb.c
@@ -844,6 +844,8 @@
 	}

 	sqlerr = sqlite3_prepare_v2(sqlDB, newStr, -1, &stmt, NULL);
+	sqlite3_free(newStr);
+	newStr = NULL;
 	if (sqlerr == SQLITE_ERROR) {
 	    template[i].ulValueLen = -1;
 	    error = CKR_ATTRIBUTE_TYPE_INVALID;


testing two unlimited dims

testing two unlimited dims

--- nc_test4/tst_unlim_vars.c
+++ nc_test4/tst_unlim_vars.c
@@ -161,6 +161,7 @@
 #define VAR_NAME "Superman"
         int ncid, varid, dimid[NDIM2];
         int data = TEST_VAL_42;
+        int data_in;
         size_t index[NDIM2] = {1, 1};
         char name_in[NC_MAX_NAME + 1];
         size_t len_in;
@@ -187,6 +188,8 @@
         if (len_in != 2) ERR;
         if (nc_inq_dim(ncid, 1, NULL, &len_in)) ERR;
         if (len_in != 2) ERR;
+        if (nc_var_var1_int(ncid, 0, index, &data_in)) ERR;
+        if (data_in != data) ERR;
         if (nc_close(ncid)) ERR;

     }


updater_utils: fix implicit conversion to enum wp_state

The getter for HWWP implicitly converted the integer returned by
crossystem to an `enum wp_state`. This only worked because of the
particular values assigned to the enum values, so explicitly convert
instead.

BUG=b:223291615
BRANCH=none
TEST=builds

Change-Id: Ib572733f8b05a5a992f09ba98050a7eab5e3bcce
Signed-off-by: Nikolai Artemiev <ae95c3c53a91f37eed715bc8c4b874a04007f68d@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3540784
Reviewed-by: Julius Werner <4d12f06cff3725783b352157673a720bc67c4afe@chromium.org>
Reviewed-by: Edward O'Callaghan <5ed2e9bf3d98d5f12a86c198971e1dafd1bbd008@chromium.org>
Tested-by: Edward O'Callaghan <5ed2e9bf3d98d5f12a86c198971e1dafd1bbd008@chromium.org>

--- futility/updater_utils.c
+++ futility/updater_utils.c
@@ -419,7 +419,7 @@
 static int host_get_wp_hw(void)
 {
 	/* wpsw refers to write protection 'switch', not 'software'. */
-	return VbGetSystemPropertyInt("wpsw_cur");
+	return VbGetSystemPropertyInt("wpsw_cur") ? WP_ENABLED : WP_DISABLED;
 }

 /* A helper function to return "fw_vboot2" system property. */