Use vres as result in emulator to make it more clear

--- src/emulate.c
+++ src/emulate.c
@@ -1927,24 +1927,25 @@

         switch(vt) {
         case VT_32:
-            v1.val = ((uint32_t) v1.val + (uint32_t) v2.val);
+            vres.val = ((uint32_t) v1.val + (uint32_t) v2.val);
             break;

         case VT_64:
-            v1.val = v1.val + v2.val;
+            vres.val = v1.val + v2.val;
             break;

         default:
             setEmulatorError(c, instr, ET_UnsupportedOperands, 0);
             return;
         }
-
+        vres.type = vt;
         cs = combineState(v1.state.cState, v2.state.cState, 0);
-        initMetaState(&(v1.state), cs);
-        // for capture we need state of original dst, do it before setting dst
-        captureBinaryOp(c, instr, es, &v1);
-        setOpValue(&v1, es, &(instr->dst));
-        setOpState(v1.state, es, &(instr->dst));
+        initMetaState(&(vres.state), cs);
+
+        // for capture we need state of dst, do before setting dst
+        captureBinaryOp(c, instr, es, &vres);
+        setOpValue(&vres, es, &(instr->dst));
+        setOpState(vres.state, es, &(instr->dst));
         break;

     case IT_CALL: {
@@ -2035,12 +2036,12 @@
         default: assert(0);
         }
         assert(opValType(&(instr->src)) == opValType(&(instr->dst)));
-        getOpValue(&v1, es, &(instr->src));
-        captureCMov(c, instr, es, &v1, es->flag_state[ft], cond);
+        getOpValue(&vres, es, &(instr->src));
+        captureCMov(c, instr, es, &vres, es->flag_state[ft], cond);
         // FIXME? if cond state unknown, set destination state always to unknown
         if (cond == true) {
-            setOpValue(&v1, es, &(instr->dst));
-            setOpState(v1.state, es, &(instr->dst));
+            setOpValue(&vres, es, &(instr->dst));
+            setOpState(vres.state, es, &(instr->dst));
         }
         break;
     }
@@ -2062,24 +2063,27 @@

     case IT_DEC:
         getOpValue(&v1, es, &(instr->dst));
+
+        vres.type = v1.type;
+        initMetaState(&(vres.state), v1.state.cState);
         switch(instr->dst.type) {
         case OT_Reg32:
         case OT_Ind32:
-            v1.val = (uint32_t)(((int32_t) v1.val) - 1);
+            vres.val = (uint32_t)(((int32_t) v1.val) - 1);
             break;

         case OT_Reg64:
         case OT_Ind64:
-            v1.val = (uint64_t)(((int64_t) v1.val) - 1);
+            vres.val = (uint64_t)(((int64_t) v1.val) - 1);
             break;

         default:
             setEmulatorError(c, instr, ET_UnsupportedOperands, 0);
             return;
         }
-        captureUnaryOp(c, instr, es, &v1);
-        setOpValue(&v1, es, &(instr->dst));
-        setOpState(v1.state, es, &(instr->dst));
+        captureUnaryOp(c, instr, es, &vres);
+        setOpValue(&vres, es, &(instr->dst));
+        setOpState(vres.state, es, &(instr->dst));
         break;

     case IT_IMUL:
@@ -2163,24 +2167,27 @@
     }
     case IT_INC:
         getOpValue(&v1, es, &(instr->dst));
+
+        vres.type = v1.type;
+        initMetaState(&(vres.state), v1.state.cState);
         switch(instr->dst.type) {
         case OT_Reg32:
         case OT_Ind32:
-            v1.val = (uint32_t)(((int32_t) v1.val) + 1);
+            vres.val = (uint32_t)(((int32_t) v1.val) + 1);
             break;

         case OT_Reg64:
         case OT_Ind64:
-            v1.val = (uint64_t)(((int64_t) v1.val) + 1);
+            vres.val = (uint64_t)(((int64_t) v1.val) + 1);
             break;

         default:
             setEmulatorError(c, instr, ET_UnsupportedOperands, 0);
             return;
         }
-        captureUnaryOp(c, instr, es, &v1);
-        setOpValue(&v1, es, &(instr->dst));
-        setOpState(v1.state, es, &(instr->dst));
+        captureUnaryOp(c, instr, es, &vres);
+        setOpValue(&vres, es, &(instr->dst));
+        setOpState(vres.state, es, &(instr->dst));
         break;

     case IT_JO:
@@ -2409,15 +2416,15 @@
         case OT_Reg32:
         case OT_Reg64:
             assert(opIsInd(&(instr->src)));
-            getOpAddr(&v1, es, &(instr->src));
+            getOpAddr(&vres, es, &(instr->src));
             if (opValType(&(instr->dst)) == VT_32) {
-                v1.val = (uint32_t) v1.val;
-                v1.type = VT_32;
+                vres.val = (uint32_t) vres.val;
+                vres.type = VT_32;
             }
-            captureLea(c, instr, es, &v1);
+            captureLea(c, instr, es, &vres);
             // may overwrite a state needed for correct capturing
-            setOpValue(&v1, es, &(instr->dst));
-            setOpState(v1.state, es, &(instr->dst));
+            setOpValue(&vres, es, &(instr->dst));
+            setOpState(vres.state, es, &(instr->dst));
             break;

         default:assert(0);
@@ -2445,42 +2452,39 @@
     }

     case IT_MOV:
-    case IT_MOVSX: // converting move
+    case IT_MOVSX: { // converting move
+        ValType dst_t = opValType(&(instr->dst));
+        getOpValue(&vres, es, &(instr->src));
+
         switch(instr->src.type) {
         case OT_Reg32:
         case OT_Ind32:
-        case OT_Imm32: {
-            ValType dst_t = opValType(&(instr->dst));
+        case OT_Imm32:
             assert(dst_t == VT_32 || dst_t == VT_64);
-            getOpValue(&v1, es, &(instr->src));
             if (dst_t == VT_64) {
                 // also a regular mov may sign-extend: imm32->64
                 // assert(instr->type == IT_MOVSX);
                 // sign extend lower 32 bit to 64 bit
-                v1.val = (int64_t) (int32_t) v1.val;
-                v1.type = VT_64;
+                vres.val = (int64_t) (int32_t) vres.val;
+                vres.type = VT_64;
             }
-            captureMov(c, instr, es, &v1);
-            setOpValue(&v1, es, &(instr->dst));
-            setOpState(v1.state, es, &(instr->dst));
-            break;
-        }
+            break;

         case OT_Reg64:
         case OT_Ind64:
         case OT_Imm64:
-            assert(opValType(&(instr->dst)) == VT_64);
-            getOpValue(&v1, es, &(instr->src));
-            captureMov(c, instr, es, &v1);
-            setOpValue(&v1, es, &(instr->dst));
-            setOpState(v1.state, es, &(instr->dst));
+            assert(dst_t == VT_64);
             break;

         default:
             setEmulatorError(c, instr, ET_UnsupportedOperands, 0);
             return;
         }
-        break;
+        captureMov(c, instr, es, &vres);
+        setOpValue(&vres, es, &(instr->dst));
+        setOpState(vres.state, es, &(instr->dst));
+        break;
+    }

     case IT_NOP:
         // nothing to do
@@ -2599,42 +2603,46 @@
         getOpValue(&v1, es, &(instr->dst));
         getOpValue(&v2, es, &(instr->src));

-        switch(opValType(&(instr->dst))) {
+        vt = opValType(&(instr->dst));
+        vres.type = vt;
+        cs = combineState(v1.state.cState, v2.state.cState, 0);
+        initMetaState(&(vres.state), cs);
+        switch(vt) {
         case VT_8:
             switch (instr->type) {
-            case IT_SHL: v1.val = (uint8_t) (v1.val << (v2.val & 7)); break;
-            case IT_SHR: v1.val = (uint8_t) (v1.val >> (v2.val & 7)); break;
+            case IT_SHL: vres.val = (uint8_t) (v1.val << (v2.val & 7)); break;
+            case IT_SHR: vres.val = (uint8_t) (v1.val >> (v2.val & 7)); break;
             case IT_SAR:
-                v1.val = (uint8_t) ((int8_t)v1.val >> (v2.val & 7)); break;
+                vres.val = (uint8_t) ((int8_t)v1.val >> (v2.val & 7)); break;
             default: assert(0);
             }
             break;

         case VT_16:
             switch (instr->type) {
-            case IT_SHL: v1.val = (uint16_t) (v1.val << (v2.val & 15)); break;
-            case IT_SHR: v1.val = (uint16_t) (v1.val >> (v2.val & 15)); break;
+            case IT_SHL: vres.val = (uint16_t) (v1.val << (v2.val & 15)); break;
+            case IT_SHR: vres.val = (uint16_t) (v1.val >> (v2.val & 15)); break;
             case IT_SAR:
-                v1.val = (uint16_t) ((int16_t)v1.val >> (v2.val & 15)); break;
+                vres.val = (uint16_t) ((int16_t)v1.val >> (v2.val & 15)); break;
             default: assert(0);
             }
             break;

         case VT_32:
             switch (instr->type) {
-            case IT_SHL: v1.val = (uint32_t) (v1.val << (v2.val & 31)); break;
-            case IT_SHR: v1.val = (uint32_t) (v1.val >> (v2.val & 31)); break;
+            case IT_SHL: vres.val = (uint32_t) (v1.val << (v2.val & 31)); break;
+            case IT_SHR: vres.val = (uint32_t) (v1.val >> (v2.val & 31)); break;
             case IT_SAR:
-                v1.val = (uint32_t) ((int32_t)v1.val >> (v2.val & 31)); break;
+                vres.val = (uint32_t) ((int32_t)v1.val >> (v2.val & 31)); break;
             default: assert(0);
             }
             break;

         case VT_64:
             switch (instr->type) {
-            case IT_SHL: v1.val = v1.val << (v2.val & 63); break;
-            case IT_SHR: v1.val = v1.val >> (v2.val & 63); break;
-            case IT_SAR: v1.val = ((int64_t)v1.val >> (v2.val & 63)); break;
+            case IT_SHL: vres.val = v1.val << (v2.val & 63); break;
+            case IT_SHR: vres.val = v1.val >> (v2.val & 63); break;
+            case IT_SAR: vres.val = ((int64_t)v1.val >> (v2.val & 63)); break;
             default: assert(0);
             }
             break;
@@ -2643,10 +2651,10 @@
             setEmulatorError(c, instr, ET_UnsupportedOperands, 0);
             return;
         }
-        v1.state.cState = combineState(v1.state.cState, v2.state.cState, 0);
-        captureBinaryOp(c, instr, es, &v1);
-        setOpValue(&v1, es, &(instr->dst));
-        setOpState(v1.state, es, &(instr->dst));
+
+        captureBinaryOp(c, instr, es, &vres);
+        setOpValue(&vres, es, &(instr->dst));
+        setOpState(vres.state, es, &(instr->dst));
         break;

     case IT_SUB:
@@ -2671,23 +2679,24 @@

         switch(vt) {
         case VT_32:
-            v1.val = ((uint32_t) v1.val - (uint32_t) v2.val);
+            vres.val = ((uint32_t) v1.val - (uint32_t) v2.val);
             break;

         case VT_64:
-            v1.val = v1.val - v2.val;
+            vres.val = v1.val - v2.val;
             break;

         default:
             setEmulatorError(c, instr, ET_UnsupportedOperands, 0);
             return;
         }
-
-        v1.state.cState = combineState(v1.state.cState, v2.state.cState, 0);
+        vres.type = vt;
+        cs = combineState(v1.state.cState, v2.state.cState, 0);
+        initMetaState(&(vres.state), cs);
         // for capturing we need state of original dst, do before setting dst
-        captureBinaryOp(c, instr, es, &v1);
-        setOpValue(&v1, es, &(instr->dst));
-        setOpState(v1.state, es, &(instr->dst));
+        captureBinaryOp(c, instr, es, &vres);
+        setOpValue(&vres, es, &(instr->dst));
+        setOpState(vres.state, es, &(instr->dst));
         break;

     case IT_TEST:
@@ -2706,18 +2715,21 @@
         getOpValue(&v2, es, &(instr->src));

         assert(v1.type == v2.type);
-        v1.state.cState = setFlagsBit(es, instr->type, &v1, &v2,
-                                      opIsEqual(&(instr->dst), &(instr->src)));
+        cs = setFlagsBit(es, instr->type, &v1, &v2,
+                         opIsEqual(&(instr->dst), &(instr->src)));
         switch(instr->type) {
-        case IT_AND: v1.val = v1.val & v2.val; break;
-        case IT_XOR: v1.val = v1.val ^ v2.val; break;
-        case IT_OR:  v1.val = v1.val | v2.val; break;
+        case IT_AND: vres.val = v1.val & v2.val; break;
+        case IT_XOR: vres.val = v1.val ^ v2.val; break;
+        case IT_OR:  vres.val = v1.val | v2.val; break;
         default: assert(0);
         }
+        vres.type = v1.type;
+        initMetaState(&(vres.state), cs);
+
         // for capturing we need state of original dst
-        captureBinaryOp(c, instr, es, &v1);
-        setOpValue(&v1, es, &(instr->dst));
-        setOpState(v1.state, es, &(instr->dst));
+        captureBinaryOp(c, instr, es, &vres);
+        setOpValue(&vres, es, &(instr->dst));
+        setOpState(vres.state, es, &(instr->dst));
         break;

     case IT_ADDSS:


sql cache: Free all unused connections at deinit.

--HG--
branch : HEAD

--- src/lib-sql/sql-db-cache.c
+++ src/lib-sql/sql-db-cache.c
@@ -67,19 +67,23 @@
 	ctx->cache->unused_count--;
 }

-static void sql_db_cache_drop_oldest(struct sql_db_cache *cache)
+static void sql_db_cache_free_tail(struct sql_db_cache *cache)
 {
 	struct sql_db *db;
 	struct sql_db_cache_context *ctx;

-	while (cache->unused_count >= cache->max_unused_connections) {
-		db = cache->unused_tail;
-		ctx = SQL_DB_CACHE_CONTEXT(db);
-		sql_db_cache_unlink(ctx);
+	db = cache->unused_tail;
+	ctx = SQL_DB_CACHE_CONTEXT(db);
+	sql_db_cache_unlink(ctx);

-		i_free(ctx->key);
-		ctx->orig_deinit(db);
-	}
+	i_free(ctx->key);
+	ctx->orig_deinit(db);
+}
+
+static void sql_db_cache_drop_oldest(struct sql_db_cache *cache)
+{
+	while (cache->unused_count >= cache->max_unused_connections)
+		sql_db_cache_free_tail(cache);
 }

 struct sql_db *
