fix mismatch argument

fix mismatch argument

--- src/cluster.c
+++ src/cluster.c
@@ -4194,7 +4194,7 @@
             }
             if ((n = clusterLookupNode(c->argv[4]->ptr)) == NULL) {
                 addReplyErrorFormat(c,"I don't know about node %s",
-                    (char*)c->argv[3]->ptr);
+                    (char*)c->argv[4]->ptr);
                 return;
             }
             server.cluster->importing_slots_from[slot] = n;


Switched to using MPN_NORM in nmod_poly_gcd_euclidean.

--- nmod_poly/gcd_euclidean.c
+++ nmod_poly/gcd_euclidean.c
@@ -28,13 +28,7 @@
 #include "flint.h"
 #include "nmod_vec.h"
 #include "nmod_poly.h"
-
-long NORM(mp_srcptr R, long len)
-{
-    while (len != 0 && R[len - 1] == 0)
-        len--;
-    return len;
-}
+#include "mpn_extras.h"

 long
 _nmod_poly_gcd_euclidean(mp_ptr G, mp_srcptr A, long lenA,
@@ -49,12 +43,14 @@
     F = R1;

     _nmod_poly_divrem(Q, R1, A, lenA, B, lenB, mod);
-    lenR1 = NORM(R1, lenB - 1);
+    lenR1 = lenB - 1;
+    MPN_NORM(R1, lenR1);

     if (lenR1 > 1)
     {
         _nmod_poly_divrem(Q, R2, B, lenB, R1, lenR1, mod);
-        lenR2 = NORM(R2, lenR1 - 1);
+        lenR2 = lenR1 - 1;
+        MPN_NORM(R2, lenR2);
     } else
     {
         if (lenR1 == 0)
@@ -74,7 +70,8 @@
     while (lenR2 > 1)
     {
         _nmod_poly_divrem(Q, R3, R1, lenR1, R2, lenR2, mod);
-        lenR3 = NORM(R3, lenR2 - 1);
+        lenR3 = lenR2 - 1;
+        MPN_NORM(R3, lenR3);
         if (++steps == 3) steps = 0;
         T = R1; R1 = R2; R2 = R3; R3 = T;
         lenR1 = lenR2; lenR2 = lenR3;


Fix 2 spelling mistakes (#129)

Fix 2 spelling mistakes (#129)

--- nnvm/include/nnvm/tuple.h
+++ nnvm/include/nnvm/tuple.h
@@ -19,7 +19,7 @@
 typedef int64_t dim_t;

 /*!
- * \brief A dynamic sized array data strcuture that is optimized for storing
+ * \brief A dynamic sized array data structure that is optimized for storing
  *        small number of elements with same type.
  *
  *  Data will be stored in stack when number of elements is small.
@@ -72,7 +72,7 @@
   }
   /*!
    * \brief Assign content to tuple from iterator.
-   * \param begin the beginning of iteratro
+   * \param begin the beginning of iterator
    * \param end end the end of the iterator
    * \tparam RandomAccessIterator iterator type
    */


arena management

arena management

--- src/codegen.c
+++ src/codegen.c
@@ -281,11 +281,25 @@
   return pic_list(state->pic, 4, pic_symbol_value(state->sCSET), pic_int_value(depth), pic_int_value(idx), value);
 }

+static pic_value analyze_node(analyze_state *, pic_value, bool);
 static pic_value analyze_call(analyze_state *, pic_value, bool);
 static pic_value analyze_lambda(analyze_state *, pic_value);

 static pic_value
 analyze(analyze_state *state, pic_value obj, bool tailpos)
+{
+  int ai = pic_gc_arena_preserve(state->pic);
+  pic_value res;
+
+  res = analyze_node(state, obj, tailpos);
+
+  pic_gc_arena_restore(state->pic, ai);
+  pic_gc_protect(state->pic, res);
+  return res;
+}
+
+static pic_value
+analyze_node(analyze_state *state, pic_value obj, bool tailpos)
 {
   pic_state *pic = state->pic;
   analyze_scope *scope = state->scope;
@@ -603,6 +617,7 @@
 analyze_call(analyze_state *state, pic_value obj, bool tailpos)
 {
   pic_state *pic = state->pic;
+  int ai = pic_gc_arena_preserve(pic);
   pic_value seq;
   pic_sym call;

@@ -615,13 +630,18 @@
   for (; ! pic_nil_p(seq); obj = pic_cdr(pic, obj)) {
     seq = pic_cons(pic, analyze(state, pic_car(pic, obj), false), seq);
   }
-  return pic_reverse(pic, seq);
+  seq = pic_reverse(pic, seq);
+
+  pic_gc_arena_restore(pic, ai);
+  pic_gc_protect(pic, seq);
+  return seq;
 }

 static pic_value
 analyze_lambda(analyze_state *state, pic_value obj)
 {
   pic_state *pic = state->pic;
+  int ai = pic_gc_arena_preserve(pic);
   pic_value args, body;

   if (pic_length(pic, obj) < 2) {
@@ -643,7 +663,10 @@
   }
   pop_scope(state);

-  return pic_list(pic, 3, pic_symbol_value(pic->sLAMBDA), args, body);
+  obj = pic_list(pic, 3, pic_symbol_value(pic->sLAMBDA), args, body);
+  pic_gc_arena_restore(pic, ai);
+  pic_gc_protect(pic, obj);
+  return obj;
 }

 /**


Bluetooth: Remove start discovery handling from hci_event.c

Since all mgmt start discovery command complete events are now handled
in start_discovery_complete callback in mgmt.c, we can remove this
handling from hci_event.c.

Signed-off-by: Andre Guedes <282d5d3bbdb7014316a30ab22daf425f10cd096c@openbossa.org>
Acked-by: Johan Hedberg <628991c7b0a19c384f9b99c21ec330ce952bb838@intel.com>
Signed-off-by: Gustavo Padovan <029a69b25713d0799b81c0a39685b4c040fa1425@collabora.co.uk>

--- net/bluetooth/hci_event.c
+++ net/bluetooth/hci_event.c
@@ -943,12 +943,6 @@

 	BT_DBG("%s status 0x%2.2x", hdev->name, status);

-	if (status) {
-		hci_dev_lock(hdev);
-		mgmt_start_discovery_failed(hdev, status);
-		hci_dev_unlock(hdev);
-		return;
-	}
 }

 static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
@@ -965,18 +959,10 @@

 	switch (cp->enable) {
 	case LE_SCAN_ENABLE:
-		if (status) {
-			hci_dev_lock(hdev);
-			mgmt_start_discovery_failed(hdev, status);
-			hci_dev_unlock(hdev);
+		if (status)
 			return;
-		}

 		set_bit(HCI_LE_SCAN, &hdev->dev_flags);
-
-		hci_dev_lock(hdev);
-		hci_discovery_set_state(hdev, DISCOVERY_FINDING);
-		hci_dev_unlock(hdev);
 		break;

 	case LE_SCAN_DISABLE:
@@ -1077,18 +1063,10 @@

 	if (status) {
 		hci_conn_check_pending(hdev);
-		hci_dev_lock(hdev);
-		if (test_bit(HCI_MGMT, &hdev->dev_flags))
-			mgmt_start_discovery_failed(hdev, status);
-		hci_dev_unlock(hdev);
 		return;
 	}

 	set_bit(HCI_INQUIRY, &hdev->flags);
-
-	hci_dev_lock(hdev);
-	hci_discovery_set_state(hdev, DISCOVERY_FINDING);
-	hci_dev_unlock(hdev);
 }

 static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)


cleanup

cleanup

--- src/command.c
+++ src/command.c
@@ -175,9 +175,6 @@
 {
   switch (ch)
   {
-    case ',': return pick_up_item_from_ground();
-    case CTRL('Z'): shell(); return false;
-    case '!': msg("Shell has been removed, use ^Z instead"); return false;

     /*TODO: change do_move to take a char instead of x,y */
     case 'h': case 'j': case 'k': case 'l':
@@ -300,10 +297,15 @@
       stat_msg = false;
       return false;

+    case KEY_SPACE: return false;
+    case '.': return true;
+    case ',': return pick_up_item_from_ground();
+    case '!': msg("Shell has been removed, use ^Z instead"); return false;
     case 'q': return quaff();
     case 'i': inventory(pack, 0); return false;
     case 'I': picky_inven(); return false;
     case 'd': drop(); return true;
+    case 'D': discovered(); return false;
     case 'r': read_scroll(); return true;
     case 't': return get_dir() ? missile(delta.y, delta.x) : false;
     case 'e': eat(); return true;
@@ -314,22 +316,20 @@
     case 'R': return ring_off();
     case 'o': option(); return false;
     case 'c': give_item_nickname(); return false;
+    case 's': search(); return true;
+    case 'S': after = false; save_game(); return false;
+    case 'z': return get_dir() ? do_zap() : false;
     case '>': go_down_a_level(); return false;
     case '<': go_up_a_level(); return false;
     case '?': print_help(); return false;
     case '/': identify_a_character(); return false;
-    case 's': search(); return true;
-    case 'D': discovered(); return false;
+    case ')': return print_currently_wearing(WEAPON);
+    case ']': return print_currently_wearing(ARMOR);
+    case '=': return print_currently_wearing(RING);
+    case CTRL('Z'): shell(); return false;
     case CTRL('P'): msg(huh); return false;
-    case 'S': after = false; save_game(); return false;
-    when KEY_SPACE: return false;
-    when '.': return true;
-    when ')': return print_currently_wearing(WEAPON);
-    when ']': return print_currently_wearing(ARMOR);
-    when '=': return print_currently_wearing(RING);
-    when 'z': return get_dir() ? do_zap() : false;
-
-    otherwise:
+
+    default:
       return do_wizard_command(ch);
   }
 }


Bluetooth: Refactor in hci_le_conn_complete_evt

This patch moves the hci_conn check to begining of hci_le_conn_
complete_evt in order to improve code's readability and better
error handling.

Signed-off-by: Andre Guedes <282d5d3bbdb7014316a30ab22daf425f10cd096c@openbossa.org>
Signed-off-by: Gustavo Padovan <029a69b25713d0799b81c0a39685b4c040fa1425@collabora.co.uk>

--- net/bluetooth/hci_event.c
+++ net/bluetooth/hci_event.c
@@ -3334,11 +3334,22 @@
 	hci_dev_lock(hdev);

 	conn = hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT);
+	if (!conn) {
+		conn = hci_conn_add(hdev, LE_LINK, &ev->bdaddr);
+		if (!conn) {
+			BT_ERR("No memory for new connection");
+			goto unlock;
+		}
+
+		conn->dst_type = ev->bdaddr_type;
+
+		if (ev->role == LE_CONN_ROLE_MASTER) {
+			conn->out = true;
+			conn->link_mode |= HCI_LM_MASTER;
+		}
+	}

 	if (ev->status) {
-		if (!conn)
-			goto unlock;
-
 		mgmt_connect_failed(hdev, &conn->dst, conn->type,
 				    conn->dst_type, ev->status);
 		hci_proto_connect_cfm(conn, ev->status);
@@ -3347,21 +3358,6 @@
 		goto unlock;
 	}

-	if (!conn) {
-		conn = hci_conn_add(hdev, LE_LINK, &ev->bdaddr);
-		if (!conn) {
-			BT_ERR("No memory for new connection");
-			goto unlock;
-		}
-
-		conn->dst_type = ev->bdaddr_type;
-
-		if (ev->role == LE_CONN_ROLE_MASTER) {
-			conn->out = true;
-			conn->link_mode |= HCI_LM_MASTER;
-		}
-	}
-
 	if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
 		mgmt_device_connected(hdev, &ev->bdaddr, conn->type,
 				      conn->dst_type, 0, NULL, 0, NULL);


Fixing double init value

Fixing double init value

--- CMSIS/DSP/Source/BasicMathFunctions/arm_dot_prod_f64.c
+++ CMSIS/DSP/Source/BasicMathFunctions/arm_dot_prod_f64.c
@@ -66,7 +66,7 @@
         float64_t * result)
 {
   uint32_t blkCnt;                               /* Loop counter */
-  float64_t sum = 0.0f;                          /* Temporary return variable */
+  float64_t sum = 0.;                            /* Temporary return variable */

   /* Initialize blkCnt with number of samples */
   blkCnt = blockSize;


net,rcu: convert call_rcu(ha_rcu_free) to kfree_rcu()

The rcu callback ha_rcu_free() just calls a kfree(),
so we use kfree_rcu() instead of the call_rcu(ha_rcu_free).

Signed-off-by: Lai Jiangshan <4c9eb49378914b743bdd32292c04df29b820d73e@cn.fujitsu.com>
Acked-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>
Signed-off-by: Paul E. McKenney <1e0ce936bb9b355d257bf5790d2513c3f28be22b@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <c028c213ed5efcf30c3f4fc7361dbde0c893c5b7@joshtriplett.org>

--- net/core/dev_addr_lists.c
+++ net/core/dev_addr_lists.c
@@ -68,14 +68,6 @@
 	return __hw_addr_add_ex(list, addr, addr_len, addr_type, false);
 }

-static void ha_rcu_free(struct rcu_head *head)
-{
-	struct netdev_hw_addr *ha;
-
-	ha = container_of(head, struct netdev_hw_addr, rcu_head);
-	kfree(ha);
-}
-
 static int __hw_addr_del_ex(struct netdev_hw_addr_list *list,
 			    unsigned char *addr, int addr_len,
 			    unsigned char addr_type, bool global)
@@ -94,7 +86,7 @@
 			if (--ha->refcount)
 				return 0;
 			list_del_rcu(&ha->list);
-			call_rcu(&ha->rcu_head, ha_rcu_free);
+			kfree_rcu(ha, rcu_head);
 			list->count--;
 			return 0;
 		}
