If the current engine is removed, then switch to another engine automatically.

BUG=http://crosbug.com/3577
TEST=manual test.

Review URL: http://codereview.chromium.org/2259004

--- bus/ibusimpl.c
+++ bus/ibusimpl.c
@@ -156,6 +156,13 @@
 static void     bus_ibus_impl_set_use_global_engine
                                                 (BusIBusImpl        *ibus,
                                                  GVariant           *value);
+static void     bus_ibus_impl_set_global_engine (BusIBusImpl        *ibus,
+                                                 BusEngineProxy     *engine);
+static void     bus_ibus_impl_set_global_engine_by_name
+                                                (BusIBusImpl        *ibus,
+                                                 const gchar        *name);
+static void     bus_ibus_impl_engines_maybe_removed
+                                                (BusIBusImpl        *ibus);
 static void     bus_ibus_impl_registry_changed  (BusIBusImpl        *ibus);
 static void     bus_ibus_impl_global_engine_changed
                                                 (BusIBusImpl        *ibus);
@@ -408,6 +415,7 @@
         }
     }

+    bus_ibus_impl_engines_maybe_removed (ibus);
     bus_ibus_impl_update_engines_hotkey_profile (ibus);
 }

@@ -1165,6 +1173,91 @@
     }
 }

+static void
+bus_ibus_impl_set_global_engine (BusIBusImpl    *ibus,
+                                 BusEngineProxy *engine)
+{
+    BusInputContext *context = NULL;
+
+    if (!ibus->use_global_engine)
+        return;
+
+    if (ibus->focused_context) {
+        bus_input_context_set_engine (ibus->focused_context, engine);
+    } else if (ibus->fake_context) {
+        bus_input_context_set_engine (ibus->fake_context, engine);
+    }
+}
+
+static void
+bus_ibus_impl_set_global_engine_by_name (BusIBusImpl *ibus,
+                                         const gchar *name)
+{
+    gchar *old_engine_name = NULL;
+
+    if (!ibus->use_global_engine)
+        return;
+
+    if (g_strcmp0 (name, ibus->global_engine_name) == 0) {
+        /* If the user requested the same global engine, then we just enable the
+         * original one. */
+        if (ibus->focused_context) {
+            bus_input_context_enable (ibus->focused_context);
+        }
+        else if (ibus->fake_context) {
+            bus_input_context_enable (ibus->fake_context);
+        }
+        return;
+    }
+
+    /* If there is a focused input context, then we just change the engine of
+     * the focused context, which will then change the global engine
+     * automatically. Otherwise, we need to change the global engine directly.
+     */
+    if (ibus->focused_context) {
+        _context_request_engine_cb (ibus->focused_context, name, ibus);
+    }
+    else if (ibus->fake_context) {
+        _context_request_engine_cb (ibus->fake_context, name, ibus);
+    }
+}
+
+static void
+bus_ibus_impl_engines_maybe_removed (BusIBusImpl *ibus)
+{
+    const gchar *old_engine_name = NULL;
+    GList *engine_list = NULL;
+
+    if (!ibus->use_global_engine || ibus->global_engine_name == NULL)
+        return;
+
+    /* The current global engine is not removed, so do nothing. */
+    if (_find_engine_desc_by_name (ibus, ibus->global_engine_name))
+        return;
+
+    /* If the previous engine is available, then just switch to it. */
+    if (ibus->global_previous_engine_name &&
+        _find_engine_desc_by_name (ibus, ibus->global_previous_engine_name)) {
+        bus_ibus_impl_set_global_engine_by_name (
+            ibus, ibus->global_previous_engine_name);
+        return;
+    }
+
+    /* Just choose one in the list. */
+    engine_list = ibus->register_engine_list;
+    if (!engine_list)
+        engine_list = ibus->engine_list;
+
+    if (engine_list) {
+        IBusEngineDesc *engine_desc = (IBusEngineDesc *)engine_list->data;
+        bus_ibus_impl_set_global_engine_by_name (ibus,
+                        ibus_engine_desc_get_name (engine_desc));
+        return;
+    }
+
+    /* No engine available? Just disable global engine. */
+    bus_ibus_impl_set_global_engine (ibus, NULL);
+}

 /**
  * _context_engine_changed_cb:
@@ -1422,6 +1515,7 @@

     g_object_unref (component);

+    bus_ibus_impl_engines_maybe_removed (ibus);
     bus_ibus_impl_update_engines_hotkey_profile (ibus);
 }


add assert

add assert

--- c/testdriver.c
+++ c/testdriver.c
@@ -125,6 +125,7 @@
             bufptr = g_expected;
             count = 3;
         } else {
+            assert(bufptr != NULL);
             strcat(bufptr, linebuf);
         }
     }


Fix duplicate xmalloc in builtin-add

Fix duplicate xmalloc in builtin-add

[jc: patch came without sign-off but it was too obvious and trivial.]

Signed-off-by: Junio C Hamano <dc50d1021234060e53ec42a77d526afa2fe07479@cox.net>

--- builtin-add.c
+++ builtin-add.c
@@ -70,7 +70,6 @@
 	base = "";
 	if (baselen) {
 		char *common = xmalloc(baselen + 1);
-		common = xmalloc(baselen + 1);
 		memcpy(common, *pathspec, baselen);
 		common[baselen] = 0;
 		path = base = common;


lib-storage: Open index with MAIL_INDEX_OPEN_FLAG_SAVEONLY if mailbox has MAILBOX_FLAG_SAVEONLY

--- src/lib-storage/index/index-storage.c
+++ src/lib-storage/index/index-storage.c
@@ -304,6 +304,8 @@
 	ibox->list_index_sync_ext_id = (uint32_t)-1;
 	ibox->index_flags = MAIL_INDEX_OPEN_FLAG_CREATE |
 		mail_storage_settings_to_index_flags(box->storage->set);
+	if ((box->flags & MAILBOX_FLAG_SAVEONLY) != 0)
+		ibox->index_flags |= MAIL_INDEX_OPEN_FLAG_SAVEONLY;
 	ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL;
 	MODULE_CONTEXT_SET(box, index_storage_module, ibox);


Make sure the mailbox is opened when enabling modseqs (fixes a STATUS crash).

--- src/lib-storage/index/index-storage.c
+++ src/lib-storage/index/index-storage.c
@@ -453,6 +453,8 @@

 	if ((feature & MAILBOX_FEATURE_CONDSTORE) != 0) {
 		box->enabled_features |= MAILBOX_FEATURE_CONDSTORE;
+		if (!box->opened)
+			index_storage_mailbox_open(ibox);
 		mail_index_modseq_enable(ibox->index);
 	}
 	return TRUE;


Evas font-engine: Don't search fi again in ot populate.

We already calculate it in content create.

git-svn-id: 6d771e449150288cc513807b7f4d2af31e9482bd@59498 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/lib/engines/common/evas_font_ot.c
+++ src/lib/engines/common/evas_font_ot.c
@@ -262,10 +262,9 @@
 }

 EAPI Eina_Bool
-evas_common_font_ot_populate_text_props(void *_fn, const Eina_Unicode *text,
-      Evas_Text_Props *props, int len)
-{
-   RGBA_Font *fn = (RGBA_Font *) _fn;
+evas_common_font_ot_populate_text_props(void *_fn __UNUSED__,
+      const Eina_Unicode *text, Evas_Text_Props *props, int len)
+{
    RGBA_Font_Int *fi;
    hb_buffer_t *buffer;
    hb_glyph_position_t *positions;
@@ -276,27 +275,7 @@
    Evas_Font_OT_Info *ot_itr;
    Evas_Coord pen_x = 0;

-   fi = fn->fonts->data;
-   /* Load the font needed for this script */
-     {
-        /* Skip common chars */
-        const Eina_Unicode *tmp;
-        for (tmp = text ;
-              *tmp &&
-              evas_common_language_char_script_get(*tmp) == EVAS_SCRIPT_COMMON ;
-              tmp++)
-          ;
-        if (!*tmp && (tmp > text)) tmp--;
-        evas_common_font_glyph_search(fn, &fi, *tmp);
-     }
-   evas_common_font_int_reload(fi);
-   if (fi->src->current_size != fi->size)
-     {
-        FTLOCK();
-        FT_Activate_Size(fi->ft.size);
-        FTUNLOCK();
-        fi->src->current_size = fi->size;
-     }
+   fi = props->font_instance;

    if (len < 0)
      {


[LIB-145] Last commit closes #277

[LIB-145] Last commit closes #277


Add skeletion of autotuning growing function

--- cpp/Mrpt.h
+++ cpp/Mrpt.h
@@ -740,6 +740,14 @@
       return beta.first + beta.second * x;
     }

+    void grow(double recall, int &optimal_votes, Mrpt &index) {
+      std::cout << "Desired recall: " << recall << "\n";
+      std::cout << "Estimated query time: " << 0.05 << "\n\n";
+      optimal_votes = 1;
+      int d = X->rows();
+      index.grow(10, 6, std::sqrt(d));
+    }
+
   private:

     void compute_exact(Mrpt &index, MatrixXi &out_exact) {
@@ -814,7 +822,6 @@
       }

       for(int i = 0; i < exact_x.size(); ++i) {
-        std::cout << exact_x[i] << " ";
         auto ri = uni(rng);
         VectorXi elected(exact_x[i]);
         for(int j = 0; j < elected.size(); ++j)
@@ -830,7 +837,7 @@
       }

-      std::cout << "\nidx_sum: " << idx_sum << "\n";
+      std::cout << "\nidx_sum: " << idx_sum;
       beta_projection = fit_theil_sen(projection_x, projection_times);
       beta_voting = fit_theil_sen(voting_x, voting_times);
       std::vector<double> ex(exact_x.size());
@@ -842,7 +849,7 @@
       beta_exact = fit_theil_sen(ex, exact_times);
       std::cout << "projection, intercept: " << beta_projection.first << " slope: " << beta_projection.second << "\n";
       std::cout << "voting, intercept: " << beta_voting.first << " slope: " << beta_voting.second << "\n";
-      std::cout << "exact, intercept: " << beta_exact.first << " slope: " << beta_exact.second << "\n";
+      std::cout << "exact, intercept: " << beta_exact.first << " slope: " << beta_exact.second << "\n\n";
     }

     const Map<const MatrixXf> *X;


Added constraint to fast bytes parameter

--- CPP/Radyx/Lzma2Compressor.h
+++ CPP/Radyx/Lzma2Compressor.h
@@ -101,7 +101,7 @@
 Lzma2Compressor<MatchTableT>::Lzma2Compressor(const Lzma2Options& options_)
 	: match_table(std::min<size_t>(options_.dictionary_size, Lzma2Encoder::GetDictionarySizeMax()),
 		options_.match_buffer_size,
-		static_cast<uint8_t>(options_.fast_length),
+		static_cast<uint8_t>(std::min(options_.fast_length, 0xFF)),
 		options_.random_filter),
 	options(options_),
 	dictionary_max(0),


viewing coordinates works

viewing coordinates works

--- c/ch13/tiny.c
+++ c/ch13/tiny.c
@@ -13,6 +13,7 @@
 ./tiny -tny_ranges -tny_use_height
 ./tiny -tny_cell_cones
 ./tiny -tny_vertex_supports
+./tiny -tny_coords_view
 ./tiny -tny_vec_view  FIXME broken
 */

@@ -57,10 +58,11 @@
     PetscSection  section;
     PetscBool     by_hand = PETSC_FALSE,
                   cell_cones = PETSC_FALSE,
+                  coords_view = PETSC_FALSE,
+                  ranges = PETSC_FALSE,
                   use_height = PETSC_FALSE,
-                  ranges = PETSC_FALSE,
-                  vertex_supports = PETSC_FALSE,
-                  vec_view = PETSC_FALSE;
+                  vec_view = PETSC_FALSE,
+                  vertex_supports = PETSC_FALSE;

     PetscInitialize(&argc,&argv,NULL,help);

