net/thunderx: add device start/stop and close

Signed-off-by: Jerin Jacob <5bca7d2a432bc0f5422b70b2701a4e4fa32edd00@caviumnetworks.com>
Signed-off-by: Maciej Czekaj <8d42daaa8d68ad54ca06613337e5c27633935527@caviumnetworks.com>
Signed-off-by: Kamil Rytarowski <c5f25be57ec63af57c261bfcaad64f8e4a79258b@caviumnetworks.com>
Signed-off-by: Zyta Szpak <e7f7ad3646dd4fe5e92a80fc64776bf64859c785@semihalf.com>
Signed-off-by: Slawomir Rosek <9eb5b0a7dcda67bfc31471595b7cdd6ce51b0869@semihalf.com>
Signed-off-by: Radoslaw Biernacki <bade5d26b78d94e5efb27f8cf03d43b298f69915@semihalf.com>

--- drivers/net/thunderx/nicvf_ethdev.c
+++ drivers/net/thunderx/nicvf_ethdev.c
@@ -69,6 +69,8 @@
 #include "nicvf_rxtx.h"
 #include "nicvf_logs.h"

+static void nicvf_dev_stop(struct rte_eth_dev *dev);
+
 static inline int
 nicvf_atomic_write_link_status(struct rte_eth_dev *dev,
 			       struct rte_eth_link *link)
@@ -534,6 +536,82 @@
 	return 0;
 }

+static int
+nicvf_qset_rbdr_alloc(struct nicvf *nic, uint32_t desc_cnt, uint32_t buffsz)
+{
+	struct nicvf_rbdr *rbdr;
+	const struct rte_memzone *rz;
+	uint32_t ring_size;
+
+	assert(nic->rbdr == NULL);
+	rbdr = rte_zmalloc_socket("rbdr", sizeof(struct nicvf_rbdr),
+				  RTE_CACHE_LINE_SIZE, nic->node);
+	if (rbdr == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate mem for rbdr");
+		return -ENOMEM;
+	}
+
+	ring_size = sizeof(struct rbdr_entry_t) * desc_cnt;
+	rz = rte_eth_dma_zone_reserve(nic->eth_dev, "rbdr", 0, ring_size,
+				   NICVF_RBDR_BASE_ALIGN_BYTES, nic->node);
+	if (rz == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate mem for rbdr desc ring");
+		return -ENOMEM;
+	}
+
+	memset(rz->addr, 0, ring_size);
+
+	rbdr->phys = rz->phys_addr;
+	rbdr->tail = 0;
+	rbdr->next_tail = 0;
+	rbdr->desc = rz->addr;
+	rbdr->buffsz = buffsz;
+	rbdr->qlen_mask = desc_cnt - 1;
+	rbdr->rbdr_status =
+		nicvf_qset_base(nic, 0) + NIC_QSET_RBDR_0_1_STATUS0;
+	rbdr->rbdr_door =
+		nicvf_qset_base(nic, 0) + NIC_QSET_RBDR_0_1_DOOR;
+
+	nic->rbdr = rbdr;
+	return 0;
+}
+
+static void
+nicvf_rbdr_release_mbuf(struct nicvf *nic, nicvf_phys_addr_t phy)
+{
+	uint16_t qidx;
+	void *obj;
+	struct nicvf_rxq *rxq;
+
+	for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) {
+		rxq = nic->eth_dev->data->rx_queues[qidx];
+		if (rxq->precharge_cnt) {
+			obj = (void *)nicvf_mbuff_phy2virt(phy,
+							   rxq->mbuf_phys_off);
+			rte_mempool_put(rxq->pool, obj);
+			rxq->precharge_cnt--;
+			break;
+		}
+	}
+}
+
+static inline void
+nicvf_rbdr_release_mbufs(struct nicvf *nic)
+{
+	uint32_t qlen_mask, head;
+	struct rbdr_entry_t *entry;
+	struct nicvf_rbdr *rbdr = nic->rbdr;
+
+	qlen_mask = rbdr->qlen_mask;
+	head = rbdr->head;
+	while (head != rbdr->tail) {
+		entry = rbdr->desc + head;
+		nicvf_rbdr_release_mbuf(nic, entry->full_addr);
+		head++;
+		head = head & qlen_mask;
+	}
+}
+
 static inline void
 nicvf_tx_queue_release_mbufs(struct nicvf_txq *txq)
 {
@@ -629,6 +707,31 @@
 	return ret;
 }

+static inline int
+nicvf_configure_rss(struct rte_eth_dev *dev)
+{
+	struct nicvf *nic = nicvf_pmd_priv(dev);
+	uint64_t rsshf;
+	int ret = -EINVAL;
+
+	rsshf = nicvf_rss_ethdev_to_nic(nic,
+			dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf);
+	PMD_DRV_LOG(INFO, "mode=%d rx_queues=%d loopback=%d rsshf=0x%" PRIx64,
+		    dev->data->dev_conf.rxmode.mq_mode,
+		    nic->eth_dev->data->nb_rx_queues,
+		    nic->eth_dev->data->dev_conf.lpbk_mode, rsshf);
+
+	if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_NONE)
+		ret = nicvf_rss_term(nic);
+	else if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_RSS)
+		ret = nicvf_rss_config(nic,
+				       nic->eth_dev->data->nb_rx_queues, rsshf);
+	if (ret)
+		PMD_INIT_LOG(ERR, "Failed to configure RSS %d", ret);
+
+	return ret;
+}
+
 static int
 nicvf_configure_rss_reta(struct rte_eth_dev *dev)
 {
@@ -670,6 +773,48 @@
 			txq->txbuffs = NULL;
 		}
 		rte_free(txq);
+	}
+}
+
+static void
+nicvf_set_tx_function(struct rte_eth_dev *dev)
+{
+	struct nicvf_txq *txq;
+	size_t i;
+	bool multiseg = false;
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		txq = dev->data->tx_queues[i];
+		if ((txq->txq_flags & ETH_TXQ_FLAGS_NOMULTSEGS) == 0) {
+			multiseg = true;
+			break;
+		}
+	}
+
+	/* Use a simple Tx queue (no offloads, no multi segs) if possible */
+	if (multiseg) {
+		PMD_DRV_LOG(DEBUG, "Using multi-segment tx callback");
+		dev->tx_pkt_burst = nicvf_xmit_pkts_multiseg;
+	} else {
+		PMD_DRV_LOG(DEBUG, "Using single-segment tx callback");
+		dev->tx_pkt_burst = nicvf_xmit_pkts;
+	}
+
+	if (txq->pool_free == nicvf_single_pool_free_xmited_buffers)
+		PMD_DRV_LOG(DEBUG, "Using single-mempool tx free method");
+	else
+		PMD_DRV_LOG(DEBUG, "Using multi-mempool tx free method");
+}
+
+static void
+nicvf_set_rx_function(struct rte_eth_dev *dev)
+{
+	if (dev->data->scattered_rx) {
+		PMD_DRV_LOG(DEBUG, "Using multi-segment rx callback");
+		dev->rx_pkt_burst = nicvf_recv_pkts_multiseg;
+	} else {
+		PMD_DRV_LOG(DEBUG, "Using single-segment rx callback");
+		dev->rx_pkt_burst = nicvf_recv_pkts;
 	}
 }

@@ -1064,6 +1209,317 @@
 	};
 }

+static nicvf_phys_addr_t
+rbdr_rte_mempool_get(void *opaque)
+{
+	uint16_t qidx;
+	uintptr_t mbuf;
+	struct nicvf_rxq *rxq;
+	struct nicvf *nic = nicvf_pmd_priv((struct rte_eth_dev *)opaque);
+
+	for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) {
+		rxq = nic->eth_dev->data->rx_queues[qidx];
+		/* Maintain equal buffer count across all pools */
+		if (rxq->precharge_cnt >= rxq->qlen_mask)
+			continue;
+		rxq->precharge_cnt++;
+		mbuf = (uintptr_t)rte_pktmbuf_alloc(rxq->pool);
+		if (mbuf)
+			return nicvf_mbuff_virt2phy(mbuf, rxq->mbuf_phys_off);
+	}
+	return 0;
+}
+
+static int
+nicvf_dev_start(struct rte_eth_dev *dev)
+{
+	int ret;
+	uint16_t qidx;
+	uint32_t buffsz = 0, rbdrsz = 0;
+	uint32_t total_rxq_desc, nb_rbdr_desc, exp_buffs;
+	uint64_t mbuf_phys_off = 0;
+	struct nicvf_rxq *rxq;
+	struct rte_pktmbuf_pool_private *mbp_priv;
+	struct rte_mbuf *mbuf;
+	struct nicvf *nic = nicvf_pmd_priv(dev);
+	struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode;
+	uint16_t mtu;
+
+	PMD_INIT_FUNC_TRACE();
+
+	/* Userspace process exited without proper shutdown in last run */
+	if (nicvf_qset_rbdr_active(nic, 0))
+		nicvf_dev_stop(dev);
+
+	/*
+	 * Thunderx nicvf PMD can support more than one pool per port only when
+	 * 1) Data payload size is same across all the pools in given port
+	 * AND
+	 * 2) All mbuffs in the pools are from the same hugepage
+	 * AND
+	 * 3) Mbuff metadata size is same across all the pools in given port
+	 *
+	 * This is to support existing application that uses multiple pool/port.
+	 * But, the purpose of using multipool for QoS will not be addressed.
+	 *
+	 */
+
+	/* Validate RBDR buff size */
+	for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) {
+		rxq = dev->data->rx_queues[qidx];
+		mbp_priv = rte_mempool_get_priv(rxq->pool);
+		buffsz = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM;
+		if (buffsz % 128) {
+			PMD_INIT_LOG(ERR, "rxbuf size must be multiply of 128");
+			return -EINVAL;
+		}
+		if (rbdrsz == 0)
+			rbdrsz = buffsz;
+		if (rbdrsz != buffsz) {
+			PMD_INIT_LOG(ERR, "buffsz not same, qid=%d (%d/%d)",
+				     qidx, rbdrsz, buffsz);
+			return -EINVAL;
+		}
+	}
+
+	/* Validate mempool attributes */
+	for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) {
+		rxq = dev->data->rx_queues[qidx];
+		rxq->mbuf_phys_off = nicvf_mempool_phy_offset(rxq->pool);
+		mbuf = rte_pktmbuf_alloc(rxq->pool);
+		if (mbuf == NULL) {
+			PMD_INIT_LOG(ERR, "Failed allocate mbuf qid=%d pool=%s",
+				     qidx, rxq->pool->name);
+			return -ENOMEM;
+		}
+		rxq->mbuf_phys_off -= nicvf_mbuff_meta_length(mbuf);
+		rxq->mbuf_phys_off -= RTE_PKTMBUF_HEADROOM;
+		rte_pktmbuf_free(mbuf);
+
+		if (mbuf_phys_off == 0)
+			mbuf_phys_off = rxq->mbuf_phys_off;
+		if (mbuf_phys_off != rxq->mbuf_phys_off) {
+			PMD_INIT_LOG(ERR, "pool params not same,%s %" PRIx64,
+				     rxq->pool->name, mbuf_phys_off);
+			return -EINVAL;
+		}
+	}
+
+	/* Check the level of buffers in the pool */
+	total_rxq_desc = 0;
+	for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) {
+		rxq = dev->data->rx_queues[qidx];
+		/* Count total numbers of rxq descs */
+		total_rxq_desc += rxq->qlen_mask + 1;
+		exp_buffs = RTE_MEMPOOL_CACHE_MAX_SIZE + rxq->rx_free_thresh;
+		exp_buffs *= nic->eth_dev->data->nb_rx_queues;
+		if (rte_mempool_count(rxq->pool) < exp_buffs) {
+			PMD_INIT_LOG(ERR, "Buff shortage in pool=%s (%d/%d)",
+				     rxq->pool->name,
+				     rte_mempool_count(rxq->pool),
+				     exp_buffs);
+			return -ENOENT;
+		}
+	}
+
+	/* Check RBDR desc overflow */
+	ret = nicvf_qsize_rbdr_roundup(total_rxq_desc);
+	if (ret == 0) {
+		PMD_INIT_LOG(ERR, "Reached RBDR desc limit, reduce nr desc");
+		return -ENOMEM;
+	}
+
+	/* Enable qset */
+	ret = nicvf_qset_config(nic);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to enable qset %d", ret);
+		return ret;
+	}
+
+	/* Allocate RBDR and RBDR ring desc */
+	nb_rbdr_desc = nicvf_qsize_rbdr_roundup(total_rxq_desc);
+	ret = nicvf_qset_rbdr_alloc(nic, nb_rbdr_desc, rbdrsz);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to allocate memory for rbdr alloc");
+		goto qset_reclaim;
+	}
+
+	/* Enable and configure RBDR registers */
+	ret = nicvf_qset_rbdr_config(nic, 0);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure rbdr %d", ret);
+		goto qset_rbdr_free;
+	}
+
+	/* Fill rte_mempool buffers in RBDR pool and precharge it */
+	ret = nicvf_qset_rbdr_precharge(nic, 0, rbdr_rte_mempool_get,
+					dev, total_rxq_desc);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to fill rbdr %d", ret);
+		goto qset_rbdr_reclaim;
+	}
+
+	PMD_DRV_LOG(INFO, "Filled %d out of %d entries in RBDR",
+		     nic->rbdr->tail, nb_rbdr_desc);
+
+	/* Configure RX queues */
+	for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) {
+		ret = nicvf_start_rx_queue(dev, qidx);
+		if (ret)
+			goto start_rxq_error;
+	}
+
+	/* Configure VLAN Strip */
+	nicvf_vlan_hw_strip(nic, dev->data->dev_conf.rxmode.hw_vlan_strip);
+
+	/* Configure TX queues */
+	for (qidx = 0; qidx < nic->eth_dev->data->nb_tx_queues; qidx++) {
+		ret = nicvf_start_tx_queue(dev, qidx);
+		if (ret)
+			goto start_txq_error;
+	}
+
+	/* Configure CPI algorithm */
+	ret = nicvf_configure_cpi(dev);
+	if (ret)
+		goto start_txq_error;
+
+	/* Configure RSS */
+	ret = nicvf_configure_rss(dev);
+	if (ret)
+		goto qset_rss_error;
+
+	/* Configure loopback */
+	ret = nicvf_loopback_config(nic, dev->data->dev_conf.lpbk_mode);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure loopback %d", ret);
+		goto qset_rss_error;
+	}
+
+	/* Reset all statistics counters attached to this port */
+	ret = nicvf_mbox_reset_stat_counters(nic, 0x3FFF, 0x1F, 0xFFFF, 0xFFFF);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to reset stat counters %d", ret);
+		goto qset_rss_error;
+	}
+
+	/* Setup scatter mode if needed by jumbo */
+	if (dev->data->dev_conf.rxmode.max_rx_pkt_len +
+					    2 * VLAN_TAG_SIZE > buffsz)
+		dev->data->scattered_rx = 1;
+	if (rx_conf->enable_scatter)
+		dev->data->scattered_rx = 1;
+
+	/* Setup MTU based on max_rx_pkt_len or default */
+	mtu = dev->data->dev_conf.rxmode.jumbo_frame ?
+		dev->data->dev_conf.rxmode.max_rx_pkt_len
+			-  ETHER_HDR_LEN - ETHER_CRC_LEN
+		: ETHER_MTU;
+
+	if (nicvf_dev_set_mtu(dev, mtu)) {
+		PMD_INIT_LOG(ERR, "Failed to set default mtu size");
+		return -EBUSY;
+	}
+
+	/* Configure callbacks based on scatter mode */
+	nicvf_set_tx_function(dev);
+	nicvf_set_rx_function(dev);
+
+	/* Done; Let PF make the BGX's RX and TX switches to ON position */
+	nicvf_mbox_cfg_done(nic);
+	return 0;
+
+qset_rss_error:
+	nicvf_rss_term(nic);
+start_txq_error:
+	for (qidx = 0; qidx < nic->eth_dev->data->nb_tx_queues; qidx++)
+		nicvf_stop_tx_queue(dev, qidx);
+start_rxq_error:
+	for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++)
+		nicvf_stop_rx_queue(dev, qidx);
+qset_rbdr_reclaim:
+	nicvf_qset_rbdr_reclaim(nic, 0);
+	nicvf_rbdr_release_mbufs(nic);
+qset_rbdr_free:
+	if (nic->rbdr) {
+		rte_free(nic->rbdr);
+		nic->rbdr = NULL;
+	}
+qset_reclaim:
+	nicvf_qset_reclaim(nic);
+	return ret;
+}
+
+static void
+nicvf_dev_stop(struct rte_eth_dev *dev)
+{
+	int ret;
+	uint16_t qidx;
+	struct nicvf *nic = nicvf_pmd_priv(dev);
+
+	PMD_INIT_FUNC_TRACE();
+
+	/* Let PF make the BGX's RX and TX switches to OFF position */
+	nicvf_mbox_shutdown(nic);
+
+	/* Disable loopback */
+	ret = nicvf_loopback_config(nic, 0);
+	if (ret)
+		PMD_INIT_LOG(ERR, "Failed to disable loopback %d", ret);
+
+	/* Disable VLAN Strip */
+	nicvf_vlan_hw_strip(nic, 0);
+
+	/* Reclaim sq */
+	for (qidx = 0; qidx < dev->data->nb_tx_queues; qidx++)
+		nicvf_stop_tx_queue(dev, qidx);
+
+	/* Reclaim rq */
+	for (qidx = 0; qidx < dev->data->nb_rx_queues; qidx++)
+		nicvf_stop_rx_queue(dev, qidx);
+
+	/* Reclaim RBDR */
+	ret = nicvf_qset_rbdr_reclaim(nic, 0);
+	if (ret)
+		PMD_INIT_LOG(ERR, "Failed to reclaim RBDR %d", ret);
+
+	/* Move all charged buffers in RBDR back to pool */
+	if (nic->rbdr != NULL)
+		nicvf_rbdr_release_mbufs(nic);
+
+	/* Reclaim CPI configuration */
+	if (!nic->sqs_mode) {
+		ret = nicvf_mbox_config_cpi(nic, 0);
+		if (ret)
+			PMD_INIT_LOG(ERR, "Failed to reclaim CPI config");
+	}
+
+	/* Disable qset */
+	ret = nicvf_qset_config(nic);
+	if (ret)
+		PMD_INIT_LOG(ERR, "Failed to disable qset %d", ret);
+
+	/* Disable all interrupts */
+	nicvf_disable_all_interrupts(nic);
+
+	/* Free RBDR SW structure */
+	if (nic->rbdr) {
+		rte_free(nic->rbdr);
+		nic->rbdr = NULL;
+	}
+}
+
+static void
+nicvf_dev_close(struct rte_eth_dev *dev)
+{
+	struct nicvf *nic = nicvf_pmd_priv(dev);
+
+	PMD_INIT_FUNC_TRACE();
+
+	nicvf_dev_stop(dev);
+	nicvf_periodic_alarm_stop(nic);
+}
+
 static int
 nicvf_dev_configure(struct rte_eth_dev *dev)
 {
@@ -1144,7 +1600,10 @@
 /* Initialize and register driver with DPDK Application */
 static const struct eth_dev_ops nicvf_eth_dev_ops = {
 	.dev_configure            = nicvf_dev_configure,
+	.dev_start                = nicvf_dev_start,
+	.dev_stop                 = nicvf_dev_stop,
 	.link_update              = nicvf_dev_link_update,
+	.dev_close                = nicvf_dev_close,
 	.stats_get                = nicvf_dev_stats_get,
 	.stats_reset              = nicvf_dev_stats_reset,
 	.promiscuous_enable       = nicvf_dev_promisc_enable,
@@ -1179,6 +1638,14 @@

 	eth_dev->dev_ops = &nicvf_eth_dev_ops;

+	/* For secondary processes, the primary has done all the work */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		/* Setup callbacks for secondary process */
+		nicvf_set_tx_function(eth_dev);
+		nicvf_set_rx_function(eth_dev);
+		return 0;
+	}
+
 	pci_dev = eth_dev->pci_dev;
 	rte_eth_copy_pci_info(eth_dev, pci_dev);


ath9k: Fix AHB reset for AR9280

ath9k: Fix AHB reset for AR9280

The commit "ath9k: Do an AHB reset before doing RTC reset"
fixed RTC reset issue for AR9280 2.0 chipsets and above.
The fix is valid for all AR9280 chipsets.

Signed-off-by: Vivek Natarajan <f9eab59b292314637a3c917fea4742741e36a19b@atheros.com>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>

--- drivers/net/wireless/ath/ath9k/hw.c
+++ drivers/net/wireless/ath/ath9k/hw.c
@@ -1793,7 +1793,7 @@
 static bool ath9k_hw_chip_reset(struct ath_hw *ah,
 				struct ath9k_channel *chan)
 {
-	if (OLC_FOR_AR9280_20_LATER) {
+	if (AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)) {
 		if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON))
 			return false;
 	} else if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM))