@@ -134,6 +138,8 @@
 	struct sql_db_cache *cache = *_cache;

 	*_cache = NULL;
+	while (cache->unused_tail != NULL)
+		sql_db_cache_free_tail(cache);
 	hash_table_destroy(&cache->dbs);
 	i_free(cache);
 }


Change Uname#sysname to Uname.sysname

Change Uname#sysname to Uname.sysname

--- src/mrb_uname.c
+++ src/mrb_uname.c
@@ -7,6 +7,8 @@
 */

 #include "mruby.h"
+#include "mruby/variable.h"
+#include "mruby/class.h"
 #include "mruby/data.h"
 #include "mrb_uname.h"
 #include <sys/utsname.h>
@@ -21,42 +23,46 @@
   "mrb_uname_data", mrb_free,
 };

-static mrb_value mrb_uname_init(mrb_state *mrb, mrb_value self)
+static mrb_value mrb_uname_wrap(mrb_state *mrb, struct RClass *uname,
+    mrb_uname_data *data)
 {
-  mrb_uname_data *data;
+    return mrb_obj_value(Data_Wrap_Struct(mrb, uname, &mrb_uname_data_type,
+          data));
+}
+
+static mrb_uname_data *mrb_uname_get_uname_data(mrb_state *mrb, mrb_value self)
+{
   struct utsname uname_b;
+  mrb_uname_data *data = NULL;
+  mrb_sym uname_sym = mrb_intern_lit(mrb, "@@uname");

-  data = (mrb_uname_data *)DATA_PTR(self);
-  if (data) {
-    mrb_free(mrb, data);
+  if (mrb_cv_defined(mrb, self, uname_sym)) {
+    Data_Get_Struct(mrb, mrb_cv_get(mrb, self, uname_sym),
+          &mrb_uname_data_type, data);
+  } else {
+    data = (mrb_uname_data *)mrb_malloc(mrb, sizeof(mrb_uname_data));
+    if (uname(&uname_b) != 0) {
+      mrb_raise(mrb, E_RUNTIME_ERROR, "uname failed");
+    }
+    data->uname_b = uname_b;
+    mrb_cv_set(mrb, self, uname_sym,
+        mrb_uname_wrap(mrb, mrb_class_ptr(self), data));
   }
-  DATA_TYPE(self) = &mrb_uname_data_type;
-  DATA_PTR(self) = NULL;
-
-  data = (mrb_uname_data *)mrb_malloc(mrb, sizeof(mrb_uname_data));
-  if (uname(&uname_b) != 0) {
-    mrb_raise(mrb, E_RUNTIME_ERROR, "uname failed");
-  }
-
-  data->uname_b = uname_b;
-  DATA_PTR(self) = data;
-
-  return self;
+  return data;
 }

 static mrb_value mrb_uname_sysname(mrb_state *mrb, mrb_value self)
 {
-  mrb_uname_data *data = DATA_PTR(self);
-
+  mrb_uname_data *data = mrb_uname_get_uname_data(mrb, self);
   return mrb_str_new_cstr(mrb, data->uname_b.sysname);
 }

 void mrb_mruby_uname_gem_init(mrb_state *mrb)
 {
     struct RClass *uname;
+
     uname = mrb_define_class(mrb, "Uname", mrb->object_class);
-    mrb_define_method(mrb, uname, "initialize", mrb_uname_init, MRB_ARGS_REQ(1));
-    mrb_define_method(mrb, uname, "sysname", mrb_uname_sysname, MRB_ARGS_NONE());
+    mrb_define_class_method(mrb, uname, "sysname", mrb_uname_sysname, MRB_ARGS_NONE());
     DONE;
 }


rethink logic

rethink logic

git-svn-id: 18bf4e4f0ca11a3471e5785d6da82074410339c6@20783 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6

--- src/enchant.c
+++ src/enchant.c
@@ -346,12 +346,10 @@
 		{
 			(*dict->add_to_personal) (dict, word, len);
 		}
-	else
-		{
-			/* emulate a personal dictionary backend if one is not provided for */
-			session = (EnchantSession*)dict->enchant_private_data;
-			enchant_session_add_personal (session, word, len);
-		}
+
+	/* add to enchant-specific backend regardless */
+	session = (EnchantSession*)dict->enchant_private_data;
+	enchant_session_add_personal (session, word, len);
 }

 /**


The attached patch handles the case where a registry entry exists but it
is the empty string. From Eric Albright.

git-svn-id: 18bf4e4f0ca11a3471e5785d6da82074410339c6@22290 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6

--- src/enchant.c
+++ src/enchant.c
@@ -100,7 +100,7 @@
                 char * enchant_path;

 		enchant_path = g_build_filename (home_dir, ENCHANT_USER_PATH_EXTENSION, NULL);
-                if (enchant_path && !g_file_test (enchant_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
+        if (enchant_path && !g_file_test (enchant_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
 			{
 				(void)g_remove (enchant_path);
 				g_mkdir (enchant_path, 0700);
@@ -124,7 +124,7 @@
 	/* Look for explicitly set registry values */
 	module_dir = enchant_get_registry_value ("Config", "Module_Dir");
 	if (module_dir)
-		return module_dir;
+		        return module_dir;

 	/* Dynamically locate library and search for modules relative to it. */
 	prefix = enchant_get_prefix_dir();
@@ -153,7 +153,7 @@
 	/* Look for explicitly set registry values */
 	ordering_dir = enchant_get_registry_value ("Config", "Data_Dir");
 	if (ordering_dir)
-		return ordering_dir;
+		        return ordering_dir;

 	/* Dynamically locate library and search for files relative to it. */
 	prefix = enchant_get_prefix_dir();
@@ -171,6 +171,9 @@
 #endif
 }

+/*
+ * Returns: the value if it exists and is not an empty string ("") or %null otherwise. Must be free'd.
+ */
 static char *
 enchant_get_registry_value_ex (int current_user, const char * const prefix, const char * const key)
 {
@@ -183,10 +186,10 @@
 	unsigned long lType;
 	DWORD dwSize;
 	char* keyName;
-  WCHAR* wszValue = NULL;
+    WCHAR* wszValue = NULL;
 	char* szValue = NULL;
-  gunichar2 * uKeyName;
-  gunichar2 * uKey;
+    gunichar2 * uKeyName;
+    gunichar2 * uKey;

 	if (current_user)
 		baseKey = HKEY_CURRENT_USER;
@@ -194,8 +197,8 @@
 		baseKey = HKEY_LOCAL_MACHINE;

 	keyName = g_strdup_printf("Software\\Enchant\\%s", prefix);
-  uKeyName = g_utf8_to_utf16 (keyName, -1, NULL, NULL, NULL);
-  uKey = g_utf8_to_utf16 (key, -1, NULL, NULL, NULL);
+    uKeyName = g_utf8_to_utf16 (keyName, -1, NULL, NULL, NULL);
+    uKey = g_utf8_to_utf16 (key, -1, NULL, NULL, NULL);

 	if(RegOpenKeyEx(baseKey, uKeyName, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
 		{
@@ -206,12 +209,14 @@
 					RegQueryValueEx(hKey, uKey, NULL, &lType, (LPBYTE) wszValue, &dwSize);
 				}
 		}
-  szValue = wszValue == NULL? NULL: g_utf16_to_utf8 (wszValue, -1, NULL, NULL, NULL);
-
-  g_free(keyName);
-  g_free(uKeyName);
-  g_free(uKey);
-  g_free(wszValue);
+
+    if(wszValue && *wszValue)
+        szValue = g_utf16_to_utf8 (wszValue, -1, NULL, NULL, NULL);
+
+    g_free(keyName);
+    g_free(uKeyName);
+    g_free(uKey);
+    g_free(wszValue);

 	return szValue;
 #endif
@@ -222,7 +227,7 @@
  * @prefix: Your category, such as "Ispell" or "Myspell"
  * @key: The tag within your category that you're interested in
  *
- * Returns: the value if it exists, or %null otherwise. Must be free'd.
+ * Returns: the value if it exists and is not an empty string ("") or %null otherwise. Must be free'd.
  *
  * This API is private to the providers.
  */
@@ -230,10 +235,14 @@
 enchant_get_registry_value (const char * const prefix, const char * const key)
 {
 	char *val;
+
+    g_return_val_if_fail (prefix, NULL);
+    g_return_val_if_fail (key, NULL);
+
 	val = enchant_get_registry_value_ex(1, prefix, key);
 	if(val == NULL) {
 		val = enchant_get_registry_value_ex (0, prefix, key);
-	}
+        }
 	return val;
 }

@@ -248,7 +257,7 @@
 ENCHANT_MODULE_EXPORT (char *)
 enchant_get_user_home_dir (void)
 {
-	const char * home_dir;
+    const char* home_dir;

 	home_dir = enchant_get_registry_value_ex (1, "Config", "Home_Dir");
 	if (home_dir)
@@ -538,7 +547,7 @@

 	if (len < 0)
 		len = strlen (word);
-
+
 	session = (EnchantSession*)dict->enchant_private_data;
 	enchant_session_clear_error (session);

@@ -584,13 +593,13 @@

 	/* Check for suggestions from personal dictionary */
 	if(session->personal)
-		pwl_suggs = enchant_pwl_suggest(session->personal, word, len, &n_pwl_suggs);
+		    pwl_suggs = enchant_pwl_suggest(session->personal, word, len, &n_pwl_suggs);

 	/* Check for suggestions from provider dictionary */
 	if (dict->suggest)
 		{
-			dict_suggs = (*dict->suggest) (dict, word, len,
-							&n_dict_suggs);
+			dict_suggs = (*dict->suggest) (dict, word, len,
+                            &n_dict_suggs);
 		}

 	/* Clone suggestions if there are any */
@@ -698,7 +707,7 @@
 	if (len < 0)
 		len = strlen (word);

-	session = (EnchantSession*)dict->enchant_private_data;
+    session = (EnchantSession*)dict->enchant_private_data;
 	enchant_session_clear_error (session);

 	enchant_session_add (session, word, len);
@@ -778,7 +787,7 @@
 enchant_dict_free_string_list (EnchantDict * dict, char **string_list)
 {
 	g_return_if_fail (string_list);
-	g_strfreev (string_list);
+    g_strfreev(string_list);
 }

 /**
@@ -826,7 +835,7 @@
 		{
 			module = (GModule *) provider->enchant_private_data;
 			file = g_module_name (module);
-			name = (*provider->identify) (provider);
+		    name = (*provider->identify) (provider);
 			desc = (*provider->describe) (provider);
 		}
 	else
@@ -891,13 +900,13 @@
 							    && init_func)
 								{
 									provider = init_func ();
-									if (provider)
-										{
+                                            if(provider)
+                                                {
 											provider->enchant_private_data = (void *) module;
 											provider->owner = broker;
 											broker->provider_list = g_slist_append (broker->provider_list, (gpointer)provider);
-										}
-								}
+                                                }
+                                        }
 							else
 								{
 									g_module_close (module);
@@ -919,9 +928,9 @@
 					    && conf_func)
 						{
 							conf_func (provider, dir_name);
+                                }
 						}
 				}
-		}

 	g_dir_close (dir);
 }
@@ -1312,7 +1321,7 @@
 			provider = (EnchantProvider *) list->data;
 			module = (GModule *) provider->enchant_private_data;

-			name = (*provider->identify) (provider);
+		    name = (*provider->identify) (provider);
 			desc = (*provider->describe) (provider);
 			file = g_module_name (module);

@@ -1488,7 +1497,7 @@
 enchant_broker_dict_exists (EnchantBroker * broker,
 			    const char * const tag)
 {
-	char * normalized_tag;
+    char * normalized_tag;
 	int exists = 0;

 	g_return_val_if_fail (broker, 0);
@@ -1654,16 +1663,16 @@
 	/* Dynamically locate library and return containing directory */
 	HINSTANCE hInstance = GetModuleHandle(L"libenchant");
 	if(hInstance != NULL)
-		{
-			WCHAR dll_path[MAX_PATH];
+    {
+		WCHAR dll_path[MAX_PATH];

-			if(GetModuleFileName(hInstance,dll_path,MAX_PATH))
-      {
-        gchar* utf8_dll_path = g_utf16_to_utf8 (dll_path, -1, NULL, NULL, NULL);
-				prefix = g_path_get_dirname(utf8_dll_path);
-        g_free(utf8_dll_path);
-      }
-		}
+        if(GetModuleFileName(hInstance,dll_path,MAX_PATH))
+        {
+            gchar* utf8_dll_path = g_utf16_to_utf8 (dll_path, -1, NULL, NULL, NULL);
+			prefix = g_path_get_dirname(utf8_dll_path);
+            g_free(utf8_dll_path);
+        }
+	}
 #elif defined(ENABLE_BINRELOC)
 	/* Use standard binreloc PREFIX macro */
 	prefix = gbr_find_prefix(NULL);


if pipe handler deletes the pipe... be safe!

SVN revision: 53323

--- src/lib/ecore/ecore_pipe.c
+++ src/lib/ecore/ecore_pipe.c
@@ -57,8 +57,10 @@
    const void       *data;
    Ecore_Pipe_Cb     handler;
    unsigned int      len;
+   int               handling;
    size_t            already_read;
    void             *passed_data;
+   Eina_Bool         delete_me : 1;
 };

@@ -326,6 +328,8 @@
         ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_del");
         return NULL;
      }
+   p->delete_me = EINA_TRUE;
+   if (p->handling > 0) return (void *)p->data;
    if (p->fd_handler) ecore_main_fd_handler_del(p->fd_handler);
    if (p->fd_read != PIPE_FD_INVALID) pipe_close(p->fd_read);
    if (p->fd_write != PIPE_FD_INVALID) pipe_close(p->fd_write);
@@ -468,17 +472,28 @@
 }

 /* Private function */