@@ -197,7 +189,7 @@

 	list_for_each_entry_safe(ha, tmp, &list->list, list) {
 		list_del_rcu(&ha->list);
-		call_rcu(&ha->rcu_head, ha_rcu_free);
+		kfree_rcu(ha, rcu_head);
 	}
 	list->count = 0;
 }


netprio_cgroup: Remove update_netdev_tables() since it is unnecessary

The update_netdev_tables() function appears to be unnecessary, since the
write_update_netdev_table() function will adjust the priomaps as and when
required anyway. So drop the usage of update_netdev_tables() entirely.

Signed-off-by: Srivatsa S. Bhat <5b23f8226e886b22344fc642373ea657dd596b63@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/core/netprio_cgroup.c
+++ net/core/netprio_cgroup.c
@@ -109,32 +109,6 @@
 	return ret;
 }

-static int update_netdev_tables(void)
-{
-	int ret = 0;
-	struct net_device *dev;
-	u32 max_len;
-	struct netprio_map *map;
-
-	rtnl_lock();
-	max_len = atomic_read(&max_prioidx) + 1;
-	for_each_netdev(&init_net, dev) {
-		map = rtnl_dereference(dev->priomap);
-		/*
-		 * don't allocate priomap if we didn't
-		 * change net_prio.ifpriomap (map == NULL),
-		 * this will speed up skb_update_prio.
-		 */
-		if (map && map->priomap_len < max_len) {
-			ret = extend_netdev_table(dev, max_len);
-			if (ret < 0)
-				break;
-		}
-	}
-	rtnl_unlock();
-	return ret;
-}
-
 static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp)
 {
 	struct cgroup_netprio_state *cs;
@@ -150,12 +124,6 @@
 	ret = get_prioidx(&cs->prioidx);
 	if (ret < 0) {
 		pr_warn("No space in priority index array\n");
-		goto out;
-	}
-
-	ret = update_netdev_tables();
-	if (ret < 0) {
-		put_prioidx(cs->prioidx);
 		goto out;
 	}


mac80211: hold sta->lock across plink switch statements

Rather than unlock at the end of each case, do it once after
all is said and done.

Signed-off-by: Bob Copeland <48181acd22b3edaebc8a447868a7df7ce629920a@cozybit.com>
Signed-off-by: Johannes Berg <bff32994ff0f8d048f262a8388145a71b6071bfe@intel.com>


Update Stepper.h

Update Stepper.h

--- src/Stepper.h
+++ src/Stepper.h
@@ -2,9 +2,6 @@

 #include <stdint.h>
 #include <algorithm>
-
-//template<uint pw>class StepControl;
-//class StpCmp;

 class Stepper
 {
@@ -22,7 +19,6 @@

     inline Stepper& SetPullInSpeed(uint pullInFreq) { v_pullIn = std::max(vPullIn_min, pullInFreq); return *this; } // largest speed the motor starts without accelerating (steps/s)
     inline Stepper& SetMaxSpeed(uint speed) { vMax = std::min(vMaxMax, speed); return *this; }
- //   inline Stepper& SetSpeed(uint _v) { v = std::min(vMax, _v); return *this; }                                  // largest speed the motor can run without loosing steps(steps / s)
     inline Stepper& SetAcceleration(uint _a) { a = std::min(aMax, _a); return *this; }                           // acceleration (steps/s^2)

     void SetTargetAbs(int pos);			// Set target position
@@ -30,6 +26,7 @@

     inline void setStepPin() { *stepPinActiveReg = 1; }
     inline void clearStepPin() { *stepPinInactiveReg = 1; }
+
     inline int32_t getPosition() const { return position + dirCw* current; }

     volatile int current;
@@ -37,7 +34,6 @@
     int D;
     unsigned v_pullIn;
     unsigned vMax;
-//    unsigned v;
     unsigned a;

     static bool cmpDelta(const Stepper * a, const Stepper * b) { return a->target > b->target; }
@@ -52,11 +48,7 @@
     volatile uint32_t* stepPinInactiveReg;
     volatile uint32_t* dirPinCwReg;
     volatile uint32_t* dirPinCcwReg;
-
     int dirCw;
-
-    //template<uint pw>
-    //friend StepControl<pw>;
 };


It turned out to be an error with unlocking and locking the wrong node!

--- src/company.c
+++ src/company.c
@@ -367,6 +367,22 @@
     return id;
 }

+void
+print_children (Company *company, int id)
+{
+    int prev_sibling;
+    int sibling = company->list[id].family[NODE_CHILD];
+    while (sibling >= 0) {
+        printf(" %d ", sibling);
+        if (node_read(company, sibling)) {
+            prev_sibling = sibling;
+            sibling = company->list[sibling].family[NODE_NEXT_SIBLING];
+            node_unlock(company, prev_sibling);
+        }
+    }
+    printf("\n");
+}
+
 /*
  * Acquire the write lock on the Company list and cleanup any existing nodes
  * (and the Node's corresponding Actor). Then free memory for the Company list
@@ -390,6 +406,7 @@
             goto cleanup;

         printf("Actor %d\n", id);
+        print_children(company, id);
         printf("  [fc] -> %d\n", company->list[id].family[NODE_CHILD]);
         printf("  [nc] -> %d\n", company->list[id].family[NODE_NEXT_SIBLING]);
         printf("  [pa] -> %d\n", company->list[id].family[NODE_PARENT]);


Cluster: fix clusterBlacklistAddNode() by setting right expire time.

The hash table value should be set to now + 60 seconds otherwise it
expires immediately.

--- src/cluster.c
+++ src/cluster.c
@@ -714,7 +714,7 @@
         id = sdsdup(id);
     }
     de = dictFind(server.cluster->nodes_black_list,id);
-    dictSetUnsignedIntegerVal(de,time(NULL));
+    dictSetUnsignedIntegerVal(de,time(NULL)+REDIS_CLUSTER_BLACKLIST_TTL);
     sdsfree(id);
 }


add Filter class

add Filter class

error: pathspec 'src/Filter.h' did not match any file(s) known to git

--- src/Filter.h
+++ src/Filter.h
@@ -0,0 +1,11 @@
+#ifndef _FILTER_H_
+#define _FILTER_H_
+
+class Filter {
+ public:
+  Filter() { }
+  virtual ~Filter() { }
+
+};
+
+#endif


Cluster: myself->ip autodiscovery.

Cluster: myself->ip autodiscovery.

Instead of having an hardcoded IP address in the node configuration, we
autodiscover it via MEET messages for automatic update when the node is
restarted with a different IP address.

This mechanism was discussed in the context of PR #1782.

--- src/cluster.c
+++ src/cluster.c
@@ -466,6 +466,11 @@

     /* The slots -> keys map is a sorted set. Init it. */
     server.cluster->slots_to_keys = zslCreate();
+
+    /* Set myself->port to my listening port, we'll just need to discover
+     * the IP address via MEET messages. */
+    myself->port = server.port;
+
     resetManualFailover();
 }

@@ -1530,6 +1535,26 @@
     /* Process packets by type. */
     if (type == CLUSTERMSG_TYPE_PING || type == CLUSTERMSG_TYPE_MEET) {
         redisLog(REDIS_DEBUG,"Ping packet received: %p", (void*)link->node);
+
+        /* We use incoming MEET messages in order to set the address
+         * for 'myself', since only other cluster nodes will send us
+         * MEET messagses on handshakes, when the cluster joins, or
+         * later if we changed address, and those nodes will use our
+         * official address to connect to us. So by obtaining this address
+         * from the socket is a simple way to discover / update our own
+         * address in the cluster without it being hardcoded in the config. */
+        if (type == CLUSTERMSG_TYPE_MEET) {
+            char ip[REDIS_IP_STR_LEN];
+
+            if (anetSockName(link->fd,ip,sizeof(ip),NULL) != -1 &&
+                strcmp(ip,myself->ip))
+            {
+                memcpy(myself->ip,ip,REDIS_IP_STR_LEN);
+                redisLog(REDIS_WARNING,"IP address for this node updated to %s",
+                    myself->ip);
+                clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG);
+            }
+        }

         /* Add this node if it is new for us and the msg type is MEET.
          * In this stage we don't try to add the node with the right


Fixed a bug in propagation of PUBLISH via the cluster bus.

This bug was spotted by clang on FreeBSD.

--- src/cluster.c
+++ src/cluster.c
@@ -902,7 +902,7 @@
     } else {
         payload = zmalloc(totlen);
         hdr = (clusterMsg*) payload;
-        memcpy(payload,hdr,sizeof(hdr));
+        memcpy(payload,hdr,sizeof(*hdr));
     }
     memcpy(hdr->data.publish.msg.bulk_data,channel->ptr,sdslen(channel->ptr));
     memcpy(hdr->data.publish.msg.bulk_data+sdslen(channel->ptr),


Cluster: conditions to clear "migrating" on slot for SETSLOT ... NODE changed.

If the slot is manually assigned to another node, clear the migrating
status regardless of the fact it was previously assigned to us or not,
as long as we no longer have keys for this slot.

This avoid a race during slots migration that may leave the slot in
migrating status in the source node, since it received an update message
from the destination node that is already claiming the slot.

This way we are sure that redis-trib at the end of the slot migration is
always able to close the slot correctly.

--- src/cluster.c
+++ src/cluster.c
@@ -3154,10 +3154,10 @@
                     return;
                 }
             }
-            /* If this node was the slot owner and the slot was marked as
-             * migrating, assigning the slot to another node will clear
+            /* If this slot is in migrating status but we have no keys
+             * for it assigning the slot to another node will clear
              * the migratig status. */
-            if (server.cluster->slots[slot] == myself &&
+            if (countKeysInSlot(slot) == 0 &&
                 server.cluster->migrating_slots_to[slot])
                 server.cluster->migrating_slots_to[slot] = NULL;


CLUSTER SLOTS: don't output failing slaves.

While we have to output failing masters in order to provide an accurate
map (that may be the one of a Redis Cluster in down state because not
all slots are served by a working master), to provide slaves in FAIL
state is not a good idea since those are not necesarely needed, and the
client will likely incur into a latency penalty trying to connect with a
slave which is down.

Note that this means that CLUSTER SLOTS does not provide a *complete*
map of slaves, however this would not be of any help since slaves may be
added later, and a client that needs to scale reads and requires to
stay updated with the list of slaves, need to do a refresh of the map
from time to time, anyway.

--- src/cluster.c
+++ src/cluster.c
@@ -3458,8 +3458,8 @@
      *           ... continued until done
      */

-    int repliedRangeCount = 0;
-    void *slotreplylen = addDeferredMultiBulkLength(c);
+    int num_masters = 0;
+    void *slot_replylen = addDeferredMultiBulkLength(c);

     dictEntry *de;
     dictIterator *di = dictGetSafeIterator(server.cluster->nodes);
@@ -3472,16 +3472,16 @@
         if (!nodeIsMaster(node) || node->numslots == 0) continue;

         for (j = 0; j < REDIS_CLUSTER_SLOTS; j++) {
-            int bit;
+            int bit, i;

             if ((bit = clusterNodeGetSlotBit(node,j)) != 0) {
                 if (start == -1) start = j;
             }
             if (start != -1 && (!bit || j == REDIS_CLUSTER_SLOTS-1)) {
+                int nested_elements = 3; /* slots (2) + master addr (1). */
+                void *nested_replylen = addDeferredMultiBulkLength(c);
+
                 if (bit && j == REDIS_CLUSTER_SLOTS-1) j++;
-
-                /* nested size: slots (2) + master (1) + slaves */
-                addReplyMultiBulkLen(c, 2 + 1 + node->numslaves);

                 /* If slot exists in output map, add to it's list.
                  * else, create a new output map for this slot */
@@ -3500,20 +3500,22 @@
                 addReplyLongLong(c, node->port);

                 /* Remaining nodes in reply are replicas for slot range */
-                int i;
                 for (i = 0; i < node->numslaves; i++) {
                     /* This loop is copy/pasted from clusterGenNodeDescription()
                      * with modifications for per-slot node aggregation */
+                    if (nodeFailed(node->slaves[i])) continue;
                     addReplyMultiBulkLen(c, 2);
                     addReplyBulkCString(c, node->slaves[i]->ip);
                     addReplyLongLong(c, node->slaves[i]->port);
+                    nested_elements++;
                 }
-                repliedRangeCount++;
+                setDeferredMultiBulkLength(c, nested_replylen, nested_elements);
+                num_masters++;
             }
         }
     }
     dictReleaseIterator(di);
-    setDeferredMultiBulkLength(c, slotreplylen, repliedRangeCount);
+    setDeferredMultiBulkLength(c, slot_replylen, num_masters);
 }

 void clusterCommand(redisClient *c) {


Switched TBB filters to used Lambdas. Code is inline and much cleaner.

--- src/KMeans.h
+++ src/KMeans.h
@@ -49,7 +49,7 @@
     float _eps = 0.00001f;

     // has the clustering converged
-    bool _converged;
+    atomic<bool> _converged;

 public:

@@ -151,8 +151,7 @@
             }
         }
         return emptyCluster;