@@ -69,14 +71,16 @@
                             "tiny.c", by_hand, &by_hand, NULL);CHKERRQ(ierr);
     ierr = PetscOptionsBool("-cell_cones", "print cones of each cell",
                             "tiny.c", cell_cones, &cell_cones, NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsBool("-coords_view", "print entries of a global vec for vertex coordinates",
+                            "tiny.c", coords_view, &coords_view, NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsBool("-ranges", "print point index ranges for vertices,edges,cells",
+                            "tiny.c", ranges, &ranges, NULL);CHKERRQ(ierr);
     ierr = PetscOptionsBool("-use_height", "use Height instead of Depth when printing points",
                             "tiny.c", use_height, &use_height, NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsBool("-ranges", "print point index ranges for vertices,edges,cells",
-                            "tiny.c", ranges, &ranges, NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsBool("-vec_view", "print entries of a global vec for P2 elements",
+                            "tiny.c", vec_view, &vec_view, NULL);CHKERRQ(ierr);
     ierr = PetscOptionsBool("-vertex_supports", "print supports of each vertex",
                             "tiny.c", vertex_supports, &vertex_supports, NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsBool("-vec_view", "print entries of a global vec for P2 elements",
-                            "tiny.c", vec_view, &vec_view, NULL);CHKERRQ(ierr);
     ierr = PetscOptionsEnd();

     if (by_hand) {
@@ -104,6 +108,7 @@
     DM               distributedMesh = NULL;
     ierr = DMPlexGetPartitioner(dmplex,&part);CHKERRQ(ierr);
     ierr = PetscPartitionerSetFromOptions(part);CHKERRQ(ierr);  // allows -petscpartitioner_view
+    // overlap of 0 appropriate to P2 etc. FEM:
     ierr = DMPlexDistribute(dmplex, 0, NULL, &distributedMesh);CHKERRQ(ierr);
     if (distributedMesh) {
       ierr = DMDestroy(&dmplex);CHKERRQ(ierr);
@@ -112,7 +117,7 @@

     ierr = DMSetFromOptions(dmplex); CHKERRQ(ierr);

-    // viewing of dmplex
+    // viewing of dmplex and vertex coordinates
     ierr = DMViewFromOptions(dmplex, NULL, "-dm_view"); CHKERRQ(ierr);  // why not enabled by default?
     if (ranges) {
         ierr = PlexViewRanges(dmplex,use_height); CHKERRQ(ierr);
@@ -122,6 +127,16 @@
     }
     if (vertex_supports) {
         ierr = PlexViewFans(dmplex,2,0,1); CHKERRQ(ierr);
+    }
+    if (coords_view) {
+        Vec coords;
+        ierr = DMGetCoordinates(dmplex,&coords); CHKERRQ(ierr);
+        if (coords) {
+            ierr = VecView(coords,PETSC_VIEWER_STDOUT_WORLD); CHKERRQ(ierr);
+        } else {
+            ierr = PetscPrintf(PETSC_COMM_WORLD,
+                "[vertex coordinates have not been set]\n"); CHKERRQ(ierr);
+        }
     }

     // create dofs like P2 elements using PetscSection


process_vm_access: tidy up a bit

process_vm_access: tidy up a bit

saner variable names, update linuxdoc comments, etc.

Signed-off-by: Al Viro <de609eb4d5d70b1d38ec6642adbfc33a2781f63c@zeniv.linux.org.uk>

--- mm/process_vm_access.c
+++ mm/process_vm_access.c
@@ -23,20 +23,11 @@

 /**
  * process_vm_rw_pages - read/write pages from task specified
- * @task: task to read/write from
- * @mm: mm for task
- * @process_pages: struct pages area that can store at least
- *  nr_pages_to_copy struct page pointers
- * @pa: address of page in task to start copying from/to
+ * @pages: array of pointers to pages we want to copy
  * @start_offset: offset in page to start copying from/to
  * @len: number of bytes to copy
- * @lvec: iovec array specifying where to copy to/from
- * @lvec_cnt: number of elements in iovec array
- * @lvec_current: index in iovec array we are up to
- * @lvec_offset: offset in bytes from current iovec iov_base we are up to
+ * @iter: where to copy to/from locally
  * @vm_write: 0 means copy from, 1 means copy to
- * @nr_pages_to_copy: number of pages to copy
- * @bytes_copied: returns number of bytes successfully copied
  * Returns 0 on success, error code otherwise
  */
 static int process_vm_rw_pages(struct page **pages,
@@ -79,16 +70,12 @@
  * process_vm_rw_single_vec - read/write pages from task specified
  * @addr: start memory address of target process
  * @len: size of area to copy to/from
- * @lvec: iovec array specifying where to copy to/from locally
- * @lvec_cnt: number of elements in iovec array
- * @lvec_current: index in iovec array we are up to
- * @lvec_offset: offset in bytes from current iovec iov_base we are up to
+ * @iter: where to copy to/from locally
  * @process_pages: struct pages area that can store at least
  *  nr_pages_to_copy struct page pointers
  * @mm: mm for task
  * @task: task to read/write from
  * @vm_write: 0 means copy from, 1 means copy to
- * @bytes_copied: returns number of bytes successfully copied
  * Returns 0 on success or on failure error code
  */
 static int process_vm_rw_single_vec(unsigned long addr,
@@ -103,7 +90,6 @@
 	unsigned long start_offset = addr - pa;
 	unsigned long nr_pages;
 	ssize_t rc = 0;
-	unsigned long nr_pages_copied = 0;
 	unsigned long max_pages_per_loop = PVM_MAX_KMALLOC_PAGES
 		/ sizeof(struct pages *);

@@ -112,38 +98,32 @@
 		return 0;
 	nr_pages = (addr + len - 1) / PAGE_SIZE - addr / PAGE_SIZE + 1;

-	while ((nr_pages_copied < nr_pages) && iov_iter_count(iter)) {
-		int nr_pages_to_copy;
-		int pages_pinned;
-		size_t n;
-		nr_pages_to_copy = min(nr_pages - nr_pages_copied,
-				       max_pages_per_loop);
+	while (!rc && nr_pages && iov_iter_count(iter)) {
+		int pages = min(nr_pages, max_pages_per_loop);
+		size_t bytes;

 		/* Get the pages we're interested in */
 		down_read(&mm->mmap_sem);
-		pages_pinned = get_user_pages(task, mm, pa,
-					      nr_pages_to_copy,
-					      vm_write, 0, process_pages, NULL);
+		pages = get_user_pages(task, mm, pa, pages,
+				      vm_write, 0, process_pages, NULL);
 		up_read(&mm->mmap_sem);

-		if (pages_pinned <= 0)
+		if (pages <= 0)
 			return -EFAULT;

-		n = pages_pinned * PAGE_SIZE - start_offset;
-		if (n > len)
-			n = len;
+		bytes = pages * PAGE_SIZE - start_offset;
+		if (bytes > len)
+			bytes = len;

 		rc = process_vm_rw_pages(process_pages,
-					 start_offset, n, iter,
+					 start_offset, bytes, iter,
 					 vm_write);
-		len -= n;
+		len -= bytes;
 		start_offset = 0;
-		nr_pages_copied += pages_pinned;
-		pa += pages_pinned * PAGE_SIZE;
-		while (pages_pinned)
-			put_page(process_pages[--pages_pinned]);
-		if (rc < 0)
-			break;
+		nr_pages -= pages;
+		pa += pages * PAGE_SIZE;
+		while (pages)
+			put_page(process_pages[--pages]);
 	}

 	return rc;
@@ -156,8 +136,7 @@
 /**
  * process_vm_rw_core - core of reading/writing pages from task specified
  * @pid: PID of process to read/write from/to
- * @lvec: iovec array specifying where to copy to/from locally
- * @liovcnt: size of lvec array
+ * @iter: where to copy to/from locally
  * @rvec: iovec array specifying where to copy to/from in the other process
  * @riovcnt: size of rvec array
  * @flags: currently unused


Tinyalsa dont drop unwanted frames in read.

Audio buffer size and frames to read might vary sometime with unwanted
frames which can be safely dropped.

--- apps/examples/testcase/ta_tc/audio/utc/utc_audio_main.c
+++ apps/examples/testcase/ta_tc/audio/utc/utc_audio_main.c
@@ -634,6 +634,10 @@
 		remain -= frames_read;
 		ret = write(fd, buffer, bytes_per_frame * frames_read);
 		TC_ASSERT_EQ_CLEANUP("pcm_readi", ret, (bytes_per_frame * frames_read), clean_all_data(fd, buffer));
+		if (remain < pcm_get_buffer_size(g_pcm)) {
+			pcm_drop(g_pcm);
+			break;
+		}
 	}

 	printf("Record done.\n");


reformatting: cJSON_strcasecmp

reformatting: cJSON_strcasecmp

--- cJSON_Utils.c
+++ cJSON_Utils.c
@@ -4,11 +4,25 @@
 #include <stdio.h>
 #include "cJSON_Utils.h"

-static int cJSONUtils_strcasecmp(const char *s1,const char *s2)
-{
-	if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
-	for(; tolower(*s1) == tolower(*s2); ++s1, ++s2)	if(*s1 == 0)	return 0;
-	return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
+static int cJSONUtils_strcasecmp(const char *s1, const char *s2)
+{
+    if (!s1)
+    {
+        return (s1 == s2) ? 0 : 1; /* both NULL? */
+    }
+    if (!s2)
+    {
+        return 1;
+    }
+    for(; tolower(*s1) == tolower(*s2); ++s1, ++s2)
+    {
+        if(*s1 == 0)
+        {
+            return 0;
+        }
+    }
+
+    return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
 }

 /* JSON Pointer implementation: */
@@ -392,4 +406,4 @@
 	}
 	if (!patch->child) {cJSON_Delete(patch);return 0;}
 	return patch;
-}+}


minor fix: signed/unsigned comparison warning

git-svn-id: e88a1e38e13faf406e05cc89eca8dd613216f6c4@3850 434f946d-2f3d-0410-ba4c-cb9f52fb0dbf

--- trunk/libmesh/include/numerics/distributed_vector.h
+++ trunk/libmesh/include/numerics/distributed_vector.h
@@ -563,7 +563,7 @@

   // _first_local_index is the sum of _local_size
   // for all processor ids less than ours
-  for (int p=0; p<libMesh::processor_id(); p++)
+  for (unsigned int p=0; p!=libMesh::processor_id(); p++)
     _first_local_index += local_sizes[p];

@@ -572,7 +572,7 @@
   // size, otherwise there is big trouble!
   int sum=0;

-  for (int p=0; p<libMesh::n_processors(); p++)
+  for (unsigned int p=0; p!=libMesh::n_processors(); p++)
     sum += local_sizes[p];

   libmesh_assert (sum == static_cast<int>(n));


reformatting: cJSONUtils_GeneratePatch

reformatting: cJSONUtils_GeneratePatch

--- cJSON_Utils.c
+++ cJSON_Utils.c
@@ -482,20 +482,26 @@
     return 0;
 }

-static void cJSONUtils_GeneratePatch(cJSON *patches,const char *op,const char *path,const char *suffix,cJSON *val)
-{
-	cJSON *patch=cJSON_CreateObject();
-	cJSON_AddItemToObject(patch,"op",cJSON_CreateString(op));
-	if (suffix)
-	{
-		char *newpath=(char*)malloc(strlen(path)+cJSONUtils_PointerEncodedstrlen(suffix)+2);
-		cJSONUtils_PointerEncodedstrcpy(newpath+sprintf(newpath,"%s/",path),suffix);
-		cJSON_AddItemToObject(patch,"path",cJSON_CreateString(newpath));
-		free(newpath);
-	}
-	else	cJSON_AddItemToObject(patch,"path",cJSON_CreateString(path));
-	if (val) cJSON_AddItemToObject(patch,"value",cJSON_Duplicate(val,1));
-	cJSON_AddItemToArray(patches,patch);
+static void cJSONUtils_GeneratePatch(cJSON *patches, const char *op, const char *path, const char *suffix, cJSON *val)
+{
+    cJSON *patch = cJSON_CreateObject();
+    cJSON_AddItemToObject(patch, "op", cJSON_CreateString(op));
+    if (suffix)
+    {
+        char *newpath = (char*)malloc(strlen(path) + cJSONUtils_PointerEncodedstrlen(suffix) + 2);
+        cJSONUtils_PointerEncodedstrcpy(newpath + sprintf(newpath, "%s/", path), suffix);
+        cJSON_AddItemToObject(patch, "path", cJSON_CreateString(newpath));
+        free(newpath);
+    }
+    else
+    {
+        cJSON_AddItemToObject(patch, "path", cJSON_CreateString(path));
+    }
+    if (val)
+    {
+        cJSON_AddItemToObject(patch, "value", cJSON_Duplicate(val, 1));
+    }
+    cJSON_AddItemToArray(patches, patch);
 }

 void cJSONUtils_AddPatchToArray(cJSON *array,const char *op,const char *path,cJSON *val)	{cJSONUtils_GeneratePatch(array,op,path,0,val);}


reformatting: cJSON_Utils.h

reformatting: cJSON_Utils.h

--- cJSON_Utils.h
+++ cJSON_Utils.h
@@ -1,30 +1,44 @@
 #include "cJSON.h"

-/* Implement RFC6901 (https://tools.ietf.org/html/rfc6901) JSON Pointer spec.	*/
-cJSON *cJSONUtils_GetPointer(cJSON *object,const char *pointer);
+/* Implement RFC6901 (https://tools.ietf.org/html/rfc6901) JSON Pointer spec. */
+cJSON *cJSONUtils_GetPointer(cJSON *object, const char *pointer);

-/* Implement RFC6902 (https://tools.ietf.org/html/rfc6902) JSON Patch spec.		*/
-cJSON* cJSONUtils_GeneratePatches(cJSON *from,cJSON *to);
-void cJSONUtils_AddPatchToArray(cJSON *array,const char *op,const char *path,cJSON *val);	/* Utility for generating patch array entries.	*/
-int cJSONUtils_ApplyPatches(cJSON *object,cJSON *patches);	/* Returns 0 for success. */
+/* Implement RFC6902 (https://tools.ietf.org/html/rfc6902) JSON Patch spec. */
+cJSON* cJSONUtils_GeneratePatches(cJSON *from, cJSON *to);
+/* Utility for generating patch array entries. */
+void cJSONUtils_AddPatchToArray(cJSON *array, const char *op, const char *path, cJSON *val);
+/* Returns 0 for success. */
+int cJSONUtils_ApplyPatches(cJSON *object, cJSON *patches);

 /*
 // Note that ApplyPatches is NOT atomic on failure. To implement an atomic ApplyPatches, use:
 //int cJSONUtils_AtomicApplyPatches(cJSON **object, cJSON *patches)
 //{
-//	cJSON *modme=cJSON_Duplicate(*object,1);
-//	int error=cJSONUtils_ApplyPatches(modme,patches);
-//	if (!error)	{cJSON_Delete(*object);*object=modme;}
-//	else		cJSON_Delete(modme);
-//	return error;
+//    cJSON *modme = cJSON_Duplicate(*object, 1);
+//    int error = cJSONUtils_ApplyPatches(modme, patches);
+//    if (!error)
+//    {
+//        cJSON_Delete(*object);
+//        *object = modme;
+//    }
+//    else
+//    {
+//        cJSON_Delete(modme);
+//    }
+//
+//    return error;
 //}
 // Code not added to library since this strategy is a LOT slower.
 */

 /* Implement RFC7386 (https://tools.ietf.org/html/rfc7396) JSON Merge Patch spec. */
-cJSON* cJSONUtils_MergePatch(cJSON *target, cJSON *patch); /* target will be modified by patch. return value is new ptr for target. */
-cJSON *cJSONUtils_GenerateMergePatch(cJSON *from,cJSON *to); /* generates a patch to move from -> to */
+/* target will be modified by patch. return value is new ptr for target. */
+cJSON* cJSONUtils_MergePatch(cJSON *target, cJSON *patch);
+/* generates a patch to move from -> to */
+cJSON *cJSONUtils_GenerateMergePatch(cJSON *from, cJSON *to);

-char *cJSONUtils_FindPointerFromObjectTo(cJSON *object,cJSON *target);	/* Given a root object and a target object, construct a pointer from one to the other.	*/
+/* Given a root object and a target object, construct a pointer from one to the other. */
+char *cJSONUtils_FindPointerFromObjectTo(cJSON *object, cJSON *target);

-void cJSONUtils_SortObject(cJSON *object);	/* Sorts the members of the object into alphabetical order.	*/
+/* Sorts the members of the object into alphabetical order. */
+void cJSONUtils_SortObject(cJSON *object);


Added node counter in graph curve skeleton

--- src/lib/skeleton/GraphCurveSkeleton.h
+++ src/lib/skeleton/GraphCurveSkeleton.h
@@ -439,6 +439,16 @@
 			}

 			/**
+			 *  \brief Get the number of nodes in the skeleton
+			 *
+			 *  \return Number of nodes
+			 */
+			unsigned int getNbNodes() const
+			{
+				return boost::num_vertices(m_graph);
+			}
+
+			/**
 			 *  \brief Test if the node inex is in the skeleton
 			 *
 			 *  \return true if the node is in the skeleton


- fixed output

- fixed output

--- storage/Utils/Exception.h
+++ storage/Utils/Exception.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) [2014-2015] Novell, Inc.
+ * Copyright (c) 2016 SUSE LLC
  *
  * All Rights Reserved.
  *
@@ -413,7 +414,7 @@

 	    return str << prefix << msg()
 		       << "; expected: \"" << _expected
-		       << "\" seen: \"" << _seen
+		       << "\" seen: \"" << _seen << "\""
 		       << std::endl;
 	}


codec: tx3g: missing braces

codec: tx3g: missing braces

refs c3c6e9b81d34ab970ccc9bb22f960558acb31cb8

--- modules/codec/substx3g.c
+++ modules/codec/substx3g.c
@@ -262,12 +262,17 @@
     if ( i_psz_bytelength > 2 &&
          ( !memcmp( p_pszstart, "\xFE\xFF", 2 ) || !memcmp( p_pszstart, "\xFF\xFE", 2 ) )
        )
+    {
         psz_subtitle = FromCharset( "UTF-16", p_pszstart, i_psz_bytelength );
+        if ( !psz_subtitle ) return NULL;
+    }
     else
+    {
         psz_subtitle = malloc( i_psz_bytelength + 1 );
-    if ( !psz_subtitle ) return NULL;
-    memcpy( psz_subtitle, p_pszstart, i_psz_bytelength );
-    psz_subtitle[ i_psz_bytelength ] = '\0';
+        if ( !psz_subtitle ) return NULL;
+        memcpy( psz_subtitle, p_pszstart, i_psz_bytelength );
+        psz_subtitle[ i_psz_bytelength ] = '\0';
+    }
     p_buf += i_psz_bytelength + sizeof(uint16_t);

     for( uint16_t i=0; i < i_psz_bytelength; i++ )


undefined xc_shm_t

undefined xc_shm_t

git-svn-id: 88e1a00e4eab3b0bb0c09889526309a3e2f5bd8a@1242 c26eb9a1-5813-0410-bd6c-c2e55f420ca7

--- mod_cacher/xc_cacher.c
+++ mod_cacher/xc_cacher.c
@@ -16,6 +16,7 @@
 #include "xcache/xc_ini.h"
 #include "xcache/xc_utils.h"
 #include "xcache/xc_sandbox.h"
+#include "xcache/xc_shm.h"
 #include "util/xc_trace.h"
 #include "util/xc_vector.h"
 #include "util/xc_align.h"


add description to throw macros

add description to throw macros

--- modules/core/exception.h
+++ modules/core/exception.h
@@ -4,6 +4,8 @@
 #include <string>
 #include <opencv2/core.hpp>

+/** Preprocessor macros for throwing types of Exceptions with custom error messages
+ */
 #define SEM_THROW_BAD_DIMS(msg) throw sem::ExceptionBadDims(msg)
 #define SEM_THROW_NOT_IMPLEMENTED throw sem::ExceptionNotImpl("Not implemented yet.")
 #define SEM_THROW_NOT_IMPLEMENTED_WMSG(msg) throw sem::ExceptionNotImpl(msg)


Small fix for PJS to remove "".

Small fix for PJS to remove "".

--- modules/demux/subtitle.c
+++ modules/demux/subtitle.c
@@ -56,12 +56,13 @@
 #define SUB_TYPE_LONGTEXT \
     N_("Force the subtiles format. Valid values are : \"microdvd\", " \
     "\"subrip\",  \"ssa1\", \"ssa2-4\", \"ass\", \"vplayer\" " \
-    "\"sami\", \"dvdsubtitle\", \"mpl2\" and \"auto\" (meaning autodetection, this " \
+    "\"sami\", \"dvdsubtitle\", \"mpl2\", \"aqt\", \"pjs\" and \"auto\" (meaning autodetection, this " \
     "should always work).")
 static const char *ppsz_sub_type[] =
 {
     "auto", "microdvd", "subrip", "subviewer", "ssa1",
-    "ssa2-4", "ass", "vplayer", "sami", "dvdsubtitle", "mpl2"
+    "ssa2-4", "ass", "vplayer", "sami", "dvdsubtitle", "mpl2",
+    "aqt", "pjs"
 };

 vlc_module_begin();
@@ -1309,17 +1310,20 @@
         psz_text = malloc( strlen(s) + 1 );

         /* Data Lines */
-        if( sscanf (s, "%d,%d,%[^\n\r]", &t1, &t2, psz_text ) == 3 )
+        if( sscanf (s, "%d,%d,\"%[^\n\r]", &t1, &t2, psz_text ) == 3 )
         {
             /* 1/10th of second ? Frame based ? FIXME */
             p_subtitle->i_start = 10 * t1;
             p_subtitle->i_stop = 10 * t2;
+            /* Remove latest " */
+            psz_text[ strlen(psz_text) - 1 ] = '\0 ';

             break;
         }
         free( psz_text );
     }
     p_subtitle->psz_text = psz_text;
+    msg_Dbg( p_demux, "%s", psz_text );
     return VLC_SUCCESS;
 }


FOR_TABLE will ignore multiple table entries.

--- caryll-font.h
+++ caryll-font.h
@@ -2,12 +2,12 @@

 #include "caryll-sfnt.h"

-#define foreach(item, array, size)                                                                                \
-	for (int keep = 1, count = 0; keep && count != size; keep = !keep, count++)                                        \
-		for (item = (array)[count]; keep; keep = !keep)
 #define FOR_TABLE(name, table)                                                                                \
-	foreach (caryll_piece table, packet.pieces, packet.numTables)                                                      \
-		if (table.tag == name)
+	for (int keep = 1, count = 0, __notfound = 1; __notfound && keep && count < packet.numTables;                      \
+	     keep = !keep, count++)                                                                                \
+		for (caryll_piece table = (packet.pieces)[count]; keep; keep = !keep)                                          \
+			if (table.tag == (name))                                                                                \
+				for (int k2 = 1; k2; k2 = 0, __notfound = 0)

 #define CARYLL_FONT_H


[UPD] The method btk::DataObject::Modified is now a public method. It gives the possibility to force the update of a pipeline.

git-svn-id: ed06c97986a68fa016311908f99ed1538fbb9b5d@1238 93be6e1e-6fcc-11de-baec-69240fdc299a

--- Code/Common/btkDataObject.h
+++ Code/Common/btkDataObject.h
@@ -54,6 +54,7 @@
     DataObject* GetParent() const {return this->mp_Parent;};
     BTK_COMMON_EXPORT void SetParent(DataObject* parent);

+    BTK_COMMON_EXPORT void Modified();
     BTK_COMMON_EXPORT void Update();

   protected:
@@ -70,8 +71,6 @@
       this->mp_Source = 0;
     };
     virtual ~DataObject() {};
-
-    BTK_COMMON_EXPORT void Modified();

   private:
     DataObject& operator=(const DataObject& ); // Not implemented.


criu: mem: initialize parasite_ctl->mem_pp

apparently got lost in rebase :)

