./bm_kiss_float -x 40000 -n 1800 improved from cputime=6.010 to cputime=5.940

--- kiss_fft.c
+++ kiss_fft.c
@@ -250,21 +250,25 @@
         const kiss_fft_state * st
         )
 {
-    kiss_fft_cpx * tmpFout=Fout;
-    int m,p,r;
+    kiss_fft_cpx * Fout_beg=Fout;
+    kiss_fft_cpx * Fout_end;
+
+    int m,p;
+
     p=*factors++; /* the radix  */
     m=*factors++; /* stage's fft length/p */
-
-    for (r=0;r<p;++r) {
+    Fout_end = Fout + p*m;
+
+    do{
         if (m==1)
             *Fout = *f;
         else
             kf_work( Fout , f, fstride*p, in_stride, factors,st);
         Fout += m;
         f += fstride*in_stride;
-    }
-
-    Fout=tmpFout;
+    }while(Fout != Fout_end );
+
+    Fout=Fout_beg;

     switch (p) {
         case 2: kf_bfly2(Fout,fstride,st,m); break;


changed from static function that wasn't inlining very well to a macro

'make test' output:
### testing SNR for  1024 point FFTs
#### DOUBLE
snr_t2f = 295.70
snr_f2t = 308.53
#### FLOAT
snr_t2f = 146.91
snr_f2t = 143.58
#### SHORT
snr_t2f = 54.677
snr_f2t = 24.668

#### timing 10000 x 1024 point FFTs
#### DOUBLE
Elapsed:0:11.38 user:9.15 sys:0.24
#### FLOAT
Elapsed:0:04.18 user:3.39 sys:0.14
#### SHORT
Elapsed:0:06.03 user:4.75 sys:0.15

--- kiss_fft.c
+++ kiss_fft.c
@@ -36,10 +36,6 @@
     kiss_fft_cpx * tmpbuf;
     kiss_fft_cpx * scratch;
 }kiss_fft_state;
-
-#define C_ADD(x,a,b) \
-    do{ (x).r = (a).r+(b).r;\
-        (x).i = (a).i+(b).i;}while(0)

 #ifdef FIXED_POINT
     /*  We don't have to worry about overflow from multiplying by twiddle factors since they
@@ -121,7 +117,7 @@
                 twidx += fstride * k;
                 if (twidx>=Norig)
                     twidx-=Norig;
-                t = cmul(scratch[q] , twiddles[twidx] );
+                C_MUL(t,scratch[q] , twiddles[twidx] );
                 Fout[ k ].r += t.r;
                 Fout[ k ].i += t.i;
             }


Opps - commt new maze constants

Opps - commt new maze constants

--- libMaze/mazeconstants.h
+++ libMaze/mazeconstants.h
@@ -67,4 +67,23 @@

 #define VISITED (CHECKED_NORTH + CHECKED_EAST + CHECKED_SOUTH + CHECKED_WEST)

+
+#define EXIT  0
+#define WALL    1
+#define UNKNOWN 2
+
+#define CLOSED_MASK    3
+#define OPEN_MASK      1
+
+typedef union {
+  uint8_t byte;
+  struct  {
+    unsigned  char north: 2 ;
+    unsigned  char east: 2 ;
+    unsigned  char south: 2 ;
+    unsigned  char west: 2 ;
+  } wall;
+} wall_t;      // structure that stores wall information (bit field)
+
+
 #endif //MAZE_MAZECONSTANTS_H


Empty audio chunks in VMD are silent, not skipped

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

--- libavformat/sierravmd.c
+++ libavformat/sierravmd.c
@@ -187,7 +187,7 @@
             get_buffer(pb, chunk, BYTES_PER_FRAME_RECORD);
             type = chunk[0];
             size = AV_RL32(&chunk[2]);
-            if(!size)
+            if(!size && type != 1)
                 continue;
             switch(type) {
             case 1: /* Audio Chunk */


Don't acquire the writer lock in rtld_exit when clearing the shared objects' reference counts.  This function is called by the atexit mechanism at program shutdown.  I don't think the locking is necessary here.  It caused OpenOffice builds to hang more often than not. Credit to Martin Blapp and Matt Dillon for helping to diagnose this problem and for testing the fix.

--- libexec/rtld-elf/rtld.c
+++ libexec/rtld-elf/rtld.c
@@ -1460,11 +1460,9 @@
     Obj_Entry *obj;

     dbg("rtld_exit()");
-    wlock_acquire();
     /* Clear all the reference counts so the fini functions will be called. */
     for (obj = obj_list;  obj != NULL;  obj = obj->next)
 	obj->refcount = 0;
-    wlock_release();
     objlist_call_fini(&list_fini);
     /* No need to remove the items from the list, since we are exiting. */
 }


Reordered backends with regard to feature completeness.

--- libfreerdp/codec/h264.c
+++ libfreerdp/codec/h264.c
@@ -420,29 +420,37 @@
 	ZeroMemory(subSystems, sizeof(subSystems));

 #if defined(_WIN32) && defined(WITH_MEDIA_FOUNDATION)
-	subSystems[i] = &g_Subsystem_MF;
-	i++;
+	{
+		subSystems[i] = &g_Subsystem_MF;
+		i++;
+	}
+#endif
+
+#ifdef WITH_OPENH264
+	{
+		extern H264_CONTEXT_SUBSYSTEM g_Subsystem_OpenH264;
+		subSystems[i] = &g_Subsystem_OpenH264;
+		i++;
+	}
 #endif

 #ifdef WITH_FFMPEG
-	extern H264_CONTEXT_SUBSYSTEM g_Subsystem_libavcodec;
-	subSystems[i] = &g_Subsystem_libavcodec;
-	i++;
-#endif
-
-#ifdef WITH_OPENH264
-	extern H264_CONTEXT_SUBSYSTEM g_Subsystem_OpenH264;
-	subSystems[i] = &g_Subsystem_OpenH264;
-	i++;
+	{
+		extern H264_CONTEXT_SUBSYSTEM g_Subsystem_libavcodec;
+		subSystems[i] = &g_Subsystem_libavcodec;
+		i++;
+	}
 #endif

 #ifdef WITH_X264
-	extern H264_CONTEXT_SUBSYSTEM g_Subsystem_x264;
-	subSystems[i] = &g_Subsystem_x264;
-	i++;
-#endif
-
-	return TRUE;
+	{
+		extern H264_CONTEXT_SUBSYSTEM g_Subsystem_x264;
+		subSystems[i] = &g_Subsystem_x264;
+		i++;
+	}
+#endif
+
+	return i > 0;
 }


Third attempt at fixing this.

Third attempt at fixing this.

1998-10-01  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* libgnome/gnome-config.c (parse_path): Third attempt at fixing this.

--- libgnome/gnome-config.c
+++ libgnome/gnome-config.c
@@ -141,7 +141,7 @@
 	if (*p->path == '='){
 		/* If it is an absolute path name */
 		p->path++;
-		p->file    = strtok (p->path, "=");
+		p->file    = g_strdup (strtok (p->path, "="));
 		p->section = strtok (NULL, "/=");
 		p->key     = strtok (NULL, "=");
 		p->def     = strtok (NULL, "=");
@@ -149,7 +149,7 @@
 		char *end;
 		sep = "/=";

-		p->file    = p->path;
+		p->file    = g_strdup (p->path);
 		p->def     = NULL;
 		p->section = NULL;
 		p->key     = NULL;
@@ -178,16 +178,15 @@
 				break;
 			}
 		}
+		q = p->file;
+
 		if (*p->file == '/')
 			p->file++;

-		q = p->file;
 		if (priv){
-			p->file = g_concat_dir_and_file (gnome_user_private_dir,
-							 q);
+			p->file = g_concat_dir_and_file (gnome_user_private_dir, q);
 		} else {
-			p->file = g_concat_dir_and_file (gnome_user_dir,
-							 q);
+			p->file = g_concat_dir_and_file (gnome_user_dir, q);
 		}
 		g_free (q);
 	}


Allow zero paths for device-mapper strings

There is no reason why we shouldn't allow zero paths in the device
mapper output.

References: 435688

Signed-off-by: Hannes Reinecke <b0d1e9e4a4e27620745ff49be9000da3174a4cc6@suse.de>

--- libmultipath/dmparser.c
+++ libmultipath/dmparser.c
@@ -186,6 +186,7 @@

 	if (num_pg > 0 && !mpp->pg) {
 		mpp->pg = vector_alloc();
+
 		if (!mpp->pg)
 			return 1;
 	}


camera: remove unused unistd.h include

camera: remove unused unistd.h include

--- libnodegl/node_camera.c
+++ libnodegl/node_camera.c
@@ -23,7 +23,6 @@
 #include <stddef.h>
 #include <stdio.h>
 #include <string.h>
-#include <unistd.h>

 #include "gctx.h"
 #include "log.h"


pipeline_gl: only insert memory barriers after glDispatchCompute()

It is up to the previous pipeline executions to insert the relevant
memory barriers (which is already the case for the compute pipelines).

--- libnodegl/pipeline_gl.c
+++ libnodegl/pipeline_gl.c
@@ -731,7 +731,6 @@
     set_buffers(s, gl);
     set_textures(s, gl);

-    ngli_glMemoryBarrier(gl, GL_ALL_BARRIER_BITS);
     ngli_glDispatchCompute(gl, nb_group_x, nb_group_y, nb_group_z);
     ngli_glMemoryBarrier(gl, GL_ALL_BARRIER_BITS);
 }


Avoid TIMER3 conflict with Servo and tone().

--- libraries/Servo/Servo.h
+++ libraries/Servo/Servo.h
@@ -65,9 +65,8 @@
 typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;

 #elif defined(__AVR_ATmega32U4__)
-#define _useTimer3
 #define _useTimer1
-typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
+typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;

 #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
 #define _useTimer3
@@ -124,4 +123,4 @@
    int8_t max;                       // maximum is this value times 4 added to MAX_PULSE_WIDTH
 };

-#endif+#endif


ITS#8323 Fix nested commit

ITS#8323 Fix nested commit

Must remove our spilled pages from parent's dirty list

--- libraries/liblmdb/mdb.c
+++ libraries/liblmdb/mdb.c
@@ -3498,6 +3498,25 @@
 				if (!(pspill[x] & 1))
 					pspill[++y] = pspill[x];
 			pspill[0] = y;
+		}
+
+		/* Remove anything in our spill list from parent's dirty list */
+		if (txn->mt_spill_pgs && txn->mt_spill_pgs[0]) {
+			for (i=1; i<=txn->mt_spill_pgs[0]; i++) {
+				MDB_ID pn = txn->mt_spill_pgs[i];
+				if (pn & 1)
+					continue;	/* deleted spillpg */
+				pn >>= 1;
+				y = mdb_mid2l_search(dst, pn);
+				if (y <= dst[0].mid && dst[y].mid == pn) {
+					free(dst[y].mptr);
+					while (y < dst[0].mid) {
+						dst[y] = dst[y+1];
+						y++;
+					}
+					dst[0].mid--;
+				}
+			}
 		}

 		/* Find len = length of merging our dirty list with parent's */


ITS#8554 kFreeBSD is like BSD

ITS#8554 kFreeBSD is like BSD

Doesn't have POSIX robust mutexes - GNU userland on BSD kernel

--- libraries/liblmdb/mdb.c
+++ libraries/liblmdb/mdb.c
@@ -149,7 +149,7 @@
 #include <resolv.h>	/* defines BYTE_ORDER on HPUX and Solaris */
 #endif

-#if defined(__APPLE__) || defined (BSD)
+#if defined(__APPLE__) || defined (BSD) || defined(__FreeBSD_kernel__)
 # if !(defined(MDB_USE_POSIX_MUTEX) || defined(MDB_USE_POSIX_SEM))
 # define MDB_USE_SYSV_SEM	1
 # endif


Revert "ITS#7570 fix MDB_GET_MULTIPLE and MDB_NEXT_MULTIPLE"

This reverts commit 372b3ddb85bef953fb548fbf2b9ef0cba4e3c8ed.

Original code works as designed.

--- libraries/liblmdb/mdb.c
+++ libraries/liblmdb/mdb.c
@@ -4377,8 +4377,6 @@
 			rc = mdb_cursor_first(&mc->mc_xcursor->mx_cursor, data, NULL);
 			if (rc != MDB_SUCCESS)
 				return rc;
-		} else if (mc->mc_db->md_flags & MDB_DUPSORT) {
-			mc->mc_xcursor->mx_cursor.mc_flags &= ~C_INITIALIZED;
 		}
 	}

@@ -4792,9 +4790,8 @@
 			break;
 		}
 		rc = MDB_SUCCESS;
-		if (!(mc->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED))
-			goto fetch;
-		if (mc->mc_xcursor->mx_cursor.mc_flags & C_EOF)
+		if (!(mc->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED) ||
+			(mc->mc_xcursor->mx_cursor.mc_flags & C_EOF))
 			break;
 		goto fetchm;
 	case MDB_NEXT_MULTIPLE:
@@ -4806,7 +4803,7 @@
 		if (!(mc->mc_flags & C_INITIALIZED))
 			rc = mdb_cursor_first(mc, key, data);
 		else
-			rc = mdb_cursor_next(mc, key, data, MDB_NEXT_NODUP);
+			rc = mdb_cursor_next(mc, key, data, MDB_NEXT_DUP);
 		if (rc == MDB_SUCCESS) {
 			if (mc->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED) {
 				MDB_cursor *mx;
@@ -4817,11 +4814,7 @@
 				data->mv_data = METADATA(mx->mc_pg[mx->mc_top]);
 				mx->mc_ki[mx->mc_top] = NUMKEYS(mx->mc_pg[mx->mc_top])-1;
 			} else {
-				MDB_node *leaf;
-fetch:
-				leaf = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);
-				data->mv_size = NODEDSZ(leaf);
-				data->mv_data = NODEDATA(leaf);
+				rc = MDB_NOTFOUND;
 			}
 		}
 		break;


Add mdb_dbg_pgno(): (sub)pagenum for debug output.

--- libraries/liblmdb/mdb.c
+++ libraries/liblmdb/mdb.c
@@ -1205,6 +1205,15 @@
 }

 #if MDB_DEBUG