-    }
-
+    }

     /**
      * @param vectors       the vectors to form clusters for
@@ -209,29 +208,6 @@
         return nearest;
     }

-    void vectorToNearestCentroid(size_t i, vector<T*>& data) {
-        size_t nearest = nearestObj(data[i], _centroids);
-        if (nearest != _nearestCentroid[i]) {
-            _converged = false;
-        }
-        _nearestCentroid[i] = nearest;
-    }
-
-    class VecToCentroid {
-    public:
-        VecToCentroid(KMeans* kmeans, vector<T*>& data) : _kmeans(kmeans), _data(data) { }
-
-        void operator()(const tbb::blocked_range<size_t>& r) const {
-            for (size_t i = r.begin(); i != r.end(); i++) {
-                _kmeans->vectorToNearestCentroid(i, _data);
-            }
-        }
-
-    private:
-        KMeans* _kmeans;
-        vector<T*>& _data;
-    };
-
     /**
      * Assign vectors to nearest centroid.
      * Pre: seedCentroids() OR recalculateCentroids() has been called
@@ -249,8 +225,17 @@
         _converged = true;

         // Parallel
-        VecToCentroid vc(this, data);
-        tbb::parallel_for(tbb::blocked_range<size_t>(0, data.size(), 1000), vc);
+        tbb::parallel_for(tbb::blocked_range<size_t>(0, data.size(), 1000),
+                [&](const tbb::blocked_range<size_t>& r) {
+                    for (size_t i = r.begin(); i != r.end(); ++i) {
+                        size_t nearest = nearestObj(data[i], _centroids);
+                        if (nearest != _nearestCentroid[i]) {
+                            _converged = false;
+                        }
+                        _nearestCentroid[i] = nearest;
+                    }
+                }
+        );
         tbb::atomic_fence(); // make sure all writes are visible on all CPUs

         // Serial
@@ -265,28 +250,6 @@
         }
     }

-    void recalculateCentroid(size_t i) {
-        Cluster<T>* c = _clusters[i];
-        if (c->size() > 0) {
-            _protoF(c->getCentroid(), c->getNearestList(), _weights);
-        }
-    }
-
-    class RecalculateCentroid {
-    public:
-        RecalculateCentroid(KMeans* kmeans) : _kmeans(kmeans) {
-        }
-
-        void operator()(const tbb::blocked_range<size_t>& r) const {
-            for (size_t i = r.begin(); i != r.end(); i++) {
-                _kmeans->recalculateCentroid(i);
-            }
-        }
-
-    private:
-        KMeans* _kmeans;
-    };
-
     /**
      * Recalculate centroids after vectors have been moved to there nearest
      * centroid.
@@ -294,8 +257,16 @@
      * Post: centroids has been updated with new vector data
      */
     void recalculateCentroids(vector<T*> &data) {
-        RecalculateCentroid recalculate(this);
-        tbb::parallel_for(tbb::blocked_range<size_t>(0, _clusters.size(), 2), recalculate);
+        tbb::parallel_for(tbb::blocked_range<size_t>(0, _clusters.size(), 2),
+                [&](const tbb::blocked_range<size_t>& r) {
+                    for (size_t i = r.begin(); i != r.end(); ++i) {
+                        Cluster<T>* c = _clusters[i];
+                        if (c->size() > 0) {
+                            _protoF(c->getCentroid(), c->getNearestList(), _weights);
+                        }
+                    }
+                }
+        );
         tbb::atomic_fence(); // make sure all writes are visible on all CPUs
     }
 };


[fix] Check if client isn't closing/writable

In some cases (two plugins with same interval of writes failing to write
at the same time) we'd try to close an already closing client and then
write to a broken pipe. Don't do that.

--- src/connect.c
+++ src/connect.c
@@ -93,7 +93,10 @@
 void estragon__on_write(uv_write_t* req, int status) {
   if (status) {
     fprintf(stderr, "write error: %s\n", uv_strerror(uv_last_error(loop)));
-    uv_close((uv_handle_t*) &client, estragon__reconnect_on_close);
+
+    if (!uv_is_closing((uv_handle_t*) &client)) {
+      uv_close((uv_handle_t*) &client, estragon__reconnect_on_close);
+    }
   }
   free(req);
 }
@@ -128,6 +131,10 @@
   uv_write_t *write_req;
   char *json_data;

+  if (!uv_is_writable(connect_req.handle)) {
+    return;
+  }
+
   metric->host = hostname;
   json_data = estragon_json_stringify(metric);


force another build

force another build

--- src/cn-cbor.c
+++ src/cn-cbor.c
@@ -236,8 +236,10 @@
 }

 const cn_cbor* cn_cbor_decode(const char* buf, size_t len, cn_cbor_errback *errp) {
-  cn_cbor catcher = {CN_CBOR_INVALID, 0, {0}, 0, 0, 0, 0, 0};
-  struct parse_buf pb = {(unsigned char *)buf, (unsigned char *)buf+len, CN_CBOR_NO_ERROR};
+  cn_cbor catcher = {CN_CBOR_INVALID, 0, {0}, 0, NULL, NULL, NULL, NULL};
+  struct parse_buf pb = {(unsigned char *)buf,
+                         (unsigned char *)buf+len,
+                         CN_CBOR_NO_ERROR};
   cn_cbor* ret = decode_item(&pb, &catcher);
   if (ret) {
     ret->parent = 0;            /* mark as top node */


Update: indentation

Update: indentation

git-svn-id: 1af002208e930b4d920e7c2b948d1e98a012c795@4197 a9d63959-f2ad-4865-b262-bf0e56cfafb6

--- common/include/pcl/common/spring.h
+++ common/include/pcl/common/spring.h
@@ -110,7 +110,7 @@

     private:
       /** init computation checking params and copying point cloud if necessary
-	* \param[out] output the output point cloud
+        * \param[out] output the output point cloud
         */
       inline bool
       initCompute (PointCloud& output);
@@ -122,7 +122,7 @@
         * and right columns of the original point cloud.
         * If the policy is set to duplicate then the top and bottom rows
         * and/or the right and left columns will be duplicated.
-	* \param[out] output the output point cloud
+        * \param[out] output the output point cloud
         */
       inline void
       expand (PointCloud& output)
@@ -148,7 +148,7 @@

       /** expand a point cloud in the set direction.
         * \param[in] val the point value to be used to fill.
-	* \param[out] output the output point cloud
+        * \param[out] output the output point cloud
         */
       inline void
       expand (const PointT& val, PointCloud& output)
@@ -167,7 +167,7 @@
         *   from top and bottom.
         * - If direction is columns or both then \a v_amount columns are deleted
         *   from left and right.
-	* \param[out] output the output point cloud
+        * \param[out] output the output point cloud
         */
       inline void
       shrink (PointCloud& output)
@@ -186,7 +186,7 @@
         * top and the bottom of a point cloud and filling them with
         * custom values.
         * \param[in] val the point value to be insterted
-	* \param[out] output the output point cloud
+        * \param[out] output the output point cloud
         */
       void
       expandRows (const PointT& val, PointCloud& output);
@@ -194,38 +194,38 @@
         * the right and the left of a point cloud and filling them with
         * custom values.
         * \param[in] val the point value to be insterted
-	* \param[out] output the output point cloud
+        * \param[out] output the output point cloud
         */
       void
       expandColumns (const PointT& val, PointCloud& output);
       /** expand point cloud duplicating the top and bottom rows \a r_amount_ times.
-	* \param[out] output the output point cloud
+        * \param[out] output the output point cloud
         */
       void
       expandRowsDuplicate (PointCloud& output);
       /** expand point cloud duplicating the right and left columns \a c_amount_
         * times.
-	* \param[out] output the output point cloud
+        * \param[out] output the output point cloud
         */
       void
       expandColumnsDuplicate (PointCloud& output);
       /** expand point cloud mirroring \a r_amount_ top and bottom rows.
-	* \param[out] output the output point cloud
+        * \param[out] output the output point cloud
         */
       void
       expandRowsMirror (PointCloud& output);
       /** expand point cloud mirroring \a c_amount_ right and left columns.
-	* \param[out] output the output point cloud
+        * \param[out] output the output point cloud
         */
       void
       expandColumnsMirror (PointCloud& output);
       /** delete \a r_amount_ rows in top and bottom of point cloud
-	* \param[out] output the output point cloud
+        * \param[out] output the output point cloud
         */
       inline void
       deleteRows (PointCloud& output);
       /** delete \a c_amount_ columns in top and bottom of point cloud
-	* \param[out] output the output point cloud
+        * \param[out] output the output point cloud
         */
       inline void
       deleteCols (PointCloud& output);


Delete command.h

Delete command.h

--- src/command.h
+++ src/command.h
@@ -1,43 +0,0 @@
-#ifndef __COMMAND_H__
-#define __COMMAND_H__
-
-#include <iostream>
-#include <vector>
-
-using namespace std;
-
-
-class Parse {
- public:
-    void print();
-
-    bool hasOpenParenthesis(string);
-
-    bool hasEndingParenthesis(string);
-
-    bool isComparator(string);
-
-    bool hasSemiColon(string);
-
-    bool isComment(string);
-
-    bool isTest(string);
-
-    bool checkForParenthesis(string command);
-
-    void remove_parenthesis(string&);
-
-    void parseString(string, vector<string>&);
-
-    void sepParenthesis(string command);
-};
-
-class Execute : public Parse {
- public:
-    bool execute(vector<string>);
-
-    bool execTest(vector<string>);
-
-    void execMain(string, bool&);
-};
-#endif


Add func_unregister_transaction_on_event to context.c

--- src/context.c
+++ src/context.c
@@ -134,6 +134,14 @@
     union ws_value_union* stack
 );

+/**
+ * Unregister a transaction on an event
+ */
+static int
+func_unregister_transaction_on_event(
+    union ws_value_union* stack
+);
+
 static const struct ws_object_function functions[] = {
     { .name = "exit", .func = func_exit },
     { .name = "log", .func = func_log },
@@ -146,6 +154,8 @@
     { .name = "set_ms_focus", .func = func_set_ms_focus },
     { .name = "set_kb_focus", .func = func_set_kb_focus },
     { .name = "reg_transaction", .func = func_register_transaction_on_event },
+    { .name = "unreg_transaction",
+      .func = func_unregister_transaction_on_event },
     { .name = NULL, .func = NULL }
 };

@@ -461,3 +471,22 @@
     return 0;
 }

+static int
+func_unregister_transaction_on_event(
+    union ws_value_union* stack
+) {
+    if (ws_value_get_type(&stack[0].value) != WS_VALUE_TYPE_STRING) {
+        return -EINVAL;
+    }
+
+    struct ws_string* trans_name = ws_value_string_get(&stack[0].string);
+
+    bool res = 0 == ws_action_manager_unregister_transaction(trans_name);
+
+    ws_object_unref((struct ws_object*) trans_name);
+
+    ws_value_union_reinit(stack, WS_VALUE_TYPE_BOOL);
+    ws_value_bool_set(&stack->bool_, res);
+
+    return 0;
+}


Fix memory leak setting transports

Fix memory leak setting transports

--- src/context.c
+++ src/context.c
@@ -1190,15 +1190,14 @@
 }               /* getdns_context_set_namespaces */

 static getdns_return_t
-getdns_set_base_dns_transports(struct getdns_context *context,
-    size_t transport_count, getdns_transport_list_t *transports)
+getdns_set_base_dns_transports(
+    getdns_context *context, size_t transport_count, getdns_transport_list_t *transports)
 {
 	size_t i;
-
-    RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
-    if (transport_count == 0 || transports == NULL) {
-        return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
-    }
+	getdns_transport_list_t *new_transports;
+
+	if (!context || transport_count == 0 || transports == NULL)
+		return GETDNS_RETURN_INVALID_PARAMETER;

 	for(i=0; i<transport_count; i++)
 	{
@@ -1208,18 +1207,23 @@
 		 && transports[i] != GETDNS_TRANSPORT_STARTTLS)
 			return GETDNS_RETURN_INVALID_PARAMETER;
 	}
-
-    GETDNS_FREE(context->my_mf, context->dns_transports);
-
-    /** duplicate **/
-    context->dns_transports = GETDNS_XMALLOC(context->my_mf,
-                                 getdns_transport_list_t, transport_count);
-    memcpy(context->dns_transports, transports,
-        transport_count * sizeof(getdns_transport_list_t));
+
+	if (!(new_transports = GETDNS_XMALLOC(context->my_mf,
+				getdns_transport_list_t, transport_count)))
+
+		return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
+
+	if (context->dns_transports)
+		GETDNS_FREE(context->my_mf, context->dns_transports);
+
+	/** duplicate **/
+	context->dns_transports = new_transports;
+	memcpy(context->dns_transports, transports,
+	    transport_count * sizeof(getdns_transport_list_t));
 	context->dns_transport_count = transport_count;
-    dispatch_updated(context, GETDNS_CONTEXT_CODE_NAMESPACES);
-
-    return GETDNS_RETURN_GOOD;
+	dispatch_updated(context, GETDNS_CONTEXT_CODE_NAMESPACES);
+
+	return GETDNS_RETURN_GOOD;
 }

 static getdns_return_t
@@ -1278,62 +1282,72 @@
  *
  */
 getdns_return_t