Signed-off-by: Mike Rapoport <6432ce95675be77d61ce23efe20f472ee21e9f31@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <c9a32589e048e044184536f7ac71ef92fe82df3e@virtuozzo.com>

--- criu/mem.c
+++ criu/mem.c
@@ -286,7 +286,7 @@
 		return -1;

 	ret = -1;
-	pp = create_page_pipe(vma_area_list->priv_size, pargs_iovs(args),
+	ctl->mem_pp = pp = create_page_pipe(vma_area_list->priv_size, pargs_iovs(args),
 				!delayed_dump);
 	if (!pp)
 		goto out;


Remove unused registerViewportLayer

Remove unused registerViewportLayer

This finishes the rest of the sequence started with r185629.

TBR=enne, pfeldman
BUG=133097

Review URL: https://codereview.chromium.org/735333005

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@186050 bbb929c8-8fbe-4397-9dbb-9b2b20218538

--- public/platform/WebLayerTreeView.h
+++ public/platform/WebLayerTreeView.h
@@ -129,12 +129,6 @@
         const WebLayer* pageScaleLayer,
         const WebLayer* innerViewportScrollLayer,
         const WebLayer* outerViewportScrollLayer) { }
-    // TODO(ccameron): remove this function once all callers have been moved to
-    // the version that specifies the overscroll elasticity layer.
-    virtual void registerViewportLayers(
-        const WebLayer* pageScaleLayer,
-        const WebLayer* innerViewportScrollLayer,
-        const WebLayer* outerViewportScrollLayer) { }
     virtual void clearViewportLayers() { }

     // Used to update the active selection bounds.


security_selinux: Implement transaction APIs

Signed-off-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>

--- src/security/security_selinux.c
+++ src/security/security_selinux.c
@@ -78,6 +78,22 @@
     virDomainDefPtr def;
 };

+typedef struct _virSecuritySELinuxContextItem virSecuritySELinuxContextItem;
+typedef virSecuritySELinuxContextItem *virSecuritySELinuxContextItemPtr;
+struct _virSecuritySELinuxContextItem {
+    const char *path;
+    const char *tcon;
+    bool optional;
+};
+
+typedef struct _virSecuritySELinuxContextList virSecuritySELinuxContextList;
+typedef virSecuritySELinuxContextList *virSecuritySELinuxContextListPtr;
+struct _virSecuritySELinuxContextList {
+    bool privileged;
+    virSecuritySELinuxContextItemPtr *items;
+    size_t nItems;
+};
+
 #define SECURITY_SELINUX_VOID_DOI       "0"
 #define SECURITY_SELINUX_NAME "selinux"

@@ -85,6 +101,115 @@
 virSecuritySELinuxRestoreTPMFileLabelInt(virSecurityManagerPtr mgr,
                                          virDomainDefPtr def,
                                          virDomainTPMDefPtr tpm);