+/** Return the page number of \b mp which may be sub-page, for debug output */
+static pgno_t
+mdb_dbg_pgno(MDB_page *mp)
+{
+	pgno_t ret;
+	COPY_PGNO(ret, mp->mp_pgno);
+	return ret;
+}
+
 /** Display a key in hexadecimal and return the address of the result.
  * @param[in] key the key to display
  * @param[in] buf the buffer to write into. Should always be #DKBUF.
@@ -1245,7 +1254,7 @@
 	DKBUF;

 	nkeys = NUMKEYS(mp);
-	fprintf(stderr, "Page %"Z"u numkeys %d\n", mp->mp_pgno, nkeys);
+	fprintf(stderr, "Page %"Z"u numkeys %d\n", mdb_dbg_pgno(mp), nkeys);
 	for (i=0; i<nkeys; i++) {
 		node = NODEPTR(mp, i);
 		key.mv_size = node->mn_ksize;
@@ -4499,15 +4508,9 @@

 	nkeys = NUMKEYS(mp);

-#if MDB_DEBUG
-	{
-	pgno_t pgno;
-	COPY_PGNO(pgno, mp->mp_pgno);
 	DPRINTF(("searching %u keys in %s %spage %"Z"u",
 	    nkeys, IS_LEAF(mp) ? "leaf" : "branch", IS_SUBP(mp) ? "sub-" : "",
-	    pgno));
-	}
-#endif
+	    mdb_dbg_pgno(mp)));

 	low = IS_LEAF(mp) ? 0 : 1;
 	high = nkeys - 1;
@@ -5086,7 +5089,8 @@
 		}
 	}

-	DPRINTF(("cursor_next: top page is %"Z"u in cursor %p", mp->mp_pgno, (void *) mc));
+	DPRINTF(("cursor_next: top page is %"Z"u in cursor %p",
+		mdb_dbg_pgno(mp), (void *) mc));
 	if (mc->mc_flags & C_DEL)
 		goto skip;

@@ -5103,7 +5107,7 @@

 skip:
 	DPRINTF(("==> cursor points to page %"Z"u with %u keys, key index %u",
-	    mp->mp_pgno, NUMKEYS(mp), mc->mc_ki[mc->mc_top]));
+	    mdb_dbg_pgno(mp), NUMKEYS(mp), mc->mc_ki[mc->mc_top]));

 	if (IS_LEAF2(mp)) {
 		key->mv_size = mc->mc_db->md_pad;
@@ -5162,7 +5166,8 @@
 		}
 	}

-	DPRINTF(("cursor_prev: top page is %"Z"u in cursor %p", mp->mp_pgno, (void *) mc));
+	DPRINTF(("cursor_prev: top page is %"Z"u in cursor %p",
+		mdb_dbg_pgno(mp), (void *) mc));

 	if (mc->mc_ki[mc->mc_top] == 0)  {
 		DPUTS("=====> move to prev sibling page");
@@ -5178,7 +5183,7 @@
 	mc->mc_flags &= ~C_EOF;

 	DPRINTF(("==> cursor points to page %"Z"u with %u keys, key index %u",
-	    mp->mp_pgno, NUMKEYS(mp), mc->mc_ki[mc->mc_top]));
+	    mdb_dbg_pgno(mp), NUMKEYS(mp), mc->mc_ki[mc->mc_top]));

 	if (IS_LEAF2(mp)) {
 		key->mv_size = mc->mc_db->md_pad;
@@ -6351,7 +6356,7 @@
 	DPRINTF(("add to %s %spage %"Z"u index %i, data size %"Z"u key size %"Z"u [%s]",
 	    IS_LEAF(mp) ? "leaf" : "branch",
 		IS_SUBP(mp) ? "sub-" : "",
-	    mp->mp_pgno, indx, data ? data->mv_size : 0,
+		mdb_dbg_pgno(mp), indx, data ? data->mv_size : 0,
 		key ? key->mv_size : 0, key ? DKEY(key) : "null"));

 	if (IS_LEAF2(mp)) {
@@ -6449,7 +6454,7 @@

 full:
 	DPRINTF(("not enough room in page %"Z"u, got %u ptrs",
-		mp->mp_pgno, NUMKEYS(mp)));
+		mdb_dbg_pgno(mp), NUMKEYS(mp)));
 	DPRINTF(("upper-lower = %u - %u = %"Z"d", mp->mp_upper,mp->mp_lower,room));
 	DPRINTF(("node size = %"Z"u", node_size));
 	return MDB_PAGE_FULL;
@@ -6469,14 +6474,8 @@
 	MDB_node	*node;
 	char		*base;

-#if MDB_DEBUG
-	{
-	pgno_t pgno;
-	COPY_PGNO(pgno, mp->mp_pgno);
 	DPRINTF(("delete node %u on %s page %"Z"u", indx,
-	    IS_LEAF(mp) ? "leaf" : "branch", pgno));
-	}
-#endif
+	    IS_LEAF(mp) ? "leaf" : "branch", mdb_dbg_pgno(mp)));
 	assert(indx < NUMKEYS(mp));

 	if (IS_LEAF2(mp)) {
@@ -7184,25 +7183,15 @@
 	MDB_cursor	mn;

 	minkeys = 1 + (IS_BRANCH(mc->mc_pg[mc->mc_top]));
-#if MDB_DEBUG
-	{
-	pgno_t pgno;
-	COPY_PGNO(pgno, mc->mc_pg[mc->mc_top]->mp_pgno);
 	DPRINTF(("rebalancing %s page %"Z"u (has %u keys, %.1f%% full)",
 	    IS_LEAF(mc->mc_pg[mc->mc_top]) ? "leaf" : "branch",
-	    pgno, NUMKEYS(mc->mc_pg[mc->mc_top]),
+	    mdb_dbg_pgno(mc->mc_pg[mc->mc_top]), NUMKEYS(mc->mc_pg[mc->mc_top]),
 		(float)PAGEFILL(mc->mc_txn->mt_env, mc->mc_pg[mc->mc_top]) / 10));
-	}
-#endif

 	if (PAGEFILL(mc->mc_txn->mt_env, mc->mc_pg[mc->mc_top]) >= FILL_THRESHOLD &&
 		NUMKEYS(mc->mc_pg[mc->mc_top]) >= minkeys) {
-#if MDB_DEBUG
-		pgno_t pgno;
-		COPY_PGNO(pgno, mc->mc_pg[mc->mc_top]->mp_pgno);
 		DPRINTF(("no need to rebalance page %"Z"u, above fill threshold",
-		    pgno));
-#endif
+		    mdb_dbg_pgno(mc->mc_pg[mc->mc_top])));
 		return MDB_SUCCESS;
 	}


Simplify/cleanup mdb_cursor_init, C_ALLOCD.

No real change.
mdb_cursor_init() checks if it needs mx, so pass it unconditionally.
Set C_ALLOCD for shadow cursors, for clarity. (It was always set as
it should anyway from the origin cursor, which would have C_ALLOCD.)

--- libraries/liblmdb/mdb.c
+++ libraries/liblmdb/mdb.c
@@ -1206,9 +1206,8 @@

 	count = 0;
 	for (i = 0; i<txn->mt_numdbs; i++) {
-		MDB_xcursor mx, *mxp;
-		mxp = (txn->mt_dbs[i].md_flags & MDB_DUPSORT) ? &mx : NULL;
-		mdb_cursor_init(&mc, txn, i, mxp);
+		MDB_xcursor mx;
+		mdb_cursor_init(&mc, txn, i, &mx);
 		if (txn->mt_dbs[i].md_root == P_INVALID)
 			continue;
 		count += txn->mt_dbs[i].md_branch_pages +
@@ -1707,7 +1706,7 @@
 				mc->mc_dbflag = &dst->mt_dbflags[i];
 				mc->mc_snum = m2->mc_snum;
 				mc->mc_top = m2->mc_top;
-				mc->mc_flags = m2->mc_flags | C_SHADOW;
+				mc->mc_flags = m2->mc_flags | (C_SHADOW|C_ALLOCD);
 				for (j=0; j<mc->mc_snum; j++) {
 					mc->mc_pg[j] = m2->mc_pg[j];
 					mc->mc_ki[j] = m2->mc_ki[j];
@@ -4933,8 +4932,7 @@
 	if (mc->mc_dbi > MAIN_DBI && !(*mc->mc_dbflag & DB_DIRTY)) {
 		MDB_cursor mc2;
 		MDB_xcursor mcx;
-		mdb_cursor_init(&mc2, mc->mc_txn, MAIN_DBI,
-			mc->mc_txn->mt_dbs[MAIN_DBI].md_flags & MDB_DUPSORT ? &mcx : NULL);
+		mdb_cursor_init(&mc2, mc->mc_txn, MAIN_DBI, &mcx);
 		rc = mdb_page_search(&mc2, &mc->mc_dbx->md_name, MDB_PS_MODIFY);
 		if (rc)
 			 return rc;
@@ -5838,7 +5836,6 @@
 mdb_cursor_open(MDB_txn *txn, MDB_dbi dbi, MDB_cursor **ret)
 {
 	MDB_cursor	*mc;
-	MDB_xcursor	*mx = NULL;
 	size_t size = sizeof(MDB_cursor);

 	if (txn == NULL || ret == NULL || dbi >= txn->mt_numdbs || !(txn->mt_dbflags[dbi] & DB_VALID))
@@ -5852,10 +5849,7 @@
 		size += sizeof(MDB_xcursor);

 	if ((mc = malloc(size)) != NULL) {
-		if (txn->mt_dbs[dbi].md_flags & MDB_DUPSORT) {
-			mx = (MDB_xcursor *)(mc + 1);
-		}
-		mdb_cursor_init(mc, txn, dbi, mx);
+		mdb_cursor_init(mc, txn, dbi, (MDB_xcursor *)(mc + 1));
 		if (txn->mt_cursors) {
 			mc->mc_next = txn->mt_cursors[dbi];
 			txn->mt_cursors[dbi] = mc;


Unused slabs are getting purged after adding a new slab

If a new slab is allocated, or an empty slab is reused, the list of empty slabs is now purged, if possible. Empty slabs which cannot be immediately purged "decay" and will be collected the next time a new slab is allocated or an empty slab is reused.

If a chunk is allocated and the slab which the chunk came from is fully utilized, the slab is moved to the end of its list. This should avoid searching this slab for free space before all other slabs of the same chunk size have been tested first. Slabs with free space are always placed closer to the head of the list.

--- library/stdlib_malloc.c
+++ library/stdlib_malloc.c
@@ -273,6 +273,19 @@
 						}

 						sn->sn_UseCount++;
+
+						/* Is this slab now fully utilized? Move it to the
+						 * end of the queue so that it will not be checked
+						 * before other slabs of the same size have been
+						 * tested. Those at the front of the queue should
+						 * still have room left.
+						 */
+						if(sn->sn_UseCount == sn->sn_Count && sn != (struct SlabNode *)slab_list->mlh_TailPred)
+						{
+							Remove((struct Node *)sn);
+							AddTail((struct List *)slab_list, (struct Node *)sn);
+						}
+
 						break;
 					}
 				}
@@ -367,6 +380,38 @@

 						AddHead((struct List *)slab_list,(struct Node *)&new_sn);
 					}
+
+					/* Mark unused slabs for purging, and purge those which
+					 * are ready to be purged.
+					 */
+					for(free_node = (struct MinNode *)__slab_data.sd_EmptySlabs.mlh_Head ;
+					    free_node->mln_Succ != NULL ;
+					    free_node = free_node_next)
+					{
+						free_node_next = (struct MinNode *)free_node->mln_Succ;
+
+						/* free_node points to SlabNode.sn_EmptyLink, which
+						 * directly follows the SlabNode.sn_MinNode.
+						 */
+						sn = (struct SlabNode *)&free_node[-1];
+
+						/* Is this empty slab ready to be purged? */
+						if(sn->sn_EmptyDecay == 0)
+						{
+							/* Unlink from list of empty slabs. */
+							Remove((struct Node *)free_node);
+
+							/* Unlink from list of slabs of the same size. */
+							Remove((struct Node *)sn);
+
+							FreeVec(sn);
+						}
+						/* Give it another chance. */
+						else
+						{
+							sn->sn_EmptyDecay--;
+						}
+					}
 				}
 			}
 		}


Fix assertion in non-virtual checks

Fix assertion in non-virtual checks

Summary:
The existing assertion of method list size in non-virtual check doesn't take into account for non concrete top method or methods.
This missing logic I think is related to the issue open source repo:
https://github.com/facebook/redex/issues/192

Reviewed By: justinjhendrick

Differential Revision: D5566770

fbshipit-source-id: ce50d69d88eb37cab6d4e90dea52e999c64a28a1

--- libredex/VirtualScope.h
+++ libredex/VirtualScope.h
@@ -436,11 +436,11 @@
         }
         for (const auto& meth : scope.methods) {
           if (!meth.first->is_concrete()) continue;
-          if (meth.second == FINAL) {
-            always_assert(scope.interfaces.size() == 0);
-            always_assert(scope.methods.size() == 1);
-            non_virtual.push_back(meth.first);
+          if (meth.second != FINAL) {
+            break;
           }
+          always_assert(scope.interfaces.size() == 0);
+          non_virtual.push_back(meth.first);
         }
       }
     }
@@ -465,9 +465,12 @@
       continue;
     }

-    if (scope.interfaces.size() == 0 &&
-        scope.methods.size() == 1) {
-      always_assert(scope.methods[0].second == FINAL);
+    for (const auto& m : scope.methods) {
+      if (!m.first->is_concrete()) continue;
+      if (m.second != FINAL) {
+        break;
+      }
+      always_assert(scope.interfaces.size() == 0);
       return true;
     }
   }


added missing header proto

added missing header proto

--- libs/fudge/format/elf.h
+++ libs/fudge/format/elf.h
@@ -142,4 +142,5 @@

 unsigned int elf_validate(struct elf_header *header);
 unsigned int elf_find_symbol(struct elf_header *header, struct elf_section_header *sectionTable, struct elf_section_header *symbolHeader, struct elf_symbol *symbolTable, char *stringTable, unsigned int count, const char *symbol);
+void elf_relocate_symbol(unsigned int address, unsigned int type, unsigned int addend);
 void elf_relocate_section(struct elf_section_header *sectionTable, struct elf_section_header *relocationHeader, struct elf_section_header *relocationData, struct elf_relocation *relocationTable, struct elf_symbol *symbolTable, unsigned int address);


Remove the deprecated Seed.get/set include path

--- libseed/seed-builtins.c
+++ libseed/seed-builtins.c
@@ -433,58 +433,6 @@
   return JSValueMakeNull(ctx);
 }