-getdns_context_set_dns_transport(struct getdns_context *context,
-    getdns_transport_t value)
-{
-    RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
-
-    size_t count = 2;
-    if (value == GETDNS_TRANSPORT_UDP_ONLY ||
-        value == GETDNS_TRANSPORT_TCP_ONLY ||
-        value == GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN ||
-        value == GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN)
-        count = 1;
-    context->dns_transport_count = count;
-    context->dns_transports = GETDNS_XMALLOC(context->my_mf,
-                                               getdns_transport_list_t, count);
-
-    switch (value) {
-        case GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP:
-            context->dns_transports[0] = GETDNS_TRANSPORT_UDP;
-            context->dns_transports[1] = GETDNS_TRANSPORT_TCP;
-            break;
-        case GETDNS_TRANSPORT_UDP_ONLY:
-            context->dns_transports[0] = GETDNS_TRANSPORT_UDP;
-            break;
-        case GETDNS_TRANSPORT_TCP_ONLY:
-        case GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN:
-            context->dns_transports[0] = GETDNS_TRANSPORT_TCP;
-            break;
-        case GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN:
-            context->dns_transports[0] = GETDNS_TRANSPORT_TLS;
-            break;
-        case GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN:
-            context->dns_transports[0] = GETDNS_TRANSPORT_TLS;
-            context->dns_transports[1] = GETDNS_TRANSPORT_TCP;
-           break;
-        case GETDNS_TRANSPORT_STARTTLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN:
-            context->dns_transports[0] = GETDNS_TRANSPORT_STARTTLS;
-            context->dns_transports[1] = GETDNS_TRANSPORT_TCP;
-           break;
-       default:
-           return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
-    }
-    /* Note that the call below does not have any effect in unbound after the
-     * ctx is finalised so for recursive mode or stub + dnssec only the first
-     * transport specified on the first query is used.
-     * However the method returns success as otherwise the transport could not
-     * be reset for stub mode.
-     * Also, not all transport options supported in libunbound yet */
-    if (set_ub_dns_transport(context) != GETDNS_RETURN_GOOD) {
-        return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
-    }
-    dispatch_updated(context, GETDNS_CONTEXT_CODE_DNS_TRANSPORT);
-    return GETDNS_RETURN_GOOD;
+getdns_context_set_dns_transport(
+    getdns_context *context, getdns_transport_t value)
+{
+	size_t count = 2;
+	getdns_transport_list_t *new_transports;
+
+	if (value == GETDNS_TRANSPORT_UDP_ONLY ||
+	    value == GETDNS_TRANSPORT_TCP_ONLY ||
+	    value == GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN ||
+	    value == GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN)
+	    count = 1;
+
+	if (!context)
+		return GETDNS_RETURN_INVALID_PARAMETER;
+
+	if (!(new_transports = GETDNS_XMALLOC(
+			context->my_mf, getdns_transport_list_t, count)))
+	       return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
+
+	if (context->dns_transports)
+		GETDNS_FREE(context->my_mf, context->dns_transports);
+
+	context->dns_transport_count = count;
+	context->dns_transports = new_transports;
+
+	switch (value) {
+	    case GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP:
+	        context->dns_transports[0] = GETDNS_TRANSPORT_UDP;
+	        context->dns_transports[1] = GETDNS_TRANSPORT_TCP;
+	        break;
+	    case GETDNS_TRANSPORT_UDP_ONLY:
+	        context->dns_transports[0] = GETDNS_TRANSPORT_UDP;
+	        break;
+	    case GETDNS_TRANSPORT_TCP_ONLY:
+	    case GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN:
+	        context->dns_transports[0] = GETDNS_TRANSPORT_TCP;
+	        break;
+	    case GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN:
+	        context->dns_transports[0] = GETDNS_TRANSPORT_TLS;
+	        break;
+	    case GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN:
+	        context->dns_transports[0] = GETDNS_TRANSPORT_TLS;
+	        context->dns_transports[1] = GETDNS_TRANSPORT_TCP;
+	       break;
+	    case GETDNS_TRANSPORT_STARTTLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN:
+	        context->dns_transports[0] = GETDNS_TRANSPORT_STARTTLS;
+	        context->dns_transports[1] = GETDNS_TRANSPORT_TCP;
+	       break;
+	   default:
+	       return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
+	}
+	/* Note that the call below does not have any effect in unbound after the
+	 * ctx is finalised so for recursive mode or stub + dnssec only the first
+	 * transport specified on the first query is used.
+	 * However the method returns success as otherwise the transport could not
+	 * be reset for stub mode.
+	 * Also, not all transport options supported in libunbound yet */
+	if (set_ub_dns_transport(context) != GETDNS_RETURN_GOOD) {
+	    return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
+	}
+	dispatch_updated(context, GETDNS_CONTEXT_CODE_DNS_TRANSPORT);
+	return GETDNS_RETURN_GOOD;
 }

 /*
- * getdns_context_set_dns_transport
+ * getdns_context_set_dns_transport_list
  *
  */
 getdns_return_t
@@ -1354,7 +1368,7 @@
     }
     dispatch_updated(context, GETDNS_CONTEXT_CODE_DNS_TRANSPORT);
     return GETDNS_RETURN_GOOD;