+static void
+_ecore_pipe_unhandle(Ecore_Pipe *p)
+{
+   p->handling--;
+   if (p->delete_me)
+     {
+        ecore_pipe_del(p);
+     }
+}

 static Eina_Bool
 _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
 {
    Ecore_Pipe  *p;
    double       start_time;
+   int          i;

    p = (Ecore_Pipe *)data;
    start_time = ecore_time_get();
-
-   do
+
+   p->handling++;
+   for (i = 0; i < 16; i++)
      {
         ssize_t       ret;

@@ -505,6 +520,7 @@
                   pipe_close(p->fd_read);
                   p->fd_read = PIPE_FD_INVALID;
                   p->fd_handler = NULL;
+                  _ecore_pipe_unhandle(p);
                   return ECORE_CALLBACK_CANCEL;
                }
 #ifndef _WIN32
@@ -515,6 +531,7 @@
                   ERR("An unhandled error (ret: %zd errno: %d [%s])"
                       "occurred while reading from the pipe the length",
                       ret, errno, strerror(errno));
+                  _ecore_pipe_unhandle(p);
                   return ECORE_CALLBACK_RENEW;
                }
 #else
@@ -526,6 +543,7 @@
                        pipe_close(p->fd_read);
                        p->fd_read = PIPE_FD_INVALID;
                        p->fd_handler = NULL;
+                       _ecore_pipe_unhandle(p);
                        return ECORE_CALLBACK_CANCEL;
                     }
                }
@@ -553,6 +571,7 @@
         else if (ret >= 0)
           {
              p->already_read += ret;
+             _ecore_pipe_unhandle(p);
              return ECORE_CALLBACK_RENEW;
           }
         else if (ret == 0)
@@ -561,6 +580,7 @@
              pipe_close(p->fd_read);
              p->fd_read = PIPE_FD_INVALID;
              p->fd_handler = NULL;
+             _ecore_pipe_unhandle(p);
              return ECORE_CALLBACK_CANCEL;
           }
 #ifndef _WIN32
@@ -571,6 +591,7 @@
              ERR("An unhandled error (ret: %zd errno: %d)"
                  "occurred while reading from the pipe the data",
                  ret, errno);
+             _ecore_pipe_unhandle(p);
              return ECORE_CALLBACK_RENEW;
           }
 #else
@@ -582,6 +603,7 @@
                   pipe_close(p->fd_read);
                   p->fd_read = PIPE_FD_INVALID;
                   p->fd_handler = NULL;
+                  _ecore_pipe_unhandle(p);
                   return ECORE_CALLBACK_CANCEL;
                }
              else
@@ -589,7 +611,7 @@
           }
 #endif
      }
-   while (ecore_time_get() - start_time < ecore_animator_frametime_get());

+   _ecore_pipe_unhandle(p);
    return ECORE_CALLBACK_RENEW;
 }


Bug 12556 - document that dictionary-related functions return a reference-counted object

git-svn-id: fa6c8bc307858af7a2ed2f6e39ba40ad8a488bfa@28599 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6

--- src/enchant.c
+++ src/enchant.c
@@ -1737,7 +1737,7 @@
  * @pwl: A non-null pathname in the GLib file name encoding (UTF-8 on Windows)
  *       to the personal wordlist file
  *
- * Returns:
+ * Returns: An EnchantDict. This dictionary is reference counted.
  */
 ENCHANT_MODULE_EXPORT (EnchantDict *)
 enchant_broker_request_pwl_dict (EnchantBroker * broker, const char *const pwl)
@@ -1832,7 +1832,7 @@
  * @broker: A non-null #EnchantBroker
  * @tag: The non-null language tag you wish to request a dictionary for ("en_US", "de_DE", ...)
  *
- * Returns: An #EnchantDict, or %null if no suitable dictionary could be found.
+ * Returns: An #EnchantDict, or %null if no suitable dictionary could be found. This dictionary is reference counted.
  */
 ENCHANT_MODULE_EXPORT (EnchantDict *)
 enchant_broker_request_dict (EnchantBroker * broker, const char *const tag)


elm_entry_common.h: added more description to elm_entry_utf8_to_markup api.

--- src/lib/elm_entry_common.h
+++ src/lib/elm_entry_common.h
@@ -240,6 +240,11 @@
  * @param s The string (in UTF-8) to be converted
  * @return The converted string (in markup). It should be freed.
  *
+ * For example, passing "<align=center>hello</align>>" will return
+ * "<align=center>hello</align> &gt;". This is useful when you
+ * want to display "&" in label, entry, and some widgets which use textblock
+ * internally.
+ *
  * @ingroup Entry
  */
 EAPI char              *elm_entry_utf8_to_markup(const char *s);


Avoid GCC's macro arg concat extension with IDE parsing

--- OpenAL32/Include/alMain.h
+++ OpenAL32/Include/alMain.h
@@ -816,7 +816,7 @@

 extern FILE *LogFile;

-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(IN_IDE_PARSER)
 #define AL_PRINT(T, MSG, ...) fprintf(LogFile, "AL lib: %s %s: "MSG, T, __FUNCTION__ , ## __VA_ARGS__)
 #else
 void al_print(const char *type, const char *func, const char *fmt, ...) PRINTF_STYLE(3,4);


Fix order of frames with --debug

Fix order of frames with --debug

When the decoding and presentation orders of pictures are different
(with GOP), the frames in YUV debug output would be in the decoding
order. This commit changes the kvazaar command line program to store the
reconstructed pictures in a buffer so that they can be output in the
presentation order.

Fixes #101.

--- src/encmain.c
+++ src/encmain.c
@@ -193,7 +193,7 @@
     // Set PTS to make sure we pass it on correctly.
     frame_in->pts = frames_read;

-    bool read_success = yuv_io_read(args->input,
+    bool read_success = yuv_io_read(args->input,
                                     args->opts->config->width,
                                     args->opts->config->height,
                                     args->encoder->cfg.input_bitdepth,
@@ -269,6 +269,41 @@
 }

+void output_recon_pictures(const kvz_api *const api,
+                           FILE *recout,
+                           kvz_picture *buffer[KVZ_MAX_GOP_LENGTH],
+                           int *buffer_size,
+                           uint64_t *next_pts,
+                           unsigned width,
+                           unsigned height)
+{
+  bool picture_written;
+  do {
+    picture_written = false;
+    for (int i = 0; i < *buffer_size; i++) {
+
+      kvz_picture *pic = buffer[i];
+      if (pic->pts == *next_pts) {
+        // Output the picture and remove it.
+        if (!yuv_io_write(recout, pic, width, height)) {
+          fprintf(stderr, "Failed to write reconstructed picture!\n");
+        }
+        api->picture_free(pic);
+        picture_written = true;
+        (*next_pts)++;
+
+        // Move rest of the pictures one position backward.
+        for (i++; i < *buffer_size; i++) {
+          buffer[i - 1] = buffer[i];
+          buffer[i] = NULL;
+        }
+        (*buffer_size)--;
+      }
+    }
+  } while (picture_written);
+}
+
+
 /**
  * \brief Program main function.
  * \param argc Argument count from commandline
@@ -290,6 +325,15 @@

   clock_t encoding_end_cpu_time;
   KVZ_CLOCK_T encoding_end_real_time;
+
+  // PTS of the reconstructed picture that should be output next.
+  // Only used with --debug.
+  uint64_t next_recon_pts = 0;
+  // Buffer for storing reconstructed pictures that are not to be output
+  // yet (i.e. in wrong order because GOP is used).
+  // Only used with --debug.
+  kvz_picture *recon_buffer[KVZ_MAX_GOP_LENGTH] = { NULL };
+  int recon_buffer_size = 0;

 #ifdef _WIN32
   // Stderr needs to be text mode to convert \n to \r\n in Windows.
@@ -484,12 +528,20 @@
         if (recout) {
           // Since chunks_out was not NULL, img_rec should have been set.
           assert(img_rec);
-          if (!yuv_io_write(recout,
-                            img_rec,
-                            opts->config->width,
-                            opts->config->height)) {
-            fprintf(stderr, "Failed to write reconstructed picture!\n");
-          }
+
+          // Move img_rec to the recon buffer.
+          assert(recon_buffer_size < KVZ_MAX_GOP_LENGTH);
+          recon_buffer[recon_buffer_size++] = img_rec;
+          img_rec = NULL;
+
+          // Try to output some reconstructed pictures.
+          output_recon_pictures(api,
+                                recout,
+                                recon_buffer,
+                                &recon_buffer_size,
+                                &next_recon_pts,
+                                opts->config->width,
+                                opts->config->height);
         }

         frames_done += 1;
@@ -509,6 +561,9 @@
     KVZ_GET_TIME(&encoding_end_real_time);
     encoding_end_cpu_time = clock();
     // Coding finished
+
+    // All reconstructed pictures should have been output.
+    assert(recon_buffer_size == 0);

     // Print statistics of the coding
     fprintf(stderr, " Processed %d frames, %10llu bits",


use correct #ifdef

use correct #ifdef

git-svn-id: 24a995eca3b83137dd7eab3408044d7832e202f7@38314 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/lib/file/evas_module.c
+++ src/lib/file/evas_module.c
@@ -174,7 +174,7 @@
 		  em->handle = NULL;
 		  em->data = NULL;
                   em->loaded = 0;
-#if defined(HAVE_PTHREAD_H) && defined(BUILD_ASYNC_PRELOAD)
+#if defined(BUILD_PTHREAD) && defined(BUILD_ASYNC_PRELOAD)
 		  pthread_spin_init(&em->lock, PTHREAD_PROCESS_PRIVATE);
 #endif
 		  if (em->type == EVAS_MODULE_TYPE_ENGINE)


Remove an unused include

Remove an unused include

--- OpenAL32/Include/alMain.h
+++ OpenAL32/Include/alMain.h
@@ -100,9 +100,6 @@
 #include <unistd.h>
 #include <assert.h>
 #include <pthread.h>
-#ifdef HAVE_PTHREAD_NP_H
-#include <pthread_np.h>
-#endif
 #include <sys/time.h>
 #include <time.h>
 #include <errno.h>


Remove dead code

Remove dead code

--- src/encoder.c
+++ src/encoder.c
@@ -318,14 +318,6 @@
     }

     encoder->wpp = encoder->cfg->wpp;
-
-    //FIXME: remove
-    if (encoder->slice_count) {
-      lcu_at_slice_start(encoder, 0);
-      lcu_at_slice_end(encoder, 0);
-      lcu_at_tile_start(encoder, 0);
-      lcu_at_tile_end(encoder, 0);
-    }

 #ifdef _DEBUG
     printf("Tiles columns width:");


Close some gaps in enum values

Close some gaps in enum values

--- OpenAL32/Include/alMain.h
+++ OpenAL32/Include/alMain.h
@@ -42,9 +42,9 @@
 #define ALC_FUMA_SOFT                            0x1601

 /* Ambisonic scalings (normalization) */
-#define ALC_N3D_SOFT                             0x1700
-#define ALC_SN3D_SOFT                            0x1701
 /*#define ALC_FUMA_SOFT*/
+#define ALC_SN3D_SOFT                            0x1602
+#define ALC_N3D_SOFT                             0x1603

 typedef ALCboolean (ALC_APIENTRY*LPALCISAMBISONICFORMATSUPPORTEDSOFT)(ALCdevice *device, ALCenum layout, ALCenum scaling, ALsizei order);
 #ifdef AL_ALEXT_PROTOTYPES


fix: 'std::bind' include error for gcc version larger than 7. (#33)

--- qmf/utils/ThreadPool-inl.h
+++ qmf/utils/ThreadPool-inl.h
@@ -13,6 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+#if __GNUC__ >= 7
+ #include <functional>
+#endif

 #include <condition_variable>


Fix error in incrementing tuple for first A.

--- qsieve/compute_poly_data.c
+++ qsieve/compute_poly_data.c
@@ -247,10 +247,10 @@

             /* (s - 1)-tuple failed, step to next (s - 1)-tuple */
             h = (4*(m + h + 1)/3 >= span) ? h + 1 : 1;
-            m = curr_subset[s - h - 2] + 1;
+            m = curr_subset[s - h - 1] + 1;

             for (j = 0; j < h; j++)
-                curr_subset[s + j - h - 2] = m + j;
+                curr_subset[s + j - h - 1] = m + j;
         }

         A_ind[s - 1] = j;


Attempt to fix larger factorisations.

Attempt to fix larger factorisations.

--- qsieve/compute_poly_data.c
+++ qsieve/compute_poly_data.c
@@ -125,10 +125,9 @@
         else if (i - rem <= num_factors)
         {
             /* can make a new factor with remaining bits plus not too many extra bits */
-            if (factor_bound[i + 1] > 0 && factor_bound[i - 2] > 0)
-            {
-                num_factors += 1;
-                low = factor_bound[i - 2]; /* need smaller primes in this case */
+            if (factor_bound[i + 1] > 0 && factor_bound[i - 1 - (++num_factors <= 5)] > 0)
+            {
+                low = factor_bound[i - 1 - (num_factors <= 5)];
                 high = factor_bound[i + 1];
                 break;
             }
@@ -261,7 +260,15 @@
             A_ind[j] = 4*curr_subset[j]/3 + 1 + low;

         for (j = 0; j < s; j++)
-            first_subset[j] = curr_subset[j]; /* save 1st tuple for restarts */
+            first_subset[j] = curr_subset[j]; /* save 1st tuple for restarts */
+
+#if QS_DEBUG
+        printf("First A_ind = (");
+        for (i = 0; i < s - 1; i++)
+            printf("%ld, ", A_ind[i]);
+        printf("%ld", A_ind[s - 1]);
+        printf(")\n");
+#endif
     }

     if (s > 3)


check_unshare_flags: kill the bogus CLONE_SIGHAND/sig->count check

check_unshare_flags(CLONE_SIGHAND) adds CLONE_THREAD to *flags_ptr if the
task is multithreaded to ensure unshare_thread() will fail.

Not only this is a bit strange way to return the error, this is absolutely
meaningless.  If signal->count > 1 then sighand->count must be also > 1,
and unshare_sighand() will fail anyway.

In fact, all CLONE_THREAD/SIGHAND/VM checks inside sys_unshare() do not
look right.  Fortunately this code doesn't really work anyway.

Signed-off-by: Oleg Nesterov <20b70f0af00562e63758b9ee42012ecc96c58590@redhat.com>
Cc: Balbir Singh <65a1aed538f36fed73d8c45e9ddfc585ce9f4abf@linux.vnet.ibm.com>
Acked-by: Roland McGrath <0d270388f2f92757a5de0f4bd891d3b392c44c4f@redhat.com>
Cc: Veaceslav Falico <13e4c2c2c15eff98ad47d02f3ccee2d83dc7015d@redhat.com>
Cc: Stanislaw Gruszka <1542dc81552e668e197a396f69e655c1621c300d@redhat.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- kernel/fork.c
+++ kernel/fork.c
@@ -1518,14 +1518,6 @@
 		*flags_ptr |= CLONE_SIGHAND;

 	/*
-	 * If unsharing signal handlers and the task was created
-	 * using CLONE_THREAD, then must unshare the thread
-	 */
-	if ((*flags_ptr & CLONE_SIGHAND) &&
-	    (atomic_read(&current->signal->count) > 1))
-		*flags_ptr |= CLONE_THREAD;
-
-	/*
 	 * If unsharing namespace, must also unshare filesystem information.
 	 */
 	if (*flags_ptr & CLONE_NEWNS)


mm: copy over oom_adj value at fork time

Fix a post-2.6.31 regression which was introduced by
2ff05b2b4eac2e63d345fc731ea151a060247f53 ("oom: move oom_adj value from
task_struct to mm_struct").

After moving the oom_adj value from the task struct to the mm_struct, the
oom_adj value was no longer properly inherited by child processes.

Copying over the oom_adj value at fork time fixes that bug.

[70a1d3ef3e17a2bb0f09a1b2e6c86f607ed1d6d9@jp.fujitsu.com: test for current->mm before dereferencing it]
Signed-off-by: Rik van Riel <a21938f5d463ddf41aa718934c205ca2cce8ebbc@redhat.com>
Reported-by: Paul Menage <3f282fcba8933e03a65a6dc92a27de8396961e2f@google.com>
Cc: KOSAKI Motohiro <70a1d3ef3e17a2bb0f09a1b2e6c86f607ed1d6d9@jp.fujitsu.com>
Acked-by: David Rientjes <d8cd2994e15bc61ddb2b113030bda55eebc3a0fe@google.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- kernel/fork.c
+++ kernel/fork.c
@@ -426,6 +426,7 @@
 	init_rwsem(&mm->mmap_sem);
 	INIT_LIST_HEAD(&mm->mmlist);
 	mm->flags = (current->mm) ? current->mm->flags : default_dump_filter;
+	mm->oom_adj = (current->mm) ? current->mm->oom_adj : 0;
 	mm->core_state = NULL;
 	mm->nr_ptes = 0;
 	set_mm_counter(mm, file_rss, 0);


[pipe] Make {read,write}_handles atomic

[pipe] Make {read,write}_handles atomic

--- kernel/pipe.c
+++ kernel/pipe.c
@@ -19,8 +19,8 @@
    struct kmutex mutex;
    struct kcond cond;

-   int read_handles;
-   int write_handles;
+   ATOMIC(int) read_handles;
+   ATOMIC(int) write_handles;
 };

 static ssize_t pipe_read(fs_handle h, char *buf, size_t size)
@@ -158,11 +158,8 @@

    res = kfs_create_new_handle(&static_ops_pipe_read_end, (void *)p, O_RDONLY);

-   if (res != NULL) {
-      kmutex_lock(&p->mutex);
+   if (res != NULL)
       p->read_handles++;
-      kmutex_unlock(&p->mutex);
-   }

    return res;
 }
@@ -173,11 +170,8 @@

    res = kfs_create_new_handle(&static_ops_pipe_write_end, (void*)p, O_WRONLY);

-   if (res != NULL) {
-      kmutex_lock(&p->mutex);
+   if (res != NULL)
       p->write_handles++;
-      kmutex_unlock(&p->mutex);
-   }

    return res;
 }