-static JSValueRef
-seed_get_include_path (JSContextRef ctx,
-		       JSObjectRef function,
-		       JSObjectRef this_object,
-		       size_t argumentCount,
-		       const JSValueRef arguments[], JSValueRef * exception)
-{
-  JSValueRef ret;
-  if (argumentCount > 0)
-    {
-      gchar *mes =
-	g_strdup_printf ("Seed.get_include_path expected "
-			 "0 arguments, got %Zd",
-			 argumentCount);
-      seed_make_exception (ctx, exception, "ArgumentError", mes);
-      g_free (mes);
-      return (JSValueMakeNull (ctx));
-    }
-
-  gchar *path_string = g_strjoinv (":", eng->search_path);
-  ret = seed_value_from_string (ctx, path_string, exception);
-  g_free (path_string);
-
-  return ret;
-}
-
-static JSValueRef
-seed_set_include_path (JSContextRef ctx,
-		       JSObjectRef function,
-		       JSObjectRef this_object,
-		       size_t argumentCount,
-		       const JSValueRef arguments[], JSValueRef * exception)
-{
-  gchar *new_path;
-  if (argumentCount != 1)
-    {
-      gchar *mes =
-	g_strdup_printf ("Seed.set_include_path expected "
-			 "1 argument, got %Zd",
-			 argumentCount);
-      seed_make_exception (ctx, exception, "ArgumentError", mes);
-      g_free (mes);
-      return JSValueMakeNull (ctx);
-    }
-
-  new_path = seed_value_to_string (ctx, arguments[0], exception);
-  g_strfreev (eng->search_path);	/* free the old path. */
-  eng->search_path = g_strsplit (new_path, ":", -1);
-
-  return JSValueMakeNull (ctx);
-}
-
 void
 seed_init_builtins (SeedEngine * local_eng, gint * argc, gchar *** argv)
 {
@@ -507,10 +455,6 @@
   seed_create_function (local_eng->context, "fork", &seed_fork, obj);
   seed_create_function (local_eng->context, "spawn", &seed_spawn, obj);
   seed_create_function (local_eng->context, "quit", &seed_quit, obj);
-  seed_create_function (local_eng->context, "set_include_path",
-			&seed_set_include_path, obj);
-  seed_create_function (local_eng->context, "get_include_path",
-			&seed_get_include_path, obj);
   seed_create_function (local_eng->context, "breakpoint",
 			&seed_breakpoint, obj);


basic logging interface

basic logging interface

error: pathspec 'libsrc/public/zlx/log.h' did not match any file(s) known to git

--- libsrc/public/zlx/log.h
+++ libsrc/public/zlx/log.h
@@ -0,0 +1,55 @@
+#ifndef _ZLX_OBSTREAM_LOG_H
+#define _ZLX_OBSTREAM_LOG_H
+
+#include "base.h"
+#include "obstream/base.h"
+
+typedef enum zlx_log_level_enum
+{
+    ZLX_LL_NONE,
+    ZLX_LL_FATAL,
+    ZLX_LL_ERROR,
+    ZLX_LL_WARNING,
+    ZLX_LL_INFO,
+    ZLX_LL_DEBUG
+} zlx_log_level_t;
+
+typedef struct zlx_log zlx_log_t;
+struct zlx_log
+{
+    zlx_log_level_t level;
+    zlx_obstream_t * stream;
+};
+
+ZLX_INLINE void zlx_log_init
+(
+    zlx_log_t * ZLX_RESTRICT log,
+    zlx_log_level_t level,
+    zlx_obstream_t * ZLX_RESTRICT stream
+)
+{
+    log->level = level;
+    log->stream = stream;
+}
+
+
+/* zlx_log_data *************************************************************/
+/**
+ *  Logs data.
+ *  @returns 0 for success, 1 for a partial write
+ */
+ZLX_INLINE int zlx_log_data
+(
+    zlx_log_t * ZLX_RESTRICT log,
+    zlx_log_level_t level,
+    uint8_t const * ZLX_RESTRICT data,
+    size_t size
+)
+{
+    if (level > log->level) return 0;
+    return zlx_obstream_write(log->stream, data, size);
+}
+
+
+#endif /* _ZLX_OBSTREAM_LOG_H */
+


read font names sanely

read font names sanely

--- libswfdec/swfdec_font.c
+++ libswfdec/swfdec_font.c
@@ -93,6 +93,7 @@
   return g_array_index (font->glyphs, SwfdecFontEntry, glyph).shape;
 }

+#if 0
 static char *
 convert_from_language (const char *s, SwfdecLanguage language)
 {
@@ -120,6 +121,7 @@
     SWFDEC_ERROR ("given text is not in language %s", langcode);
   return ret;
 }
+#endif

 int
 tag_func_define_font_info (SwfdecSwfDecoder *s, guint version)
@@ -158,7 +160,6 @@
   wide = swfdec_bits_getbit (&s->b);
   if (version > 1)
     language = swfdec_bits_get_u8 (&s->b);
