Downgrade log message: refcnt file may not exist

If kernel doesn't have support to unload modules,
/sys/module/<modname>/refcnt will not exist and that's ok.

Reported by: Sven Anders <anders@anduras.de>

--- libkmod/libkmod-module.c
+++ libkmod/libkmod-module.c
@@ -1749,7 +1749,7 @@
 	fd = open(path, O_RDONLY|O_CLOEXEC);
 	if (fd < 0) {
 		err = -errno;
-		ERR(mod->ctx, "could not open '%s': %s\n",
+		DBG(mod->ctx, "could not open '%s': %s\n",
 			path, strerror(errno));
 		return err;
 	}


All the environment will be passed by socket

Now all the environment is sent via a socket to
the wallet, so there is no need to set this even
if we have them in PAM.

--- pam_kwallet.c
+++ pam_kwallet.c
@@ -214,20 +214,6 @@
         goto cleanup;
     }

-    int result = set_env(pamh, "HOME", userInfo->pw_dir);
-    if (result < 0) {
-        pam_syslog(pamh, LOG_ERR, "pam_kwallet: Impossible to set home env");
-        goto cleanup;
-    }
-
-    const char *display = get_env(pamh, "DISPLAY");
-    if (!display) {
-        pam_syslog(pamh, LOG_ERR, "pam_kwallet: Impossible to get DISPLAY env, kwallet will crash...");
-        goto cleanup;
-    }
-
-    //Set in pam as well
-    result = set_env(pamh, "DISPLAY", display);
     if (result != PAM_SUCCESS) {
         pam_syslog(pamh, LOG_ERR, "pam_kwallet: Impossible to set DISPLAY env, %s", pam_strerror(pamh, result));
         goto cleanup;


Update buffer.c

Update buffer.c

--- src/buffer.c
+++ src/buffer.c
@@ -1,3 +1,6 @@
+#ifndef DBMS_BUFFER
+#define DBMS_BUFFER
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -82,3 +85,4 @@
         fclose(tp->db_file);
         free(tp);
 }
+#endif // DBMS_BUFFER


param: report open failure

param: report open failure

--- src/systemcmds/param/param.c
+++ src/systemcmds/param/param.c
@@ -244,7 +244,7 @@
 	int fd = open(param_file_name, O_RDONLY);

 	if (fd < 0) {
-		warn("open '%s'", param_file_name);
+		warn("open failed '%s'", param_file_name);
 		return 1;
 	}


Don't cast an int * to a size_t *

Don't cast an int * to a size_t *

If sizeof(int) != sizeof(size_t) this may not work correctly.

Fixes a Coverity issue.

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

--- apps/speed.c
+++ apps/speed.c
@@ -600,6 +600,7 @@
     unsigned char *buf2_malloc;
     unsigned char *key;
     unsigned int siglen;
+    size_t sigsize;
 #ifndef OPENSSL_NO_RSA
     RSA *rsa_key[RSA_NUM];
 #endif
@@ -1185,11 +1186,11 @@
     unsigned char *buf = tempargs->buf;
     EVP_MD_CTX **edctx = tempargs->eddsa_ctx;
     unsigned char *eddsasig = tempargs->buf2;