add blocking uart_getchar() add USE_2X option

--- kernel/uart.c
+++ kernel/uart.c
@@ -33,6 +33,36 @@
 {
 	loop_until_bit_is_set(UCSRA, UDRE);
 	UDR = c;
+}
+
+char
+uart_getchar(void)
+{
+	char c;
+
+	loop_until_bit_is_set(UCSRA, RXC);
+
+	if (UCSRA & _BV(FE))
+		return -2;		/* EOF */
+	if (UCSRA & _BV(DOR))
+		return -1;		/* ERR */
+	c = UDR;
+
+	switch (c) {
+	case '\r':
+		c = '\n';
+		break;
+	case '\n':
+		uart_putchar(c);
+		break;
+	case '\t':
+		c = ' ';
+		break;
+	default:
+		break;
+	}
+
+	return c;
 }

 ISR(SIG_UART_RECV)
@@ -76,5 +106,9 @@
 	UCSRB = _BV(RXCIE) | _BV(RXEN) | _BV(TXEN);
 	UBRRH = UBRRH_VALUE;
 	UBRRL = UBRRL_VALUE;
+#if USE_2X
+	UCSRA |= _BV(U2X);
+#else
 	UCSRA &= ~_BV(U2X);
+#endif
 }


Allow both arfvocab and arfrel in core:relationship

To my understanding of NISTIR-7694 is not very clear on the topic.
Reading the prose, the 'isAbout' is supposed to be a part of arfrel,
however in the example, the isAbout is prefixed by arfvocab.

I guess it is better to suppose both.

Afterall, so far, we are exporting arfrel:isAbout, while we are
supporting only arfvocab:isAbout when reading it.

--- src/DS/rds_index.c
+++ src/DS/rds_index.c
@@ -197,7 +197,8 @@
 		xmlChar *subject_attr = xmlGetProp(relationship_node, BAD_CAST "subject");
 		xmlChar *inner_ref = relationship_get_inner_ref(relationship_node);