-  font->name = convert_from_language (name, language);
   g_free (name);
   if (font->name) {
     SWFDEC_LOG ("Creating font description for font %d", id);
@@ -308,8 +309,12 @@
   SWFDEC_DEBUG("langcode %d", langcode);

   font_name_len = swfdec_bits_get_u8 (bits);
-  //font_name =
-  bits->ptr += font_name_len;
+  font->name = swfdec_bits_get_string_length (bits, font_name_len);
+  if (font->name == NULL) {
+    SWFDEC_ERROR ("error reading font name");
+  } else {
+    SWFDEC_LOG ("  font name = %s", font->name);
+  }

   n_glyphs = swfdec_bits_get_u16 (bits);
   if (wide_offsets) {
@@ -397,7 +402,11 @@
   SWFDEC_LOG (" language = %u", (guint) language);
   len = swfdec_bits_get_u8 (&s->b);
   font->name = swfdec_bits_get_string_length (&s->b, len);
-  SWFDEC_LOG (" name = %s", font->name);
+  if (font->name == NULL) {
+    SWFDEC_ERROR ("error reading font name");
+  } else {
+    SWFDEC_LOG ("  font name = %s", font->name);
+  }
   n_glyphs = swfdec_bits_get_u16 (&s->b);
   SWFDEC_LOG (" n_glyphs = %u", n_glyphs);


support for ssh port with <get> -file

support for ssh port with <get> -file

--- src/testdefinitionprocessor.c
+++ src/testdefinitionprocessor.c
@@ -451,7 +451,7 @@
 	char *fname;
 	exec_data edata;
 	int command_len;
-	char *remote = opts.target_address;
+	char *p, *remote = opts.target_address;

 	memset (&edata, 0x0, sizeof (exec_data));
 	init_exec_data(&edata);
@@ -473,26 +473,31 @@
 				strlen (opts.username) + 1 +
 				strlen (fname) +
 				strlen (opts.output_folder) +
-				strlen (remote) + 10;
+				strlen (remote) + 30;
 		} else {
 #endif
 			command_len = strlen ("scp ") +
 				strlen (fname) +
 				strlen (opts.output_folder) +
-				strlen (remote) + 10;
+				strlen (remote) + 30;
 #ifdef ENABLE_LIBSSH2
 		}
 #endif

 		command = (xmlChar *)malloc (command_len);
-
+		if (opts.target_port)
+			sprintf (command, "scp -P %u ", opts.target_port);
+		else
+			sprintf (command, "scp ");
+		p = (char *)(command + (strlen (command)));
+
 #ifdef ENABLE_LIBSSH2
 		if (opts.libssh2) {
-			sprintf ((char *)command, "scp %s@%s:\'%s\' %s", opts.username,
-			         remote, fname, opts.output_folder);
+			sprintf (p, "%s@%s:\'%s\' %s", opts.username, remote,
+				 fname, opts.output_folder);
 		} else {
 #endif
-		sprintf ((char *)command, "scp %s:\'%s\' %s", remote, fname,
+		sprintf (p, "%s:\'%s\' %s", remote, fname,
 			 opts.output_folder);
 #ifdef ENABLE_LIBSSH2
 		}


UCT/DC: Fix DCI count config check.

UCT/DC: Fix DCI count config check.

--- src/uct/ib/dc/base/dc_iface.c
+++ src/uct/ib/dc/base/dc_iface.c
@@ -153,8 +153,15 @@
     UCS_CLASS_CALL_SUPER_INIT(uct_rc_iface_t, ops, md, worker, dev_name, rx_headroom,
                               rx_priv_len, &config->super.super);

-    if (config->ndci <= 1) {
-        ucs_error("dc interface must have at least 1 dci");
+    if (config->ndci < 1) {
+        ucs_error("dc interface must have at least 1 dci (requested: %d)",
+                  config->ndci);
+        return UCS_ERR_INVALID_PARAM;
+    }
+
+    if (config->ndci > UCT_DC_IFACE_MAX_DCIS) {
+        ucs_error("dc interface can have at most %d dcis (requested: %d)",
+                  UCT_DC_IFACE_MAX_DCIS, config->ndci);
         return UCS_ERR_INVALID_PARAM;
     }


Remove cruft from previously reverted CL (r4661).

BUG=http://code.google.com/p/nativeclient/issues/detail?id=1589
Review URL: http://codereview.chromium.org/6776029

git-svn-id: 721b910a23eff8a86f00c8fd261a7587cddf18f8@4667 fcba33aa-ac0c-11dd-b9e7-8d5594d729c2

--- src/untrusted/nacl/gc_hooks.c
+++ src/untrusted/nacl/gc_hooks.c
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2011 The Native Client Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include <sys/nacl_syscalls.h>
-#include <sys/types.h>
-#include "native_client/src/untrusted/nacl/gc_hooks.h"
-
-static TYPE_nacl_gc_hook pre_gc_hook = (TYPE_nacl_gc_hook) NULL;
-static TYPE_nacl_gc_hook post_gc_hook = (TYPE_nacl_gc_hook) NULL;
-
-void IRT_pre_irtcall_hook() {
-  if (pre_gc_hook != NULL) {
-    pre_gc_hook();
-  }
-}
-
-void IRT_post_irtcall_hook() {
-  if (post_gc_hook != NULL) {
-    post_gc_hook();
-  }
-}
-
-void nacl_register_gc_hooks(TYPE_nacl_gc_hook prehook,
-                            TYPE_nacl_gc_hook posthook) {
-  if (pre_gc_hook != NULL || post_gc_hook != NULL) {
-    (void)write(2, "nacl_register_gc_hooks: double call\n", 41);
-  }
-  pre_gc_hook = prehook;
-  post_gc_hook = posthook;
-}


MdeModulePkg ScsiDiskDxe: Set block I/O media of SCSI CDROM to read-only

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>

git-svn-id: 3158a46dfd52e07d1fda3e32e1ab2e353a00b20f@19443 6f19259b-4bc3-4df7-8a09-765794883524

--- MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
+++ MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
@@ -256,6 +256,7 @@

   case EFI_SCSI_TYPE_CDROM:
     ScsiDiskDevice->BlkIo.Media->BlockSize = 0x800;
+    ScsiDiskDevice->BlkIo.Media->ReadOnly  = TRUE;
     MustReadCapacity = FALSE;
     break;
   }


MdeModulePkg DxeHttpLib: Fix typos in function descriptions

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>

git-svn-id: 3158a46dfd52e07d1fda3e32e1ab2e353a00b20f@19597 6f19259b-4bc3-4df7-8a09-765794883524

--- MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -134,7 +134,7 @@
 }

 /**
-  This function return the updated state accroding to the input state and next character of
+  This function return the updated state according to the input state and next character of
   the authority.

   @param[in]       Char           Next character.
@@ -299,7 +299,7 @@
 }

 /**
-  This function return the updated state accroding to the input state and next character of a URL.
+  This function return the updated state according to the input state and next character of a URL.

   @param[in]       Char           Next character.
   @param[in]       State          Current value of the parser state machine.
@@ -1056,7 +1056,7 @@
   Parser->State = BodyParserBodyStart;

   //
-  // Determine the message length accroding to RFC 2616.
+  // Determine the message length according to RFC 2616.
   // 1. Check whether the message "MUST NOT" have a message-body.
   //
   Parser->IgnoreBody = HttpIoNoMessageBody (Method, StatusCode);


MdeModulePkg/HiiDatabase: Remove the incorrect calculation of font baseline

When add Font Package, the cell in EFI_HII_FONT_PACKAGE_HDR
contains the measurement of the widest and tallest characters
in the font. The measurement may be not absolutely correct,
so when use this cell information to calculate the baseline may
cause incorrect result. Besides this calculation is not necessary.
So remove it now.

Cc: Liming Gao <6480311aeeb4b006862f6d13ebabddc03f51e507@intel.com>
Cc: Eric Dong <fa9eeec52367040ac98013bc4b2913db170588f8@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <1e8692d8ed8470b17e8ddd7612a0f029768dcb56@intel.com>
Reviewed-by: Eric Dong <fa9eeec52367040ac98013bc4b2913db170588f8@intel.com>
Reviewed-by: Liming Gao <6480311aeeb4b006862f6d13ebabddc03f51e507@intel.com>

--- MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
+++ MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
@@ -704,10 +704,6 @@
       (UINT8 *) FontPackage->FontPkgHdr + 3 * sizeof (UINT32),
       sizeof (EFI_HII_GLYPH_INFO)
       );
-    BaseLine = (UINT16) (LocalCell.Height + LocalCell.OffsetY);
-    if (MinOffsetY > LocalCell.OffsetY) {
-      MinOffsetY = LocalCell.OffsetY;
-    }
   }

   BlockPtr    = FontPackage->GlyphBlock;


fixed compilation errors reported by g++ 4.7.1

--- src/util/interval_skip_list.h
+++ src/util/interval_skip_list.h
@@ -318,7 +318,7 @@
        \brief Return true if the two entries (that satisfy lt(e1, e2)) can be merged.
     */
     bool can_be_merged(entry const & e1, entry const & e2) const {
-        return val_eq(e1.val(), e2.val()) && eq(succ(e1.end_key()), e2.begin_key());
+        return this->val_eq(e1.val(), e2.val()) && this->eq(this->succ(e1.end_key()), e2.begin_key());
     }

     /**
@@ -334,9 +334,9 @@
             entry & next_entry = next_bucket->get(0);
             if (can_be_merged(curr_entry, next_entry)) {
                 curr_entry.set_end_key(next_entry.end_key());
-                del_entry(m, next_bucket, 0); // del_entry invokes dec_ref_eh
+                this->del_entry(m, next_bucket, 0); // del_entry invokes dec_ref_eh
                 if (next_bucket->empty())
-                    del_bucket(m, next_bucket, pred_vect);
+                    this->del_bucket(m, next_bucket, pred_vect);
             }
         }
     }
@@ -355,7 +355,7 @@
             entry & next_entry = bt->get(idx+1);
             if (can_be_merged(curr_entry, next_entry)) {
                 curr_entry.set_end_key(next_entry.end_key());
-                del_entry(m, bt, idx+1); // del_entry invokes dec_ref_eh
+                this->del_entry(m, bt, idx+1); // del_entry invokes dec_ref_eh
             }
         }
     }
@@ -371,7 +371,7 @@
         entry & prev_entry = bt->get(idx-1);
         if (can_be_merged(prev_entry, curr_entry)) {
             prev_entry.set_end_key(curr_entry.end_key());
-            del_entry(m, bt, idx); // del_entry invokes dec_ref_eh
+            this->del_entry(m, bt, idx); // del_entry invokes dec_ref_eh
         }
     }

@@ -439,7 +439,7 @@
             int mid = low + ((high - low) / 2);
             SASSERT(mid < static_cast<int>(bt->size()));
             entry & mid_entry = bt->get(mid);
-            if (gt(k, mid_entry.end_key())) {
+            if (this->gt(k, mid_entry.end_key())) {
                 low = mid + 1;
                 if (low > high) {
                     // mid entry must be deleted since k > mid_entry.end_key().
@@ -461,7 +461,7 @@
                 SASSERT(contains(mid_entry, k));
                 if (lt(k, mid_entry.end_key())) {
                     TRACE("del_entries_upto_bug", tout << "exit 3) mid: " << mid << "\n"; this->display(tout, mid_entry); tout << "\n";);
-                    mid_entry.set_begin_key(succ(k));
+                    mid_entry.set_begin_key(this->succ(k));
                     SASSERT(mid < static_cast<int>(bt->size())); // Reason: loop invariant
                     return del_entries<RECYCLE_ENTRY>(m, bt, s_idx, mid);
                 }
@@ -486,14 +486,14 @@
                 del_last_entries_upto<false>(m, bt, 0, k);
                 return;
             }
-            else if (eq(k, bt_last_key)) {
-                del_bucket(m, bt, pred_vect);
+            else if (this->eq(k, bt_last_key)) {
+                this->del_bucket(m, bt, pred_vect);
                 return;
             }
             else {
-                SASSERT(gt(k, bt_last_key));
+                SASSERT(this->gt(k, bt_last_key));
                 bucket * next = bt->get_next(0);
-                del_bucket(m, bt, pred_vect);
+                this->del_bucket(m, bt, pred_vect);
                 bt = next;
                 // continue deleting...
             }
@@ -524,7 +524,7 @@

         key const & bt_last_key = last_key(bt);
         TRACE("del_entries_upto_bug", tout << "bt_last_key: " << bt_last_key << "\n";);
-        if (lt(k, bt_last_key)) {
+        if (this->lt(k, bt_last_key)) {
             return del_last_entries_upto<INSERT>(m, bt, 0, k);
         }
         else {
@@ -533,10 +533,10 @@
                 this->dec_ref(m, bt);
                 // REMARK: the slot 0 will be reused, but the element there is gone.
                 bt->set_size(1);
-                if (gt(k, bt_last_key)) {
+                if (this->gt(k, bt_last_key)) {
                     bucket * next = bt->get_next(0);
                     if (next != 0) {
-                        update_predecessor_vector(pred_vect, bt, next_pred_vect);
+                        this->update_predecessor_vector(pred_vect, bt, next_pred_vect);
                         del_entries_upto_loop(m, next, k, next_pred_vect);
                     }
                 }
@@ -544,7 +544,7 @@
             }
             else {
                 bucket * next = bt->get_next(0);
-                del_bucket(m, bt, pred_vect); // it will invoke dec_ref_eh for all values in bt.
+                this->del_bucket(m, bt, pred_vect); // it will invoke dec_ref_eh for all values in bt.
                 // pred_vect does not need to be updated since it contains the predecessors of
                 // bt, since bt was deleted they are now the predecessors of its successor.
                 if (next != 0) {
@@ -592,7 +592,7 @@
             return del_last_entries_upto<INSERT>(m, bt, s_idx, k);
         }
         else {
-            if (gt(k, bt_last_key)) {
+            if (this->gt(k, bt_last_key)) {
                 del_entries_upto_loop(m, bt->get_next(0), k, pred_vect);
             }
             if (Traits::ref_count) {
@@ -639,14 +639,14 @@
                 merge_next_if_possible(m, bt, 0, next_pred_vect);
             }
             else {
-                update_predecessor_vector(pred_vect, bt);
+	        this->update_predecessor_vector(pred_vect, bt);
                 merge_next_if_possible(m, bt, 0, pred_vect);
             }
             return;
         }
         // check if can merge with first entry in the bucket.
         entry & fe = bt->first_entry();
-        if (val_eq(fe.val(), v) && eq(fe.begin_key(), succ(e))) {
+        if (this->val_eq(fe.val(), v) && this->eq(fe.begin_key(), this->succ(e))) {
             // can merge
             fe.set_begin_key(b);
             // A new reference to v was not created. So, we must invoke dec_ref_eh since we increased the counter above.
@@ -657,15 +657,15 @@
         if (bt->size() == bt->capacity()) {
             if (bt->capacity() < Traits::max_capacity) {
                 SASSERT(this->first_bucket() == bt && this->first_bucket()->get_next(0) == 0);
-                expand_first_bucket(m);
+                this->expand_first_bucket(m);
                 bt = this->first_bucket();
             }
             else {
                 // there is no space
-                splice(m, bt, pred_vect);
-            }
-        }
-        open_space(bt, 0);
+                this->splice(m, bt, pred_vect);
+            }
+        }
+        this->open_space(bt, 0);
         set_entry(bt, 0, b, e, v); // Reference to v was stored, and inc_ref_eh was invoked above.
         SASSERT(!can_be_merged(bt->get(0), bt->get(1)));
     }
@@ -697,17 +697,17 @@
             // there is no space
             if (bt->capacity() < Traits::max_capacity) {
                 SASSERT(this->first_bucket() == bt && this->first_bucket()->get_next(0) == 0);
-                expand_first_bucket(m);
+                this->expand_first_bucket(m);
                 bt = this->first_bucket();
                 // there is no need to update pred_vect, since the list contains only one bucket.
             }
             else {
-                splice(m, bt, pred_vect);
+                this->splice(m, bt, pred_vect);
                 bucket * new_next = bt->get_next(0);
                 SASSERT(bt->size() == bt->capacity()/2);
                 if (idx == bt->capacity()/2) {
                     entry & bt_last_entry = bt->last_entry();
-                    if (val_eq(bt_last_entry.val(), v) && eq(bt_last_entry.end_key(), pred(b))) {
+                    if (this->val_eq(bt_last_entry.val(), v) && this->eq(bt_last_entry.end_key(), this->pred(b))) {
                         // merged with the last key of bt
                         bt_last_entry.set_end_key(e);
                         // A new reference to v was not created. So, we must invoke dec_ref_eh since we increased the counter above.
@@ -715,7 +715,7 @@
                         return;
                     }
                     entry & new_next_first_entry = new_next->first_entry();
-                    if (val_eq(new_next_first_entry.val(), v) && eq(new_next_first_entry.begin_key(), succ(e))) {
+                    if (this->val_eq(new_next_first_entry.val(), v) && this->eq(new_next_first_entry.begin_key(), this->succ(e))) {
                         // merged with the first key of new_next
                         new_next_first_entry.set_begin_key(b);
                         // A new reference to v was not created. So, we must invoke dec_ref_eh since we increased the counter above.
@@ -731,12 +731,12 @@
                     idx -= bt->capacity()/2;
                     SASSERT(idx > 0);
                     bt   = new_next;
-                    update_predecessor_vector(pred_vect, bt);
+                    this->update_predecessor_vector(pred_vect, bt);
                 }
             }
         }
         SASSERT(idx > 0);
-        open_space(bt, idx);
+        this->open_space(bt, idx);
         set_entry(bt, idx, b, e, v); // Reference to v was stored, and inc_ref_eh was invoked above.
         merge_next_if_possible(m, bt, idx, pred_vect);
         merge_prev_if_possible(m, bt, idx);
@@ -759,7 +759,7 @@
         for (;;) {
             int mid = low + ((high - low) / 2);
             entry & mid_entry = bt->get(mid);
-            if (gt(b, mid_entry.end_key())) {
+            if (this->gt(b, mid_entry.end_key())) {
                 low = mid + 1;
                 if (low > high) {
                     // insert after mid_entry since b > mid_entry.end_key().
@@ -779,8 +779,8 @@
             else {
                 SASSERT(contains(mid_entry, b));
                 TRACE("insert_inside_bug", tout << "insert_inside:\n"; this->display(tout, bt););
-                if (val_eq(mid_entry.val(), v)) {
-                    if (gt(e, mid_entry.end_key())) {
+                if (this->val_eq(mid_entry.val(), v)) {
+                    if (this->gt(e, mid_entry.end_key())) {
                         // No need to create space.
                         // We did not create a new reference to v.
                         mid_entry.set_end_key(e);
@@ -790,8 +790,8 @@
                     }
                 }
                 else {
-                    if (gt(b, mid_entry.begin_key())) {
-                        if (lt(e, mid_entry.end_key())) {
+                    if (this->gt(b, mid_entry.begin_key())) {
+                        if (this->lt(e, mid_entry.end_key())) {
                             // New interval is the middle of existing interval

                             // We must INVOKE add_ref_eh for mid_entry.val() and v.
@@ -802,11 +802,11 @@
                             if (bt->size() >= bt->capacity() - 1) {
                                 if (bt->capacity() < Traits::max_capacity) {
                                     SASSERT(this->first_bucket() == bt && this->first_bucket()->get_next(0) == 0);
-                                    expand_first_bucket(m);
+                                    this->expand_first_bucket(m);
                                     bt = this->first_bucket();
                                 }
                                 else {
-                                    splice(m, bt, pred_vect);
+                                    this->splice(m, bt, pred_vect);
                                     int new_sz = bt->size();
                                     bucket * new_next = bt->get_next(0);
                                     if (mid >= new_sz) {
@@ -816,19 +816,19 @@
                                     }
                                 }
                             }
-                            open_2spaces(bt, mid);
+                            this->open_2spaces(bt, mid);
                             entry & mid1_entry = bt->get(mid);
                             entry & new_entry  = bt->get(mid+1);
                             entry & mid2_entry = bt->get(mid+2);
                             mid2_entry             = mid1_entry;
-                            mid1_entry.set_end_key(pred(b));
+                            mid1_entry.set_end_key(this->pred(b));
                             new_entry.set_begin_key(b);
                             new_entry.set_end_key(e);
                             new_entry.set_val(v);
-                            mid2_entry.set_begin_key(succ(e));
+                            mid2_entry.set_begin_key(this->succ(e));
                         }
                         else {
-                            mid_entry.set_end_key(pred(b));
+                            mid_entry.set_end_key(this->pred(b));
                             insert_at(m, bt, mid+1, b, e, v, pred_vect);
                         }
                     }
@@ -864,7 +864,7 @@
         for (;;) {
             int mid = low + ((high - low) / 2);
             entry & mid_entry = bt->get(mid);
-            if (gt(b, mid_entry.end_key())) {
+            if (this->gt(b, mid_entry.end_key())) {
                 low = mid + 1;
                 if (low > high) {
                     // insert after mid_entry since b > mid_entry.end_key().
@@ -872,7 +872,7 @@
                     return;
                 }
             }
-            else if (lt(b, mid_entry.begin_key())) {
+            else if (this->lt(b, mid_entry.begin_key())) {
                 high = mid - 1;
                 if (low > high) {
                     // insert before mid_entry since b < mid_entry.begin_key().
@@ -883,8 +883,8 @@
             }
             else {
                 SASSERT(contains(mid_entry, b));
-                if (gt(b, mid_entry.begin_key())) {
-                    if (lt(e, mid_entry.end_key())) {
+                if (this->gt(b, mid_entry.begin_key())) {
+                    if (this->lt(e, mid_entry.end_key())) {
                         // The removed interval is inside of an existing interval.

                         // mid_entry will be split in two. So, we must invoke add_ref_eh for mid_entry.val()
@@ -894,12 +894,12 @@
                         if (bt->size() == bt->capacity()) {
                             if (bt->capacity() < Traits::max_capacity) {
                                 SASSERT(this->first_bucket() == bt && this->first_bucket()->get_next(0) == 0);
-                                expand_first_bucket(m);
+                                this->expand_first_bucket(m);
                                 bt = this->first_bucket();
                                 SASSERT(bt->size() < bt->capacity());
                             }
                             else {
-                                splice(m, bt, pred_vect);
+                                this->splice(m, bt, pred_vect);
                                 if (mid >= static_cast<int>(bt->size())) {
                                     // mid_entry moved to new (successor) bucket
                                     mid -= bt->size();
@@ -907,14 +907,14 @@
                                 }
                             }
                         }
-                        open_space(bt, mid);
+                        this->open_space(bt, mid);
                         entry & mid1_entry = bt->get(mid);
                         entry & mid2_entry = bt->get(mid+1);
-                        mid1_entry.set_end_key(pred(b));
-                        mid2_entry.set_begin_key(succ(e));
+                        mid1_entry.set_end_key(this->pred(b));
+                        mid2_entry.set_begin_key(this->succ(e));
                     }
                     else {
-                        mid_entry.set_end_key(pred(b));
+                        mid_entry.set_end_key(this->pred(b));
                         del_entries_upto<false>(m, bt, mid+1, e, pred_vect);
                     }
                 }
@@ -1052,7 +1052,7 @@
             SASSERT(this->first_bucket() == next);
             insert_begin(m, next, b, e, v, pred_vect);
         }
-        else if (next == 0 || gt(first_key(next), b)) {
+        else if (next == 0 || this->gt(first_key(next), b)) {
             insert_inside(m, curr, b, e, v, pred_vect);
         }
         else {
@@ -1065,7 +1065,7 @@

             // check if we can merge with last entry of curr
             entry & curr_last_entry = curr->last_entry();
-            if (val_eq(curr_last_entry.val(), v) && eq(curr_last_entry.end_key(), pred(b))) {
+            if (this->val_eq(curr_last_entry.val(), v) && this->eq(curr_last_entry.end_key(), this->pred(b))) {
                 // No new reference to v was create, we don't need to invok inc_ref_eh
                 curr_last_entry.set_end_key(e);
                 del_entries_upto<false>(m, next, e, pred_vect, 0);
@@ -1202,7 +1202,7 @@
             SASSERT(next != 0);
             remove_begin(m, next, b, e, pred_vect);
         }
-        else if (next == 0 || gt(first_key(next), b)) {
+        else if (next == 0 || this->gt(first_key(next), b)) {
             remove_inside(m, curr, b, e, pred_vect);
         }
         else {


Win32: Add macros for common functions like strdup

For some reason, Microsoft have an aversion to including functions like
strdup, open, read, write, and close that are part of the POSIX
standard, but still keep them present with a _ prefix.

This commit adds #defines for some of these functions so that we can
keep using the existing code without having to add all lots of ugly
underscores everywhere.

--- DocFormats/DFCommon.h
+++ DocFormats/DFCommon.h
@@ -15,9 +15,10 @@
 #ifndef DocFormats_DFCommon_h
 #define DocFormats_DFCommon_h

+#include "DFTypes.h"
+
 #include <assert.h>
 #include <ctype.h>
-#include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <iconv.h>
@@ -30,6 +31,22 @@
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+
+#ifdef WIN32
+#include <io.h>
+#define open _open
+#define creat _creat
+#define read _read
+#define write _write
+#define close _close
+#define snprintf _snprintf
+#define vsnprintf _vsnprintf
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define strdup _strdup
+#else // not WIN32
+#include <dirent.h>
 #include <unistd.h>
+#endif

 #endif


added stub

added stub

--- content/OTRadioLink/utility/OTV0P2BASE_PowerManagement.h
+++ content/OTRadioLink/utility/OTV0P2BASE_PowerManagement.h
@@ -197,8 +197,16 @@
                 }
         };

-#endif // ARDUINO_ARCH_AVR
-
+#else
+    // Stubs for unit testing.
+    template <uint8_t , uint8_t , uint8_t , uint8_t , bool >
+    class RAII_SPIPowerUpSPIIfDisabled final
+    {
+    public:
+        RAII_SPIPowerUpSPIIfDisabled() { }
+        ~RAII_SPIPowerUpSPIIfDisabled() { }
+    };
+#endif

 /************** Serial IO ************************/


ui_sdl: Removed 'char *s' field from struct 'Label'.

--- ui_sdl.c
+++ ui_sdl.c
@@ -29,7 +29,6 @@
   int frames_left;
   Mcrd pos;
   Img img;
-  char *s;
 } Label;

 static List labels = {NULL, NULL, 0};
