initialize seed and generate bits

initialize seed and generate bits

--- product.c
+++ product.c
@@ -122,6 +122,8 @@

 int main() {
 lhcaInitialize();
+lhcaSeed('z','e','l','a','h','z','e','l');
+printf("%c%c%c%c%c%c%c%c",lhcaOne(),lhcaTwo(),lhcaThree(),lhcaFour(),lhcaFive(),lhcaSix(),lhcaSeven(),lhcaEight());
 test1(256*61);
 printf("\n\n\n");
 test2(256*61);


test: relax timing assumption of loop_stop

The loop_stop test makes an implicit assumption about the triggering
timing of a repeating trigger, which may not hold true on slower or
virtualized machines, thus failing the test as shown at [0] and
discussed at [1].
This commit relaxes the assumption, without mandating the exact number
of runs.

[0] http://ur1.ca/fr5bw
[1] https://groups.google.com/d/msg/libuv/5-fNIC7hIAo/yqznDmwHDAIJ

Signed-off-by: Luca Bruno <d11e81b0438fe9a6fbb85b72e5bb4c36a65f49c7@debian.org>

--- test/test-loop-stop.c
+++ test/test-loop-stop.c
@@ -62,7 +62,7 @@

   r = uv_run(uv_default_loop(), UV_RUN_NOWAIT);
   ASSERT(r != 0);
-  ASSERT(prepare_called == 3);
+  ASSERT(prepare_called > 1);

   r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
   ASSERT(r == 0);


test: fix compiling with gcc-4.5

test: fix compiling with gcc-4.5

--- test/test-ping-pong.c
+++ test/test-ping-pong.c
@@ -43,7 +43,7 @@
   union {
     uv_tcp_t tcp;
     uv_pipe_t pipe;
-  };
+  } stream;
   uv_connect_t connect_req;
   char read_buffer[BUFSIZE];
 } pinger_t;
@@ -85,7 +85,7 @@

   req = malloc(sizeof(uv_write_t));

-  if (uv_write(req, (uv_stream_t*)&pinger->tcp, &buf, 1, pinger_after_write)) {
+  if (uv_write(req, (uv_stream_t*)&pinger->stream.tcp, &buf, 1, pinger_after_write)) {
     FATAL("uv_write failed");
   }

@@ -108,7 +108,7 @@
       free(buf.base);
     }

-    uv_close((uv_handle_t*)(&pinger->tcp), pinger_on_close);
+    uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close);

     return;
   }
@@ -123,7 +123,7 @@
       if (pinger->pongs < NUM_PINGS) {
         pinger_write_ping(pinger);
       } else {
-        uv_close((uv_handle_t*)(&pinger->tcp), pinger_on_close);
+        uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close);
         return;
       }
     }
@@ -155,13 +155,13 @@
   pinger->pongs = 0;

   /* Try to connec to the server and do NUM_PINGS ping-pongs. */
-  r = uv_tcp_init(uv_default_loop(), &pinger->tcp);
-  pinger->tcp.data = pinger;
+  r = uv_tcp_init(uv_default_loop(), &pinger->stream.tcp);
+  pinger->stream.tcp.data = pinger;
   ASSERT(!r);

   /* We are never doing multiple reads/connects at a time anyway. */
   /* so these handles can be pre-initialized. */
-  r = uv_tcp_connect6(&pinger->connect_req, &pinger->tcp, server_addr,
+  r = uv_tcp_connect6(&pinger->connect_req, &pinger->stream.tcp, server_addr,
       pinger_on_connect);
   ASSERT(!r);

@@ -180,13 +180,13 @@
   pinger->pongs = 0;

   /* Try to connec to the server and do NUM_PINGS ping-pongs. */
-  r = uv_tcp_init(uv_default_loop(), &pinger->tcp);
-  pinger->tcp.data = pinger;
+  r = uv_tcp_init(uv_default_loop(), &pinger->stream.tcp);
+  pinger->stream.tcp.data = pinger;
   ASSERT(!r);

   /* We are never doing multiple reads/connects at a time anyway. */
   /* so these handles can be pre-initialized. */
-  r = uv_tcp_connect(&pinger->connect_req, &pinger->tcp, server_addr,
+  r = uv_tcp_connect(&pinger->connect_req, &pinger->stream.tcp, server_addr,
       pinger_on_connect);
   ASSERT(!r);

@@ -204,14 +204,14 @@
   pinger->pongs = 0;

   /* Try to connec to the server and do NUM_PINGS ping-pongs. */
-  r = uv_pipe_init(uv_default_loop(), &pinger->pipe);
-  pinger->pipe.data = pinger;
+  r = uv_pipe_init(uv_default_loop(), &pinger->stream.pipe);
+  pinger->stream.pipe.data = pinger;
   ASSERT(!r);

   /* We are never doing multiple reads/connects at a time anyway. */
   /* so these handles can be pre-initialized. */

-  r = uv_pipe_connect(&pinger->connect_req, &pinger->pipe, TEST_PIPENAME,
+  r = uv_pipe_connect(&pinger->connect_req, &pinger->stream.pipe, TEST_PIPENAME,
       pinger_on_connect);
   ASSERT(!r);


添加数据流读取器的游标重置接口.

添加数据流读取器的游标重置接口.

--- proto4z.h
+++ proto4z.h
@@ -282,6 +282,8 @@
 	ReadStream(const char *pAttachData, Integer attachDataLen);
 	~ReadStream(){}
 public:
+
+	inline void ResetMoveCursor(){ m_cursor = StreamHeadTrait::HeadLen;}
 	//get head memory to packHead
 	inline void GetStreamHead(char *streamHead/*[StreamHeadTrait::HeadLen]*/);
 	inline Integer GetStreamHeadLen(){ return StreamHeadTrait::HeadLen; };
@@ -952,6 +954,8 @@
 		m_pAttachData = NULL;
 	}
 }
+
+
 template<class StreamHeadTrait>
 inline void ReadStream<StreamHeadTrait>::CheckMoveCursor(Integer unit)
 {


cpu/nrf51: fix formatting uint to PRIu32

--- cpu/nrf51/periph/pwm.c
+++ cpu/nrf51/periph/pwm.c
@@ -20,6 +20,7 @@

 #include <stdint.h>
 #include <string.h>
+#include <inttypes.h>

 #include "periph/gpio.h"
 #include "periph/pwm.h"
@@ -113,7 +114,7 @@
     /* start pwm with value '0' */
     pwm_set(dev, 0, 0);

-    DEBUG("Timer frequency is set to %ld\n", timer_freq);
+    DEBUG("Timer frequency is set to %" PRIu32 "\n", timer_freq);

     return (uint32_t)(timer_freq / res);
 }


proto_2: Fix coding style.

proto_2: Fix coding style.

--- proto_2.c
+++ proto_2.c
@@ -78,7 +78,10 @@
     {
         cam.fov = s3d_radians(45);

-        s3d_vec3_assign(cam.rot, s3d_radians(45), s3d_radians(-35), 0);
+        s3d_vec3_assign(
+            cam.rot, s3d_radians(45), s3d_radians(-35), 0
+        );
+
         s3d_vec3_assign(cam.pos, 0, 2, -25);
     }


salut-si-bytestream-manager: fix coding style

--- src/salut-si-bytestream-manager.c
+++ src/salut-si-bytestream-manager.c
@@ -63,7 +63,7 @@
 };

 #define SALUT_SI_BYTESTREAM_MANAGER_GET_PRIVATE(obj) \
-    ((SalutSiBytestreamManagerPrivate *) ((SalutSiBytestreamManager *)obj)->priv)
+    ((SalutSiBytestreamManagerPrivate *) ((SalutSiBytestreamManager *) obj)->priv)

 static void
 salut_si_bytestream_manager_init (SalutSiBytestreamManager *self)


driver core: Use sysfs_rename_link in device_rename

Don't open code the renaming of symlinks in sysfs
instead use the new helper function sysfs_rename_link

Acked-by: Tejun Heo <546b05909706652891a87f7bfe385ae147f61f91@kernel.org>
Acked-by: Serge Hallyn <dd6cacb2d07f0aa354aa6e74c149a3580e5a1db1@us.ibm.com>
Signed-off-by: Eric W. Biederman <8a741aa8cbd77ebc4a56ddb528ce9fd15d42f034@aristanetworks.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

--- drivers/base/core.c
+++ drivers/base/core.c
@@ -1578,22 +1578,16 @@
 	if (old_class_name) {
 		new_class_name = make_class_name(dev->class->name, &dev->kobj);
 		if (new_class_name) {
-			error = sysfs_create_link_nowarn(&dev->parent->kobj,
-							 &dev->kobj,
-							 new_class_name);
-			if (error)
-				goto out;
-			sysfs_remove_link(&dev->parent->kobj, old_class_name);
+			error = sysfs_rename_link(&dev->parent->kobj,
+						  &dev->kobj,
+						  old_class_name,
+						  new_class_name);
 		}
 	}
 #else
 	if (dev->class) {
-		error = sysfs_create_link_nowarn(&dev->class->p->class_subsys.kobj,
-						 &dev->kobj, dev_name(dev));
-		if (error)
-			goto out;
-		sysfs_remove_link(&dev->class->p->class_subsys.kobj,
-				  old_device_name);
+		error = sysfs_rename_link(&dev->class->p->class_subsys.kobj,
+					  &dev->kobj, old_device_name, new_name);
 	}
 #endif


rbd: check for overflow in rbd_get_num_segments()

The return type of rbd_get_num_segments() is int, but the values it
operates on are u64.  Although it's not likely, there's no guarantee
the result won't exceed what can be respresented in an int.  The
function is already designed to return -ERANGE on error, so just add
this possible overflow as another reason to return that.

Signed-off-by: Alex Elder <f429030cf5c0faf36fac3d102073b6e63a647baa@inktank.com>
Reviewed-by: Dan Mick <b07550071eaa6a9296289c43bbd6c90559196431@inktank.com>
Reviewed-by: Josh Durgin <51652c783f70f5b272ebd02f1fd20d3af7a2449f@inktank.com>