+
+
+virThreadLocal contextList;
+
+static int
+virSecuritySELinuxContextListAppend(virSecuritySELinuxContextListPtr list,
+                                    const char *path,
+                                    const char *tcon,
+                                    bool optional)
+{
+    virSecuritySELinuxContextItemPtr item;
+
+    if (VIR_ALLOC(item) < 0)
+        return -1;
+
+    item->path = path;
+    item->tcon = tcon;
+    item->optional = optional;
+
+    if (VIR_APPEND_ELEMENT(list->items, list->nItems, item) < 0) {
+        VIR_FREE(item);
+        return -1;
+    }
+
+    return 0;
+}
+
+static void
+virSecuritySELinuxContextListFree(void *opaque)
+{
+    virSecuritySELinuxContextListPtr list = opaque;
+    size_t i;
+
+    if (!list)
+        return;
+
+    for (i = 0; i < list->nItems; i++)
+        VIR_FREE(list->items[i]);
+    VIR_FREE(list);
+}
+
+
+/**
+ * virSecuritySELinuxTransactionAppend:
+ * @path: Path to chown
+ * @tcon: target context
+ * @optional: true if setting @tcon is optional
+ *
+ * Appends an entry onto transaction list.
+ *
+ * Returns: 1 in case of successful append
+ *          0 if there is no transaction enabled
+ *         -1 otherwise.
+ */
+static int
+virSecuritySELinuxTransactionAppend(const char *path,
+                                    const char *tcon,
+                                    bool optional)
+{
+    virSecuritySELinuxContextListPtr list;
+
+    list = virThreadLocalGet(&contextList);
+    if (!list)
+        return 0;
+
+    if (virSecuritySELinuxContextListAppend(list, path, tcon, optional) < 0)
+        return -1;
+
+    return 1;
+}
+
+
+static int virSecuritySELinuxSetFileconHelper(const char *path,
+                                              const char *tcon,
+                                              bool optional,
+                                              bool privileged);
+
+/**
+ * virSecuritySELinuxTransactionRun:
+ * @pid: process pid
+ * @opaque: opaque data
+ *
+ * This is the callback that runs in the same namespace as the domain we are
+ * relabelling. For given transaction (@opaque) it relabels all the paths on
+ * the list.
+ *
+ * Returns: 0 on success
+ *         -1 otherwise.
+ */
+static int
+virSecuritySELinuxTransactionRun(pid_t pid ATTRIBUTE_UNUSED,
+                                 void *opaque)
+{
+    virSecuritySELinuxContextListPtr list = opaque;
+    size_t i;
+
+    for (i = 0; i < list->nItems; i++) {
+        virSecuritySELinuxContextItemPtr item = list->items[i];
+
+        /* TODO Implement rollback */
+        if (virSecuritySELinuxSetFileconHelper(item->path,
+                                               item->tcon,
+                                               item->optional,
+                                               list->privileged) < 0)
+            return -1;
+    }
+
+    return 0;
+}

 /*
@@ -560,6 +685,14 @@
 virSecuritySELinuxInitialize(virSecurityManagerPtr mgr)
 {
     VIR_DEBUG("SELinuxInitialize %s", virSecurityManagerGetDriver(mgr));
+
+    if (virThreadLocalInit(&contextList,
+                           virSecuritySELinuxContextListFree) < 0) {
+        virReportSystemError(errno, "%s",
+                             _("Unable to initialize thread local variable"));
+        return -1;
+    }
+
     if (STREQ(virSecurityManagerGetDriver(mgr),  "LXC")) {
         return virSecuritySELinuxLXCInitialize(mgr);
     } else {
@@ -843,6 +976,110 @@
     return SECURITY_SELINUX_VOID_DOI;
 }

+/**
+ * virSecuritySELinuxTransactionStart:
+ * @mgr: security manager
+ *
+ * Starts a new transaction. In transaction nothing is changed context
+ * until TransactionCommit() is called. This is implemented as a list
+ * that is appended to whenever setfilecon() would be called. Since
+ * secdriver APIs can be called from multiple threads (to work over
+ * different domains) the pointer to the list is stored in thread local
+ * variable.
+ *
+ * Returns 0 on success,
+ *        -1 otherwise.
+ */
+static int
+virSecuritySELinuxTransactionStart(virSecurityManagerPtr mgr)
+{
+    bool privileged = virSecurityManagerGetPrivileged(mgr);
+    virSecuritySELinuxContextListPtr list;
+
+    list = virThreadLocalGet(&contextList);
+    if (list) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Another relabel transaction is already started"));
+        return -1;
+    }
+
+    if (VIR_ALLOC(list) < 0)
+        return -1;
+
+    list->privileged = privileged;
+
+    if (virThreadLocalSet(&contextList, list) < 0) {
+        virReportSystemError(errno, "%s",
+                             _("Unable to set thread local variable"));
+        VIR_FREE(list);
+        return -1;
+    }
+
+    return 0;
+}
+
+/**
+ * virSecuritySELinuxTransactionCommit:
+ * @mgr: security manager
+ * @pid: domain's PID
+ *
+ * Enters the @pid namespace (usually @pid refers to a domain) and
+ * performs all the sefilecon()-s on the list. Note that the
+ * transaction is also freed, therefore new one has to be started after
+ * successful return from this function. Also it is considered as error
+ * if there's no transaction set and this function is called.
+ *
+ * Returns: 0 on success,
+ *         -1 otherwise.
+ */
+static int
+virSecuritySELinuxTransactionCommit(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
+                                    pid_t pid)
+{
+    virSecuritySELinuxContextListPtr list;
+    int ret = 0;
+
+    list = virThreadLocalGet(&contextList);
+    if (!list)
+        return 0;
+
+    if (virThreadLocalSet(&contextList, NULL) < 0) {
+        virReportSystemError(errno, "%s",
+                             _("Unable to clear thread local variable"));
+        goto cleanup;
+    }
+
+    if (virProcessRunInMountNamespace(pid,
+                                      virSecuritySELinuxTransactionRun,
+                                      list) < 0)
+        goto cleanup;
+
+    ret = 0;
+ cleanup:
+    virSecuritySELinuxContextListFree(list);
+    return ret;
+}
+
+/**
+ * virSecuritySELinuxTransactionAbort:
+ * @mgr: security manager
+ *
+ * Cancels and frees any out standing transaction.
+ */
+static void
+virSecuritySELinuxTransactionAbort(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
+{
+    virSecuritySELinuxContextListPtr list;
+
+    list = virThreadLocalGet(&contextList);
+    if (!list)
+        return;
+
+    if (virThreadLocalSet(&contextList, NULL) < 0)
+        VIR_DEBUG("Unable to clear thread local variable");
+    virSecuritySELinuxContextListFree(list);
+}
+
 static int
 virSecuritySELinuxGetProcessLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                   virDomainDefPtr def ATTRIBUTE_UNUSED,
@@ -885,10 +1122,19 @@
  * return 1 if labelling was not possible.  Otherwise, require a label
  * change, and return 0 for success, -1 for failure.  */
 static int
-virSecuritySELinuxSetFileconHelper(const char *path, char *tcon,
+virSecuritySELinuxSetFileconHelper(const char *path, const char *tcon,
                                    bool optional, bool privileged)
 {
     security_context_t econ;
+    int rc;
+
+    /* Be aware that this function might run in a separate process.
+     * Therefore, any driver state changes would be thrown away. */
+
+    if ((rc = virSecuritySELinuxTransactionAppend(path, tcon, optional)) < 0)
+        return -1;
+    else if (rc > 0)
+        return 0;

     VIR_INFO("Setting SELinux context on '%s' to '%s'", path, tcon);

@@ -945,7 +1191,7 @@

 static int
 virSecuritySELinuxSetFileconOptional(virSecurityManagerPtr mgr,
-                                     const char *path, char *tcon)
+                                     const char *path, const char *tcon)
 {
     bool privileged = virSecurityManagerGetPrivileged(mgr);
     return virSecuritySELinuxSetFileconHelper(path, tcon, true, privileged);
@@ -953,7 +1199,7 @@

 static int
 virSecuritySELinuxSetFilecon(virSecurityManagerPtr mgr,
-                             const char *path, char *tcon)
+                             const char *path, const char *tcon)
 {
     bool privileged = virSecurityManagerGetPrivileged(mgr);
     return virSecuritySELinuxSetFileconHelper(path, tcon, false, privileged);
@@ -2667,6 +2913,10 @@
     .getModel                           = virSecuritySELinuxGetModel,
     .getDOI                             = virSecuritySELinuxGetDOI,

+    .transactionStart                   = virSecuritySELinuxTransactionStart,
+    .transactionCommit                  = virSecuritySELinuxTransactionCommit,
+    .transactionAbort                   = virSecuritySELinuxTransactionAbort,
+
     .domainSecurityVerify               = virSecuritySELinuxVerify,

     .domainSetSecurityDiskLabel         = virSecuritySELinuxSetDiskLabel,


rtp sout: support IPv6 in SDP for RTSP

rtp sout: support IPv6 in SDP for RTSP

--- modules/stream_out/rtp.c
+++ modules/stream_out/rtp.c
@@ -763,13 +763,18 @@
     {
         inclport = 0;

+        /* Check against URL format rtsp://[<ipv6>]:<port>/<path> */
+        bool ipv6 = rtsp_url != NULL && strlen( rtsp_url ) > 7
+                    && rtsp_url[7] == '[';
+
         /* Dummy destination address for RTSP */
-        memset (&dst, 0, sizeof( struct sockaddr_in ) );
-        dst.ss_family = AF_INET;
+        dstlen = ipv6 ? sizeof( struct sockaddr_in6 )
+                      : sizeof( struct sockaddr_in );
+        memset (&dst, 0, dstlen);
+        dst.ss_family = ipv6 ? AF_INET6 : AF_INET;
 #ifdef HAVE_SA_LEN
-        dst.ss_len =
-#endif
-        dstlen = sizeof( struct sockaddr_in );
+        dst.ss_len = dstlen;
+#endif
     }

     psz_sdp = vlc_sdp_Start( VLC_OBJECT( p_stream ), SOUT_CFG_PREFIX,


Separate MCS range parsing from MCS range checking

Pull the code which parses the current process MCS range
out of virSecuritySELinuxMCSFind and into a new method
virSecuritySELinuxMCSGetProcessRange.

Signed-off-by: Daniel P. Berrange <bb938cf255e055ff3507f2627d214e8e62118fcf@redhat.com>

--- src/security/security_selinux.c
+++ src/security/security_selinux.c
@@ -105,93 +105,14 @@

 static char *
-virSecuritySELinuxMCSFind(virSecurityManagerPtr mgr)
+virSecuritySELinuxMCSFind(virSecurityManagerPtr mgr,
+                          const char *sens,
+                          int catMin,
+                          int catMax)
 {
     virSecuritySELinuxDataPtr data = virSecurityManagerGetPrivateData(mgr);
-    int c1 = 0;
-    int c2 = 0;
+    int catRange;
     char *mcs = NULL;
-    security_context_t ourSecContext = NULL;
-    context_t ourContext = NULL;
-    char *sens = NULL, *cat, *tmp;
-    int catMin, catMax, catRange;
-
-    if (getcon_raw(&ourSecContext) < 0) {
-        virReportSystemError(errno, "%s",
-                             _("Unable to get current process SELinux context"));
-        goto cleanup;
-    }
-    if (!(ourContext = context_new(ourSecContext))) {
-        virReportSystemError(errno,
-                             _("Unable to parse current SELinux context '%s'"),
-                             ourSecContext);
-        goto cleanup;
-    }
-
-    if (!(sens = strdup(context_range_get(ourContext)))) {
-        virReportOOMError();
-        goto cleanup;
-    }
-
-    /* Find and blank out the category part */
-    if (!(tmp = strchr(sens, ':'))) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Cannot parse sensitivity level in %s"),
-                       sens);
-        goto cleanup;
-    }
-    *tmp = '\0';
-    cat = tmp + 1;
-    /* Find and blank out the sensitivity upper bound */
-    if ((tmp = strchr(sens, '-')))
-        *tmp = '\0';
-    /* sens now just contains the sensitivity lower bound */
-
-    /* Find & extract category min */
-    tmp = cat;
-    if (tmp[0] != 'c') {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Cannot parse category in %s"),
-                       cat);
-        goto cleanup;
-    }
-    tmp++;
-    if (virStrToLong_i(tmp, &tmp, 10, &catMin) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Cannot parse category in %s"),
-                       cat);
-        goto cleanup;
-    }
-
-    /* We *must* have a pair of categories otherwise
-     * there's no range to allocate VM categories from */
-    if (!tmp[0]) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("No category range available"));
-        goto cleanup;
-    }
-
-    /* Find & extract category max (if any) */
-    if (tmp[0] != '.') {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Cannot parse category in %s"),
-                       cat);
-        goto cleanup;
-    }
-    tmp++;
-    if (tmp[0] != 'c') {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Cannot parse category in %s"),
-                       cat);
-        goto cleanup;
-    }
-    tmp++;
-    if (virStrToLong_i(tmp, &tmp, 10, &catMax) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Cannot parse category in %s"),
-                       cat);
-        goto cleanup;
-    }

     /* +1 since virRandomInt range is exclusive of the upper bound */
     catRange = (catMax - catMin) + 1;
@@ -200,21 +121,22 @@
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Category range c%d-c%d too small"),
                        catMin, catMax);
-        goto cleanup;
+        return NULL;
     }

     VIR_DEBUG("Using sensitivity level '%s' cat min %d max %d range %d",
               sens, catMin, catMax, catRange);

     for (;;) {
-        c1 = virRandomInt(catRange);
-        c2 = virRandomInt(catRange);
-        VIR_DEBUG("Try cat %s:c%d,c%d", sens, c1+catMin, c2+catMin);
+        int c1 = virRandomInt(catRange);
+        int c2 = virRandomInt(catRange);
+
+        VIR_DEBUG("Try cat %s:c%d,c%d", sens, c1 + catMin, c2 + catMin);

         if (c1 == c2) {
             if (virAsprintf(&mcs, "%s:c%d", sens, catMin + c1) < 0) {
                 virReportOOMError();
-                goto cleanup;
+                return NULL;
             }
         } else {
             if (c1 > c2) {
@@ -224,22 +146,114 @@
             }
             if (virAsprintf(&mcs, "%s:c%d,c%d", sens, catMin + c1, catMin + c2) < 0) {
                 virReportOOMError();
-                goto cleanup;
+                return NULL;
             }
         }

         if (virHashLookup(data->mcs, mcs) == NULL)
-            goto cleanup;
+            break;

         VIR_FREE(mcs);
     }

+    return mcs;
+}
+
+static int
+virSecuritySELinuxMCSGetProcessRange(char **sens,
+                                     int *catMin,
+                                     int *catMax)
+{
+    security_context_t ourSecContext = NULL;
+    context_t ourContext = NULL;
+    char *cat, *tmp;
+    int ret = -1;
+
+    if (getcon_raw(&ourSecContext) < 0) {
+        virReportSystemError(errno, "%s",
+                             _("Unable to get current process SELinux context"));
+        goto cleanup;
+    }
+    if (!(ourContext = context_new(ourSecContext))) {
+        virReportSystemError(errno,
+                             _("Unable to parse current SELinux context '%s'"),
+                             ourSecContext);
+        goto cleanup;
+    }
+
+    if (!(*sens = strdup(context_range_get(ourContext)))) {
+        virReportOOMError();
+        goto cleanup;
+    }
+
+    /* Find and blank out the category part */
+    if (!(tmp = strchr(*sens, ':'))) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Cannot parse sensitivity level in %s"),
+                       *sens);
+        goto cleanup;
+    }
+    *tmp = '\0';
+    cat = tmp + 1;
+    /* Find and blank out the sensitivity upper bound */
+    if ((tmp = strchr(*sens, '-')))
+        *tmp = '\0';
+    /* sens now just contains the sensitivity lower bound */
+
+    /* Find & extract category min */
+    tmp = cat;
+    if (tmp[0] != 'c') {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Cannot parse category in %s"),
+                       cat);
+        goto cleanup;
+    }
+    tmp++;
+    if (virStrToLong_i(tmp, &tmp, 10, catMin) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Cannot parse category in %s"),
+                       cat);
+        goto cleanup;
+    }
+
+    /* We *must* have a pair of categories otherwise
+     * there's no range to allocate VM categories from */
+    if (!tmp[0]) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("No category range available"));
+        goto cleanup;
+    }
+
+    /* Find & extract category max (if any) */
+    if (tmp[0] != '.') {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Cannot parse category in %s"),
+                       cat);
+        goto cleanup;
+    }
+    tmp++;
+    if (tmp[0] != 'c') {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Cannot parse category in %s"),
+                       cat);
+        goto cleanup;
+    }
+    tmp++;
+    if (virStrToLong_i(tmp, &tmp, 10, catMax) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Cannot parse category in %s"),
+                       cat);
+        goto cleanup;
+    }
+
+    ret = 0;
+
 cleanup:
-    VIR_DEBUG("Found context '%s'", NULLSTR(mcs));
-    VIR_FREE(sens);
+    if (ret < 0)
+        VIR_FREE(*sens);
     freecon(ourSecContext);
     context_free(ourContext);
-    return mcs;
+    return ret;
 }

 static char *
@@ -559,6 +573,8 @@
     virSecurityLabelDefPtr seclabel;
     virSecuritySELinuxDataPtr data;
     const char *baselabel;
+    char *sens = NULL;
+    int catMin, catMax;

     seclabel = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME);
     if (seclabel == NULL) {
@@ -609,7 +625,15 @@
         break;

     case VIR_DOMAIN_SECLABEL_DYNAMIC:
-        if (!(mcs = virSecuritySELinuxMCSFind(mgr)))
+        if (virSecuritySELinuxMCSGetProcessRange(&sens,
+                                                 &catMin,
+                                                 &catMax) < 0)
+            goto cleanup;
+
+        if (!(mcs = virSecuritySELinuxMCSFind(mgr,
+                                              sens,
+                                              catMin,
+                                              catMax)))
             goto cleanup;

         if (virSecuritySELinuxMCSAdd(mgr, mcs) < 0)
@@ -688,6 +712,7 @@
         context_free(ctx);
     VIR_FREE(scontext);
     VIR_FREE(mcs);
+    VIR_FREE(sens);

     VIR_DEBUG("model=%s label=%s imagelabel=%s baselabel=%s",
               NULLSTR(seclabel->model),


added tracing

added tracing

--- src/seedsprovider/dyn_florida.c
+++ src/seedsprovider/dyn_florida.c
@@ -52,7 +52,7 @@
    printf("ENV PORT %s\n", getenv("DYNOMITE_FLORIDA_PORT"));
    printf("ENV REQUEST %s\n ", getenv("DYNOMITE_FLORIDA_REQUEST") );
    printf("IP %s\n", floridaIp);
-   printf("PORT %s\n", floridaPort);
+   printf("PORT %d\n", floridaPort);
    printf("REQUEST %s\n ", request);
 }


删掉kill信息

删掉kill信息

--- cpServer.c
+++ cpServer.c
@@ -85,7 +85,7 @@
         if (conn->fpm_pid)
         {
             kill(conn->fpm_pid, 9);
-            printf("kill %d\n",conn->fpm_pid);
+          //  printf("kill %d\n",conn->fpm_pid);
         }
     }
 }