@@ -531,7 +530,7 @@
 draw_label (Label *l){
   Scrd pos = map2scr(l->pos);
   pos.y -= 4 * (60 - l->frames_left);
-  text(&font, l->s, pos);
+  draw_img(l->img, pos);
 }

 static void
@@ -545,7 +544,6 @@
     if(l->frames_left == 0){
       Node *prev = node->p;
       SDL_FreeSurface(l->img);
-      free(l->s);
       delete_node(&labels, node);
       node = prev;
     }
@@ -693,8 +691,7 @@
   Label *l = calloc(1, sizeof(Label));
   l->frames_left = 60;
   l->pos = pos;
-  l->s = malloc(strlen(str) + 1);
-  strcpy(l->s, str);
+  l->img = create_text(&font, str);
   push_node(&labels, l);
 }


ui_sdl: draw_possible_tiles() -> draw_reachable_tiles().

--- ui_sdl.c
+++ ui_sdl.c
@@ -331,7 +331,7 @@

 static void
-draw_possible_tiles(){
+draw_reachable_tiles(){
   Mcrd m;
   FOR_EACH_MCRD(m){
     Mcrd p = tile(m)->parent;
@@ -427,7 +427,7 @@
   draw_bg(black);
   draw_map();
   if(ui_mode==MODE_SELECT && selunit)
-    draw_possible_tiles();
+    draw_reachable_tiles();
   if(selunit)
     draw_img(img_selected_hex, map2scr(selunit->m));
   draw_img(img_selected_hex, map2scr(selected_tile));


testgtk: Convert size groups example from GtkTable to GtkGrid

--- tests/testgtk.c
+++ tests/testgtk.c
@@ -4217,7 +4217,7 @@
 {
   GtkWidget *content_area;
   GtkWidget *window;
-  GtkWidget *table;
+  GtkWidget *grid;
   GtkWidget *main_button;
   GtkWidget *button;
   GtkWidget *spin_button;
@@ -4243,13 +4243,13 @@

   content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));

-  table = gtk_table_new (2, 2, FALSE);
-  gtk_box_pack_start (GTK_BOX (content_area), table, TRUE, TRUE, 0);
-
-  gtk_table_set_row_spacings (GTK_TABLE (table), 5);
-  gtk_table_set_col_spacings (GTK_TABLE (table), 5);
-  gtk_container_set_border_width (GTK_CONTAINER (table), 5);
-  gtk_widget_set_size_request (table, 250, 250);
+  grid = gtk_grid_new ();
+  gtk_box_pack_start (GTK_BOX (content_area), grid, TRUE, TRUE, 0);
+
+  gtk_grid_set_row_spacing (GTK_GRID (grid), 5);
+  gtk_grid_set_column_spacing (GTK_GRID (grid), 5);
+  gtk_container_set_border_width (GTK_CONTAINER (grid), 5);
+  gtk_widget_set_size_request (grid, 250, 250);

   hgroup1 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
   hgroup2 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
@@ -4257,11 +4257,12 @@
   vgroup2 = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);

   main_button = gtk_button_new_with_label ("X");
-
-  gtk_table_attach (GTK_TABLE (table), main_button,
-		    0, 1,       0, 1,
-		    GTK_EXPAND, GTK_EXPAND,
-		    0,          0);
+  gtk_widget_set_hexpand (main_button, TRUE);
+  gtk_widget_set_vexpand (main_button, TRUE);
+  gtk_widget_set_halign (main_button, GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (main_button, GTK_ALIGN_CENTER);
+  gtk_grid_attach (GTK_GRID (grid), main_button, 0, 0, 1, 1);
+
   gtk_size_group_add_widget (master_size_group, main_button);
   gtk_size_group_add_widget (hgroup1, main_button);
   gtk_size_group_add_widget (vgroup1, main_button);
@@ -4270,26 +4271,32 @@
 			       SIZE_GROUP_INITIAL_SIZE);

   button = gtk_button_new ();
-  gtk_table_attach (GTK_TABLE (table), button,
-		    1, 2,       0, 1,
-		    GTK_EXPAND, GTK_EXPAND,
-		    0,          0);
+  gtk_widget_set_hexpand (button, TRUE);
+  gtk_widget_set_vexpand (button, TRUE);
+  gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+  gtk_grid_attach (GTK_GRID (grid), button, 1, 0, 1, 1);
+
   gtk_size_group_add_widget (vgroup1, button);
   gtk_size_group_add_widget (vgroup2, button);

   button = gtk_button_new ();
-  gtk_table_attach (GTK_TABLE (table), button,
-		    0, 1,       1, 2,
-		    GTK_EXPAND, GTK_EXPAND,
-		    0,          0);
+  gtk_widget_set_hexpand (button, TRUE);
+  gtk_widget_set_vexpand (button, TRUE);
+  gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+  gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 1, 1);
+
   gtk_size_group_add_widget (hgroup1, button);
   gtk_size_group_add_widget (hgroup2, button);

   button = gtk_button_new ();
-  gtk_table_attach (GTK_TABLE (table), button,
-		    1, 2,       1, 2,
-		    GTK_EXPAND, GTK_EXPAND,
-		    0,          0);
+  gtk_widget_set_hexpand (button, TRUE);
+  gtk_widget_set_vexpand (button, TRUE);
+  gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+  gtk_grid_attach (GTK_GRID (grid), button, 1, 1, 1, 1);
+
   gtk_size_group_add_widget (hgroup2, button);
   gtk_size_group_add_widget (vgroup2, button);


check: Use GST_CHECK_MAIN macro

check: Use GST_CHECK_MAIN macro

--- tests/check/gst/gstprotection.c
+++ tests/check/gst/gstprotection.c
@@ -288,19 +288,4 @@
   return s;
 }

-int
-main (int argc, char **argv)
-{
-  int nf;
-
-  Suite *s = protection_suite ();
-  SRunner *sr = srunner_create (s);
-
-  gst_check_init (&argc, &argv);
-
-  srunner_run_all (sr, CK_NORMAL);
-  nf = srunner_ntests_failed (sr);
-  srunner_free (sr);
-
-  return nf;
-}
+GST_CHECK_MAIN (protection);


Update md5.h because it can't get the value from configure.

--- src/interfaces/odbc/md5.h
+++ src/interfaces/odbc/md5.h
@@ -39,11 +39,11 @@
 #endif   /* not C++ */
 #endif   /* __BEOS__ */

-#ifndef __BEOS__				/* this shouldn't be required, but is is! */
+/* #if SIZEOF_UINT8 == 0  Can't get this from configure */
 typedef unsigned char uint8;	/* == 8 bits */
 typedef unsigned short uint16;	/* == 16 bits */
 typedef unsigned int uint32;	/* == 32 bits */
-#endif   /* __BEOS__ */
+/* #endif */

 extern bool EncryptMD5(const char *passwd, const char *salt,
 		   size_t salt_len, char *buf);


wocky-contact: fire notify change when a property is changed

--- wocky/wocky-contact.c
+++ wocky/wocky-contact.c
@@ -316,10 +316,12 @@

   priv = WOCKY_CONTACT_GET_PRIVATE (contact);

-  if (priv->name != NULL)
-    g_free (priv->name);
-
+  if (!wocky_strdiff (priv->name, name))
+    return;
+
+  g_free (priv->name);
   priv->name = g_strdup (name);
+  g_object_notify (G_OBJECT (contact), "name");
 }

 /**
@@ -359,7 +361,11 @@

   priv = WOCKY_CONTACT_GET_PRIVATE (contact);

+  if (priv->subscription == subscription)
+    return;
+
   priv->subscription = subscription;
+  g_object_notify (G_OBJECT (contact), "subscription");
 }

 /**
@@ -438,17 +444,15 @@

   priv = WOCKY_CONTACT_GET_PRIVATE (contact);

+  if (groups_equal ((const gchar * const *) groups,
+        (const gchar * const *) priv->groups))
+    return;
+
   if (priv->groups != NULL)
     g_strfreev (priv->groups);

   priv->groups = g_strdupv (groups);
-}
-
-static gint
-cmp_gchar (gchar *a,
-    gchar *b)
-{
-  return *a - *b;
+  g_object_notify (G_OBJECT (contact), "groups");
 }

 gboolean


unwind: introduce stacktrace_walker

unwind: introduce stacktrace_walker

In current implementation, the stack trace is captured and printed at
the same time, in trace_syscall_exiting.  This approach cannot
provide user expected information when a system call changes the
memory mapping.  In such cases, the stack trace should be captured on
entering syscall and printed on exiting.

As the initial step for splitting capturing from printing, this change
introduces stacktrace_walker utility function.  It can be used both for
capturing in trace_syscall_entering and printing in
trace_syscall_exiting.

Signed-off-by: Masatake YAMATO <bdfff7006d3a5967c7c741d652a74f5445442e11@redhat.com>

--- unwind.c
+++ unwind.c
@@ -48,6 +48,19 @@
 	char* binary_filename;
 };

+/*
+ * Type used in stacktrace walker
+ */
+typedef void (*call_action_fn)(void *data,
+			       char *binary_filename,
+			       char *symbol_name,
+			       unw_word_t function_off_set,
+			       unsigned long true_offset);
+typedef void (*error_action_fn)(void *data,
+				const char *error,
+				unsigned long true_offset);
+
+
 static unw_addr_space_t libunwind_as;

 void
@@ -169,9 +182,14 @@
 	tcp->mmap_cache_size = 0;
 }

-/* use libunwind to unwind the stack and print a backtrace */
-void
-unwind_print_stacktrace(struct tcb* tcp)
+/*
+ * walking the stack
+ */
+static void
+stacktrace_walk(struct tcb *tcp,
+		call_action_fn call_action,
+		error_action_fn error_action,
+		void *data)
 {
 	unw_word_t ip;
 	unw_cursor_t cursor;
@@ -228,23 +246,18 @@
 				true_offset = ip - cur_mmap_cache->start_addr +
 					cur_mmap_cache->mmap_offset;
 				if (symbol_name[0]) {
-					/*
-					 * we want to keep the format used by backtrace_symbols from the glibc
-					 *
-					 * ./a.out() [0x40063d]
-					 * ./a.out() [0x4006bb]
-					 * ./a.out() [0x4006c6]
-					 * /lib64/libc.so.6(__libc_start_main+0xed) [0x7fa2f8a5976d]
-					 * ./a.out() [0x400569]
-					 */
-					tprintf(" > %s(%s+0x%lx) [0x%lx]\n",
-						cur_mmap_cache->binary_filename,
-						symbol_name, function_off_set, true_offset);
+					call_action(data,
+						    cur_mmap_cache->binary_filename,
+						    symbol_name,
+						    function_off_set,
+						    true_offset);
 				} else {
-					tprintf(" > %s() [0x%lx]\n",
-						cur_mmap_cache->binary_filename, true_offset);
+					call_action(data,
+						    cur_mmap_cache->binary_filename,
+						    symbol_name,
+						    0,
+						    true_offset);
 				}
-				line_ended();
 				break; /* stack frame printed */
 			}
 			else if (mid == 0) {
@@ -254,8 +267,8 @@
 				 * unw_get_reg returns IP == 0
 				 */
 				if(ip)
-					tprintf(" > backtracing_error\n");
-				line_ended();
+					error_action(data,
+						     "backtracing_error", 0);
 				goto ret;
 			}
 			else if (ip < cur_mmap_cache->start_addr)
@@ -265,19 +278,86 @@

 		}
 		if (lower > upper) {
-			tprintf(" > backtracing_error [0x%lx]\n", ip);
-			line_ended();
+			error_action(data,
+				     "backtracing_error", ip);
 			goto ret;
 		}

 		ret_val = unw_step(&cursor);

 		if (++stack_depth > 255) {
-			tprintf("> too many stack frames\n");
-			line_ended();
+			error_action(data,
+				     "too many stack frames", 0);
 			break;
 		}
 	} while (ret_val > 0);
 ret:
 	free(symbol_name);
 }