ath9k_hw: disable ANI for AR9003

ath9k_hw: disable ANI for AR9003

ANI is still being debugged on AR9003 by our systems team
so it should not yet be enabled yet. When ANI will be
enabled all ANI functionality is expected to be enabled
so fill the ANI functionality to all for AR9003 for now
as well.

Cc: Enis Akay <2192bba367c97b0e1419c21e062d46ae226a7ec1@atheros.com>
Signed-off-by: Luis R. Rodriguez <79e6b8107a8aa3944e09fad43634662ac3b91a0b@atheros.com>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>

--- drivers/net/wireless/ath/ath9k/hw.c
+++ drivers/net/wireless/ath/ath9k/hw.c
@@ -363,7 +363,13 @@
 	ah->config.ofdm_trig_high = 500;
 	ah->config.cck_trig_high = 200;
 	ah->config.cck_trig_low = 100;
-	ah->config.enable_ani = 1;
+
+	/*
+	 * For now ANI is disabled for AR9003, it is still
+	 * being tested.
+	 */
+	if (!AR_SREV_9300_20_OR_LATER(ah))
+		ah->config.enable_ani = 1;

 	for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
 		ah->config.spurchans[i][0] = AR_NO_SPUR;
@@ -941,7 +947,7 @@
 	ath9k_hw_init_cal_settings(ah);

 	ah->ani_function = ATH9K_ANI_ALL;
-	if (AR_SREV_9280_10_OR_LATER(ah))
+	if (AR_SREV_9280_10_OR_LATER(ah) && !AR_SREV_9300_20_OR_LATER(ah))
 		ah->ani_function &= ~ATH9K_ANI_NOISE_IMMUNITY_LEVEL;

 	ath9k_hw_init_mode_regs(ah);


ath9k: Update rate control for 11NA HT40 mode

Now the lowest rate in 11na ht40 mode is 13.5Mbps this shortens the
range when compared to 11na ht20 mode where the lowest rate is 6.5Mbps.
To improve the range, make 6.5Mbps as the lowest rate in 11na ht40 mode,
this improves the range by approximately 2dB. 11ng ht40 does not have
this issue as it also has basic rates (1, 2, 5.5 and 11).

Signed-off-by: Vasanthakumar Thiagarajan <1f9b907e684cdf06e2f9d7218724ac8143aa73aa@atheros.com>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>


libertas: fix signedness bug in lbs_auth_to_authtype()

Return type for lbs_auth_to_authtype() is changed from "u8" to
"int" to return negative error code correctly.
Also an error check is added in connect handler for invalid auth
type.

Reported-by: Dan Carpenter <ff341aa343d564f9e53e9dcb6996be8c04859a66@oracle.com>
Signed-off-by: Amitkumar Karwar <7343c7ffb424bf4c3ebd1cd0c94117b3c12118ff@marvell.com>
Signed-off-by: Kiran Divekar <025772fc17aabb16071ba6705694ad1d8c4a97de@marvell.com>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>

--- drivers/net/wireless/libertas/cfg.c
+++ drivers/net/wireless/libertas/cfg.c
@@ -103,7 +103,7 @@
  * Convert NL80211's auth_type to the one from Libertas, see chapter 5.9.1
  * in the firmware spec
  */
-static u8 lbs_auth_to_authtype(enum nl80211_auth_type auth_type)
+static int lbs_auth_to_authtype(enum nl80211_auth_type auth_type)
 {
 	int ret = -ENOTSUPP;

@@ -1411,7 +1411,12 @@
 		goto done;
 	}

-	lbs_set_authtype(priv, sme);
+	ret = lbs_set_authtype(priv, sme);
+	if (ret == -ENOTSUPP) {
+		wiphy_err(wiphy, "unsupported authtype 0x%x\n", sme->auth_type);
+		goto done;
+	}
+
 	lbs_set_radio(priv, preamble, 1);

 	/* Do the actual association */


Fix for vfs_lookup vnode ref counting (#196)

--- sys/vfs.c
+++ sys/vfs.c
@@ -215,7 +215,8 @@
       if (error)
         return error;
       v = v_mntpt;
-      vnode_ref(v);
+      /* vnode_ref(v); No need to ref this vnode, VFS_ROOT already did it for
+       * us. */
       vnode_lock(v);
     }

@@ -233,7 +234,8 @@
     if (error)
       return error;
     v = v_child;
-    vnode_ref(v);
+    /* vnode_ref(v); No need to ref this vnode, VFS_LOOKUP already did it for
+     * us. */
     vnode_lock(v);
   }


NFC: st21nfca: Fix potential skb leaks in NFC-DEP code

After a unsuccessful call to nfc_hci_send_event the skb was not
freed and might lead to memory leak.

Signed-off-by: Christophe Ricard <7fc2cd33e78f60c767c0b054f476a876f109b675@st.com>
Signed-off-by: Samuel Ortiz <0ba86cb3f08bbb861958e54bd3438887adb4263c@linux.intel.com>


power/reset: at91-poweroff: get and use slow clock