-}               /* getdns_context_set_dns_transport */
+}               /* getdns_context_set_dns_transport_list */

 static void
 set_ub_limit_outstanding_queries(struct getdns_context* context, uint16_t value) {


Avoiding another warning when compiling with Gtk+ 3

--- src/compare.c
+++ src/compare.c
@@ -77,7 +77,11 @@
 	compare.label = gtk_label_new(" ");
 	gtk_misc_set_alignment(GTK_MISC(compare.label), 0.0, 0.5);
 	gtk_box_pack_start(GTK_BOX(vbox), compare.label, FALSE, TRUE, 0);
+#if GTK_CHECK_VERSION(3, 0, 0)
+	bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
+#else
 	bbox = gtk_hbutton_box_new();
+#endif
 	gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
 	widget = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
 	g_signal_connect_swapped(widget, "clicked", G_CALLBACK(


bugfix: too many calls to free()

bugfix: too many calls to free()

--- src/context.c
+++ src/context.c
@@ -374,18 +374,12 @@
     DEBUG_LOG(1,"Freeing context");

     if (context) {
-        int nranks, i;
-        ghost_nrank(&nranks, context->mpicomm);
-
-        for(i=0; i<nranks; i++) {
-            if (context->wishlist) {
-                free(context->wishlist[i]);
-            }
-            if (context->duelist) {
-                free(context->duelist[i]);
-            }
-        }
-
+        if (context->wishlist) {
+            free(context->wishlist[0]);
+        }
+        if (context->duelist) {
+            free(context->duelist[0]);
+        }
         free(context->wishlist);
         free(context->duelist);
         free(context->wishes);


Do not use delimiters when no values are saved

--- src/compile.c
+++ src/compile.c
@@ -18,10 +18,15 @@
         *pch = 0;
         if (strlen(line) <= 1)
             continue;
-        char *key = strtok(line, delimiter);
-        char *val = strtok(NULL, "\n");
-        if (with_content && !val)
-            continue;
+        char *key, *val = NULL;
+        if (with_content) {
+            key = strtok(line, delimiter);
+            val = strtok(NULL, "\n");
+            if (!val)
+                continue;
+        } else {
+            key = line;
+        }
         trie_insert(trie, key, val);
         ++count;
         if (isatty(STDOUT_FILENO) && (count % 1000) == 0) {


contest REFACTOR minor improvements

contest REFACTOR minor improvements

--- src/context.c
+++ src/context.c
@@ -189,7 +189,7 @@
 API const struct lys_module *
 ly_ctx_load_module(struct ly_ctx *ctx, const char *name, const char *revision, const char **features)
 {
-    struct lys_module *result = NULL;
+    struct lys_module *mod = NULL;
     struct lys_glob_unres unres = {0};
     LY_ERR ret = LY_SUCCESS;

@@ -227,13 +227,13 @@
     LY_CHECK_ARG_RET(NULL, new_ctx, LY_EINVAL);

     ctx = calloc(1, sizeof *ctx);
-    LY_CHECK_ERR_RET(!ctx, LOGMEM(NULL), LY_EMEM);
+    LY_CHECK_ERR_GOTO(!ctx, LOGMEM(NULL); rc = LY_EMEM, cleanup);

     /* dictionary */
     lydict_init(&ctx->dict);

     /* plugins */
-    LY_CHECK_ERR_RET(lyplg_init(), LOGINT(NULL), LY_EINT);
+    LY_CHECK_ERR_GOTO(lyplg_init(), LOGINT(NULL); rc = LY_EINT, cleanup);

     /* initialize thread-specific keys */
     while ((pthread_key_create(&ctx->errlist_key, ly_err_free)) == EAGAIN) {}
@@ -245,7 +245,7 @@
     ctx->flags = options;
     if (search_dir) {
         search_dir_list = strdup(search_dir);
-        LY_CHECK_ERR_GOTO(!search_dir_list, LOGMEM(NULL); rc = LY_EMEM, error);
+        LY_CHECK_ERR_GOTO(!search_dir_list, LOGMEM(NULL); rc = LY_EMEM, cleanup);

         for (dir = search_dir_list; (sep = strchr(dir, ':')) != NULL && rc == LY_SUCCESS; dir = sep + 1) {
             *sep = 0;
@@ -265,9 +265,7 @@
         free(search_dir_list);

         /* If ly_ctx_set_searchdir() failed, the error is already logged. Just exit */
-        if (rc != LY_SUCCESS) {
-            goto error;
-        }
+        LY_CHECK_GOTO(rc, cleanup);
     }
     ctx->change_count = 1;

@@ -278,26 +276,27 @@

     /* create dummy in */
     rc = ly_in_new_memory(internal_modules[0].data, &in);
-    LY_CHECK_GOTO(rc, error);
+    LY_CHECK_GOTO(rc, cleanup);

     /* load internal modules */
     for (i = 0; i < ((options & LY_CTX_NO_YANGLIBRARY) ? (LY_INTERNAL_MODS_COUNT - 2) : LY_INTERNAL_MODS_COUNT); i++) {
         ly_in_memory(in, internal_modules[i].data);
         LY_CHECK_GOTO(rc = lys_parse_in(ctx, in, internal_modules[i].format, NULL, NULL, &unres.creating, &module), cleanup);
         if (internal_modules[i].implemented || (ctx->flags & LY_CTX_ALL_IMPLEMENTED)) {
-            LY_CHECK_GOTO(rc = lys_implement(module, NULL, &unres), error);
+            LY_CHECK_GOTO(rc = lys_implement(module, NULL, &unres), cleanup);
         }
     }

     /* resolve global unres */
-    LY_CHECK_GOTO(rc = lys_compile_unres_glob(ctx, &unres), error);
+    LY_CHECK_GOTO(rc = lys_compile_unres_glob(ctx, &unres), cleanup);

     if (!(options & LY_CTX_EXPLICIT_COMPILE)) {
         /* compile now */
-        LY_CHECK_GOTO(rc = ly_ctx_compile(ctx), error);
+        LY_CHECK_GOTO(rc = ly_ctx_compile(ctx), cleanup);
         ctx->flags &= ~LY_CTX_EXPLICIT_COMPILE;
     }

+cleanup:
     ly_in_free(in, 0);
     lys_compile_unres_glob_erase(ctx, &unres, 0);
     if (rc) {


fixed license header

fixed license header

--- src/context.h
+++ src/context.h
@@ -1,32 +1,39 @@
 /**
  *
- * /brief getdns contect management functions
+ * /file
+ * /brief getdns context management functions
  *
- * This is the meat of the API
  * Originally taken from the getdns API description pseudo implementation.
  *
  */
-/* The MIT License (MIT)
- * Copyright (c) 2013 Verisign, Inc.
+
+/*
+ * Copyright (c) 2013, Versign, Inc.
+ * All rights reserved.
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of the <organization> nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 #ifndef _GETDNS_CONTEXT_H_
 #define _GETDNS_CONTEXT_H_


Set the widget for the frame label

Set the widget for the frame label

--- src/control.c
+++ src/control.c
@@ -99,6 +99,7 @@
 	gtk_misc_set_alignment(GTK_MISC(control->name), 0.0, 0.5);
 #endif
 	gtk_box_pack_start(GTK_BOX(hbox), control->name, TRUE, TRUE, 0);
+	gtk_frame_set_label_widget(GTK_FRAME(control->frame), hbox);
 	return control;
 }


Minor buf in nn_ep_init fixed

Minor buf in nn_ep_init fixed

Signed-off-by: Martin Sustrik <4dd6061be1198639e8b05ce4fd5ead7a0dcaa0f4@250bpm.com>

--- src/core/ep.c
+++ src/core/ep.c
@@ -45,8 +45,6 @@
 {
     int rc;

-    /*  TODO: Accessing sock's internal member is not nice. Can it be done
-        in a better way? */
     nn_fsm_init (&self->fsm, nn_ep_handler, &sock->fsm);
     self->state = NN_EP_STATE_IDLE;

@@ -75,6 +73,7 @@
     /*  Endpoint creation failed. */
     if (rc < 0) {
         nn_list_item_term (&self->item);
+        nn_fsm_term (&self->fsm);
         return rc;
     }


Cleanup

Cleanup

--- src/core/os.h
+++ src/core/os.h
@@ -14,14 +14,10 @@
 #include "temp_allocator.h"

 #if CROWN_PLATFORM_POSIX
-	#include <cstdarg>
-	#include <cstdio>
-	#include <cstdlib>
 	#include <dirent.h>
 	#include <dlfcn.h>
 	#include <sys/stat.h>
 	#include <sys/time.h>
-	#include <sys/types.h>
 	#include <sys/wait.h>
 	#include <errno.h>
 	#include <time.h>


src: re-add madvise(MADV_DONTNEED) in chunk unload

--- src/cowsync.c
+++ src/cowsync.c
@@ -116,6 +116,9 @@
 				if (munlock(ptr_dst - CHUNK_SIZE, CHUNK_SIZE) < 0) {
 					err(1, "munlock on dst failed @ %ldK", off / 1024);
 				}
+
+				madvise(ptr_src - CHUNK_SIZE, CHUNK_SIZE, MADV_DONTNEED);
+				madvise(ptr_dst - CHUNK_SIZE, CHUNK_SIZE, MADV_DONTNEED);
 			}

 			if (mlock(ptr_src, len_chunk) < 0) {


src/cpu/pic.c: removed debug functions removed debug functions

--- src/cpu/pic.c
+++ src/cpu/pic.c
@@ -1,4 +1,3 @@
-#include <tty/tty.h>
 #include <cpu/pic.h>

 #define PIC_MASTER_CMD  0x0020
@@ -43,7 +42,6 @@
 void pic_enable_irq(uint8_t irq)
 {
 	irq_mask = irq_mask & ~(1 << irq); // clear bit that the IRQ is on
-	tty_printf("irq_mask = %x\n", irq_mask);

 	if (irq >= 8) {
 		outb(PIC_SLAVE_DATA, IRQ_MASK_SLAVE);
@@ -55,7 +53,6 @@
 void pic_disable_irq(uint8_t irq)
 {
 	irq_mask |= (1 << irq); // set bit that the IRQ is on
-	tty_printf("irq_mask = %x\n", irq_mask);

 	if (irq >= 8) {
 		outb(PIC_SLAVE_DATA, IRQ_MASK_SLAVE);


Added mavl_get_count

Added mavl_get_count

FossilOrigin-Name: a244ddd86ce08778664f647f0825b4b41f9bd1f84570f9c6787dbccd4c7ae106

--- src/cw/mavl.h
+++ src/cw/mavl.h
@@ -211,7 +211,12 @@
 	while(NULL != (val = mavliter_next(iter)))

-
+/**
+ * Get the number of elements stored in a mavl object
+ * @param m mavl object
+ * @return Number of elemenst
+ */
+#define mavl_get_count(m) (m->count)

 typedef mavl_t mavl_conststr_t;
 extern mavl_conststr_t mavl_create_conststr();


Add static lib building support for Windows

--- src/confuse.h
+++ src/confuse.h
@@ -51,11 +51,15 @@
 # ifdef HAVE__ISATTY
 #  define isatty _isatty
 # endif
-# ifdef BUILDING_DLL
-#  define DLLIMPORT __declspec (dllexport)
-# else /* ! BUILDING_DLL */
-#  define DLLIMPORT __declspec (dllimport)
-# endif /* BUILDING_DLL */
+# ifdef BUILDING_STATIC
+#  define DLLIMPORT
+# else /* ! BUILDING_STATIC */
+#  ifdef BUILDING_DLL
+#   define DLLIMPORT __declspec (dllexport)
+#  else /* ! BUILDING_DLL */
+#   define DLLIMPORT __declspec (dllimport)
+#  endif /* BUILDING_DLL */
+# endif /* BUILDING_STATIC */
 #else /* ! _WIN32 || __GNUC__ */
 # define DLLIMPORT
 #endif /* _WIN32 */


context: fix test for systeminfo_handler

Signed-off-by: Enrico Jorns <a2e5f936c390f36494e46e71bcfbe365bb1e8c49@pengutronix.de>

--- src/context.c
+++ src/context.c
@@ -90,7 +90,7 @@

 	}

-	if (&context->config->systeminfo_handler &&
+	if (context->config->systeminfo_handler &&
 		g_file_test(context->config->systeminfo_handler, G_FILE_TEST_EXISTS)) {

 		GError *ierror = NULL;


Added inlining for all functions

Added inlining for all functions

--- src/context.c
+++ src/context.c
@@ -41,17 +41,17 @@

 #include "context.h"

-spookyhash_context* spookyhash_context_allocate(void *(*mem_alloc)(size_t)) {
+SPOOKYHASH_FORCE_INLINE spookyhash_context* spookyhash_context_allocate(void *(*mem_alloc)(size_t)) {
     void *(*memory_alloc)(size_t) = mem_alloc == NULL ? malloc : mem_alloc;
     return (spookyhash_context *) memory_alloc(sizeof(spookyhash_context));
 }

-void spookyhash_context_free(spookyhash_context* context, void (*mem_free)(void *)) {
+SPOOKYHASH_FORCE_INLINE void spookyhash_context_free(spookyhash_context* context, void (*mem_free)(void *)) {
     void (*memory_free)(void *) = mem_free == NULL ? free : mem_free;
     memory_free(context);
 }

-void spookyhash_context_init(spookyhash_context *context, uint_fast64_t seed1, uint_fast64_t seed2) {
+SPOOKYHASH_FORCE_INLINE void spookyhash_context_init(spookyhash_context *context, uint_fast64_t seed1, uint_fast64_t seed2) {
     context->m_length = 0;
     context->m_remainder = 0;
     context->m_state[0] = seed1;


Renamed TOKENPASTE to CONCAT.

Renamed TOKENPASTE to CONCAT.

--- src/counter.h
+++ src/counter.h
@@ -41,8 +41,8 @@

 } // namespace counter

-#define TOKENPASTE2(x, y) x ## y
-#define TOKENPASTE(x, y) TOKENPASTE2(x, y)
+#define CONCAT2(x, y) x ## y
+#define CONCAT(x, y) CONCAT2(x, y)

 #define CURRENT_COUNTER_IMPL(T, FUNCTION)                   \
     decltype(FUNCTION(counter::Counter<255, T>{}))::value   \
@@ -52,8 +52,8 @@

 #define INC_COUNTER(T)                                                                                \
     namespace counter {                                                                                \
-    constexpr auto TOKENPASTE(value_, __LINE__) = CURRENT_COUNTER(T);                                       \
-    Counter<TOKENPASTE(value_, __LINE__) + 1, T> __counter(Counter<TOKENPASTE(value_, __LINE__) + 1, T>);   \
+    constexpr auto CONCAT(value_, __LINE__) = CURRENT_COUNTER(T);                                       \
+    Counter<CONCAT(value_, __LINE__) + 1, T> __counter(Counter<CONCAT(value_, __LINE__) + 1, T>);   \
     } /* namespace counter */                                                                               \

 #define CURRENT_CLASS_COUNTER()                                 \
@@ -64,9 +64,9 @@
         })                                                      \

 #define INC_CLASS_COUNTER()                                                                     \
-    static constexpr auto TOKENPASTE(value_, __LINE__) = CURRENT_CLASS_COUNTER();               \
-    static constexpr auto __class_counter(counter::Counter<TOKENPASTE(value_, __LINE__) + 1>)   \
-        -> counter::Counter<TOKENPASTE(value_, __LINE__) + 1>                                   \
+    static constexpr auto CONCAT(value_, __LINE__) = CURRENT_CLASS_COUNTER();               \
+    static constexpr auto __class_counter(counter::Counter<CONCAT(value_, __LINE__) + 1>)   \
+        -> counter::Counter<CONCAT(value_, __LINE__) + 1>                                   \
     {                                                                                \
         return {};                                                                              \
     }                                                                                \


disable graph rebuilding on shape removal when the contact graph is not enabled

--- src/cpSpace.c
+++ src/cpSpace.c
@@ -386,9 +386,11 @@

 		cpBodyRemoveShape(body, shape);

-		arbiterRemovalContext context = {space, shape};
-		cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)arbiterSetFilterRemovedShape, &context);
 		cpSpatialIndexRemove(space->activeShapes, shape, shape->hashid);
+		if(space->sleepTimeThreshold != INFINITY || space->enableContactGraph){
+		  arbiterRemovalContext context = {space, shape};
+		  cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)arbiterSetFilterRemovedShape, &context);
+		}
 	}
 }

@@ -401,9 +403,11 @@

 //	cpBodyRemoveShape(shape->body, shape);

-	arbiterRemovalContext context = {space, shape};
-	cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)arbiterSetFilterRemovedShape, &context);
 	cpSpatialIndexRemove(space->staticShapes, shape, shape->hashid);
+	if(space->sleepTimeThreshold != INFINITY || space->enableContactGraph){
+	  arbiterRemovalContext context = {space, shape};
+	  cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)arbiterSetFilterRemovedShape, &context);
+	}

 	cpSpaceActivateShapesTouchingShape(space, shape);
 }


In ieee80211_node_leave(), clear the associd after calling
ieee80211_node_leave_rsn() since ieee80211_node_leave_rsn()
calls ic_delete_key() and drivers like ral(4) RT2860 need
a valid associd in their delete_key callbacks.
This affects HostAP mode only.

from Nathanael Rensen.

remove a useless (nested) #ifndef IEEE80211_STA_ONLY while i'm here

--- net80211/ieee80211_node.c
+++ net80211/ieee80211_node.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: ieee80211_node.c,v 1.59 2010/06/14 17:51:43 damien Exp $	*/
+/*	$OpenBSD: ieee80211_node.c,v 1.60 2010/06/19 08:33:50 damien Exp $	*/
 /*	$NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $	*/

 /*-
@@ -1434,10 +1434,9 @@
 	ni->ni_flags &= ~IEEE80211_NODE_PMK;
 	ni->ni_rsn_gstate = RSNA_IDLE;

-#ifndef IEEE80211_STA_ONLY
 	timeout_del(&ni->ni_eapol_to);
 	timeout_del(&ni->ni_sa_query_to);
-#endif
+
 	ni->ni_rsn_retries = 0;
 	ni->ni_flags &= ~IEEE80211_NODE_TXRXPROT;
 	ni->ni_port_valid = 0;
@@ -1505,13 +1504,11 @@
 	if (ic->ic_opmode != IEEE80211_M_HOSTAP)
 		panic("not in ap mode, mode %u", ic->ic_opmode);
 	/*
-	 * If node wasn't previously associated all
-	 * we need to do is reclaim the reference.
+	 * If node wasn't previously associated all we need to do is
+	 * reclaim the reference.
 	 */
 	if (ni->ni_associd == 0)
 		return;
-	IEEE80211_AID_CLR(ni->ni_associd, ic->ic_aid_bitmap);
-	ni->ni_associd = 0;

 	if (ni->ni_pwrsave == IEEE80211_PS_DOZE)
 		ic->ic_pssta--;
@@ -1527,6 +1524,8 @@
 		ieee80211_node_leave_ht(ic, ni);
 #endif

+	IEEE80211_AID_CLR(ni->ni_associd, ic->ic_aid_bitmap);
+	ni->ni_associd = 0;
 	ieee80211_node_newstate(ni, IEEE80211_STA_COLLECT);

 #if NBRIDGE > 0


Version.h: show the right URL for our page

--- src/Version.h
+++ src/Version.h
@@ -34,6 +34,6 @@
 #define VERSION_WEBPAGEDISPLAY       L"flo's freeware - http://www.flos-freeware.ch"
 #define VERSION_EMAILDISPLAY         L"florian.balmer@gmail.com"
 #define VERSION_COMPANYNAME          L"Florian Balmer et al."
-#define VERSION_MODPAGEDISPLAY       L"https://github.com/XhmikosR/notepad2-mod"
+#define VERSION_MODPAGEDISPLAY       L"http://xhmikosr.github.com/notepad2-mod/"

 #endif // NOTEPAD2_VERSION_H


includes vendors.h now

includes vendors.h now

FossilOrigin-Name: db3b640e8eb161ed99abd906ffbcb05f3b7b301f5a8ce89204c5797d7169b2d8

--- src/ac/conf.h
+++ src/ac/conf.h
@@ -30,6 +30,7 @@
 #include "cw/lwapp.h"
 #include "cw/bstr.h"
 #include "cw/mod.h"
+#include "cw/vendors.h"

 extern struct mod_ac * conf_mods[10];


Oops, don't need that printf

Oops, don't need that printf

--- src/actions.c
+++ src/actions.c
@@ -1092,7 +1092,7 @@

    exe = (char *) a->params;
    if(!exe) return;
-   printf("exe: %s\n",exe);
+   /* printf("exe: %s\n",exe); */
    e_exec_run(exe);
    return;
    UN(a);


adapter_up() cleanup

adapter_up() cleanup

--- src/adapter.c
+++ src/adapter.c
@@ -2520,53 +2520,49 @@
 		adapter->pairable = TRUE;

 	/* Set scan mode */
-	if (read_device_mode(srcaddr, mode, sizeof(mode)) == 0) {
-		if (!strcmp(mode, "off")) {
-			if (main_opts.offmode == HCID_OFFMODE_NOSCAN) {
-				adapter->mode = MODE_OFF;
-				adapter->scan_mode= SCAN_DISABLED;
-			} else if (main_opts.offmode == HCID_OFFMODE_DEVDOWN) {
-				static gboolean restore_on_mode = FALSE;
-
-				if (!restore_on_mode) {
-					ioctl(dd, HCIDEVDOWN, adapter->dev_id);
-					restore_on_mode = TRUE;
-					return;
-				}
-
-				if (read_on_mode(srcaddr, mode, sizeof(mode)) < 0)
-					write_device_mode(&adapter->bdaddr, mode);
-				else
-					write_device_mode(&adapter->bdaddr, "connectable");
-
-				adapter_up(adapter, dd);
+	if (read_device_mode(srcaddr, mode, sizeof(mode)) < 0) {
+		adapter->mode = MODE_CONNECTABLE;
+		adapter->scan_mode = SCAN_PAGE;
+		goto proceed;
+	}
+
+	if (!strcmp(mode, "off")) {
+		if (main_opts.offmode == HCID_OFFMODE_NOSCAN) {
+			adapter->mode = MODE_OFF;
+			adapter->scan_mode= SCAN_DISABLED;
+		} else if (main_opts.offmode == HCID_OFFMODE_DEVDOWN) {
+			static gboolean restore_on_mode = FALSE;
+
+			if (!restore_on_mode) {
+				ioctl(dd, HCIDEVDOWN, adapter->dev_id);
+				restore_on_mode = TRUE;
+				return;
 			}
-		} else if (!strcmp(mode, "connectable")) {
+
+			if (read_on_mode(srcaddr, mode, sizeof(mode)) < 0)
+				write_device_mode(&adapter->bdaddr, mode);
+			else
+				write_device_mode(&adapter->bdaddr,
+							"connectable");
+
+			adapter_up(adapter, dd);
+		}
+	} else if (!strcmp(mode, "connectable")) {
+		adapter->mode = MODE_CONNECTABLE;
+		adapter->scan_mode = SCAN_PAGE;
+	} else {
+		/* Set discoverable only if timeout is 0 */
+		if (adapter->discov_timeout == 0) {
+			adapter->mode = adapter->pairable ?
+					MODE_LIMITED : MODE_DISCOVERABLE;
+			adapter->scan_mode = SCAN_PAGE | SCAN_INQUIRY;
+		} else {
 			adapter->mode = MODE_CONNECTABLE;
 			adapter->scan_mode = SCAN_PAGE;
-		} else if (!strcmp(mode, "discoverable")) {
-			/* Set discoverable only if timeout is 0 */
-			if (adapter->discov_timeout == 0) {
-				adapter->mode = adapter->pairable ?
-					MODE_LIMITED : MODE_DISCOVERABLE;
-				adapter->scan_mode = SCAN_PAGE | SCAN_INQUIRY;
-			} else {
-				adapter->mode = MODE_CONNECTABLE;
-				adapter->scan_mode = SCAN_PAGE;
-			}
-		} else if (!strcmp(mode, "limited")) {
-			/* Set discoverable only if timeout is 0 */
-			if (adapter->discov_timeout == 0) {
-				adapter->mode = MODE_LIMITED;
-				adapter->scan_mode = SCAN_PAGE | SCAN_INQUIRY;
-			} else {
-				adapter->mode = MODE_CONNECTABLE;
-				adapter->scan_mode = SCAN_PAGE;
-
-			}
 		}
 	}

+proceed:
 	hci_send_cmd(dd, OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE,
 					1, &adapter->scan_mode);


core: Separate adapter name property from alias

--- src/adapter.c
+++ src/adapter.c
@@ -194,10 +194,6 @@

 	key_file = g_key_file_new();

-	if (adapter->stored_name)
-		g_key_file_set_string(key_file, "General", "Name",
-							adapter->stored_name);
-
 	g_key_file_set_boolean(key_file, "General", "Pairable",
 				adapter->pairable);

@@ -216,6 +212,10 @@
 		g_key_file_set_integer(key_file, "General",
 					"DiscoverableTimeout",
 					adapter->discov_timeout);
+
+	if (adapter->stored_name)
+		g_key_file_set_string(key_file, "General", "Alias",
+							adapter->stored_name);

 	ba2str(&adapter->bdaddr, address);
 	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/settings", address);
@@ -549,37 +549,20 @@

 void adapter_name_changed(struct btd_adapter *adapter, const char *name)
 {
-	if (g_strcmp0(adapter->name, name) == 0)
-		return;
-
-	g_free(adapter->name);
-	adapter->name = g_strdup(name);
-
-	if (adapter->allow_name_changes == TRUE) {
-		DBG("updating stored name");
-
-		g_free(adapter->stored_name);
-		adapter->stored_name = g_strdup(adapter->name);
-
-		store_adapter_info(adapter);
-	}
-
 	g_dbus_emit_property_changed(btd_get_dbus_connection(), adapter->path,
-						ADAPTER_INTERFACE, "Name");
+						ADAPTER_INTERFACE, "Alias");

 	attrib_gap_set(adapter, GATT_CHARAC_DEVICE_NAME,
 				(const uint8_t *) name, strlen(name));
 }

-int adapter_set_name(struct btd_adapter *adapter, const char *name)
+static int set_name(struct btd_adapter *adapter, const char *name)
 {
 	char maxname[MAX_NAME_LENGTH + 1];
-
-	if (g_strcmp0(adapter->name, name) == 0)
-		return 0;

 	memset(maxname, 0, sizeof(maxname));
 	strncpy(maxname, name, MAX_NAME_LENGTH);
+
 	if (!g_utf8_validate(maxname, -1, NULL)) {
 		error("Name change failed: supplied name isn't valid UTF-8");
 		return -EINVAL;
@@ -588,27 +571,25 @@
 	return mgmt_set_name(adapter->dev_id, maxname);
 }

-static void set_name(struct btd_adapter *adapter, const char *name,
-						GDBusPendingPropertySet id)
-{
-	int ret;
-
-	if (adapter->allow_name_changes == FALSE)
-		return g_dbus_pending_property_error(id,
-						ERROR_INTERFACE ".Failed",
-						strerror(EPERM));
-
-	ret = adapter_set_name(adapter, name);
-	if (ret >= 0)
-		return g_dbus_pending_property_success(id);
-
-	if (ret == -EINVAL)
-		g_dbus_pending_property_error(id,
-					ERROR_INTERFACE ".InvalidArguments",
-					"Invalid arguments in method call");
-	else
-		g_dbus_pending_property_error(id, ERROR_INTERFACE ".Failed",
-							strerror(-ret));
+int adapter_set_name(struct btd_adapter *adapter, const char *name)
+{
+	if (g_strcmp0(adapter->name, name) == 0)
+		return 0;
+
+	g_free(adapter->name);
+	adapter->name = g_strdup(name);
+
+	g_dbus_emit_property_changed(btd_get_dbus_connection(), adapter->path,
+						ADAPTER_INTERFACE, "Name");
+
+	/* alias is preferred over system name */
+	if (adapter->stored_name)
+		return 0;
+
+	g_dbus_emit_property_changed(btd_get_dbus_connection(), adapter->path,
+						ADAPTER_INTERFACE, "Alias");
+
+	return set_name(adapter, name);
 }

 struct btd_device *adapter_find_device(struct btd_adapter *adapter,
@@ -947,16 +928,60 @@
 					DBusMessageIter *value,
 					GDBusPendingPropertySet id, void *data)
 {
+	struct btd_adapter *adapter = data;
 	const char *name;
-
-	if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_STRING)
-		return g_dbus_pending_property_error(id,
+	int ret;
+
+	if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_STRING) {
+		g_dbus_pending_property_error(id,
 					ERROR_INTERFACE ".InvalidArguments",
 					"Invalid arguments in method call");
+		return;
+	}

 	dbus_message_iter_get_basic(value, &name);

-	set_name(data, name, id);
+	if (g_str_equal(name, "")  == TRUE) {
+		if (adapter->stored_name == NULL) {
+			/* no alias set, nothing to restore */
+			g_dbus_pending_property_success(id);
+			return;
+		}
+
+		/* restore to system name */
+		ret = set_name(adapter, adapter->name);
+	} else {
+		if (g_strcmp0(adapter->stored_name, name) == 0) {
+			/* alias already set, nothing to do */
+			g_dbus_pending_property_success(id);
+			return;
+		}
+
+		/* set to alias */
+		ret = set_name(adapter, name);
+	}
+
+	if (ret >= 0) {
+		g_free(adapter->stored_name);
+
+		if (g_str_equal(name, "")  == TRUE)
+			adapter->stored_name = NULL;
+		else
+			adapter->stored_name = g_strdup(name);
+
+		store_adapter_info(adapter);
+
+		g_dbus_pending_property_success(id);
+		return;
+	}
+
+	if (ret == -EINVAL)
+		g_dbus_pending_property_error(id,
+					ERROR_INTERFACE ".InvalidArguments",
+					"Invalid arguments in method call");
+	else
+		g_dbus_pending_property_error(id, ERROR_INTERFACE ".Failed",
+							strerror(-ret));
 }

 static gboolean adapter_property_get_class(const GDBusPropertyTable *property,
@@ -2571,9 +2596,6 @@
 		free(converted);
 	}

-	if (read_local_name(&adapter->bdaddr, str) == 0)
-		g_key_file_set_string(key_file, "General", "Name", str);
-
 	if (read_device_pairable(&adapter->bdaddr, &flag) == 0)
 		g_key_file_set_boolean(key_file, "General", "Pairable", flag);

@@ -2590,6 +2612,9 @@
 		g_key_file_set_boolean(key_file, "General", "Discoverable",
 					mode == MODE_DISCOVERABLE);
 	}
+
+	if (read_local_name(&adapter->bdaddr, str) == 0)
+		g_key_file_set_string(key_file, "General", "Alias", str);

 	create_file(filename, S_IRUSR | S_IWUSR);

@@ -2618,10 +2643,14 @@
 	if (!g_key_file_load_from_file(key_file, filename, 0, NULL))
 		convert_config(adapter, filename, key_file);

-	/* Get name */
+	/* Get alias */
 	adapter->stored_name = g_key_file_get_string(key_file, "General",
-								"Name", NULL);
-	adapter->name = g_strdup(adapter->stored_name);
+								"Alias", NULL);
+	if (!adapter->stored_name) {
+		/* fallback */
+		adapter->stored_name = g_key_file_get_string(key_file,
+						"General", "Name", NULL);
+	}

 	/* Set class */
 	adapter->dev_class = main_opts.class;


Fix response on adapter RequestSession method

Fixes response on adapter RequestSession method to be sent after mode is
changed, if such is necessary. More specifically, change of power off
mode to power on is in question.

Currently response is sent when mode change is confirmed by agent, not
by response from controller. Such may lead to failed CreateDevice method
if it is called quickly enough after RequestSession when controller is
in powered off state.

New session is not created if there is already a session for such D-Bus
message.

--- src/adapter.c
+++ src/adapter.c
@@ -452,6 +452,20 @@
 	return 0;
 }

+static struct session_req *find_session_by_msg(GSList *list, const DBusMessage *msg)
+{
+	GSList *l;
+
+	for (l = list; l; l = l->next) {
+		struct session_req *req = l->data;
+
+		if (req->msg == msg)
+			return req;
+	}
+
+	return NULL;
+}
+
 static int set_mode(struct btd_adapter *adapter, uint8_t new_mode,
 			DBusMessage *msg)
 {
@@ -496,11 +510,18 @@

 	DBG("%s", modestr);

-	if (msg != NULL)
-		/* Wait for mode change to reply */
-		adapter->pending_mode = create_session(adapter, connection,
-							msg, new_mode, NULL);
-	else
+	if (msg != NULL) {
+		struct session_req *req;
+
+		req = find_session_by_msg(adapter->mode_sessions, msg);
+		if (req) {
+			adapter->pending_mode = req;
+			session_ref(req);
+		} else
+			/* Wait for mode change to reply */
+			adapter->pending_mode = create_session(adapter,
+					connection, msg, new_mode, NULL);
+	} else
 		/* Nothing to reply just write the new mode */
 		adapter->mode = new_mode;

@@ -795,16 +816,25 @@
 		return;
 	}

-	err = set_mode(req->adapter, req->mode, NULL);
+	err = set_mode(req->adapter, req->mode, req->msg);
 	if (err < 0)
 		reply = btd_error_failed(req->msg, strerror(-err));
+	else if (!req->adapter->pending_mode)
+		reply = dbus_message_new_method_return(req->msg);
 	else
-		reply = dbus_message_new_method_return(req->msg);
-
-	g_dbus_send_message(req->conn, reply);
-
-	dbus_message_unref(req->msg);
-	req->msg = NULL;
+		reply = NULL;
+
+	if (reply) {
+		/*
+		 * Send reply immediately only if there was an error changing
+		 * mode, or change is not needed. Otherwise, reply is sent in
+		 * set_mode_complete.
+		 */
+		g_dbus_send_message(req->conn, reply);
+
+		dbus_message_unref(req->msg);
+		req->msg = NULL;
+	}

 	if (!find_session(req->adapter->mode_sessions, req->owner))
 		session_unref(req);


fix length conversion in add_tlv

fix length conversion in add_tlv

--- src/dazibao.c
+++ src/dazibao.c
@@ -141,6 +141,7 @@
 		}
                 buf->length = (tlv_length[0] << 16) + (tlv_length[1] << 8)
                                 + tlv_length[2];
+/*		printf("buf->length is %u", buf->length);*/
 		if (lseek(d->fd, buf->length, SEEK_CUR) == -1) {
                         ERROR("next_tlv lseek next_tlv", -1);
                 }
@@ -206,14 +207,24 @@
         }

-        union {
-                char t[3];
-                int i:24;
-        } len;
-        len.i = src->length;
-
-
-        if (write(d->fd, len.t, TLV_SIZEOF_LENGTH) != TLV_SIZEOF_LENGTH){
+	/* FIXME: write it better */
+	/*
+	 * the problem is that if we do not use a union with char[4]/int
+	 * then the less significant byte will be skipped
+	 * (on little endian machine, at least)
+	 * whereas we have to skip the most significant one
+	 * assuming that sizeof(int) is 4, this following hack is correct
+	 * assuming it is not, it is not...
+	 */
+	union {
+		unsigned int i;
+		unsigned char c[4];
+	} tmp;
+
+	/* convert to big endian */
+	tmp.i = htonl(src->length);
+
+        if (write(d->fd, &tmp.c[1], TLV_SIZEOF_LENGTH) != TLV_SIZEOF_LENGTH){
                 ERROR("add_tlv write tlv_length",-1);
         }


Remove leftover field in remote_dev_info struct

Field "bdaddr_type" of the remote_dev_info structure is not being
referenced in the code. Field "type" is already being used to store
the Bluetooth address type.

--- src/adapter.h
+++ src/adapter.h
@@ -78,7 +78,6 @@
 	char **uuids;
 	size_t uuid_count;
 	GSList *services;
-	uint8_t bdaddr_type;
 	uint8_t flags;
 };


Add Q_OBJECT macro to QSpiAdaptor so subclass meta objects will be correct.   * Fixes many failed calls to invokeMethod in accessible_adaptor.cpp.

--- src/adaptor.h
+++ src/adaptor.h
@@ -29,11 +29,12 @@
 /*
  * Implements all methods neccessary to adapt calls from AT-SPI to the
  * QAccessibleInterface.
- *
+ *
  */

 class QSpiAdaptor : public QSpiObject
 {
+    Q_OBJECT
 public:
     QSpiAdaptor (QSpiAccessibleCache  *cache,
                  QAccessibleInterface *interface):QSpiObject (cache, interface) {}


Removed unnecessary lookup

Removed unnecessary lookup

The lookup value is the same as the index.  The index in this
case is either a 0 or 1.

Change-Id: I0432dfcbea9e7bb20bca7574e25fb1fd8a51c8e9

--- src/dec/vp8.c
+++ src/dec/vp8.c
@@ -462,7 +462,7 @@
 // (and 0 if there's no coeff at all)
 static int GetCoeffs(VP8BitReader* const br, ProbaArray prob,
                      int ctx, const quant_t dq, int n, int16_t* out) {
-  const uint8_t* p = prob[kBands[n]][ctx];
+  const uint8_t* p = prob[n][ctx];  // n is either 0 or 1 here. kBands[n] is not necessary.
   if (!VP8GetBit(br, p[0])) {   // first EOB is more a 'CBP' bit.
     return 0;
   }


Add output flushing in decoder

Add output flushing in decoder

--- src/decoder.c
+++ src/decoder.c
@@ -392,6 +392,7 @@
 			}
 			fprintf(fout, "\n");
 		}
+		fflush(fout);
 		// If user provided reference labels, use them to collect
 		// statistics about how well we have performed here.
 		if (mdl->opt->check) {


Update to projected aperture field name

Update to projected aperture field name

Typo fixed.

--- src/allvars.h
+++ src/allvars.h
@@ -3807,7 +3807,7 @@
         }
         if (opt.iaperturecalc>0 && opt.apertureprojnum>0) {
             for (auto k=0;k<3;k++) {
-            string projname = "Projected_apeture_"+to_string(k+1)+"_";
+            string projname = "Projected_aperture_"+to_string(k+1)+"_";
             for (auto i=0; i<opt.apertureprojnum;i++)
                 headerdatainfo.push_back(projname+string("mass_")+opt.aperture_proj_names_kpc[i]+string("_kpc"));
 #ifdef GASON


Better error message

Better error message

--- src/desfire.h
+++ src/desfire.h
@@ -176,7 +176,7 @@
               continue;
             } else if(res) {
               uv_mutex_unlock(&m_reader->mDevice);
-              throw errorResult(m_info, 0x12303, "Can't conntect to Mifare DESFire target.", error());
+              throw errorResult(m_info, 0x12303, errorString(), error(), "Can't conntect to Mifare DESFire target.");
               break;
             } else {
               break;


Update to aperture io

Update to aperture io

--- src/allvars.h
+++ src/allvars.h
@@ -1560,7 +1560,7 @@
 #ifdef GASON
         aperture_npart_gas=p.aperture_npart_gas;
         aperture_mass_gas=p.aperture_mass_gas;
-#ifdef STARON
+#ifdef STARON
         aperture_npart_gas_sf=p.aperture_npart_gas_sf;
         aperture_npart_gas_nsf=p.aperture_npart_gas_nsf;
         aperture_mass_gas_sf=p.aperture_mass_gas_sf;
@@ -2784,7 +2784,7 @@
         //if aperture information calculated also include
         if (opt.iaperturecalc>0) {
             for (auto i=0; i<opt.aperturenum;i++) {
-                headerdatainfo.push_back((string("npart_")+opt.aperture_names_kpc[i]+string("_kpc")));
+                headerdatainfo.push_back((string("Aperture_npart_")+opt.aperture_names_kpc[i]+string("_kpc")));
 #ifdef USEHDF
                 predtypeinfo.push_back(PredType::STD_U64LE);
 #endif
@@ -2793,7 +2793,7 @@
 #endif
             }
             for (auto i=0; i<opt.aperturenum;i++) {
-                headerdatainfo.push_back((string("mass_")+opt.aperture_names_kpc[i]+string("_kpc")));
+                headerdatainfo.push_back((string("Aperture_mass_")+opt.aperture_names_kpc[i]+string("_kpc")));
 #ifdef USEHDF
                 predtypeinfo.push_back(desiredproprealtype[0]);
 #endif
@@ -2802,82 +2802,82 @@
 #endif
             }
 #ifdef GASON
-        for (auto i=0; i<opt.aperturenum;i++) {
-            headerdatainfo.push_back((string("npart_gas_")+opt.aperture_names_kpc[i]+string("_kpc")));
-#ifdef USEHDF
-            predtypeinfo.push_back(PredType::STD_U64LE);
-#endif
-#ifdef USEADIOS
-            adiospredtypeinfo.push_back(ADIOS_DATATYPES::adios_unsigned_long);
-#endif
-        }
-        for (auto i=0; i<opt.aperturenum;i++) {
-            headerdatainfo.push_back((string("mass_gas_")+opt.aperture_names_kpc[i]+string("_kpc")));
-#ifdef USEHDF
-            predtypeinfo.push_back(desiredproprealtype[0]);
-#endif
-#ifdef USEADIOS
-            adiospredtypeinfo.push_back(desiredadiosproprealtype[0]);
-#endif
-        }
+            for (auto i=0; i<opt.aperturenum;i++) {
+                headerdatainfo.push_back((string("Aperture_npart_gas_")+opt.aperture_names_kpc[i]+string("_kpc")));
+#ifdef USEHDF
+                predtypeinfo.push_back(PredType::STD_U64LE);
+#endif
+#ifdef USEADIOS
+                adiospredtypeinfo.push_back(ADIOS_DATATYPES::adios_unsigned_long);
+#endif
+            }
+            for (auto i=0; i<opt.aperturenum;i++) {
+                headerdatainfo.push_back((string("Aperture_mass_gas_")+opt.aperture_names_kpc[i]+string("_kpc")));
+#ifdef USEHDF
+                predtypeinfo.push_back(desiredproprealtype[0]);
+#endif
+#ifdef USEADIOS
+                adiospredtypeinfo.push_back(desiredadiosproprealtype[0]);
+#endif
+            }
 #ifdef STARON
-        for (auto i=0; i<opt.aperturenum;i++) {
-            headerdatainfo.push_back((string("npart_gas_sf_")+opt.aperture_names_kpc[i]+string("_kpc")));
-#ifdef USEHDF
-            predtypeinfo.push_back(PredType::STD_U64LE);
-#endif
-#ifdef USEADIOS
-            adiospredtypeinfo.push_back(ADIOS_DATATYPES::adios_unsigned_long);
-#endif
-        }
-        for (auto i=0; i<opt.aperturenum;i++) {
-            headerdatainfo.push_back((string("mass_gas_sf_")+opt.aperture_names_kpc[i]+string("_kpc")));
-#ifdef USEHDF
-            predtypeinfo.push_back(desiredproprealtype[0]);
-#endif
-#ifdef USEADIOS
-            adiospredtypeinfo.push_back(desiredadiosproprealtype[0]);
-#endif
-        }
-        for (auto i=0; i<opt.aperturenum;i++) {
-            headerdatainfo.push_back((string("npart_gas_nsf_")+opt.aperture_names_kpc[i]+string("_kpc")));
-#ifdef USEHDF
-            predtypeinfo.push_back(PredType::STD_U64LE);
-#endif
-#ifdef USEADIOS
-            adiospredtypeinfo.push_back(ADIOS_DATATYPES::adios_unsigned_long);
-#endif
-        }
-        for (auto i=0; i<opt.aperturenum;i++) {
-            headerdatainfo.push_back((string("mass_gas_nsf_")+opt.aperture_names_kpc[i]+string("_kpc")));
-#ifdef USEHDF
-            predtypeinfo.push_back(desiredproprealtype[0]);
-#endif
-#ifdef USEADIOS
-            adiospredtypeinfo.push_back(desiredadiosproprealtype[0]);
-#endif
-        }
+            for (auto i=0; i<opt.aperturenum;i++) {
+                headerdatainfo.push_back((string("Aperture_npart_gas_sf_")+opt.aperture_names_kpc[i]+string("_kpc")));
+#ifdef USEHDF
+                predtypeinfo.push_back(PredType::STD_U64LE);
+#endif
+#ifdef USEADIOS
+                adiospredtypeinfo.push_back(ADIOS_DATATYPES::adios_unsigned_long);
+#endif
+            }
+            for (auto i=0; i<opt.aperturenum;i++) {
+                headerdatainfo.push_back((string("Aperture_mass_gas_sf_")+opt.aperture_names_kpc[i]+string("_kpc")));
+#ifdef USEHDF
+                predtypeinfo.push_back(desiredproprealtype[0]);
+#endif
+#ifdef USEADIOS
+                adiospredtypeinfo.push_back(desiredadiosproprealtype[0]);
+#endif
+            }
+            for (auto i=0; i<opt.aperturenum;i++) {
+                headerdatainfo.push_back((string("Aperture_npart_gas_nsf_")+opt.aperture_names_kpc[i]+string("_kpc")));
+#ifdef USEHDF
+                predtypeinfo.push_back(PredType::STD_U64LE);
+#endif
+#ifdef USEADIOS
+                adiospredtypeinfo.push_back(ADIOS_DATATYPES::adios_unsigned_long);
+#endif
+            }
+            for (auto i=0; i<opt.aperturenum;i++) {
+                headerdatainfo.push_back((string("Aperture_mass_gas_nsf_")+opt.aperture_names_kpc[i]+string("_kpc")));
+#ifdef USEHDF
+                predtypeinfo.push_back(desiredproprealtype[0]);
+#endif
+#ifdef USEADIOS
+                adiospredtypeinfo.push_back(desiredadiosproprealtype[0]);
+#endif
+            }
 #endif
 #endif
 #ifdef STARON
-        for (auto i=0; i<opt.aperturenum;i++) {
-            headerdatainfo.push_back((string("npart_star_")+opt.aperture_names_kpc[i]+string("_kpc")));
-#ifdef USEHDF
-            predtypeinfo.push_back(PredType::STD_U64LE);
-#endif
-#ifdef USEADIOS
-            adiospredtypeinfo.push_back(ADIOS_DATATYPES::adios_unsigned_long);
-#endif
-        }
-        for (auto i=0; i<opt.aperturenum;i++) {
-            headerdatainfo.push_back((string("mass_star_")+opt.aperture_names_kpc[i]+string("_kpc")));
-#ifdef USEHDF
-            predtypeinfo.push_back(desiredproprealtype[0]);
-#endif
-#ifdef USEADIOS
-            adiospredtypeinfo.push_back(desiredadiosproprealtype[0]);
-#endif
-        }
+            for (auto i=0; i<opt.aperturenum;i++) {
+                headerdatainfo.push_back((string("Aperture_npart_star_")+opt.aperture_names_kpc[i]+string("_kpc")));
+#ifdef USEHDF
+                predtypeinfo.push_back(PredType::STD_U64LE);
+#endif
+#ifdef USEADIOS
+                adiospredtypeinfo.push_back(ADIOS_DATATYPES::adios_unsigned_long);
+#endif
+            }
+            for (auto i=0; i<opt.aperturenum;i++) {
+                headerdatainfo.push_back((string("Aperture_mass_star_")+opt.aperture_names_kpc[i]+string("_kpc")));
+#ifdef USEHDF
+                predtypeinfo.push_back(desiredproprealtype[0]);
+#endif
+#ifdef USEADIOS
+                adiospredtypeinfo.push_back(desiredadiosproprealtype[0]);
+#endif
+            }
 #endif
         }
     }


Fewer warnings during compilation

Fewer warnings during compilation

--- src/desktop.c
+++ src/desktop.c
@@ -289,12 +289,12 @@
 		char const * label, GCallback callback, DesktopIcon * icon,
 		GtkWidget * menu);
 /* callbacks */
-static void _on_icon_open(GtkWidget * widget, gpointer data);
-static void _on_icon_edit(GtkWidget * widget, gpointer data);
-static void _on_icon_run(GtkWidget * widget, gpointer data);
-static void _on_icon_open_with(GtkWidget * widget, gpointer data);
-static void _on_icon_delete(GtkWidget * widget, gpointer data);
-static void _on_icon_properties(GtkWidget * widget, gpointer data);
+static void _on_icon_open(gpointer data);
+static void _on_icon_edit(gpointer data);
+static void _on_icon_run(gpointer data);
+static void _on_icon_open_with(gpointer data);
+static void _on_icon_delete(gpointer data);
+static void _on_icon_properties(gpointer data);

 static gboolean _on_icon_button_press(GtkWidget * widget,
 		GdkEventButton * event, gpointer data)
@@ -313,7 +313,7 @@
 	}
 	if(event->type == GDK_2BUTTON_PRESS && event->button == 1)
 	{
-		_on_icon_open(widget, desktopicon);
+		_on_icon_open(desktopicon);
 		return FALSE;
 	}
 	if(event->type != GDK_BUTTON_PRESS || event->button != 3)