-		if (oscap_str_startswith((const char *) type_attr, "arfvocab:")) {
+		if (oscap_str_startswith((const char *) type_attr, "arfvocab:")
+				|| oscap_str_startswith((const char *) type_attr, "arfrel:")) {
 			if (oscap_str_endswith((const char*)type_attr, ":isAbout")) {
 				struct rds_asset_index* asset = rds_index_get_asset(ret, (const char*)inner_ref);
 				struct rds_report_index* report = rds_index_get_report(ret, (const char*)subject_attr);


removed viral 'using namepsace std' clause in header

--- src/DataEnvelope.h
+++ src/DataEnvelope.h
@@ -14,8 +14,6 @@

 #ifndef MG_DATA_ENVELOPE
 #define MG_DATA_ENVELOPE
-
-using namespace std;

 // This enum represents known data types
 //TODO: These should be 32bit id/hash values for dataNamespace strings or something


The O_NOCTTY flag shouldn't be used when opening the Voyager device. (dm)

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

--- Drivers/Voyager/braille.c
+++ Drivers/Voyager/braille.c
@@ -224,7 +224,7 @@

   dispbuf = prevdata = NULL;

-  brl_fd = open (dev, O_RDWR | O_NOCTTY);
+  brl_fd = open (dev, O_RDWR);
   /* Kernel driver will block until a display is connected. */
   if (brl_fd < 0){
     LogPrint(LOG_ERR, "Open failed on device %s: %s", dev, strerror(errno));


Added using for new AlphaChannelOption's in Magick++.

git-svn-id: 7f11a4e55de7d4642c7675696f15857479c93c9d@17416 aa41f4f7-0bf4-0310-aa73-e5a19afd5a74

--- Magick++/lib/Magick++/Include.h
+++ Magick++/lib/Magick++/Include.h
@@ -287,6 +287,8 @@
   using MagickCore::DiscreteAlphaChannel;
   using MagickCore::DisassociateAlphaChannel;
   using MagickCore::ExtractAlphaChannel;
+  using MagickCore::OffAlphaChannel;
+  using MagickCore::OnAlphaChannel;
   using MagickCore::OpaqueAlphaChannel;
   using MagickCore::RemoveAlphaChannel;
   using MagickCore::SetAlphaChannel;


Synchronized  Macro definition of GET_GUID_HOB_DATA_SIZE, GET_GUID_HOB_DATA, END_OF_HOB_LIST, GET_NEXT_HOB, GET_HOB_LENGTH, GET_HOB_TYPE with Spec.

git-svn-id: 5648d1bec6962b0a6d1d1b40eba8cf5cdb62da3d@6860 6f19259b-4bc3-4df7-8a09-765794883524

--- MdePkg/Include/Library/HobLib.h
+++ MdePkg/Include/Library/HobLib.h
@@ -425,7 +425,9 @@
   @return HobType

 **/
-#define GET_HOB_TYPE(Hob)     ((Hob).Header->HobType)
+//#define GET_HOB_TYPE(Hob)     ((Hob).Header->HobType)
+#define GET_HOB_TYPE(HobStart) \
+  ((*(EFI_HOB_GENERIC_HEADER **)&(HobStart))->HobType)

 /**
   Returns the length, in bytes, of a HOB.
@@ -438,7 +440,9 @@
   @return HobLength

 **/
-#define GET_HOB_LENGTH(Hob)   ((Hob).Header->HobLength)
+//#define GET_HOB_LENGTH(Hob)   ((Hob).Header->HobLength)
+#define GET_HOB_LENGTH(HobStart) \
+  ((*(EFI_HOB_GENERIC_HEADER **)&(HobStart))->HobLength)

 /**
   Returns a pointer to the next HOB in the HOB list.
@@ -451,7 +455,9 @@
   @return A pointer to the next HOB in the HOB list.

 **/
-#define GET_NEXT_HOB(Hob)     ((Hob).Raw + GET_HOB_LENGTH (Hob))
+//#define GET_NEXT_HOB(Hob)     ((Hob).Raw + GET_HOB_LENGTH (Hob))
+#define GET_NEXT_HOB(HobStart) \
+  (VOID *)(*(UINT8 **)&(HobStart) + GET_HOB_LENGTH (HobStart))

 /**
   Determines if a HOB is the last HOB in the HOB list.
@@ -479,7 +485,9 @@
   @return  A pointer to the data buffer in a HOB

 **/
-#define GET_GUID_HOB_DATA(GuidHob)      ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID)))
+//#define GET_GUID_HOB_DATA(GuidHob)      ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID)))
+#define GET_GUID_HOB_DATA(HobStart) \
+  (VOID *)(*(UINT8 **)&(HobStart) + sizeof (EFI_HOB_GUID_TYPE))

 /**
   Returns the size of the data buffer from a HOB of type EFI_HOB_TYPE_GUID_EXTENSION.
@@ -491,6 +499,8 @@

   @return  The size of the data buffer
 **/
-#define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE))
+//#define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE))
+#define GET_GUID_HOB_DATA_SIZE(HobStart) \
+  (UINT16)(GET_HOB_LENGTH (HobStart) - sizeof (EFI_HOB_GUID_TYPE))

 #endif


remove blank for function typedef, it will break generating doxygen document.

git-svn-id: 5648d1bec6962b0a6d1d1b40eba8cf5cdb62da3d@5593 6f19259b-4bc3-4df7-8a09-765794883524

--- MdePkg/Include/Library/PcdLib.h
+++ MdePkg/Include/Library/PcdLib.h
@@ -652,7 +652,7 @@
 **/
 typedef
 VOID
-(EFIAPI *PCD_CALLBACK) (
+(EFIAPI *PCD_CALLBACK)(
   IN        CONST GUID        *CallBackGuid, OPTIONAL
   IN        UINTN             CallBackToken,
   IN  OUT   VOID              *TokenData,


* src/errcode.c: include stdarg.h

* src/errcode.c: include stdarg.h

--- src/errcode.c
+++ src/errcode.c
@@ -23,6 +23,7 @@
 #include <config.h>

 #include "errcode.h"
+#include <stdarg.h>

 static void vreport_error(struct error *err, aug_errcode_t errcode,
                    const char *format, va_list ap) {


Save the git_file in the gitfo_cache when enabling caching

Signed-off-by: Ramsay Jones <3e74413778ce9c8bebbbaedfd56741f6850faeaf@ramsay1.demon.co.uk>

--- src/fileops.c
+++ src/fileops.c
@@ -151,6 +151,7 @@
 	if (!ioc)
 		return NULL;

+	ioc->fd = fd;
 	ioc->pos = 0;
 	ioc->cache_size = cache_size;
 	ioc->cache = git__malloc(cache_size);


Removed example C file for gmachine

Removed example C file for gmachine

--- src/example.c
+++ src/example.c
@@ -1,23 +0,0 @@
-#include "RTS.h"
-
-// Declare global lookup table.
-Node *globalTable[3];
-
-int main(int argc, char *argv[]) {
-    Instruction global_I_is[4] = { insPush(0), insSlide(2), insUnwind(), insEnd() };
-    Instruction global_K_is[4] = { insPush(0), insSlide(3), insUnwind(), insEnd() };
-    Instruction global_S_is[10] = { insPush(2), insPush(2), insMkAp(), insPush(3), insPush(2), insMkAp(), insMkAp(), insSlide(4), insUnwind(), insEnd() };
-    Instruction global_main_is[10] = { insPushInt(3), insPushGlobal(0), insPushGlobal(1), insPushGlobal(2), insMkAp(), insMkAp(), insMkAp(), insSlide(1), insUnwind(), insEnd() };
-
-    // Allocate global nodes on the heap.
-    Node *global_I_node = mkNodeGlobal(1, global_I_is);
-    Node *global_K_node = mkNodeGlobal(2, global_K_is);
-    Node *global_S_node = mkNodeGlobal(2, global_S_is);
-
-    // Populate global lookup table.
-    globalTable[0] = global_I_node;
-    globalTable[1] = global_K_node;
-    globalTable[2] = global_S_node;
-
-    run(global_main_is, globalTable);
-}


remove FILEREF_DEBUG that sneaked in

remove FILEREF_DEBUG that sneaked in

--- src/fileref.c
+++ src/fileref.c
@@ -23,8 +23,6 @@

 #include "kore.h"

-#define FILEREF_DEBUG	1
-
 /* cached filerefs expire after 30 seconds of inactivity. */
 #define FILEREF_EXPIRATION		(1000 * 30)


Handle wait error properly

Handle wait error properly

--- src/execute.c
+++ src/execute.c
@@ -116,13 +116,13 @@
     //TODO Run execution tree

     // Pipe testing
-    char *input[3];
-    char *output[2];
-    input[0] = "cat";
-    input[1] = "README.md";
-    input[2] = '\0';
-    output[0] = "wc";
-    output[1] = '\0';
+    //char *input[3];
+    //char *output[2];
+    //input[0] = "cat";
+    //input[1] = "README.md";
+    //input[2] = '\0';
+    //output[0] = "wc";
+    //output[1] = '\0';

     pid_t pid;
     if ((pid = fork()) < 0)
@@ -136,7 +136,10 @@
     }
     else //Parent
     {
-        int wc = wait(NULL);
+        if (wait(NULL) == -1)
+        {
+            printf("*** Error: wait failed. This may get confusing\n");
+        }
     }

     // Delete the tree and return from execute call
@@ -236,7 +239,7 @@
         dup2(fd[1],1);   /* make 1 same as write-to end of pipe  */

         //Run command, check for error
-        fprintf(stderr, "Above child execvp\n");
+        //fprintf(stderr, "Above child execvp\n");
         if (execvp(*input, input) < 0)
         {
             fprintf(stderr, "*** ERROR: child exec failed: %s\n", *input);
@@ -247,7 +250,10 @@
     else //Parent
     {
         //printf("above wait\n");
-        int wc = wait(NULL);
+        if (wait(NULL) == -1)
+        {
+            printf("*** Error: wait failed. This may get confusing\n");
+        }

         close(fd[1]);    /* close write end of pipe              */
         dup2(fd[0],0);   /* make 0 same as read-from end of pipe */


NA OFI: add support for OPX provider

NA OFI: add support for OPX provider

Allow for FI_CONTEXT2 through NA_OFI_CONTEXT2 flag

Co-authored-by: Brian Wilson <bb095ec7e92c1e1e3f5a8c0b300a787256901cc5@cornelisnetworks.com>

--- src/na/na_ofi.c
+++ src/na/na_ofi.c
@@ -55,10 +55,17 @@
  */
 #define NA_OFI_VERSION FI_VERSION(1, 9)

+/* Fallback for undefined OPX values */
+#if FI_VERSION_LT(FI_VERSION(FI_MAJOR_VERSION, FI_MINOR_VERSION),              \
+    FI_VERSION(1, 15))
+#    define FI_ADDR_OPX  -1
+#    define FI_PROTO_OPX -1
+#endif
+
 /* Fallback for undefined CXI values */
 #ifndef NA_OFI_HAS_EXT_CXI_H
-#    define FI_ADDR_CXI  FI_FORMAT_UNSPEC
-#    define FI_PROTO_CXI FI_PROTO_UNSPEC
+#    define FI_ADDR_CXI  -2
+#    define FI_PROTO_CXI -2
 #endif

 /* Default basic bits */
@@ -74,6 +81,7 @@
 #define NA_OFI_SEP        (1 << 4) /* supports SEPs */
 #define NA_OFI_SOURCE_MSG (1 << 5) /* requires source info in the MSG */
 #define NA_OFI_LOC_INFO   (1 << 6) /* supports locality info */
+#define NA_OFI_CONTEXT2   (1 << 7) /* requires FI_CONTEXT2 */

 /* X-macro to define the following for each supported provider:
  * - enum type
@@ -142,6 +150,16 @@
       FI_SOURCE | FI_SOURCE_ERR | FI_DIRECTED_RECV,                            \
       NA_OFI_SIGNAL | NA_OFI_SEP | NA_OFI_LOC_INFO                             \
     )                                                                          \
+    X(NA_OFI_PROV_OPX,                                                         \
+      "opx",                                                                   \
+      "",                                                                      \
+      FI_ADDR_OPX,                                                             \
+      FI_ADDR_OPX,                                                             \
+      FI_PROGRESS_MANUAL,                                                      \
+      FI_PROTO_OPX,                                                            \
+      FI_SOURCE | FI_DIRECTED_RECV,                                            \
+      NA_OFI_SEP | NA_OFI_SOURCE_MSG | NA_OFI_CONTEXT2                         \
+    )                                                                          \
     X(NA_OFI_PROV_VERBS,                                                       \
       "verbs;ofi_rxm",                                                         \
       "verbs",                                                                 \
@@ -357,6 +375,19 @@
     uint64_t addr1;
 };

+/* OPX address */
+NA_PACKED(union na_ofi_opx_addr {
+    uint64_t raw;
+    NA_PACKED(struct {
+        uint8_t hfi1_rx;
+        uint8_t hfi1_unit;
+        uint8_t reliability_rx;
+        uint16_t endpoint_id;
+        uint16_t lid;
+        uint8_t rx_index;
+    });
+});
+
 /* GNI address */
 struct na_ofi_gni_addr {
     struct {
@@ -402,6 +433,7 @@
     struct na_ofi_sockaddr_ib sib;
     struct na_ofi_psm_addr psm;
     struct na_ofi_psm2_addr psm2;
+    union na_ofi_opx_addr opx;
     struct na_ofi_gni_addr gni;
     struct na_ofi_cxi_addr cxi;
     struct na_ofi_str_addr str;
@@ -489,7 +521,7 @@
         struct na_ofi_rma_info rma;
     } info;                             /* Op info                  */
     HG_QUEUE_ENTRY(na_ofi_op_id) entry; /* Entry in queue           */
-    struct fi_context fi_ctx;           /* Context handle           */
+    struct fi_context fi_ctx[2];        /* Context handle           */
     hg_time_t retry_deadline;           /* Retry deadline           */
     struct na_ofi_class *na_ofi_class;  /* NA class associated      */
     na_context_t *context;              /* NA context associated    */
@@ -664,6 +696,8 @@
 static na_return_t
 na_ofi_str_to_psm2(const char *str, struct na_ofi_psm2_addr *psm2_addr);
 static na_return_t
+na_ofi_str_to_opx(const char *str, union na_ofi_opx_addr *opx_addr);
+static na_return_t
 na_ofi_str_to_gni(const char *str, struct na_ofi_gni_addr *gni_addr);
 static na_return_t
 na_ofi_str_to_cxi(const char *str, struct na_ofi_cxi_addr *cxi_addr);
@@ -685,6 +719,8 @@
 na_ofi_psm_to_key(const struct na_ofi_psm_addr *addr);
 static NA_INLINE uint64_t
 na_ofi_psm2_to_key(const struct na_ofi_psm2_addr *addr);
+static NA_INLINE uint64_t
+na_ofi_opx_to_key(const union na_ofi_opx_addr *addr);
 static NA_INLINE uint64_t
 na_ofi_gni_to_key(const struct na_ofi_gni_addr *addr);
 static NA_INLINE uint64_t
@@ -1563,6 +1599,8 @@
             return sizeof(struct na_ofi_psm_addr);
         case FI_ADDR_PSMX2:
             return sizeof(struct na_ofi_psm2_addr);
+        case FI_ADDR_OPX:
+            return sizeof(union na_ofi_opx_addr);
         case FI_ADDR_GNI:
             return sizeof(struct na_ofi_gni_addr);
         case FI_ADDR_CXI:
@@ -1623,6 +1661,8 @@
             return na_ofi_str_to_psm(str, &addr->psm);
         case FI_ADDR_PSMX2:
             return na_ofi_str_to_psm2(str, &addr->psm2);
+        case FI_ADDR_OPX:
+            return na_ofi_str_to_opx(str, &addr->opx);
         case FI_ADDR_GNI:
             return na_ofi_str_to_gni(str, &addr->gni);
         case FI_ADDR_CXI:
@@ -1809,6 +1849,32 @@
         (uint64_t *) &psm2_addr->addr0, (uint64_t *) &psm2_addr->addr1);
     NA_CHECK_SUBSYS_ERROR(addr, rc != 2, error, ret, NA_PROTONOSUPPORT,
         "Could not convert addr string to PSM2 addr format");
+
+    return NA_SUCCESS;
+
+error:
+    return ret;
+}
+
+/*---------------------------------------------------------------------------*/
+static na_return_t
+na_ofi_str_to_opx(const char *str, union na_ofi_opx_addr *opx_addr)
+{
+    uint8_t rx_index, hfi1_rx, hfi1_unit, reliability_rx;
+    uint16_t lid, endpoint_id;
+    na_return_t ret;
+    int rc;
+
+    rc = sscanf(str, "%*[^:]://%04hx.%04hx.%02hhx.%02hhx.%02hhx.%02hhx", &lid,
+        &endpoint_id, &rx_index, &hfi1_rx, &hfi1_unit, &reliability_rx);
+    NA_CHECK_SUBSYS_ERROR(addr, rc != 6, error, ret, NA_PROTONOSUPPORT,
+        "Could not convert addr string to OPX addr format");
+    *opx_addr = (union na_ofi_opx_addr){.lid = lid,
+        .endpoint_id = endpoint_id,
+        .rx_index = rx_index,
+        .hfi1_rx = hfi1_rx,
+        .hfi1_unit = hfi1_unit,
+        .reliability_rx = reliability_rx};

     return NA_SUCCESS;

@@ -1907,6 +1973,8 @@
             return na_ofi_psm_to_key(&addr->psm);
         case FI_ADDR_PSMX2:
             return na_ofi_psm2_to_key(&addr->psm2);
+        case FI_ADDR_OPX:
+            return na_ofi_opx_to_key(&addr->opx);
         case FI_ADDR_GNI:
             return na_ofi_gni_to_key(&addr->gni);
         case FI_ADDR_CXI:
@@ -1953,6 +2021,13 @@
 {
     /* Only need the psm2_epid, i.e. the first 64 bits */
     return addr->addr0;
+}
+
+/*---------------------------------------------------------------------------*/
+static NA_INLINE uint64_t
+na_ofi_opx_to_key(const union na_ofi_opx_addr *addr)
+{
+    return addr->raw;
 }

 /*---------------------------------------------------------------------------*/
@@ -2001,6 +2076,8 @@
             return sizeof(struct na_ofi_psm_addr);
         case FI_ADDR_PSMX2:
             return sizeof(struct na_ofi_psm2_addr);
+        case FI_ADDR_OPX:
+            return sizeof(union na_ofi_opx_addr);
         case FI_ADDR_GNI:
             return sizeof(struct na_ofi_gni_addr);
         case FI_ADDR_CXI:
@@ -2061,6 +2138,13 @@
                 buf_size);
             memcpy(buf, &addr->psm2, sizeof(addr->psm2));
             break;
+        case FI_ADDR_OPX:
+            NA_CHECK_SUBSYS_ERROR(addr,
+                buf_size < sizeof(union na_ofi_opx_addr), error, ret,
+                NA_OVERFLOW, "Buffer size (%zu) too small to copy addr",
+                buf_size);
+            memcpy(buf, &addr->opx, sizeof(addr->opx));
+            break;
         case FI_ADDR_GNI:
             NA_CHECK_SUBSYS_ERROR(addr,
                 buf_size < sizeof(struct na_ofi_gni_addr), error, ret,
@@ -2142,6 +2226,13 @@
                 NA_OVERFLOW, "Buffer size (%zu) too small to copy addr",
                 buf_size);
             memcpy(&addr->psm2, buf, sizeof(addr->psm2));
+            break;
+        case FI_ADDR_OPX:
+            NA_CHECK_SUBSYS_ERROR(addr,
+                buf_size < sizeof(union na_ofi_opx_addr), error, ret,
+                NA_OVERFLOW, "Buffer size (%zu) too small to copy addr",
+                buf_size);
+            memcpy(&addr->opx, buf, sizeof(addr->opx));
             break;
         case FI_ADDR_GNI:
             NA_CHECK_SUBSYS_ERROR(addr,
@@ -2523,7 +2614,11 @@
      * modify an IO vector  of  length  >  1, including  any  related  memory
      * descriptor array, until the associated operation has completed.
      */
-    hints->mode = FI_CONTEXT | FI_ASYNC_IOV;
+    hints->mode = FI_ASYNC_IOV;
+    if (na_ofi_prov_flags[prov_type] & NA_OFI_CONTEXT2)
+        hints->mode |= FI_CONTEXT2;
+    else
+        hints->mode |= FI_CONTEXT;

     /* ep_type: reliable datagram (connection-less) */
     hints->ep_attr->type = FI_EP_RDM;
@@ -2785,6 +2880,7 @@
         }
         case FI_ADDR_PSMX:
         case FI_ADDR_PSMX2:
+        case FI_ADDR_OPX:
         case FI_ADDR_GNI:
         case FI_ADDR_STR:
             /* Nothing to do */
@@ -2910,7 +3006,8 @@
         NA_GOTO_SUBSYS_ERROR(cls, error, ret, NA_PROTONOSUPPORT,
             "Malformed CXI info, format is: cxi[0-9]:[0-510]");

-    snprintf(pid_name, sizeof(pid_name), "%" PRIu16, pid & pid_mask);
+    snprintf(
+        pid_name, sizeof(pid_name), "%" PRIu16, (uint16_t) (pid & pid_mask));

     *service_p = strdup(pid_name);
     NA_CHECK_SUBSYS_ERROR(cls, *service_p == NULL, error, ret, NA_NOMEM,
@@ -3310,6 +3407,7 @@
         case FI_SOCKADDR_IN:
         case FI_ADDR_PSMX:
         case FI_ADDR_PSMX2:
+        case FI_ADDR_OPX:
         case FI_ADDR_GNI:
         case FI_ADDR_CXI:
         case FI_ADDR_STR:


Patched stl_decl.h according to the patch included in the FreeBSD port.

    http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/gjstest/

--- base/stl_decl.h
+++ base/stl_decl.h
@@ -25,7 +25,7 @@
 #elif defined(__APPLE__) /* gcc with a twist */
 #include "base/stl_decl_osx.h"

-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__FreeBSD__)
 #include "base/stl_decl_linux.h"

 #else


fix: add hash_t.

fix: add hash_t.

--- src/ez_hash.c
+++ src/ez_hash.c
@@ -376,6 +376,7 @@
 //
 typedef struct hash_item_s {
     void *key;
+    int len;
     void *val;
     list_head_t listNode;
 } hash_item_t;
@@ -398,16 +399,24 @@
     return h;
 }

-static uint32_t get_hash_index(const void *key, int len) {
+static uint32_t hashcode_key(const void *key, int len) {
     return MurmurHash3_x86_32(key, len, 0);
 }

+static int hash_compare_key(const void *key, int len, const void *find_key, int find_len) {
+    if (len != find_len) {
+        return 0;
+    }
+    return (key == find_key) ? 1 : 0;
+}
+
 int hash_put(const hash_t *h, const void *key, int len, const void *val) {
-    int index = get_hash_index(key, len) & (h->bucket - 1);
+    int index = hashcode_key(key, len) & (h->bucket - 1);
     hash_item_t *e = &(h->array[index]);

     hash_item_t *nv = ez_malloc(sizeof(hash_item_t));
     nv->key = (void *) key;
+    nv->len = len;
     nv->val = (void *) val;

     list_add(&nv->listNode, &e->listNode);
@@ -416,15 +425,30 @@
 }

 void *hash_get(const hash_t *h, const void *key, int len) {
-    int index = get_hash_index(key, len) & (h->bucket - 1);
+    int index = hashcode_key(key, len) & (h->bucket - 1);
     hash_item_t *e = &(h->array[index]);
     LIST_FOR(&e->listNode, i) {
         hash_item_t *te = EZ_CONTAINER_OF(i, hash_item_t, listNode);
-        // 比较 (te->key, key)
+        // 比较 (te->key, key, len, len)
+        int r = hash_compare_key(te->key, te->len, key, len);
+        if (r) {
+            return te->val;
+        }
     }
     return NULL;
 }

 int hash_del(const hash_t *h, const void *key, int len) {
+    int index = hashcode_key(key, len) & (h->bucket - 1);
+    hash_item_t *e = &(h->array[index]);
+    LIST_FOR(&e->listNode, i) {
+        hash_item_t *te = EZ_CONTAINER_OF(i, hash_item_t, listNode);
+        // 比较 (te->key, key, len, len)
+        int r = hash_compare_key(te->key, te->len, key, len);
+        if (r) {
+            list_del(&te->listNode);
+            return 1;
+        }
+    }
     return 0;
 }


Remove the last few struct initializers.

--- src/fin_ast.c
+++ src/fin_ast.c
@@ -155,7 +155,9 @@

     fin_ast_expr_t* expr = fin_ast_parse_unary_expr(ctx, lex);
     fin_ast_unary_expr_t* un_expr = (fin_ast_unary_expr_t*)ctx->alloc(NULL, sizeof(fin_ast_unary_expr_t));
-    *un_expr = (fin_ast_unary_expr_t){ .base = (fin_ast_expr_t){ .type = fin_ast_expr_type_unary }, .op = op, .expr = expr };
+    un_expr->base.type = fin_ast_expr_type_unary;
+    un_expr->op = op;
+    un_expr->expr = expr;
     return &un_expr->base;
 }

@@ -408,7 +410,11 @@
     if (fin_lex_match(lex, fin_lex_type_else))
         false_stmt = fin_ast_parse_stmt(ctx, lex);
     fin_ast_if_stmt_t* stmt = (fin_ast_if_stmt_t*)ctx->alloc(NULL, sizeof(fin_ast_if_stmt_t));
-    *stmt = (fin_ast_if_stmt_t){ .base = (fin_ast_stmt_t){ .type = fin_ast_stmt_type_if, .next = NULL }, .cond = cond, .true_stmt = true_stmt, .false_stmt = false_stmt };
+    stmt->base.type = fin_ast_stmt_type_if;
+    stmt->base.next = NULL;
+    stmt->cond = cond;
+    stmt->true_stmt = true_stmt;
+    stmt->false_stmt = false_stmt;
     return &stmt->base;
 }

@@ -419,7 +425,10 @@
     fin_ast_expect(lex, fin_lex_type_r_paren);
     fin_ast_stmt_t* stmt = fin_ast_parse_stmt(ctx, lex);
     fin_ast_while_stmt_t* while_stmt = (fin_ast_while_stmt_t*)ctx->alloc(NULL, sizeof(fin_ast_while_stmt_t));
-    *while_stmt = (fin_ast_while_stmt_t){ .base = (fin_ast_stmt_t){ .type = fin_ast_stmt_type_while, .next = NULL }, .cond = cond, .stmt = stmt };
+    while_stmt->base.type = fin_ast_stmt_type_while;
+    while_stmt->base.next = NULL;
+    while_stmt->cond = cond;
+    while_stmt->stmt = stmt;
     return &while_stmt->base;
 }

@@ -432,7 +441,10 @@
     fin_ast_expect(lex, fin_lex_type_r_paren);
     fin_ast_expect(lex, fin_lex_type_semicolon);
     fin_ast_do_stmt_t* do_stmt = (fin_ast_do_stmt_t*)ctx->alloc(NULL, sizeof(fin_ast_do_stmt_t));
-    *do_stmt = (fin_ast_do_stmt_t){ .base = (fin_ast_stmt_t){ .type = fin_ast_stmt_type_do, .next = NULL }, .cond = cond, .stmt = stmt };
+    do_stmt->base.type = fin_ast_stmt_type_do;
+    do_stmt->base.next = NULL;
+    do_stmt->cond = cond;
+    do_stmt->stmt = stmt;
     return &do_stmt->base;
 }


add type to skills

add type to skills

--- src/feSkill.h
+++ src/feSkill.h
@@ -6,6 +6,8 @@
 class feSkill {
   private:
 		std::string name;
+	public:
+		char getType() = 0;
 };

 #endif


Uses slightly faster call to internal transforms

--- src/ffts_nd.c
+++ src/ffts_nd.c
@@ -154,13 +154,13 @@

 	size_t i,j;
 	for(i=0;i<p->Ns[0];i++) {
-		ffts_execute(p->plans[0], din + (i * p->Ms[0]), buf + (i * p->Ms[0]));
+		p->plans[0]->transform(p->plans[0], din + (i * p->Ms[0]), buf + (i * p->Ms[0]));
 	}
 	ffts_transpose(buf, dout, p->Ms[0], p->Ns[0], p->transpose_buf);

 	for(i=1;i<p->rank;i++) {
 		for(j=0;j<p->Ns[i];j++) {
-			ffts_execute(p->plans[i], dout + (j * p->Ms[i]), buf + (j * p->Ms[i]));
+			p->plans[i]->transform(p->plans[i], dout + (j * p->Ms[i]), buf + (j * p->Ms[i]));
 		}
 		ffts_transpose(buf, dout, p->Ms[i], p->Ns[i], p->transpose_buf);
 	}


fix the bug in string_compare

fix the bug in string_compare

--- src/nc_string.c
+++ src/nc_string.c
@@ -102,7 +102,7 @@
 string_compare(const struct string *s1, const struct string *s2)
 {
     if (s1->len != s2->len) {
-        return s1->len - s2->len > 0 ? 1 : -1;
+        return s1->len > s2->len ? 1 : -1;
     }

     return nc_strncmp(s1->data, s2->data, s1->len);


Add newline when logging to file in order to do not add underscores to syslog for all messages.

--- src/fnc_log.c
+++ src/fnc_log.c
@@ -102,6 +102,7 @@
     if(!no_print) {
         va_start(args, fmt);
         vfprintf(fd, fmt, args);
+        fprintf(fd, "\n");
         va_end(args);
         fflush(fd);
     }


sds: fix off-by-one overflow. OSS-Fuzz 5647136884654080 (#3136)

Signed-off-by: davkor <aa743a0aaec8f7d7a1f01442503957f4d7a2d634@adalogics.com>

--- src/flb_sds.c
+++ src/flb_sds.c
@@ -288,7 +288,7 @@
             cp = 0;
             for (b = 0; b < hex_bytes; b++) {
                 p = (const unsigned char *) str + i + b;
-                if (p > (str + str_len)) {
+                if (p >= (str + str_len)) {
                     break;
                 }
                 ret = flb_utf8_decode(&state, &cp, *p);


don't define _XOPEN_SOURCE for NetBSD

don't define _XOPEN_SOURCE for NetBSD

on NetBSD, defining _XOPEN_SOURCE hides extensions
like inet_aton, strcasecmp, etc.

--- src/fmacros.h
+++ src/fmacros.h
@@ -36,9 +36,13 @@
 #define _GNU_SOURCE
 #endif

-#if defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#if defined(__linux__) || defined(__OpenBSD__)
 #define _XOPEN_SOURCE 700
-#else
+/*
+ * On NetBSD, _XOPEN_SOURCE undefines _NETBSD_SOURCE and
+ * thus hides inet_aton etc.
+ */
+#elif !defined(__NetBSD__)
 #define _XOPEN_SOURCE
 #endif


Compilation fixed on OpenBSD making sure that _XOPEN_SOURCE is set to 700 in fmacros.h

--- src/fmacros.h
+++ src/fmacros.h
@@ -3,7 +3,7 @@

 #define _BSD_SOURCE

-#ifdef __linux__
+#if defined(__linux__) || defined(__OpenBSD__)
 #define _XOPEN_SOURCE 700
 #else
 #define _XOPEN_SOURCE


:art: Format code

:art: Format code

--- src/forcing.c
+++ src/forcing.c
@@ -424,42 +424,32 @@
         PIHMprintf(VL_ERROR, "Please check your forcing file.\n");
         PIHMexit(EXIT_FAILURE);
     }
-    else
-    {
-        first = 1;
-        last = ts->length - 1;
-
-        while (first <= last)
-        {
-            middle = (first + last) / 2;
-            if (t >= ts->ftime[middle - 1] && t < ts->ftime[middle])
-            {
-                for (j = 0; j < nvrbl; j++)
-                {
-                    if (intrpl)
-                    {
-                        ts->value[j] =
-                            ((double)(ts->ftime[middle] - t) *
-                            ts->data[middle - 1][j] +
-                            (double)(t - ts->ftime[middle - 1]) *
-                            ts->data[middle][j]) /
-                            (double)(ts->ftime[middle] - ts->ftime[middle - 1]);
-                    }
-                    else
-                    {
-                        ts->value[j] = ts->data[middle - 1][j];
-                    }
-                }
-                break;
-            }
-            else if (ts->ftime[middle] > t)
-            {
-                last = middle - 1;
-            }
-            else
-            {
-                first = middle + 1;
-            }
+
+    first = 1;
+    last = ts->length - 1;
+
+    while (first <= last)
+    {
+        middle = (first + last) / 2;
+        if (t >= ts->ftime[middle - 1] && t < ts->ftime[middle])
+        {
+            for (j = 0; j < nvrbl; j++)
+            {
+                ts->value[j] = (intrpl) ?
+                    ((double)(ts->ftime[middle] - t) * ts->data[middle - 1][j] +
+                    (double)(t - ts->ftime[middle - 1]) * ts->data[middle][j]) /
+                    (double)(ts->ftime[middle] - ts->ftime[middle - 1]) :
+                    ts->data[middle - 1][j];
+            }
+            break;
+        }
+        else if (ts->ftime[middle] > t)
+        {
+            last = middle - 1;
+        }
+        else
+        {
+            first = middle + 1;
         }
     }
 }


Fix struct comparison in tests for Win64

On 64-bit Windows, sizeof(unsigned char *) is 8, sizeof(long) is 4 and
alignof(ogg_int64_t) is 8. This results in a 4-byte hole in ogg_packet
after "long e_o_s", which means ogg_packet structs cannot be reliably
compared by memcmp. Compare ogg_packet structs member-by-member instead.

This fixes `make check` for me on mingw-w64/GCC.

Signed-off-by: Ralph Giles <65585f72bf62a11d2f4105aa30c20fe94efea46f@thaumas.net>

--- src/framing.c
+++ src/framing.c
@@ -1493,6 +1493,34 @@
                        1,
                        0};

+int compare_packet(const ogg_packet *op1, const ogg_packet *op2){
+  if(op1->packet!=op2->packet){
+    fprintf(stderr,"op1->packet != op2->packet\n");
+    return(1);
+  }
+  if(op1->bytes!=op2->bytes){
+    fprintf(stderr,"op1->bytes != op2->bytes\n");
+    return(1);
+  }
+  if(op1->b_o_s!=op2->b_o_s){
+    fprintf(stderr,"op1->b_o_s != op2->b_o_s\n");
+    return(1);
+  }
+  if(op1->e_o_s!=op2->e_o_s){
+    fprintf(stderr,"op1->e_o_s != op2->e_o_s\n");
+    return(1);
+  }
+  if(op1->granulepos!=op2->granulepos){
+    fprintf(stderr,"op1->granulepos != op2->granulepos\n");
+    return(1);
+  }
+  if(op1->packetno!=op2->packetno){
+    fprintf(stderr,"op1->packetno != op2->packetno\n");
+    return(1);
+  }
+  return(0);
+}
+
 void test_pack(const int *pl, const int **headers, int byteskip,
                int pageskip, int packetskip){
   unsigned char *data=_ogg_malloc(1024*1024); /* for scripted test cases only */
@@ -1601,7 +1629,7 @@
               ogg_stream_packetout(&os_de,&op_de); /* just catching them all */

               /* verify peek and out match */
-              if(memcmp(&op_de,&op_de2,sizeof(op_de))){
+              if(compare_packet(&op_de,&op_de2)){
                 fprintf(stderr,"packetout != packetpeek! pos=%ld\n",
                         depacket);
                 exit(1);


modify fopen

modify fopen

--- src/fs/file.c
+++ src/fs/file.c
@@ -63,9 +63,13 @@
 #endif

 FILE *fopen(const char *path, const char *mode) {
-	node_t *nod = vfs_find_node(path, NULL);
+	node_t *nod;
 	file_system_driver_t *drv;
+	file_operations_t *fop;
 	FILE *file;
+
+	nod = vfs_find_node(path, NULL);
+
 	if (nod == NULL) {
 		//FIXME: ahtung! workaround.
 		ramfs_create_param_t param;
@@ -76,6 +80,12 @@
 		drv = find_filesystem("ramfs");
 		drv->fsop->create_file(&param);
 		nod = vfs_find_node(path, NULL);
+	}
+
+	if (NULL != nod->file_info) {
+		/*if fop set*/
+		fop = (file_operations_t *)nod->file_info;
+		return fop->fopen(path, mode);
 	}
 	drv = nod->fs_type;
 	if (NULL == drv->file_op->fopen) {


Cleanup superfluous include in bignum.h.

Used cppclean for code analysis:  https://code.google.com/archive/p/
cppclean/

--- src/bignum.h
+++ src/bignum.h
@@ -9,7 +9,6 @@

 #include "serialize.h"
 #include "uint256.h"
-#include "version.h"

 #include <openssl/bn.h>


Re-match devices when the AppStream metadata is updated

This allows us to notify clients watching for the 'supported' property for
new devices added to the LVFS.

--- src/fu-main.c
+++ src/fu-main.c
@@ -84,6 +84,8 @@
 	FuProvider		*provider;
 } FuDeviceItem;

+static gboolean fu_main_get_updates_item_update (FuMainPrivate *priv, FuDeviceItem *item);
+
 /**
  * fu_main_emit_changed:
  **/
@@ -1103,8 +1105,10 @@
 	AsApp *app;
 	GPtrArray *apps;
 	guint i;
+	FuDeviceItem *item;
 	FuMainPrivate *priv = (FuMainPrivate *) user_data;

+	/* print what we've got */
 	apps = as_store_get_apps (priv->store);
 	if (apps->len == 0) {
 		g_debug ("no devices in store");
@@ -1117,6 +1121,14 @@
 				 as_app_get_name (app, NULL));
 		}
 	}
+
+	/* are any devices now supported? */
+	for (i = 0; i < priv->devices->len; i++) {
+		item = g_ptr_array_index (priv->devices, i);
+		if (fu_main_get_updates_item_update (priv, item))
+			fu_main_emit_device_changed (priv, item->device);
+	}
+
 	priv->store_changed_id = 0;
 	return G_SOURCE_REMOVE;
 }


event: Rename _event_max_timeout_cb to _max_timeout_triggered_cb.

Signed-off-by: Janne Mäntyharju <26626460a685506f187f11bef9c43807de9d8b55@nokia.com>

--- src/ngf-event.c
+++ src/ngf-event.c
@@ -22,7 +22,8 @@
 #include "ngf-event.h"

 static inline void  _trigger_event_callback (NgfEvent *event, NgfEventState  state);
-static gboolean     _event_max_timeout_cb (gpointer userdata);
+static gboolean     _max_timeout_triggered_cb (gpointer userdata);
+
 static void         _stream_state_cb (NgfAudioStream *stream, NgfAudioStreamState state, gpointer userdata);
 static const char*  _get_mapped_tone (NgfToneMapper *mapper, const char *tone);
 static gboolean     _event_is_vibra_enabled (NgfEvent *self);
@@ -87,9 +88,10 @@
 }

 static gboolean
-_event_max_timeout_cb (gpointer userdata)
+_max_timeout_triggered_cb (gpointer userdata)
 {
     NgfEvent *self = (NgfEvent*) userdata;
+
     self->max_length_timeout_id = 0;
     ngf_event_stop (self);

@@ -454,7 +456,7 @@

     guint max_length = ngf_properties_get_int (self->properties, "max_length");
     if (max_length > 0)
-        self->max_length_timeout_id = g_timeout_add (max_length, _event_max_timeout_cb, self);
+        self->max_length_timeout_id = g_timeout_add (max_length, _max_timeout_triggered_cb, self);

     /* Trigger the start timer, which will be used to monitor the minimum timeout. */


fixed slabptr bug (empty slabs at end)

fixed slabptr bug (empty slabs at end)

--- src/ftensor.c
+++ src/ftensor.c
@@ -50,7 +50,7 @@
     ft->vals[mode][n] = tt->vals[n];
   }

-  printf("mode: "SS_IDX" found "SS_IDX" fibers.\n", mode, nfibs);
+  printf("mode: "SS_IDX" found "SS_IDX" fibers.\n", mode+1, nfibs);

   /* allocate fiber structure */
   ft->nfibs[mode] = nfibs;
@@ -115,8 +115,10 @@
       ft->slabptr[mode][slab++] = f;
     }
   }
+
+  /* account for any empty slabs at end */
   ft->slabptr[mode][slab] = nfibs;
-  assert(slab == nslabs);
+  ft->nslabs[mode] = slab;
 }


Fix for #2283 C_Sign fails ECDSA when card can do HASH on card

Do not truncate ECDSA input to size of key if card or driver will do HASH.

 On branch Fix_for_2283_ECDSA
 Changes to be committed:
	modified:   src/libopensc/pkcs15-sec.c

--- src/libopensc/pkcs15-sec.c
+++ src/libopensc/pkcs15-sec.c
@@ -737,7 +737,7 @@
 	 * But if card is going to do the hash, pass in all the data
 	 */
 	else if (senv.algorithm == SC_ALGORITHM_EC &&
-			(senv.flags & SC_ALGORITHM_ECDSA_HASHES) == 0) {
+			(senv.algorithm_flags & SC_ALGORITHM_ECDSA_HASHES) == 0) {
 		inlen = MIN(inlen, (prkey->field_length+7)/8);
 	}


trivial: Fix up a literal format string in fwupdmgr

--- src/fu-util.c
+++ src/fu-util.c
@@ -680,7 +680,7 @@
 		g_set_error_literal (error,
 				     FWUPD_ERROR,
 				     FWUPD_ERROR_INTERNAL,
-				     "%s: failed to setup networking");
+				     "failed to setup networking");
 		return FALSE;
 	}