implement all flavours of RET

implement all flavours of RET

--- ctl_unit.c
+++ ctl_unit.c
@@ -889,6 +889,36 @@
 enum cb_ops {
 	CB_OP_BIT = 1, CB_OP_RES = 2, CB_OP_SET = 3
 };
+
+/*!
+ * @brief RET (0xC9) - return from CALL
+ * @result pop two bytes from the stack and jump to that location
+ */
+void ret(emulator_state *state)
+{
+	state->pc = mem_read16(state, state->sp);
+	state->sp += 2;
+}
+
+/*!
+ * @brief RETNZ (0xC0) - return from CALL if Z flag not set
+ * @result RET, if Z flag not set, otherwise nothing.
+ */
+void retnz(emulator_state *state)
+{
+	if(!(state->flag_reg & FLAG_Z)) ret(state);
+	else state->pc++;
+}
+
+/*!
+ * @brief RETZ (0xC8) - return from CALL if Z flag set
+ * @result RET, if Z flag is set, otherwise nothing.
+ */
+void retz(emulator_state *state)
+{
+	if(state->flag_reg & FLAG_Z) ret(state);
+	else state->pc++;
+}

 /*!
  * @brief CB ..
@@ -978,6 +1008,36 @@
 	mem_write16(state, state->sp, ++state->pc);

 	state->pc = (msb<<8 | lsb);
+}
+
+/*!
+ * @brief RETNC (0xD0) - return from CALL if C flag not set
+ * @result RET, if C flag not set, otherwise nothing.
+ */
+void retnc(emulator_state *state)
+{
+	if(!(state->flag_reg & FLAG_C)) ret(state);
+	else state->pc++;
+}
+
+/*!
+ * @brief RETC (0xD8) - return from CALL if C flag set
+ * @result RET, if C flag is set, otherwise nothing.
+ */
+void retc(emulator_state *state)
+{
+	if(state->flag_reg & FLAG_C) ret(state);
+	else state->pc++;
+}
+
+/*!
+ * @brief RETI (0xD9) - return from CALL and enable interrupts
+ * @result RET + EI
+ */
+void reti(emulator_state *state)
+{
+	state->toggle_int_on_next = true;
+	ret(state);
 }

 /*!
@@ -1114,10 +1174,10 @@
 	/* 0xA8 */ xor_b, xor_c, xor_d, xor_e, xor_h, xor_l, NULL, xor_a,
 	/* 0xB0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	/* 0xB8 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-	/* 0xC0 */ NULL, NULL, NULL, jp_imm16, NULL, NULL, NULL, NULL,
-	/* 0xC8 */ NULL, NULL, NULL, cb_dispatch, NULL, call_imm16, NULL, NULL,
-	/* 0xD0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-	/* 0xD8 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	/* 0xC0 */ retnz, NULL, NULL, jp_imm16, NULL, NULL, NULL, NULL,
+	/* 0xC8 */ retz, ret, NULL, cb_dispatch, NULL, call_imm16, NULL, NULL,
+	/* 0xD0 */ retnc, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	/* 0xD8 */ retc, reti, NULL, NULL, NULL, NULL, NULL, NULL,
 	/* 0xE0 */ ldh_imm8_a, NULL, NULL, NULL, NULL, NULL, and_imm8, NULL,
 	/* 0xE8 */ NULL, NULL, ld_d16_a, NULL, NULL, NULL, NULL, NULL,
 	/* 0xF0 */ ldh_a_imm8, NULL, NULL, di, NULL, NULL, NULL, NULL,


* src/libshogun/kernel/GaussianKernel.h:

  - public get_width() added.

--- src/libshogun/kernel/GaussianKernel.h
+++ src/libshogun/kernel/GaussianKernel.h
@@ -75,6 +75,14 @@
 		 */
 		inline virtual const char* get_name() const { return "GaussianKernel"; }

+		/** return the kernel's width
+		 *
+		 * @return kernel width
+		 */
+		inline virtual float64_t get_width(void) const {
+			return width;
+		}
+
 	protected:
 		/** compute kernel function for features a and b
 		 * idx_{a,b} denote the index of the feature vectors


implement all 8-bit ADD insrs

implement all 8-bit ADD insrs

--- ctl_unit.c
+++ ctl_unit.c
@@ -1232,8 +1232,90 @@
 	state->pc++;
 }

+static inline void add_common(emulator_state *state, uint8_t to_add)
+{
+	/* TODO flags */
+	*REG_A(state) += to_add;
+	if(*REG_A(state) == 0) state->flag_reg |= FLAG_Z;
+
+	state->pc++;
+}
+
+/*!
+ * @brief ADD B (0x80)
+ * @result A += B
+ */
+void add_b(emulator_state *state)
+{
+	add_common(state, *REG_B(state));
+}
+
+/*!
+ * @brief ADD C (0x81)
+ * @result A += C
+ */
+void add_c(emulator_state *state)
+{
+	add_common(state, *REG_C(state));
+}
+
+/*!
+ * @brief ADD D (0x82)
+ * @result A += D
+ */
+void add_d(emulator_state *state)
+{
+	add_common(state, *REG_D(state));
+}
+
+/*!
+ * @brief ADD E (0x83)
+ * @result A += E
+ */
+void add_e(emulator_state *state)
+{
+	add_common(state, *REG_E(state));
+}
+
+/*!
+ * @brief ADD H (0x84)
+ * @result A += H
+ */
+void add_h(emulator_state *state)
+{
+	add_common(state, *REG_H(state));
+}
+
+/*!
+ * @brief ADD L (0x85)
+ * @result A += L
+ */
+void add_l(emulator_state *state)
+{
+	add_common(state, *REG_L(state));
+}
+
+/*!
+ * @brief ADD (HL) (0x86)
+ * @result A += contents of memory at HL
+ */
+void add_hl(emulator_state *state)
+{
+	add_common(state, mem_read8(state, state->hl));
+}
+
+/*!
+ * @brief ADD A (0x87)
+ * @result A += A
+ */
+void add_a(emulator_state *state)
+{
+	add_common(state, *REG_A(state));
+}
+
 void sub_common(emulator_state *state, uint8_t to_sub)
 {
+	/* TODO flags */
 	*REG_A(state) -= to_sub;

 	state->pc++;
@@ -1695,6 +1777,15 @@
 	state->sp -= 2;
 	mem_write16(state, state->sp, state->bc);
 	state->pc++;
+}
+
+/*!
+ * @brief ADD n (0xC6)
+ * @result A += immediate (n)
+ */
+void add_imm8(emulator_state *state)
+{
+	add_common(state, mem_read8(state, ++state->pc));
 }

 enum cb_regs
@@ -2301,7 +2392,7 @@
 	/* 0x68 */ ld_l_b, ld_l_c, ld_l_d, ld_l_e, ld_l_h, ld_l_l, ld_l_hl, ld_l_a,
 	/* 0x70 */ ld_hl_b, ld_hl_c, ld_hl_d, ld_hl_e, ld_hl_h, ld_hl_l, NULL, ld_hl_a,
 	/* 0x78 */ ld_a_b, ld_a_c, ld_a_d, ld_a_e, ld_a_h, ld_a_l, ld_a_hl, ld_a_a,
-	/* 0x80 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	/* 0x80 */ add_b, add_c, add_d, add_e, add_h, add_l, add_hl, add_a,
 	/* 0x88 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	/* 0x90 */ sub_b, sub_c, sub_d, sub_e, sub_h, sub_l, sub_hl, sub_a,
 	/* 0x98 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -2309,7 +2400,7 @@
 	/* 0xA8 */ xor_b, xor_c, xor_d, xor_e, xor_h, xor_l, xor_hl, xor_a,
 	/* 0xB0 */ or_b, or_c, or_d, or_e, or_h, or_l, or_hl, or_a,
 	/* 0xB8 */ cp_b, cp_c, cp_d, cp_e, cp_h, cp_l, cp_hl, cp_a,
-	/* 0xC0 */ retnz, pop_bc, jp_nz_imm16, jp_imm16, NULL, push_bc, NULL, NULL,
+	/* 0xC0 */ retnz, pop_bc, jp_nz_imm16, jp_imm16, NULL, push_bc, add_imm8, NULL,
 	/* 0xC8 */ retz, ret, jp_z_imm16, cb_dispatch, NULL, call_imm16, NULL, NULL,
 	/* 0xD0 */ retnc, pop_de, jp_nc_imm16, NULL, NULL, push_de, sub_imm8, NULL,
 	/* 0xD8 */ retc, reti, jp_c_imm16, NULL, NULL, NULL, NULL, NULL,


*-login: Ignore ENOTCONN error for shutdown() It's probably just a duplicate of a previous read() failure.

--- src/login-common/client-common-auth.c
+++ src/login-common/client-common-auth.c
@@ -442,7 +442,7 @@

 		/* the fd may still be hanging somewhere in kernel or another
 		   process. make sure the client gets disconnected. */
-		if (shutdown(client->fd, SHUT_RDWR) < 0)
+		if (shutdown(client->fd, SHUT_RDWR) < 0 && errno != ENOTCONN)
 			i_error("shutdown() failed: %m");

 		if (data == NULL)


removed printf

removed printf

--- src/ludumdare31/ld31/game/ld31_game.c
+++ src/ludumdare31/ld31/game/ld31_game.c
@@ -982,7 +982,7 @@
 								break;
 							}
 						}
-						printf("%i \n", e->health);
+
 						e->speed = (rand() % 3 + 1);
 						e->attack_speed = 2000;
 						e->last_shot = 0;


Fixed the evaluation of expressions involving tensors of 2 or 3 elements on CUDA devices.

--- unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
+++ unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
@@ -168,11 +168,10 @@
     const Index PacketSize = unpacket_traits<typename Evaluator::PacketReturnType>::size;
     const Index vectorized_step_size = step_size * PacketSize;
     const Index vectorized_size = (size / PacketSize) * PacketSize;