--- drivers/block/rbd.c
+++ drivers/block/rbd.c
@@ -820,6 +820,7 @@
 {
 	u64 start_seg;
 	u64 end_seg;
+	u64 result;

 	if (!len)
 		return 0;
@@ -829,7 +830,11 @@
 	start_seg = ofs >> header->obj_order;
 	end_seg = (ofs + len - 1) >> header->obj_order;

-	return end_seg - start_seg + 1;
+	result = end_seg - start_seg + 1;
+	if (result > (u64) INT_MAX)
+		return -ERANGE;
+
+	return (int) result;
 }

 /*


rbd: set up watch in rbd_dev_image_probe()

Move setting up the watch request for an image so it's done in
rbd_dev_image_probe() rather than rbd_dev_probe_finish().  Move
it all the way up to before doing the initial probe.  This avoids
a potential race condition, in which we get (and use) the initial
snapshot context for an image, and it gets changed between that
time and the time we get the watch set up.

This resolves:
    http://tracker.ceph.com/issues/3871

Signed-off-by: Alex Elder <f429030cf5c0faf36fac3d102073b6e63a647baa@inktank.com>
Reviewed-by: Josh Durgin <51652c783f70f5b272ebd02f1fd20d3af7a2449f@inktank.com>

--- drivers/block/rbd.c
+++ drivers/block/rbd.c
@@ -4721,11 +4721,6 @@
 static int rbd_dev_probe_finish(struct rbd_device *rbd_dev)
 {
 	int ret;
-	int tmp;
-
-	ret = rbd_dev_header_watch_sync(rbd_dev, 1);
-	if (ret)
-		return ret;

 	ret = rbd_dev_mapping_set(rbd_dev);
 	if (ret)
@@ -4773,9 +4768,6 @@
 	unregister_blkdev(rbd_dev->major, rbd_dev->name);
 err_out_id:
 	rbd_dev_id_put(rbd_dev);
-	tmp = rbd_dev_header_watch_sync(rbd_dev, 0);
-	if (tmp)
-		rbd_warn(rbd_dev, "failed to cancel watch event (%d)\n", ret);
 	rbd_dev_mapping_clear(rbd_dev);

 	return ret;
@@ -4816,6 +4808,7 @@
 static int rbd_dev_image_probe(struct rbd_device *rbd_dev)
 {
 	int ret;
+	int tmp;

 	/*
 	 * Get the id from the image id object.  If it's not a
@@ -4832,16 +4825,20 @@
 	if (ret)
 		goto err_out_format;

+	ret = rbd_dev_header_watch_sync(rbd_dev, 1);
+	if (ret)
+		goto out_header_name;
+
 	if (rbd_dev->image_format == 1)
 		ret = rbd_dev_v1_probe(rbd_dev);
 	else
 		ret = rbd_dev_v2_probe(rbd_dev);
 	if (ret)
-		goto out_header_name;
+		goto err_out_watch;

 	ret = rbd_dev_snaps_update(rbd_dev);
 	if (ret)
-		goto out_header_name;
+		goto err_out_watch;

 	ret = rbd_dev_spec_update(rbd_dev);
 	if (ret)
@@ -4861,6 +4858,10 @@
 	rbd_header_free(&rbd_dev->header);
 err_out_snaps:
 	rbd_remove_all_snaps(rbd_dev);
+err_out_watch:
+	tmp = rbd_dev_header_watch_sync(rbd_dev, 0);
+	if (tmp)
+		rbd_warn(rbd_dev, "unable to tear down watch request\n");
 out_header_name:
 	kfree(rbd_dev->header_name);
 	rbd_dev->header_name = NULL;


Continue looping over the next queue if the current queue is empty. No functional changes.

--- src/scheduling/mir_sched_pol_ws.c
+++ src/scheduling/mir_sched_pol_ws.c
@@ -134,29 +134,30 @@
         if (ctr == num_queues)
             ctr = 0;

-        if (mir_queue_size(queue) > 0) {
-            mir_queue_pop(queue, (void**)&(*task));
-            if (*task) {
-                // Update stats
-                if (runtime->enable_worker_stats == 1) {
+        if (mir_queue_size(queue) == 0)
+            continue;
+
+        mir_queue_pop(queue, (void**)&(*task));
+        if (*task) {
+            // Update stats
+            if (runtime->enable_worker_stats == 1) {
 #ifdef MIR_MEM_POL_ENABLE
-                    uint16_t node = runtime->arch->node_of(worker->cpu_id);
-                    struct mir_mem_node_dist_t* dist = mir_task_get_mem_node_dist(*task, MIR_DATA_ACCESS_READ);
-                    if (dist) {
-                        (*task)->comm_cost = mir_mem_node_dist_get_comm_cost(dist, node);
-                        mir_worker_statistics_update_comm_cost(worker->statistics, (*task)->comm_cost);
-                    }
+                uint16_t node = runtime->arch->node_of(worker->cpu_id);
+                struct mir_mem_node_dist_t* dist = mir_task_get_mem_node_dist(*task, MIR_DATA_ACCESS_READ);
+                if (dist) {
+                    (*task)->comm_cost = mir_mem_node_dist_get_comm_cost(dist, node);
+                    mir_worker_statistics_update_comm_cost(worker->statistics, (*task)->comm_cost);
+                }
 #endif

-                    worker->statistics->num_tasks_stolen++;
-                }
+                worker->statistics->num_tasks_stolen++;
+            }

-                __sync_fetch_and_sub(&g_num_tasks_waiting, 1);
-                T_DBG("St", *task);
+            __sync_fetch_and_sub(&g_num_tasks_waiting, 1);
+            T_DBG("St", *task);

-                found = 1;
-                break;
-            }
+            found = 1;
+            break;
         }
     }


rbd: don't zero-fill non-image object requests

A result of ENOENT from a read request for an object that's part of
an rbd image indicates that there is a hole in that portion of the
image.  Similarly, a short read for such an object indicates that
the remainder of the read should be interpreted a full read with
zeros filling out the end of the request.

This behavior is not correct for objects that are not backing rbd
image data.  Currently rbd_img_obj_request_callback() assumes it
should be done for all objects.

Change rbd_img_obj_request_callback() so it only does this zeroing
for image objects.  Encapsulate that special handling in its own
function.  Add an assertion that the image object request is a bio
request, since we assume that (and we currently don't support any
other types).

This resolves a problem identified here:
    http://tracker.ceph.com/issues/4559

The regression was introduced by bf0d5f503dc11d6314c0503591d258d60ee9c944.

Reported-by: Dan van der Ster <2591e5f46f28d303f9dc027d475a5c60d8dea17a@vanderster.com>
Signed-off-by: Alex Elder <f429030cf5c0faf36fac3d102073b6e63a647baa@inktank.com>
Reviewed-off-by: Sage Weil <6dd34506bbd5e58221bbb3e4732d97c91f02277b@inktank.com>

--- drivers/block/rbd.c
+++ drivers/block/rbd.c
@@ -1264,33 +1264,20 @@
 	return atomic_read(&obj_request->done) != 0;
 }

-static void rbd_obj_request_complete(struct rbd_obj_request *obj_request)
-{
-	dout("%s: obj %p cb %p\n", __func__, obj_request,
-		obj_request->callback);
-	if (obj_request->callback)
-		obj_request->callback(obj_request);
-	else
-		complete_all(&obj_request->completion);
-}
-
-static void rbd_osd_trivial_callback(struct rbd_obj_request *obj_request)
-{
-	dout("%s: obj %p\n", __func__, obj_request);
-	obj_request_done_set(obj_request);
-}
-
-static void rbd_osd_read_callback(struct rbd_obj_request *obj_request)
-{
-	dout("%s: obj %p result %d %llu/%llu\n", __func__, obj_request,
-		obj_request->result, obj_request->xferred, obj_request->length);
+static void
+rbd_img_obj_request_read_callback(struct rbd_obj_request *obj_request)
+{
+	dout("%s: obj %p img %p result %d %llu/%llu\n", __func__,
+		obj_request, obj_request->img_request, obj_request->result,
+		obj_request->xferred, obj_request->length);
 	/*
-	 * ENOENT means a hole in the object.  We zero-fill the
+	 * ENOENT means a hole in the image.  We zero-fill the
 	 * entire length of the request.  A short read also implies
 	 * zero-fill to the end of the request.  Either way we
 	 * update the xferred count to indicate the whole request
 	 * was satisfied.
 	 */
+	BUG_ON(obj_request->type != OBJ_REQUEST_BIO);
 	if (obj_request->result == -ENOENT) {
 		zero_bio_chain(obj_request->bio_list, 0);
 		obj_request->result = 0;
@@ -1301,6 +1288,32 @@
 		obj_request->xferred = obj_request->length;
 	}
 	obj_request_done_set(obj_request);
+}
+
+static void rbd_obj_request_complete(struct rbd_obj_request *obj_request)
+{
+	dout("%s: obj %p cb %p\n", __func__, obj_request,
+		obj_request->callback);
+	if (obj_request->callback)
+		obj_request->callback(obj_request);
+	else
+		complete_all(&obj_request->completion);
+}
+
+static void rbd_osd_trivial_callback(struct rbd_obj_request *obj_request)
+{
+	dout("%s: obj %p\n", __func__, obj_request);
+	obj_request_done_set(obj_request);
+}
+
+static void rbd_osd_read_callback(struct rbd_obj_request *obj_request)
+{
+	dout("%s: obj %p result %d %llu/%llu\n", __func__, obj_request,
+		obj_request->result, obj_request->xferred, obj_request->length);
+	if (obj_request->img_request)
+		rbd_img_obj_request_read_callback(obj_request);
+	else
+		obj_request_done_set(obj_request);
 }

 static void rbd_osd_write_callback(struct rbd_obj_request *obj_request)


Ignore zero length constructed segments.

--- crypto/asn1/tasn_dec.c
+++ crypto/asn1/tasn_dec.c
@@ -1169,7 +1169,7 @@
 			return 0;
 #endif
 			}
-		else if (!collect_data(buf, &p, plen))
+		else if (plen && !collect_data(buf, &p, plen))
 			return 0;
 		len -= p - q;
 		}


rbd: use snap_id not index to look up snap info

In order to align with what was needed for format 1 rbd images,
rbd_dev_v2_snap_info() was set up to take as argument an index into
the array of snapshot ids in a rbd device's snapshot context.

This switches that around, so we pass the snapshot id instead.
In doing this, rbd_snap_name() now returns a dynamically-allocated
string rather than a fixed one, so there's no need to make a
duplicate in its caller, rbd_dev_spec_update().

This means the following functions take a snapshot id where they
previously used an index value:
    rbd_dev_snap_info()
    rbd_dev_v1_snap_info()
    rbd_dev_v2_snap_info()

A new function, rbd_dev_snap_index(), determines the snap index for
format 1 images and uses it to look up the name.

Signed-off-by: Alex Elder <f429030cf5c0faf36fac3d102073b6e63a647baa@inktank.com>
Reviewed-by: Josh Durgin <51652c783f70f5b272ebd02f1fd20d3af7a2449f@inktank.com>

--- drivers/block/rbd.c
+++ drivers/block/rbd.c
@@ -433,6 +433,8 @@

 static int rbd_dev_refresh(struct rbd_device *rbd_dev);
 static int rbd_dev_v2_refresh(struct rbd_device *rbd_dev);
+static const char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev,
+					u64 snap_id);

 static int rbd_open(struct block_device *bdev, fmode_t mode)
 {
@@ -838,18 +840,27 @@
 	return BAD_SNAP_INDEX;
 }