Now the back-end reports number of function evaluations properly.

git-svn-id: b6c97393e82be3812a607970066d172a5388f86f@1372 df83fd30-4cca-4c36-ab9d-e8b5583ccbd1

--- src/npsolWrap.c
+++ src/npsolWrap.c
@@ -687,14 +687,15 @@
 		handleFreeVarList(currentState, x, n);
 	}

-	SEXP minimum, estimate, gradient, hessian, code, status, statusMsg, iterations, ans=NULL, names=NULL, algebras, algebra, matrices, optimizer, intervals, NAmat, intervalCodes, calculatedHessian, stdErrors;
-
-	int numReturns = 12;
+	SEXP minimum, estimate, gradient, hessian, code, status, statusMsg, iterations, ans=NULL, names=NULL, algebras, algebra, matrices, optimizer, intervals, NAmat, intervalCodes, calculatedHessian, stdErrors, evaluations;
+
+	int numReturns = 13;

 	PROTECT(minimum = NEW_NUMERIC(1));
 	PROTECT(code = NEW_NUMERIC(1));
 	PROTECT(status = allocVector(VECSXP, 3));
 	PROTECT(iterations = NEW_NUMERIC(1));
+	PROTECT(evaluations = NEW_NUMERIC(2));
 	PROTECT(matrices = NEW_LIST(currentState->numMats));
 	PROTECT(algebras = NEW_LIST(currentState->numAlgs));