-    unsigned int *eddsasiglen = &tempargs->siglen;
+    size_t *eddsasigsize = &tempargs->sigsize;
     int ret, count;

     for (count = 0; COND(eddsa_c[testnum][0]); count++) {
-        ret = EVP_DigestSign(edctx[testnum], eddsasig, (size_t *)eddsasiglen, buf, 20);
+        ret = EVP_DigestSign(edctx[testnum], eddsasig, eddsasigsize, buf, 20);
         if (ret == 0) {
             BIO_printf(bio_err, "EdDSA sign failure\n");
             ERR_print_errors(bio_err);
@@ -1206,11 +1207,11 @@
     unsigned char *buf = tempargs->buf;
     EVP_MD_CTX **edctx = tempargs->eddsa_ctx;
     unsigned char *eddsasig = tempargs->buf2;
-    unsigned int eddsasiglen = tempargs->siglen;
+    size_t eddsasigsize = tempargs->sigsize;
     int ret, count;

     for (count = 0; COND(eddsa_c[testnum][1]); count++) {
-        ret = EVP_DigestVerify(edctx[testnum], eddsasig, eddsasiglen, buf, 20);
+        ret = EVP_DigestVerify(edctx[testnum], eddsasig, eddsasigsize, buf, 20);
         if (ret != 1) {
             BIO_printf(bio_err, "EdDSA verify failure\n");
             ERR_print_errors(bio_err);
@@ -1525,7 +1526,7 @@
         const char *name;
         unsigned int nid;
         unsigned int bits;
-        unsigned int siglen;
+        size_t sigsize;
     } test_ed_curves[] = {
         /* EdDSA */
         {"Ed25519", NID_ED25519, 253, 64},
@@ -3101,9 +3102,9 @@
         } else {
             for (i = 0; i < loopargs_len; i++) {
                 /* Perform EdDSA signature test */
-                loopargs[i].siglen = test_ed_curves[testnum].siglen;
+                loopargs[i].sigsize = test_ed_curves[testnum].sigsize;
                 st = EVP_DigestSign(loopargs[i].eddsa_ctx[testnum],
-                                    loopargs[i].buf2, (size_t *)&loopargs[i].siglen,
+                                    loopargs[i].buf2, &loopargs[i].sigsize,
                                     loopargs[i].buf, 20);
                 if (st == 0)
                     break;
@@ -3133,7 +3134,7 @@
             /* Perform EdDSA verification test */
             for (i = 0; i < loopargs_len; i++) {
                 st = EVP_DigestVerify(loopargs[i].eddsa_ctx[testnum],
-                                      loopargs[i].buf2, loopargs[i].siglen,
+                                      loopargs[i].buf2, loopargs[i].sigsize,
                                       loopargs[i].buf, 20);
                 if (st != 1)
                     break;


Create functions.h

Create functions.h

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

--- clock_step_motor_TSI/functions.h
+++ clock_step_motor_TSI/functions.h
@@ -0,0 +1,52 @@
+/*
+ * functions.h
+ *
+ * Created: 06-Nov-14 0:21:55
+ *  Author: 4a4ik
+ */
+
+
+#ifndef FUNCTIONS_H_
+#define FUNCTIONS_H_
+
+#define F_CPU 8000000UL
+
+#include <avr/io.h>
+#include <util/delay.h>
+#include <avr/interrupt.h>
+#include <string.h>
+#include <stdlib.h>
+#include <avr/eeprom.h>
+
+void IrDA_init();
+void irDA_read_eeprom();
+void irDA_update_eeprom();
+
+
+//--------------display--------------//
+
+void send();
+void write_symbol( char a );
+void write_number( int a );
+void write_text( const char *s );
+void initialize( int _2_line );
+void set_mode( int display_shift, int right );
+void enable_display( int display_on, int cursor_on, int blinking_on );
+void return_cursor();
+void clear_display();
+void move_cursor( int x_pos, int line );
+void lcd_init();
+
+//MOTOR
+void motor_step(char clockwise, unsigned char number );
+
+
+#define max_signal_length 40
+#define max_numbers 10
+
+#define number_already_recorded 1
+
+extern unsigned char signal[max_numbers][max_signal_length];
+
+
+#endif /* FUNCTIONS_H_ */


gro: more generic L2 header check

gro: more generic L2 header check

Shlomo Pongratz reported GRO L2 header check was suited for Ethernet
only, and failed on IB/ipoib traffic.

He provided a patch faking a zeroed header to let GRO aggregates frames.

Roland Dreier, Herbert Xu, and others suggested we change GRO L2 header
check to be more generic, ie not assuming L2 header is 14 bytes, but
taking into account hard_header_len.

__napi_gro_receive() has special handling for the common case (Ethernet)
to avoid a memcmp() call and use an inline optimized function instead.

Signed-off-by: Eric Dumazet <a0baddf32b28d2f9429941ed4af2fe636e210591@gmail.com>
Reported-by: Shlomo Pongratz <1f86d81346d2409d459cb27f2332519909807c77@mellanox.com>
Cc: Roland Dreier <0d270388f2f92757a5de0f4bd891d3b392c44c4f@kernel.org>
Cc: Or Gerlitz <de1b678a59344538ef9f2ddb34a5f9486544e2f9@mellanox.com>
Cc: Herbert Xu <ef65de1c7be0aa837fe7b25ba9a7739905af6a55@gondor.apana.org.au>
Tested-by: Sean Hefty <9575f92314b8ac7581ac1b2afb880058b7fbd431@intel.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/core/dev.c
+++ net/core/dev.c
@@ -3491,14 +3491,20 @@
 __napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
 {
 	struct sk_buff *p;
+	unsigned int maclen = skb->dev->hard_header_len;

 	for (p = napi->gro_list; p; p = p->next) {
 		unsigned long diffs;

 		diffs = (unsigned long)p->dev ^ (unsigned long)skb->dev;
 		diffs |= p->vlan_tci ^ skb->vlan_tci;
-		diffs |= compare_ether_header(skb_mac_header(p),
-					      skb_gro_mac_header(skb));
+		if (maclen == ETH_HLEN)
+			diffs |= compare_ether_header(skb_mac_header(p),
+						      skb_gro_mac_header(skb));
+		else if (!diffs)
+			diffs = memcmp(skb_mac_header(p),
+				       skb_gro_mac_header(skb),
+				       maclen);
 		NAPI_GRO_CB(p)->same_flow = !diffs;
 		NAPI_GRO_CB(p)->flush = 0;
 	}


Simplify loop when checking search for address

Rather than checking record length repeatedly this sets function pointers once
and then uses them in the loop.

--- libmaxminddb/MMDB_Core.c
+++ libmaxminddb/MMDB_Core.c
@@ -49,6 +49,8 @@
                               in_addr_any *in_addr);
 LOCAL int find_address_in_search_tree(MMDB_s *mmdb, uint8_t *address,
                                       MMDB_lookup_result_s *res);
+LOCAL uint32_t get_left_28_bit_record(const uint8_t *record);
+LOCAL uint32_t get_right_28_bit_record(const uint8_t *record);
 LOCAL void populate_description_metadata(MMDB_s *mmdb);
 LOCAL int read_metadata(MMDB_s *mmdb, uint8_t *metadata_content, ssize_t size);
 LOCAL uint32_t value_for_key_as_uint32(MMDB_entry_s *start, char *key);
@@ -215,47 +217,59 @@
     const uint8_t *search_tree = mmdb->file_in_mem_ptr;
     const uint8_t *record_pointer;
     uint32_t max_depth0 = mmdb->depth - 1;
-    uint32_t offset = 0;
+    uint32_t value = 0;
+
+    uint32_t (*left_record_value)(const uint8_t *);
+    uint32_t (*right_record_value)(const uint8_t *);
+    uint8_t right_record_offset;
+
+    if (record_length == 6) {
+        left_record_value = &get_uint24;
+        right_record_value = &get_uint24;
+        right_record_offset = 3;
+    } else if (record_length == 7) {
+        left_record_value = &get_left_28_bit_record;
+        right_record_value = &get_right_28_bit_record;
+        right_record_offset = 3;
+    } else if (record_length == 8) {
+        left_record_value = &get_uint32;
+        right_record_value = &get_uint32;
+        right_record_offset = 4;
+    }

     for (uint32_t current_bit = max_depth0; current_bit >= 0; current_bit--) {
-        record_pointer = &search_tree[offset * record_length];
-        if (record_length == 6) {
-            if (address[(max_depth0 - current_bit) >> 3] &
-                (1U << (~(max_depth0 - current_bit) & 7))) {
-
-                record_pointer += 3;
-            }
-            offset = get_uint24(record_pointer);
-        } else if (record_length == 7) {
-            if (address[(max_depth0 - current_bit) >> 3] &
-                (1U << (~(max_depth0 - current_bit) & 7))) {
-
-                record_pointer += 3;
-                offset = get_uint32(record_pointer);
-                offset &= 0xfffffff;
-            } else {
-                offset =
-                    record_pointer[0] * 65536 + record_pointer[1] * 256 +
-                    record_pointer[2] + ((record_pointer[3] & 0xf0) << 20);
-            }
-        } else if (record_length == 8) {
-            if (address[(max_depth0 - current_bit) >> 3] &
-                (1U << (~(max_depth0 - current_bit) & 7))) {
-
-                record_pointer += 4;
-            }
-            offset = get_uint32(record_pointer);
-        }
-
-        if (offset >= node_count) {
+        record_pointer = &search_tree[value * record_length];
+        if (address[(max_depth0 - current_bit) >> 3] &
+            (1U << (~(max_depth0 - current_bit) & 7))) {
+
+            record_pointer += right_record_offset;
+            value = right_record_value(record_pointer);
+        }
+        else {
+            value = left_record_value(record_pointer);
+        }
+
+        if (value >= node_count) {
             res->netmask = mmdb->depth - current_bit;
-            res->entry.offset = offset - node_count;
+            res->entry.offset = value - node_count;
             return MMDB_SUCCESS;
         }
     }

     // We should not be able to reach this return. If we do, something very bad happened.
     return MMDB_CORRUPT_DATABASE;
+}
+
+LOCAL uint32_t get_left_28_bit_record(const uint8_t *record)
+{
+    return record[0] * 65536 + record[1] * 256 + record[2] +
+        ((record[3] & 0xf0) << 20);
+}
+
+LOCAL uint32_t get_right_28_bit_record(const uint8_t *record)
+{
+    uint32_t value = get_uint32(record);
+    return value & 0xfffffff;
 }

 int MMDB_lookup_by_ipnum_128(struct in6_addr ipnum,


Improved commandline hints

Improved commandline hints

--- apps/multirotor_att_control/multirotor_att_control_main.c
+++ apps/multirotor_att_control/multirotor_att_control_main.c
@@ -189,7 +189,7 @@
 {
 	if (reason)
 		fprintf(stderr, "%s\n", reason);
-	fprintf(stderr, "usage: multirotor_att_control [-m <mode>] [-t] {start|stop}\n");
+	fprintf(stderr, "usage: multirotor_att_control [-m <mode>] [-t] {start|status|stop}\n");
 	fprintf(stderr, "    <mode> is 'rates' or 'attitude'\n");
 	fprintf(stderr, "    -t enables motor test mode with 10%% thrust\n");
 	exit(1);


added first interface for flood fill

added first interface for flood fill

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

--- src/logic/MazeAlgorithm.h
+++ src/logic/MazeAlgorithm.h
@@ -0,0 +1,15 @@
+#ifndef MAZE_ALGORITHM_H
+#define MAZE_ALGORITHM_H
+
+#include "define.h"
+#include "MazeMap.h"
+#include "Robot.h"
+
+typedef int[MAZE_HEIGHT][MAZE_WIDTH] ff_map;
+
+// flood fill algorithms
+void malgo_floodfill_compute(int targetX, targetY, MazeMap *mm, ff_map *in);
+void malgo_floodfill_recompute_target(int targetX, int targetY, ff_map *in);
+void malgo_floodfill_make_move(int xPos, int yPos, ff_map *map);
+
+#endif


net: WARN if skb_checksum_help() is called on skb requiring segmentation

skb_checksum_help() has never done anything useful with skbs that
require segmentation.  Setting skb->ip_summed = CHECKSUM_NONE makes
them invalid and provokes a later WARNing in skb_gso_segment().

Passing such an skb to skb_checksum_help() indicates a bug, so we
should warn about it immediately.  Move the warning from
skb_gso_segment() into a shared function, and add gso_type and
gso_size to it.

Signed-off-by: Ben Hutchings <0672176982fbc629cc374f31a7a45ae1671abf90@solarflare.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/core/dev.c
+++ net/core/dev.c
@@ -1887,6 +1887,22 @@
 EXPORT_SYMBOL(skb_set_dev);
 #endif /* CONFIG_NET_NS */

+static void skb_warn_bad_offload(const struct sk_buff *skb)
+{
+	struct net_device *dev = skb->dev;
+	const char *driver = "";
+
+	if (dev && dev->dev.parent)
+		driver = dev_driver_string(dev->dev.parent);
+
+	WARN(1, "%s: caps=(%pNF, %pNF) len=%d data_len=%d gso_size=%d "
+	     "gso_type=%d ip_summed=%d\n",
+	     driver, dev ? &dev->features : NULL,
+	     skb->sk ? &skb->sk->sk_route_caps : NULL,
+	     skb->len, skb->data_len, skb_shinfo(skb)->gso_size,
+	     skb_shinfo(skb)->gso_type, skb->ip_summed);
+}
+
 /*
  * Invalidate hardware checksum when packet is to be mangled, and
  * complete checksum manually on outgoing path.
@@ -1900,8 +1916,8 @@
 		goto out_set_summed;

 	if (unlikely(skb_shinfo(skb)->gso_size)) {
-		/* Let GSO fix up the checksum. */
-		goto out_set_summed;
+		skb_warn_bad_offload(skb);
+		return -EINVAL;
 	}

 	offset = skb_checksum_start_offset(skb);
@@ -1961,16 +1977,7 @@
 	__skb_pull(skb, skb->mac_len);

 	if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) {
-		struct net_device *dev = skb->dev;
-		const char *driver = "";
-
-		if (dev && dev->dev.parent)
-			driver = dev_driver_string(dev->dev.parent);
-
-		WARN(1, "%s: caps=(%pNF, %pNF) len=%d data_len=%d ip_summed=%d\n",
-		     driver, dev ? &dev->features : NULL,
-		     skb->sk ? &skb->sk->sk_route_caps : NULL,
-		     skb->len, skb->data_len, skb->ip_summed);
+		skb_warn_bad_offload(skb);

 		if (skb_header_cloned(skb) &&
 		    (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))


Increase the size of the buffer for the version string

--- libmemcached/memcached.h
+++ libmemcached/memcached.h
@@ -34,7 +34,7 @@
 #endif

 /* These are Private and should not be used by applications */
-#define MEMCACHED_VERSION_STRING_LENGTH 12
+#define MEMCACHED_VERSION_STRING_LENGTH 24

 /* string value */
 struct memcached_continuum_item_st {


Limited Z-compensation much stronger to prevent throttle jumps

--- apps/multirotor_att_control/multirotor_attitude_control.c
+++ apps/multirotor_att_control/multirotor_attitude_control.c
@@ -252,15 +252,15 @@
 	 */
 	float zcompensation = 1.0f;

-	if (fabsf(att->roll) > 1.0f) {
-		zcompensation *= 1.85081571768f;
+	if (fabsf(att->roll) > 0.3f) {
+		zcompensation *= 1.04675160154f;

 	} else {
 		zcompensation *= 1.0f / cosf(att->roll);
 	}

-	if (fabsf(att->pitch) > 1.0f) {
-		zcompensation *= 1.85081571768f;
+	if (fabsf(att->pitch) > 0.3f) {
+		zcompensation *= 1.04675160154f;

 	} else {
 		zcompensation *= 1.0f / cosf(att->pitch);


Remove redundant assert

Remove redundant assert

--- src/lv_widgets/lv_chart.c
+++ src/lv_widgets/lv_chart.c
@@ -636,7 +636,6 @@
  */
 uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser)
 {
-    LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
     LV_ASSERT_NULL(ser);

     return(ser->start_point);


added missing \file parma.h

added missing \file parma.h

--- parma/parma.h
+++ parma/parma.h
@@ -7,6 +7,8 @@

 #ifndef PARMA_H
 #define PARMA_H
+
+/** \file parma.h */

 #include "apf.h"
 #include "apfPartition.h"


[NET]: split dev_ifsioc() according to locking

This always bugged me: dev_ioctl() called dev_ifsioc() either inside
read_lock(dev_base_lock) or rtnl_lock(), depending on the ioctl being
executed.

This change moves the ioctls executed inside dev_base_lock to a new
function, dev_ifsioc_locked().  Now the locking context is completely
clear to the reader.

Signed-off-by: Jeff Garzik <15f615bf7d20c2937c7eb5aa759110fd6768848c@redhat.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/core/dev.c
+++ net/core/dev.c
@@ -3083,9 +3083,9 @@
 }

 /*
- *	Perform the SIOCxIFxxx calls.
- */
-static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
+ *	Perform the SIOCxIFxxx calls, inside read_lock(dev_base_lock)
+ */
+static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cmd)
 {
 	int err;
 	struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
@@ -3098,24 +3098,14 @@
 			ifr->ifr_flags = dev_get_flags(dev);
 			return 0;

-		case SIOCSIFFLAGS:	/* Set interface flags */
-			return dev_change_flags(dev, ifr->ifr_flags);
-
 		case SIOCGIFMETRIC:	/* Get the metric on the interface
 					   (currently unused) */
 			ifr->ifr_metric = 0;
 			return 0;

-		case SIOCSIFMETRIC:	/* Set the metric on the interface
-					   (currently unused) */
-			return -EOPNOTSUPP;
-
 		case SIOCGIFMTU:	/* Get the MTU of a device */
 			ifr->ifr_mtu = dev->mtu;
 			return 0;
-
-		case SIOCSIFMTU:	/* Set the MTU of a device */
-			return dev_set_mtu(dev, ifr->ifr_mtu);

 		case SIOCGIFHWADDR:
 			if (!dev->addr_len)
@@ -3126,16 +3116,9 @@
 			ifr->ifr_hwaddr.sa_family = dev->type;
 			return 0;

-		case SIOCSIFHWADDR:
-			return dev_set_mac_address(dev, &ifr->ifr_hwaddr);
-
-		case SIOCSIFHWBROADCAST:
-			if (ifr->ifr_hwaddr.sa_family != dev->type)
-				return -EINVAL;
-			memcpy(dev->broadcast, ifr->ifr_hwaddr.sa_data,
-			       min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) dev->addr_len));
-			call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
-			return 0;
+		case SIOCGIFSLAVE:
+			err = -EINVAL;
+			break;

 		case SIOCGIFMAP:
 			ifr->ifr_map.mem_start = dev->mem_start;
@@ -3146,6 +3129,59 @@
 			ifr->ifr_map.port      = dev->if_port;
 			return 0;

+		case SIOCGIFINDEX:
+			ifr->ifr_ifindex = dev->ifindex;
+			return 0;
+
+		case SIOCGIFTXQLEN:
+			ifr->ifr_qlen = dev->tx_queue_len;
+			return 0;
+
+		default:
+			/* dev_ioctl() should ensure this case
+			 * is never reached
+			 */
+			WARN_ON(1);
+			err = -EINVAL;
+			break;
+
+	}
+	return err;
+}
+
+/*
+ *	Perform the SIOCxIFxxx calls, inside rtnl_lock()
+ */
+static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
+{
+	int err;
+	struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
+
+	if (!dev)
+		return -ENODEV;
+
+	switch (cmd) {
+		case SIOCSIFFLAGS:	/* Set interface flags */
+			return dev_change_flags(dev, ifr->ifr_flags);
+
+		case SIOCSIFMETRIC:	/* Set the metric on the interface
+					   (currently unused) */
+			return -EOPNOTSUPP;
+
+		case SIOCSIFMTU:	/* Set the MTU of a device */
+			return dev_set_mtu(dev, ifr->ifr_mtu);
+
+		case SIOCSIFHWADDR:
+			return dev_set_mac_address(dev, &ifr->ifr_hwaddr);
+
+		case SIOCSIFHWBROADCAST:
+			if (ifr->ifr_hwaddr.sa_family != dev->type)
+				return -EINVAL;
+			memcpy(dev->broadcast, ifr->ifr_hwaddr.sa_data,
+			       min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) dev->addr_len));
+			call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
+			return 0;
+
 		case SIOCSIFMAP:
 			if (dev->set_config) {
 				if (!netif_device_present(dev))
@@ -3171,14 +3207,6 @@
 				return -ENODEV;
 			return dev_mc_delete(dev, ifr->ifr_hwaddr.sa_data,
 					     dev->addr_len, 1);
-
-		case SIOCGIFINDEX:
-			ifr->ifr_ifindex = dev->ifindex;
-			return 0;
-
-		case SIOCGIFTXQLEN:
-			ifr->ifr_qlen = dev->tx_queue_len;
-			return 0;

 		case SIOCSIFTXQLEN:
 			if (ifr->ifr_qlen < 0)
@@ -3290,7 +3318,7 @@
 		case SIOCGIFTXQLEN:
 			dev_load(net, ifr.ifr_name);
 			read_lock(&dev_base_lock);
-			ret = dev_ifsioc(net, &ifr, cmd);
+			ret = dev_ifsioc_locked(net, &ifr, cmd);
 			read_unlock(&dev_base_lock);
 			if (!ret) {
 				if (colon)


Move array size checking to verification.

	We don't necessarily know the type of the array index until
	after substituting, so things like sizeof() or constant
	folding may not work.

--- parse/infer.c
+++ parse/infer.c
@@ -2031,9 +2031,6 @@
 		t->fixed = 1;
 		if (t->type == Tyarray) {
 			typesub(t->asize, noerr);
-			t->asize = fold(t->asize, 1);
-			if (t->asize && exprop(t->asize) != Olit)
-				fatal(t->asize, "nonconstant array size near %s\n", ctxstr(t->asize));
 		} else if (t->type == Tystruct) {
 			inaggr++;
 			for (i = 0; i < t->nmemb; i++)
@@ -2593,6 +2590,7 @@
 void
 verify(Node *f)
 {
+	Type *t;
 	Node *n;
 	size_t i;

@@ -2607,6 +2605,14 @@
 					namestr(n->impl.traitname), tystr(n->impl.type));
 		}
 	}
+	for (i = 0; i < ntypes; i++) {
+		t = types[i];
+		if (t->type != Tyarray)
+			continue;
+		t->asize = fold(t->asize, 1);
+		if (t->asize && exprop(t->asize) != Olit)
+			fatal(t->asize, "nonconstant array size near %s\n", ctxstr(t->asize));
+	}
 }

 void


Some compilers are extra-picky about the difference between const T * and const T * const in template specializations; gcc 3.4.6 doesn't care either way. Make-it-compile.

svn path=/trunk/kdesupport/strigi/; revision=700795

--- src/xmlindexer/xmlindexwriter.h
+++ src/xmlindexer/xmlindexwriter.h
@@ -236,7 +236,7 @@
             const Strigi::RegisteredField* field, const std::string& value) {
         Data* d = static_cast<Data*>(ar->writerData());
         d->values.insert(
-            std::make_pair<const Strigi::RegisteredField*, std::string>(
+            std::make_pair<const Strigi::RegisteredField* const, std::string>(
             field, value));
     }
     void addValue(const Strigi::AnalysisResult* ar,
@@ -244,7 +244,7 @@
             const unsigned char* data, uint32_t size) {
         Data* d = static_cast<Data*>(ar->writerData());
         d->values.insert(
-            std::make_pair<const Strigi::RegisteredField*, std::string>(
+            std::make_pair<const Strigi::RegisteredField* const, std::string>(
             field, std::string((const char*)data, size)));
     }
     void addValue(const Strigi::AnalysisResult* ar,
@@ -254,7 +254,7 @@
         v.str("");
         v << value;
         d->values.insert(
-            std::make_pair<const Strigi::RegisteredField*, std::string>(
+            std::make_pair<const Strigi::RegisteredField* const, std::string>(
             field, v.str()));
     }
     void addValue(const Strigi::AnalysisResult* ar,
@@ -264,7 +264,7 @@
         v.str("");
         v << value;
         d->values.insert(
-            std::make_pair<const Strigi::RegisteredField*, std::string>(
+            std::make_pair<const Strigi::RegisteredField* const, std::string>(
             field, v.str()));
     }
     void addValue(const Strigi::AnalysisResult* ar,
@@ -274,7 +274,7 @@
         v.str("");
         v << value;
         d->values.insert(
-            std::make_pair<const Strigi::RegisteredField*, std::string>(
+            std::make_pair<const Strigi::RegisteredField* const, std::string>(
             field, v.str()));
     }
     void addTriplet(const std::string& subject,


notification: Use snap name and app name as fallback desktop-entry

Snaps use desktop IDs based on the snap name and the application name
inside the snap, so if we're in a such container, we need to compute the
desktop-entry using those values. We can figure them out from the snap
cgroup they're in.

In such case, don't even try to use the GApplication ID as that is
likely wrong in a snapped environment.

--- libnotify/notification.c
+++ libnotify/notification.c
@@ -71,6 +71,7 @@

         const char     *snap_path;
         const char     *snap_name;
+        char           *snap_app;

         /* NULL to use icon data. Anything else to have server lookup icon */
         char           *icon_name;
@@ -357,6 +358,7 @@
 maybe_initialize_snap (NotifyNotification *obj)
 {
         NotifyNotificationPrivate *priv = obj->priv;
+        gchar *cgroup_contents = NULL;

         priv->snap_path = g_getenv ("SNAP");
         if (priv->snap_path == NULL)
@@ -373,8 +375,81 @@
                 priv->snap_name = NULL;
         }

+        if (g_file_get_contents ("/proc/self/cgroup", &cgroup_contents,
+                                 NULL, NULL)) {
+                gchar **lines = g_strsplit (cgroup_contents, "\n", -1);
+                gchar *found_snap_name = NULL;
+                gint i;
+
+                for (i = 0; lines[i]; ++i) {
+                        gchar **parts = g_strsplit (lines[i], ":", 3);
+                        gchar *basename;
+                        gchar **ns;
+                        guint ns_length;
+
+                        if (g_strv_length (parts) != 3) {
+                                g_strfreev (parts);
+                                continue;
+                        }
+
+                        basename = g_path_get_basename (parts[2]);
+                        g_strfreev (parts);
+
+                        if (!basename) {
+                                continue;
+                        }
+
+                        ns = g_strsplit (basename, ".", -1);
+                        ns_length = g_strv_length (ns);
+                        g_free (basename);
+
+                        if (ns_length < 2 || !g_str_equal (ns[0], "snap")) {
+                                g_strfreev (ns);
+                                continue;
+                        }
+
+                        if (priv->snap_name == NULL) {
+                                g_free (found_snap_name);
+                                found_snap_name = g_strdup (ns[1]);
+                        }
+
+                        if (ns_length < 3) {
+                                g_strfreev (ns);
+                                continue;
+                        }
+
+                        if (priv->snap_name == NULL) {
+                                priv->snap_name = found_snap_name;
+                                found_snap_name = NULL;
+                        }
+
+                        if (g_str_equal (ns[1], priv->snap_name)) {
+                                priv->snap_app = g_strdup (ns[2]);
+                                g_strfreev (ns);
+                                break;
+                        }
+
+                        g_strfreev (ns);
+                }
+
+                if (priv->snap_name == NULL && found_snap_name != NULL) {
+                        priv->snap_name = found_snap_name;
+                        found_snap_name = NULL;
+                }
+
+                g_strfreev (lines);
+                g_free (found_snap_name);
+        }
+
+        if (priv->snap_app == NULL) {
+                priv->snap_app = g_strdup (priv->snap_name);
+        }
+
         g_debug ("SNAP path: %s", priv->snap_path);
         g_debug ("SNAP name: %s", priv->snap_name);
+        g_debug ("SNAP app: %s", priv->snap_app);
+
+        g_free (cgroup_contents);
 }

 static void
@@ -409,6 +484,7 @@
         g_free (priv->summary);
         g_free (priv->body);
         g_free (priv->icon_name);
+        g_free (priv->snap_app);

         if (priv->actions != NULL) {
                 g_slist_foreach (priv->actions, (GFunc) g_free, NULL);
@@ -680,7 +756,7 @@
         gpointer                   key, data;
         GVariant                  *result;
 #ifdef GLIB_VERSION_2_32
-        GApplication              *application;
+        GApplication              *application = NULL;
 #endif

         g_return_val_if_fail (notification != NULL, FALSE);
@@ -716,8 +792,24 @@
                 g_variant_builder_add (&hints_builder, "{sv}", key, data);
         }

+        if (priv->snap_app &&
+            g_hash_table_lookup (priv->hints, "desktop-entry") == NULL) {
+                gchar *snap_desktop;
+
+                snap_desktop = g_strdup_printf ("%s_%s",
+                                                priv->snap_name,
+                                                priv->snap_app);
+
+                g_debug ("Using desktop entry: %s", snap_desktop);
+                g_variant_builder_add (&hints_builder, "{sv}",
+                                       "desktop-entry",
+                                       g_variant_new_take_string (snap_desktop));
+        }
+
 #ifdef GLIB_VERSION_2_32
-        application = g_application_get_default ();
+        if (!priv->snap_app) {
+                application = g_application_get_default ();
+        }

         if (application != NULL) {
             GVariant *desktop_entry = g_hash_table_lookup (priv->hints, "desktop-entry");
@@ -725,6 +817,7 @@
             if (desktop_entry == NULL) {
                 const char *application_id = g_application_get_application_id (application);

+                g_debug ("Using desktop entry: %s", application_id);
                 g_variant_builder_add (&hints_builder, "{sv}", "desktop-entry",
                                        g_variant_new_string (application_id));
             }


net: speedup dst_release()

net: speedup dst_release()

During tbench/oprofile sessions, I found that dst_release() was in third position.

CPU: Core 2, speed 2999.68 MHz (estimated)
Counted CPU_CLK_UNHALTED events (Clock cycles when not halted) with a unit mask of 0x00 (Unhalted core cycles) count 100000
samples  %        symbol name
483726    9.0185  __copy_user_zeroing_intel
191466    3.5697  __copy_user_intel
185475    3.4580  dst_release
175114    3.2648  ip_queue_xmit
153447    2.8608  tcp_sendmsg
108775    2.0280  tcp_recvmsg
102659    1.9140  sysenter_past_esp
101450    1.8914  tcp_current_mss
95067     1.7724  __copy_from_user_ll
86531     1.6133  tcp_transmit_skb

Of course, all CPUS fight on the dst_entry associated with 127.0.0.1

Instead of first checking the refcount value, then decrement it,
we use atomic_dec_return() to help CPU to make the right memory transaction
(ie getting the cache line in exclusive mode)

dst_release() is now at the fifth position, and tbench a litle bit faster ;)

CPU: Core 2, speed 3000.1 MHz (estimated)
Counted CPU_CLK_UNHALTED events (Clock cycles when not halted) with a unit mask of 0x00 (Unhalted core cycles) count 100000
samples  %        symbol name
647107    8.8072  __copy_user_zeroing_intel
258840    3.5229  ip_queue_xmit
258302    3.5155  __copy_user_intel
209629    2.8531  tcp_sendmsg
165632    2.2543  dst_release
149232    2.0311  tcp_current_mss
147821    2.0119  tcp_recvmsg
137893    1.8767  sysenter_past_esp
127473    1.7349  __copy_from_user_ll
121308    1.6510  ip_finish_output
118510    1.6129  tcp_transmit_skb
109295    1.4875  tcp_v4_rcv

Signed-off-by: Eric Dumazet <376627c3b2da88577629dab6f8516ef352eb3ff8@cosmosbay.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/core/dst.c
+++ net/core/dst.c
@@ -263,9 +263,11 @@
 void dst_release(struct dst_entry *dst)
 {
 	if (dst) {
-		WARN_ON(atomic_read(&dst->__refcnt) < 1);
+               int newrefcnt;
+
 		smp_mb__before_atomic_dec();
-		atomic_dec(&dst->__refcnt);
+               newrefcnt = atomic_dec_return(&dst->__refcnt);
+               WARN_ON(newrefcnt < 0);
 	}
 }
 EXPORT_SYMBOL(dst_release);


Fix boolean logic in http_GetHdrToken

Fix boolean logic in http_GetHdrToken

For quoted tokens, http_GetHdrToken should not try a case insensitive match
if the sensitive match fails

--- bin/varnishd/cache/cache_http.c
+++ bin/varnishd/cache/cache_http.c
@@ -443,8 +443,9 @@
 		}
 		/* Check for substrings before memcmp() */
 		if ((h + fl == e || vct_issepctl(h[fl])) &&
-		    ((quoted && !memcmp(h, token, fl)) ||
-		     !strncasecmp(h, token, fl))) {
+		    (quoted
+		    ? !memcmp(h, token, fl)
+		    : !strncasecmp(h, token, fl))) {
 			if (ptr != NULL) {
 				h += fl;
 				while (vct_islws(*h))


Fix a double free in the destroy path triggered when a second process,
in my case dhclient(8), races with ifconfig(8) to free the descriptors
of the joined multicast groups.

While here reduce the difference with carp(4).

ok dms@

--- net/if_trunk.c
+++ net/if_trunk.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: if_trunk.c,v 1.101 2015/06/09 14:50:14 mpi Exp $	*/
+/*	$OpenBSD: if_trunk.c,v 1.102 2015/06/15 15:55:08 mpi Exp $	*/

 /*
  * Copyright (c) 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -857,17 +857,19 @@
 	if ((error = ether_delmulti(ifr, &tr->tr_ac)) != ENETRESET)
 		return (error);

-	if ((error = trunk_ioctl_allports(tr, SIOCDELMULTI,
-	    (caddr_t)ifr)) != 0) {
+	/* We no longer use this multicast address.  Tell parent so. */
+	error = trunk_ioctl_allports(tr, SIOCDELMULTI, (caddr_t)ifr);
+	if (error == 0) {
+		SLIST_REMOVE(&tr->tr_mc_head, mc, trunk_mc, mc_entries);
+		free(mc, M_DEVBUF, sizeof(*mc));
+	} else {
 		/* XXX At least one port failed to remove the address */
 		if (tr->tr_ifflags & IFF_DEBUG) {
 			printf("%s: failed to remove multicast address "
-			    "on all ports\n", tr->tr_ifname);
-		}
-	}
-
-	SLIST_REMOVE(&tr->tr_mc_head, mc, trunk_mc, mc_entries);
-	free(mc, M_DEVBUF, 0);
+			    "on all ports (%d)\n", tr->tr_ifname, error);
+		}
+		(void)ether_addmulti(ifr, &tr->tr_ac);
+	}

 	return (0);
 }
@@ -886,7 +888,7 @@
 		trunk_ioctl_allports(tr, SIOCDELMULTI, (caddr_t)ifr);

 		SLIST_REMOVE(&tr->tr_mc_head, mc, trunk_mc, mc_entries);
-		free(mc, M_DEVBUF, 0);
+		free(mc, M_DEVBUF, sizeof(*mc));
 	}
 }


When a multicast tunnel destination is configured, we have to detect address and link state changes on the interface that is sending out the tunnel traffic.  Attach a link state and address hook in this case and reset the multicast configuration.  This also fixes a problem on VMware that looses the multicast associations when the virtual link state of the NIC is triggered.

--- net/if_vxlan.c
+++ net/if_vxlan.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: if_vxlan.c,v 1.5 2013/10/15 10:24:41 mpi Exp $	*/
+/*	$OpenBSD: if_vxlan.c,v 1.6 2013/10/19 11:20:08 reyk Exp $	*/

 /*
  * Copyright (c) 2013 Reyk Floeter <reyk@openbsd.org>
@@ -64,10 +64,14 @@
 int	 vxlan_clone_create(struct if_clone *, int);
 int	 vxlan_clone_destroy(struct ifnet *);
 void	 vxlan_multicast_cleanup(struct ifnet *);
+int	 vxlan_join_multicast(struct ifnet *, struct sockaddr_in *,
+	    struct sockaddr_in *);
 int	 vxlan_media_change(struct ifnet *);
 void	 vxlan_media_status(struct ifnet *, struct ifmediareq *);
 int	 vxlan_config(struct ifnet *, struct sockaddr *, struct sockaddr *);
 int	 vxlan_output(struct ifnet *, struct mbuf *);
+void	 vxlan_addr_change(void *);
+void	 vxlan_link_change(void *);

 struct if_clone	vxlan_cloner =
     IF_CLONE_INITIALIZER("vxlan", vxlan_clone_create, vxlan_clone_destroy);
@@ -174,11 +178,55 @@
 {
 	struct vxlan_softc	*sc = (struct vxlan_softc *)ifp->if_softc;
 	struct ip_moptions	*imo = &sc->sc_imo;
+	struct ifnet		*mifp = imo->imo_multicast_ifp;
+
+	if (mifp != NULL && sc->sc_ahcookie != NULL) {
+		hook_disestablish(mifp->if_addrhooks, sc->sc_ahcookie);
+		sc->sc_ahcookie = NULL;
+	}
+	if (mifp != NULL && sc->sc_lhcookie != NULL) {
+		hook_disestablish(mifp->if_linkstatehooks, sc->sc_lhcookie);
+		sc->sc_lhcookie = NULL;
+	}

 	if (imo->imo_num_memberships > 0) {
 		in_delmulti(imo->imo_membership[--imo->imo_num_memberships]);
 		imo->imo_multicast_ifp = NULL;
 	}
+}
+
+int
+vxlan_join_multicast(struct ifnet *ifp, struct sockaddr_in *src,
+    struct sockaddr_in *dst)
+{
+	struct vxlan_softc	*sc = ifp->if_softc;
+	struct ip_moptions	*imo = &sc->sc_imo;
+	struct ifaddr		*ifa;
+
+	if (!IN_MULTICAST(dst->sin_addr.s_addr))
+		return (0);
+
+	if (src->sin_addr.s_addr == INADDR_ANY ||
+	    IN_MULTICAST(src->sin_addr.s_addr))
+		return (EINVAL);
+	if ((ifa = ifa_ifwithaddr(sintosa(src),
+	    sc->sc_rtableid)) == NULL || ifa->ifa_ifp == NULL ||
+	    (ifa->ifa_ifp->if_flags & IFF_MULTICAST) == 0)
+		return (EADDRNOTAVAIL);
+
+ 	if ((imo->imo_membership[0] =
+	    in_addmulti(&dst->sin_addr, ifa->ifa_ifp)) == NULL)
+		return (ENOBUFS);
+
+	imo->imo_num_memberships++;
+	imo->imo_multicast_ifp = ifa->ifa_ifp;
+	if (sc->sc_ttl > 0)
+		imo->imo_multicast_ttl = sc->sc_ttl;
+	else
+		imo->imo_multicast_ttl = IP_DEFAULT_MULTICAST_TTL;
+	imo->imo_multicast_loop = 0;
+
+	return (0);
 }

 void
@@ -212,9 +260,9 @@
 	struct ip_moptions	*imo = &sc->sc_imo;
 #ifdef INET
 	struct sockaddr_in	*src4, *dst4;
-	struct ifaddr		*ifa;
-#endif
-	int			 reset = 0;
+#endif
+	int			 reset = 0, error;
+	struct ifnet		*mifp = imo->imo_multicast_ifp;

 	if (src != NULL && dst != NULL) {
 		/* XXX inet6 is not supported */
@@ -233,33 +281,28 @@

 	if (src4->sin_len != sizeof(*src4) || dst4->sin_len != sizeof(*dst4))
 		return (EINVAL);
-
+#endif
+
+	vxlan_multicast_cleanup(ifp);
+
+#ifdef INET
 	if (IN_MULTICAST(dst4->sin_addr.s_addr)) {
-		if (src4->sin_addr.s_addr == INADDR_ANY ||
-		    IN_MULTICAST(src4->sin_addr.s_addr))
-			return (EINVAL);
-		if ((ifa = ifa_ifwithaddr(sintosa(src4),
-		    sc->sc_rtableid)) == NULL ||
-		    ifa->ifa_ifp == NULL ||
-		    (ifa->ifa_ifp->if_flags & IFF_MULTICAST) == 0)
-			return (EADDRNOTAVAIL);
-	}
-#endif
-
-	vxlan_multicast_cleanup(ifp);
-
-#ifdef INET
-	if (IN_MULTICAST(dst4->sin_addr.s_addr)) {
-		if ((imo->imo_membership[0] =
-		    in_addmulti(&dst4->sin_addr, ifa->ifa_ifp)) == NULL)
-			return (ENOBUFS);
-		imo->imo_num_memberships++;
-		imo->imo_multicast_ifp = ifa->ifa_ifp;
-		if (sc->sc_ttl > 0)
-			imo->imo_multicast_ttl = sc->sc_ttl;
-		else
-			imo->imo_multicast_ttl = IP_DEFAULT_MULTICAST_TTL;
-		imo->imo_multicast_loop = 0;
+		if ((error = vxlan_join_multicast(ifp, src4, dst4)) != 0)
+			return (error);
+
+		mifp = imo->imo_multicast_ifp;
+
+		/* Insert addr and link state hooks at head */
+		if ((sc->sc_ahcookie =
+		    hook_establish(mifp->if_addrhooks,
+		    0, vxlan_addr_change, sc)) == NULL)
+			panic("%s: cannot allocate %s address hook",
+			    __func__, mifp->if_xname);
+		if ((sc->sc_lhcookie =
+		    hook_establish(mifp->if_linkstatehooks,
+		    0, vxlan_link_change, sc)) == NULL)
+			panic("%s: cannot allocate %s linkstate hook",
+			    __func__, mifp->if_xname);
 	}
 	if (dst4->sin_port)
 		sc->sc_dstport = dst4->sin_port;
@@ -602,3 +645,39 @@

 	return (error);
 }
+
+void
+vxlan_addr_change(void *arg)
+{
+	struct vxlan_softc	*sc = arg;
+	struct ifnet		*ifp = &sc->sc_ac.ac_if;
+	int			 s;
+
+	/*
+	 * Reset the configuration after resume or any possible address
+	 * configuration changes.
+	 */
+	s = splnet();
+	if (vxlan_config(ifp, NULL, NULL) != 0) {
+		bzero(&sc->sc_src, sizeof(sc->sc_src));
+		bzero(&sc->sc_dst, sizeof(sc->sc_dst));
+	}
+	splx(s);
+}
+
+void
+vxlan_link_change(void *arg)
+{
+	struct vxlan_softc	*sc = arg;
+	struct ifnet		*ifp = &sc->sc_ac.ac_if;
+	int			 s;
+
+	/*
+	 * The machine might have lost its multicast associations after
+	 * link state changes.  This fixes a problem with VMware after
+	 * suspend/resume of the host or guest.
+	 */
+	s = splnet();
+	(void)vxlan_config(ifp, NULL, NULL);
+	splx(s);
+}


[IPV4]: Fix "Proxy ARP seems broken"

[IPV4]: Fix "Proxy ARP seems broken"

Meelis Roos <mroos@linux.ee> wrote:
> RK> My firewall setup relies on proxyarp working.  However, with 2.6.14-rc3,
> RK> it appears to be completely broken.  The firewall is 212.18.232.186,
>
> Same here with some kernel between 14-rc2 and 14-rc3 - no reposnse to
> ARP on a proxyarp gateway. Sorry, no exact revison and no more debugging
> yet since it'a a production gateway.

The breakage is caused by the change to use the CB area for flagging
whether a packet has been queued due to proxy_delay.  This area gets
cleared every time arp_rcv gets called.  Unfortunately packets delayed
due to proxy_delay also go through arp_rcv when they are reprocessed.

In fact, I can't think of a reason why delayed proxy packets should go
through netfilter again at all.  So the easiest solution is to bypass
that and go straight to arp_process.

This is essentially what would've happened before netfilter support
was added to ARP.

Signed-off-by: Herbert Xu <ef65de1c7be0aa837fe7b25ba9a7739905af6a55@gondor.apana.org.au>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/ipv4/arp.c
+++ net/ipv4/arp.c
@@ -697,12 +697,6 @@
 	arp_xmit(skb);
 }

-static void parp_redo(struct sk_buff *skb)
-{
-	nf_reset(skb);
-	arp_rcv(skb, skb->dev, NULL, skb->dev);
-}
-
 /*
  *	Process an arp request.
  */
@@ -920,6 +914,11 @@
 		in_dev_put(in_dev);
 	kfree_skb(skb);
 	return 0;
+}
+
+static void parp_redo(struct sk_buff *skb)
+{
+	arp_process(skb);
 }


tcp: select(writefds) don't hang up when a peer close connection

This issue come from ruby language community. Below test program
hang up when only run on Linux.

	% uname -mrsv
	Linux 2.6.26-2-486 #1 Sat Dec 26 08:37:39 UTC 2009 i686
	% ruby -rsocket -ve '
	BasicSocket.do_not_reverse_lookup = true
	serv = TCPServer.open("127.0.0.1", 0)
	s1 = TCPSocket.open("127.0.0.1", serv.addr[1])
	s2 = serv.accept
	s2.close
	s1.write("a") rescue p $!
	s1.write("a") rescue p $!
	Thread.new {
	  s1.write("a")
	}.join'
	ruby 1.9.3dev (2010-07-06 trunk 28554) [i686-linux]
	#<Errno::EPIPE: Broken pipe>
	[Hang Here]

FreeBSD, Solaris, Mac doesn't. because Ruby's write() method call
select() internally. and tcp_poll has a bug.

SUS defined 'ready for writing' of select() as following.

|  A descriptor shall be considered ready for writing when a call to an output
|  function with O_NONBLOCK clear would not block, whether or not the function
|  would transfer data successfully.

That said, EPIPE situation is clearly one of 'ready for writing'.

We don't have read-side issue because tcp_poll() already has read side
shutdown care.

|        if (sk->sk_shutdown & RCV_SHUTDOWN)
|                mask |= POLLIN | POLLRDNORM | POLLRDHUP;

So, Let's insert same logic in write side.

- reference url
  http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/31065
  http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/31068

Signed-off-by: KOSAKI Motohiro <70a1d3ef3e17a2bb0f09a1b2e6c86f607ed1d6d9@jp.fujitsu.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>


tcp: Do not tack on TSO data to non-TSO packet

If a socket starts out on a non-TSO route, and then switches to
a TSO route, then we will tack on data to the tail of the tx queue
even if it started out life as non-TSO.  This is suboptimal because
all of it will then be copied and checksummed unnecessarily.

This patch fixes this by ensuring that skb->ip_summed is set to
CHECKSUM_PARTIAL before appending extra data beyond the MSS.

Signed-off-by: Herbert Xu <ef65de1c7be0aa837fe7b25ba9a7739905af6a55@gondor.apana.org.au>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/ipv4/tcp.c
+++ net/ipv4/tcp.c
@@ -903,13 +903,17 @@
 		iov++;

 		while (seglen > 0) {
-			int copy;
+			int copy = 0;
+			int max = size_goal;

 			skb = tcp_write_queue_tail(sk);
-
-			if (!tcp_send_head(sk) ||
-			    (copy = size_goal - skb->len) <= 0) {
-
+			if (tcp_send_head(sk)) {
+				if (skb->ip_summed == CHECKSUM_NONE)
+					max = mss_now;
+				copy = max - skb->len;
+			}
+
+			if (copy <= 0) {
 new_segment:
 				/* Allocate new segment. If the interface is SG,
 				 * allocate skb fitting to single page.
@@ -930,6 +934,7 @@

 				skb_entail(sk, skb);
 				copy = size_goal;
+				max = size_goal;
 			}

 			/* Try to append data to the end of skb. */
@@ -1028,7 +1033,7 @@
 			if ((seglen -= copy) == 0 && iovlen == 0)
 				goto out;

-			if (skb->len < size_goal || (flags & MSG_OOB))
+			if (skb->len < max || (flags & MSG_OOB))
 				continue;

 			if (forced_push(tp)) {


Fix bugs wrt Initial Expression Widget.

Fix bugs wrt Initial Expression Widget.

--- copasi/UI/CQModelValue.ui.h
+++ copasi/UI/CQModelValue.ui.h
@@ -1,9 +1,9 @@
 // Begin CVS Header
 //   $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/UI/Attic/CQModelValue.ui.h,v $
-//   $Revision: 1.21 $
+//   $Revision: 1.22 $
 //   $Name:  $
 //   $Author: pwilly $
-//   $Date: 2008/04/01 11:22:57 $
+//   $Date: 2008/04/01 11:23:20 $
 // End CVS Header

 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
@@ -435,7 +435,6 @@
   // Expression
   //  mpEditExpression->setExpression(mpModelValue->getExpression());
   ((CQExpressionWidget *)mpEditExpression->widget(0))->setExpression(mpModelValue->getExpression());
-  //  std::cout << "EXP: " << mpModelValue->getExpression() << " vs " << ((CQExpressionWidget *)mpEditExpression->widget(0))->getExpression() << std::endl;
   std::cout << "EXP: " << ((CQExpressionWidget *)mpEditExpression->widget(0))->getExpression() << std::endl;
   slotTypeChanged(mpComboBoxType->currentItem());
   /*


tcp: do_tcp_sendpages() must try to push data out on oom conditions

Since recent changes on TCP splicing (starting with commits 2f533844
"tcp: allow splice() to build full TSO packets" and 35f9c09f "tcp:
tcp_sendpages() should call tcp_push() once"), I started seeing
massive stalls when forwarding traffic between two sockets using
splice() when pipe buffers were larger than socket buffers.

Latest changes (net: netdev_alloc_skb() use build_skb()) made the
problem even more apparent.

The reason seems to be that if do_tcp_sendpages() fails on out of memory
condition without being able to send at least one byte, tcp_push() is not
called and the buffers cannot be flushed.

After applying the attached patch, I cannot reproduce the stalls at all
and the data rate it perfectly stable and steady under any condition
which previously caused the problem to be permanent.

The issue seems to have been there since before the kernel migrated to
git, which makes me think that the stalls I occasionally experienced
with tux during stress-tests years ago were probably related to the
same issue.

This issue was first encountered on 3.0.31 and 3.2.17, so please backport
to -stable.

Signed-off-by: Willy Tarreau <aff024fe4ab0fece4091de044c58c9ae4233383a@1wt.eu>
Acked-by: Eric Dumazet <312c7d941f03386814be517ffdb3e0eb6624e275@google.com>
Cc: <4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org>


gdbus: don't warn when returning a value on a closed connection

g_dbus_method_invocation_return_value(), etc, don't have GError
parameters (which makes sense since they won't usually return errors,
and there's not much you could do if they did), so in the rare case
when something does go wrong, they print a warning.

However, there is at least one situation where the warning is a bad
idea: if you are using private bus connections, and a client connects,
makes a request, and then disconnects before getting the response.
Given that there's nothing the caller can do to prevent this case from
getting hit (since the client might not disconnect until after the
call to g_dbus_method_invocation_return_value() starts) and given that
the server can never actually know for sure that the client has
received the response (it might disconnect after reading the response,
but before processing it), just kill the warning in this case.

https://bugzilla.gnome.org/show_bug.cgi?id=753839

--- gio/gdbusmethodinvocation.c
+++ gio/gdbusmethodinvocation.c
@@ -505,7 +505,8 @@
   error = NULL;
   if (!g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, &error))
     {
-      g_warning ("Error sending message: %s", error->message);
+      if (!g_error_matches (G_IO_ERROR, G_IO_ERROR_CLOSED))
+        g_warning ("Error sending message: %s", error->message);
       g_error_free (error);
     }
   g_object_unref (reply);


ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0.

ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0.

Do not use bit-shift if relay_prefixlen == 0;
relay_prefix << 32 does not result in 0.

Signed-off-by: YOSHIFUJI Hideaki <948b80da4254122ea1e8973dd9930d46b7654cf3@linux-ipv6.org>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>


Revert previous.

Revert previous.

--- net/pf_ioctl.c
+++ net/pf_ioctl.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: pf_ioctl.c,v 1.212 2009/02/15 20:42:33 mbalmer Exp $ */
+/*	$OpenBSD: pf_ioctl.c,v 1.213 2009/02/15 21:46:12 mbalmer Exp $ */

 /*
  * Copyright (c) 2001 Daniel Hartmeier
@@ -1588,9 +1588,7 @@
 			error = EINVAL;
 			break;
 		}
-#if NPFSYNC > 0
 		error = pfsync_state_import(sp, PFSYNC_SI_IOCTL);
-#endif
 		break;
 	}

@@ -1607,9 +1605,8 @@
 			error = ENOENT;
 			break;
 		}
-#if NPFSYNC > 0
+
 		pfsync_state_export(&ps->state, s);
-#endif
 		break;
 	}

@@ -1634,9 +1631,7 @@
 			if (state->timeout != PFTM_UNLINKED) {
 				if ((nr+1) * sizeof(*p) > (unsigned)ps->ps_len)
 					break;
-#if NPFSYNC > 0
 				pfsync_state_export(pstore, state);
-#endif
 				error = copyout(pstore, p, sizeof(*p));
 				if (error) {
 					free(pstore, M_TEMP);


do not differentiate manually configured address from autoconfigured ones
wrt prefix management;
- always earn a reference to the prefix when an address is configured
 (by ioctl).
- always delete the prefix when an address that has the last referene
  is manually removed.

The change should solve the problem raised in KAME-snap 6989.

sync w/kame

--- netinet6/in6.c
+++ netinet6/in6.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: in6.c,v 1.48 2002/09/23 23:28:15 itojun Exp $	*/
+/*	$OpenBSD: in6.c,v 1.49 2002/10/17 00:09:39 itojun Exp $	*/
 /*	$KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $	*/

 /*
@@ -704,7 +704,7 @@
 		pr0.ndpr_vltime = ifra->ifra_lifetime.ia6t_vltime;
 		pr0.ndpr_pltime = ifra->ifra_lifetime.ia6t_pltime;

-		/* add the prefix if there's one. */
+		/* add the prefix if not yet. */
 		if ((pr = nd6_prefix_lookup(&pr0)) == NULL) {
 			/*
 			 * nd6_prelist_add will install the corresponding
@@ -718,8 +718,9 @@
 				return (EINVAL); /* XXX panic here? */
 			}
 		}
-		if ((ia->ia6_flags & IN6_IFF_AUTOCONF) &&
-		    ia->ia6_ndpr == NULL) { /* new autoconfed addr */
+
+		/* relate the address to the prefix */
+		if (ia->ia6_ndpr == NULL) {
 			ia->ia6_ndpr = pr;
 			pr->ndpr_refcnt++;
 		}
@@ -759,20 +760,12 @@
 			pr0.ndpr_prefix.sin6_addr.s6_addr32[i] &=
 			    ia->ia_prefixmask.sin6_addr.s6_addr32[i];
 		}
-		/*
-		 * The logic of the following condition is a bit complicated.
-		 * We expire the prefix when
-		 * 1. the address obeys autoconfiguration and it is the
-		 *    only owner of the associated prefix, or
-		 * 2. the address does not obey autoconf and there is no
-		 *    other owner of the prefix.
-		 */
 		if ((pr = nd6_prefix_lookup(&pr0)) != NULL &&
-		    (((ia->ia6_flags & IN6_IFF_AUTOCONF) != 0 &&
-		      pr->ndpr_refcnt == 1) ||
-		     ((ia->ia6_flags & IN6_IFF_AUTOCONF) == 0 &&
-		      pr->ndpr_refcnt == 0)))
-			purgeprefix = 1;
+		    pr == ia->ia6_ndpr) {
+			pr->ndpr_refcnt--;
+			if (pr->ndpr_refcnt == 0)
+				purgeprefix = 1;
+		}

 	  purgeaddr:
 		in6_purgeaddr(&ia->ia_ifa);


Partial revert of r7396

Partial revert of r7396

This change reverts a small part of what was done in r7396. It seems
like that change uncovered another issue with NEON.

BUG=4177,chrome-os-partner:31534
R=tina.legrand@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/33849004

git-svn-id: 917f5d3ca488f358c4d40eaec14422cf392ccec9@8043 4adac7df-926f-26a2-2b94-8c16560cd09d

--- webrtc/modules/audio_coding/codecs/isac/fix/source/fft.c
+++ webrtc/modules/audio_coding/codecs/isac/fix/source/fft.c
@@ -176,8 +176,10 @@
       bjQx = ImxQx[k1] + ImxQx[k2];
       RexQx[kk] = akQx + ajQx;
       ImxQx[kk] = bkQx + bjQx;
-      akQx -= ajQx >> 1;
-      bkQx -= bjQx >> 1;
+      tmp116 = ajQx >> 1;
+      tmp216 = bjQx >> 1;
+      akQx = akQx - tmp116;
+      bkQx = bkQx - tmp216;
       tmp116 = RexQx[k1] - RexQx[k2];
       tmp216 = ImxQx[k1] - ImxQx[k2];


Remove most of the DTLS special casing from the write record code

Most of this was unnecessary anyway since DTLS isn't using these codepaths.

Reviewed-by: Hugo Landau <ce9fa1e55a72fc9b85dd06e47ea2c07848fb7d2c@openssl.org>
Reviewed-by: Tomas Mraz <2bc6038c3dfca09b2da23c8b6da8ba884dc2dcc2@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19343)

--- ssl/record/methods/tls_common.c
+++ ssl/record/methods/tls_common.c
@@ -1513,37 +1513,18 @@
     int using_ktls;
     /* TODO(RECLAYER): REMOVE ME */
     SSL_CONNECTION *s = rl->cbarg;
-    SSL *ssl = SSL_CONNECTION_GET_SSL(s);
     OSSL_RECORD_TEMPLATE prefixtempl;
     OSSL_RECORD_TEMPLATE *thistempl;

-    /*
-     * TODO(RECLAYER): Remove this once DTLS crypto has
-     *                 been moved to the new write record layer.
-     */
-    if (rl->isdtls) {
-        SSL_SESSION *sess = s->session;
-
-        if ((sess == NULL)
-                || (s->enc_write_ctx == NULL)
-                || (EVP_MD_CTX_get0_md(s->write_hash) == NULL)) {
-            mac_size = 0;
-        } else {
-            mac_size = EVP_MD_CTX_get_size(s->write_hash);
-            if (mac_size < 0) {
-                RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
-                goto err;
-            }
-        }
-    } else {
-        if (rl->md_ctx != NULL && EVP_MD_CTX_get0_md(rl->md_ctx) != NULL) {
-            mac_size = EVP_MD_CTX_get_size(rl->md_ctx);
-            if (mac_size < 0) {
-                RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
-                goto err;
-            }
-        }
-    }
+
+    if (rl->md_ctx != NULL && EVP_MD_CTX_get0_md(rl->md_ctx) != NULL) {
+        mac_size = EVP_MD_CTX_get_size(rl->md_ctx);
+        if (mac_size < 0) {
+            RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
+            goto err;
+        }
+    }
+
     /* Do we need to add an empty record prefix? */
     prefix = rl->need_empty_fragments
              && templates[0].type == SSL3_RT_APPLICATION_DATA;
@@ -1761,22 +1742,10 @@
         if (!using_ktls && !rl->use_etm && mac_size != 0) {
             unsigned char *mac;

-            /*
-             * TODO(RECLAYER): Remove this once DTLS crypto has
-             *                 been moved to the new write record layer.
-             */
-            if (rl->isdtls) {
-                if (!WPACKET_allocate_bytes(thispkt, mac_size, &mac)
-                        || !ssl->method->ssl3_enc->mac(s, thiswr, mac, 1)) {
-                    RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
-                    goto err;
-                }
-            } else {
-                if (!WPACKET_allocate_bytes(thispkt, mac_size, &mac)
-                        || !rl->funcs->mac(rl, thiswr, mac, 1)) {
-                    RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
-                    goto err;
-                }
+            if (!WPACKET_allocate_bytes(thispkt, mac_size, &mac)
+                    || !rl->funcs->mac(rl, thiswr, mac, 1)) {
+                RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
+                goto err;
             }
         }

@@ -1826,24 +1795,13 @@
                     goto err;
                 }
             }
-            /*
-             * TODO(RECLAYER): Remove this once DTLS crypto has
-             *                 been moved to the new write record layer.
-             */
-            if (rl->isdtls) {
-                if (ssl->method->ssl3_enc->enc(s, wr + prefix, numtempl, 1, NULL,
-                                               mac_size) < 1) {
-                    if (!ossl_statem_in_error(s))
-                        RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
-                    goto err;
+
+            if (rl->funcs->cipher(rl, wr + prefix, numtempl, 1, NULL,
+                                  mac_size) < 1) {
+                if (!ossl_statem_in_error(s)) {
+                    RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
                 }
-            } else {
-                if (rl->funcs->cipher(rl, wr + prefix, numtempl, 1, NULL,
-                                      mac_size) < 1) {
-                    if (!ossl_statem_in_error(s))
-                        RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
-                    goto err;
-                }
+                goto err;
             }
         }
     }
@@ -1873,22 +1831,10 @@
         if (rl->use_etm && mac_size != 0) {
             unsigned char *mac;

-            /*
-             * TODO(RECLAYER): Remove this once DTLS crypto has
-             *                 been moved to the new write record layer.
-             */
-            if (rl->isdtls) {
-                if (!WPACKET_allocate_bytes(thispkt, mac_size, &mac)
-                        || !ssl->method->ssl3_enc->mac(s, thiswr, mac, 1)) {
-                    RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
-                    goto err;
-                }
-            } else {
-                if (!WPACKET_allocate_bytes(thispkt, mac_size, &mac)
-                        || !rl->funcs->mac(rl, thiswr, mac, 1)) {
-                    RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
-                    goto err;
-                }
+            if (!WPACKET_allocate_bytes(thispkt, mac_size, &mac)
+                    || !rl->funcs->mac(rl, thiswr, mac, 1)) {
+                RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
+                goto err;
             }

             SSL3_RECORD_add_length(thiswr, mac_size);


Provide assign operator for TIter

Provide assign operator for TIter

Let assign TIterator* directly without need of creating
temporary TIter object in between.
Solves #7633


Check last session

Check last session

--- src/amf/nsmf-handler.c
+++ src/amf/nsmf-handler.c
@@ -366,9 +366,8 @@
     amf_ue = sess->amf_ue;
     ogs_assert(amf_ue);

-    amf_sess_remove(sess);
-
-    if (ogs_list_count(&amf_ue->sess_list) == 0) {
+    /* Check last session */
+    if (ogs_list_count(&amf_ue->sess_list) == 1) {

         if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_authentication)) {

@@ -419,5 +418,7 @@
         }
     }

+    amf_sess_remove(sess);
+
     return OGS_OK;
 }


Fixed the overflow in the AGC

Fixed the overflow in the AGC

BUG=webrtc:8236

Review-Url: https://codereview.webrtc.org/3009373002
Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#19818}

--- webrtc/modules/audio_processing/agc/legacy/digital_agc.c
+++ webrtc/modules/audio_processing/agc/legacy/digital_agc.c
@@ -524,8 +524,17 @@
     // iterate over samples
     for (n = 0; n < L; n++) {
       for (i = 0; i < num_bands; ++i) {
-        tmp32 = out[i][k * L + n] * (gain32 >> 4);
-        out[i][k * L + n] = (int16_t)(tmp32 >> 16);
+        int64_t tmp64 = ((int64_t)(out[i][k * L + n])) * (gain32 >> 4);
+        tmp64 = tmp64 >> 16;
+        if (tmp64 > 32767) {
+          out[i][k * L + n] = 32767;
+        }
+        else if (tmp64 < -32768) {
+          out[i][k * L + n] = -32768;
+        }
+        else {
+          out[i][k * L + n] = (int16_t)(tmp64);
+        }
       }
       gain32 += delta;
     }


edk2/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c:
  Fix warning from Intel Compiler.

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

--- EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c
+++ EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c
@@ -125,7 +125,7 @@
   EFI_STATUS                Status;

   DevicePathSize  = (UINT16) EfiDevicePathSize (DevicePath);
-  Size            = DevicePathSize + sizeof (EFI_STATUS_CODE_DATA);
+  Size            = (UINT16) (DevicePathSize + sizeof (EFI_STATUS_CODE_DATA));
   ExtendedData    = (EFI_STATUS_CODE_DATA *) EfiLibAllocatePool (Size);
   if (ExtendedData == NULL) {
     return EFI_OUT_OF_RESOURCES;


Added some slightly less obscure convenience methods for soft core hackers

--- GBAnalytics/GBAnalytics.h
+++ GBAnalytics/GBAnalytics.h
@@ -24,5 +24,9 @@
 @end

 //Shorthands
-static inline void _t(NSString *event) { [GBAnalytics trackEvent:event]; }
-static inline void _td(NSString *event, NSDictionary *dictionary) { [GBAnalytics trackEvent:event withDictionary:dictionary]; }
+static inline void TrackEvent(NSString *event) { [GBAnalytics trackEvent:event]; }
+static inline void TrackEventWithDictionary(NSString *event, NSDictionary *dictionary) { [GBAnalytics trackEvent:event withDictionary:dictionary]; }
+
+//Super Shorthands
+static inline void _t(NSString *event) { TrackEvent(event); }
+static inline void _td(NSString *event, NSDictionary *dictionary) { TrackEventWithDictionary(event, dictionary); }


cosmetic

cosmetic

--- Library/Sources/Stroika/Foundation/Containers/Private/IteratorImplHelper.h
+++ Library/Sources/Stroika/Foundation/Containers/Private/IteratorImplHelper.h
@@ -37,12 +37,11 @@
         {
         }
         // weird explicit def need here and cannot do = default? --LGP 2021-10-31
-        ContainerDebugChangeCounts_ (const ContainerDebugChangeCounts_& src)
+        ContainerDebugChangeCounts_ ([[maybe_unused]] const ContainerDebugChangeCounts_& src)
 #if qDebug
-            : fChangeCount
-        {
-            src.fChangeCount.load ()
-        }
+            // clang-format off
+            : fChangeCount{src.fChangeCount.load ()}
+        // clang-format on
 #endif
         {
         }


Remove unneeded check for property setting

--- testmud/mud/home/Thing/lib/property.c
+++ testmud/mud/home/Thing/lib/property.c
@@ -118,8 +118,6 @@

 				creator = DRIVER->creator(lib);

-				ACCESS_CHECK(creator == "Game");
-
 				call_other(this_object(), func, value);
 			}
 			return;
@@ -312,8 +310,6 @@

 			creator = DRIVER->creator(lib);

-			ACCESS_CHECK(creator == "Game");
-
 			return call_other(this_object(), func);
 		}
 	default:


Don't show text on buttons with icons that are not wider than they are tall.

--- src/button.c
+++ src/button.c
@@ -144,7 +144,7 @@
    /* Determine how much room is left for text. */
    textWidth = 0;
    textHeight = 0;
-   if(bp->text) {
+   if(bp->text && (width > height || !bp->icon)) {
       textWidth = GetStringWidth(bp->font, bp->text);
       textHeight = GetStringHeight(bp->font);
       if(iconWidth > 0 && textWidth + iconWidth + 7 > width) {


Fix operator->

Fix operator->

--- src/bwtree.h
+++ src/bwtree.h
@@ -8075,7 +8075,7 @@
      * to access members of the value, but cannot modify
      */
     inline const KeyValuePair *operator->() {
-      return &(*it);
+      return &*kv_p;
     }

     /*


rm unused

rm unused

Former-commit-id: 70f03c026d0b5a525ac8e81534db55aa61b32f1d

--- mtrail/src/mtrail/mt_2d.h
+++ mtrail/src/mtrail/mt_2d.h
@@ -44,21 +44,7 @@

 	struct sm_vec2 pos;
 	float angle;
-
-	struct mt_color col_mul, col_mul_delta;
-	struct mt_color col_add, col_add_delta;
-
-	union {
-		// image
-		struct {
-			int zz;
-		} A;
-
-		// shape
-		struct {
-			float size, size_delta;
-		} B;
-	} mode;
+	int _dummy;		// unused: dummy for align to 64bit

 	struct t2d_particle* next;
 };
@@ -74,18 +60,6 @@
 	float fadeout_time;

 	int mode_type;
-	union {
-		// image
-		struct {
-			int sym_count;
-			struct t2d_symbol* syms;
-		} A;
-
-		// shape
-		struct {
-			int zz;
-		} B;
-	} mode;

 	int symbol_count;
 	struct t2d_symbol* symbols;
@@ -106,8 +80,6 @@
 	struct t2d_emitter* next;
 };

-#define SIZEOF_T2D_EMITTER (sizeof(struct t2d_emitter) + PTR_SIZE_DIFF * 3)
-
 void t2d_init();
 void t2d_regist_cb(void (*render_symbol_func)(void* symbol, float x, float y, float angle, float scale, uint8_t* mul_col, uint8_t* add_col, const void* ud),
 				   void (*render_shape_func)(const float* positions, const uint32_t* colors, int count));


Removing TryConsolidateNode() since now we consolidate node only in need

--- src/bwtree.h
+++ src/bwtree.h
@@ -3739,13 +3739,7 @@
     // deal with (e.g. go to its parent and comsolidate parent first) then
     // we should aggressively comsolidate the SMO away to avoid further
     // access
-    bool recommend_consolidation = FinishPartialSMO(context_p);
-
-    if(context_p->abort_flag == true) {
-      return;
-    }
-
-    TryConsolidateNode(context_p, recommend_consolidation);
+    FinishPartialSMO(context_p);

     if(context_p->abort_flag == true) {
       return;
@@ -3772,13 +3766,7 @@
     // This updates the current snapshot in the stack
     UpdateNodeSnapshot(node_id, context_p);

-    bool recommend_consolidation = FinishPartialSMO(context_p);
-
-    if(context_p->abort_flag == true) {
-      return;
-    }
-
-    TryConsolidateNode(context_p, recommend_consolidation);
+    FinishPartialSMO(context_p);

     if(context_p->abort_flag == true) {
       return;
@@ -4658,124 +4646,6 @@
     }

     return;
-  }
-
-  /*
-   * TryConsolidateNode() - Consolidate current node if its length exceeds the
-   *                        threshold value
-   *
-   * If the length of delta chain does not exceed the threshold then this
-   * function does nothing
-   *
-   * If function returns true then we have successfully consolidated a node
-   * Otherwise no consolidation happens. The return value might be used
-   * as a hint for deciding whether to adjust node size or not
-   *
-   * NOTE: If consolidation fails then this function does not do anything
-   * and will just continue with its own job. There is no chance of abort
-   *
-   * TODO: If strict mode is on, then whenever consolidation fails we should
-   * always abort and start from the beginning, to keep delta chain length
-   * upper bound intact
-   */
-  bool TryConsolidateNode(Context *context_p,
-                          bool recommend_consolidation) {
-    NodeSnapshot *snapshot_p = GetLatestNodeSnapshot(context_p);
-
-    // Do not overwrite this pointer since we will use this
-    // to locate garbage delta chain
-    const BaseNode *node_p = snapshot_p->node_p;
-    NodeID node_id = snapshot_p->node_id;
-
-    // We could only perform consolidation on delta node
-    // because we want to see depth field
-    if(node_p->IsDeltaNode() == false) {
-      assert(recommend_consolidation == false);
-
-      // The depth of base node may not be 0
-      // since if we consolidate parent node to finish the partial SMO,
-      // then parent node will have non-0 depth in order to avoid being too
-      // large (see FindSplitNextKey() and FindMergePrevNextKey() and
-      // JumpToLeftSibling())
-      // assert(node_p->metadata.depth == 0);
-
-      return false;
-    }
-
-    // If depth does not exceeds threshold then we check recommendation flag
-    int depth = node_p->GetDepth();
-
-    if(snapshot_p->IsLeaf() == true) {
-      // Adjust the length a little bit using this variable
-      // NOTE: The length of the delta chain on leaf coule be a
-      // little bit longer than on inner
-      // so this is usually a negative value
-      // This improves performance
-      depth += DELTA_CHAIN_LENGTH_THRESHOLD_LEAF_DIFF;
-    }
-
-    if(depth < DELTA_CHAIN_LENGTH_THRESHOLD) {
-      // If there is not recommended consolidation just return
-      if(recommend_consolidation == false) {
-        return false;
-      } else {
-        bwt_printf("Delta chian length < threshold, "
-                   "but consolidation is recommended\n");
-      }
-    }
-
-    // After this point we decide to consolidate node
-
-    if(snapshot_p->IsLeaf()) {
-      // This function returns a leaf node object
-      const LeafNode *leaf_node_p = CollectAllValuesOnLeaf(snapshot_p);
-
-      // CAS leaf node
-      bool ret = InstallNodeToReplace(node_id, leaf_node_p, node_p);
-      if(ret == true) {
-        bwt_printf("Leaf node consolidation (ID %lu) CAS succeeds\n",
-                   node_id);
-
-        // Update current snapshot using our best knowledge
-        snapshot_p->node_p = leaf_node_p;
-
-        // Add the old delta chain to garbage list and its
-        // deallocation is delayed
-        epoch_manager.AddGarbageNode(node_p);
-      } else {
-        bwt_printf("Leaf node consolidation CAS failed. NO ABORT\n");
-
-        // TODO: If we want to keep delta chain length constant then it
-        // should abort here
-
-        delete leaf_node_p;
-
-        return false;
-      } // if CAS succeeds / fails
-    } else {
-      const InnerNode *inner_node_p = CollectAllSepsOnInner(snapshot_p);
-
-      bool ret = InstallNodeToReplace(node_id, inner_node_p, node_p);
-      if(ret == true) {
-        bwt_printf("Inner node consolidation (ID %lu) CAS succeeds\n",
-                   node_id);
-
-        snapshot_p->node_p = inner_node_p;
-
-        // Add the old delta into garbage list
-        epoch_manager.AddGarbageNode(node_p);
-      } else {
-        bwt_printf("Inner node consolidation CAS failed. NO ABORT\n");
-
-        context_p->abort_flag = true;
-
-        delete inner_node_p;
-
-        return false;
-      } // if CAS succeeds / fails
-    } // if it is leaf / is inner
-
-    return true;
   }

   /*


Fix the last remaining test_csv failure. We were using T_CHAR for a UNICODE character. (This happened to work on x86 most of the time due to endianness; but not on PPC.)

--- Modules/_csv.c
+++ Modules/_csv.c
@@ -186,6 +186,12 @@
 }

 static PyObject *
+Dialect_get_delimiter(DialectObj *self)
+{
+        return get_nullchar_as_None(self->delimiter);
+}
+
+static PyObject *
 Dialect_get_escapechar(DialectObj *self)
 {
         return get_nullchar_as_None(self->escapechar);
@@ -292,7 +298,6 @@
 #define D_OFF(x) offsetof(DialectObj, x)

 static struct PyMemberDef Dialect_memberlist[] = {
-	{ "delimiter",          T_CHAR, D_OFF(delimiter), READONLY },
 	{ "skipinitialspace",   T_INT, D_OFF(skipinitialspace), READONLY },
 	{ "doublequote",        T_INT, D_OFF(doublequote), READONLY },
 	{ "strict",             T_INT, D_OFF(strict), READONLY },
@@ -300,6 +305,7 @@
 };

 static PyGetSetDef Dialect_getsetlist[] = {
+	{ "delimiter",          (getter)Dialect_get_delimiter},
 	{ "escapechar",		(getter)Dialect_get_escapechar},
 	{ "lineterminator",	(getter)Dialect_get_lineterminator},
 	{ "quotechar",		(getter)Dialect_get_quotechar},


conf: Don't free uninitialized pointer

conf: Don't free uninitialized pointer

This causes libvirtd to crash when both <boot dev='...'/> and <boot
order='...'/> are used in one domain XML. Introduced by
5fa3d775a9f8cdb3423373eb084219aaf778df11

--- src/conf/domain_conf.c
+++ src/conf/domain_conf.c
@@ -6430,7 +6430,8 @@
 {
     xmlNodePtr *nodes = NULL;
     int i, n;
-    char *bootstr, *useserial;
+    char *bootstr;
+    char *useserial = NULL;
     int ret = -1;
     unsigned long deviceBoot, serialPorts;


git-svn-id: https://svn.apache.org/repos/asf/webservices/axis2/trunk/c@550505 13f79535-47bb-0310-9956-ffa450edef68

--- axiom/src/parser/guththila/guththila_xml_reader_wrapper.c
+++ axiom/src/parser/guththila/guththila_xml_reader_wrapper.c
@@ -245,7 +245,7 @@
     const char *encoding)
 {
     guththila_xml_reader_wrapper_impl_t *guththila_impl = NULL;
-    axutil_allocator_t *allocator = NULL;
+    //axutil_allocator_t *allocator = NULL;
     guththila_t *guththila = NULL;

     AXIS2_ENV_CHECK(env, NULL);
@@ -259,7 +259,7 @@
         return NULL;
     }

-    allocator = axutil_allocator_init(NULL);
+    //allocator = axutil_allocator_init(NULL);

     /*-------difference of two create function is here--------*/
     guththila_impl->reader =
@@ -326,7 +326,7 @@
     int type)
 {
     guththila_xml_reader_wrapper_impl_t *guththila_impl = NULL;
-    axutil_allocator_t *allocator = NULL;
+    //axutil_allocator_t *allocator = NULL;
     guththila_t *guththila = NULL;

     AXIS2_ENV_CHECK(env, NULL);
@@ -340,7 +340,7 @@
         return NULL;
     }

-    allocator = axutil_allocator_init(NULL);
+    //allocator = axutil_allocator_init(NULL);

     /*-------difference of two create function is here--------*/
     guththila_impl->reader =


Move two functions to private

Move two functions to private

--- src/bwtree.h
+++ src/bwtree.h
@@ -331,35 +331,8 @@
   // We need to make it atomic since multiple threads might try to modify it
   uint64_t epoch;

- public:
-
-  /*
-   * Constructor - Initialize GC data structure
-   */
-  BwTreeBase() :
-    gc_metadata_p{nullptr},
-    original_p{nullptr},
-    thread_num{total_thread_num.load()},
-    epoch{0UL} {
-
-    // Allocate memory for thread local data structure
-    PrepareThreadLocal();
-
-    return;
-  }
-
-  /*
-   * Destructor - Manually call destructor and then frees the memory
-   */
-  ~BwTreeBase() {
-    // Frees all metadata
-    DestroyThreadLocal();
-
-    bwt_printf("Finished destroying class BwTreeBase\n")
-
-    return;
-  }
-
+ private:
+
   /*
    * DestroyThreadLocal() - Destroies thread local
    *
@@ -420,6 +393,35 @@
     }

     return;
+  }
+
+ public:
+
+  /*
+   * Constructor - Initialize GC data structure
+   */
+  BwTreeBase() :
+    gc_metadata_p{nullptr},
+    original_p{nullptr},
+    thread_num{total_thread_num.load()},
+    epoch{0UL} {
+
+    // Allocate memory for thread local data structure
+    PrepareThreadLocal();
+
+    return;
+  }
+
+  /*
+   * Destructor - Manually call destructor and then frees the memory
+   */
+  ~BwTreeBase() {
+    // Frees all metadata
+    DestroyThreadLocal();
+
+    bwt_printf("Finished destroying class BwTreeBase\n")
+
+    return;
   }

   /*


doc: document when GrpcNumChannelsOption applies (#10000)

--- google/cloud/grpc_options.h
+++ google/cloud/grpc_options.h
@@ -41,6 +41,13 @@
  * gRPC limits the number of simultaneous calls in progress on a channel to
  * 100. Increasing the number of channels thus increases the number of
  * operations that can be in progress in parallel.
+ *
+ * @note This option only applies when passed to the following functions:
+ * - `bigtable::MakeDataConnection()`
+ * - `pubsub::MakePublisherConnection()`
+ * - `pubsub::MakeSubscriberConnection()`
+ * - `spanner::MakeConnection()`
+ * - `storage_experimental::DefaultGrpcClient()`
  */
 struct GrpcNumChannelsOption {
   using Type = int;


m68k: teach modpost about .m68_fixup

m68k: teach modpost about .m68_fixup

Signed-off-by: Al Viro <de609eb4d5d70b1d38ec6642adbfc33a2781f63c@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- scripts/mod/modpost.c
+++ scripts/mod/modpost.c
@@ -1076,6 +1076,7 @@
 		".plt",			/* seen on ARCH=um build on x86_64. Harmless */
 		".smp_locks",
 		".stab",
+		".m68k_fixup",
 		NULL
 	};
 	/* Start of section names */


virDomainFSDefFree: Unref private data

virDomainFSDefFree: Unref private data

The privateData object is allocated in virDomainFSDefNew() but
never unref'd.

==119642== 480 bytes in 20 blocks are definitely lost in loss record 656 of 671
==119642==    at 0x4837B86: calloc (vg_replace_malloc.c:762)
==119642==    by 0x57806A0: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6000.7)
==119642==    by 0x4AE7392: virAllocVar (viralloc.c:331)
==119642==    by 0x4B64395: virObjectNew (virobject.c:241)
==119642==    by 0x48F1464: qemuDomainFSPrivateNew (qemu_domain.c:1427)
==119642==    by 0x4BBF004: virDomainFSDefNew (domain_conf.c:2307)
==119642==    by 0x4BD859A: virDomainFSDefParseXML (domain_conf.c:11217)
==119642==    by 0x4BF9DD1: virDomainDefParseXML (domain_conf.c:21179)
==119642==    by 0x4BFCD5B: virDomainDefParseNode (domain_conf.c:21943)
==119642==    by 0x4BFCC36: virDomainDefParse (domain_conf.c:21901)
==119642==    by 0x4BFCCCB: virDomainDefParseFile (domain_conf.c:21924)
==119642==    by 0x114A9D: testCompareXMLToArgv (qemuxml2argvtest.c:452)

Fixes: 5120577ed79f89e172e3deed534fa9b585f4701f
Signed-off-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>
Reviewed-by: Ján Tomko <4cab11cfb98d3c937327354a78eb07dbb6ee2bc6@redhat.com>

--- src/conf/domain_conf.c
+++ src/conf/domain_conf.c
@@ -2324,6 +2324,7 @@
     VIR_FREE(def->dst);
     virDomainDeviceInfoClear(&def->info);
     VIR_FREE(def->virtio);
+    virObjectUnref(def->privateData);

     VIR_FREE(def);
 }


reinstate old label name for ingex player

--- mxf/mxf_labels_and_keys.h
+++ mxf/mxf_labels_and_keys.h
@@ -465,6 +465,10 @@
 static const mxfUL MXF_EC_L(AVCFrameWrapped) = MXF_AVC_BYTESTREAM_EC_L(0x01);
 static const mxfUL MXF_EC_L(AVCClipWrapped)  = MXF_AVC_BYTESTREAM_EC_L(0x02);

+/* Legacy naming used in Ingex player */
+static const mxfUL MXF_EC_L(AVCIFrameWrapped) = MXF_AVC_BYTESTREAM_EC_L(0x01);
+static const mxfUL MXF_EC_L(AVCIClipWrapped)  = MXF_AVC_BYTESTREAM_EC_L(0x02);
+
 int mxf_is_avc_ec(const mxfUL *label, int frame_wrapped);


use overwrite for scene change detector

use overwrite for scene change detector

--- codec/processing/src/scenechangedetection/SceneChangeDetection.h
+++ codec/processing/src/scenechangedetection/SceneChangeDetection.h
@@ -72,7 +72,7 @@
   }
   virtual ~CSceneChangeDetectorVideo() {
   }