-    Index i = first_index * PacketSize;
-    for ( ; i < vectorized_size; i += vectorized_step_size) {
+    for (Index i = first_index * PacketSize; i < vectorized_size; i += vectorized_step_size) {
       eval.evalPacket(i);
     }
-    for ( ; i < size; i += step_size) {
+    for (Index i = vectorized_size + first_index; i < size; i += step_size) {
       eval.evalScalar(i);
     }
   }


adapted monitor invocations for K1OM

adapted monitor invocations for K1OM

--- usr/monitor/include/arch/k1om/monitor_invocations.h
+++ usr/monitor/include/arch/k1om/monitor_invocations.h
@@ -4,166 +4,16 @@
  */

 /*
- * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
+ * Copyright (c) 2014 ETH Zurich.
  * All rights reserved.
  *
  * This file is distributed under the terms in the attached LICENSE file.
  * If you do not find this file, copies can be found by writing to:
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group.
  */

-#ifndef INVOCATIONS_H
-#define INVOCATIONS_H
+/*
+ * XXX: reuse the standard x86_64 headers
+ */

-#include <barrelfish/syscall_arch.h>
-#include <barrelfish/caddr.h>
-#include <barrelfish/invocations_arch.h>
-
-/**
- * \brief Spawn a new core.
- *
- * \param core_id    APIC ID of the core to try booting
- * \param cpu_type   Type of core to boot
- * \param entry      Kernel entry point in physical memory
- */
-static inline errval_t
-invoke_monitor_spawn_core(coreid_t core_id, enum cpu_type cpu_type,
-                          forvaddr_t entry)
-{
-    return cap_invoke4(cap_kernel, KernelCmd_Spawn_core, core_id, cpu_type,
-                       entry).error;
-}
-
-static inline errval_t
-invoke_monitor_identify_cap(capaddr_t cap, int bits, struct capability *out)
-{
-    return cap_invoke4(cap_kernel, KernelCmd_Identify_cap, cap, bits,
-                       (uintptr_t)out).error;
-}
-
-static inline errval_t
-invoke_monitor_identify_domains_cap(capaddr_t root_cap, int root_bits,
-                                    capaddr_t cap, int bits,
-                                    struct capability *out)
-{
-    return cap_invoke6(cap_kernel, KernelCmd_Identify_domains_cap,
-                       root_cap, root_bits, cap, bits, (uintptr_t)out).error;
-}
-
-
-static inline errval_t
-invoke_monitor_nullify_cap(capaddr_t cap, int bits)
-{
-    return cap_invoke3(cap_kernel, KernelCmd_Nullify_cap, cap, bits).error;
-}
-
-static inline errval_t
-invoke_monitor_cap_remote(capaddr_t cap, int bits, bool is_remote,
-                          bool * has_descendents)
-{
-    struct sysret r = cap_invoke4(cap_kernel, KernelCmd_Remote_cap, cap, bits,
-                                  is_remote);
-    if (err_is_ok(r.error)) {
-        *has_descendents = r.value;
-    }
-    return r.error;
-}
-
-static inline errval_t
-invoke_monitor_create_cap(uint64_t *raw, capaddr_t caddr, int bits, capaddr_t slot)
-{
-    assert(sizeof(struct capability) % sizeof(uint64_t) == 0);
-    assert(sizeof(struct capability) / sizeof(uint64_t) == 4);
-    return cap_invoke8(cap_kernel, KernelCmd_Create_cap,
-                       raw[0], raw[1], raw[2], raw[3],
-                       caddr, bits, slot).error;
-}
-
-static inline errval_t
-invoke_monitor_register(struct capref ep)
-{
-    return cap_invoke2(cap_kernel, KernelCmd_Register, get_cap_addr(ep)).error;
-}
-
-static inline errval_t
-invoke_monitor_identify_cnode_get_cap(uint64_t *cnode_raw, capaddr_t slot,
-                                      struct capability *out)
-{
-    return cap_invoke4(cap_kernel, KernelCmd_Iden_cnode_get_cap,
-                       (uintptr_t)cnode_raw, slot, (uintptr_t)out).error;
-}
-
-
-static inline errval_t
-invoke_monitor_remote_cap_retype(capaddr_t rootcap_addr, uint8_t rootcap_vbits,
-                                 capaddr_t src, enum objtype newtype,
-                                 int objbits, capaddr_t to, capaddr_t slot,
-                                 int bits) {
-    return cap_invoke9(cap_kernel, MonitorCmd_Retype, rootcap_addr,
-                       rootcap_vbits, src, newtype, objbits, to, slot,
-                       bits).error;
-}
-
-static inline errval_t
-invoke_monitor_remote_cap_delete(capaddr_t rootcap_addr, uint8_t rootcap_vbits,
-                                 capaddr_t src, int bits) {
-    return cap_invoke5(cap_kernel, MonitorCmd_Delete, rootcap_addr,
-                       rootcap_vbits, src, bits).error;
-}
-
-static inline errval_t
-invoke_monitor_remote_cap_revoke(capaddr_t rootcap_addr, uint8_t rootcap_vbits,
-                                 capaddr_t src, int bits) {
-    return cap_invoke5(cap_kernel, MonitorCmd_Revoke, rootcap_addr,
-                       rootcap_vbits, src, bits).error;
-}
-
-/**
- * \brief Set up tracing in the kernel
- *
- */
-static inline errval_t
-invoke_trace_setup(struct capref cap)
-{
-    return cap_invoke2(cap_kernel, KernelCmd_Setup_trace,
-                       get_cap_addr(cap)).error;
-}
-
-static inline errval_t
-invoke_domain_id(struct capref cap, domainid_t domain_id)
-{
-    return cap_invoke3(cap_kernel, KernelCmd_Domain_Id, get_cap_addr(cap),
-                       domain_id).error;
-}
-
-static inline errval_t invoke_monitor_sync_timer(uint64_t synctime)
-{
-    return cap_invoke2(cap_kernel, KernelCmd_Sync_timer, synctime).error;
-}
-
-static inline errval_t
-invoke_monitor_ipi_register(struct capref ep, int chanid)
-{
-    return cap_invoke3(cap_kernel, KernelCmd_IPI_Register, get_cap_addr(ep),
-                       chanid).error;
-}
-
-static inline errval_t
-invoke_monitor_ipi_delete(int chanid)
-{
-    return cap_invoke2(cap_kernel, KernelCmd_IPI_Delete, chanid).error;
-}
-
-static inline errval_t
-invoke_monitor_get_arch_id(uintptr_t *arch_id)
-{
-    assert(arch_id != NULL);
-
-    struct sysret sysret = cap_invoke1(cap_kernel, KernelCmd_Get_arch_id);
-    if (sysret.error == SYS_ERR_OK) {
-        *arch_id = sysret.value;
-    }
-    return sysret.error;
-}
-
-#endif
+#include "../x86_64/monitor_invocations.h"


- complete new tp_alloc_skb()

- complete new tp_alloc_skb()

--- strinet/src/drivers/udp.c
+++ strinet/src/drivers/udp.c
@@ -4141,7 +4141,7 @@
  * through the data to generate the checksum.
  */
 #if defined LFS
-STATIC INLINE streams_fastcall __hot_out struct sk_buff *
+STATIC noinline streams_fastcall __unlikely struct sk_buff *
 tp_alloc_skb_old(struct tp *tp, mblk_t *mp, unsigned int headroom, int gfp)
 {
 	struct sk_buff *skb;
@@ -4282,9 +4282,30 @@
 STATIC INLINE streams_fastcall __hot_out struct sk_buff *
 tp_alloc_skb(struct tp *tp, mblk_t *mp, unsigned int headroom, int gfp)
 {
-	goto old_way;
+	struct sk_buff *skb;
+
+	if (unlikely((mp->b_datap->db_flag & (DB_SKBUFF)) == 0))
+		goto old_way;
+	if (unlikely((mp->b_rptr < mp->b_datap->db_base + headroom)))
+		goto go_slow;
+	if (unlikely((skb = (typeof(skb)) mp->b_datap->db_frtnp->free_arg) == NULL))
+		goto go_slow;
+	skb_get(skb);
+	skb_reserve(skb, mp->b_rptr - skb->data);
+	skb_put(skb, mp->b_wptr - mp->b_rptr);
+	/* we never have any page fragments, so we can steal a pointer from the page fragement
+	   list. */
+	assert(skb_shinfo(skb)->nr_frags == 0);
+	skb_shinfo(skb)->frags[0].page = (struct page *) tp_get(tp);
+	skb->destructor = tp_skb_destructor;
+	spin_lock_bh(&tp->qlock);
+	tp->sndmem += skb->truesize;
+	spin_unlock_bh(&tp->qlock);
+	return (skb);
       old_way:
 	return tp_alloc_skb_old(tp, mp, headroom, gfp);
+      go_slow:
+	return tp_alloc_skb_slow(tp, mp, headroom, gfp);
 }
 #else				/* !defined LFS */
 STATIC INLINE streams_fastcall __hot_out struct sk_buff *


Fixed error handling when file loading fails

git-svn-id: ab66a9de07fa9d47c5829c82992f5279466c775f@2520 63c20433-aa62-49bd-875c-5a186b69a8fb

--- modules/isom_in/read.c
+++ modules/isom_in/read.c
@@ -221,13 +221,10 @@
 	}

 	if (isor_is_local(szURL)) {
-//		if (!read->mov) read->mov = gf_isom_open(szURL, GF_ISOM_OPEN_READ, NULL);
 		GF_Err e = gf_isom_open_progressive(szURL, &read->mov, &read->missing_bytes);
 		if (e != GF_OK){
-		    GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("[IsoMedia] : error while opening %s, error=%s\n", szURL, gf_error_to_string(e)));
-		}
-		if (!read->mov) {
-			gf_term_on_connect(serv, NULL, gf_isom_last_error(NULL));
+		    GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[IsoMedia] : error while opening %s, error=%s\n", szURL, gf_error_to_string(e)));
+			gf_term_on_connect(serv, NULL, e);
 			return GF_OK;
 		}
 		read->frag_type = gf_isom_is_fragmented(read->mov) ? 1 : 0;


Minor tweak to 'convenience' database query function to improve error return.

--- database.c
+++ database.c
@@ -110,7 +110,11 @@
 }

 int db_read_single(const char *query, MYSQL_BIND *params, MYSQL_BIND *results) {
-	db_read_open(query, params, results);
-	db_read_fetch();
+	if (db_read_open(query, params, results) == -1) {
+		return -1;
+	}
+	if (db_read_fetch() == -1) {
+		return -1;
+	}
 	return db_read_close();
 }


BLE: switch default to stay at 9600 baud

--- src/BLE/ble.h
+++ src/BLE/ble.h
@@ -31,7 +31,7 @@
 	void echoBTreply(bool printDebug = false);
 	bool setUseFasterBaudRateUponBegin(bool enable = true) { return useFasterBaudRateUponBegin = enable; }
 protected:
-	bool useFasterBaudRateUponBegin = true;
+	bool useFasterBaudRateUponBegin = false; //default as to whether to use faster baud rate or not
 	void setSerialBaudRate(int new_baud);
 	int hardwareFactoryReset(bool printDebug = false);
 	void switchToNewBaudRate(int new_baudrate);


Bugfix in node tx queue handling.

Bugfix in node tx queue handling.

--- db/shard.h
+++ db/shard.h
@@ -339,6 +339,10 @@
         if (nodes.find(node) != nodes.end()) {
             n = nodes[node];
             n->waiters++;
+            // first wait for node to become free
+            while (n->in_use) {
+                n->cv.wait();
+            }
             // check if write exists in queue---in case we are recovering from failure
             bool exists = false;
             for (auto &p: n->tx_queue) {
@@ -347,14 +351,18 @@
                     break;
                 }
             }
-            if (exists) {
+            if (exists && n->tx_queue.front() != comp) {
+                // write exists in queue, but cannot be executed right now
                 while (n->in_use || n->tx_queue.front() != comp) {
                     n->cv.wait();
                 }
-            } // if doesn't exist, then execute write immediately
+                n->tx_queue.pop_front();
+            } else if (exists) {
+                // write exists in queue and is the first
+                n->tx_queue.pop_front();
+            }
             n->waiters--;
             n->in_use = true;
-            n->tx_queue.pop_front();
         }
         update_mutex.unlock();


Various encoder bug-fixes

Various encoder bug-fixes

--- src/Encoder.c
+++ src/Encoder.c
@@ -78,7 +78,6 @@
     ZydisEncoderTableOperand operands[5];
     ZydisOpcodeMap map;
     ZydisInstructionAttributes attribs;
-    ZydisModRMMod modRmReg;
     ZydisModeConstraint modeConstraint;
     ZydisPrefixBit prefixBits;
     uint8_t mandatoryPrefix; // 0x00 = None
@@ -251,8 +250,8 @@
     ZYDIS_ASSERT(ctx);

     // Can we use short 2-byte VEX encoding?