Commit dca1a4b5ff6e ("clk: at91: keep slow clk enabled to prevent system
hang") added a workaround for the slow clock as it is not properly handled
by its users.

Get and use the slow clock as it is necessary for the at91 shutdown
controller.

Signed-off-by: Alexandre Belloni <a7228e626ecf0022ac91fc1cd8db88e71d0e5e0e@free-electrons.com>
Signed-off-by: Sebastian Reichel <1ea78bda3cb6d36efdb8fc89aad6555e21b4887e@kernel.org>


raw/dpaa2_qdma: remove datapath checks for lcore ID

There is no need for preventional check of rte_lcore_id() in
data path. This patch removes the same.

Signed-off-by: Nipun Gupta <4871fd67344c57328097f2fd932ad9a0f1f1fe74@nxp.com>
Acked-by: Hemant Agrawal <90d96ef1ecd8ed49b97c7897be950e80824a9c5c@nxp.com>

--- drivers/raw/dpaa2_qdma/dpaa2_qdma.c
+++ drivers/raw/dpaa2_qdma/dpaa2_qdma.c
@@ -1391,13 +1391,6 @@
 		&dpdmai_dev->qdma_dev->vqs[e_context->vq_id];
 	int ret;

-	/* Return error in case of wrong lcore_id */
-	if (rte_lcore_id() != qdma_vq->lcore_id) {
-		DPAA2_QDMA_ERR("QDMA enqueue for vqid %d on wrong core",
-				e_context->vq_id);
-		return -EINVAL;
-	}
-
 	ret = qdma_vq->enqueue_job(qdma_vq, e_context->job, nb_jobs);
 	if (ret < 0) {
 		DPAA2_QDMA_ERR("DPDMAI device enqueue failed: %d", ret);
@@ -1428,13 +1421,6 @@
 		/** Make sure there are enough space to get jobs.*/
 		if (unlikely(nb_jobs < DPAA2_QDMA_MAX_SG_NB))
 			return -EINVAL;
-	}
-
-	/* Return error in case of wrong lcore_id */
-	if (rte_lcore_id() != (unsigned int)(qdma_vq->lcore_id)) {
-		DPAA2_QDMA_WARN("QDMA dequeue for vqid %d on wrong core",
-				context->vq_id);
-		return -1;
 	}

 	/* Only dequeue when there are pending jobs on VQ */


soc/tegra: fuse: export tegra_sku_info

soc/tegra: fuse: export tegra_sku_info

Some Tegra drivers might be compiled as kernel modules, and they need the
fuse information for initialization. One example is the GK20A Nouveau
driver. It needs the GPU speedo value to calculate frequency-voltage
table. So export the tegra_sku_info.

Signed-off-by: Vince Hsu <5ea228a5cf8d16f5020fb76be180e36823a0ff47@nvidia.com>
Acked-by: Alexandre Courbot <301cd6a3ea50a894b4b51e385c5eb12b9a4ffc0c@nvidia.com>
Acked-by: Thierry Reding <3055038c414aef68bf32c33b8118623e7554e0f2@nvidia.com>
Signed-off-by: Ben Skeggs <d9f27fb07c1e9f131223ad827fa5179f3846c30b@redhat.com>


staging: fsl-mc: changed timeout units for MC cmd completion

Changed units for the timeout to wait for completion
of MC command, from jiffies to milliseconds.

Signed-off-by: J. German Rivera <e5abd150e1c13259864272e1f04e1f040eecb828@freescale.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>


iio: mxs-lradc: fix iio channel map regression

Since commit c8231a9af8147f8a ("iio: mxs-lradc: compute temperature
from channel 8 and 9") with the removal of adc channel 9 there is
no 1-1 mapping in the channel spec.

All hwmon channel values above 9 are accessible via there index minus
one. So add a hidden iio channel 9 to fix this issue.

Signed-off-by: Stefan Wahren <05c83f7cee1d5cf9307ce0d7ae6ccfa44e4deab5@i2se.com>
Acked-by: Alexandre Belloni <a7228e626ecf0022ac91fc1cd8db88e71d0e5e0e@free-electrons.com>
Reviewed-by: Marek Vasut <f40600653b33f5282fa4c5daf377dfc444fb4625@denx.de>
Cc: d96e5b2dd07c1733b2b013bd82922c22baade37d@vger.kernel.org
Signed-off-by: Jonathan Cameron <09f65b71b7655725897b2fd41a09a0cefe2e1ace@kernel.org>


staging: rtl8188eu: odm: conditional setting with no effect

The if and the else branch code are identical - so the condition has no
effect on the effective code - this patch removes the condition and the
duplicated code. Due to this being a fall-through-if here - the first
if condition has no effect either - so it also can be removed.
struct mlme_priv is thus also no longer needed here.

Signed-off-by: Nicholas Mc Guire <1f1947151fff46847c7ab253c8b8ee2fc7e63b14@osadl.org>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>


staging: wlan-ng: fix block comment indentation

Update indentation of block comments to follow linux coding style

Signed-off-by: Ioana Ciornei <02a19ab65c159578d79886f96d62df7e3629ce80@gmail.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>


iscsi-target: Fix NULL pointer dereference in iscsit_send_reject

Fix up a NULL pointer dereference regression in iscsit_send_reject()
introduced by from commit 2ec5a8c11.

Reported-by: Geert Uytterhoeven <0da414d9d963da4039c2a0525b1844228075aa58@linux-m68k.org>
Signed-off-by: Nicholas Bellinger <978acd1567d5598152161fdf8bf3ca568f950c9b@linux-iscsi.org>

--- drivers/target/iscsi/iscsi_target.c
+++ drivers/target/iscsi/iscsi_target.c
@@ -3557,11 +3557,11 @@
 	struct iscsi_cmd *cmd,
 	struct iscsi_conn *conn)
 {
-	u32 iov_count = 0, tx_size = 0;
-	struct iscsi_reject *hdr;
+	struct iscsi_reject *hdr = (struct iscsi_reject *)&cmd->pdu[0];
 	struct kvec *iov;
-
-	iscsit_build_reject(cmd, conn, (struct iscsi_reject *)&cmd->pdu[0]);
+	u32 iov_count = 0, tx_size;
+
+	iscsit_build_reject(cmd, conn, hdr);

 	iov = &cmd->iov_misc[0];
 	iov[iov_count].iov_base = cmd->pdu;


drivers/video/backlight/da9052_bl.c: drop devm_kfree of devm_kzalloc'd data

devm_kfree should not have to be explicitly used.

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,d;
@@

x = devm_kzalloc(...)
...
?-devm_kfree(d,x);
// </smpl>

Signed-off-by: Julia Lawall <3d4a3affaf9163789962e9770780389962bda29d@lip6.fr>
Acked-by: Jingoo Han <fc379137a64feb86ce38ec5811a14280acc1ccfc@samsung.com>
Signed-off-by: Florian Tobias Schandinat <9843642cd7809d7c6d8c25ac9e4b0e2f1b5283bf@gmx.de>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- drivers/video/backlight/da9052_bl.c
+++ drivers/video/backlight/da9052_bl.c
@@ -129,7 +129,6 @@
 				       &da9052_backlight_ops, &props);
 	if (IS_ERR(bl)) {
 		dev_err(&pdev->dev, "Failed to register backlight\n");
-		devm_kfree(&pdev->dev, wleds);
 		return PTR_ERR(bl);
 	}

@@ -149,7 +148,6 @@
 	wleds->state = DA9052_WLEDS_OFF;
 	da9052_adjust_wled_brightness(wleds);
 	backlight_device_unregister(bl);
-	devm_kfree(&pdev->dev, wleds);

 	return 0;
 }


cocoa-webkit: use non-deprecated constants, but redefine them for backwards compatibility

--- webview.h
+++ webview.h
@@ -988,6 +988,14 @@
 #endif /* WEBVIEW_WINAPI */

 #if defined(WEBVIEW_COCOA)
+#if (! defined MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
+#define NSWindowStyleMaskMiniaturizable  NSMiniaturizableWindowMask
+#define NSWindowStyleMaskTitled          NSTitledWindowMask
+#define NSWindowStyleMaskClosable        NSClosableWindowMask
+#define NSEventMaskAny                   NSAnyEventMask
+#define NSEventModifierFlagCommand       NSCommandKeyMask
+#define NSEventModifierFlagOption        NSAlternateKeyMask
+#endif /* MAC_OS_X_VERSION_10_12 */
 static void webview_window_will_close(id self, SEL cmd, id notification) {
   struct webview *w =
       (struct webview *)objc_getAssociatedObject(self, "webview");
@@ -1081,7 +1089,7 @@
   NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:title action:@selector(hide:) keyEquivalent:@"h"] autorelease];
   [appMenu addItem:item];
   item = [[[NSMenuItem alloc] initWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"] autorelease];
-  [item setKeyEquivalentModifierMask:(NSAlternateKeyMask | NSCommandKeyMask)];
+  [item setKeyEquivalentModifierMask:(NSEventModifierFlagOption| NSEventModifierFlagCommand)];
   [appMenu addItem:item];
   item = [[[NSMenuItem alloc] initWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""] autorelease];
   [appMenu addItem:item];


mshtml: formatting

mshtml: formatting

--- webview.h
+++ webview.h
@@ -854,7 +854,8 @@
   if (!browserObject->lpVtbl->QueryInterface(
           browserObject, iid_unref(&IID_IWebBrowser2), (void **)&webBrowser2)) {
     LPCSTR webPageName;
-    isDataURL = (strncmp(w->url, WEBVIEW_DATA_URL_PREFIX, strlen(WEBVIEW_DATA_URL_PREFIX)) == 0);
+    isDataURL = (strncmp(w->url, WEBVIEW_DATA_URL_PREFIX,
+                         strlen(WEBVIEW_DATA_URL_PREFIX)) == 0);
     if (isDataURL) {
       webPageName = "about:blank";
     } else {
@@ -887,42 +888,43 @@

     char *url = calloc(1, strlen(w->url) + 1);
     char *q = url;
-    for (const char *p = w->url + strlen(WEBVIEW_DATA_URL_PREFIX); *q = *p; p++, q++) {
-      if (*q == '%' && *(p+1) && *(p+2)) {
-	sscanf(p+1, "%02x", q);
-	p = p + 2;
+    for (const char *p = w->url + strlen(WEBVIEW_DATA_URL_PREFIX); *q = *p;
+         p++, q++) {
+      if (*q == '%' && *(p + 1) && *(p + 2)) {
+        sscanf(p + 1, "%02x", q);
+        p = p + 2;
       }
     }

     if (webBrowser2->lpVtbl->get_Document(webBrowser2, &lpDispatch) == S_OK) {
       if (lpDispatch->lpVtbl->QueryInterface(lpDispatch, &IID_IHTMLDocument2,
-					      (void **)&htmlDoc2) == S_OK) {
-	if ((sfArray = SafeArrayCreate(VT_VARIANT, 1,
-				       (SAFEARRAYBOUND *)&ArrayBound))) {
-	  if (!SafeArrayAccessData(sfArray, (void **)&pVar)) {
-	    pVar->vt = VT_BSTR;
+                                             (void **)&htmlDoc2) == S_OK) {
+        if ((sfArray = SafeArrayCreate(VT_VARIANT, 1,
+                                       (SAFEARRAYBOUND *)&ArrayBound))) {
+          if (!SafeArrayAccessData(sfArray, (void **)&pVar)) {
+            pVar->vt = VT_BSTR;
 #ifndef UNICODE
-	    {
-	      wchar_t *buffer = webview_to_utf16(url);
-	      if (buffer == NULL) {
-	        goto release;
-	      }
-	      bstr = SysAllocString(buffer);
-	      GlobalFree(buffer);
-	    }
+            {
+              wchar_t *buffer = webview_to_utf16(url);
+              if (buffer == NULL) {
+                goto release;
+              }
+              bstr = SysAllocString(buffer);
+              GlobalFree(buffer);
+            }
 #else
-	    bstr = SysAllocString(string);
+            bstr = SysAllocString(string);
 #endif
-	    if ((pVar->bstrVal = bstr)) {
-	      htmlDoc2->lpVtbl->write(htmlDoc2, sfArray);
-	      htmlDoc2->lpVtbl->close(htmlDoc2);
-	    }
-	  }
-	  SafeArrayDestroy(sfArray);
-	}
+            if ((pVar->bstrVal = bstr)) {
+              htmlDoc2->lpVtbl->write(htmlDoc2, sfArray);
+              htmlDoc2->lpVtbl->close(htmlDoc2);
+            }
+          }
+          SafeArrayDestroy(sfArray);
+        }
       release:
-	free(url);
-	htmlDoc2->lpVtbl->Release(htmlDoc2);
+        free(url);
+        htmlDoc2->lpVtbl->Release(htmlDoc2);
       }
       lpDispatch->lpVtbl->Release(lpDispatch);
     }
@@ -948,7 +950,7 @@
     IWebBrowser2 *webBrowser2;
     IOleObject *browser = *w->priv.browser;
     if (browser->lpVtbl->QueryInterface(browser, iid_unref(&IID_IWebBrowser2),
-                                         (void **)&webBrowser2) == S_OK) {
+                                        (void **)&webBrowser2) == S_OK) {
       RECT rect;
       GetClientRect(hwnd, &rect);
       webBrowser2->lpVtbl->put_Width(webBrowser2, rect.right);
@@ -1044,9 +1046,12 @@
   case WM_KEYUP: {
     IWebBrowser2 *webBrowser2;
     IOleObject *browser = *w->priv.browser;
-    if (browser->lpVtbl->QueryInterface(browser, iid_unref(&IID_IWebBrowser2), (void **)&webBrowser2) == S_OK) {
-      IOleInPlaceActiveObject* pIOIPAO;
-      if (browser->lpVtbl->QueryInterface(browser, iid_unref(&IID_IOleInPlaceActiveObject), (void**)&pIOIPAO) == S_OK) {
+    if (browser->lpVtbl->QueryInterface(browser, iid_unref(&IID_IWebBrowser2),
+                                        (void **)&webBrowser2) == S_OK) {
+      IOleInPlaceActiveObject *pIOIPAO;
+      if (browser->lpVtbl->QueryInterface(
+              browser, iid_unref(&IID_IOleInPlaceActiveObject),
+              (void **)&pIOIPAO) == S_OK) {
         pIOIPAO->lpVtbl->TranslateAccelerator(pIOIPAO, &msg);
         pIOIPAO->lpVtbl->Release(pIOIPAO);
       }


acpi_fujitsu: update for P8010

acpi_fujitsu: update for P8010

PR:		kern/121102
Submitted by:	Anish Mistry <amistry@am-productions.biz>
MFC after:	3 weeks

--- sys/dev/acpi_support/acpi_fujitsu.c
+++ sys/dev/acpi_support/acpi_fujitsu.c
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2002 Sean Bullington <seanATstalker.org>
- *               2003-2006 Anish Mistry <amistry@am-productions.biz>
+ *               2003-2008 Anish Mistry <amistry@am-productions.biz>
  *               2004 Mark Santcroos <marks@ripe.net>
  * All Rights Reserved.
  *
@@ -86,6 +86,7 @@
 #define METHOD_RVOL	6
 #define METHOD_GSIF	7
 #define METHOD_GHKS	8
+#define METHOD_GBLS	9

 /* Notify event */
 #define	ACPI_NOTIFY_STATUS_CHANGED	0x80
@@ -110,6 +111,7 @@
 	/* Control methods */
 	struct int_nameval	_sta,	/* unused */
 				gbll,	/* brightness */
+				gbls,	/* get brightness state */
 				ghks,	/* hotkey selector */
 				gbuf,	/* unused (buffer?) */
 				gmou,	/* mouse */
@@ -191,6 +193,11 @@
 		.description	= "Brightness level of the LCD panel"
 	},
 	{
+		.name		= "lcd_brightness",
+		.method		= METHOD_GBLS,
+		.description	= "Brightness level of the LCD panel"
+	},
+	{
 		.name		= "volume",
 		.method		= METHOD_GVOL,
 		.description	= "Speakers/headphones volume level"
@@ -360,6 +367,7 @@
 	/* Setup all of the names for each control method */
 	sc->_sta.name = "_STA";
 	sc->gbll.name = "GBLL";
+	sc->gbls.name = "GBLS";
 	sc->ghks.name = "GHKS";
 	sc->gmou.name = "GMOU";
 	sc->gsif.name = "GSIF";
@@ -386,6 +394,9 @@
 				break;
 			case METHOD_GBLL:
 				exists = sc->gbll.exists;
+				break;
+			case METHOD_GBLS:
+				exists = sc->gbls.exists;
 				break;
 			case METHOD_GVOL:
 			case METHOD_MUTE:
@@ -463,6 +474,9 @@
 		case METHOD_GBLL:
 			nv = sc->gbll;
 			break;
+		case METHOD_GBLS:
+			nv = sc->gbls;
+			break;
 		case METHOD_GMOU:
 			nv = sc->gmou;
 			break;
@@ -519,6 +533,11 @@
 			changed = BRIGHT_CHANGED;
 			control = "SBLL";
 			nv = sc->gbll;
+			break;
+		case METHOD_GBLS:
+			changed = BRIGHT_CHANGED;
+			control = "SBL2";
+			nv = sc->gbls;
 			break;
 		case METHOD_GMOU:
 			changed = MOUSE_CHANGED;
@@ -585,6 +604,14 @@
 	}

 	if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
+		sc->gbls.name, &val))) {
+		sc->gbls.exists = 0;
+	} else {
+		sc->gbls.exists = 1;
+	}
+
+	// don't add if we can use the new method
+	if (sc->gbls.exists || ACPI_FAILURE(acpi_GetInteger(sc->handle,
 	    sc->gbll.name, &val))) {
 		sc->gbll.exists = 0;
 	} else {
@@ -681,11 +708,37 @@
 			/* Clear the modification bit */
 			sc->gmou.value &= MOUSE_SETTING_BITS;

+			/* Set the value in case it is not hardware controlled */
+                        acpi_fujitsu_method_set(sc, METHOD_GMOU, sc->gmou.value);
+
 			acpi_UserNotify("FUJITSU", sc->handle, FN_POINTER_ENABLE);

 			ACPI_VPRINT(sc->dev, acpi_sc, "Internal pointer is now %s\n",
 			(sc->bIntPtrEnabled) ? "enabled" : "disabled");
 		}
+	}
+
+	/* Screen Brightness Level P8XXX */
+	if(sc->gbls.exists) {
+		if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
+                sc->gbls.name, &(sc->gbls.value)))) {
+                        device_printf(sc->dev, "Couldn't query P8XXX brightness level\n");
+                        return (FALSE);
+                }
+		if (changed & BRIGHT_CHANGED) {
+			/* No state to record here. */
+
+			/* Clear the modification bit */
+			sc->gbls.value &= BRIGHTNESS_SETTING_BITS;
+
+			/* Set the value in case it is not hardware controlled */
+			acpi_fujitsu_method_set(sc, METHOD_GBLS, sc->gbls.value);
+
+			acpi_UserNotify("FUJITSU", sc->handle, FN_LCD_BRIGHTNESS);
+
+			ACPI_VPRINT(sc->dev, acpi_sc, "P8XXX Brightness level is now %d\n",
+			sc->gbls.value);
+                }
 	}

 	/* Screen Brightness Level */


The New and Improved snake_server - Service Pack 1: now even more sensitive to load average variations!


Properly free directory_path in DCCloseAndFree

--- disk_cache.c
+++ disk_cache.c
@@ -110,6 +110,7 @@
   size_t lines_size = cache->header.num_lines * sizeof(DCCacheLine_t);
   munmap(cache->lines, lines_size);
   close(cache->fd);
+  free(cache->directory_path);
   free(cache);
 }