@@ -326,14 +326,14 @@
 	menuitem = gtk_separator_menu_item_new();
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE, NULL);
-	g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(
+	g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(
 				_on_icon_delete), desktopicon);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 	menuitem = gtk_separator_menu_item_new();
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 	menuitem = gtk_image_menu_item_new_from_stock(
 			GTK_STOCK_PROPERTIES, NULL);
-	g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(
+	g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(
 				_on_icon_properties), desktopicon);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 	gtk_widget_show_all(menu);
@@ -346,7 +346,7 @@
 	GtkWidget * menuitem;

 	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, NULL);
-	g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(
+	g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(
 				_on_icon_open), desktopicon);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 }
@@ -369,12 +369,12 @@
 	{
 		menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_EXECUTE,
 				NULL);
-		g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(
-					_on_icon_run), desktopicon);
+		g_signal_connect_swapped(G_OBJECT(menuitem), "activate",
+				G_CALLBACK(_on_icon_run), desktopicon);
 		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 	}
 	menuitem = gtk_menu_item_new_with_mnemonic("Open _with...");
-	g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(
+	g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(
 				_on_icon_open_with), desktopicon);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 }
@@ -391,11 +391,12 @@
 		menuitem = gtk_image_menu_item_new_from_stock(label, NULL);
 	else
 		menuitem = gtk_menu_item_new_with_mnemonic(label);