+static const char *rbd_dev_v1_snap_name(struct rbd_device *rbd_dev, u64 snap_id)
+{
+	u32 which;
+
+	which = rbd_dev_snap_index(rbd_dev, snap_id);
+	if (which == BAD_SNAP_INDEX)
+		return NULL;
+
+	return _rbd_dev_v1_snap_name(rbd_dev, which);
+}
+
 static const char *rbd_snap_name(struct rbd_device *rbd_dev, u64 snap_id)
 {
-	struct rbd_snap *snap;
-
 	if (snap_id == CEPH_NOSNAP)
 		return RBD_SNAP_HEAD_NAME;

-	list_for_each_entry(snap, &rbd_dev->snaps, node)
-		if (snap_id == snap->id)
-			return snap->name;
-
-	return NULL;
+	rbd_assert(rbd_image_format_valid(rbd_dev->image_format));
+	if (rbd_dev->image_format == 1)
+		return rbd_dev_v1_snap_name(rbd_dev, snap_id);
+
+	return rbd_dev_v2_snap_name(rbd_dev, snap_id);
 }

 static struct rbd_snap *snap_by_name(struct rbd_device *rbd_dev,
@@ -3446,11 +3457,15 @@
  * Returns a dynamically-allocated snapshot name if successful, or a
  * pointer-coded error otherwise.
  */
-static const char *rbd_dev_v1_snap_info(struct rbd_device *rbd_dev, u32 which,
-		u64 *snap_size, u64 *snap_features)
+static const char *rbd_dev_v1_snap_info(struct rbd_device *rbd_dev,
+			u64 snap_id, u64 *snap_size, u64 *snap_features)
 {
 	const char *snap_name;
-
+	u32 which;
+
+	which = rbd_dev_snap_index(rbd_dev, snap_id);
+	if (which == BAD_SNAP_INDEX)
+		return ERR_PTR(-ENOENT);
 	snap_name = _rbd_dev_v1_snap_name(rbd_dev, which);
 	if (!snap_name)
 		return ERR_PTR(-ENOMEM);
@@ -3816,12 +3831,6 @@

 	snap_name = rbd_snap_name(rbd_dev, spec->snap_id);
 	if (!snap_name) {
-		rbd_warn(rbd_dev, "no snapshot with id %llu", spec->snap_id);
-		ret = -EIO;
-		goto out_err;
-	}
-	snap_name = kstrdup(snap_name, GFP_KERNEL);
-	if (!snap_name) {
 		ret = -ENOMEM;
 		goto out_err;
 	}
@@ -3909,11 +3918,12 @@
 	return ret;
 }

-static const char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev, u32 which)
+static const char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev,
+					u64 snap_id)
 {
 	size_t size;
 	void *reply_buf;
-	__le64 snap_id;
+	__le64 snapid;
 	int ret;
 	void *p;
 	void *end;
@@ -3924,11 +3934,10 @@
 	if (!reply_buf)
 		return ERR_PTR(-ENOMEM);

-	rbd_assert(which < rbd_dev->header.snapc->num_snaps);
-	snap_id = cpu_to_le64(rbd_dev->header.snapc->snaps[which]);
+	snapid = cpu_to_le64(snap_id);
 	ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_name,
 				"rbd", "get_snapshot_name",
-				&snap_id, sizeof (snap_id),
+				&snapid, sizeof (snapid),
 				reply_buf, size);
 	dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret);
 	if (ret < 0) {
@@ -3943,24 +3952,21 @@
 		goto out;

 	dout("  snap_id 0x%016llx snap_name = %s\n",
-		(unsigned long long)le64_to_cpu(snap_id), snap_name);
+		(unsigned long long)snap_id, snap_name);
 out:
 	kfree(reply_buf);

 	return snap_name;
 }