dispatch_running: protect loop over listeners with read-lock

--- dispatcher.c
+++ dispatcher.c
@@ -720,6 +720,7 @@
 							dispatch_check_rlimit_and_warn();
 							continue;
 						}
+						pthread_rwlock_rdlock(&listenerslock);
 						for (c = 0; c < MAX_LISTENERS; c++) {
 							if (listeners[c] == NULL)
 								continue;
@@ -730,9 +731,10 @@
 							if (*sock != -1)
 								break;
 						}
+						pthread_rwlock_unlock(&listenerslock);
 						if (c == MAX_LISTENERS) {
 							logerr("dispatch: could not find listener for "
-									"socket, this should never happen\n");
+									"socket, rejecting connection\n");
 							close(client);
 							continue;
 						}


dispatch_connection: reorder logic to fix value tampering

This is an alternative to the solution presented by cekstam in pull
request #18.

After we've seen the first space, we no longer need to replace "weird"
chars, as only values follow.  As correctly pointed out, float
representations might even have "weird" chars, such as the '+'.

With this commit, we allow any char after the first space, but still
reduce whitespace into a single space.

--- dispatcher.c
+++ dispatcher.c
@@ -281,13 +281,33 @@
 		firstspace = NULL;
 		lastnl = NULL;
 		for (p = conn->buf; p - conn->buf < conn->buflen; p++) {
-			if ((*p >= 'a' && *p <= 'z') ||
-					(*p >= 'A' && *p <= 'Z') ||
-					(*p >= '0' && *p <= '9') ||
-					*p == '-' || *p == '_' || *p == ':')
-			{
-				/* copy char */
-				*q++ = *p;
+			if (*p == '\n' || *p == '\r') {
+				/* end of metric */
+				lastnl = p;
+
+				/* just a newline on it's own? some random garbage? skip */
+				if (q == conn->metric || firstspace == NULL) {
+					q = conn->metric;
+					firstspace = NULL;
+					continue;
+				}
+
+				*q++ = '\n';
+				*q = '\0';  /* can do this because we substract one from buf */
+
+				/* perform routing of this metric */
+				conn->destlen =
+					router_route(conn->dests, sizeof(conn->dests),
+							conn->metric, firstspace);
+
+				/* restart building new one from the start */
+				q = conn->metric;
+				firstspace = NULL;
+
+				conn->wait = time(NULL);
+				/* send the metric to where it is supposed to go */
+				if (dispatch_process_dests(conn, self) == 0)
+					break;
 			} else if (*p == ' ' || *p == '\t' || *p == '.') {
 				/* separator */
 				if (*p == '\t')
@@ -313,33 +333,14 @@
 							(q - 1) != firstspace)
 						*q++ = *p;
 				}
-			} else if (*p == '\n' || *p == '\r') {
-				/* end of metric */
-				lastnl = p;
-
-				/* just a newline on it's own? some random garbage? skip */
-				if (q == conn->metric || firstspace == NULL) {
-					q = conn->metric;
-					firstspace = NULL;
-					continue;
-				}
-
-				*q++ = '\n';
-				*q = '\0';  /* can do this because we substract one from buf */
-
-				/* perform routing of this metric */
-				conn->destlen =
-					router_route(conn->dests, sizeof(conn->dests),
-							conn->metric, firstspace);
-
-				/* restart building new one from the start */
-				q = conn->metric;
-				firstspace = NULL;
-
-				conn->wait = time(NULL);
-				/* send the metric to where it is supposed to go */
-				if (dispatch_process_dests(conn, self) == 0)
-					break;
+			} else if (firstspace != NULL ||
+					(*p >= 'a' && *p <= 'z') ||
+					(*p >= 'A' && *p <= 'Z') ||
+					(*p >= '0' && *p <= '9') ||
+					*p == '-' || *p == '_' || *p == ':')
+			{
+				/* copy char */
+				*q++ = *p;
 			} else {
 				/* something barf, replace by underscore */
 				*q++ = '_';


dispatch_addconnection: memset per connection to help Coverity

--- dispatcher.c
+++ dispatcher.c
@@ -242,10 +242,10 @@
 			return -1;
 		}

-		memset(&newlst[connectionslen], '\0',
-				sizeof(connection) * CONNGROWSZ);
-		for (c = connectionslen; c < connectionslen + CONNGROWSZ; c++)
+		for (c = connectionslen; c < connectionslen + CONNGROWSZ; c++) {
+			memset(&newlst[c], '\0', sizeof(connection));
 			newlst[c].takenby = -1;  /* free */
+		}
 		connections = newlst;
 		c = connectionslen;  /* for the setup code below */
 		newlst[c].takenby = -2;


Add LockHeader()/StopConcurrentMutations() functions to reduce repeated code/comments in TcmallocSlab.

Also:
- Simplify the Locking code in ShrinkOtherCache().
- Move the order of declarations in TcmallocSlab's private section to match the style guide: types, static constants, functions, data members.
PiperOrigin-RevId: 418682433
Change-Id: I27cdb88eeb21fc686f5ec177e3cea8aaa85bf31e

--- tcmalloc/internal/percpu_tcmalloc.h
+++ tcmalloc/internal/percpu_tcmalloc.h
@@ -182,16 +182,6 @@
   }

  private:
-  // Since we lazily initialize our slab, we expect it to be mmap'd and not
-  // resident.  We align it to a page size so neighboring allocations (from
-  // TCMalloc's internal arena) do not necessarily cause the metadata to be
-  // faulted in.
-  //
-  // We prefer a small page size (EXEC_PAGESIZE) over the anticipated huge page
-  // size to allow small-but-slow to allocate the slab in the tail of its
-  // existing Arena block.
-  static constexpr std::align_val_t kPhysicalPageAlign{EXEC_PAGESIZE};
-
   // In order to support dynamic slab metadata sizes, we need to be able to
   // atomically update both the slabs pointer and the shift value so we store
   // both together in an atomic SlabsAndShift, which manages the bit operations.
@@ -246,30 +236,46 @@
     void Lock();
   };

+  // We cast Header to std::atomic<int64_t>.
+  static_assert(sizeof(Header) == sizeof(std::atomic<int64_t>),
+                "bad Header size");
+
+  // Since we lazily initialize our slab, we expect it to be mmap'd and not
+  // resident.  We align it to a page size so neighboring allocations (from
+  // TCMalloc's internal arena) do not necessarily cause the metadata to be
+  // faulted in.
+  //
+  // We prefer a small page size (EXEC_PAGESIZE) over the anticipated huge page
+  // size to allow small-but-slow to allocate the slab in the tail of its
+  // existing Arena block.
+  static constexpr std::align_val_t kPhysicalPageAlign{EXEC_PAGESIZE};
+
   // It's important that we use consistent values for slabs/shift rather than
   // loading from the atomic repeatedly whenever we use one of the values.
   std::pair<Slabs*, size_t> GetSlabsAndShift(std::memory_order order) const {
     return slabs_and_shift_.load(order).Get();
   }

-  // We cast Header to std::atomic<int64_t>.
-  static_assert(sizeof(Header) == sizeof(std::atomic<int64_t>),
-                "bad Header size");
+  static Slabs* CpuMemoryStart(Slabs* slabs, size_t shift, int cpu);
+  static std::atomic<int64_t>* GetHeader(Slabs* slabs, size_t shift, int cpu,
+                                         size_t cl);
+  static Header LoadHeader(std::atomic<int64_t>* hdrp);
+  static void StoreHeader(std::atomic<int64_t>* hdrp, Header hdr);
+  static void LockHeader(Slabs* slabs, size_t shift, int cpu, size_t cl);
+  static int CompareAndSwapHeader(int cpu, std::atomic<int64_t>* hdrp,
+                                  Header old, Header hdr,
+                                  size_t virtual_cpu_id_offset);
+  // Stops concurrent mutations from occurring for <cpu> by locking the
+  // corresponding headers. All allocations/deallocations will miss this cache
+  // for <cpu> until the headers are unlocked.
+  static void StopConcurrentMutations(Slabs* slabs, size_t shift, int cpu,
+                                      size_t virtual_cpu_id_offset);

   // We store both a pointer to the array of slabs and the shift value together
   // so that we can atomically update both with a single store.
   std::atomic<SlabsAndShift> slabs_and_shift_{};
   // This is in units of bytes.
   size_t virtual_cpu_id_offset_ = offsetof(kernel_rseq, cpu_id);
-
-  static Slabs* CpuMemoryStart(Slabs* slabs, size_t shift, int cpu);
-  static std::atomic<int64_t>* GetHeader(Slabs* slabs, size_t shift, int cpu,
-                                         size_t cl);
-  static Header LoadHeader(std::atomic<int64_t>* hdrp);
-  static void StoreHeader(std::atomic<int64_t>* hdrp, Header hdr);
-  static int CompareAndSwapHeader(int cpu, std::atomic<int64_t>* hdrp,
-                                  Header old, Header hdr,
-                                  size_t virtual_cpu_id_offset);
 };

 template <size_t NumClasses>
@@ -1014,6 +1020,16 @@
 }

 template <size_t NumClasses>
+inline void TcmallocSlab<NumClasses>::LockHeader(Slabs* slabs, size_t shift,
+                                                 int cpu, size_t cl) {
+  // Note: this reinterpret_cast and write in Lock lead to undefined
+  // behavior, because the actual object type is std::atomic<int64_t>. But
+  // C++ does not allow to legally express what we need here: atomic writes
+  // of different sizes.
+  reinterpret_cast<Header*>(GetHeader(slabs, shift, cpu, cl))->Lock();
+}
+
+template <size_t NumClasses>
 inline int TcmallocSlab<NumClasses>::CompareAndSwapHeader(
     int cpu, std::atomic<int64_t>* hdrp, Header old, Header hdr,
     const size_t virtual_cpu_id_offset) {
@@ -1026,6 +1042,26 @@
 #else
   Crash(kCrash, __FILE__, __LINE__, "This architecture is not supported.");
 #endif
+}
+
+template <size_t NumClasses>
+inline void TcmallocSlab<NumClasses>::StopConcurrentMutations(
+    Slabs* slabs, size_t shift, int cpu, size_t virtual_cpu_id_offset) {
+  for (bool done = false; !done;) {
+    for (size_t cl = 0; cl < NumClasses; ++cl) {
+      LockHeader(slabs, shift, cpu, cl);
+    }
+    FenceCpu(cpu, virtual_cpu_id_offset);
+    done = true;
+    for (size_t cl = 0; cl < NumClasses; ++cl) {
+      Header hdr = LoadHeader(GetHeader(slabs, shift, cpu, cl));
+      if (!hdr.IsLocked()) {
+        // Header was overwritten by Grow/Shrink. Retry.
+        done = false;
+        break;
+      }
+    }
+  }
 }

 template <size_t NumClasses>
@@ -1098,34 +1134,15 @@
   const auto [slabs, shift] = GetSlabsAndShift(std::memory_order_relaxed);
   const size_t virtual_cpu_id_offset = virtual_cpu_id_offset_;

-  // TODO(ckennelly): Consolidate this logic with Drain.
   // Phase 1: verify no header is locked
   for (size_t cl = 0; cl < NumClasses; ++cl) {
     Header hdr = LoadHeader(GetHeader(slabs, shift, cpu, cl));
     CHECK_CONDITION(!hdr.IsLocked());
   }

-  // Phase 2: Stop concurrent mutations.  Locking ensures that there exists no
-  // value of current such that begin < current.
-  for (bool done = false; !done;) {
-    for (size_t cl = 0; cl < NumClasses; ++cl) {
-      // Note: this reinterpret_cast and write in Lock lead to undefined
-      // behavior, because the actual object type is std::atomic<int64_t>. But
-      // C++ does not allow to legally express what we need here: atomic writes
-      // of different sizes.
-      reinterpret_cast<Header*>(GetHeader(slabs, shift, cpu, cl))->Lock();
-    }
-    FenceCpu(cpu, virtual_cpu_id_offset);
-    done = true;
-    for (size_t cl = 0; cl < NumClasses; ++cl) {
-      Header hdr = LoadHeader(GetHeader(slabs, shift, cpu, cl));
-      if (!hdr.IsLocked()) {
-        // Header was overwritten by Grow/Shrink. Retry.
-        done = false;
-        break;
-      }
-    }
-  }
+  // Phase 2: stop concurrent mutations for <cpu>. Locking ensures that there
+  // exists no value of current such that begin < current.
+  StopConcurrentMutations(slabs, shift, cpu, virtual_cpu_id_offset);

   // Phase 3: Initialize prefetch target and compute the offsets for the
   // boundaries of each size class' cache.
@@ -1200,18 +1217,13 @@
   CHECK_CONDITION(!hdr.IsLocked());
   const uint16_t begin = hdr.begin;