@@ -1014,7 +1015,7 @@
 	SET_STRING_ELT(names, nextEl++, mkChar("calculatedHessian"));
 	SET_STRING_ELT(names, nextEl++, mkChar("standardErrors"));

-	int nextEl = 0;
+	nextEl = 0;

 	SET_VECTOR_ELT(ans, nextEl++, minimum);
 	SET_VECTOR_ELT(ans, nextEl++, estimate);


Verify devices support updating in mode they are called.

Providers that have both online and offline update methods don't
do verification that the device actually supports that mode.

This caused problems for Dell TPM devices where if you called
$ fwupdmgr install tpm.cab

It would attempt to use the online stub added in 1d97c8b5.
This would of course fall over requiring you to call with
$ fwupdmgr install tpm.cab --allow-offline

This fix will guarantee that the current install fallback
logic takes into account both device and provider support
for online/offline.

--- src/fu-main.c
+++ src/fu-main.c
@@ -549,13 +549,23 @@
 			return FALSE;
 		}

-		/* The provider might have taken away update abilities */
-		if (!fu_device_has_flag (item->device, FWUPD_DEVICE_FLAG_ALLOW_OFFLINE) &&
+		/* Called with online update, test if device is supposed to allow this */
+		if (!(helper->flags & FWUPD_INSTALL_FLAG_OFFLINE) &&
 		    !fu_device_has_flag (item->device, FWUPD_DEVICE_FLAG_ALLOW_ONLINE)) {
 			g_set_error(error,
 				    FWUPD_ERROR,
-				    FWUPD_ERROR_INTERNAL,
-				    "Device %s does not now allow updates",
+				    FWUPD_ERROR_NOT_SUPPORTED,
+				    "Device %s does not allow online updates",
+				    fu_device_get_id (device));
+			return FALSE;
+		}
+		/* Called with offline update, test if device is supposed to allow this */
+		if (helper->flags & FWUPD_INSTALL_FLAG_OFFLINE &&
+		    !fu_device_has_flag (item->device, FWUPD_DEVICE_FLAG_ALLOW_OFFLINE)) {
+			g_set_error(error,
+				    FWUPD_ERROR,
+				    FWUPD_ERROR_NOT_SUPPORTED,
+				    "Device %s does not allow offline updates",
 				    fu_device_get_id (device));
 			return FALSE;
 		}


Add SLJIT_INT_OP to SLJIT_MUL and add comments about an overhead of SLJIT_INT_OP.

Based on email from Zoltán Herczeg.

--- src/bpfjit.c
+++ src/bpfjit.c
@@ -414,10 +414,14 @@
 bpf_alu_to_sljit_op(struct bpf_insn *pc)
 {

+	/*
+	 * Note: all CPUs have 32bit multiply instruction so SLJIT_INT_OP
+	 * doesn't have any overhead.
+	 */
 	switch (BPF_OP(pc->code)) {
 	case BPF_ADD: return SLJIT_ADD;
 	case BPF_SUB: return SLJIT_SUB;
-	case BPF_MUL: return SLJIT_MUL;
+	case BPF_MUL: return SLJIT_MUL|SLJIT_INT_OP;
 	case BPF_OR:  return SLJIT_OR;
 	case BPF_AND: return SLJIT_AND;
 	case BPF_LSH: return SLJIT_SHL;
@@ -433,6 +437,10 @@
 static int
 bpf_jmp_to_sljit_cond(struct bpf_insn *pc, bool negate)
 {
+	/*
+	 * Note: all CPUs have 32bit comparison instructions so SLJIT_INT_OP
+	 * doesn't have any overhead.
+	 */
 	int rv = SLJIT_INT_OP;

 	switch (BPF_OP(pc->code)) {


clarify error

clarify error

--- src/libopticon/var_parse.c
+++ src/libopticon/var_parse.c
@@ -245,7 +245,7 @@
                 }
                 if (! strchr (VALIDUNQUOTEDV, *c)) {
                     sprintf (LAST_PARSE_ERROR, "Invalid character in "
-                             "value: '%c'", *c);
+                             "value for '%s': '%c'", keybuf, *c);
                     return 0;
                 }
                 if (*c == '.') value_dots++;


FILE: optimize allocation

FILE: optimize allocation

--- src/ntru_file.c
+++ src/ntru_file.c
@@ -54,9 +54,14 @@
 	int fd = 0;
 	size_t str_size = 0;
 	ssize_t n;
+	size_t file_length = 0;
 	string *result_string;

 	fd = open(filename, O_RDONLY);
+	file_length = lseek(fd, 0, SEEK_END) + 1;
+	lseek(fd, 0, SEEK_SET);
+
+	cstring = malloc(sizeof(char) * file_length);

 	if (fd != -1) {
 		/* read and copy chunks */
@@ -69,11 +74,6 @@
 			}

 			str_size += n; /* count total bytes read */
-
-			REALLOC( /* allocate correct size */
-					cstring, /* pointer to realloc */
-					str_size /* total bytes read */
-					+ 1); /* space for trailing NULL byte */

 			/* append buffer to string */
 			memcpy(cstring + (str_size - n), buf, (size_t)n);


Snapshot that compiles --kkd

Snapshot that compiles --kkd

--- src/gateway.c
+++ src/gateway.c
@@ -5,6 +5,7 @@
 void* HandleConn(void* thread_data){
     int connfd = *(int *)thread_data;
     free(thread_data);
+

 }

@@ -50,7 +51,6 @@
     // Bind the socket and port to the name
     if(bind(listenfd, (struct sockaddr*)&serv_addr,sizeof(serv_addr)) < 0){
         fprintf(stderr,"Socket bind error: %s\n",strerror(errno));
-        free(serv_addr);
         exit(-1);
     }

@@ -60,7 +60,7 @@
      */
     if(listen(listenfd, 10) == -1){
         fprintf(stderr,"Socket listen error: %s\n",strerror(errno));
-        free(serv_addr);
+
         exit(-1);
     }

@@ -85,4 +85,6 @@
         pthread_detach(thread);

     }
+
+    return 0;
 }


Some ext2 structs.

Some ext2 structs.

--- src/Harmony/ext2.h
+++ src/Harmony/ext2.h
@@ -6,12 +6,66 @@
 #include "multiboot.h"
 #include "utilities.h"

+struct superblockExt;
+
 struct superblock{
-
+	unsigned int inodes;
+	unsigned int blocks;
+	unsigned int resBlocks; //Su reserved blocks.
+	unsigned int unallocBlocks;
+	unsigned int unallocInodes;
+	unsigned int superblock; //Superblock block location.
+	unsigned int logBlock; //1024 << (x) to get block size.
+	unsigned int logFragment; //1024 << (x) to get fragment size.
+	unsigned int blockGroupSize; //Blocks in a block group.
+	unsigned int fragmentGroupSize; //Fragments in a block group.
+	unsigned int inodeGroupSize; //Inodes in a block group.
+	unsigned int mountTime; //POSIX last mount time.
+	unsigned int writeTime; //POSIX last write time.
+	unsigned short fsckLast; //Amount of mount times since last fsck.
+	unsigned short fsckMax; //Amount of mounts before fsck must be done.
+	unsigned short signature; //0xEF53
+	unsigned short fsState; //FS state. 1 is clean; 2 is errored.
+	unsigned short errorDo; //What to do when bad things(tm). 1 is ignore, 2 is remount as ro, 3 is kernel panic.
+	unsigned short verMinor; //Minor version.
+	unsigned int fsckTime; //POSIX last fsck time.
+	unsigned int fsckInterval; //POSIX interval between forced fscks.
+	unsigned int osId; //ID of creator OS. 0 is linux, 1 is hurd, 2 is masix, 3 is freebsd, 4 is lites.
+	unsigned int verMajor; //Major version.
+	unsigned short superUser; //UID of su.
+	unsigned short superGroup; //GID of su.
+	struct superblockExt ext; //Extension of the superblock. See struct superblockExt.
 }__attribute__((packed));

-struct superblockExt{
+struct superblockExt{ //Only exists if superblock->verMajor >= 1.
+	unsigned int nosuInode; //First non-reserved inode. 11 when nonexistant.
+	unsigned short inodeSize; //Byte size of inodes. 128 when nonexistant.
+	unsigned short blockGroup; //Block group the superblock is part of, if a backup copy.
+	unsigned int optional; //Optional features present. 0x1=prealloc, 0x2=afs inodes, 0x4=journaled, 0x8=xattr, 0x10=resizable, 0x20=hashindex.
+	unsigned int required; //Required features present. 0x1=compression, 0x2=typed dirs, 0x4=journal replay, 0x8=jounalUsed.
+	unsigned int rofeat; //Readonly features present. 0x1=sparse superblock & tables, 0x2=64-bit, 0x4=binary tree.
+	unsigned char fsId[16]; //Filesystem ID.
+	unsigned char volId[16]; //Volume name, terminated with \0.
+	unsigned char path[64]; //Path volume was last mounted to, terminated with \0.
+	unsigned int compress; //What compression algorithims used if superblockExt->required & 0x1.
+	unsigned char preallocFile; //Blocks to preallocate for files.
+	unsigned char preallocDir; //Blocks to preallocate for directories.
+	unsigned short reserved1; //Reserved.
+	unsigned char journalId[16]; //Same as superblockExt->fsId.
+	unsigned int journalInode; //Inode location of the journal.
+	unsigned int journalDevice; //Block device of the journal.
+	unsigned int orphanInode; //Head of the orphan inode list.
+	unsigned char reserved2[788]; //Reserved.
+}__attribute__((packed));

+struct groupDesc{
+	unsigned int blockAddr; //Block address of the block usage bitmap.
+	unsigned int inodeAddr; //Block address of the inode usage bitmap.
+	unsigned int inodeTable; //Block address of inode table.
+	unsigned short unallocBlocks; //Unallocated blocks in group.
+	unsigned short unallocInodes; //Unallocated inodes in group.
+	unsigned short dirs; //Number of directories.
+	unsigned char reserved[14]; //Reserved.
 }__attribute__((packed));

 //True if initialized successfully.


fu-main: Fix sender_features insert with wrong size

--- src/fu-main.c
+++ src/fu-main.c
@@ -1534,11 +1534,13 @@
 		return;
 	}
 	if (g_strcmp0 (method_name, "SetFeatureFlags") == 0) {
-		guint64 feature_flags = 0;
-		g_variant_get (parameters, "(t)", &feature_flags);
-		g_debug ("Called %s(%" G_GUINT64_FORMAT ")", method_name, feature_flags);
+		FwupdFeatureFlags feature_flags;
+		guint64 feature_flags_u64 = 0;
+		g_variant_get (parameters, "(t)", &feature_flags_u64);
+		g_debug ("Called %s(%" G_GUINT64_FORMAT ")", method_name, feature_flags_u64);

 		/* old flags for the same sender will be automatically destroyed */
+		feature_flags = feature_flags_u64;
 		g_hash_table_insert (priv->sender_features,
 				     g_strdup (sender),
 				     g_memdup (&feature_flags, sizeof(feature_flags)));


Move free_blob_list into the static section of bucket.c.

Signed-off-by: Chris Lalancette <60b62644009db6b194cc0445b64e9b27bb26433a@redhat.com>

--- src/bucket.c
+++ src/bucket.c
@@ -196,6 +196,11 @@
   return ret;
 }

+static void free_blob_list(struct deltacloud_bucket_blob **blobs)
+{
+  free_list(blobs, struct deltacloud_bucket_blob, deltacloud_free_bucket_blob);
+}
+
 int deltacloud_get_buckets(struct deltacloud_api *api,
 			   struct deltacloud_bucket **buckets)
 {
@@ -483,11 +488,6 @@
   free_metadata_list(&blob->metadata);
 }

-static void free_blob_list(struct deltacloud_bucket_blob **blobs)
-{
-  free_list(blobs, struct deltacloud_bucket_blob, deltacloud_free_bucket_blob);
-}
-
 int deltacloud_bucket_destroy(struct deltacloud_api *api,
 			      struct deltacloud_bucket *bucket)
 {


GBA DMA: Add misalign warnings

GBA DMA: Add misalign warnings

--- src/gba/dma.c
+++ src/gba/dma.c
@@ -87,6 +87,15 @@
 			currentDma->reg = GBADMARegisterClearSrcControl(currentDma->reg);
 		}
 		currentDma->nextDest = currentDma->dest;
+
+		uint32_t width = 2 << GBADMARegisterGetWidth(currentDma->reg);
+		if (currentDma->nextSource & (width - 1)) {
+			mLOG(GBA_MEM, GAME_ERROR, "Misaligned DMA source address: 0x%08X", currentDma->nextSource);
+		}
+		if (currentDma->nextDest & (width - 1)) {
+			mLOG(GBA_MEM, GAME_ERROR, "Misaligned DMA destination address: 0x%08X", currentDma->nextDest);
+		}
+
 		GBADMASchedule(gba, dma, currentDma);
 	}
 	// If the DMA has already occurred, this value might have changed since the function started