-    if (ctx->info->details.vex.X      == 1 &&
-        ctx->info->details.vex.B      == 1 &&
+    if (ctx->info->details.vex.X      == 0 &&
+        ctx->info->details.vex.B      == 0 &&
         ctx->info->details.vex.W      == 0 &&
         ctx->info->details.vex.m_mmmm == 1)
     {
@@ -472,9 +471,11 @@
         case 'X': ctx->info->details.sib.index = lowerBits; break;
         default: ZYDIS_UNREACHABLE;
     }
+
+    // No top bit? Quick exit.
+    if (!topBit) return ZYDIS_STATUS_SUCCESS;

     uint8_t* topBitDst = NULL;
-
     switch (ctx->info->encoding)
     {
     case ZYDIS_INSTRUCTION_ENCODING_DEFAULT:
@@ -532,13 +533,36 @@
            reg == ZYDIS_REGISTER_RBP;
 }

-static ZydisBool ZydisIsStackReg(ZydisRegister reg)
+static ZydisBool ZydisIsSPReg(ZydisRegister reg)
 {
     return reg == ZYDIS_REGISTER_SPL ||
            reg == ZYDIS_REGISTER_SP  ||
            reg == ZYDIS_REGISTER_ESP ||
-           reg == ZYDIS_REGISTER_RSP ||
-           ZydisIsBPReg(reg);
+           reg == ZYDIS_REGISTER_RSP;
+}
+
+static ZydisBool ZydisIsStackReg(ZydisRegister reg)
+{
+    return ZydisIsSPReg(reg) || ZydisIsBPReg(reg);
+}
+
+static ZydisStatus ZydisSetREXWIfRequired(ZydisEncoderContext* ctx, ZydisRegister reg)
+{
+    ZydisRegisterClass regClass = ZydisRegisterGetClass(reg);
+    if (regClass == ZYDIS_REGCLASS_GPR64)
+    {
+        if (ctx->info->mode == ZYDIS_DISASSEMBLER_MODE_64BIT)
+        {
+            ctx->info->details.rex.W = 0x01;
+            ctx->info->attributes |= ZYDIS_ATTRIB_HAS_REX;
+        }
+        else
+        {
+            return ZYDIS_STATUS_IMPOSSIBLE_INSTRUCTION; // TODO
+        }
+    }
+
+    return ZYDIS_STATUS_SUCCESS;
 }

 static ZydisStatus ZydisPrepareMemoryOperand(ZydisEncoderContext* ctx,
@@ -628,13 +652,13 @@
         ctx->info->attributes |= ZYDIS_ATTRIB_HAS_SEGMENT_ES;
         break;
     case ZYDIS_REGISTER_SS:
-        ctx->info->attributes |= ZYDIS_ATTRIB_HAS_SEGMENT_SS;
+        if (!ZydisIsStackReg(operand->mem.base))
+        {
+            ctx->info->attributes |= ZYDIS_ATTRIB_HAS_SEGMENT_SS;
+        }
         break;
     case ZYDIS_REGISTER_CS:
-        if (!ZydisIsStackReg(operand->mem.base))
-        {
-            ctx->info->attributes |= ZYDIS_ATTRIB_HAS_SEGMENT_CS;
-        }
+        ctx->info->attributes |= ZYDIS_ATTRIB_HAS_SEGMENT_CS;
         break;
     case ZYDIS_REGISTER_DS:
         if (ZydisIsStackReg(operand->mem.base))
@@ -652,18 +676,13 @@
         return ZYDIS_STATUS_IMPOSSIBLE_INSTRUCTION; // TODO: Better status.
     }

-    // SIB byte required?
-    if (operand->mem.index || operand->mem.scale)
-    {
-        // Base and index register must be of same register class, verify.
-        if (ZydisRegisterGetClass(operand->mem.index) != baseRegClass)
-        {
-            return ZYDIS_STATUS_IMPOSSIBLE_INSTRUCTION; // TODO
-        }
-
+    // SIB byte required? rSP can only be encoded with SIB.
+    if (operand->mem.index || operand->mem.scale || ZydisIsSPReg(operand->mem.base))
+    {
         // Translate scale to SIB format.
         switch (operand->mem.scale)
         {
+        case 0: // We take 0 (uninitialized, 0 from memset) as * 1.
         case 1: ctx->info->details.sib.scale = 0x00; break;
         case 2: ctx->info->details.sib.scale = 0x01; break;
         case 4: ctx->info->details.sib.scale = 0x02; break;
@@ -671,11 +690,25 @@
         default: return ZYDIS_STATUS_IMPOSSIBLE_INSTRUCTION; // TODO
         }

-        // Base & index register.
+        // Move base register info to SIB.
         ctx->info->details.sib.base = ctx->info->details.modrm.rm;
-        ZYDIS_CHECK(ZydisPrepareRegOperand(ctx, operand->mem.index, 'X'));
-
         ctx->info->details.modrm.rm = 0x04 /* SIB */;
+
+        // Process index register.
+        if (operand->mem.index != ZYDIS_REGISTER_NONE)
+        {
+            // Base and index register must be of same register class, verify.
+            if (ZydisRegisterGetClass(operand->mem.index) != baseRegClass)
+            {
+                return ZYDIS_STATUS_IMPOSSIBLE_INSTRUCTION; // TODO
+            }
+            ZYDIS_CHECK(ZydisPrepareRegOperand(ctx, operand->mem.index, 'X'));
+        }
+        else
+        {
+            ctx->info->details.sib.index = 0x04 /* no index */;
+        }
+
         ctx->info->attributes |= ZYDIS_ATTRIB_HAS_SIB;
     }

@@ -748,6 +781,7 @@
     {
         ZYDIS_ASSERT(!ctx->info->details.modrm.reg);
         ZYDIS_CHECK(ZydisPrepareRegOperand(ctx, operand->reg, 'R'));
+        ZYDIS_CHECK(ZydisSetREXWIfRequired(ctx, operand->reg));
     } break;
     case ZYDIS_OPERAND_ENCODING_RM:
     case ZYDIS_OPERAND_ENCODING_RM_CD2:
@@ -772,6 +806,7 @@
         else if (operand->type == ZYDIS_OPERAND_TYPE_REGISTER)
         {
             ZYDIS_CHECK(ZydisPrepareRegOperand(ctx, operand->reg, 'B'));
+            ZYDIS_CHECK(ZydisSetREXWIfRequired(ctx, operand->reg));
             ctx->info->details.modrm.mod = 0x03 /* reg */;
         }

@@ -782,9 +817,10 @@
     {
         int16_t reg = ZydisRegisterGetId(operand->reg);
         if (reg == -1) return ZYDIS_STATUS_INVALID_PARAMETER;
-        ctx->info->opcode += reg & 0x0F;
-        ctx->info->details.rex.R = (reg & 0x08) >> 3;
+        ctx->info->opcode += reg & 0x07;
+        ctx->info->details.rex.B = (reg & 0x08) >> 3;
         if (ctx->info->details.rex.B) ctx->info->attributes |= ZYDIS_ATTRIB_HAS_REX;
+        //ZYDIS_CHECK(ZydisSetREXWIfRequired(ctx, operand->reg));
         break;
     }
     case ZYDIS_OPERAND_ENCODING_VVVV:
@@ -909,9 +945,10 @@
             const ZydisEncoderTableOperand* curEncoderOp = &curEntry->operands[k];
             const ZydisOperandInfo* curReqOp = &info->operands[k];
             if (curReqOp->encoding != curEncoderOp->encoding) goto continueTopLevel;
-            ZydisOperandType simpleType;
-            ZYDIS_CHECK(ZydisSimplifyOperandType(curEncoderOp->type, &simpleType));
-            if (curReqOp->type != simpleType) goto continueTopLevel;
+            //ZydisOperandType simpleType;
+            //ZYDIS_CHECK(ZydisSimplifyOperandType(curEncoderOp->type, &simpleType));
+            //if (curReqOp->type != simpleType) goto continueTopLevel;
+            if (curReqOp->temp != curEncoderOp->type) goto continueTopLevel;
         }

         // Still here? We found our entry!
@@ -987,16 +1024,20 @@
     info->details.evex.B  = (pb & ZYDIS_PREFBIT_EVEX_B ) ? 1 : 0;
     info->details.evex.L2 = (pb & ZYDIS_PREFBIT_EVEX_L2) ? 1 : 0;
     info->details.vex.L   = (pb & ZYDIS_PREFBIT_VEX_L  ) ? 1 : 0;
-    info->details.rex.W   = (pb & ZYDIS_PREFBIT_REX_W  ) ? 1 : 0;
+    if (info->details.rex.W)
+    {
+        info->details.rex.W = 1;
+        info->attributes |= ZYDIS_ATTRIB_HAS_REX;
+    }
     ZYDIS_CHECK(ZydisPrepareMandatoryPrefixes(&ctx));

     // Prepare opcode.
     ZYDIS_CHECK(ZydisPrepareOpcode(&ctx));

     // Some instructions have additional opcode bits encoded in ModRM.reg.
-    if (ctx.matchingEntry->modRmReg != 0xFF)
-    {
-        ctx.info->details.modrm.reg = ctx.matchingEntry->modRmReg;
+    if (ctx.matchingEntry->modrmReg != 0xFF)
+    {
+        ctx.info->details.modrm.reg = ctx.matchingEntry->modrmReg;
     }

     // Analyze and prepare operands.


Add missing fclose state

Add missing fclose state

--- apps/examples/testcase/le_tc/filesystem/fs_main.c
+++ apps/examples/testcase/le_tc/filesystem/fs_main.c
@@ -1746,6 +1746,7 @@

 	/* A case with NULL filename, valid stream and mode flag */
 	fp = freopen(NULL, "r", fp);
+	fclose(fp);
 	TC_ASSERT_NEQ("freopen", fp, NULL);

 	/* A negative case with NULL path, valid stream and invalid mode. It will return NULL */


Revert "[CPUFREQ] speedstep-centrino should ignore upper performance control bits"

This reverts commit d7a1944e8da5e91859b98259189aaaa4d8b7fa07.

--- arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
+++ arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -463,10 +463,6 @@
 	}

 	for (i=0; i<p->state_count; i++) {
-		/* clear high bits (set by some BIOSes) that are non-relevant and
-		   problematic for this driver's MSR only frequency transition code */
-		p->states[i].control &= 0xffff;
-
 		if (p->states[i].control != p->states[i].status) {
 			dprintk("Different control (%llu) and status values (%llu)\n",
 				p->states[i].control, p->states[i].status);


MIPS: bcm63xx: Fix header_crc comment in bcm963xx_tag.h

The CRC32 actually includes the tag_version.

Signed-off-by: Jonas Gorski <9712c064bde5a52658fc87d6454b4956f9bf286b@gmail.com>
Cc: 562397917b9a8bf316569a848858b12fb417723f@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2275/
Signed-off-by: Ralf Baechle <92f48d309cda194c8eda36aa8f9ae28c488fa208@linux-mips.org>

--- arch/mips/include/asm/mach-bcm63xx/bcm963xx_tag.h
+++ arch/mips/include/asm/mach-bcm63xx/bcm963xx_tag.h
@@ -88,7 +88,7 @@
 	char kernel_crc[CRC_LEN];
 	/* 228-235: Unused at present */
 	char reserved1[8];
-	/* 236-239: CRC32 of header excluding tagVersion */
+	/* 236-239: CRC32 of header excluding last 20 bytes */
 	char header_crc[CRC_LEN];
 	/* 240-255: Unused at present */
 	char reserved2[16];


net: add struct newlink_extras

net: add struct newlink_extras

We'll use this struct in the next patch to set some top level IFLA_ members
that we need for restoring macvlan devices.

travis-ci: success for series starting with [v10,01/11] net: pass the struct nlattrs to dump() functions
Signed-off-by: Tycho Andersen <10c18fcb898ee6b17d6575d444b125d10b3f4d6a@canonical.com>
Signed-off-by: Pavel Emelyanov <c9a32589e048e044184536f7ac71ef92fe82df3e@virtuozzo.com>

--- criu/net.c
+++ criu/net.c
@@ -842,8 +842,17 @@
 	char buf[1024];
 };

+/* Optional extra things to be provided at the top level of the NEWLINK
+ * request.
+ */
+struct newlink_extras {
+	int netns_id;		/* IFLA_NET_NS_ID */
+	int link;		/* IFLA_LINK */
+	int target_netns;	/* IFLA_NET_NS_FD */
+};
+
 static int populate_newlink_req(struct newlink_req *req, int msg_type, NetDeviceEntry *nde,
-		int (*link_info)(NetDeviceEntry *, struct newlink_req *))
+		int (*link_info)(NetDeviceEntry *, struct newlink_req *), struct newlink_extras *extras)
 {
 	memset(req, 0, sizeof(*req));

@@ -861,6 +870,17 @@
 		req->i.ifi_index = nde->ifindex;
 	req->i.ifi_flags = nde->flags;

+	if (extras) {
+		if (extras->netns_id >= 0)
+			addattr_l(&req->h, sizeof(*req), IFLA_LINK_NETNSID, &extras->netns_id, sizeof(extras->netns_id));
+
+		if (extras->link >= 0)
+			addattr_l(&req->h, sizeof(*req), IFLA_LINK, &extras->link, sizeof(extras->link));
+
+		if (extras->target_netns >= 0)
+			addattr_l(&req->h, sizeof(*req), IFLA_NET_NS_FD, &extras->target_netns, sizeof(extras->target_netns));
+
+	}

 	addattr_l(&req->h, sizeof(*req), IFLA_IFNAME, nde->name, strlen(nde->name));
 	addattr_l(&req->h, sizeof(*req), IFLA_MTU, &nde->mtu, sizeof(nde->mtu));
@@ -890,11 +910,12 @@
 }

 static int do_rtm_link_req(int msg_type, NetDeviceEntry *nde, int nlsk,
-		int (*link_info)(NetDeviceEntry *, struct newlink_req *))
+		int (*link_info)(NetDeviceEntry *, struct newlink_req *),
+		struct newlink_extras *extras)
 {
 	struct newlink_req req;

-	if (populate_newlink_req(&req, msg_type, nde, link_info) < 0)
+	if (populate_newlink_req(&req, msg_type, nde, link_info, extras) < 0)
 		return -1;

 	return do_rtnl_req(nlsk, &req, req.h.nlmsg_len, restore_link_cb, NULL, NULL);
@@ -902,14 +923,15 @@

 int restore_link_parms(NetDeviceEntry *nde, int nlsk)
 {
-	return do_rtm_link_req(RTM_SETLINK, nde, nlsk, NULL);
+	return do_rtm_link_req(RTM_SETLINK, nde, nlsk, NULL, NULL);
 }

 static int restore_one_link(NetDeviceEntry *nde, int nlsk,
-		int (*link_info)(NetDeviceEntry *, struct newlink_req *))
+		int (*link_info)(NetDeviceEntry *, struct newlink_req *),
+		struct newlink_extras *extras)
 {
 	pr_info("Restoring netdev %s idx %d\n", nde->name, nde->ifindex);
-	return do_rtm_link_req(RTM_NEWLINK, nde, nlsk, link_info);
+	return do_rtm_link_req(RTM_NEWLINK, nde, nlsk, link_info, extras);
 }

 #ifndef VETH_INFO_MAX
@@ -1014,14 +1036,13 @@
 	case ND_TYPE__EXTLINK:  /* see comment in images/netdev.proto */
 		return restore_link_parms(nde, nlsk);
 	case ND_TYPE__VENET:
-		return restore_one_link(nde, nlsk, venet_link_info);
+		return restore_one_link(nde, nlsk, venet_link_info, NULL);
 	case ND_TYPE__VETH:
-		return restore_one_link(nde, nlsk, veth_link_info);
+		return restore_one_link(nde, nlsk, veth_link_info, NULL);
 	case ND_TYPE__TUN:
 		return restore_one_tun(nde, nlsk);
 	case ND_TYPE__BRIDGE:
-		return restore_one_link(nde, nlsk, bridge_link_info);
-
+		return restore_one_link(nde, nlsk, bridge_link_info, NULL);
 	default:
 		pr_err("Unsupported link type %d\n", nde->type);
 		break;


Revert "logging: Use spin lock"

Revert "logging: Use spin lock"

This reverts commit dfe9561d9b643b41cbf466d7b8b73d5c85df976f.

Signed-off-by: Anas Nashif <0d9952ec84ac43c159f6b7e7ed99a9080c00dd6e@intel.com>

--- subsys/logging/log_core.c
+++ subsys/logging/log_core.c
@@ -89,7 +89,6 @@
 static uint32_t log_strdup_max;
 static uint32_t log_strdup_longest;
 static struct k_timer log_process_thread_timer;
-static struct k_spinlock list_lock;

 static log_timestamp_t dummy_timestamp(void);
 static log_timestamp_get_t timestamp_func = dummy_timestamp;
@@ -229,50 +228,43 @@

 static void z_log_msg_post_finalize(void)
 {
+	atomic_val_t cnt = atomic_inc(&buffered_cnt);

 	if (panic_mode) {
-		static struct k_spinlock process_lock;
-		k_spinlock_key_t key = k_spin_lock(&process_lock);
-
+		unsigned int key = irq_lock();
 		(void)log_process(false);
-		k_spin_unlock(&process_lock, key);
-	} else if (proc_tid != NULL) {
-		static atomic_t reentry_flag;
-		atomic_val_t cnt = atomic_inc(&buffered_cnt);
-
-		if (cnt == 0) {
-			if (atomic_inc(&reentry_flag) == 0) {
-				k_timer_start(&log_process_thread_timer,
-				      K_MSEC(CONFIG_LOG_PROCESS_THREAD_SLEEP_MS),
-				      K_NO_WAIT);
-			}
-			atomic_dec(&reentry_flag);
-		} else if (CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD &&
-			   cnt == CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD) {
+		irq_unlock(key);
+	} else if (proc_tid != NULL && cnt == 0) {
+		k_timer_start(&log_process_thread_timer,
+			K_MSEC(CONFIG_LOG_PROCESS_THREAD_SLEEP_MS), K_NO_WAIT);
+	} else if (CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD) {
+		if ((cnt == CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD) &&
+		    (proc_tid != NULL)) {
 			k_timer_stop(&log_process_thread_timer);
 			k_sem_give(&log_process_thread_sem);
-		} else {
-			/* No action needed. Message processing will be triggered by the
-			 * timeout or when number of upcoming messages exceeds the
-			 * threshold.
-			 */
-		}
+		}
+	} else {
+		/* No action needed. Message processing will be triggered by the
+		 * timeout or when number of upcoming messages exceeds the
+		 * threshold.
+		 */
+		;
 	}
 }

 static inline void msg_finalize(struct log_msg *msg,
 				struct log_msg_ids src_level)
 {
-	k_spinlock_key_t key;
+	unsigned int key;

 	msg->hdr.ids = src_level;
 	msg->hdr.timestamp = timestamp_func();

-	key = k_spin_lock(&list_lock);
+	key = irq_lock();

 	log_list_add_tail(&list, msg);

-	k_spin_unlock(&list_lock, key);
+	irq_unlock(key);

 	z_log_msg_post_finalize();
 }
@@ -793,10 +785,10 @@
 		return msg;
 	}

-	k_spinlock_key_t key = k_spin_lock(&list_lock);
+	int key = irq_lock();

 	msg.msg = log_list_head_get(&list);
-	k_spin_unlock(&list_lock, key);
+	irq_unlock(key);

 	return msg;
 }
@@ -912,14 +904,14 @@

 	if (IS_ENABLED(CONFIG_LOG_STRDUP_POOL_PROFILING)) {
 		size_t slen = strlen(str);
-		static struct k_spinlock strdup_lock;
+		static struct k_spinlock lock;
 		k_spinlock_key_t key;

-		key = k_spin_lock(&strdup_lock);
+		key = k_spin_lock(&lock);
 		log_strdup_in_use++;
 		log_strdup_max = MAX(log_strdup_in_use, log_strdup_max);
 		log_strdup_longest = MAX(slen, log_strdup_longest);
-		k_spin_unlock(&strdup_lock, key);
+		k_spin_unlock(&lock, key);
 	}

 	/* Set 'allocated' flag. */


tty: Deprecate no-regfile entry case