-  // Phase 2: stop concurrent mutations.
-  for (bool done = false; !done;) {
-    reinterpret_cast<Header*>(GetHeader(slabs, shift, cpu, cl))->Lock();
+  // Phase 2: stop concurrent mutations for <cpu> for size class <cl>.
+  do {
+    LockHeader(slabs, shift, cpu, cl);
     FenceCpu(cpu, virtual_cpu_id_offset);
-    done = true;
-
     hdr = LoadHeader(GetHeader(slabs, shift, cpu, cl));
-    if (!hdr.IsLocked()) {
-      // Header was overwritten by Grow/Shrink. Retry.
-      done = false;
-    }
-  }
+    // If the header was overwritten in Grow/Shrink, then we need to try again.
+  } while (!hdr.IsLocked());

   // Phase 3: If we do not have len number of items to shrink, we try
   // to pop items from the list first to create enough capacity that can be
@@ -1280,26 +1292,8 @@
     begin[cl] = hdr.begin;
   }

-  // Phase 2: stop concurrent mutations.
-  for (bool done = false; !done;) {
-    for (size_t cl = 0; cl < NumClasses; ++cl) {
-      // Note: this reinterpret_cast and write in Lock lead to undefined
-      // behavior, because the actual object type is std::atomic<int64_t>. But
-      // C++ does not allow to legally express what we need here: atomic writes
-      // of different sizes.
-      reinterpret_cast<Header*>(GetHeader(slabs, shift, cpu, cl))->Lock();
-    }
-    FenceCpu(cpu, virtual_cpu_id_offset);
-    done = true;
-    for (size_t cl = 0; cl < NumClasses; ++cl) {
-      Header hdr = LoadHeader(GetHeader(slabs, shift, cpu, cl));
-      if (!hdr.IsLocked()) {
-        // Header was overwritten by Grow/Shrink. Retry.
-        done = false;
-        break;
-      }
-    }
-  }
+  // Phase 2: stop concurrent mutations for <cpu>.
+  StopConcurrentMutations(slabs, shift, cpu, virtual_cpu_id_offset);

   // Phase 3: execute callbacks.
   for (size_t cl = 0; cl < NumClasses; ++cl) {


Improve wording of TpConnectionRequestHandlesCb, TpConnectionHoldHandlesCb docs

It was previously unclear whether it was the same pointer, or a pointer
to a copy.

--- telepathy-glib/connection-handles.c
+++ telepathy-glib/connection-handles.c
@@ -348,7 +348,7 @@
  *  tp_connection_hold_handles()
  * @n_handles: the number of handles that were passed to
  *  tp_connection_hold_handles() on success, or 0 on failure
- * @handles: the same @n_handles handles that were passed to
+ * @handles: a copy of the array of @n_handles handles that was passed to
  *  tp_connection_hold_handles() on success, or %NULL on failure
  * @error: %NULL on success, or an error on failure
  * @user_data: the same arbitrary pointer that was passed to
@@ -487,7 +487,7 @@
  *  tp_connection_request_handles() on success, or 0 on failure
  * @handles: the @n_handles handles corresponding to @ids, in the same order,
  *  or %NULL on failure
- * @ids: the same @n_handles IDs that were passed to
+ * @ids: a copy of the array of @n_handles IDs that was passed to
  *  tp_connection_request_handles() on success, or %NULL on failure
  * @error: %NULL on success, or an error on failure
  * @user_data: the same arbitrary pointer that was passed to


Make DEBUG=1 mode work with mouse events

--- termkey.c
+++ termkey.c
@@ -133,6 +133,14 @@
   case TERMKEY_TYPE_KEYSYM:
     fprintf(stderr, "Keysym sym=%d(%s)", key->code.sym, termkey_get_keyname(tk, key->code.sym));
     break;
+  case TERMKEY_TYPE_MOUSE:
+    {
+      TermKeyMouseEvent ev;
+      int button, line, col;
+      termkey_interpret_mouse(tk, key, &ev, &button, &line, &col);
+      fprintf(stderr, "Mouse ev=%d button=%d pos=(%d,%d)\n", ev, button, line, col);
+    }
+    break;
   }

   int m = key->modifiers;


Improve diagnostics while walking the DOM.

--- xmp2rdf.c
+++ xmp2rdf.c
@@ -173,7 +173,9 @@
 process_document(xmlDoc *doc)
 {
 	xmlNode *root, *node;
-
+	int processed;
+
+	processed = 0;
 	root = xmlDocGetRootElement(doc);
 	for(node = root; node; node = node->next)
 	{
@@ -185,25 +187,46 @@
 		{
 			if(!strcmp((const char *) node->name, "xmpmeta") || !strcmp((const char *) node->name, "xapmeta"))
 			{
-				process_container(doc, node);
+				if(processed)
+				{
+					fprintf(stderr, "%s: Warning: multiple XMP metadata containers found; only the first will be processed\n", input_filename);
+				}
+				else
+				{
+					if(process_container(doc, node))
+					{
+						return -1;
+					}
+					processed++;
+				}
 				return 0;
 			}
 		}
 		else if(node->ns && !strcmp((const char *) node->ns->href, "http://www.w3.org/1999/02/22-rdf-syntax-ns#") && !strcmp((const char *) node->name, "RDF"))
 		{
-			process_rdf(doc, node);
-			return 0;
+			if(processed)
+			{
+				fprintf(stderr, "%s: Warning: multiple XMP metadata containers found; only the first will be processed\n", input_filename);
+			}
+			else
+			{
+				if(process_rdf(doc, node))
+				{
+					return -1;
+				}
+				processed++;
+			}
 		}
 		if(node->ns && node->ns->href && node->ns->href[0])
 		{
-			fprintf(stderr, "%s: unexpected element %s within the %s namespace\n", input_filename, node->name, node->ns->href);
+			fprintf(stderr, "%s: Warning: unexpected element %s within the %s namespace\n", input_filename, node->name, node->ns->href);
 		}
 		else
 		{
-			fprintf(stderr, "%s: unexpected element %s within the default namespace\n", input_filename, node->name);
-		}
-		break;
-	}
+			fprintf(stderr, "%s: Warning: unexpected element %s within the default namespace\n", input_filename, node->name);
+		}
+	}
+	fprintf(stderr, "%s: no XMP metadata container found\n", input_filename);
 	return -1;
 }


Reduce default movie framerate to 10 FPS

--- testmud/mud/home/Game/lib/animate.c
+++ testmud/mud/home/Game/lib/animate.c
@@ -30,7 +30,7 @@
 void begin()
 {
 	oldtime = millitime();
-	framerate = 30;
+	framerate = 10;

 	query_user()->set_mode(MODE_NOECHO);


Remove use of deprecated GtkVBox API in GTK+ example

RevBy: TrustMe
When building with recent GTK+ 3.0 and CONFIG+=debug
this will cause the build to fail.

--- examples/apps/gtk2/exampleapp-gtk.c
+++ examples/apps/gtk2/exampleapp-gtk.c
@@ -34,7 +34,12 @@
     entry = gtk_entry_new();
     text_view = gtk_text_view_new();
     gtk_widget_set_size_request(text_view, 150, 200);
+
+#if GTK_MAJOR_VERSION >= 3
+    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
+#else
     vbox = gtk_vbox_new(FALSE, 10);
+#endif

     gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);


Create repeated_decl_2.c

Create repeated_decl_2.c

Некорректно считывается код после ошибки, если сразу после ошибки написать текст, то транслятор будет думать, что этот текст и есть эта переменная, если просто ; поставить, то дальнейший код читается корректно

error: pathspec 'tests/errors/Dima/repeated_decl_2.c' did not match any file(s) known to git

--- tests/errors/Dima/repeated_decl_2.c
+++ tests/errors/Dima/repeated_decl_2.c
@@ -0,0 +1,8 @@
+int main()
+{
+	int a;
+	void a;
+	//; //нужно раскоментить, чтобы дальнейший код читался правильно
+	//hj //если вместо ; раскоментить этот текст, то выдаст ошибку повторное описание идентификатора hj
+	return 0;
+}


Remove unnecessary file

Remove unnecessary file