-static const char *rbd_dev_v2_snap_info(struct rbd_device *rbd_dev, u32 which,
-		u64 *snap_size, u64 *snap_features)
-{
-	u64 snap_id;
+static const char *rbd_dev_v2_snap_info(struct rbd_device *rbd_dev,
+			u64 snap_id, u64 *snap_size, u64 *snap_features)
+{
 	u64 size;
 	u64 features;
 	const char *snap_name;
 	int ret;

-	rbd_assert(which < rbd_dev->header.snapc->num_snaps);
-	snap_id = rbd_dev->header.snapc->snaps[which];
 	ret = _rbd_dev_v2_snap_size(rbd_dev, snap_id, NULL, &size);
 	if (ret)
 		goto out_err;
@@ -3969,7 +3975,7 @@
 	if (ret)
 		goto out_err;

-	snap_name = rbd_dev_v2_snap_name(rbd_dev, which);
+	snap_name = rbd_dev_v2_snap_name(rbd_dev, snap_id);
 	if (!IS_ERR(snap_name)) {
 		*snap_size = size;
 		*snap_features = features;
@@ -3980,14 +3986,14 @@
 	return ERR_PTR(ret);
 }

-static const char *rbd_dev_snap_info(struct rbd_device *rbd_dev, u32 which,
-		u64 *snap_size, u64 *snap_features)
+static const char *rbd_dev_snap_info(struct rbd_device *rbd_dev,
+		u64 snap_id, u64 *snap_size, u64 *snap_features)
 {
 	if (rbd_dev->image_format == 1)
-		return rbd_dev_v1_snap_info(rbd_dev, which,
+		return rbd_dev_v1_snap_info(rbd_dev, snap_id,
 					snap_size, snap_features);
 	if (rbd_dev->image_format == 2)
-		return rbd_dev_v2_snap_info(rbd_dev, which,
+		return rbd_dev_v2_snap_info(rbd_dev, snap_id,
 					snap_size, snap_features);
 	return ERR_PTR(-EINVAL);
 }
@@ -4085,7 +4091,7 @@
 			continue;
 		}

-		snap_name = rbd_dev_snap_info(rbd_dev, index,
+		snap_name = rbd_dev_snap_info(rbd_dev, snap_id,
 					&snap_size, &snap_features);
 		if (IS_ERR(snap_name)) {
 			ret = PTR_ERR(snap_name);


Do not prepend $OPENSSL_CONF_INCLUDE to absolute include paths

Also check for malloc failure and do not add '/' when
$OPENSSL_CONF_INCLUDE already ends with directory separator.

Fixes #13302

Reviewed-by: Matt Caswell <1fa2ef4755a9226cb9a0a4840bd89b158ac71391@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13306)

--- crypto/conf/conf_def.c
+++ crypto/conf/conf_def.c
@@ -414,12 +414,19 @@
                 if (!str_copy(conf, psection, &include, p))
                     goto err;

-                if (include_dir != NULL) {
+                if (include_dir != NULL && !ossl_is_absolute_path(include)) {
                     size_t newlen = strlen(include_dir) + strlen(include) + 2;

                     include_path = OPENSSL_malloc(newlen);
+                    if (include_path == NULL) {
+                        CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
+                        OPENSSL_free(include);
+                        goto err;
+                    }
+
                     OPENSSL_strlcpy(include_path, include_dir, newlen);
-                    OPENSSL_strlcat(include_path, "/", newlen);
+                    if (!ossl_ends_with_dirsep(include_path))
+                        OPENSSL_strlcat(include_path, "/", newlen);
                     OPENSSL_strlcat(include_path, include, newlen);
                     OPENSSL_free(include);
                 } else {


fixed typo

fixed typo

--- src/serialization/serialization.h
+++ src/serialization/serialization.h
@@ -170,7 +170,7 @@
   template <bool W, template <bool> class Archive>			\
   bool do_serialize_object(Archive<W> &ar){

-/*! \macro PREPARE_CUSTON_VECTOR_SERIALIZATION
+/*! \macro PREPARE_CUSTOM_VECTOR_SERIALIZATION
  */
 #define PREPARE_CUSTOM_VECTOR_SERIALIZATION(size, vec)			\
   ::serialization::detail::prepare_custom_vector_serialization(size, vec, typename Archive<W>::is_saving())


rbd: use rbd_obj_watch_request_helper() helper

Switch rbd_dev_header_{un,}watch_sync() to use the new helper and fix
rbd_dev_header_unwatch_sync() to destroy watch_request structures
before queuing watch-remove message while at it.  This mistake slipped
into commit b30a01f2a307 ("rbd: fix osd_request memory leak in
__rbd_dev_header_watch_sync()") and could lead to "image still in use"
errors on image removal.

Signed-off-by: Ilya Dryomov <33f1a10eef0a3354755a1541edfdb100ff87fcfc@inktank.com>
Reviewed-by: Alex Elder <f429030cf5c0faf36fac3d102073b6e63a647baa@linaro.org>

--- drivers/block/rbd.c
+++ drivers/block/rbd.c
@@ -3040,130 +3040,49 @@
 	if (ret < 0)
 		return ret;

-	rbd_assert(rbd_dev->watch_event);
-
-	obj_request = rbd_obj_request_create(rbd_dev->header_name, 0, 0,
-					     OBJ_REQUEST_NODATA);
-	if (!obj_request) {
-		ret = -ENOMEM;
-		goto out_cancel;
-	}
-
-	obj_request->osd_req = rbd_osd_req_create(rbd_dev, true, 1,
-						  obj_request);
-	if (!obj_request->osd_req) {
-		ret = -ENOMEM;
-		goto out_put;
-	}
-
-	ceph_osdc_set_request_linger(osdc, obj_request->osd_req);
-
-	osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_WATCH,
-			      rbd_dev->watch_event->cookie, 0, 1);
-	rbd_osd_req_format_write(obj_request);
-
-	ret = rbd_obj_request_submit(osdc, obj_request);
-	if (ret)
-		goto out_linger;
-
-	ret = rbd_obj_request_wait(obj_request);
-	if (ret)
-		goto out_linger;
-
-	ret = obj_request->result;
-	if (ret)
-		goto out_linger;
+	obj_request = rbd_obj_watch_request_helper(rbd_dev, true);
+	if (IS_ERR(obj_request)) {
+		ceph_osdc_cancel_event(rbd_dev->watch_event);
+		rbd_dev->watch_event = NULL;
+		return PTR_ERR(obj_request);
+	}

 	/*
 	 * A watch request is set to linger, so the underlying osd
 	 * request won't go away until we unregister it.  We retain
 	 * a pointer to the object request during that time (in
-	 * rbd_dev->watch_request), so we'll keep a reference to
-	 * it.  We'll drop that reference (below) after we've
-	 * unregistered it.
+	 * rbd_dev->watch_request), so we'll keep a reference to it.
+	 * We'll drop that reference after we've unregistered it in
+	 * rbd_dev_header_unwatch_sync().
 	 */
 	rbd_dev->watch_request = obj_request;

 	return 0;
-
-out_linger:
-	ceph_osdc_unregister_linger_request(osdc, obj_request->osd_req);
-out_put:
-	rbd_obj_request_put(obj_request);
-out_cancel:
+}
+
+/*
+ * Tear down a watch request, synchronously.
+ */
+static void rbd_dev_header_unwatch_sync(struct rbd_device *rbd_dev)
+{
+	struct rbd_obj_request *obj_request;
+
+	rbd_assert(rbd_dev->watch_event);
+	rbd_assert(rbd_dev->watch_request);
+
+	rbd_obj_request_end(rbd_dev->watch_request);
+	rbd_obj_request_put(rbd_dev->watch_request);
+	rbd_dev->watch_request = NULL;
+
+	obj_request = rbd_obj_watch_request_helper(rbd_dev, false);
+	if (!IS_ERR(obj_request))
+		rbd_obj_request_put(obj_request);
+	else
+		rbd_warn(rbd_dev, "unable to tear down watch request (%ld)",
+			 PTR_ERR(obj_request));
+
 	ceph_osdc_cancel_event(rbd_dev->watch_event);
 	rbd_dev->watch_event = NULL;
-
-	return ret;
-}
-
-/*
- * Tear down a watch request, synchronously.
- */
-static int __rbd_dev_header_unwatch_sync(struct rbd_device *rbd_dev)
-{
-	struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
-	struct rbd_obj_request *obj_request;
-	int ret;
-
-	rbd_assert(rbd_dev->watch_event);
-	rbd_assert(rbd_dev->watch_request);
-
-	obj_request = rbd_obj_request_create(rbd_dev->header_name, 0, 0,
-					     OBJ_REQUEST_NODATA);
-	if (!obj_request) {
-		ret = -ENOMEM;
-		goto out_cancel;
-	}
-
-	obj_request->osd_req = rbd_osd_req_create(rbd_dev, true, 1,
-						  obj_request);
-	if (!obj_request->osd_req) {
-		ret = -ENOMEM;
-		goto out_put;
-	}
-
-	osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_WATCH,
-			      rbd_dev->watch_event->cookie, 0, 0);
-	rbd_osd_req_format_write(obj_request);
-
-	ret = rbd_obj_request_submit(osdc, obj_request);
-	if (ret)
-		goto out_put;
-
-	ret = rbd_obj_request_wait(obj_request);
-	if (ret)
-		goto out_put;
-
-	ret = obj_request->result;
-	if (ret)
-		goto out_put;
-
-	/* We have successfully torn down the watch request */
-
-	ceph_osdc_unregister_linger_request(osdc,
-					    rbd_dev->watch_request->osd_req);
-	rbd_obj_request_put(rbd_dev->watch_request);
-	rbd_dev->watch_request = NULL;
-
-out_put:
-	rbd_obj_request_put(obj_request);
-out_cancel:
-	ceph_osdc_cancel_event(rbd_dev->watch_event);
-	rbd_dev->watch_event = NULL;
-
-	return ret;
-}
-
-static void rbd_dev_header_unwatch_sync(struct rbd_device *rbd_dev)
-{
-	int ret;
-
-	ret = __rbd_dev_header_unwatch_sync(rbd_dev);
-	if (ret) {
-		rbd_warn(rbd_dev, "unable to tear down watch request: %d\n",
-			 ret);
-	}
 }

 /*


ecdsa_ossl: address coverity nit

ecdsa_ossl: address coverity nit

BN_CTX_end() does not handle NULL input, so we must manually check
before calling from the cleanup handler.

Reviewed-by: Richard Levitte <5fb523282dd7956571c80524edc2dccfa0bd8234@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6502)

--- crypto/ec/ecdsa_ossl.c
+++ crypto/ec/ecdsa_ossl.c
@@ -336,7 +336,8 @@
         ECDSA_SIG_free(ret);
         ret = NULL;
     }
-    BN_CTX_end(ctx);
+    if (ctx != NULL)
+        BN_CTX_end(ctx);
     BN_CTX_free(ctx);
     BN_clear_free(kinv);
     return ret;


rbd: set device_type::release instead of device::release

No point in providing an empty device_type::release callback and then
setting device::release for each rbd_dev dynamically.

Signed-off-by: Ilya Dryomov <152d4c5bebf13a5b809d42b4d789cf9d887e6698@gmail.com>

--- drivers/block/rbd.c
+++ drivers/block/rbd.c
@@ -3989,14 +3989,12 @@
 	NULL
 };

-static void rbd_sysfs_dev_release(struct device *dev)
-{
-}
+static void rbd_dev_release(struct device *dev);

 static struct device_type rbd_device_type = {
 	.name		= "rbd",
 	.groups		= rbd_attr_groups,
-	.release	= rbd_sysfs_dev_release,
+	.release	= rbd_dev_release,
 };

 static struct rbd_spec *rbd_spec_get(struct rbd_spec *spec)
@@ -4077,7 +4075,6 @@
 	rbd_dev->dev.bus = &rbd_bus_type;
 	rbd_dev->dev.type = &rbd_device_type;
 	rbd_dev->dev.parent = &rbd_root_dev;
-	rbd_dev->dev.release = rbd_dev_release;
 	device_initialize(&rbd_dev->dev);

 	rbd_dev->rbd_client = rbdc;


Fix 'overlapping comparisons always evaluate to true' compile error with clang-10

--- crypto/gnutls/gnutls.c
+++ crypto/gnutls/gnutls.c
@@ -70,12 +70,12 @@
   gnutls_cipher_algorithm_t hp_cipher;

   cipher = gnutls_cipher_get(session);
-  if (cipher != GNUTLS_CIPHER_UNKNOWN || cipher != GNUTLS_CIPHER_NULL) {
+  if (cipher != GNUTLS_CIPHER_UNKNOWN && cipher != GNUTLS_CIPHER_NULL) {
     ctx->aead.native_handle = (void *)cipher;
   }

   hash = gnutls_prf_hash_get(session);
-  if (hash != GNUTLS_DIG_UNKNOWN || hash != GNUTLS_DIG_NULL) {
+  if (hash != GNUTLS_DIG_UNKNOWN && hash != GNUTLS_DIG_NULL) {
     ctx->md.native_handle = (void *)hash;
   }


Test case added.

Test case added.

This fails on original code but runs perfectly with my fix.

--- test/test_iniparser.c
+++ test/test_iniparser.c
@@ -230,9 +230,9 @@
     dictionary_unset(dic, "sec0:key2");

     CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(dic, "sec42", keys));
-    nkeys = iniparser_getsecnkeys(dic, "sec99");
+    nkeys = iniparser_getsecnkeys(dic, "Sec99");
     CuAssertIntEquals(tc, nkeys, 9);
-    CuAssertPtrEquals(tc, keys, iniparser_getseckeys(dic, "sec99", keys));
+    CuAssertPtrEquals(tc, keys, iniparser_getseckeys(dic, "Sec99", keys));
     for (i = 0; i < 9; ++i) {
         sprintf(key_name, "sec99:key%d", i);
         CuAssertStrEquals(tc, key_name, keys[i]);


rbd: get additional info in parent spec

rbd: get additional info in parent spec

When a layered rbd image has a parent, that parent is identified
only by its pool id, image id, and snapshot id.  Images that have
been mapped also record *names* for those three id's.

Add code to look up these names for parent images so they match
mapped images more closely.  Skip doing this for an image if it
already has its pool name defined (this will be the case for images
mapped by the user).

It is possible that an the name of a parent image can't be
determined, even if the image id is valid.  If this occurs it
does not preclude correct operation, so don't treat this as
an error.

On the other hand, defined pools will always have both an id and a
name.   And any snapshot of an image identified as a parent for a
clone image will exist, and will have a name (if not it indicates
some other internal error).  So treat failure to get these bits
of information as errors.

Signed-off-by: Alex Elder <f429030cf5c0faf36fac3d102073b6e63a647baa@inktank.com>
Reviewed-by: Josh Durgin <51652c783f70f5b272ebd02f1fd20d3af7a2449f@inktank.com>

--- drivers/block/rbd.c
+++ drivers/block/rbd.c
@@ -70,7 +70,10 @@

 #define RBD_SNAP_HEAD_NAME	"-"

+/* This allows a single page to hold an image name sent by OSD */
+#define RBD_IMAGE_NAME_LEN_MAX	(PAGE_SIZE - sizeof (__le32) - 1)
 #define RBD_IMAGE_ID_LEN_MAX	64
+
 #define RBD_OBJ_PREFIX_LEN_MAX	64

 /* Feature bits */
@@ -656,6 +659,20 @@
 	header->object_prefix = NULL;

 	return -ENOMEM;
+}
+
+static const char *rbd_snap_name(struct rbd_device *rbd_dev, u64 snap_id)
+{
+	struct rbd_snap *snap;
+
+	if (snap_id == CEPH_NOSNAP)
+		return RBD_SNAP_HEAD_NAME;
+
+	list_for_each_entry(snap, &rbd_dev->snaps, node)
+		if (snap_id == snap->id)
+			return snap->name;
+
+	return NULL;
 }

 static int snap_by_name(struct rbd_device *rbd_dev, const char *snap_name)
@@ -2499,6 +2516,7 @@
 		goto out_err;
 	}
 	parent_spec->image_id = image_id;
+	parent_spec->image_id_len = len;
 	ceph_decode_64_safe(&p, end, parent_spec->snap_id, out_err);
 	ceph_decode_64_safe(&p, end, overlap, out_err);

@@ -2510,6 +2528,117 @@
 out_err:
 	kfree(reply_buf);
 	rbd_spec_put(parent_spec);
+
+	return ret;
+}
+
+static char *rbd_dev_image_name(struct rbd_device *rbd_dev)
+{
+	size_t image_id_size;
+	char *image_id;
+	void *p;
+	void *end;
+	size_t size;
+	void *reply_buf = NULL;
+	size_t len = 0;
+	char *image_name = NULL;
+	int ret;
+
+	rbd_assert(!rbd_dev->spec->image_name);
+
+	image_id_size = sizeof (__le32) + rbd_dev->spec->image_id_len;
+	image_id = kmalloc(image_id_size, GFP_KERNEL);
+	if (!image_id)
+		return NULL;
+
+	p = image_id;
+	end = (char *) image_id + image_id_size;
+	ceph_encode_string(&p, end, rbd_dev->spec->image_id,
+				(u32) rbd_dev->spec->image_id_len);
+
+	size = sizeof (__le32) + RBD_IMAGE_NAME_LEN_MAX;
+	reply_buf = kmalloc(size, GFP_KERNEL);
+	if (!reply_buf)
+		goto out;
+
+	ret = rbd_req_sync_exec(rbd_dev, RBD_DIRECTORY,
+				"rbd", "dir_get_name",
+				image_id, image_id_size,
+				(char *) reply_buf, size,
+				CEPH_OSD_FLAG_READ, NULL);
+	if (ret < 0)
+		goto out;
+	p = reply_buf;
+	end = (char *) reply_buf + size;
+	image_name = ceph_extract_encoded_string(&p, end, &len, GFP_KERNEL);
+	if (IS_ERR(image_name))
+		image_name = NULL;
+	else
+		dout("%s: name is %s len is %zd\n", __func__, image_name, len);
+out:
+	kfree(reply_buf);
+	kfree(image_id);
+
+	return image_name;
+}
+
+/*
+ * When a parent image gets probed, we only have the pool, image,
+ * and snapshot ids but not the names of any of them.  This call
+ * is made later to fill in those names.  It has to be done after
+ * rbd_dev_snaps_update() has completed because some of the
+ * information (in particular, snapshot name) is not available
+ * until then.
+ */
+static int rbd_dev_probe_update_spec(struct rbd_device *rbd_dev)
+{
+	struct ceph_osd_client *osdc;
+	const char *name;
+	void *reply_buf = NULL;
+	int ret;
+
+	if (rbd_dev->spec->pool_name)
+		return 0;	/* Already have the names */
+
+	/* Look up the pool name */
+
+	osdc = &rbd_dev->rbd_client->client->osdc;
+	name = ceph_pg_pool_name_by_id(osdc->osdmap, rbd_dev->spec->pool_id);
+	if (!name)
+		return -EIO;	/* pool id too large (>= 2^31) */
+
+	rbd_dev->spec->pool_name = kstrdup(name, GFP_KERNEL);
+	if (!rbd_dev->spec->pool_name)
+		return -ENOMEM;
+
+	/* Fetch the image name; tolerate failure here */
+
+	name = rbd_dev_image_name(rbd_dev);
+	if (name) {
+		rbd_dev->spec->image_name_len = strlen(name);
+		rbd_dev->spec->image_name = (char *) name;
+	} else {
+		pr_warning(RBD_DRV_NAME "%d "
+			"unable to get image name for image id %s\n",
+			rbd_dev->major, rbd_dev->spec->image_id);
+	}
+
+	/* Look up the snapshot name. */
+
+	name = rbd_snap_name(rbd_dev, rbd_dev->spec->snap_id);
+	if (!name) {
+		ret = -EIO;
+		goto out_err;
+	}
+	rbd_dev->spec->snap_name = kstrdup(name, GFP_KERNEL);
+	if(!rbd_dev->spec->snap_name)
+		goto out_err;
+
+	return 0;
+out_err:
+	kfree(reply_buf);
+	kfree(rbd_dev->spec->pool_name);
+	rbd_dev->spec->pool_name = NULL;

 	return ret;
 }
@@ -3372,6 +3501,10 @@
 	if (ret)
 		return ret;

+	ret = rbd_dev_probe_update_spec(rbd_dev);
+	if (ret)
+		goto err_out_snaps;
+
 	ret = rbd_dev_set_mapping(rbd_dev);
 	if (ret)
 		goto err_out_snaps;


fix(csapp-proxylab): fix cache struct defination typo

--- csapp/proxylab/proxy.c
+++ csapp/proxylab/proxy.c
@@ -31,7 +31,7 @@
     int t_readcnt;

     char url[300];
-    sem_t url_mutex
+    sem_t url_mutex;
     sem_t url_w;
     int url_readcnt;
 };
@@ -44,11 +44,11 @@
 void cache_url_read(int index, char *dst);
 int cache_turn_read(int index);

-int main()
+int main(int argc, char *argv[])
 {
     Signal(SIGPIPE, SIG_IGN);
     struct sockaddr_in clientaddr;
-    int post, listenfd, clientlen;
+    int port, listenfd, clientlen;
     int turn = 1;
     pthread_t tid;
     struct arg *p;
@@ -59,7 +59,7 @@
     }

     for (int i = 0; i < 10; i++) {
-        cache_erase[i];
+        cache_erase(i);
     }

     port = atoi(argv[1]);


rbd: remove parent devices on probe error

When an error occurs while finishing probing a device it is assumed
that parent devices get cleaned up when deleting a device.  They
don't.  Add a call to clean them up.  Note that this means the
parent spec will already be cleaned up so it doesn't have to be
in one of the rbd_add() error paths.

Signed-off-by: Alex Elder <f429030cf5c0faf36fac3d102073b6e63a647baa@inktank.com>
Reviewed-by: Josh Durgin <51652c783f70f5b272ebd02f1fd20d3af7a2449f@inktank.com>

--- drivers/block/rbd.c
+++ drivers/block/rbd.c
@@ -4813,8 +4813,7 @@
 	return ret;

 err_out_bus:
-	/* this will also clean up rest of rbd_dev stuff */
-
+	rbd_dev_remove_parent(rbd_dev);
 	rbd_bus_del_dev(rbd_dev);

 	return ret;
@@ -4931,7 +4930,6 @@

 	return count;
 err_out_rbd_dev:
-	rbd_spec_put(rbd_dev->parent_spec);
 	kfree(rbd_dev->header_name);
 	rbd_dev_destroy(rbd_dev);
 err_out_client:


myspace-item-view: Fix potential corruption bug by changing owner unowned string

The string returned by json_object_get_string_member is owned by the
JsonObject - it's pretty rude to use sw_unescape_entities on it to change it's
content.

It's even worse to give the ownership using sw_item_take when you don't own it
the first place.

--- services/myspace/myspace-item-view.c
+++ services/myspace/myspace-item-view.c
@@ -221,7 +221,6 @@
   JsonNode *author;
   JsonObject *entry_obj, *author_obj;
   const char *tmp;
-  char *status;

   item = sw_item_new ();
   sw_item_set_service (item, service);
@@ -257,8 +256,9 @@
   sw_item_request_image_fetch (item, FALSE, "authoricon", g_strdup (tmp));;

   /* Get the content */
-  status = json_object_get_string_member (entry_obj, "status");
-  sw_item_put (item, "content", sw_unescape_entities ((gchar *)status));
+  tmp = json_object_get_string_member (entry_obj, "status");
+  /* sw_unescape_entities works in place -> must duplicate before */
+  sw_item_take (item, "content", sw_unescape_entities (g_strdup (tmp)));
   /* TODO: if mood is not "(none)" then append that to the status message */

   /* Get the date */


dmaengine: pl330: Really fix choppy sound because of wrong residue calculation

When pl330 driver was used during sound playback, after some time or
after a number of plays the sound became choppy or totally noisy. For
example on Odroid XU3 board the first four executions of aplay with
small WAVE worked fine, but fifth was unrecognizable with errors:
	$ aplay /usr/share/sounds/alsa/Front_Right.wava
	underrun!!! (at least 0.095 ms long)

Issue was caused by wrong residue reported by pl330 driver to
pcm_dmaengine for its cyclic dma transfers.

The pl330_tx_status(), residue reporting function, used a "last" flag in
a descriptor to indicate that there is no more data to send.

The pl330_tx_submit() iterated over descriptors trying to remove this
flag from them and then mark last descriptor as "last".  However when
iterating it actually removed the flag not from descriptors but always
from last of it (and then reset it). Thus effectively once some
descriptor was marked as last, then it stayed like this forever causing
residue to be reported too low.

Signed-off-by: Krzysztof Kozlowski <e2fab786eddc0871341d92c5a7126cb6c6b4f7fc@gmail.com>
Fixes: aee4d1fac887 ("dmaengine: pl330: improve pl330_tx_status() function")
Cc: <4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org>
Reported-by: 18a98c35f49808b45edadc75fb1b25ebfd4037d6@unseen.is
Suggested-by: Marek Szyprowski <2a0259761cc3e88db42be5300c1579a67c77e65e@samsung.com>
Tested-by: Lars-Peter Clausen <3318dc5ce3e4fb7c28a0b841b6801c884e1d0896@metafoo.de>
Signed-off-by: Vinod Koul <5cf69c63beb17bf38d63aa0e923ee8256af0e205@intel.com>

--- drivers/dma/pl330.c
+++ drivers/dma/pl330.c
@@ -2328,7 +2328,7 @@
 			desc->txd.callback = last->txd.callback;
 			desc->txd.callback_param = last->txd.callback_param;
 		}