-  virtual void operator () (uint8_t* pSrcY, int32_t iSrcStrideY, uint8_t* pRefY, int32_t iRefStrideY, uint8_t *& pStaticBlockIdc) {
+  void operator () (uint8_t* pSrcY, int32_t iSrcStrideY, uint8_t* pRefY, int32_t iRefStrideY, uint8_t *& pStaticBlockIdc) {
     int32_t iSad = m_pfSad(pSrcY, iSrcStrideY, pRefY, iSrcStrideY);
     m_sParam.iMotionBlockNum += iSad > HIGH_MOTION_BLOCK_THRESHOLD;
   }
@@ -87,7 +87,7 @@
   }
   virtual ~CSceneChangeDetectorScreen() {
   }
-  virtual void operator() (uint8_t* pSrcY, int32_t iSrcStrideY, uint8_t* pRefY, int32_t iRefStrideY, uint8_t *& pStaticBlockIdc) {
+  void operator() (uint8_t* pSrcY, int32_t iSrcStrideY, uint8_t* pRefY, int32_t iRefStrideY, uint8_t *& pStaticBlockIdc) {
     int32_t iSad = m_pfSad(pSrcY, iSrcStrideY, pRefY, iSrcStrideY);
     if( iSad == 0 ){
       *pStaticBlockIdc ++ = NO_STATIC;


Added "random" method to Gaussian class.

Now it's possible to randomize with Gaussian distribuition.
MAX_VARIANCE increased to maximize precision.

--- Gaussian.h
+++ Gaussian.h
@@ -13,7 +13,10 @@
 #ifndef Gaussian_h
 #define Gaussian_h

-#define MAX_VARIANCE 100000
+#include "Math.h"
+#include "Arduino.h"
+
+#define MAX_VARIANCE 2147483600

 class Gaussian
 {
@@ -116,6 +119,17 @@
 		*this = sum(_gaus);
 	}

+	/*
+		Randomize a variable with Gaussian distribuition,
+		using it's mean and variance
+	*/
+	virtual double random(){
+		double R1, R2;
+		R1 = ::random(MAX_VARIANCE)/(double)MAX_VARIANCE;
+		R2 = ::random(MAX_VARIANCE)/(double)MAX_VARIANCE;
+		return mean + variance * cos( 2 * M_PI * R1) * sqrt(-log(R2));
+	}
+
 };


[t:4462] fixing compilation errors

[t:4462] fixing compilation errors

git-svn-id: b5c078ec0b4d3a50497e9dd3081db18a5b4f16e5@39695 c7de825b-a66e-492c-adef-691d508d4ae1

--- src/tests/threaded_stress_test_helpers.h
+++ src/tests/threaded_stress_test_helpers.h
@@ -1234,13 +1234,12 @@
     scan_arg.operation_extra = &soe;
     scan_arg.operation = scan_op_no_check;
     scan_arg.lock_type = STRESS_LOCK_NONE;
-    int64_t x;
     struct worker_extra we;
-    we.thread_arg = &arg;
+    we.thread_arg = &scan_arg;
     we.operation_lock = NULL;
     we.operation_lock_mutex = NULL;
-    we.num_operations_completed = &x;
-    worker(&worker_extra);
+    we.num_operations_completed = 0;
+    worker(&we);
 }

 static void


Include clutter-json.h, not json-types.h

The json-types.h header is found by the mere fact of it being
in the project; if we are compiling against the system JSON-GLib
this could be horribly out of date.

We need to use clutter-json.h, which will include the right
header for us.

--- clutter/clutter-script-private.h
+++ clutter/clutter-script-private.h
@@ -27,7 +27,7 @@
 #define __CLUTTER_SCRIPT_PRIVATE_H__

 #include <glib-object.h>
-#include "json/json-types.h"
+#include "clutter-json.h"
 #include "clutter-color.h"
 #include "clutter-types.h"
 #include "clutter-script.h"


Fix minor typo in comment (numberes -> numbers) Change: 114566035

--- tensorflow/core/lib/random/random_distributions.h
+++ tensorflow/core/lib/random/random_distributions.h
@@ -34,10 +34,10 @@
 // underlying random integer generator.
 // Arguments:
 //   Generator: a generator type that returns a number of uint32 upon each
-//              each invocation. It needs to define kResultElementCount for the
-//              sample count for each invocation, and ResultType for actual
-//              returned sample type.
-//   RealType: the data type of the real numberes that will be returned by the
+//              invocation. It needs to define kResultElementCount for the
+//              sample count for each invocation, and ResultType for the
+//              actual returned sample type.
+//   RealType: the data type of the real numbers that will be returned by the
 //             distribution. This could be either float or double for now.
 // This class is meant to be implemented through specialization. The default
 // is not defined by design.


tortoise cvs told me to commit the file too

error: pathspec 'ScriptingModules/CEGUILua/lua_and_tolua++/src/tolua++/tolua_map_original.c' did not match any file(s) known to git

--- ScriptingModules/CEGUILua/lua_and_tolua++/src/tolua++/tolua_map_original.c
+++ ScriptingModules/CEGUILua/lua_and_tolua++/src/tolua++/tolua_map_original.c
@@ -0,0 +1,577 @@
+/* tolua: functions to map features
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** Apr 2003
+** $Id$
+*/
+
+/* This code is free software; you can redistribute it and/or modify it.
+** The software provided hereunder is on an "as is" basis, and
+** the author has no obligation to provide maintenance, support, updates,
+** enhancements, or modifications.
+*/
+
+#include "tolua++.h"
+#include "tolua_event.h"
+#include "lauxlib.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+/* Create metatable
+	* Create and register new metatable
+*/
+static int tolua_newmetatable (lua_State* L, char* name)
+{
+ int r = luaL_newmetatable(L,name);
+	if (r)
+	 tolua_classevents(L); /* set meta events */
+ lua_pop(L,1);
+	return r;
+}
+
+/* Map super classes
+	* It sets 'name' as being also a 'base', mapping all super classes of 'base' in 'name'
+*/
+static void mapsuper (lua_State* L, const char* name, const char* base)
+{
+	/* push registry.super */
+ lua_pushstring(L,"tolua_super");
+ lua_rawget(L,LUA_REGISTRYINDEX);    /* stack: super */
+	luaL_getmetatable(L,name);          /* stack: super mt */
+ lua_rawget(L,-2);                   /* stack: super table */
+	if (lua_isnil(L,-1))
+	{
+	 /* create table */
+		lua_pop(L,1);
+	 lua_newtable(L);                    /* stack: super table */
+	 luaL_getmetatable(L,name);          /* stack: super table mt */
+		lua_pushvalue(L,-2);                /* stack: super table mt table */
+		lua_rawset(L,-4);                   /* stack: super table */
+	}
+
+	/* set base as super class */
+	lua_pushstring(L,base);
+	lua_pushboolean(L,1);
+	lua_rawset(L,-3);                    /* stack: super table */
+
+	/* set all super class of base as super class of name */
+	luaL_getmetatable(L,base);          /* stack: super table base_mt */
+	lua_rawget(L,-3);                   /* stack: super table base_table */
+	if (lua_istable(L,-1))
+	{
+		/* traverse base table */
+		lua_pushnil(L);  /* first key */
+		while (lua_next(L,-2) != 0)
+		{
+			/* stack: ... base_table key value */
+			lua_pushvalue(L,-2);    /* stack: ... base_table key value key */
+			lua_insert(L,-2);       /* stack: ... base_table key key value */
+			lua_rawset(L,-5);       /* stack: ... base_table key */
+		}
+	}
+	lua_pop(L,3);                       /* stack: <empty> */
+}
+
+/* creates a 'tolua_ubox' table for base clases, and
+// expects the metatable and base metatable on the stack */
+static void set_ubox(lua_State* L) {
+
+	/* mt basemt */
+	if (!lua_isnil(L, -1)) {
+		lua_pushstring(L, "tolua_ubox");
+		lua_rawget(L,-2);
+	} else {
+		lua_pushnil(L);
+	};
+	/* mt basemt base_ubox */
+	if (!lua_isnil(L,-1)) {
+		lua_pushstring(L, "tolua_ubox");
+		lua_insert(L, -2);
+		/* mt basemt key ubox */
+		lua_rawset(L,-4);
+		/* (mt with ubox) basemt */
+	} else {
+		/* mt basemt nil */
+		lua_pop(L, 1);
+		lua_pushstring(L,"tolua_ubox"); lua_newtable(L);
+		/* make weak value metatable for ubox table to allow userdata to be
+		garbage-collected */
+		lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "v"); lua_rawset(L, -3);               /* stack: string ubox mt */
+		lua_setmetatable(L, -2);  /* stack:mt basemt string ubox */
+		lua_rawset(L,-4);
+	};
+
+};
+
+/* Map inheritance
+	* It sets 'name' as derived from 'base' by setting 'base' as metatable of 'name'
+*/
+static void mapinheritance (lua_State* L, const char* name, const char* base)
+{
+	/* set metatable inheritance */
+	luaL_getmetatable(L,name);
+
+	if (base && *base)
+		luaL_getmetatable(L,base);
+	else {
+
+		if (lua_getmetatable(L, -1)) { /* already has a mt, we don't overwrite it */
+			lua_pop(L, 2);
+			return;
+		};
+		luaL_getmetatable(L,"tolua_commonclass");
+	};
+
+	set_ubox(L);
+
+	lua_setmetatable(L,-2);
+	lua_pop(L,1);
+}
+
+/* Object type
+*/
+static int tolua_bnd_type (lua_State* L)
+{
+	tolua_typename(L,lua_gettop(L));
+	return 1;
+}
+
+/* Take ownership
+*/
+static int tolua_bnd_takeownership (lua_State* L)
+{
+	int success = 0;
+	if (lua_isuserdata(L,1))
+	{
+		if (lua_getmetatable(L,1))        /* if metatable? */
+		{
+			lua_pop(L,1);             /* clear metatable off stack */
+			/* force garbage collection to avoid C to reuse a to-be-collected address */
+			lua_setgcthreshold(L,0);
+			success = tolua_register_gc(L,1);
+		}
+	}
+	lua_pushboolean(L,success!=0);
+	return 1;
+}
+
+/* Release ownership
+*/
+static int tolua_bnd_releaseownership (lua_State* L)
+{
+	int done = 0;
+	if (lua_isuserdata(L,1))
+	{
+	 void* u = *((void**)lua_touserdata(L,1));
+		/* force garbage collection to avoid releasing a to-be-collected address */
+		lua_setgcthreshold(L,0);
+  lua_pushstring(L,"tolua_gc");
+  lua_rawget(L,LUA_REGISTRYINDEX);
+	 lua_pushlightuserdata(L,u);
+	 lua_rawget(L,-2);
+	 lua_getmetatable(L,1);
+	 if (lua_rawequal(L,-1,1))  /* check that we are releasing the correct type */
+	 {
+	  lua_pushlightuserdata(L,u);
+		 lua_pushnil(L);
+		 lua_rawset(L,-4);
+   done = 1;
+		}
+	}
+	lua_pushboolean(L,done!=0);
+	return 1;
+}
+
+/* Type casting
+*/
+static int tolua_bnd_cast (lua_State* L)
+{
+
+/* // old code
+        void* v = tolua_tousertype(L,1,NULL);
+        const char* s = tolua_tostring(L,2,NULL);
+        if (v && s)
+         tolua_pushusertype(L,v,s);
+        else
+         lua_pushnil(L);
+        return 1;
+*/
+
+	void* v;
+	if (lua_getmetatable(L, 1)) {
+		/* lua_pop(L, 1); */
+		v = tolua_tousertype(L,1,NULL);
+	} else {
+		v = tolua_touserdata(L, 1, NULL);
+	};
+
+	const char* s = tolua_tostring(L,2,NULL);
+	if (v && s)
+	 tolua_pushusertype(L,v,s);
+	else
+	 lua_pushnil(L);
+	return 1;
+}
+
+TOLUA_API void tolua_open (lua_State* L)
+{
+ int top = lua_gettop(L);
+ lua_pushstring(L,"tolua_opened");
+ lua_rawget(L,LUA_REGISTRYINDEX);
+ if (!lua_isboolean(L,-1))
+ {
+  lua_pushstring(L,"tolua_opened"); lua_pushboolean(L,1); lua_rawset(L,LUA_REGISTRYINDEX);
+
+  /* create peer object table */
+  lua_pushstring(L, "tolua_peers"); lua_newtable(L);
+  /* make weak key metatable for peers indexed by userdata object */
+  lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "k"); lua_rawset(L, -3);                /* stack: string peers mt */
+  lua_setmetatable(L, -2);   /* stack: string peers */
+  lua_rawset(L,LUA_REGISTRYINDEX);
+
+  /* create object ptr -> udata mapping table */
+  lua_pushstring(L,"tolua_ubox"); lua_newtable(L);
+  /* make weak value metatable for ubox table to allow userdata to be
+     garbage-collected */
+  lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "v"); lua_rawset(L, -3);               /* stack: string ubox mt */
+  lua_setmetatable(L, -2);  /* stack: string ubox */
+  lua_rawset(L,LUA_REGISTRYINDEX);
+
+  lua_pushstring(L,"tolua_super"); lua_newtable(L); lua_rawset(L,LUA_REGISTRYINDEX);
+  lua_pushstring(L,"tolua_gc"); lua_newtable(L);lua_rawset(L,LUA_REGISTRYINDEX);
+
+  tolua_newmetatable(L,"tolua_commonclass");
+
+  tolua_module(L,NULL,0);
+  tolua_beginmodule(L,NULL);
+  tolua_module(L,"tolua",0);
+  tolua_beginmodule(L,"tolua");
+  tolua_function(L,"type",tolua_bnd_type);
+  tolua_function(L,"takeownership",tolua_bnd_takeownership);
+  tolua_function(L,"releaseownership",tolua_bnd_releaseownership);
+  tolua_function(L,"cast",tolua_bnd_cast);
+  tolua_endmodule(L);
+  tolua_endmodule(L);
+ }
+ lua_settop(L,top);
+}
+
+/* Copy a C object
+*/
+TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size)
+{
+	void* clone = (void*)malloc(size);
+	if (clone)
+	 memcpy(clone,value,size);
+	else
+		tolua_error(L,"insuficient memory",NULL);
+	return clone;
+}
+
+/* Default collect function
+*/
+TOLUA_API int tolua_default_collect (lua_State* tolua_S)
+{
+ void* self = tolua_tousertype(tolua_S,1,0);
+ free(self);
+ return 0;
+}
+
+/* Do clone
+*/
+TOLUA_API int tolua_register_gc (lua_State* L, int lo)
+{
+ int success = 1;
+ void *value = *(void **)lua_touserdata(L,lo);
+ lua_pushstring(L,"tolua_gc");
+ lua_rawget(L,LUA_REGISTRYINDEX);
+	lua_pushlightuserdata(L,value);
+	lua_rawget(L,-2);
+	if (!lua_isnil(L,-1)) /* make sure that object is not already owned */
+		success = 0;
+	else
+	{
+		lua_pushlightuserdata(L,value);
+		lua_getmetatable(L,lo);
+		lua_rawset(L,-4);
+	}
+	lua_pop(L,2);
+	return success;
+}
+
+/* Register a usertype
+	* It creates the correspoding metatable in the registry, for both 'type' and 'const type'.
+	* It maps 'const type' as being also a 'type'
+*/
+TOLUA_API void tolua_usertype (lua_State* L, char* type)
+{
+ char ctype[128] = "const ";
+ strncat(ctype,type,120);
+
+	/* create both metatables */
+ if (tolua_newmetatable(L,ctype) && tolua_newmetatable(L,type))
+	 mapsuper(L,type,ctype);             /* 'type' is also a 'const type' */
+}
+
+
+/* Begin module
+	* It pushes the module (or class) table on the stack
+*/
+TOLUA_API void tolua_beginmodule (lua_State* L, char* name)
+{
+	if (name)
+	{
+	 lua_pushstring(L,name);
+		lua_rawget(L,-2);
+	}
+	else
+	 lua_pushvalue(L,LUA_GLOBALSINDEX);
+}
+
+/* End module
+	* It pops the module (or class) from the stack
+*/
+TOLUA_API void tolua_endmodule (lua_State* L)
+{
+	lua_pop(L,1);
+}
+
+/* Map module
+	* It creates a new module
+*/
+#if 1
+TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar)
+{
+	if (name)
+	{
+		/* tolua module */
+		lua_pushstring(L,name);
+		lua_rawget(L,-2);
+		if (!lua_istable(L,-1))  /* check if module already exists */
+		{
+			lua_pop(L,1);
+		 lua_newtable(L);
+		 lua_pushstring(L,name);
+			lua_pushvalue(L,-2);
+		 lua_rawset(L,-4);       /* assing module into module */
+		}
+	}
+	else
+	{
+		/* global table */
+		lua_pushvalue(L,LUA_GLOBALSINDEX);
+	}
+	if (hasvar)
+	{
+		if (!tolua_ismodulemetatable(L))  /* check if it already has a module metatable */
+		{
+			/* create metatable to get/set C/C++ variable */
+			lua_newtable(L);
+			tolua_moduleevents(L);
+			if (lua_getmetatable(L,-2))
+				lua_setmetatable(L,-2);  /* set old metatable as metatable of metatable */
+			lua_setmetatable(L,-2);
+		}
+	}
+	lua_pop(L,1);               /* pop module */
+}
+#else
+TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar)
+{
+	if (name)
+	{
+		/* tolua module */
+		lua_pushstring(L,name);
+		lua_newtable(L);
+	}
+	else
+	{
+		/* global table */
+		lua_pushvalue(L,LUA_GLOBALSINDEX);
+	}
+	if (hasvar)
+	{
+		/* create metatable to get/set C/C++ variable */
+		lua_newtable(L);
+		tolua_moduleevents(L);
+		if (lua_getmetatable(L,-2))
+			lua_setmetatable(L,-2);  /* set old metatable as metatable of metatable */
+		lua_setmetatable(L,-2);
+	}
+	if (name)
+		lua_rawset(L,-3);       /* assing module into module */
+	else
+		lua_pop(L,1);           /* pop global table */
+}
+#endif
+
+/* Map C class
+	* It maps a C class, setting the appropriate inheritance and super classes.
+*/
+TOLUA_API void tolua_cclass (lua_State* L, char* lname, char* name, char* base, lua_CFunction col)
+{
+	char cname[128] = "const ";
+	char cbase[128] = "const ";
+	strncat(cname,name,120);
+	strncat(cbase,base,120);
+
+	mapinheritance(L,name,base);
+	mapinheritance(L,cname,name);
+
+	mapsuper(L,cname,cbase);
+	mapsuper(L,name,base);
+
+	lua_pushstring(L,lname);
+	luaL_getmetatable(L,name);
+	lua_pushstring(L,".collector");
+	lua_pushcfunction(L,col);
+
+	lua_rawset(L,-3);              /* store collector function into metatable */
+	lua_rawset(L,-3);              /* assign class metatable to module */
+
+	/* now we also need to store the collector table for the const
+	   instances of the class */
+	luaL_getmetatable(L,cname);
+	lua_pushstring(L,".collector");
+	lua_pushcfunction(L,col);
+	lua_rawset(L,-3);
+	lua_pop(L,1);                  /* get rid of metatable for const object */
+
+}
+
+/* Add base
+	* It adds additional base classes to a class (for multiple inheritance)
+	* (not for now)
+TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base) {
+
+	char cname[128] = "const ";
+	char cbase[128] = "const ";
+	strncat(cname,name,120);
+	strncat(cbase,base,120);
+
+	mapsuper(L,cname,cbase);
+	mapsuper(L,name,base);
+};
+*/
+
+/* Map function
+	* It assigns a function into the current module (or class)
+*/
+TOLUA_API void tolua_function (lua_State* L, char* name, lua_CFunction func)
+{
+ lua_pushstring(L,name);
+ lua_pushcfunction(L,func);
+	lua_rawset(L,-3);
+}
+
+/* sets the __call event for the class (expects the class' main table on top) */
+TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type) {
+
+	lua_getmetatable(L, -1);
+	/*luaL_getmetatable(L, type);*/
+	lua_pushstring(L,"__call");
+	lua_pushcfunction(L,func);
+	lua_rawset(L,-3);
+	lua_pop(L, 1);
+};
+
+/* Map constant number
+	* It assigns a constant number into the current module (or class)
+*/
+TOLUA_API void tolua_constant (lua_State* L, char* name, double value)
+{
+	lua_pushstring(L,name);
+	tolua_pushnumber(L,value);
+	lua_rawset(L,-3);
+}
+
+
+/* Map variable
+	* It assigns a variable into the current module (or class)
+*/
+TOLUA_API void tolua_variable (lua_State* L, char* name, lua_CFunction get, lua_CFunction set)
+{
+	/* get func */
+	lua_pushstring(L,".get");
+	lua_rawget(L,-2);
+	if (!lua_istable(L,-1))
+	{
+		/* create .get table, leaving it at the top */
+		lua_pop(L,1);
+		lua_newtable(L);
+	 lua_pushstring(L,".get");
+		lua_pushvalue(L,-2);
+		lua_rawset(L,-4);
+	}
+	lua_pushstring(L,name);
+	lua_pushcfunction(L,get);
+ lua_rawset(L,-3);                  /* store variable */
+	lua_pop(L,1);                      /* pop .get table */
+
+	/* set func */
+	if (set)
+	{
+		lua_pushstring(L,".set");
+		lua_rawget(L,-2);
+		if (!lua_istable(L,-1))
+		{
+			/* create .set table, leaving it at the top */
+			lua_pop(L,1);
+			lua_newtable(L);
+			lua_pushstring(L,".set");
+			lua_pushvalue(L,-2);
+			lua_rawset(L,-4);
+		}
+		lua_pushstring(L,name);
+		lua_pushcfunction(L,set);
+		lua_rawset(L,-3);                  /* store variable */
+		lua_pop(L,1);                      /* pop .set table */
+	}
+}
+
+/* Access const array
+	* It reports an error when trying to write into a const array
+*/
+static int const_array (lua_State* L)
+{
+ luaL_error(L,"value of const array cannot be changed");
+ return 0;
+}
+
+/* Map an array
+	* It assigns an array into the current module (or class)
+*/
+TOLUA_API void tolua_array (lua_State* L, char* name, lua_CFunction get, lua_CFunction set)
+{
+	lua_pushstring(L,".get");
+	lua_rawget(L,-2);
+	if (!lua_istable(L,-1))
+	{
+		/* create .get table, leaving it at the top */
+		lua_pop(L,1);
+		lua_newtable(L);
+	 lua_pushstring(L,".get");
+		lua_pushvalue(L,-2);
+		lua_rawset(L,-4);
+	}
+	lua_pushstring(L,name);
+
+ lua_newtable(L);           /* create array metatable */
+ lua_pushvalue(L,-1);
+	lua_setmetatable(L,-2);    /* set the own table as metatable (for modules) */
+ lua_pushstring(L,"__index");
+ lua_pushcfunction(L,get);
+	lua_rawset(L,-3);
+ lua_pushstring(L,"__newindex");
+ lua_pushcfunction(L,set?set:const_array);
+	lua_rawset(L,-3);
+
+ lua_rawset(L,-3);                  /* store variable */
+	lua_pop(L,1);                      /* pop .get table */
+}
+


- Added the sig_t typedef to <signal.h>.

git-svn-id: 2bb8db730c750c20743bd1fa53c3f96cb40efdb0@14688 87f5fb63-7c3d-0410-a384-fd976d0f7a62