--- tests/overhead/extrae_get_caller4.c
+++ tests/overhead/extrae_get_caller4.c
@@ -1,68 +0,0 @@
-/*****************************************************************************\
- *                        ANALYSIS PERFORMANCE TOOLS                         *
- *                                   Extrae                                  *
- *              Instrumentation package for parallel applications            *
- *****************************************************************************
- *     ___     This library is free software; you can redistribute it and/or *
- *    /  __         modify it under the terms of the GNU LGPL as published   *
- *   /  /  _____    by the Free Software Foundation; either version 2.1      *
- *  /  /  /     \   of the License, or (at your option) any later version.   *
- * (  (  ( B S C )                                                           *
- *  \  \  \_____/   This library is distributed in hope that it will be      *
- *   \  \__         useful but WITHOUT ANY WARRANTY; without even the        *
- *    \___          implied warranty of MERCHANTABILITY or FITNESS FOR A     *
- *                  PARTICULAR PURPOSE. See the GNU LGPL for more details.   *
- *                                                                           *
- * You should have received a copy of the GNU Lesser General Public License  *
- * along with this library; if not, write to the Free Software Foundation,   *
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA          *
- * The GNU LEsser General Public License is contained in the file COPYING.   *
- *                                 ---------                                 *
- *   Barcelona Supercomputing Center - Centro Nacional de Supercomputacion   *
-\*****************************************************************************/
-
-/* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- *\
- | @file: $HeadURL$
- | @last_commit: $Date$
- | @version:     $Revision$
-\* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
-#include <stdio.h>
-#include <time.h>
-
-#include "extrae_user_events.h"
-
-extern void * get_caller (int);
-
-void xyz (int n)
-{
-	int i;
-	for (i = 0; i < n; i++)
-		get_caller (5);
-}
-
-void bar (int n)
-{
-	xyz (n);
-}
-
-void foo (int n)
-{
-	bar (n);
-}
-
-int main(int argc, char **argv)
-{
-	unsigned long long t1, t2;
-	struct timespec start, stop;
-	int n = 1000000, i;
-	Extrae_init();
-	clock_gettime (CLOCK_MONOTONIC, &start);
-	foo (n);
-	clock_gettime (CLOCK_MONOTONIC, &stop);
-	t1 = start.tv_nsec;
-	t1 += start.tv_sec * 1000000000;
-	t2 = stop.tv_nsec;
-	t2 += stop.tv_sec * 1000000000;
-	printf ("RESULT : Extrae_eventandcounters() %Lu ns\n", (t2 - t1) / n);
-	Extrae_fini();
-}


third_party/threads: use intptr_t for int<>void* typecasting

While the current code operates correctly, one needs to wrap
all the typecasting via intptr_t to prevent compiler warnings
such as

  warning: cast to pointer from integer of different size
  [-Wint-to-pointer-cast]

  warning: cast from pointer to integer of different size
  [-Wpointer-to-int-cast]

Signed-off-by: Emil Velikov <4c996f2f093ddd0585a556460b4cc3ba555546ef@gmail.com>

--- third_party/threads/threads_posix.c
+++ third_party/threads/threads_posix.c
@@ -66,7 +66,7 @@
 {
     struct impl_thrd_param pack = *((struct impl_thrd_param *)p);
     free(p);
-    return (void*)pack.func(pack.arg);
+    return (void*)(intptr_t)pack.func(pack.arg);
 }

@@ -253,7 +253,7 @@
 // 7.25.5.5
 void thrd_exit(int res)
 {
-    pthread_exit((void*)res);
+    pthread_exit((void*)(intptr_t)res);
 }

 // 7.25.5.6
@@ -263,7 +263,7 @@
     if (pthread_join(thr, &code) != 0)
         return thrd_error;
     if (res)
-        *res = (int)code;
+        *res = (int)(intptr_t)code;
     return thrd_success;
 }


Fix compile warning

Fix compile warning

--- thirdparty/ck/include/ck_spinlock.h
+++ thirdparty/ck/include/ck_spinlock.h
@@ -527,7 +527,7 @@
 {

 	ck_pr_fence_memory();
-	CK_SPINLOCK_TICKET_INC((CK_SPINLOCK_TICKET_TYPE_BASE *)&ticket->value);
+	CK_SPINLOCK_TICKET_INC((CK_SPINLOCK_TICKET_TYPE_BASE *)(void*)&ticket->value);
 	return;
 }


fix unsigned and signed comparison

fix unsigned and signed comparison

Summary:
I was building `//crypto/cat/cpp/tests/examples:corp_e2e_manual_test` on Windows and build failed because of this.
`refCount` is `size_t` and it's being compared with `int`. Probably I was building with stricter flags than needed but this fix looks harmless to me.

Full error I had:
```
buck-out/dev/cells/fbsource/gen/third-party/glog/glogWindows#header-mode-symlink-tree-only,headers\glog/logging.h:703:32: error: comparison of integers of different signs: 'const unsigned long long' and 'const int' [-Werror,-Wsign-compare]
DEFINE_CHECK_OP_IMPL(Check_GT, > )
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
buck-out/dev/cells/fbsource/gen/third-party/glog/glogWindows#header-mode-symlink-tree-only,headers\glog/logging.h:687:32: note: expanded from macro 'DEFINE_CHECK_OP_IMPL'
    if (GOOGLE_PREDICT_TRUE(v1 op v2)) return NULL; \
                            ~~ ^  ~~
buck-out/dev/cells/fbsource/gen/third-party/glog/glogWindows#header-mode-symlink-tree-only,headers\glog/logging.h:141:32: note: expanded from macro 'GOOGLE_PREDICT_TRUE'
#define GOOGLE_PREDICT_TRUE(x) x
                               ^
buck-out/dev/gen/thrift/lib/cpp2/async/interaction#header-mode-symlink-tree-only,headers\thrift/lib/cpp2/async/Interaction.h:93:5: note: in instantiation of function template specialization 'google::Check_GTImpl<unsigned long long, int>' requested here
    DCHECK_GT(refCount_, 0);
    ^
buck-out/dev/cells/fbsource/gen/third-party/glog/glogWindows#header-mode-symlink-tree-only,headers\glog/logging.h:980:31: note: expanded from macro 'DCHECK_GT'
#define DCHECK_GT(val1, val2) CHECK_GT(val1, val2)
                              ^
buck-out/dev/cells/fbsource/gen/third-party/glog/glogWindows#header-mode-symlink-tree-only,headers\glog/logging.h:774:30: note: expanded from macro 'CHECK_GT'
#define CHECK_GT(val1, val2) CHECK_OP(_GT, > , val1, val2)
                             ^
buck-out/dev/cells/fbsource/gen/third-party/glog/glogWindows#header-mode-symlink-tree-only,headers\glog/logging.h:745:3: note: expanded from macro 'CHECK_OP'
  CHECK_OP_LOG(name, op, val1, val2, google::LogMessageFatal)
  ^
buck-out/dev/cells/fbsource/gen/third-party/glog/glogWindows#header-mode-symlink-tree-only,headers\glog/logging.h:725:18: note: expanded from macro 'CHECK_OP_LOG'
         google::Check##name##Impl(                      \
                 ^
<scratch space>:14:1: note: expanded from here
Check_GTImpl
^
thrift\lib\cpp2\async\AsyncProcessor.cpp:428:18: note: in instantiation of function template specialization 'apache::thrift::Tile::__fbthrift_releaseRef<apache::thrift::Cpp2ConnContext>' requested here
    interaction->__fbthrift_releaseRef(
                 ^
1 error generated.
    When running <c++ preprocess_and_compile>.
    When building rule //thrift/lib/cpp2:async_processor#compile-AsyncProcessor.cpp.obj9c3cd9ff,windows-x86_64.
```

Reviewed By: Mizuchi, iahs

Differential Revision: D23867300

fbshipit-source-id: 1488387140fc702979a6ec5aaf9fdbdb7d87e24b

--- thrift/lib/cpp2/async/Interaction.h
+++ thrift/lib/cpp2/async/Interaction.h
@@ -90,7 +90,7 @@
       folly::EventBase& eb) {
     eb.dcheckIsInEventBaseThread();
     DCHECK(!__fbthrift_isPromise());
-    DCHECK_GT(refCount_, 0);
+    DCHECK_GT(refCount_, 0u);
     if (--refCount_ == 0 && terminationRequested_) {
       tm.add([tile = conn.removeTile(id)] {});
     }
@@ -121,7 +121,7 @@
       Cpp2ConnContext& ctx,
       concurrency::ThreadManager& tm,
       folly::EventBase& eb) {
-    DCHECK_EQ(refCount_, 0);
+    DCHECK_EQ(refCount_, 0u);

     if (destructionRequested_) {
       tm.add([tile = ctx.removeTile(id)] {});


Document constant_iterator & friends.

Document constant_iterator & friends.

--HG--
extra : convert_revision : svn%3A83215879-3e5a-4751-8c9d-778f44bb06a5/trunk%40454

--- thrust/iterator/constant_iterator.h
+++ thrust/iterator/constant_iterator.h
@@ -29,12 +29,74 @@
 namespace thrust
 {

+/*! \addtogroup iterators
+ *  \{
+ */
+
+/*! \p constant_iterator is a fancy iterator which represents a pointer into a sequence
+ *  of constant values. This iterator is useful for creating a sequence filled with the same
+ *  value without explicitly storing it in memory. Using \p constant_iterator saves both
+ *  memory capacity and bandwidth.
+ *
+ *  The following code snippet demonstrates how to create a \p constant_iterator whose
+ *  \c value_type is \c int and whose value is \c 10.
+ *
+ *  \code
+ *  #include <thrust/iterator/constant_iterator.h>
+ *
+ *  thrust::constant_iterator<int> iter(10);
+ *
+ *  *iter;    // returns 10
+ *  iter[0];  // returns 10
+ *  iter[1];  // returns 10
+ *  iter[13]; // returns 10
+ *
+ *  // and so on...
+ *  \endcode
+ *
+ *  This next example demonstrates how to use a \p constant_iterator with the
+ *  \p thrust::transform function to increment all elements of a sequence by the
+ *  same value. We will create a temporary \p constant_iterator with the function
+ *  \p make_constant_iterator function in order to avoid explicitly specifying
+ *  its type:
+ *
+ *  \code
+ *  #include <thrust/iterator/constant_iterator.h>
+ *  #include <thrust/transform.h>
+ *  #include <thrust/functional.h>
+ *  #include <thrust/device_vector.h>
+ *
+ *  int main(void)
+ *  {
+ *    thrust::device_vector<int> data(4);
+ *    data[0] = 3;
+ *    data[1] = 7;
+ *    data[2] = 2;
+ *    data[3] = 5;
+ *
+ *    // add 10 to all values in data
+ *    thrust::transform(data.begin(), data.end(),
+ *                      thrust::make_constant_iterator(10),
+ *                      data.begin(),
+ *                      thrust::plus<int>());
+ *
+ *    // data is now [13, 17, 12, 15]
+ *
+ *    return 0;
+ *  }
+ *
+ *  \endcode
+ *
+ *  \see make_constant_iterator
+ */
 template<typename Value,
          typename Incrementable = use_default,
          typename Space = use_default>
   class constant_iterator
     : public detail::constant_iterator_base<Value, Incrementable, Space>::type
 {
+    /*! \cond
+     */
     friend class thrust::experimental::iterator_core_access;
     typedef typename detail::constant_iterator_base<Value, Incrementable, Space>::type          super_t;
     typedef typename detail::constant_iterator_base<Value, Incrementable, Space>::incrementable incrementable;
@@ -44,26 +106,60 @@
     typedef typename super_t::reference  reference;
     typedef typename super_t::value_type value_type;

+    /*! \endcond
+     */
+
+    /*! Null constructor initializes this \p constant_iterator's constant using its
+     *  null constructor.
+     */
     __host__ __device__
     constant_iterator(void)
       : super_t(), m_value(){};

+    /*! Copy constructor copies the value of another \p constant_iterator into this
+     *  \p constant_iterator.
+     *
+     *  \p rhs The value to copy.
+     */
     __host__ __device__
     constant_iterator(constant_iterator const &rhs)
       : super_t(rhs.base()), m_value(rhs.m_value) {}

+    /*! This constructor receives a value to use as the constant value of this
+     *  \p constant_iterator and an index specifying the location of this
+     *  \p constant_iterator in a sequence.
+     *
+     *  \p v The value of this \p constant_iterator's constant value.
+     *  \p i The index of this \p constant_iterator in a sequence. Defaults to the
+     *       value returned by \c Incrementable's null constructor. For example,
+     *       when <tt>Incrementable == int</tt>, \c 0.
+     */
     __host__ __device__
     constant_iterator(value_type const& v, incrementable const &i = incrementable())
       : super_t(base_iterator(i)), m_value(v) {}

+    /*! This constructor is templated to allow construction from a value type and
+     *  incrementable type related this this \p constant_iterator's respective types.
+     *
+     *  \p v The value of this \p constant_iterator's constant value.
+     *  \p i The index of this \p constant_iterator in a sequence. Defaults to the
+     *       value returned by \c Incrementable's null constructor. For example,
+     *       when <tt>Incrementable == int</tt>, \c 0.
+     */
     template<typename OtherValue, typename OtherIncrementable>
     __host__ __device__
     constant_iterator(OtherValue const& v, OtherIncrementable const& i = incrementable())
       : super_t(base_iterator(i)), m_value(v) {}

+    /*! This method returns the value of this \p constant_iterator's constant value.
+     *  \return A \c const reference to this \p constant_iterator's constant value.
+     */
     __host__ __device__
     Value const& value(void) const
     { return m_value; }
+
+    /*! \cond
+     */

   protected:
     __host__ __device__
@@ -83,8 +179,26 @@

   private:
     const Value m_value;
+
+    /*! \endcond
+     */
 }; // end constant_iterator

+
+/*! This version of \p make_constant_iterator creates a \p constant_iterator
+ *  from values given for both value and index. The type of \p constant_iterator
+ *  may be inferred by the compiler from the types of its parameters.
+ *
+ *  \param x The value of the returned \p constant_iterator's constant value.
+ *  \param i The index of the returned \p constant_iterator within a sequence.
+ *           The type of this parameter defaults to \c int. In the default case,
+ *           the value of this parameter is \c 0.
+ *
+ *  \return A new \p constant_iterator with constant value & index as given
+ *          by \p x & \p i.
+ *
+ *  \see constant_iterator
+ */
 template<typename V, typename I>
 inline __host__ __device__
 constant_iterator<V,I> make_constant_iterator(V x, I i = int())
@@ -92,6 +206,16 @@
   return constant_iterator<V,I>(x, i);
 } // end make_constant_iterator()

+
+/*! This version of \p make_constant_iterator creates a \p constant_iterator
+ *  using only a parameter for the desired constant value. The value of the
+ *  returned \p constant_iterator's index is set to \c 0.
+ *
+ *  \param x The value of the returned \p constant_iterator's constant value.
+ *  \return A new \p constant_iterator with constant value equal to \p x and
+ *          index equal to \c 0.
+ *  \see constant_iterator
+ */
 template<typename V>
 inline __host__ __device__
 constant_iterator<V> make_constant_iterator(V x)


gnutls: really fix leak in privkey export

For some reason, the tests all time out for me when I run them locally
with asan, so this is trial-and-error debugging....

--- tls/gnutls/gtlscertificate-gnutls.c
+++ tls/gnutls/gtlscertificate-gnutls.c
@@ -176,16 +176,19 @@
                                              NULL, GNUTLS_PKCS_PLAIN,
                                              *output_data, output_size);
   if (status == 0)
-    return;
+    {
+      gnutls_x509_privkey_deinit (x509_privkey);
+      return;
+    }

   g_free (*output_data);

 err:
+  *output_data = NULL;
+  *output_size = 0;
+
   if (x509_privkey)
     gnutls_x509_privkey_deinit (x509_privkey);
-
-  *output_data = NULL;
-  *output_size = 0;
 }

 static void


Convert athdebug to use the 64 bit dev.ath.X.debug sysctl.

--- tools/tools/ath/athdebug/athdebug.c
+++ tools/tools/ath/athdebug/athdebug.c
@@ -51,6 +51,7 @@

 const char *progname;