-	g_signal_connect(G_OBJECT(menuitem), "activate", callback, desktopicon);
+	g_signal_connect_swapped(G_OBJECT(menuitem), "activate", callback,
+			desktopicon);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 }

-static void _on_icon_open(GtkWidget * widget, gpointer data)
+static void _on_icon_open(gpointer data)
 {
 	DesktopIcon * desktopicon = data;
 	pid_t pid;
@@ -405,7 +406,7 @@
 		if(desktopicon->desktop->mime != NULL) /* XXX ugly */
 			if(mime_action(desktopicon->desktop->mime, "open",
 					desktopicon->path) != 0)
-				_on_icon_open_with(widget, desktopicon);
+				_on_icon_open_with(desktopicon);
 		return;
 	}
 	if((pid = fork()) == -1)
@@ -420,14 +421,14 @@
 	exit(127);
 }

-static void _on_icon_edit(GtkWidget * widget, gpointer data)
+static void _on_icon_edit(gpointer data)
 {
 	DesktopIcon * desktopicon = data;

 	mime_action(desktopicon->desktop->mime, "edit", desktopicon->path);
 }

-static void _on_icon_run(GtkWidget * widget, gpointer data)
+static void _on_icon_run(gpointer data)
 {
 	DesktopIcon * desktopicon = data;
 	GtkWidget * dialog;
@@ -454,7 +455,7 @@
 	}
 }