+
+/*
+ * printing an entry in stack
+ */
+/*
+ * we want to keep the format used by backtrace_symbols from the glibc
+ *
+ * ./a.out() [0x40063d]
+ * ./a.out() [0x4006bb]
+ * ./a.out() [0x4006c6]
+ * /lib64/libc.so.6(__libc_start_main+0xed) [0x7fa2f8a5976d]
+ * ./a.out() [0x400569]
+ */
+#define STACK_ENTRY_SYMBOL_FMT			\
+	" > %s(%s+0x%lx) [0x%lx]\n",		\
+	binary_filename,			\
+	symbol_name,				\
+	function_off_set,			\
+	true_offset
+#define STACK_ENTRY_NOSYMBOL_FMT		\
+	" > %s() [0x%lx]\n",			\
+	binary_filename, true_offset
+#define STACK_ENTRY_BUG_FMT			\
+	" > BUG IN %s\n"
+#define STACK_ENTRY_ERROR_WITH_OFFSET_FMT	\
+	" > %s [0x%lx]\n", error, true_offset
+#define STACK_ENTRY_ERROR_FMT			\
+	" > %s\n", error
+
+static void
+print_call_cb(void *dummy,
+	      char *binary_filename,
+	      char *symbol_name,
+	      unw_word_t function_off_set,
+	      unsigned long true_offset)
+{
+	if (symbol_name)
+		tprintf(STACK_ENTRY_SYMBOL_FMT);
+	else if (binary_filename)
+		tprintf(STACK_ENTRY_NOSYMBOL_FMT);
+	else
+		tprintf(STACK_ENTRY_BUG_FMT, __FUNCTION__);
+
+	line_ended();
+}
+
+static void
+print_error_cb(void *dummy,
+	       const char *error,
+	       unsigned long true_offset)
+{
+	if (true_offset)
+		tprintf(STACK_ENTRY_ERROR_WITH_OFFSET_FMT);
+	else
+		tprintf(STACK_ENTRY_ERROR_FMT);
+
+	line_ended();
+}
+
+/*
+ * printing stack
+ */
+void
+unwind_print_stacktrace(struct tcb* tcp)
+{
+	stacktrace_walk(tcp, print_call_cb, print_error_cb, NULL);
+}


Switch off test case timeout because we need more time to test all cases.

--- tests/testhit.c
+++ tests/testhit.c
@@ -845,6 +845,7 @@
 	tcase_add_test( tc_basic, test_change_for_normal );
 	//tcase_add_test( tc_basic, test_has_normal );
 	tcase_add_test( tc_basic, test_discover_normal );
+	tcase_set_timeout( tc_basic, 0 );

 	TCase *tc_border = tcase_create( "Border" );
 	//tcase_add_test( tc_border, test_init_border );


[bouqueau] fix warning

[bouqueau] fix warning

--- src/isomedia/isom_write.c
+++ src/isomedia/isom_write.c
@@ -2417,7 +2417,7 @@

 	//duplicate other boxes
 	i=0;