+/* XXX TODO: include if_ath_debug.h */
 enum {
 	ATH_DEBUG_XMIT		= 0x00000001,	/* basic xmit operation */
 	ATH_DEBUG_XMIT_DESC	= 0x00000002,	/* xmit descriptors */
@@ -81,7 +82,7 @@

 static struct {
 	const char	*name;
-	u_int		bit;
+	uint64_t	bit;
 } flags[] = {
 	{ "xmit",	ATH_DEBUG_XMIT },
 	{ "xmit_desc",	ATH_DEBUG_XMIT_DESC },
@@ -109,7 +110,7 @@
 	{ "fatal",	ATH_DEBUG_FATAL },
 };

-static u_int
+static uint64_t
 getflag(const char *name, int len)
 {
 	int i;
@@ -150,7 +151,7 @@
 	const char *cp, *tp;
 	const char *sep;
 	int c, op, i;
-	u_int32_t debug, ndebug;
+	uint64_t debug, ndebug;
 	size_t debuglen;
 	char oid[256];


proxy-test: work even when the upstream DNS lies

Rather than depending on the host's DNS configuration to properly
return an error for a non-existent hostname, just substitute in
a dummy GResolver implementation that does it for us.

--- gio/tests/proxy-test.c
+++ gio/tests/proxy-test.c
@@ -674,6 +674,62 @@
 }

+/******************************************************************/
+/* Now a GResolver implementation, so the can't-resolve test will */
+/* pass even if you have an evil DNS-faking ISP.                  */
+/******************************************************************/
+
+typedef GResolver GFakeResolver;
+typedef GResolverClass GFakeResolverClass;
+
+G_DEFINE_TYPE (GFakeResolver, g_fake_resolver, G_TYPE_RESOLVER)
+
+static void
+g_fake_resolver_init (GFakeResolver *gtr)
+{
+}
+
+static GList *
+g_fake_resolver_lookup_by_name (GResolver     *resolver,
+				const gchar   *hostname,
+				GCancellable  *cancellable,
+				GError       **error)
+{
+  /* This is only ever called with lookups that are expected to
+   * fail.
+   */
+  g_set_error (error,
+	       G_RESOLVER_ERROR,
+	       G_RESOLVER_ERROR_NOT_FOUND,
+	       "Not found");
+  return NULL;
+}
+
+static void
+g_fake_resolver_lookup_by_name_async (GResolver           *resolver,
+				      const gchar         *hostname,
+				      GCancellable        *cancellable,
+				      GAsyncReadyCallback  callback,
+				      gpointer             user_data)
+{
+  g_simple_async_report_error_in_idle (G_OBJECT (resolver),
+				       callback, user_data,
+				       G_RESOLVER_ERROR,
+				       G_RESOLVER_ERROR_NOT_FOUND,
+				       "Not found");
+}
+
+static void
+g_fake_resolver_class_init (GFakeResolverClass *fake_class)
+{
+  GResolverClass *resolver_class = G_RESOLVER_CLASS (fake_class);
+
+  resolver_class->lookup_by_name        = g_fake_resolver_lookup_by_name;
+  resolver_class->lookup_by_name_async  = g_fake_resolver_lookup_by_name_async;
+}
+
+
+
 /****************************************/
 /* We made it! Now for the actual test! */
 /****************************************/
@@ -1030,6 +1086,7 @@
 main (int   argc,
       char *argv[])
 {
+  GResolver *fake_resolver;
   GCancellable *cancellable;
   gint result;

@@ -1047,6 +1104,9 @@
   g_proxy_b_get_type ();
   g_setenv ("GIO_USE_PROXY_RESOLVER", "test", TRUE);

+  fake_resolver = g_object_new (g_fake_resolver_get_type (), NULL);
+  g_resolver_set_default (fake_resolver);
+
   cancellable = g_cancellable_new ();
   create_server (&server, cancellable);
   create_proxy (&proxy_a, 'a', "alpha", cancellable);


usuniety

usuniety

--- git/TermometrAC/main.c
+++ git/TermometrAC/main.c
@@ -1,151 +0,0 @@
-#include <avr/io.h>
-#include <util/delay.h>
-#include <util/atomic.h>
-#include <stdlib.h>
-#include <avr/interrupt.h>
-#include <avr/pgmspace.h>
-#include <stdbool.h>
-
-#define BAUD 9600
-
-typedef struct CommText{
-	const __memx char* text;
-	uint8_t size;
-	bool dynamic;
-}CommText;
-
-typedef struct CommNode CommNode;
-
-struct CommNode{
-	CommNode* next;
-	CommText text;
-};
-
-typedef struct CommQueue{
-	CommNode* head;
-	CommNode* tail;
-	bool isEmpty;
-}CommQueue;
-
-
-
-CommQueue* getUsartToSendQueue(void){
-	static CommQueue usartToSendQueue={NULL,NULL,true};
-	return &usartToSendQueue;
-}
-
-CommQueue* getUsartReceivedQueue(void){
-	static CommQueue usartReceivedQueue={NULL,NULL,true};
-	return &usartReceivedQueue;
-}
-
-void queue(CommQueue* queue, CommText text){
-	CommNode* tmpNode=malloc(sizeof(CommNode));
-	tmpNode->next=NULL;
-	tmpNode->text=text;
-	if (queue->head==NULL){
-		queue->head=tmpNode;
-		queue->tail=tmpNode;
-		queue->isEmpty=false;
-	}
-	else{
-		queue->tail->next=tmpNode;
-		queue->tail=tmpNode;
-	}
-}
-
-CommText dequeue(CommQueue* queue){
-	if (queue->head==NULL){
-		CommText nullText={NULL,0,false};
-		return nullText;
-	}
-	CommNode* tmpNode=queue->head;
-	queue->head=queue->head->next;
-	if (queue->head==NULL){
-		queue->tail=NULL;
-		queue->isEmpty=true;
-	}
-	CommText retText=tmpNode->text;
-	free(tmpNode);
-	return retText;
-}
-
-
-
-
-
-
-void usartTransmit(uint8_t data) {
-/* Wait for empty transmit buffer */
-	while (!(UCSR0A & (1<<UDRE0))){};
-
-	UDR0 = data;
-}
-
-uint8_t usartReceive(void){
-/* Wait for data to be received */
-	while (!(UCSR0A & (1<<RXC0)));
-
-	return UDR0;
-}
-
-void usartInit(uint16_t baud){
-/*Set baud rate */
-	uint16_t ubrr=F_CPU/16/baud-1;
-	UBRR0H = (uint8_t)(ubrr>>8);
-	UBRR0L = (uint8_t)ubrr;
-
-/*Enable receiver and transmitter and interrupts*/
-	UCSR0B = (1<<RXEN0)|(1<<TXEN0)|(1<<TXCIE0)|(1<<RXCIE0);
-
-/* Set frame format: 8data, 2stop bit */
-	UCSR0C = (1<<USBS0)|(3<<UCSZ00);
-}
-
-ISR(USART_TX_vect){
-	if (!getUsartToSendQueue()->isEmpty)
-		ATOMIC_BLOCK(ATOMIC_RESTORESTATE){
-			CommText toSend=dequeue(getUsartToSendQueue());
-			const __memx char* p=toSend.text;
-			usartTransmit((uint8_t)toSend.size);
-			while(p){
-				usartTransmit(*p);
-				p++;
-			}
-			if (toSend.dynamic)
-				free(toSend.text);
-
-		}
-}
-
-ISR(USART_RX_vect){
-	static completedTransmission=true;
-	static uint8_t marker;
-	ATOMIC_BLOCK(ATOMIC_RESTORESTATE){
-		CommText received;
-		if (!completedTransmission){
-			received=getUsartReceivedQueue()->head->text;
-			*(received.text+marker)=usartRecive();
-			marker++;
-			if(marker==received.size){
-				completedTransmission=true;
-				*(received.text+marker)='\0';
-			}
-		}
-		else {
-			received.size=usartReceive();
-			received.dynamic=true;
-			received.text=malloc(received.size+1);
-			marker=0;
-		}
-
-	}
-
-}
-
-
-int main(void){
-	usartInit(BAUD);
-
-
-}


change platform to environment (#254)

change platform to environment (#254)

--- mixerclient/control/include/http/check_data.h
+++ mixerclient/control/include/http/check_data.h
@@ -47,7 +47,7 @@
   virtual std::map<std::string, std::string> GetRequestHeaders() const = 0;

   // These headers are extracted into top level attributes.
-  // They can be retrieved at O(1) speed by Platform (Envoy).
+  // They can be retrieved at O(1) speed by environment (Envoy).
   // It is faster to use the map from GetRequestHeader() call.
   enum HeaderType {
     HEADER_PATH = 0,


Test stdio wrappers

Test stdio wrappers

--- glib/tests/fileutils.c
+++ glib/tests/fileutils.c
@@ -27,10 +27,17 @@
 #define GLIB_DISABLE_DEPRECATION_WARNINGS

 #include <glib.h>
+
+/* Test our stdio wrappers here */
+#define G_STDIO_NO_WRAP_ON_UNIX
 #include <glib/gstdio.h>

 #ifdef G_OS_UNIX
 #include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <utime.h>
 #endif
 #ifdef G_OS_WIN32
 #include <windows.h>
@@ -643,17 +650,20 @@
 {
   gchar *name;
   GError *error = NULL;
+  gint ret;

   name = g_dir_make_tmp ("testXXXXXXtest", &error);
   g_assert_no_error (error);
   g_assert (g_file_test (name, G_FILE_TEST_IS_DIR));
-  g_assert (g_rmdir (name) == 0);
+  ret = g_rmdir (name);
+  g_assert (ret == 0);
   g_free (name);

   name = g_dir_make_tmp (NULL, &error);
   g_assert_no_error (error);
   g_assert (g_file_test (name, G_FILE_TEST_IS_DIR));
-  g_assert (g_rmdir (name) == 0);
+  ret = g_rmdir (name);
+  g_assert (ret == 0);
   g_free (name);

   name = g_dir_make_tmp ("test/XXXXXX", &error);
@@ -817,6 +827,69 @@
 #else
   g_test_skip ("Symbolic links not supported");
 #endif
+}
+
+static void
+test_stdio_wrappers (void)
+{
+  GStatBuf buf;
+  gchar *cwd, *path;
+  gint ret;
+  struct utimbuf ut;
+  GError *error = NULL;
+
+  g_remove ("mkdir-test/test-create");
+  g_rmdir ("mkdir-test");
+
+  ret = g_stat ("mkdir-test", &buf);
+  g_assert (ret == -1);
+  ret = g_mkdir ("mkdir-test", 0666);
+  g_assert (ret == 0);
+  ret = g_stat ("mkdir-test", &buf);
+  g_assert (ret == 0);
+  g_assert (S_ISDIR (buf.st_mode));
+
+  cwd = g_get_current_dir ();
+  path = g_build_filename (cwd, "mkdir-test", NULL);
+  g_free (cwd);
+  ret = g_chdir (path);
+  g_assert (errno == EACCES);
+  g_assert (ret == -1);
+  ret = g_chmod (path, 0777);
+  g_assert (ret == 0);
+  ret = g_chdir (path);
+  g_assert (ret == 0);
+  cwd = g_get_current_dir ();
+  g_assert (g_str_equal (cwd, path));
+  g_free (cwd);
+  g_free (path);
+
+  ret = g_creat ("test-creat", 0555);
+  g_close (ret, &error);
+  g_assert_no_error (error);
+
+  ret = g_access ("test-creat", F_OK);
+  g_assert (ret == 0);
+
+  ret = g_rename ("test-creat", "test-create");
+  g_assert (ret == 0);
+
+  ret = g_open ("test-create", O_RDONLY, 0666);
+  g_close (ret, &error);
+  g_assert_no_error (error);
+
+  ut.actime = ut.modtime = (time_t)0;
+  ret = g_utime ("test-create", &ut);
+  g_assert (ret == 0);
+
+  ret = g_lstat ("test-create", &buf);
+  g_assert (ret == 0);
+  g_assert (buf.st_atime == (time_t)0);
+  g_assert (buf.st_mtime == (time_t)0);
+
+  g_chdir ("..");
+  g_remove ("mkdir-test/test-create");
+  g_rmdir ("mkdir-test");
 }

 int
@@ -839,6 +912,7 @@
   g_test_add_func ("/fileutils/mkdtemp", test_mkdtemp);
   g_test_add_func ("/fileutils/set-contents", test_set_contents);
   g_test_add_func ("/fileutils/read-link", test_read_link);
+  g_test_add_func ("/fileutils/stdio-wrappers", test_stdio_wrappers);

   return g_test_run ();
 }


Add changes entry on: Change the tria pointer and the debug_output_grid function from private to protected to be used in derived classes.

git-svn-id: 31d9d2f6432a47c86a3640814024c107794ea77c@15766 0785d39b-7218-0410-832d-ea1e28bc413d

--- deal.II/doc/news/changes.h
+++ deal.II/doc/news/changes.h
@@ -261,9 +261,15 @@

+

Improved: The tria pointer and the debug_output_grid function in GridIn
+  are changed from private to protected to be accessible in derived classes.
+

+  (RH 2008/02/24)
+

+

New: The new Boundary::get_new_point_on_face and
   get_intermediate_points_on_face functions offer an dimension independent
-  interface to this class.
+  interface to the Boundary class.

   (RH 2008/02/24)


minor spelling correction within a comment

changing 'secrete' to 'secret'

--- google-authenticator.c
+++ google-authenticator.c
@@ -69,7 +69,7 @@
     return -1;
   }

-  // Compute the HMAC_SHA1 of the secrete and the challenge.
+  // Compute the HMAC_SHA1 of the secret and the challenge.
   uint8_t hash[SHA1_DIGEST_LENGTH];
   hmac_sha1(secret, secretLen, challenge, 8, hash, SHA1_DIGEST_LENGTH);


Fix warnings in Xcode 5

Fix warnings in Xcode 5

The default type of assign throws warnings about assign not being appropriate in Xcode 5.   Furthermore cocoapods :inhibit_warnings => true isn't suppressing these warnings...

--- Classes/Core/QAppearance.h
+++ Classes/Core/QAppearance.h
@@ -51,8 +51,8 @@
 @property(nonatomic, strong) UIColor *sectionTitleShadowColor;
 @property(nonatomic) BOOL toolbarTranslucent;
 @property(nonatomic) CGFloat cellBorderWidth;
-@property(nonatomic) NSNumber * defaultHeightForHeader;
-@property(nonatomic) NSNumber * defaultHeightForFooter;
+@property(nonatomic, strong) NSNumber * defaultHeightForHeader;
+@property(nonatomic, strong) NSNumber * defaultHeightForFooter;

 @property(nonatomic) UIBarStyle toolbarStyle;


ENH: removed BooleanStructuredPoints

ENH: removed BooleanStructuredPoints

--- graphics/vtkGraphics.h
+++ graphics/vtkGraphics.h
@@ -46,7 +46,6 @@
 #include "vtkAxes.h"
 #include "vtkBYUReader.h"
 #include "vtkBYUWriter.h"
-#include "vtkBooleanStructuredPoints.h"
 #include "vtkBooleanTexture.h"
 #include "vtkBrownianPoints.h"
 #include "vtkCamera.h"


COMP: #if TTTT is not accepted in Visual Studio for a variable that was previously       defined using #define TTTT 1.  Now replaced with #ifdef TTTT.

--- Code/Common/itkImageBase.h
+++ Code/Common/itkImageBase.h
@@ -271,7 +271,7 @@
    * prior to calling ComputeOffset. */

-#if ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING
+#ifdef ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING
   inline OffsetValueType ComputeOffset(const IndexType &ind) const
     {
     OffsetValueType offset = 0;
@@ -306,7 +306,7 @@
    * should be between 0 and the number of pixels in the
    * BufferedRegion (the latter can be found using
    * ImageRegion::GetNumberOfPixels()). */
-#if ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING
+#ifdef ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING
   inline IndexType ComputeIndex(OffsetValueType offset) const
     {
     IndexType index;
@@ -351,7 +351,7 @@
    * Floating point index results are truncated to integers.
    * Returns true if the resulting index is within the image, false otherwise
    * \sa Transform */
-#if ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING
+#ifdef ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING
   template<class TCoordRep>
   bool TransformPhysicalPointToIndex(
     const Point<TCoordRep, VImageDimension>& point,
@@ -441,7 +441,7 @@
    * from a discrete index (in the index space)
    *
    * \sa Transform */
-#if ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING
+#ifdef ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING
   template<class TCoordRep>
   void TransformIndexToPhysicalPoint(
                       const IndexType & index,


Added missing include.

Added missing include.

--- copasi/barChart/qwt3dScale.h
+++ copasi/barChart/qwt3dScale.h
@@ -1,23 +1,28 @@
 // Begin CVS Header
 //   $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/barChart/qwt3dScale.h,v $
-//   $Revision: 1.1 $
+//   $Revision: 1.2 $
 //   $Name:  $
-//   $Author: akoenig $
-//   $Date: 2007/11/12 17:01:07 $
+//   $Author: shoops $
+//   $Date: 2008/09/16 15:24:22 $
 // End CVS Header

-// Copyright (C) 2007 by Pedro Mendes, Virginia Tech Intellectual
+// Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
+// Properties, Inc., EML Research, gGmbH, University of Heidelberg,
+// and The University of Manchester.
+// All rights reserved.
+
+// Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
 // Properties, Inc. and EML Research, gGmbH.
 // All rights reserved.

 #ifndef SCALE_H
 #define SCALE_H

-#include "qwt3d_scale.h"
-
 #include <qstring.h>
-#include "qwt3d_types.h"
-#include "qwt3d_autoptr.h"
+#include <qwt3d_scale.h>
+#include <qwt3d_types.h>
+#include <qwt3d_autoptr.h>
+#include <qwt3d_axis.h>

 //! Automatic beautifying of linear scales
 class LinearAutoScaler2 : public Qwt3D::LinearAutoScaler


reflect moved MolDrawing;

reflect moved MolDrawing;

--- Code/JavaWrappers/Depict.h
+++ Code/JavaWrappers/Depict.h
@@ -30,7 +30,7 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

-#include <Demos/RDKit/Draw/MolDrawing.h>
+#include <GraphMol/MolDrawing/MolDrawing.h>

 namespace {
   std::string getColor(int atNum){


Make the value-checking macros avoid creating an error userInfo dictionary if the error is not going to be created (i.e. the given error reference pointer is NULL).

--- Code/RKValueTransformers.h
+++ Code/RKValueTransformers.h
@@ -96,8 +96,10 @@
         success = [inputValue isKindOfClass:expectedArgument]; \
     } \
     if (! success) { \
-        NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Expected an `inputValue` of type `%@`, but got a `%@`.", expectedArgument, [inputValue class]] };\
-        if (error) *error = [NSError errorWithDomain:RKValueTransformersErrorDomain code:RKValueTransformationErrorUntransformableInputValue userInfo:userInfo]; \
+        if (error) { \
+            NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Expected an `inputValue` of type `%@`, but got a `%@`.", expectedArgument, [inputValue class]] };\
+            *error = [NSError errorWithDomain:RKValueTransformersErrorDomain code:RKValueTransformationErrorUntransformableInputValue userInfo:userInfo]; \
+        } \
         return NO; \
     } \
 })
@@ -125,8 +127,10 @@
         success = [outputValueClass isSubclassOfClass:expectedArgument]; \
     } \
     if (! success) { \
-        NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Expected an `outputValueClass` of type `%@`, but got a `%@`.", expectedArgument, outputValueClass] };\
-        if (error) *error = [NSError errorWithDomain:RKValueTransformersErrorDomain code:RKValueTransformationErrorUnsupportedOutputClass userInfo:userInfo]; \
+        if (error) { \
+            NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Expected an `outputValueClass` of type `%@`, but got a `%@`.", expectedArgument, outputValueClass] };\
+            *error = [NSError errorWithDomain:RKValueTransformersErrorDomain code:RKValueTransformationErrorUnsupportedOutputClass userInfo:userInfo]; \
+        } \
         return NO; \
     } \
 })