-static void _on_icon_open_with(GtkWidget * widget, gpointer data)
+static void _on_icon_open_with(gpointer data)
 {
 	DesktopIcon * desktopicon = data;
 	GtkWidget * dialog;
@@ -483,7 +484,7 @@
 	g_free(filename);
 }

-static void _on_icon_delete(GtkWidget * widget, gpointer data)
+static void _on_icon_delete(gpointer data)
 {
 	DesktopIcon * desktopicon = data;

@@ -491,7 +492,7 @@
 	desktop_icon_remove(desktopicon->desktop, desktopicon);
 }

-static void _on_icon_properties(GtkWidget * widget, gpointer data)
+static void _on_icon_properties(gpointer data)
 {
 	DesktopIcon * desktopicon = data;
 	pid_t pid;
@@ -812,10 +813,10 @@
 static GdkFilterReturn _event_button_press(XButtonEvent * xbev,
 		Desktop * desktop);
 static GdkFilterReturn _event_expose(XExposeEvent * xevent, Desktop * desktop);
-static void _on_popup_new_folder(GtkWidget * widget, gpointer data);
-static void _on_popup_new_text_file(GtkWidget * widget, gpointer data);
-static void _on_popup_paste(GtkWidget * widget, gpointer data);
-static void _on_popup_preferences(GtkWidget * widget, gpointer data);
+static void _on_popup_new_folder(gpointer data);
+static void _on_popup_new_text_file(gpointer data);
+static void _on_popup_paste(gpointer data);
+static void _on_popup_preferences(gpointer data);

 static GdkFilterReturn _new_on_root_event(GdkXEvent * xevent, GdkEvent * event,
 		gpointer data)
@@ -858,7 +859,7 @@
 	menuitem = gtk_image_menu_item_new_with_label("Folder");
 	image = gtk_image_new_from_icon_name("folder-new", GTK_ICON_SIZE_MENU);
 	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
-	g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(
+	g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(
 				_on_popup_new_folder), desktop);
 	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
 	menuitem = gtk_separator_menu_item_new();
@@ -867,14 +868,14 @@
 	image = gtk_image_new_from_icon_name("stock_new-text",
 			GTK_ICON_SIZE_MENU);
 	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
-	g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(
+	g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(
 				_on_popup_new_text_file), desktop);
 	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
 	/* edition */
 	menuitem = gtk_separator_menu_item_new();
 	gtk_menu_shell_append(GTK_MENU_SHELL(desktop->menu), menuitem);
 	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_PASTE, NULL);
-	g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(
+	g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(
 				_on_popup_paste), desktop);
 	gtk_menu_shell_append(GTK_MENU_SHELL(desktop->menu), menuitem);
 	/* preferences */
@@ -882,7 +883,7 @@
 	gtk_menu_shell_append(GTK_MENU_SHELL(desktop->menu), menuitem);
 	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES,
 			NULL);
-	g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(
+	g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(
 				_on_popup_preferences), desktop);
 	gtk_menu_shell_append(GTK_MENU_SHELL(desktop->menu), menuitem);
 	gtk_widget_show_all(desktop->menu);
@@ -904,7 +905,7 @@
 	return GDK_FILTER_CONTINUE;
 }

-static void _on_popup_new_folder(GtkWidget * widget, gpointer data)
+static void _on_popup_new_folder(gpointer data)
 {
 	static char const newfolder[] = "New folder";
 	Desktop * desktop = data;
@@ -924,7 +925,7 @@
 	free(path);
 }

-static void _on_popup_new_text_file(GtkWidget * widget, gpointer data)
+static void _on_popup_new_text_file(gpointer data)
 {
 	static char const newtext[] = "New text file.txt";
 	Desktop * desktop = data;
@@ -946,7 +947,7 @@
 	free(path);
 }

-static void _on_popup_paste(GtkWidget * widget, gpointer data)
+static void _on_popup_paste(gpointer data)
 {
 	Desktop * desktop = data;

@@ -955,7 +956,7 @@
 	desktop->menu = NULL;
 }

-static void _on_popup_preferences(GtkWidget * widget, gpointer data)
+static void _on_popup_preferences(gpointer data)
 {
 	Desktop * desktop = data;


Added the original c-code for accessing GPIO2 via memmap.

error: pathspec 'experiments/memmap_programming/memmap_programming.c' did not match any file(s) known to git

--- experiments/memmap_programming/memmap_programming.c
+++ experiments/memmap_programming/memmap_programming.c
@@ -0,0 +1,183 @@
+//
+// BeagleBone Black HDMI Cape must be disabled.  Follow the article below.
+//
+// http://www.logicsupply.com/blog/2013/07/18/disabling-the-beaglebone-black-hdmi-cape/
+// Disabling the BeagleBone Black HDMI Cape
+// The HDMI port on the BeagleBone Black is implemented as a virtual cape. This virtual cape uses pins on the
+// expansion headers, limiting the available pins. If you don’t need HDMI you gain 20 more GPIO pins by disabling
+// the HDMI cape. Other reasons for disabling HDMI are to make UART 5 and the flow control for UART 3 and 4
+// available or to get more PWM pins. Follow the instructions below to disable the HDMI cape and make pins 27 to 46
+// on header P8 available.
+//
+// Before you start, it’s always a good idea to update your BeagleBone Black with the latest Angstrom image.
+// Use SSH to connect to the BeagleBone Black. You can use the web based GateOne SSH client or use PuTTY and connect
+// to beaglebone.local or 192.168.7.2
+//
+// user name: root
+// password: <enter>
+//
+// Mount the FAT partition:
+// mount /dev/mmcblk0p1  /mnt/card
+//
+// Edit the uEnv.txt on the mounted partition:
+// nano /mnt/card/uEnv.txt
+//
+// To disable the HDMI Cape, change the contents of uEnv.txt to:
+// optargs=quiet capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN
+//
+// Save the file:
+// Ctrl-X, Y
+//
+// Unmount the partition:
+// umount /mnt/card
+//
+// Reboot the board:
+// shutdown -r now
+//
+// Wait about 10 seconds and reconnect to the BeagleBone Black through SSH. To see what capes are enabled:
+// cat /sys/devices/bone_capemgr.*/slots
+//
+// #
+// # Original slots setting
+// #
+// root@beaglebone:/media# cat /sys/devices/bone_capemgr.9/slots
+//  0: 54:PF---
+//  1: 55:PF---
+//  2: 56:PF---
+//  3: 57:PF---
+//  4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
+//  5: ff:P-O-L Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
+//
+// #
+// # Should look like below after turning off the HDMI cape
+// #
+// root@beaglebone:/media# cat /sys/devices/bone_capemgr.9/slots
+//  0: 54:PF---
+//  1: 55:PF---
+//  2: 56:PF---
+//  3: 57:PF---
+//  4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
+//  5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
+//
+// #
+// # Actual slots image after turning off the HDMI
+// #
+//  0: 54:PF---
+//  1: 55:PF---
+//  2: 56:PF---
+//  3: 57:PF---
+//  4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
+//  5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
+//  6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
+//
+// Every line shows something like “P-O-L” or “P-O–”. The letter “L” means the Cape is enabled; no letter “L” means
+// that it is disabled. You can see here that the HDMI Cape has been disabled, so pin 27 to 46 on header P8 are now
+// available to use.
+//
+//     Call the ruby code to enable the following pins to :OUT mode
+//     GPIOPin.new(:P8_29, :OUT) # Strobe pin
+//     GPIOPin.new(:P8_27, :OUT) # RdNWr pin - Read on high (Read not Write on high)
+//
+//     The pins below are the address pins
+//     GPIOPin.new(:P8_37, :OUT)
+//     GPIOPin.new(:P8_38, :OUT)
+//     GPIOPin.new(:P8_36, :OUT)
+//     GPIOPin.new(:P8_34, :OUT)
+//
+//     Call the ruby code to enable the following pins to :IN mode
+//     The pins below are the data bus pins
+//     @bbb_data0 = GPIOPin.new(:P8_45, :IN)
+//     @bbb_data1 = GPIOPin.new(:P8_46, :IN)
+//     @bbb_data2 = GPIOPin.new(:P8_43, :IN)
+//     @bbb_data3 = GPIOPin.new(:P8_44, :IN)
+//     @bbb_data4 = GPIOPin.new(:P8_41, :IN)
+//     @bbb_data5 = GPIOPin.new(:P8_42, :IN)
+//     @bbb_data6 = GPIOPin.new(:P8_39, :IN)
+//     @bbb_data7 = GPIOPin.new(:P8_40, :IN)
+//
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h> // sleep
+
+#define GPIO_DATAOUT 0x13C
+#define GPIO_SETDATAOUT 0x194
+#define GPIO_CLEARDATAOUT 0x190
+#define GPIO_OE 0x134
+#define GPIO_DATAIN 0x138
+
+int dataBusMask = 0xff<<6;
+int AddrShift = 14;
+int DataShift = 6;
+#define GPIO2_START_ADDR 0x481AC000 /*0x44e108a4*/
+#define GPIO2_END_ADDR   0x481AE000  /*0x44e10800 */
+#define GPIO2_SIZE (GPIO2_END_ADDR - GPIO2_START_ADDR)
+
+#define Strobe (1<<23) /*pin 22 for strobe*/
+#define RdnWr (1<<22) // Read on High
+
+volatile void *gpio_addr;
+volatile unsigned int *gpio_AddrData_OE; // gpio_OE
+volatile unsigned int *gpio_AddrData_DataOut;
+volatile unsigned int *gpio_AddrData_DataIn;
+
+void sendToDevice(int *addr,int *data){
+    int dataHold;
+    dataHold = 0; // Flush buffer.
+
+    dataHold |= *addr<<AddrShift;
+    dataHold |= *data<<DataShift;
+
+    *gpio_AddrData_OE = 0; // All output is on...
+    *gpio_AddrData_DataOut = dataHold;
+    *gpio_AddrData_DataOut ^= Strobe; // The "write pulte"
+}
+
+int  getFromDevice(int *addr){
+    int toBeReturned;
+    int dataHold;
+    dataHold = 0; // Flush buffer.
+    dataHold |= *addr<<AddrShift;
+    dataHold |= RdnWr;  // Extra op with no value...
+    *gpio_AddrData_OE = 0; // All output is on...
+    *gpio_AddrData_OE ^= dataBusMask; // It just needs it.
+    *gpio_AddrData_DataOut = dataHold;
+
+    toBeReturned = 0x000ff&*gpio_AddrData_DataIn>>DataShift;
+    *gpio_AddrData_DataOut ^= RdnWr;
+    // toBeReturned = 0x00ff&&(toBeReturned>>6);
+    // printf("oe=%08x data %08x\n",*gpio_AddrData_OE,toBeReturned);
+    return toBeReturned;
+}
+
+
+
+void main (void) {
+    int testCase = 0;
+    int addr = 0;
+    int data = 0;
+    int strobe = 0;
+    int fd = open("/dev/mem", O_RDWR);
+    gpio_addr = mmap(0, GPIO2_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, GPIO2_START_ADDR);
+    gpio_AddrData_OE = gpio_addr+GPIO_OE; // Sets the strobe register to output.
+    gpio_AddrData_DataOut = gpio_addr+GPIO_DATAOUT;
+    gpio_AddrData_DataIn = gpio_addr+GPIO_DATAIN;
+
+    *gpio_AddrData_DataOut = Strobe;
+    while (1) {
+
+        if (data<255) data++;
+        else data = 0;
+
+        if (addr<15) addr++;
+        else addr = 0;
+
+        sendToDevice(&addr,&data);
+        // sleep(1);
+        testCase = getFromDevice(&addr);
+
+        // printf("data %08x\n",testCase);
+        // sleep(1);
+    }
+        // End of 'void main (void)'
+}