remove all tabs

remove all tabs

--- src/general.c
+++ src/general.c
@@ -18,26 +18,26 @@
   git_index_write(index);

   git_index_write_tree(&tree_oid, index);
-	git_index_free(index);
-
+  git_index_free(index);
+
   git_tree_lookup(&tree, repo, &tree_oid);

   git_signature_new(&signature, "Li Xuanji", "xuanji@gmail.com", 1323847743, 60);
   git_commit_create_v(
-		&commit_oid,
-		repo,
-		"HEAD",
-		signature,
-		signature,
-		NULL,
-		message,
-		tree,
-		0);
-
-	git_tree_free(tree);
-	git_signature_free(signature);
-
-	return 0;
+    &commit_oid,
+    repo,
+    "HEAD",
+    signature,
+    signature,
+    NULL,
+    message,
+    tree,
+    0);
+
+  git_tree_free(tree);
+  git_signature_free(signature);
+
+  return 0;
 }

 int listrefs() {
@@ -61,7 +61,6 @@
       git_oid_fmt(out, git_reference_target(ref));
       printf("%s [%s]\n", refname, out);
       break;
-
     case GIT_REF_SYMBOLIC:
       printf("%s => %s\n", refname, git_reference_symbolic_target(ref));
       break;
@@ -99,13 +98,13 @@
 int general() {

   git_repository_init(&repo, "zit", 0);
-
-	touch("zit/readme", "Zit \n --- git for zombieis");
-	stage_and_commit("readme", "Initial commit\n\0");
-
-	touch("zit/TODO", "- Make project logo \n- Watch Friends");
-	stage_and_commit("TODO", "TODO\n\0");
-
+
+  touch("zit/readme", "Zit \n --- git for zombieis");
+  stage_and_commit("readme", "Initial commit\n\0");
+
+  touch("zit/TODO", "- Make project logo \n- Watch Friends");
+  stage_and_commit("TODO", "TODO\n\0");
+
   revwalk_from_head();

   listrefs();


doc(library/type_context): improve docstring for new design

cc @kha

--- src/library/type_context.h
+++ src/library/type_context.h
@@ -290,20 +290,21 @@

       *** Backtracking and scopes ***

-      The type context performs "local backtracking".
+      The type context performs "local backtracking" when deciding whether two terms
+      are definitionally equal or not (i.e., at the `is_def_eq` method).
       When backtracking, assignments have to be undone.
-      This feature is used to implement heuristics for the `is_def_eq` predicate, and
-      to undo any assignment performed by failed `is_def_eq t s` tests.
-
       For example, when checking `f a =?= f b` (i.e., `f a` is definitionally equal
       fo `f b`), we first check `a =?= b`, if it fails, we backtrack and try
       to unfold the `f`-applications. We say the backtracking is local
       because if `a =?= b` succeeds, we commit to this choice.

-      The backtracking support is implemeted using "scope" objects.
+      This kind of local backtracking is implemeted using "scope" objects.
       It saves the current state of `metavar_context` and the size of the
       trail stack (aka undo stack) for temporary metavariables. Whenever a temporary
       metavariable is assigned a new entry is inserted into the trail stack.
+
+      Remark: tyhe type class resolution procedure uses "global backtracking",
+      and can be viewed as a (very) basic lambda prolog interpreter.

       *** Unification vs Matching vs pure definitional equality ***

@@ -418,31 +419,58 @@
       metavariables created for solving different problems.

       *** Applications ***
-
-      - Elaboration and tactics such as `apply`.
-      We use regular metavariables and unification (i.e., metavariables on
-      the left and right hand side can be assigned).
+      Here we assume the `is_def_eq` general form is
+
+      lctx | (a_1, k_1, t_1) =?= (a_2, k_2, t_2)
+
+      where `lctx` is the local context for the temporary metavariables occurring in `t_i`;
+      `a_i` is a flag indicating whether metavariables occurring in `t_i` can be assigned or not;
+      `k_i` is the offset for the metavariables occurring in `t_i`.
+      The local context `lctx` is only relevant for `t_i` is `a_i` is set to true.
+      `lctx`, `k_i` are only relevant if we are in TMP mode. We use `lctx` to validate
+      whether an assignment to a temporary metavariable is valid or not.
+
+      We use the following shorthands
+
+      `(unify) t =?= s` denotes `_ | (true, 0, t) =?= (true, 0, s)`
+      `(match) t =?= s` denotes `_ | (true, 0, t) =?= (false, 0, s)`
+      `(pure) t =?= s` denotes `_ | (false, 0, t) =?= (false, 0, s)`
+      `(tmp-match) lctx | (k, t) =?= s` denotes `lctx | (true, k, t) =?= (false, 0, s)`
+      `(nested-tmp-match) lctx | (k', t) =?= (k, s)` denotes `lctx | (true, k', t) =?= (false, k, s)`
+      `(tmp-unify) lctx | t =?= s` denotes `lctx | (true, 0, t) =?= (true, 0, s)`
+
+      - Elaboration and tactics such as `apply`. We use `(unify) t =?= s`

       - We also want to support a version of `apply` where metavariables
       in the goal cannot be assigned. This variant does not exist
-      in versions <= 3.3. For this variant, we use regular metavariables and matching.
-
-      - `rewrite` tactic, we use regular metavariables and unification.
+      in versions <= 3.3. We use `(match) t =?= s`
+
+      - `rewrite` tactic, we use `(unify) t =?= s`.
       We also have the a variant (not available in versions <= 3.3) where
-      we use regular metavariables and matching.
+      we use regular metavariables and matching. In this case, we use `(match) t =?= s`
+
+      - `tactic.is_def_eq`: we use `(pure) t =?= s`

       - `app_builder`: a helper procedure for creating applications
       where missing arguments and universes levels are inferred using type inference.
-      We use temporary metavariables and unification.
-
-      - `tactic.is_def_eq`: we use regular metavariables and pure definitionally
-      equality.
-
-      - Simplification lemmas: temporary metavariables and matching.
-
-      - Ematching lemmas: similar to simplification lemmas.
+      It takes a `type_context` `ctx` as argument.
+      We use `(tmp-match) lctx | (k, t) =?= s` where `k` is the number of
+      temporary metavariables in `ctx` when invoked the `app_builder`, and the `lctx` is
+      `ctx.lctx()`
+
+      - Simplifier and Ematcher. They solve nested matching problems.
+      In versions <= 3.3, we use the `tmp_type_context` hack to be able
+      to use multiple temporary assignments. Now, we use a single tmp assignment
+      and offsets. We set `k` as the number of temporary metavariables we had
+      before we create a new matching problem. Thus, we use `(tmp-match) lctx | (k, t) =?= s`.
+      Note that, `s` does not contain temporary metavariables. It is a term from the current goal.

       - (Internal) Type class resolution: we use temporary metavariables and unification.
+      Before trying to synthesize `?m : C a_1 ... a_n`,
+      we use a preprocessing step that creates `C a_1' ... a_n'` where `a_i'` contains
+      only fresh new temporary metavariables. So, no offsets are needed since
+      we don't use pre-allocated temporary metavars. Thus, we use
+      `(tmp-unify) lctx | t =?= s` where `lctx` is the local context for `?m`.

       - (Internal) Recursive function unfolding during `is_def_eq`.
       (This feature is also not available in versions <= 3.3).
@@ -453,16 +481,20 @@
       We are essentially using the equational lemma to
       perform a delta reduction while we are solvind a
       unification/matching problem.
-      Here again we use temporary metavariables and matching.
+      We use `(nested-tmp-match) lctx | (k', t) =?= (k, s)`
+      where `lctx` is `this.lctx()`, `k'` is the number of temporary metavariable in `this`,
+      `t` is the left-hand-side of the "refl" equational lemma,
+      and `k` is the current offset associated with `s`.
+      If `s` is on the left (right) hand side of the
+      current `is_def_eq` call, then we use the current left (right) offset.

       - (Internal) Unification hints. For versions <= 3.3, we used a
       custom and very basic matching procedure to implement
       this feature. This created several stability problems
       and counterintuitive behavior. We use temporary
       metavariables and matching.
-
-      The applications tagged with `(Internal)` are considered part of the
-      type_context implementation.
+      We also use `(nested-tmp-match) lctx | (k', t) =?= (k, s)`.
+      This case is very similar to the previous one.
     */

     /* This class supports temporary meta-variables "mode". In this "tmp" mode,


Minor optimization

Minor optimization

--- src/buffer.c
+++ src/buffer.c
@@ -131,6 +131,8 @@
 {
 	char * p;

+	if(size == buffer->size)
+		return 0;
 	if((p = realloc(buffer->data, size)) == NULL && size != 0)
 		return error_set_code(-errno, "%s", strerror(errno));
 	buffer->data = p;