@@ -143,10 +147,12 @@
  */
 #define RKValueTransformerTestTransformation(condition, error, ...) ({ \
 if (! (condition)) { \
-    NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: [NSString stringWithFormat:__VA_ARGS__] };\
-    if (error) *error = [NSError errorWithDomain:RKValueTransformersErrorDomain code:RKValueTransformationErrorTransformationFailed userInfo:userInfo]; \
-        return NO; \
-    } \
+    if (error) { \
+        NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: [NSString stringWithFormat:__VA_ARGS__] };\
+        *error = [NSError errorWithDomain:RKValueTransformersErrorDomain code:RKValueTransformationErrorTransformationFailed userInfo:userInfo]; \
+    } \
+    return NO; \
+  } \
 })

 ////////////////////////////////////////////////////////////////////////////////////////////////////


Coin Flip Simulator v1.0.0

Coin Flip Simulator v1.0.0

error: pathspec 'Coin-Flip-Simulator/main.c' did not match any file(s) known to git

--- Coin-Flip-Simulator/main.c
+++ Coin-Flip-Simulator/main.c
@@ -0,0 +1,31 @@
+/*
+/ Coin Flip Simulator v1.0.0
+/ Author: Julian D. Quitian
+/ Date: 12/27/2015
+*/
+
+#include <stdio.h>
+#include <time.h>
+#include <stdlib.h>
+
+int main(void){
+	int heads = 0, tails = 0, loops;
+	srand(time(NULL));
+
+	//Welcome Screen & User Input
+	printf("%s\n", "Welcome!\nPlease enter number of times you'd like the coin to be flipped: ");
+	scanf("%d", &loops);
+
+	//Randomize & count heads, tails
+	for(int i = 0; i < loops; i++){
+		num = (rand() % 2) + 1;
+		if(num == 1)
+			heads++;
+		if(num == 2)
+			tails++;
+	}
+
+	//Print results
+	printf("Heads: %d times\nTails: %d times\n", heads, tails);
+	return 1;
+}


[MOVED FROM BAD] fix to new plugin system

Original commit message from CVS:
fix to new plugin system

--- gst/y4m/gsty4mencode.c
+++ gst/y4m/gsty4mencode.c
@@ -26,15 +26,12 @@
 #include <gst/video/video.h>
 #include "gsty4mencode.h"

-static GstElementDetails y4mencode_details = {
+static GstElementDetails y4mencode_details = GST_ELEMENT_DETAILS (
   "Y4mEncode",
   "Codec/Video/Encoder",
-  "LGPL",
   "Encodes a YUV frame into the yuv4mpeg format (mjpegtools)",
-  VERSION,
-  "Wim Taymans <wim.taymans@chello.be>",
-  "(C) 2001",
-};
+  "Wim Taymans <wim.taymans@chello.be>"
+);

 /* Filter signals and args */
@@ -70,6 +67,7 @@
   )
 )

+static void	gst_y4mencode_base_init		(gpointer g_class);
 static void	gst_y4mencode_class_init	(GstY4mEncodeClass *klass);
 static void	gst_y4mencode_init		(GstY4mEncode *filter);

@@ -98,7 +96,7 @@
   if (!y4mencode_type) {
     static const GTypeInfo y4mencode_info = {
       sizeof(GstY4mEncodeClass),
-      NULL,
+      gst_y4mencode_base_init,
       NULL,
       (GClassInitFunc)gst_y4mencode_class_init,
       NULL,
@@ -114,6 +112,18 @@
   return y4mencode_type;
 }

+
+static void
+gst_y4mencode_base_init (gpointer g_class)
+{
+  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+
+  gst_element_class_add_pad_template (element_class,
+		  GST_PAD_TEMPLATE_GET (y4mencode_src_factory));
+  gst_element_class_add_pad_template (element_class,
+		  GST_PAD_TEMPLATE_GET (y4mencode_sink_factory));
+  gst_element_class_set_details (element_class, &y4mencode_details);
+}
 static void
 gst_y4mencode_class_init (GstY4mEncodeClass *klass)
 {
@@ -280,27 +290,20 @@
 }

 static gboolean
-plugin_init (GModule *module, GstPlugin *plugin)
-{
-  GstElementFactory *factory;
-
-  factory = gst_element_factory_new("y4menc",GST_TYPE_Y4MENCODE,
-                                   &y4mencode_details);
-  g_return_val_if_fail(factory != NULL, FALSE);
-
-  gst_element_factory_add_pad_template (factory,
-		  GST_PAD_TEMPLATE_GET (y4mencode_src_factory));
-  gst_element_factory_add_pad_template (factory,
-		  GST_PAD_TEMPLATE_GET (y4mencode_sink_factory));
-
-  gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
-
-  return TRUE;
-}
-
-GstPluginDesc plugin_desc = {
+plugin_init (GstPlugin *plugin)
+{
+  return gst_element_register (plugin, "y4menc", GST_RANK_NONE, GST_TYPE_Y4MENCODE);
+}
+
+GST_PLUGIN_DEFINE (
   GST_VERSION_MAJOR,
   GST_VERSION_MINOR,
   "y4menc",
-  plugin_init
-};
+  "Encodes a YUV frame into the yuv4mpeg format (mjpegtools)",
+  plugin_init,
+  VERSION,
+  GST_LICENSE,
+  GST_COPYRIGHT,
+  GST_PACKAGE,
+  GST_ORIGIN
+)


Use our own function to compute icon sizes

Signed-off-by: Federico Mena Quintero <4999915a961edfd7686112c2935288e1266eae14@gnome.org>

--- gtk/gtkplacessidebar.c
+++ gtk/gtkplacessidebar.c
@@ -206,6 +206,20 @@
 		       initiated_unmount);
 }

+static gint
+get_icon_size (GtkPlacesSidebar *sidebar)
+{
+	GtkSettings *settings;
+	gint width, height;
+
+	settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (sidebar)));
+
+	if (gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU, &width, &height))
+		return MAX (width, height);
+	else
+		return 16;
+}
+
 static GdkPixbuf *
 get_eject_icon (GtkPlacesSidebar *sidebar,
 		gboolean highlighted)
@@ -218,7 +232,7 @@
 	GtkStyleContext *style;

 	icon_theme = gtk_icon_theme_get_default ();
-	icon_size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+	icon_size = get_icon_size (sidebar);
 	icon = g_themed_icon_new_with_default_fallbacks ("media-eject-symbolic");
 	icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme, icon, icon_size, 0);

@@ -340,7 +354,7 @@

 	check_heading_for_section (sidebar, section_type);

-	icon_size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+	icon_size = get_icon_size (sidebar);
 	icon_info = nautilus_icon_info_lookup (icon, icon_size);

 	pixbuf = nautilus_icon_info_get_pixbuf_at_size (icon_info, icon_size);
@@ -965,7 +979,7 @@
 							sidebar->eject_icon_cell_renderer,
 							&x_offset, &width);

-		eject_button_size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+		eject_button_size = get_icon_size (sidebar);

 		/* This is kinda weird, but we have to do it to workaround gtk+ expanding
 		 * the eject cell renderer (even thought we told it not to) and we then


Unbreak the build.

Unbreak the build.

--- shotgun/lib/object.h
+++ shotgun/lib/object.h
@@ -1,5 +1,7 @@
 #ifndef SEEN_RUBINIUS_OBJECT_H
 #define SEEN_RUBINIUS_OBJECT_H
+
+#include <assert.h>

 OBJECT object_create_metaclass(STATE, OBJECT cls, OBJECT sup);
 OBJECT object_metaclass(STATE, OBJECT obj);


def-ed EXIT_SUCCESS/FAILURE for SunOS

def-ed EXIT_SUCCESS/FAILURE for SunOS

--- core/alsp_src/generic/defs.h
+++ core/alsp_src/generic/defs.h
@@ -190,6 +190,15 @@
 #include <stdlib.h>
 #endif	/* HAVE_STDLIB_H */

+/* SunOS fails to define EXIT_FAILURE and EXIT_SUCCESS */
+#ifndef EXIT_FAILURE
+#define EXIT_FAILURE 1
+#endif
+
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
+#endif
+
 #include <stdio.h>

 #if defined(HAVE_STDARG_H)


Sync from nautilus commit b2e8339d9f49770db0f6a523c8bf77b11d7eace3

Simplify setting eject icon

Signed-off-by: Federico Mena Quintero <4999915a961edfd7686112c2935288e1266eae14@gnome.org>

--- gtk/gtkplacessidebar.c
+++ gtk/gtkplacessidebar.c
@@ -182,7 +182,6 @@
 	PLACES_SIDEBAR_COLUMN_NO_EJECT,
 	PLACES_SIDEBAR_COLUMN_BOOKMARK,
 	PLACES_SIDEBAR_COLUMN_TOOLTIP,
-	PLACES_SIDEBAR_COLUMN_EJECT_GICON,
 	PLACES_SIDEBAR_COLUMN_SECTION_TYPE,
 	PLACES_SIDEBAR_COLUMN_HEADING_TEXT,

@@ -478,7 +477,6 @@
 	   const char *tooltip)
 {
 	GtkTreeIter           iter;
-	GIcon *eject;
 	gboolean show_eject, show_unmount;
 	gboolean show_eject_button;

@@ -495,12 +493,6 @@
 		show_eject_button = FALSE;
 	} else {
 		show_eject_button = (show_unmount || show_eject);
-	}
-
-	if (show_eject_button) {
-		eject = g_themed_icon_new_with_default_fallbacks ("media-eject-symbolic");
-	} else {
-		eject = NULL;
 	}

 	gtk_list_store_append (sidebar->store, &iter);
@@ -517,13 +509,8 @@
 			    PLACES_SIDEBAR_COLUMN_NO_EJECT, !show_eject_button,
 			    PLACES_SIDEBAR_COLUMN_BOOKMARK, place_type != PLACES_BOOKMARK,
 			    PLACES_SIDEBAR_COLUMN_TOOLTIP, tooltip,
-			    PLACES_SIDEBAR_COLUMN_EJECT_GICON, eject,
 			    PLACES_SIDEBAR_COLUMN_SECTION_TYPE, section_type,
 			    -1);
-
-	if (eject != NULL) {
-		g_object_unref (eject);
-	}
 }

 typedef struct {
@@ -3443,6 +3430,7 @@
 	GtkTreeViewColumn *col;
 	GtkCellRenderer   *cell;
 	GtkTreeSelection  *selection;
+	GIcon             *eject;

 	gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (sidebar)), GTK_STYLE_CLASS_SIDEBAR);

@@ -3522,6 +3510,7 @@
 	/* eject icon renderer */
 	cell = gtk_cell_renderer_pixbuf_new ();
 	sidebar->eject_icon_cell_renderer = cell;
+	eject = g_themed_icon_new_with_default_fallbacks ("media-eject-symbolic");
 	g_object_set (cell,
 		      "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
 		      "stock-size", GTK_ICON_SIZE_MENU,
@@ -3530,12 +3519,13 @@
 			 this even though we tell it not to. */
 		      "xalign", 1.0,
 		      "follow-state", TRUE,
+		      "gicon", eject,
 		      NULL);
 	gtk_tree_view_column_pack_start (col, cell, FALSE);
 	gtk_tree_view_column_set_attributes (col, cell,
 					     "visible", PLACES_SIDEBAR_COLUMN_EJECT,
-					     "gicon", PLACES_SIDEBAR_COLUMN_EJECT_GICON,
 					     NULL);
+	g_object_unref (eject);

 	/* normal text renderer */
 	cell = gtk_cell_renderer_text_new ();
@@ -3854,7 +3844,6 @@
 		G_TYPE_BOOLEAN,
 		G_TYPE_BOOLEAN,
 		G_TYPE_STRING,
-		G_TYPE_ICON,
 		G_TYPE_INT,
 		G_TYPE_STRING
 	};


Convert DistributedTableSizeOnWorker function to new connection API

--- src/backend/distributed/master/master_metadata_utility.c
+++ src/backend/distributed/master/master_metadata_utility.c
@@ -190,8 +190,12 @@
 	char *workerNodeName = workerNode->workerName;
 	uint32 workerNodePort = workerNode->workerPort;
 	char *tableSizeString;
+	uint64 tableSize = 0;
+	MultiConnection *connection = NULL;
+	uint32 connectionFlag = FORCE_NEW_CONNECTION;
+	PGresult *result = NULL;
+	int queryResult = 0;
 	List *sizeList = NIL;
-	uint64 tableSize = 0;

 	List *shardIntervalsOnNode = ShardIntervalsOnWorkerNode(workerNode, relationId);

@@ -199,14 +203,16 @@
 														   shardIntervalsOnNode,
 														   sizeQuery);

-	sizeList = ExecuteRemoteQuery(workerNodeName, workerNodePort, NULL, tableSizeQuery);
-
-	if (sizeList == NIL)
+	connection = GetNodeConnection(connectionFlag, workerNodeName, workerNodePort);
+	queryResult = ExecuteOptionalRemoteCommand(connection, tableSizeQuery->data, &result);
+
+	if (queryResult != 0)
 	{
 		ereport(ERROR, (errcode(ERRCODE_CONNECTION_FAILURE),
 						errmsg("cannot get the size because of a connection error")));
 	}

+	sizeList = ReadFirstColumnAsText(result);
 	tableSizeStringInfo = (StringInfo) linitial(sizeList);
 	tableSizeString = tableSizeStringInfo->data;
 	tableSize = atol(tableSizeString);


Remove to-do items for Nautilus; they are done now

--- gtk/gtkplacessidebar.c
+++ gtk/gtkplacessidebar.c
@@ -57,12 +57,6 @@
  * * Sync nautilus commit 1dcd2d816a1278f7eec1d074ec5d9134af34a803
  * * Sync nautilus commit 71ad0d3adc2553ef5bcd06ec32600302e9169765
  *
- * * Nautilus needs to connect to "populate-popup" and add these items:
- *
- *    * Open in new tab
- *    * Open in new window
- *    * Empty trash
- *    * Properties - only if g_file_is_native (location);
  */

 #include "config.h"