tty: Deprecate no-regfile entry case

TTY files carry link on regfile entry since 1.4 (commit caa64d97)

Signed-off-by: Pavel Emelyanov <c9a32589e048e044184536f7ac71ef92fe82df3e@virtuozzo.com>
Acked-by: Cyrill Gorcunov <7a1ea01eee6961eb1e372e3508c2670446d086f4@openvz.org>

--- criu/tty.c
+++ criu/tty.c
@@ -1541,6 +1541,9 @@
 	 */
 	info->reg_d = try_collect_special_file(info->tfe->id, 1);
 	if (!info->reg_d) {
+		if (!deprecated_ok("TTY w/o regfile"))
+			return -1;
+
 		if (is_pty(info->driver)) {
 			info->reg_d = pty_alloc_reg(info, true);
 			if (!info->reg_d) {


logging: avoid buffer overrun extracting arguments

The number of arguments for a format string is approximated by the
number of conversion specifications.  This count may exceed the maximum
supported argument count.  Limit the extraction to the available space.

Signed-off-by: Peter Bigot <a4112a160b558d5427af084318038e19a95979ee@nordicsemi.no>

--- subsys/logging/log_core.c
+++ subsys/logging/log_core.c
@@ -392,6 +392,7 @@
 		log_arg_t args[LOG_MAX_NARGS];
 		u32_t nargs = count_args(fmt);

+		__ASSERT_NO_MSG(nargs < LOG_MAX_NARGS);
 		for (int i = 0; i < nargs; i++) {
 			args[i] = va_arg(ap, log_arg_t);
 		}


Remove unneeded atom parameters.

Remove unneeded atom parameters.

Since the function that retrieves the window title always uses the same
atoms, do not pass them as parameters, but use them internally, instead.

--- scrotwm.c
+++ scrotwm.c
@@ -563,7 +563,7 @@
 void		 store_float_geom(struct ws_win *, struct swm_region *);
 int		 floating_toggle_win(struct ws_win *);
 void		 spawn_select(struct swm_region *, union arg *, char *, int *);
-unsigned char	*get_win_name(Display *, Window, Atom, Atom, unsigned long *);
+unsigned char	*get_win_name(Display *, Window, unsigned long *);

 int
 get_property(Window id, Atom atom, long count, Atom type,
@@ -1357,8 +1357,8 @@
 	unsigned long		len;

 	if (window_name_enabled && cur_focus != NULL) {
-		if ((title = get_win_name(display, cur_focus->id, a_netwmname,
-		    a_utf8_string, &len)) != NULL) {
+		title = get_win_name(display, cur_focus->id, &len);
+		if (title != NULL) {
 			DNPRINTF(SWM_D_BAR, "bar_window_name: title: %s\n",
 			    title);

@@ -3313,27 +3313,26 @@
 }

 unsigned char *
-get_win_name(Display *dpy, Window win, Atom wname, Atom stype,
-    unsigned long *slen)
+get_win_name(Display *dpy, Window win, unsigned long *slen)
 {
 	int			status, retfmt;
 	unsigned long		nitems, nbytes, nextra;
 	unsigned char		*prop = NULL;
 	Atom			rettype;

-	status = XGetWindowProperty(dpy, win, wname, 0L, 0L, False, stype,
-	    &rettype, &retfmt,  &nitems, &nbytes, &prop);
+	status = XGetWindowProperty(dpy, win, a_netwmname, 0L, 0L, False,
+	    a_utf8_string, &rettype, &retfmt,  &nitems, &nbytes, &prop);
 	if (status != Success)
 		return (NULL);
 	XFree(prop);

-	status = XGetWindowProperty(dpy, win, wname, 0L, nbytes, False,
-	    stype, &rettype, &retfmt, &nitems, &nextra, &prop);
+	status = XGetWindowProperty(dpy, win, a_netwmname, 0L, nbytes, False,
+	    a_utf8_string, &rettype, &retfmt, &nitems, &nextra, &prop);
 	if (status != Success) {
 		XFree(prop);
 		return (NULL);
 	}
-	if (rettype != stype) {
+	if (rettype != a_utf8_string) {
 		XFree(prop);
 		return (NULL);
 	}
@@ -3380,8 +3379,7 @@
 		if (win->iconic == 0)
 			continue;

-		name = get_win_name(display, win->id, a_netwmname,
-		    a_utf8_string, &len);
+		name = get_win_name(display, win->id, &len);
 		if (name == NULL)
 			continue;
 		fprintf(lfile, "%s.%lu\n", name, win->id);
@@ -3538,8 +3536,7 @@
 	TAILQ_FOREACH(win, &search_r->ws->winlist, entry) {
 		if (win->iconic == 0)
 			continue;
-		name = get_win_name(display, win->id, a_netwmname,
-		    a_utf8_string, &len);
+		name = get_win_name(display, win->id, &len);
 		if (name == NULL)
 			continue;
 		if (asprintf(&s, "%s.%lu", name, win->id) == -1) {


(svn_fs_open_berkeley): Store the filesystem path fs->env_path. Load svn-dev.el.

--- subversion/libsvn_fs/fs.c
+++ subversion/libsvn_fs/fs.c
@@ -309,6 +309,8 @@

   SVN_ERR (check_already_open (fs));

+  fs->env_path = apr_pstrdup (fs->pool, path);
+
   svn_err = allocate_env (fs);
   if (svn_err) goto error;

@@ -381,3 +383,12 @@

   return 0;
 }
+
+
++
+/*
+ * local variables:
+ * eval: (load-file "../svn-dev.el")
+ * end:
+ */


cpu, cc2538: adapt uart to RIOT gpio API

--- cpu/cc2538/periph/uart.c
+++ cpu/cc2538/periph/uart.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2014 Loci Controls Inc.
+ *               2017 HAW Hamburg
  *
  * This file is subject to the terms and conditions of the GNU Lesser
  * General Public License v2.1. See the file LICENSE in the top level
@@ -15,7 +16,7 @@
  * @brief       Low-level UART driver implementation
  *
  * @author      Ian Martin <ian@locicontrols.com>
- *
+ * @author      Sebastian Meiling <s@mlng.net>
  * @}
  */

@@ -192,45 +193,15 @@
 #if UART_0_EN
         case UART_0:
             u = UART_0_DEV;
-
-            /*
-             * Select the UARTx RX pin by writing to the IOC_UARTRXD_UARTn register
-             */
-            IOC_UARTRXD_UART0 = UART_0_RX_PIN;
-
-            /*
-             * Pad Control for the TX pin:
-             * - Set function to UARTn TX
-             * - Output Enable
-             */
-            IOC_PXX_SEL[UART_0_TX_PIN] = UART0_TXD;
-            IOC_PXX_OVER[UART_0_TX_PIN] = IOC_OVERRIDE_OE;
-
-            /* Set RX and TX pins to peripheral mode */
-            gpio_hardware_control(UART_0_TX_PIN);
-            gpio_hardware_control(UART_0_RX_PIN);
+            gpio_init_af(UART_0_RX_PIN, UART0_RXD, GPIO_IN);
+            gpio_init_af(UART_0_TX_PIN, UART0_TXD, GPIO_OUT);
             break;
 #endif
 #if UART_1_EN
         case UART_1:
             u = UART_1_DEV;
-
-            /*
-             * Select the UARTx RX pin by writing to the IOC_UARTRXD_UARTn register
-             */
-            IOC_UARTRXD_UART1 = UART_1_RX_PIN;
-
-            /*
-             * Pad Control for the TX pin:
-             * - Set function to UARTn TX
-             * - Output Enable
-             */
-            IOC_PXX_SEL[UART_1_TX_PIN] = UART1_TXD;
-            IOC_PXX_OVER[UART_1_TX_PIN] = IOC_OVERRIDE_OE;
-
-            /* Set RX and TX pins to peripheral mode */
-            gpio_hardware_control(UART_1_TX_PIN);
-            gpio_hardware_control(UART_1_RX_PIN);
+            gpio_init_af(UART_1_RX_PIN, UART1_RXD, GPIO_IN);
+            gpio_init_af(UART_1_TX_PIN, UART1_TXD, GPIO_OUT);
             break;
 #endif

@@ -255,16 +226,12 @@
     /* On the CC2538, hardware flow control is supported only on UART1 */
     if (u == UART1) {
 #ifdef UART_1_RTS_PIN
-        IOC_PXX_SEL[UART_1_RTS_PIN] = UART1_RTS;
-        gpio_hardware_control(UART_1_RTS_PIN);
-        IOC_PXX_OVER[UART_1_RTS_PIN] = IOC_OVERRIDE_OE;
+        gpio_init_af(UART_1_RTS_PIN, UART1_RTS, GPIO_OUT);
         u->cc2538_uart_ctl.CTLbits.RTSEN = 1;
 #endif

 #ifdef UART_1_CTS_PIN
-        IOC_UARTCTS_UART1 = UART_1_CTS_PIN;
-        gpio_hardware_control(UART_1_CTS_PIN);
-        IOC_PXX_OVER[UART_1_CTS_PIN] = IOC_OVERRIDE_DIS;
+        gpio_init_af(UART_1_CTS_PIN, UART1_CTS, GPIO_IN);
         u->cc2538_uart_ctl.CTLbits.CTSEN = 1;
 #endif
     }
@@ -334,7 +301,7 @@

     /* Block if the TX FIFO is full */
     for (size_t i = 0; i < len; i++) {
-        while (u->cc2538_uart_fr.FRbits.TXFF);
+        while (u->cc2538_uart_fr.FRbits.TXFF) {}
         u->DR = data[i];
     }
 }


cleanup debug code

cleanup debug code

--- scrotwm.c
+++ scrotwm.c
@@ -3808,16 +3808,6 @@
 	}
 	if (cfile)
 		conf_load(cfile);
-	/*
-	if (cfile) {
-		do {
-			if (conf_load(cfile) != 0) {
-				fprintf(stderr, "bah!\n");
-				exit(1);
-			}
-		} while (1);
-	}
-	*/

 	/* setup all bars */
 	for (i = 0; i < ScreenCount(display); i++)


* subversion/libsvn_wc/wc.h
  Partially revert r979476.

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

--- subversion/libsvn_wc/wc.h
+++ subversion/libsvn_wc/wc.h
@@ -50,8 +50,8 @@
 #define SVN_WC__REVERT_EXT    ".svn-revert" /* for reverting a replaced
                                                file */

-#define SVN_WC__SINGLE_DB
-#define SINGLE_DB
+/*#define SVN_WC__SINGLE_DB
+#define SINGLE_DB*/


cpu/samd21: fix or add missing EXTI on GPIO

Signed-off-by: dylad <d56dfe611c7cd6204525c7c9b6afc5e84aed0f5d@mesotic.com>


*sigh* fix corner case where windows were being mapped from a different workspace after alt-q.

--- scrotwm.c
+++ scrotwm.c
@@ -2179,8 +2179,8 @@

 	set_win_state(win, NormalState);

-	/* floaters need this */
-	if (win->floating)
+	/* floaters need to be mapped if they are in the current workspace */
+	if (win->floating && (ws->idx == r->ws->idx))
 		XMapRaised(display, win->id);

 	/* make new win focused */


* subversion/svn/info-cmd.c (print_info):     Make "Moved from:" and "Moved to:" conform to upper-case-ness of     'svn info' output.

--- subversion/svn/info-cmd.c
+++ subversion/svn/info-cmd.c
@@ -414,9 +414,9 @@
           relpath = svn_dirent_skip_ancestor(info->wc_info->wcroot_abspath,
                                              info->wc_info->moved_from_abspath);
           if (relpath && relpath[0] != '\0')
-            SVN_ERR(svn_cmdline_printf(pool, _("Moved from: %s\n"), relpath));
+            SVN_ERR(svn_cmdline_printf(pool, _("Moved From: %s\n"), relpath));
           else
-            SVN_ERR(svn_cmdline_printf(pool, _("Moved from: %s\n"),
+            SVN_ERR(svn_cmdline_printf(pool, _("Moved From: %s\n"),
                                        info->wc_info->moved_from_abspath));
         }

@@ -427,9 +427,9 @@
           relpath = svn_dirent_skip_ancestor(info->wc_info->wcroot_abspath,
                                              info->wc_info->moved_to_abspath);
           if (relpath && relpath[0] != '\0')
-            SVN_ERR(svn_cmdline_printf(pool, _("Moved to: %s\n"), relpath));
+            SVN_ERR(svn_cmdline_printf(pool, _("Moved To: %s\n"), relpath));
           else
-            SVN_ERR(svn_cmdline_printf(pool, _("Moved to: %s\n"),
+            SVN_ERR(svn_cmdline_printf(pool, _("Moved To: %s\n"),
                                        info->wc_info->moved_to_abspath));
         }
     }


stm32f1/i2c: fix multi byte reading

stm32f1/i2c: fix multi byte reading

--- cpu/stm32f1/periph/i2c.c
+++ cpu/stm32f1/periph/i2c.c
@@ -252,6 +252,7 @@
             DEBUG("Send Slave address and wait for ADDR == 1\n");
             _start(i2c, address, I2C_FLAG_READ);
             _clear_addr(i2c);
+            i2c->CR1 |= (I2C_CR1_ACK);

             while (i < (length - 3)) {
                 DEBUG("Wait until byte was received\n");


cdstrategy(): check that media is loaded before doing anything with the
cd.

ok art@

--- scsi/cd.c
+++ scsi/cd.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: cd.c,v 1.57 2001/10/25 12:59:21 drahn Exp $	*/
+/*	$OpenBSD: cd.c,v 1.58 2002/02/01 10:06:18 hin Exp $	*/
 /*	$NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $	*/

 /*
@@ -515,18 +515,18 @@
 	SC_DEBUG(cd->sc_link, SDEV_DB1,
 	    ("%ld bytes @ blk %d\n", bp->b_bcount, bp->b_blkno));
 	/*
+	 * If the device has been made invalid, error out
+	 * maybe the media changed, or no media loaded
+	 */
+	if ((cd->sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
+		bp->b_error = EIO;
+		goto bad;
+	}
+	/*
 	 * The transfer must be a whole number of blocks.
 	 */
 	if ((bp->b_bcount % cd->sc_dk.dk_label->d_secsize) != 0) {
 		bp->b_error = EINVAL;
-		goto bad;
-	}
-	/*
-	 * If the device has been made invalid, error out
-	 * maybe the media changed
-	 */
-	if ((cd->sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
-		bp->b_error = EIO;
 		goto bad;
 	}
 	/*