-	while (box = gf_list_get(orig_file->TopBoxes, i++)) {
+	while ((box = (GF_Box*)gf_list_get(orig_file->TopBoxes, i++))) {
 		switch(box->type) {
 			case GF_ISOM_BOX_TYPE_MOOV:
 			case GF_ISOM_BOX_TYPE_META:


function declare

function declare

--- php_php_server.h
+++ php_php_server.h
@@ -45,6 +45,16 @@
 	char * worker_name;
 ZEND_END_MODULE_GLOBALS(php_server)

+
+/* function declare*/
+PHP_FUNCTION(php_server_create);
+PHP_FUNCTION(php_server_bind);
+PHP_FUNCTION(php_server_send);
+PHP_FUNCTION(php_server_set);
+PHP_FUNCTION(php_server_get);
+PHP_FUNCTION(php_server_run);
+
+
 /* Always refer to the globals in your function as PHP_SERVER_G(variable).
    You are encouraged to rename these macros something shorter, see
    examples in any other php module directory.


small fixes after merge

small fixes after merge

--- usbmon.c
+++ usbmon.c
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -34,11 +35,10 @@

 char hostname[1024];

-static struct option options[] =
-{
+static struct option options[] = {
     {"help", no_argument, 0, 'h'},
-    {"", no_argument, 0, 'n'},
-    {"", no_argument, 0, 'c'},
+    {"nomon", no_argument, 0, 'n'},
+    {"collectd", no_argument, 0, 'c'},
     {0, 0, 0, 0}
 };

@@ -80,7 +80,7 @@
     fflush(stdout);
 }

-void printhelp() {
+void usage() {
     printf("usbmon [-n][-c]\n" \
     "  -n do not monitor events\n" \
     "  -c collectd exec plugin mode\n");
@@ -109,7 +109,7 @@
         {
             case 0:
             case 'h':
-                printhelp();
+                usage();
                 return 0;
             case 'n':
                 no_mon = 1;


enable timeout events

enable timeout events

--- sys/net/ccn_lite/ccn-lite-relay.c
+++ sys/net/ccn_lite/ccn-lite-relay.c
@@ -69,17 +69,20 @@
     long usec;

     rtc_time(&now);
+    DEBUGMSG(1, "ccnl_run_events now: %ld:%ld\n", now.tv_sec, now.tv_usec);

     while (eventqueue) {
         struct ccnl_timer_s *t = eventqueue;
         usec = timevaldelta(&(t->timeout), &now);

         if (usec >= 0) {
+            DEBUGMSG(1, "ccnl_run_events nothing to do: %ld:%ld\n", now.tv_sec, now.tv_usec);
             now.tv_sec = usec / 1000000;
             now.tv_usec = usec % 1000000;
             return &now;
         }

+        DEBUGMSG(1, "ccnl_run_events run event handler: %ld:%ld\n", now.tv_sec, now.tv_usec);
         if (t->fct) {
             (t->fct)(t->node, t->intarg);
         }
@@ -192,6 +195,8 @@
     else {
         DEBUGMSG(1, "sorry, could not open riot trans device\n");
     }
+
+    ccnl_set_timer(1000000, ccnl_ageing, relay, 0);
 }

 #if RIOT_CCNL_POPULATE
@@ -305,9 +310,9 @@
     riot_ccnl_msg_t *m;

     while (!ccnl->halt_flag) {
-        //        struct timeval *timeout = ccnl_run_events();
         DEBUGMSG(1, "waiting for incomming msg\n");
         msg_receive(&in);
+        struct timeval *timeout = ccnl_run_events();

         switch (in.type) {
             case PKT_PENDING:


Split int from float instantiations

Split int from float instantiations

--- src/vistk/image/instantiate.h
+++ src/vistk/image/instantiate.h
@@ -4,10 +4,27 @@
  * Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
  */

+#ifndef VISTK_IMAGE_INSTANTIATE_H
+#define VISTK_IMAGE_INSTANTIATE_H
+
 #include <boost/cstdint.hpp>

+/**
+ * \file image/instantiate.h
+ *
+ * \brief Types for instantiation of image library templates.
+ */
+
+#define VISTK_IMAGE_INSTANTIATE_INT(cls) \
+  template class cls<bool>;              \
+  template class cls<uint8_t>
+
+#define VISTK_IMAGE_INSTANTIATE_FLOAT(cls) \
+  template class cls<float>;               \
+  template class cls<double>
+
 #define VISTK_IMAGE_INSTANTIATE(cls) \
-  template class cls<bool>;          \
-  template class cls<uint8_t>;       \
-  template class cls<float>;         \
-  template class cls<double>
+  VISTK_IMAGE_INSTANTIATE_INT(cls);  \
+  VISTK_IMAGE_INSTANTIATE_FLOAT(cls)
+
+#endif // VISTK_IMAGE_INSTANTIATE_H


Added option for smaller icons

Added option for smaller icons

--- lemonbar.c
+++ lemonbar.c
@@ -327,7 +327,7 @@
         return 0;
     }
     int w = cairo_image_surface_get_width(img);
-    //int h = cairo_image_surface_get_height(img);
+    int h = cairo_image_surface_get_height(img);

     switch (align) {
         case ALIGN_C:
@@ -346,10 +346,12 @@
             break;
     }

+    int posX = bh / 2 - h / 2;
+
     fill_rect(mon->pixmap, gc[GC_CLEAR], x, 0, w, bh);

-    cairo_set_source_surface(mon->cr, img, x, 0);
-    cairo_mask_surface(mon->cr, img, x, 0);
+    cairo_set_source_surface(mon->cr, img, x, posX);
+    cairo_mask_surface(mon->cr, img, x, posX);

     //Render to the xcb surface
     //cairo_surface_flush(mon->surface);


proxy: fix active open connection cleanup

Thanks to DucTM for spotting the issue.

Change-Id: I7985560f224c99cf0fdeea0c8457a3ac6f10b03c
Signed-off-by: Florin Coras <c9715e5cdf0718c2e9b10678757dfb027875eba2@cisco.com>

--- src/vnet/session-apps/proxy.c
+++ src/vnet/session-apps/proxy.c
@@ -105,9 +105,9 @@
       else if (!pool_is_free_index (pm->sessions, p[0]))
 	{
 	  ps = pool_elt_at_index (pm->sessions, p[0]);
-	  if (ps->vpp_server_handle != ~0)
+	  if (ps->vpp_active_open_handle != ~0)
 	    active_open_session = session_get_from_handle
-	      (ps->vpp_server_handle);
+	      (ps->vpp_active_open_handle);
 	  else
 	    active_open_session = 0;
 	}


Unbreak loading of shared objects/modules on OpenBSD.

--- lgi/core.c
+++ lgi/core.c
@@ -487,12 +487,18 @@
 {
   char *name;

-  /* If the version is present, combine it with basename. */
+  /* If the version is present, combine it with basename.
+     Except on OpenBSD, where libraries are versioned like libfoo.so.0.0
+     and we will always load the shared object with the highest version
+     number.
+   */
+#ifndef __OpenBSD__
   if (!lua_isnoneornil (L, 2))
     name = g_strdup_printf (MODULE_NAME_FORMAT_VERSION,
 			    luaL_checkstring (L, 1),
 			    (int) luaL_checkinteger (L, 2));
   else
+#endif
     name = g_strdup_printf (MODULE_NAME_FORMAT_PLAIN,
 			    luaL_checkstring (L, 1));


Allow Ransac functor and template class to be templated and work with point
sets of different type.

Ransac can also fit samples of different types (i.e. 3-D points to 2-D points)
as long as the Fitting and Error functors convert them accordingly and the
templating allows for different point types; which it does now.

--- src/vw/InterestPoint/RANSAC.h
+++ src/vw/InterestPoint/RANSAC.h
@@ -99,10 +99,10 @@
     double m_inlier_threshold;

     // Returns the number of inliers for a given threshold.
-    template <class ContainerT>
+    template <class ContainerT1, class ContainerT2>
     unsigned num_inliers(typename FittingFuncT::result_type const& H,
-                         std::vector<ContainerT> const& p1,
-                         std::vector<ContainerT> const& p2) const {
+                         std::vector<ContainerT1> const& p1,
+                         std::vector<ContainerT2> const& p2) const {
       unsigned result = 0;
       for (unsigned i=0; i<p1.size(); i++) {
         if (m_error_func(H,p1[i],p2[i]) < m_inlier_threshold)
@@ -132,10 +132,10 @@
   public:

     // Returns the list of inlier indices.
-    template <class ContainerT>
+    template <class ContainerT1, class ContainerT2>
     void inliers(typename FittingFuncT::result_type const& H,
-                 std::vector<ContainerT> const& p1,std::vector<ContainerT> const& p2,
-                 std::vector<ContainerT> &inliers1, std::vector<ContainerT> &inliers2) const {
+                 std::vector<ContainerT1> const& p1, std::vector<ContainerT2> const& p2,
+                 std::vector<ContainerT1> &inliers1, std::vector<ContainerT2> &inliers2) const {

       inliers1.clear();
       inliers2.clear();
@@ -149,9 +149,9 @@
     }

     // Returns the list of inlier indices.
-    template <class ContainerT>
+    template <class ContainerT1, class ContainerT2>
     std::vector<int> inlier_indices(typename FittingFuncT::result_type const& H,
-                                     std::vector<ContainerT> const& p1,std::vector<ContainerT> const& p2) const {
+                                     std::vector<ContainerT1> const& p1,std::vector<ContainerT2> const& p2) const {
       std::vector<int> result;
       for (unsigned int i=0; i<p1.size(); i++)
         if (m_error_func(H,p1[i],p2[i]) < m_inlier_threshold)
@@ -162,9 +162,9 @@
     RandomSampleConsensus(FittingFuncT const& fitting_func, ErrorFuncT const& error_func, double inlier_threshold)
       : m_fitting_func(fitting_func), m_error_func(error_func), m_inlier_threshold(inlier_threshold) {}

-    template <class ContainerT>
-    typename FittingFuncT::result_type operator()(std::vector<ContainerT> const& p1,
-                                                  std::vector<ContainerT> const& p2,
+    template <class ContainerT1, class ContainerT2>
+    typename FittingFuncT::result_type operator()(std::vector<ContainerT1> const& p1,
+                                                  std::vector<ContainerT2> const& p2,
                                                   int ransac_iterations = 0) {
       // check consistency
       VW_ASSERT( p1.size() == p2.size(),
@@ -194,7 +194,8 @@
         ransac_iterations = p1.size() * 2;

       int n = m_fitting_func.min_elements_needed_for_fit(p1[0]);
-      std::vector<ContainerT> try1(n), try2(n);
+      std::vector<ContainerT1> try1(n);
+      std::vector<ContainerT2> try2(n);
       int random_indices[n];
       for (int iteration=0; iteration < ransac_iterations; ++iteration) {
         // Get four points at random, taking care not
@@ -246,9 +247,9 @@
   };

   // Free function
-  template <class ContainerT, class FittingFuncT, class ErrorFuncT>
-  typename FittingFuncT::result_type ransac(std::vector<ContainerT> const& p1,
-                                            std::vector<ContainerT> const& p2,
+  template <class ContainerT1, class ContainerT2, class FittingFuncT, class ErrorFuncT>
+  typename FittingFuncT::result_type ransac(std::vector<ContainerT1> const& p1,
+                                            std::vector<ContainerT2> const& p2,
                                             FittingFuncT const& fitting_func,
                                             ErrorFuncT const& error_func,
                                             double inlier_threshold = 50) {


open_esplibs libnet80211: source code for sdk_cnx_node_search. (#280)

Also code for sdk_cnx_sta_leave, although disabled due to accessing static date, but it shows a reference to the netif->flags and the NETIF_FLAG_DHCP flag removed in lwip v2.

--- open_esplibs/libnet80211/wl_cnx.c
+++ open_esplibs/libnet80211/wl_cnx.c
@@ -7,5 +7,100 @@
 #if OPEN_LIBNET80211_WL_CNX
 // The contents of this file are only built if OPEN_LIBNET80211_WL_CNX is set to true

+#include "espressif/esp_misc.h"
+#include "esplibs/libnet80211.h"
+#include <string.h>
+#include "lwip/dhcp.h"
+
+ETSTimer sdk_sta_con_timer;
+void *sdk_g_cnx_probe_rc_list_cb;
+
+#if 0
+
+// Most of the code in this file assesses static data so it will be all or none.
+static uint32_t Ldata001;
+static uint8_t Ldata003;
+static uint8_t Ldata004;
+static uint32_t Ldata006;
+static void *Ldate007;
+
+// Use of the netif->flags and the NETIF_FLAG_DHCP flag removed in lwip v2.
+void sdk_cnx_sta_leave(struct sdk_g_ic_netif_info *netif_info, void *arg1) {
+    struct netif *netif = netif_info->netif;
+
+    uint32_t phy_type = sdk_ieee80211_phy_type_get();
+    uint16_t v1 = *(uint16_t *)(arg1 + 0x1a) & 0xfff;
+    sdk_ic_set_sta(0, 0, arg1, 0, v1, phy_type, 0, 0);
+
+    netif_set_down(netif);
+
+    // The NETIF_FLAG_DHCP flags is removed in lwip v2?
+    if (netif->flags & 0x8) {
+        dhcp_release(netif);
+        dhcp_stop(netif);
+    }
+
+    uint32_t v2 = *(uint8_t *)(arg1 + 0xe8);
+    free(sdk_g_ic.v._unknown190[v2]);
+    sdk_g_ic.v._unknown190[v2] = NULL;
+
+    if (sdk_g_ic.v._unknown190[0]) {
+        free(sdk_g_ic.v._unknown190[0]);
+        sdk_g_ic.v._unknown190[0] = NULL;
+    }
+
+    if (sdk_g_ic.v._unknown190[1]) {
+        free(sdk_g_ic.v._unknown190[1]);
+        sdk_g_ic.v._unknown190[1] = NULL;
+    }
+
+    sdk_scan_cancel();
+
+    sdk_wDev_SetRxPolicy(0, 0, 0);
+
+    Ldata001 = 2;
+
+    uint8_t v3 = *(uint8_t *)(arg1 + 0x6);
+    if (v3 & 2) {
+        *(uint8_t *)(arg1 + 0x6) = v3 & 0xfd;
+        sdk_cnx_rc_update_state_metric(arg1, -7, 1);
+        Ldate007 = arg1;
+    }
+
+    sdk_cnx_remove_rc(arg1);
+
+    Ldata006 = 0;
+    *(uint32_t *)(arg1 + 0x8) &= 0xfffffffe;
+    netif_info->_unknown88 = NULL;
+
+    return;
+}
+#endif
+
+void IRAM *sdk_cnx_node_search(uint8_t mac[6])
+{
+    int end = sdk_g_ic.s._unknown310 + 2;
+
+    // Note this defensive test seems dead code, the value is loaded
+    // as a uint8_t value so adding 2 ensures this test never passes.
+    if (end < 1)
+        return NULL;
+
+    struct sdk_netif_conninfo **conninfo = sdk_g_ic.v.softap_netif_info->conninfo;
+
+    int i = 0;
+    do {
+        struct sdk_netif_conninfo *info = conninfo[i];
+
+        if (info) {
+            if (memcmp(mac, info->mac_addr, 6) == 0) {
+                return info;
+            }
+        }
+        i++;
+    } while (i < end);
+
+    return NULL;
+}

 #endif /* OPEN_LIBNET80211_WL_CNX */


ceph: remove duplicate declaration of ceph_setattr

Signed-off-by: Peter Rosin <3a0ad89228e0bf11d9bd43fb0f453cf9d7ca9376@lysator.liu.se>
Signed-off-by: Sage Weil <6dd34506bbd5e58221bbb3e4732d97c91f02277b@inktank.com>

--- fs/ceph/super.h
+++ fs/ceph/super.h
@@ -717,7 +717,6 @@

 extern int ceph_do_getattr(struct inode *inode, int mask);
 extern int ceph_permission(struct inode *inode, int mask);
-extern int ceph_setattr(struct dentry *dentry, struct iattr *attr);
 extern int ceph_setattr(struct dentry *dentry, struct iattr *attr);
 extern int ceph_getattr(struct vfsmount *mnt, struct dentry *dentry,
 			struct kstat *stat);


fs/ext2/super.c: Drop memory allocation cast

Drop cast on the result of kmem_cache_alloc.

The semantic patch that makes this change is as follows:

// <smpl>
@@
type T;
@@

- (T *)
  (\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
   kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...))
// </smpl>

Signed-off-by: Himangi Saraogi <23256c5b125c18bd580b7fa252de87dcf0c3a427@gmail.com>
Acked-by: Julia Lawall <018ee4f95fc49739477deedb13d2cd210889e607@lip6.fr>
Signed-off-by: Jan Kara <596727c8a0ea4db3ba2ceceedccbacd3d7b371b8@suse.cz>

--- fs/ext2/super.c
+++ fs/ext2/super.c
@@ -161,7 +161,7 @@
 static struct inode *ext2_alloc_inode(struct super_block *sb)
 {
 	struct ext2_inode_info *ei;
-	ei = (struct ext2_inode_info *)kmem_cache_alloc(ext2_inode_cachep, GFP_KERNEL);
+	ei = kmem_cache_alloc(ext2_inode_cachep, GFP_KERNEL);
 	if (!ei)
 		return NULL;
 	ei->i_block_alloc_info = NULL;


channel-contacts: hash table may contain NULL contact

This is the case when joining a room containing members having an unknown
owner.

https://bugs.freedesktop.org/show_bug.cgi?id=42670

--- telepathy-glib/channel-contacts.c
+++ telepathy-glib/channel-contacts.c
@@ -1093,7 +1093,12 @@

   g_hash_table_iter_init (&iter, table);
   while (g_hash_table_iter_next (&iter, NULL, &value))
-    g_ptr_array_add (contacts, value);
+    {
+      if (value == NULL)
+        continue;
+
+      g_ptr_array_add (contacts, value);
+    }
 }

 void


ext4: remove __ext4_journalled_writepage() from mpage_da_submit_io()

We don't support delayed allocation in data=journal mode. So checking for it in
mpage_da_submit_io() doesn't make really sence. If we ever decide to extend
delayed allocation support to data=journal mode, adding
__ext4_journalled_writepage() call will be the least of problems we have to
solve. Most likely we'd have to implement separate writepages call anyways
because we don't have transaction credits for writing more than a single page
so mapping of page buffers would have to be done differently.

Signed-off-by: Jan Kara <596727c8a0ea4db3ba2ceceedccbacd3d7b371b8@suse.cz>
Signed-off-by: "Theodore Ts'o" <4ed386e0495d3e109932df055831d9ec2f824927@mit.edu>

--- fs/ext4/inode.c
+++ fs/ext4/inode.c
@@ -1354,7 +1354,6 @@
 	loff_t size = i_size_read(inode);
 	unsigned int len, block_start;
 	struct buffer_head *bh, *page_bufs = NULL;
-	int journal_data = ext4_should_journal_data(inode);
 	sector_t pblock = 0, cur_logical = 0;
 	struct ext4_io_submit io_submit;

@@ -1453,16 +1452,8 @@
 				block_commit_write(page, 0, len);

 			clear_page_dirty_for_io(page);
-			/*
-			 * Delalloc doesn't support data journalling,
-			 * but eventually maybe we'll lift this
-			 * restriction.
-			 */
-			if (unlikely(journal_data && PageChecked(page)))
-				err = __ext4_journalled_writepage(page, len);
-			else
-				err = ext4_bio_write_page(&io_submit, page,
-							  len, mpd->wbc);
+			err = ext4_bio_write_page(&io_submit, page, len,
+						  mpd->wbc);
 			if (!err)
 				mpd->pages_written++;
 			/*


nfsd: clean up comments over nfs4_file definition

They're a bit outdated wrt to some recent changes.

Signed-off-by: Jeff Layton <4376fbf8623cd7b7c0232225289bb91cedc0a27f@primarydata.com>
Reviewed-by: Christoph Hellwig <923f7720577207a44b32e59bbfbea59d27f1ae8e@lst.de>
Signed-off-by: J. Bruce Fields <51738506c1b2ccb0761f23bdc612c93babf738ea@redhat.com>

--- fs/nfsd/state.h
+++ fs/nfsd/state.h
@@ -463,15 +463,19 @@
 /*
  * nfs4_file: a file opened by some number of (open) nfs4_stateowners.
  *
- * These objects are global. nfsd only keeps one instance of a nfs4_file per
- * inode (though it may keep multiple file descriptors open per inode). These
- * are tracked in the file_hashtbl which is protected by the state_lock
- * spinlock.
+ * These objects are global. nfsd keeps one instance of a nfs4_file per
+ * filehandle (though it may keep multiple file descriptors for each). Each
+ * inode can have multiple filehandles associated with it, so there is
+ * (potentially) a many to one relationship between this struct and struct
+ * inode.
+ *
+ * These are hashed by filehandle in the file_hashtbl, which is protected by
+ * the global state_lock spinlock.
  */
 struct nfs4_file {
 	atomic_t		fi_ref;
 	spinlock_t		fi_lock;
-	struct hlist_node       fi_hash;    /* hash by "struct inode *" */
+	struct hlist_node       fi_hash;	/* hash on fi_fhandle */
 	struct list_head        fi_stateids;
 	struct list_head	fi_delegations;
 	/* One each for O_RDONLY, O_WRONLY, O_RDWR: */


fs/ufs/balloc.c: remove err parameter in ufs_add_fragments

err is used in ufs_new_fragments (ufs_add_fragments only callsite)
not in ufs_add_fragments.

Signed-off-by: Fabian Frederick <3efd2a027b14fd890cd23a9ef6d1134b4e5ad850@skynet.be>
Cc: Evgeniy Dushistov <33ef474d644ae25e5bbba24fb01189cc6a985106@mail.ru>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- fs/ufs/balloc.c
+++ fs/ufs/balloc.c
@@ -24,7 +24,7 @@

 #define INVBLOCK ((u64)-1L)

-static u64 ufs_add_fragments(struct inode *, u64, unsigned, unsigned, int *);
+static u64 ufs_add_fragments(struct inode *, u64, unsigned, unsigned);
 static u64 ufs_alloc_fragments(struct inode *, unsigned, u64, unsigned, int *);
 static u64 ufs_alloccg_block(struct inode *, struct ufs_cg_private_info *, u64, int *);
 static u64 ufs_bitmap_search (struct super_block *, struct ufs_cg_private_info *, u64, unsigned);
@@ -432,7 +432,7 @@
 	/*
 	 * resize block
 	 */
-	result = ufs_add_fragments (inode, tmp, oldcount, newcount, err);
+	result = ufs_add_fragments(inode, tmp, oldcount, newcount);
 	if (result) {
 		*err = 0;
 		UFS_I(inode)->i_lastfrag = max(UFS_I(inode)->i_lastfrag,
@@ -491,7 +491,7 @@
 }

 static u64 ufs_add_fragments(struct inode *inode, u64 fragment,
-			     unsigned oldcount, unsigned newcount, int *err)
+			     unsigned oldcount, unsigned newcount)
 {
 	struct super_block * sb;
 	struct ufs_sb_private_info * uspi;


tests/gnrc_ipv6_ext_frag: add test for nth frag with full rbuf first

Adds a test case for when the following conditions cause a crash:

- a subsequent fragment is received before the first
- the reassembly buffer is currently filled up when another fragment of
  a different datagram arrives and thus needs to be cached out to make
  room for the new reassembly

--- tests/gnrc_ipv6_ext_frag/main.c
+++ tests/gnrc_ipv6_ext_frag/main.c
@@ -402,6 +402,53 @@
     gnrc_pktbuf_is_empty();
 }

+static void test_ipv6_ext_frag_reass_out_of_order_rbuf_full(void)
+{
+    gnrc_pktsnip_t *ipv6_snip = gnrc_ipv6_hdr_build(NULL, &_src, &_dst);
+    gnrc_pktsnip_t *pkt = gnrc_pktbuf_add(ipv6_snip, _test_frag3,
+                                          sizeof(_test_frag3),
+                                          GNRC_NETTYPE_UNDEF);
+    ipv6_hdr_t *ipv6 = ipv6_snip->data;
+    ipv6_ext_frag_t *frag = pkt->data;
+    gnrc_ipv6_ext_frag_rbuf_t *rbuf;
+    gnrc_ipv6_ext_frag_limits_t *ptr;
+    static const uint32_t foreign_id = TEST_ID + 44U;
+
+
+    TEST_ASSERT_EQUAL_INT(1, GNRC_IPV6_EXT_FRAG_RBUF_SIZE);
+    /* prepare fragment from a from a foreign datagram */
+    ipv6->nh = PROTNUM_IPV6_EXT_FRAG;
+    ipv6->hl = TEST_HL;
+    ipv6->len = byteorder_htons(pkt->size);
+    frag->nh = PROTNUM_UDP;
+    frag->resv = 0U;
+    ipv6_ext_frag_set_offset(frag, TEST_FRAG3_OFFSET);
+    frag->id = byteorder_htonl(foreign_id);
+
+    /* receive a fragment from a foreign datagram first */
+    TEST_ASSERT_NULL(gnrc_ipv6_ext_frag_reass(pkt));
+    TEST_ASSERT_NOT_NULL((rbuf = gnrc_ipv6_ext_frag_rbuf_get(ipv6,
+                                                             foreign_id)));
+    TEST_ASSERT_NOT_NULL(rbuf->pkt);
+    TEST_ASSERT_EQUAL_INT(sizeof(_exp_payload), rbuf->pkt->size);
+    TEST_ASSERT_EQUAL_INT(foreign_id, rbuf->id);
+    TEST_ASSERT(rbuf->last);
+    ptr = (gnrc_ipv6_ext_frag_limits_t *)rbuf->limits.next;
+    TEST_ASSERT_NOT_NULL(ptr);
+    ptr = ptr->next;
+    TEST_ASSERT_NOT_NULL(ptr);
+    TEST_ASSERT_EQUAL_INT(TEST_FRAG3_OFFSET / 8, ptr->start);
+    TEST_ASSERT_EQUAL_INT(sizeof(_exp_payload) / 8, ptr->end);
+    TEST_ASSERT(((clist_node_t *)ptr) == rbuf->limits.next);
+    TEST_ASSERT(memcmp(&_exp_payload[TEST_FRAG3_OFFSET],
+                       (uint8_t *)rbuf->pkt->data + TEST_FRAG3_OFFSET,
+                       rbuf->pkt->size - TEST_FRAG3_OFFSET) == 0);
+
+    /* redo test_ipv6_ext_frag_reass_one_frag but now rbuf is full and oldest
+     * entry should be cycled out */
+    test_ipv6_ext_frag_reass_out_of_order();
+}
+
 static void test_ipv6_ext_frag_reass_one_frag(void)
 {
     gnrc_pktsnip_t *ipv6_snip = gnrc_ipv6_hdr_build(NULL, &_src, &_dst);
@@ -445,6 +492,7 @@
         new_TestFixture(test_ipv6_ext_frag_rbuf_gc),
         new_TestFixture(test_ipv6_ext_frag_reass_in_order),
         new_TestFixture(test_ipv6_ext_frag_reass_out_of_order),
+        new_TestFixture(test_ipv6_ext_frag_reass_out_of_order_rbuf_full),
         new_TestFixture(test_ipv6_ext_frag_reass_one_frag),
     };


Make predictor filter flush partially processed scanlines when encountering EOF in input.

--- fitz/filt_predict.c
+++ fitz/filt_predict.c
@@ -119,13 +119,13 @@
 }

 static inline void
-fz_predictnone(fz_predict *p, unsigned char *in, unsigned char *out)
-{
-	memcpy(out, in, p->stride);
+fz_predictnone(fz_predict *p, unsigned char *in, int len, unsigned char *out)
+{
+	memcpy(out, in, len);
 }

 static void
-fz_predicttiff(fz_predict *p, unsigned char *in, unsigned char *out)
+fz_predicttiff(fz_predict *p, unsigned char *in, int len, unsigned char *out)
 {
 	int left[MAXC];
 	int i, k;
@@ -147,7 +147,7 @@
 }

 static void
-fz_predictpng(fz_predict *p, unsigned char *in, unsigned char *out, int predictor)
+fz_predictpng(fz_predict *p, unsigned char *in, int len, unsigned char *out, int predictor)
 {
 	int bpp = p->bpp;
 	int i;
@@ -156,14 +156,14 @@
 	switch (predictor)
 	{
 	case 0:
-		memcpy(out, in, p->stride);
+		memcpy(out, in, len);
 		break;
 	case 1:
 		for (i = bpp; i > 0; i--)
 		{
 			*out++ = *in++;
 		}
-		for (i = p->stride - bpp; i > 0; i--)
+		for (i = len - bpp; i > 0; i--)
 		{
 			*out = *in++ + out[-bpp];
 			out++;
@@ -174,7 +174,7 @@
 		{
 			*out++ = *in++ + *ref++;
 		}
-		for (i = p->stride - bpp; i > 0; i--)
+		for (i = len - bpp; i > 0; i--)
 		{
 			*out++ = *in++ + *ref++;
 		}
@@ -184,7 +184,7 @@
 		{
 			*out++ = *in++ + (*ref++) / 2;
 		}
-		for (i = p->stride - bpp; i > 0; i--)
+		for (i = len - bpp; i > 0; i--)
 		{
 			*out = *in++ + (out[-bpp] + *ref++)/2;
 			out++;
@@ -195,7 +195,7 @@
 		{
 			*out++ = *in++ + paeth(0, *ref++, 0);
 		}
-		for (i = p->stride - bpp; i > 0; i --)
+		for (i = len - bpp; i > 0; i --)
 		{
 			*out = *in++ + paeth(out[-bpp], *ref, ref[-bpp]);
 			ref++;
@@ -209,54 +209,59 @@
 fz_processpredict(fz_filter *filter, fz_buffer *in, fz_buffer *out)
 {
 	fz_predict *dec = (fz_predict*)filter;
+	int remaining, toconsume, toproduce;
 	int ispng = dec->predictor >= 10;
-	int predictor;

 	dec->ref = dec->refbuf;
 	while (1)
 	{
-		if (in->rp + dec->stride + ispng > in->wp)
-		{
-			if (in->eof)
-				return fz_iodone;
-			if (dec->refbuf != dec->ref)
-			{
-				memcpy(dec->refbuf, dec->ref, dec->stride);
-			}
+		remaining = in->wp - in->rp;
+		toconsume = MIN(remaining, dec->stride + ispng);
+		toproduce = MIN(remaining - ispng, dec->stride);
+
+		if (remaining < dec->stride + ispng && !in->eof)
+		{
 			return fz_ioneedin;
 		}

-		if (out->wp + dec->stride > out->ep)
-		{
-			if (dec->refbuf != dec->ref)
-			{
-				memcpy(dec->refbuf, dec->ref, dec->stride);
-			}
+		if (out->wp + toproduce > out->ep)
+		{
 			return fz_ioneedout;
 		}

-		if (dec->predictor == 1)
-		{
-			fz_predictnone(dec, in->rp, out->wp);
-		}
-		else if (dec->predictor == 2)
-		{
-			if (dec->bpc != 8)
-				memset(out->wp, 0, dec->stride);
-			fz_predicttiff(dec, in->rp, out->wp);
-		}
-		else
-		{
-			predictor = *in->rp++;
-			fz_predictpng(dec, in->rp, out->wp, predictor);
-		}
-
-		if (dec->refbuf)
-		{
-			dec->ref = out->wp;
-		}
-
-		in->rp += dec->stride;
-		out->wp += dec->stride;
-	}
-}
+		if (toconsume > 0)
+		{
+			if (dec->predictor == 1)
+			{
+				fz_predictnone(dec, in->rp, toconsume, out->wp);
+			}
+			else if (dec->predictor == 2)
+			{
+				if (dec->bpc != 8)
+					memset(out->wp, 0, toconsume);
+				fz_predicttiff(dec, in->rp, toconsume, out->wp);
+			}
+			else
+			{
+				int predictor = *in->rp++;
+				toconsume -= ispng;
+				fz_predictpng(dec, in->rp, toconsume, out->wp, predictor);
+			}
+
+			if (dec->refbuf)
+			{
+				memcpy(dec->refbuf, out->wp, toproduce);
+				dec->ref = dec->refbuf;
+			}
+
+			in->rp += toconsume;
+			out->wp += toproduce;
+		}
+
+		if (in->eof && (in->wp - in->rp <= 0))
+		{
+			return fz_iodone;
+		}
+
+	}
+}


Fixed getDefaultDisplayData() return values

--- src/xwcXSrvUtil/xwcXSrvUtil.c
+++ src/xwcXSrvUtil/xwcXSrvUtil.c
@@ -104,7 +104,7 @@
     {
         logCtrl ("\t\tError getting default display data: NULL pointer to "
                 "program context received", LOG_LVL_NO, True);
-        return NULL;
+        return False;
     }

     ctx->rootW = DefaultRootWindow (ctx->xDpy);
@@ -129,14 +129,14 @@
     {
         logCtrl ("\t\tError getting screen by window attributes: "
                 "No display specified", LOG_LVL_NO, True);
-        return NULL;
+        return False;
     }

     if (ctx->rootWAttr.screen == NULL)
     {
         logCtrl ("\t\tError getting default screen: No valid screen pointer "
                 "found in root window's attributes struct", LOG_LVL_NO, True);
-        return NULL;
+        return False;
     }

     ctx->xScr = ctx->rootWAttr.screen;
@@ -305,4 +305,4 @@
     logCtrl ("\t\tsuccess", LOG_LVL_2, True);

     return True;
-}+}


erts: Refactor erlang:insert_element/3 for clarity

--- erts/emulator/beam/bif.c
+++ erts/emulator/beam/bif.c
@@ -2543,7 +2543,7 @@
     Eterm* hp;
     Uint arity;
     Eterm res;
-    Sint ix;
+    Sint ix, c1, c2;

     if (is_not_tuple(BIF_ARG_2) || is_not_small(BIF_ARG_1)) {
 	BIF_ERROR(BIF_P, BADARG);
@@ -2561,14 +2561,12 @@
     res = make_tuple(hp);
     *hp = make_arityval(arity + 1);

-    ix--;
-    arity -= ix;
-
-    while (ix--) { *++hp = *++ptr; }
-
+    c1 = ix - 1;
+    c2 = arity - ix + 1;
+
+    while (c1--) { *++hp = *++ptr; }
     *++hp = BIF_ARG_3;
-
-    while(arity--) { *++hp = *++ptr; }
+    while (c2--) { *++hp = *++ptr; }

     BIF_RET(res);
 }


fix offsets

fix offsets

--- ut2004.c
+++ ut2004.c
@@ -35,8 +35,8 @@
 // arbitrary
 #define MAX_LISTING_RECORD_LEN 0x04FF

-#define RESPONSE_OFFSET_CDKEY     4
-#define RESPONSE_OFFSET_CHALLENGE 38
+#define RESPONSE_OFFSET_CDKEY     5
+#define RESPONSE_OFFSET_CHALLENGE 39

 static const char challenge_response[] = {
     0x68, 0x00, 0x00, 0x00,  '!', 0xCD, 0xCD, 0xCD,
@@ -656,8 +656,8 @@
     in += len;
     do
     {
-	*o-- = hexchar[*--in&0x0F];
-	*o-- = hexchar[(*in>>4)&0x0F];
+	*--o = hexchar[*--in&0x0F];
+	*--o = hexchar[(*in>>4)&0x0F];
     } while(o != out);
 }


IMAPX: Fix DELETED flag sync when using real Trash folder.

After copying messages to a real Trash folder and then tagging them for
deletion, we immediately expunge.  Now the IMAPX expunge operation first
synchronizes message flags with the server, which is sensible.  But when
using a real Trash folder, this extra sync was causing deleted messages
to keep coming back from the grave like zombies.

The problem was when using a real Trash folder, the internal operation
that synchronizes flags first clears any DELETED flags.  Normally that's
what we want, except when we're about to expunge since expunging depends
on those DELETED flags.  So make an exception for this case.

--- camel/camel-imapx-server.c
+++ camel/camel-imapx-server.c
@@ -124,6 +124,11 @@
 	GArray *on_user; /* imapx_flag_change */
 	GArray *off_user;
 	gint unread_change;
+
+	/* Remove recently set DELETED flags before synchronizing.
+	 * This is only set when using a real Trash folder and NOT
+	 * about to expunge the folder. */
+	gboolean remove_deleted_flags;
 };

 struct _AppendMessageData {
@@ -434,6 +439,7 @@
 						 gconstpointer bp);
 static gboolean	imapx_server_sync_changes	(CamelIMAPXServer *is,
 						 CamelFolder *folder,
+						 guint32 job_type,
 						 gint pri,
 						 GCancellable *cancellable,
 						 GError **error);
@@ -4417,7 +4423,7 @@
 	g_return_val_if_fail (data != NULL, FALSE);

 	success = imapx_server_sync_changes (
-		is, job->folder, job->pri, cancellable, error);
+		is, job->folder, job->type, job->pri, cancellable, error);
 	if (!success)
 		imapx_unregister_job (is, job);

@@ -5303,7 +5309,7 @@
 	/* Sync changes first, else unread count will not
 	 * match. Need to think about better ways for this */
 	success = imapx_server_sync_changes (
-		is, folder, job->pri, cancellable, error);
+		is, folder, job->type, job->pri, cancellable, error);
 	if (!success)
 		goto done;

@@ -5569,7 +5575,7 @@
 	gboolean success;

 	success = imapx_server_sync_changes (
-		is, job->folder, job->pri, cancellable, error);
+		is, job->folder, job->type, job->pri, cancellable, error);

 	if (success) {
 		/* TODO handle UIDPLUS capability */
@@ -6126,7 +6132,9 @@
 			if (!xinfo)
 				continue;

-			xinfo->server_flags = ((CamelMessageInfoBase *) xinfo)->flags & CAMEL_IMAPX_SERVER_FLAGS;
+			if (data->remove_deleted_flags)
+				xinfo->info.flags &= ~CAMEL_MESSAGE_DELETED;
+			xinfo->server_flags = xinfo->info.flags & CAMEL_IMAPX_SERVER_FLAGS;
 			xinfo->info.flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED;
 			xinfo->info.dirty = TRUE;
 			camel_flag_list_copy (&xinfo->server_user_flags, &xinfo->info.user_flags);
@@ -6200,18 +6208,34 @@
 			c (is->tagprefix, "checking/storing %s flags '%s'\n", on?"on":"off", flags_table[j].name);
 			imapx_uidset_init (&ss, 0, 100);
 			for (i = 0; i < uids->len; i++) {
-				CamelIMAPXMessageInfo *info = (CamelIMAPXMessageInfo *) camel_folder_summary_get
-										(job->folder->summary, uids->pdata[i]);
+				CamelIMAPXMessageInfo *info;
+				gboolean remove_deleted_flag;
 				guint32 flags;
 				guint32 sflags;
 				gint send;

-				if (!info)
+				info = (CamelIMAPXMessageInfo *)
+					camel_folder_summary_get (
+						job->folder->summary,
+						uids->pdata[i]);
+
+				if (info == NULL)
 					continue;

-				flags = ((CamelMessageInfoBase *) info)->flags & CAMEL_IMAPX_SERVER_FLAGS;
+				flags = info->info.flags & CAMEL_IMAPX_SERVER_FLAGS;
 				sflags = info->server_flags & CAMEL_IMAPX_SERVER_FLAGS;
 				send = 0;
+
+				remove_deleted_flag =
+					data->remove_deleted_flags &&
+					(flags & CAMEL_MESSAGE_DELETED);
+
+				if (remove_deleted_flag) {
+					/* Remove the DELETED flag so the
+					 * message appears normally in the
+					 * real Trash folder when copied. */
+					flags &= ~CAMEL_MESSAGE_DELETED;
+				}

 				if ( (on && (((flags ^ sflags) & flags) & flag))
 				     || (!on && (((flags ^ sflags) & ~flags) & flag))) {
@@ -7233,6 +7257,7 @@
 static gboolean
 imapx_server_sync_changes (CamelIMAPXServer *is,
                            CamelFolder *folder,
+                           guint32 job_type,
                            gint pri,
                            GCancellable *cancellable,
                            GError **error)
@@ -7311,13 +7336,9 @@
 			camel_imapx_folder_maybe_move_to_real_junk (
 				CAMEL_IMAPX_FOLDER (folder), uid);

-		if (move_to_real_trash) {
-			/* Remove the DELETED flag so the message
-			 * appears normally in the Trash folder. */
-			flags &= ~CAMEL_MESSAGE_DELETED;
+		if (move_to_real_trash)
 			camel_imapx_folder_maybe_move_to_real_trash (
 				CAMEL_IMAPX_FOLDER (folder), uid);
-		}

 		if (flags != sflags) {
 			off_orset |= (flags ^ sflags) & ~flags;
@@ -7419,6 +7440,10 @@
 	data->on_user = on_user;  /* takes ownership */
 	data->off_user = off_user;  /* takes ownership */

+	data->remove_deleted_flags =
+		use_real_trash_path &&
+		(job_type != IMAPX_JOB_EXPUNGE);
+
 	job = camel_imapx_job_new (cancellable);
 	job->type = IMAPX_JOB_SYNC_CHANGES;
 	job->start = imapx_job_sync_changes_start;
@@ -7447,7 +7472,9 @@
                                  GError **error)
 {
 	return imapx_server_sync_changes (
-		is, folder, IMAPX_PRIORITY_SYNC_CHANGES,
+		is, folder,
+		IMAPX_JOB_SYNC_CHANGES,
+		IMAPX_PRIORITY_SYNC_CHANGES,
 		cancellable, error);
 }