-		last->last = false;
+		desc->last = false;

 		dma_cookie_assign(&desc->txd);


yayyyyy centroid

yayyyyy centroid

--- physics.c
+++ physics.c
@@ -89,7 +89,7 @@
   // store the vertices in a slightly more user friendly thing
   po_vector* vertex = polygon.vertices;

-  // our centroid sum
+  // our centroid sum, initiallized at 0
   po_vector sum;
   sum.x = 0;
   sum.y = 0;


Added comments.
Added lines for appending default view/filter extension (.vw and .ftr)

(Logical change 1.359)

--- setools/seaudit/multifilter_window.c
+++ setools/seaudit/multifilter_window.c
@@ -185,13 +185,19 @@

 	if (!window)
 		return;
-
+
+	/* If this is not a 'Save As' request and the multifilter is a loaded saved multifilter,
+	 * then just save using it's original filename. Otherwise, it has no filename and so get
+	 * the filename from the user, while appending the default seaudit view extension. */
 	if (!saveas && strcmp(window->filename->str, "") != 0)
 		filename = g_string_new(window->filename->str);
 	else {
 		filename = get_filename_from_user("Save View", window->name->str);
 		if (filename == NULL)
 			return;
+		/* Append the default seaudit view extension (defined in seaudit.h). */
+		g_string_append(filename, SEAUDIT_VIEW_EXT);
+
 		if (g_file_test(filename->str, G_FILE_TEST_EXISTS)) {
 			message = g_string_new("");
 			g_string_printf(message, "The file %s\nalready exists.  Are you sure you wish to continue?", filename->str);
@@ -530,6 +536,9 @@
 	filename = get_filename_from_user("Export filter", filter->name);
 	if (filename == NULL)
 		return;
+	/* Append the default seaudit filter extension (defined in seaudit.h). */
+	g_string_append(filename, SEAUDIT_FILTER_EXT);
+
 	if (g_file_test(filename->str, G_FILE_TEST_EXISTS)) {
 		message = g_string_new("");
 		g_string_printf(message, "The file %s\nalready exists.  Are you sure you wish to continue?", filename->str);


drivers/bch: fix linking error

drivers/bch: fix linking error

This patch fixes a linking error of bchdev_unregister.c.
Change _err to fdbg.

Change-Id: I7643bada69bf8dba80ec3bc441ca4c9933e12e6d
Signed-off-by: EunBong Song <1a7e7e98e070490e67aa35ab67fbf9fdda8f48ac@samsung.com>

--- os/drivers/bch/bchdev_unregister.c
+++ os/drivers/bch/bchdev_unregister.c
@@ -97,7 +97,7 @@
 	/* Open the character driver associated with chardev */
 	fd = open(chardev, O_RDONLY);
 	if (fd < 0) {
-		_err("ERROR: Failed to open %s: %d\n", chardev, errno);
+		fdbg("ERROR: Failed to open %s: %d\n", chardev, errno);
 		return -errno;
 	}

@@ -109,7 +109,7 @@
 	(void)close(fd);

 	if (ret < 0) {
-		_err("ERROR: ioctl failed: %d\n", errno);
+		fdbg("ERROR: ioctl failed: %d\n", errno);
 		return -errno;
 	}


KVM: Improve local apic timer wraparound handling

Better handle wrap-around cases when reading the APIC CCR
(current count register).  Also, if ICR is 0, CCR should also
be 0... previously reading CCR before setting ICR would result
in a large kinda-random number.

Signed-off-by: Kevin Pedretti <1efe0d036e85621189016b79a75a643d1d55ce40@gmail.com>
Signed-off-by: Avi Kivity <8f920f22884d6fea9df883843c4a8095a2e5ac6f@qumranet.com>

--- drivers/kvm/lapic.c
+++ drivers/kvm/lapic.c
@@ -494,11 +494,18 @@

 static u32 apic_get_tmcct(struct kvm_lapic *apic)
 {
-	u32 counter_passed;
-	ktime_t passed, now = apic->timer.dev.base->get_time();
-	u32 tmcct = apic_get_reg(apic, APIC_TMICT);
+	u64 counter_passed;
+	ktime_t passed, now;
+	u32 tmcct;

 	ASSERT(apic != NULL);
+
+	now = apic->timer.dev.base->get_time();
+	tmcct = apic_get_reg(apic, APIC_TMICT);
+
+	/* if initial count is 0, current count should also be 0 */
+	if (tmcct == 0)
+		return 0;

 	if (unlikely(ktime_to_ns(now) <=
 		ktime_to_ns(apic->timer.last_update))) {
@@ -514,15 +521,24 @@

 	counter_passed = div64_64(ktime_to_ns(passed),
 				  (APIC_BUS_CYCLE_NS * apic->timer.divide_count));
-	tmcct -= counter_passed;
-
-	if (tmcct <= 0) {
-		if (unlikely(!apic_lvtt_period(apic)))
+
+	if (counter_passed > tmcct) {
+		if (unlikely(!apic_lvtt_period(apic))) {
+			/* one-shot timers stick at 0 until reset */
 			tmcct = 0;
-		else
-			do {
-				tmcct += apic_get_reg(apic, APIC_TMICT);
-			} while (tmcct <= 0);
+		} else {
+			/*
+			 * periodic timers reset to APIC_TMICT when they
+			 * hit 0. The while loop simulates this happening N
+			 * times. (counter_passed %= tmcct) would also work,
+			 * but might be slower or not work on 32-bit??
+			 */
+			while (counter_passed > tmcct)
+				counter_passed -= tmcct;
+			tmcct -= counter_passed;
+		}
+	} else {
+		tmcct -= counter_passed;
 	}

 	return tmcct;


added warnings and non-generic DynamicObjectArray

--- src/shogun/features/SubsetStack.h
+++ src/shogun/features/SubsetStack.h
@@ -58,8 +58,11 @@
 	/** removes all subsets, leaving this subset being the pure identity */
 	virtual void remove_all_subsets();

-	/** @return size of active subset, -1 if there is no such */
+	/** @return size of active subset */
 	inline index_t get_size() {
+		if (!has_subsets())
+			SG_WARNING("CSubsetStack::get_size(): No subset in stack!\n");
+
 		return has_subsets() ? m_active_subset->get_size() : -1;
 	}

@@ -88,7 +91,7 @@
 	 * recomputing them when subsets are removed. There is always the identity
 	 * subset as first element in here (only internal visible, has_subsets()
 	 * returns false if only this identity is present) */
-	CDynamicObjectArray<CSubset>* m_active_subsets_stack;
+	CDynamicObjectArray* m_active_subsets_stack;

 	/** active index subset. Last element on stack for quick access */
 	CSubset* m_active_subset;


add glNewList() test

add glNewList() test

error: pathspec 'test/tests/list/new.c' did not match any file(s) known to git

--- test/tests/list/new.c
+++ test/tests/list/new.c
@@ -0,0 +1,6 @@
+int main() {
+    int list = glGenLists(1);
+    glNewList(list, GL_COMPILE);
+    mock_assert(state.list.active, "glNewList failed\n");
+    mock_return;
+}


rename ioqversion -> generation; move increment before fstrm_iothr_destroy

--- lib/dns/dnstap.c
+++ lib/dns/dnstap.c
@@ -122,7 +122,7 @@
 /*
  * Change under task exclusive.
  */
-static unsigned int ioqversion;
+static unsigned int generation;

 static void
 mutex_init(void) {
@@ -189,7 +189,7 @@
 		      DNS_LOGMODULE_DNSTAP, ISC_LOG_INFO,
 		      "opening dnstap destination '%s'", path);

-	ioqversion++;
+	generation++;

 	env = isc_mem_get(mctx, sizeof(dns_dtenv_t));
 	if (env == NULL)
@@ -326,11 +326,11 @@
 		      "%s dnstap destination '%s'",
 		      (roll < 0) ? "reopening" : "rolling",
 		      env->path);
+
+	generation++;

 	if (env->iothr != NULL)
 		fstrm_iothr_destroy(&env->iothr);
-
-	ioqversion++;

 	if (env->mode == dns_dtmode_file && roll >= 0) {
 		/*
@@ -415,7 +415,7 @@
 dt_queue(dns_dtenv_t *env) {
 	isc_result_t result;
 	struct ioq {
-		unsigned int ioqversion;
+		unsigned int generation;
 		struct fstrm_iothr_queue *ioq;
 	} *ioq;

@@ -429,7 +429,7 @@
 		return (NULL);

 	ioq = (struct ioq *)isc_thread_key_getspecific(dt_key);
-	if (ioq != NULL && ioq->ioqversion != ioqversion) {
+	if (ioq != NULL && ioq->generation != generation) {
 		result = isc_thread_key_setspecific(dt_key, NULL);
 		if (result != ISC_R_SUCCESS)
 			return (NULL);
@@ -440,7 +440,7 @@
 		ioq = malloc(sizeof(*ioq));
 		if (ioq == NULL)
 			return (NULL);
-		ioq->ioqversion = ioqversion;
+		ioq->generation = generation;
 		ioq->ioq = fstrm_iothr_get_input_queue(env->iothr);
 		if (ioq->ioq == NULL) {
 			free(ioq);
@@ -484,7 +484,7 @@
 		      "closing dnstap");
 	env->magic = 0;

-	ioqversion++;
+	generation++;

 	if (env->iothr != NULL)
 		fstrm_iothr_destroy(&env->iothr);


md/bitmap: remove bitmap_mask_state

md/bitmap: remove bitmap_mask_state

This function isn't really needed.  It sets or clears a flag in both
bitmap->flags and sb->state.
However both times it is called, bitmap_update_sb is called soon
afterwards which copies bitmap->flags to sb->state.
So just make changes to bitmap->flags, and open-code those rather than
hiding in a function.

Signed-off-by: NeilBrown <1c00aa603bb92d594c03cff60ecf8e63b2a5bcb1@suse.de>

--- drivers/md/bitmap.c
+++ drivers/md/bitmap.c
@@ -640,38 +640,6 @@
 	return err;
 }

-enum bitmap_mask_op {
-	MASK_SET,
-	MASK_UNSET
-};
-
-/* record the state of the bitmap in the superblock.  Return the old value */
-static int bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
-			     enum bitmap_mask_op op)
-{
-	bitmap_super_t *sb;
-	int old;
-
-	if (!bitmap->storage.sb_page) /* can't set the state */
-		return 0;
-	sb = kmap_atomic(bitmap->storage.sb_page);
-	old = le32_to_cpu(sb->state) & bits;
-	switch (op) {
-	case MASK_SET:
-		sb->state |= cpu_to_le32(bits);
-		bitmap->flags |= bits;
-		break;
-	case MASK_UNSET:
-		sb->state &= cpu_to_le32(~bits);
-		bitmap->flags &= ~bits;
-		break;
-	default:
-		BUG();
-	}
-	kunmap_atomic(sb);
-	return old;
-}
-
 /*
  * general bitmap file operations
  */
@@ -828,7 +796,8 @@
 {
 	char *path, *ptr = NULL;

-	if (bitmap_mask_state(bitmap, BITMAP_STALE, MASK_SET) == 0) {
+	if (!(bitmap->flags & BITMAP_STALE)) {
+		bitmap->flags |= BITMAP_STALE;
 		bitmap_update_sb(bitmap);

 		if (bitmap->storage.file) {
@@ -1830,7 +1799,7 @@

 	if (err)
 		goto out;
-	bitmap_mask_state(bitmap, BITMAP_STALE, MASK_UNSET);
+	bitmap->flags &= ~BITMAP_STALE;

 	/* Kick recovery in case any bits were set */
 	set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery);


md/faulty: remove typedef: conf_t -> struct faulty_conf

Signed-off-by: NeilBrown <1c00aa603bb92d594c03cff60ecf8e63b2a5bcb1@suse.de>

--- drivers/md/faulty.c
+++ drivers/md/faulty.c
@@ -81,16 +81,16 @@
 	bio_io_error(b);
 }

-typedef struct faulty_conf {
+struct faulty_conf {
 	int period[Modes];
 	atomic_t counters[Modes];
 	sector_t faults[MaxFault];
 	int	modes[MaxFault];
 	int nfaults;
 	struct md_rdev *rdev;
-} conf_t;
-
-static int check_mode(conf_t *conf, int mode)
+};
+
+static int check_mode(struct faulty_conf *conf, int mode)
 {
 	if (conf->period[mode] == 0 &&
 	    atomic_read(&conf->counters[mode]) <= 0)
@@ -105,7 +105,7 @@
 	return 0;
 }

-static int check_sector(conf_t *conf, sector_t start, sector_t end, int dir)
+static int check_sector(struct faulty_conf *conf, sector_t start, sector_t end, int dir)
 {
 	/* If we find a ReadFixable sector, we fix it ... */
 	int i;
@@ -129,7 +129,7 @@
 	return 0;
 }

-static void add_sector(conf_t *conf, sector_t start, int mode)
+static void add_sector(struct faulty_conf *conf, sector_t start, int mode)
 {
 	int i;
 	int n = conf->nfaults;
@@ -171,7 +171,7 @@

 static int make_request(struct mddev *mddev, struct bio *bio)
 {
-	conf_t *conf = mddev->private;
+	struct faulty_conf *conf = mddev->private;
 	int failit = 0;

 	if (bio_data_dir(bio) == WRITE) {
@@ -224,7 +224,7 @@

 static void status(struct seq_file *seq, struct mddev *mddev)
 {
-	conf_t *conf = mddev->private;
+	struct faulty_conf *conf = mddev->private;
 	int n;

 	if ((n=atomic_read(&conf->counters[WriteTransient])) != 0)
@@ -259,7 +259,7 @@
 {
 	int mode = mddev->new_layout & ModeMask;
 	int count = mddev->new_layout >> ModeShift;
-	conf_t *conf = mddev->private;
+	struct faulty_conf *conf = mddev->private;

 	if (mddev->new_layout < 0)
 		return 0;
@@ -299,7 +299,7 @@
 {
 	struct md_rdev *rdev;
 	int i;
-	conf_t *conf;
+	struct faulty_conf *conf;

 	if (md_check_no_bitmap(mddev))
 		return -EINVAL;
@@ -327,7 +327,7 @@

 static int stop(struct mddev *mddev)
 {
-	conf_t *conf = mddev->private;
+	struct faulty_conf *conf = mddev->private;

 	kfree(conf);
 	mddev->private = NULL;


md/raid10: always set reshape_safe when initializing reshape_position.

'reshape_position' tracks where in the reshape we have reached.
'reshape_safe' tracks where in the reshape we have safely recorded
in the metadata.

These are compared to determine when to update the metadata.
So it is important that reshape_safe is initialised properly.
Currently it isn't.  When starting a reshape from the beginning
it usually has the correct value by luck.  But when reducing the
number of devices in a RAID10, it has the wrong value and this leads
to the metadata not being updated correctly.
This can lead to corruption if the reshape is not allowed to complete.

This patch is suitable for any -stable kernel which supports RAID10
reshape, which is 3.5 and later.

Fixes: 3ea7daa5d7fd ("md/raid10: add reshape support")
Cc: 4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org (v3.5+ please wait for -final to be out for 2 weeks)
Signed-off-by: NeilBrown <1c00aa603bb92d594c03cff60ecf8e63b2a5bcb1@suse.com>

--- drivers/md/raid10.c
+++ drivers/md/raid10.c
@@ -3556,6 +3556,7 @@
 			/* far_copies must be 1 */
 			conf->prev.stride = conf->dev_sectors;
 	}
+	conf->reshape_safe = conf->reshape_progress;
 	spin_lock_init(&conf->device_lock);
 	INIT_LIST_HEAD(&conf->retry_list);

@@ -3760,7 +3761,6 @@
 		}
 		conf->offset_diff = min_offset_diff;

-		conf->reshape_safe = conf->reshape_progress;
 		clear_bit(MD_RECOVERY_SYNC, &mddev->recovery);
 		clear_bit(MD_RECOVERY_CHECK, &mddev->recovery);
 		set_bit(MD_RECOVERY_RESHAPE, &mddev->recovery);
@@ -4103,6 +4103,7 @@
 		conf->reshape_progress = size;
 	} else
 		conf->reshape_progress = 0;
+	conf->reshape_safe = conf->reshape_progress;
 	spin_unlock_irq(&conf->device_lock);

 	if (mddev->delta_disks && mddev->bitmap) {
@@ -4170,6 +4171,7 @@
 		rdev->new_data_offset = rdev->data_offset;
 	smp_wmb();
 	conf->reshape_progress = MaxSector;
+	conf->reshape_safe = MaxSector;
 	mddev->reshape_position = MaxSector;
 	spin_unlock_irq(&conf->device_lock);
 	return ret;
@@ -4524,6 +4526,7 @@
 	md_finish_reshape(conf->mddev);
 	smp_wmb();
 	conf->reshape_progress = MaxSector;
+	conf->reshape_safe = MaxSector;
 	spin_unlock_irq(&conf->device_lock);

 	/* read-ahead size must cover two whole stripes, which is


cpmac: fix wrong MDIO bus identifier

cpmac: fix wrong MDIO bus identifier

This patch fixes the wrong MDIO bus identifier which was
set to 0 unconditionaly, suitable for external switches while
it is actually 1 for PHYs different than external switches
which are autodetected.

Signed-off-by: Florian Fainelli <73262ad0334ab37227b2f7a0205f51db1e606681@openwrt.org>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/cpmac.c
+++ drivers/net/cpmac.c
@@ -1109,7 +1109,7 @@
 static int __devinit cpmac_probe(struct platform_device *pdev)
 {
 	int rc, phy_id;
-	char *mdio_bus_id = "0";
+	char mdio_bus_id[BUS_ID_SIZE];
 	struct resource *mem;
 	struct cpmac_priv *priv;
 	struct net_device *dev;
@@ -1127,7 +1127,7 @@

 	if (phy_id == PHY_MAX_ADDR) {
 		if (external_switch || dumb_switch) {
-			mdio_bus_id = 0; /* fixed phys bus */
+			strncpy(mdio_bus_id, "0", BUS_ID_SIZE); /* fixed phys bus */
 			phy_id = pdev->id;
 		} else {
 			dev_err(&pdev->dev, "no PHY present\n");
@@ -1254,7 +1254,7 @@
 	}

 	cpmac_mii->phy_mask = ~(mask | 0x80000000);
-	snprintf(cpmac_mii->id, MII_BUS_ID_SIZE, "0");
+	snprintf(cpmac_mii->id, MII_BUS_ID_SIZE, "1");

 	res = mdiobus_register(cpmac_mii);
 	if (res)


Forget one :-) catch me if you can *muhahaha*

--- src/world/ObjectMgr.h
+++ src/world/ObjectMgr.h
@@ -349,7 +349,7 @@
 #ifdef arcemu_USE_MAP_PLAYER_INDEX

 // you can use the string map (slower)
-typedef std::map<string, PlayerInfo*> PlayerNameStringIndexMap;
+typedef std::map<std::string, PlayerInfo*> PlayerNameStringIndexMap;

 #else			// or


drivers/net/e2100.c: fix sparse warning: symbol shadows an earlier one

Impact: Remove redundant inner scope variable and while being at it
make use of ARRAY_SIZE instead of a hardcoded number.

Fix this sparse warning:
  drivers/net/e2100.c:219:56: warning: symbol 'i' shadows an earlier one
  drivers/net/e2100.c:181:13: originally declared here

Signed-off-by: Hannes Eder <331be22c6b63ca3e0a03d408c2d906b1b02cd5f2@hanneseder.net>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/e2100.c
+++ drivers/net/e2100.c
@@ -216,13 +216,13 @@
 		printk(" %02X", station_addr[i]);

 	if (dev->irq < 2) {
-		int irqlist[] = {15,11,10,12,5,9,3,4}, i;
-		for (i = 0; i < 8; i++)
+		int irqlist[] = {15, 11, 10, 12, 5, 9, 3, 4};
+		for (i = 0; i < ARRAY_SIZE(irqlist); i++)
 			if (request_irq (irqlist[i], NULL, 0, "bogus", NULL) != -EBUSY) {
 				dev->irq = irqlist[i];
 				break;
 			}
-		if (i >= 8) {
+		if (i >= ARRAY_SIZE(irqlist)) {
 			printk(" unable to get IRQ %d.\n", dev->irq);
 			retval = -EAGAIN;
 			goto out;


r8169: fix past rtl_chip_info array size for unknown chipsets

'i' is unsigned.

Signed-off-by: Roel Kluin <e18d74b914d880e021734ee3329e838c0a50e849@tiscali.nl>
Acked-by: Francois Romieu <b6456b24ae82a7595be3173ae585c7a827f25f37@fr.zoreil.com>

--- drivers/net/r8169.c
+++ drivers/net/r8169.c
@@ -1705,18 +1705,18 @@

 	rtl8169_print_mac_version(tp);

-	for (i = ARRAY_SIZE(rtl_chip_info) - 1; i >= 0; i--) {
+	for (i = 0; i < ARRAY_SIZE(rtl_chip_info); i++) {
 		if (tp->mac_version == rtl_chip_info[i].mac_version)
 			break;
 	}
-	if (i < 0) {
+	if (i == ARRAY_SIZE(rtl_chip_info)) {
 		/* Unknown chip: assume array element #0, original RTL-8169 */
 		if (netif_msg_probe(tp)) {
 			dev_printk(KERN_DEBUG, &pdev->dev,
 				"unknown chip version, assuming %s\n",
 				rtl_chip_info[0].name);
 		}
-		i++;
+		i = 0;
 	}
 	tp->chipset = i;


replace the defines list by an enum

replace the defines list by an enum

--- src/wrapper_mplayer.c
+++ src/wrapper_mplayer.c
@@ -43,12 +43,14 @@

 #define SLAVE_CMD_BUFFER 256

-#define MPLAYER_DVDNAV_UP     1
-#define MPLAYER_DVDNAV_DOWN   2
-#define MPLAYER_DVDNAV_LEFT   3
-#define MPLAYER_DVDNAV_RIGHT  4
-#define MPLAYER_DVDNAV_MENU   5
-#define MPLAYER_DVDNAV_SELECT 6
+typedef enum {
+  MPLAYER_DVDNAV_UP     = 1,
+  MPLAYER_DVDNAV_DOWN   = 2,
+  MPLAYER_DVDNAV_LEFT   = 3,
+  MPLAYER_DVDNAV_RIGHT  = 4,
+  MPLAYER_DVDNAV_MENU   = 5,
+  MPLAYER_DVDNAV_SELECT = 6,
+} mplayer_dvdnav_t;

 /* Status of MPlayer child */
 typedef enum mplayer_status {


vxlan: fix potential NULL dereference in arp_reduce()

This patch fixes a NULL pointer dereference in the event of an
skb allocation failure in arp_reduce().

Signed-Off-By: David L Stevens <dlstevens@us.ibm.com>
Acked-by: Cong Wang <cwang@twopensource.com>

Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/vxlan.c
+++ drivers/net/vxlan.c
@@ -1318,6 +1318,9 @@

 		neigh_release(n);

+		if (reply == NULL)
+			goto out;
+
 		skb_reset_mac_header(reply);
 		__skb_pull(reply, skb_network_offset(reply));
 		reply->ip_summed = CHECKSUM_UNNECESSARY;


cosmetic: fix indent

cosmetic: fix indent

--- src/wrapper_mplayer.c
+++ src/wrapper_mplayer.c
@@ -531,7 +531,7 @@
   if (!command || state != ITEM_ENABLE)
     return;

-    send_to_slave (player, "%s %s", command, prop);
+  send_to_slave (player, "%s %s", command, prop);
 }

 /**


obexd: Initialize services bit mask to 0

--- obexd/src/main.c
+++ obexd/src/main.c
@@ -139,7 +139,7 @@
 	GOptionContext *context;
 	GError *err = NULL;
 	struct sigaction sa;
-	int log_option = LOG_NDELAY | LOG_PID, services;
+	int log_option = LOG_NDELAY | LOG_PID, services = 0;

 #ifdef NEED_THREADS
 	if (g_thread_supported() == FALSE)


NFC: pn533: Re-group fields in struct pn533

Signed-off-by: Waldemar Rymarkiewicz <35d304b3075d514779e58e47500a1aa9e0a46d68@tieto.com>
Signed-off-by: Samuel Ortiz <0ba86cb3f08bbb861958e54bd3438887adb4263c@linux.intel.com>

--- drivers/nfc/pn533.c
+++ drivers/nfc/pn533.c
@@ -314,6 +314,7 @@
 	struct usb_device *udev;
 	struct usb_interface *interface;
 	struct nfc_dev *nfc_dev;
+	u32 device_type;

 	struct urb *out_urb;
 	struct urb *in_urb;
@@ -326,19 +327,22 @@
 	struct work_struct poll_work;
 	struct work_struct mi_work;
 	struct work_struct tg_work;
-	struct timer_list listen_timer;
+
+	struct list_head cmd_queue;
+	struct pn533_cmd *cmd;
+	u8 cmd_pending;
 	int wq_in_error;
-	int cancel_listen;
+	struct mutex cmd_lock;  /* protects cmd queue */

 	void *cmd_complete_mi_arg;
-	struct mutex cmd_lock;
-	struct pn533_cmd *cmd;

 	struct pn533_poll_modulations *poll_mod_active[PN533_POLL_MOD_MAX + 1];
 	u8 poll_mod_count;
 	u8 poll_mod_curr;
 	u32 poll_protocols;
 	u32 listen_protocols;
+	struct timer_list listen_timer;
+	int cancel_listen;

 	u8 *gb;
 	size_t gb_len;
@@ -346,11 +350,6 @@
 	u8 tgt_available_prots;
 	u8 tgt_active_prot;
 	u8 tgt_mode;
-
-	u32 device_type;
-
-	struct list_head cmd_queue;
-	u8 cmd_pending;

 	struct pn533_frame_ops *ops;
 };


open() returns -1 on failure, not 0. -1 checked for now.

--- cvd/Linux/v4l2buffer.h
+++ cvd/Linux/v4l2buffer.h
@@ -18,6 +18,12 @@
   V4L2BBMchew
 };

+/*
+enum V4L2BufferFrameOrder{
+  MostRecent,
+  InOrder,
+};*/
+
 namespace Exceptions
 {
 	namespace V4L2Buffer
@@ -34,7 +40,7 @@
 class V4L2Buffer : public VideoBuffer<unsigned char>
 {
 	public:
-		V4L2Buffer(const char *devname, bool fields, V4L2BufferBlockMethod block);
+		V4L2Buffer(const char *devname, bool fields, V4L2BufferBlockMethod block, int numbufs=V4L2BUFFERS);
 		~V4L2Buffer();

 		virtual ImageRef size()
@@ -56,11 +62,11 @@
 		std::string device;
 		int my_dropped_frames;
 		int my_prev_frame_no;
+		int num_buffers;
 		bool i_am_using_fields;
 		float my_frame_rate;
 		ImageRef my_image_size;
 		V4L2BufferBlockMethod my_block_method;
-
 		struct v4l2_buffer* m_sv4l2Buffer;
 		void** m_pvVideoBuffer;
 		int m_nVideoFileDesc;


NFC: pn533: Rename pn533_fw_reset appropriately

Define explicitely it is Pasori specific reset command.

Signed-off-by: Waldemar Rymarkiewicz <35d304b3075d514779e58e47500a1aa9e0a46d68@tieto.com>
Signed-off-by: Samuel Ortiz <0ba86cb3f08bbb861958e54bd3438887adb4263c@linux.intel.com>

--- drivers/nfc/pn533.c
+++ drivers/nfc/pn533.c
@@ -2314,7 +2314,7 @@
 	return 0;
 }

-static int pn533_fw_reset(struct pn533 *dev)
+static int pn533_pasori_fw_reset(struct pn533 *dev)
 {
 	struct sk_buff *skb;
 	struct sk_buff *resp;
@@ -2409,7 +2409,7 @@
 		break;

 	case PN533_DEVICE_PASORI:
-		pn533_fw_reset(dev);
+		pn533_pasori_fw_reset(dev);

 		rc = pn533_set_configuration(dev, PN533_CFGITEM_PASORI,
 					     pasori_cfg, 3);
@@ -2419,7 +2419,7 @@
 			return rc;
 		}

-		pn533_fw_reset(dev);
+		pn533_pasori_fw_reset(dev);

 		break;
 	}


Replaced auto_ptr'd array[] with a static array[]. Using auto_ptr with new[] is a no-no, since it'll not use delete[] and this results in BADNESS 9000. I'm sure there was a good reason not to use a static array in the first place (exception if you can't make one that big perhaps?) so maybe there's a better way.

--- cvd/internal/io/jpeg.h
+++ cvd/internal/io/jpeg.h
@@ -59,10 +59,10 @@

   template <class T, class S> struct JPEGReader {
     static void read(BasicImage<T>& im, jpeg_in& jpeg) {
-      std::auto_ptr<S> rowbuf(new S[jpeg.x_size()]);
+      S rowbuf[jpeg.x_size()];
       for (int r=0; r<jpeg.y_size(); r++) {
-	jpeg.get_raw_pixel_lines((byte*)rowbuf.get(), 1);
-	Pixel::ConvertPixels<S,T>::convert(rowbuf.get(), im[r], jpeg.x_size());
+	jpeg.get_raw_pixel_lines((byte*)rowbuf, 1);
+	Pixel::ConvertPixels<S,T>::convert(rowbuf, im[r], jpeg.x_size());
       }
     }
   };


More debug printing added as well as returning rank/size in myinit() and myfini() debug prints

--- src/xalt_initialize.c
+++ src/xalt_initialize.c
@@ -282,9 +282,6 @@
               perror("uname");
               exit(EXIT_FAILURE);
             }
-	  my_size = compute_value(sizeA);
-	  if (my_size < 1L)
-	    my_size = 1L;

           fprintf(stderr, "---------------------------------------------\n"
                           " Date:          %s\n"
@@ -298,6 +295,9 @@
                   dateStr, XALT_GIT_VERSION, u.nodename, u.sysname, u.release,
                   u.version, u.machine);
         }
+      my_size = compute_value(sizeA);
+      if (my_size < 1L)
+	my_size = 1L;
       get_abspath(exec_path,sizeof(exec_path));
       fprintf(stderr,"myinit(%ld/%ld,%s,%s){\n", my_rank, my_size, STR(STATE),exec_path);
     }
@@ -828,7 +828,7 @@
       close(STDERR_FILENO);
       dup2(errfd, STDERR_FILENO);
       my_stderr = fdopen(errfd,"w");
-      DEBUG3(my_stderr,"\nmyfini(%ld,%s,%s){\n", my_rank, STR(STATE), exec_path);
+      DEBUG4(my_stderr,"\nmyfini(%ld/%ld,%s,%s){\n", my_rank, my_size, STR(STATE), exec_path);
     }

   /* Stop tracking if my mpi rank is not zero or the path was rejected. */
@@ -1040,6 +1040,8 @@
 	    DEBUG4(my_stderr, "    -> Sampling program run_time: %g: (my_rand: %g <= prob: %g) for program: %s\n",
 		   run_time, my_rand, probability, exec_path);
 	}
+      else
+	DEBUG0(my_stderr, "    -> XALT_SAMPLING = \"no\" All programs tracked!\n");
     }

   const char * run_submission = XALT_DIR "/libexec/xalt_run_submission";


added k_matrix default ctor

added k_matrix default ctor

--- src/algo/depth-to-rgb-calibration/calibration-types.h
+++ src/algo/depth-to-rgb-calibration/calibration-types.h
@@ -179,22 +179,15 @@

     struct k_matrix
     {
-        k_matrix(matrix_3x3 mat)
+        k_matrix() = default;
+        k_matrix(matrix_3x3 const & mat)
             :k_mat(mat)
         {}

-        double get_fx() const {
-            return k_mat.rot[0];
-        }
-        double get_fy() const {
-            return k_mat.rot[4];
-        }
-        double get_ppx() const {
-            return k_mat.rot[2];
-        }
-        double get_ppy() const {
-            return k_mat.rot[5];
-        }
+        double get_fx() const { return k_mat.rot[0]; }
+        double get_fy() const { return k_mat.rot[4]; }
+        double get_ppx() const { return k_mat.rot[2]; }
+        double get_ppy() const { return k_mat.rot[5]; }

         matrix_3x3 k_mat;


[PATCH] pcmcia: fix comment for pcmcia_load_firmware

The comment of "pcmcia_load_firmware" is wrong: the
firmware(*.cis) files reside in /lib/firmware/ _not_
/lib/firmware/cis/ .

Signed-off-by: 67e08e12dd60545d8b29ebd61fd5858dad508676@nifty.com
Signed-off-by: Dominik Brodowski <ba324ca7b1c77fc20bb970d5aff6eea9377918a5@dominikbrodowski.net>

--- drivers/pcmcia/ds.c
+++ drivers/pcmcia/ds.c
@@ -236,11 +236,11 @@
 /**
  * pcmcia_load_firmware - load CIS from userspace if device-provided is broken
  * @dev - the pcmcia device which needs a CIS override
- * @filename - requested filename in /lib/firmware/cis/
+ * @filename - requested filename in /lib/firmware/
  *
  * This uses the in-kernel firmware loading mechanism to use a "fake CIS" if
  * the one provided by the card is broken. The firmware files reside in
- * /lib/firmware/cis/ in userspace.
+ * /lib/firmware/ in userspace.
  */
 static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
 {


actually implement fastest mode (no motion compensation) a bit less
braindead (don't skip mode selection)

git-svn-id: 8dbf393e6e9ab8d4979d29f9a341a98016792aa6@14013 0101bb08-14d6-0310-b084-bc0e0c8e3800

--- lib/enc/encode.c
+++ lib/enc/encode.c
@@ -1101,8 +1101,6 @@

   QIndex = (unsigned char)cpi->pb.FrameQIndex;

-  if(!cpi->MotionCompensation)
-    return 0;

   /* change the quatization matrix to the one at best Q to compute the
      new error score */
@@ -1215,7 +1213,7 @@

         /* If the best error is above the required threshold search
            for a new inter MV */
-        if ( BestError > cpi->MinImprovementForNewMV ) {
+        if ( BestError > cpi->MinImprovementForNewMV && cpi->MotionCompensation) {
           /* Use a mix of heirachical and exhaustive searches for
              quick mode. */
           if ( cpi->pb.info.quick_p ) {
@@ -1264,7 +1262,7 @@
         MBGF_MVError = HUGE_ERROR;
         GFMVect.x = 0; /* Set 0,0 motion vector */
         GFMVect.y = 0;
-        if ( BestError > cpi->MinImprovementForNewMV ) {
+        if ( BestError > cpi->MinImprovementForNewMV && cpi->MotionCompensation) {
           /* Do an MV search in the golden reference frame */
           MBGF_MVError = GetMBMVInterError( cpi, cpi->pb.GoldenFrame,
                                             YFragIndex, PixelsPerLine,
@@ -1297,7 +1295,7 @@
         /* Finally... If the best error is still to high then consider
            the 4MV mode */
         MBInterFOURMVError = HUGE_ERROR;
-        if ( BestError > cpi->FourMVThreshold ) {
+        if ( BestError > cpi->FourMVThreshold && cpi->MotionCompensation) {
           /* Get the 4MV error. */
           MBInterFOURMVError =
             GetFOURMVExhaustiveSearch( cpi, cpi->pb.LastFrameRecon,