add support for MySQL 5.0.3's BIT (unsigned 64 bit vector) and NEWDECIMAL (arbitrary precision decimal string) types

--- drivers/mysql/dbd_mysql.c
+++ drivers/mysql/dbd_mysql.c
@@ -224,10 +224,7 @@

 int dbd_get_socket(dbi_conn_t *conn){
 	MYSQL *mycon = (MYSQL*)conn->connection;
-
-	if (!mycon) return -1;
-
-	return (int)mycon->net.fd;
+	return mycon ? mycon->net.fd : -1;
 }

 const char *dbd_get_encoding(dbi_conn_t *conn){
@@ -339,7 +336,7 @@
       /* return corresponding odd entry */
       return mysql_encoding_hash[i+1];
     }
-    i+=2;
+    i += 2;
   }

   /* don't know how to translate, return original encoding */
@@ -355,7 +352,7 @@
       /* return corresponding even entry */
       return mysql_encoding_hash[i];
     }
-    i+=2;
+    i += 2;
   }

   /* don't know how to translate, return original encoding */
@@ -581,6 +578,10 @@
 			_type = DBI_TYPE_INTEGER;
 			_attribs |= DBI_INTEGER_SIZE4;
 			break;
+#ifdef FIELD_TYPE_BIT
+		case FIELD_TYPE_BIT: // BIT field (MySQL 5.0.3 and up)
+			_attribs |= DBI_INTEGER_UNSIGNED;
+#endif
 		case FIELD_TYPE_LONGLONG:
 			_type = DBI_TYPE_INTEGER;
 			_attribs |= DBI_INTEGER_SIZE8;
@@ -622,6 +623,9 @@
 				_type = DBI_TYPE_BINARY;
 				break;
 			}
+#ifdef FIELD_TYPE_NEWDECIMAL
+		case FIELD_TYPE_NEWDECIMAL: // Precision math DECIMAL or NUMERIC field (MySQL 5.0.3 and up)
+#endif
 		case FIELD_TYPE_DECIMAL: /* decimal is actually a string, has arbitrary precision, no floating point rounding */
 		case FIELD_TYPE_ENUM:
 		case FIELD_TYPE_SET:


Add #include for std::tolower. Fixes VS2017 build error. (#5544)


nfp: add Rx and Tx

nfp: add Rx and Tx

Signed-off-by: Alejandro Lucero <1ffca3a1926aae782ae3c39a5b308878ba1e5683@netronome.com>
Signed-off-by: Rolf Neugebauer <6fdd1d8677ab4fbcb4df3eff6e190c3298f7f742@netronome.com>

--- drivers/net/nfp/nfp_net.c
+++ drivers/net/nfp/nfp_net.c
@@ -74,8 +74,25 @@
 static void nfp_net_close(struct rte_eth_dev *dev);
 static int nfp_net_configure(struct rte_eth_dev *dev);
 static int nfp_net_init(struct rte_eth_dev *eth_dev);
+static int nfp_net_rx_fill_freelist(struct nfp_net_rxq *rxq);
+static uint32_t nfp_net_rx_queue_count(struct rte_eth_dev *dev,
+				       uint16_t queue_idx);
+static uint16_t nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+				  uint16_t nb_pkts);
+static void nfp_net_rx_queue_release(void *rxq);
+static int nfp_net_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
+				  uint16_t nb_desc, unsigned int socket_id,
+				  const struct rte_eth_rxconf *rx_conf,
+				  struct rte_mempool *mp);
+static int nfp_net_tx_free_bufs(struct nfp_net_txq *txq);
+static void nfp_net_tx_queue_release(void *txq);
+static int nfp_net_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
+				  uint16_t nb_desc, unsigned int socket_id,
+				  const struct rte_eth_txconf *tx_conf);
 static int nfp_net_start(struct rte_eth_dev *dev);
 static void nfp_net_stop(struct rte_eth_dev *dev);
+static uint16_t nfp_net_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts);

 /*
  * The offset of the queue controller queues in the PCIe Target. These
@@ -184,6 +201,100 @@
 nn_cfg_writeq(struct nfp_net_hw *hw, int off, uint64_t val)
 {
 	nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
+}
+
+/* Creating memzone for hardware rings. */
+static const struct rte_memzone *
+ring_dma_zone_reserve(struct rte_eth_dev *dev, const char *ring_name,
+		      uint16_t queue_id, uint32_t ring_size, int socket_id)
+{
+	char z_name[RTE_MEMZONE_NAMESIZE];
+	const struct rte_memzone *mz;
+
+	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
+		 dev->driver->pci_drv.name,
+		 ring_name, dev->data->port_id, queue_id);
+
+	mz = rte_memzone_lookup(z_name);
+	if (mz)
+		return mz;
+
+	return rte_memzone_reserve_aligned(z_name, ring_size, socket_id, 0,
+					   NFP_MEMZONE_ALIGN);
+}
+
+static void
+nfp_net_rx_queue_release_mbufs(struct nfp_net_rxq *rxq)
+{
+	unsigned i;
+
+	if (rxq->rxbufs == NULL)
+		return;
+
+	for (i = 0; i < rxq->rx_count; i++) {
+		if (rxq->rxbufs[i].mbuf) {
+			rte_pktmbuf_free_seg(rxq->rxbufs[i].mbuf);
+			rxq->rxbufs[i].mbuf = NULL;
+		}
+	}
+}
+
+static void
+nfp_net_rx_queue_release(void *rx_queue)
+{
+	struct nfp_net_rxq *rxq = rx_queue;
+
+	if (rxq) {
+		nfp_net_rx_queue_release_mbufs(rxq);
+		rte_free(rxq->rxbufs);
+		rte_free(rxq);
+	}
+}
+
+static void
+nfp_net_reset_rx_queue(struct nfp_net_rxq *rxq)
+{
+	nfp_net_rx_queue_release_mbufs(rxq);
+	rxq->wr_p = 0;
+	rxq->rd_p = 0;
+	rxq->nb_rx_hold = 0;
+}
+
+static void
+nfp_net_tx_queue_release_mbufs(struct nfp_net_txq *txq)
+{
+	unsigned i;
+
+	if (txq->txbufs == NULL)
+		return;
+
+	for (i = 0; i < txq->tx_count; i++) {
+		if (txq->txbufs[i].mbuf) {
+			rte_pktmbuf_free_seg(txq->txbufs[i].mbuf);
+			txq->txbufs[i].mbuf = NULL;
+		}
+	}
+}
+
+static void
+nfp_net_tx_queue_release(void *tx_queue)
+{
+	struct nfp_net_txq *txq = tx_queue;
+
+	if (txq) {
+		nfp_net_tx_queue_release_mbufs(txq);
+		rte_free(txq->txbufs);
+		rte_free(txq);
+	}
+}
+
+static void
+nfp_net_reset_tx_queue(struct nfp_net_txq *txq)
+{
+	nfp_net_tx_queue_release_mbufs(txq);
+	txq->wr_p = 0;
+	txq->rd_p = 0;
+	txq->tail = 0;
 }

 static int
@@ -423,6 +534,18 @@
 	hw->ctrl = new_ctrl;
 }

+static int
+nfp_net_rx_freelist_setup(struct rte_eth_dev *dev)
+{
+	int i;
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		if (nfp_net_rx_fill_freelist(dev->data->rx_queues[i]) < 0)
+			return -1;
+	}
+	return 0;
+}
+
 static void
 nfp_net_params_setup(struct nfp_net_hw *hw)
 {
@@ -451,6 +574,7 @@
 {
 	uint32_t new_ctrl, update = 0;
 	struct nfp_net_hw *hw;
+	int ret;

 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);

@@ -476,18 +600,58 @@
 	if (nfp_net_reconfig(hw, new_ctrl, update) < 0)
 		return -EIO;

+	/*
+	 * Allocating rte mbuffs for configured rx queues.
+	 * This requires queues being enabled before
+	 */
+	if (nfp_net_rx_freelist_setup(dev) < 0) {
+		ret = -ENOMEM;
+		goto error;
+	}
+
 	hw->ctrl = new_ctrl;

 	return 0;
+
+error:
+	/*
+	 * An error returned by this function should mean the app
+	 * exiting and then the system releasing all the memory
+	 * allocated even memory coming from hugepages.
+	 *
+	 * The device could be enabled at this point with some queues
+	 * ready for getting packets. This is true if the call to
+	 * nfp_net_rx_freelist_setup() succeeds for some queues but
+	 * fails for subsequent queues.
+	 *
+	 * This should make the app exiting but better if we tell the
+	 * device first.
+	 */
+	nfp_net_disable_queues(dev);
+
+	return ret;
 }

 /* Stop device: disable rx and tx functions to allow for reconfiguring. */
 static void
 nfp_net_stop(struct rte_eth_dev *dev)
 {
+	int i;
+
 	PMD_INIT_LOG(DEBUG, "Stop\n");

 	nfp_net_disable_queues(dev);
+
+	/* Clear queues */
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		nfp_net_reset_tx_queue(
+			(struct nfp_net_txq *)dev->data->tx_queues[i]);
+	}
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		nfp_net_reset_rx_queue(
+			(struct nfp_net_rxq *)dev->data->rx_queues[i]);
+	}
 }

 /* Reset and stop device. The device can not be restarted. */
@@ -513,6 +677,828 @@
 	 * The ixgbe PMD driver disables the pcie master on the
 	 * device. The i40e does not...
 	 */
+}
+
+static uint32_t
+nfp_net_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_idx)
+{
+	struct nfp_net_rxq *rxq;
+	struct nfp_net_rx_desc *rxds;
+	uint32_t idx;
+	uint32_t count;
+
+	rxq = (struct nfp_net_rxq *)dev->data->rx_queues[queue_idx];
+
+	if (rxq == NULL) {
+		PMD_INIT_LOG(ERR, "Bad queue: %u\n", queue_idx);
+		return 0;
+	}
+
+	idx = rxq->rd_p % rxq->rx_count;
+	rxds = &rxq->rxds[idx];
+
+	count = 0;
+
+	/*
+	 * Other PMDs are just checking the DD bit in intervals of 4
+	 * descriptors and counting all four if the first has the DD
+	 * bit on. Of course, this is not accurate but can be good for
+	 * perfomance. But ideally that should be done in descriptors
+	 * chunks belonging to the same cache line
+	 */
+
+	while (count < rxq->rx_count) {
+		rxds = &rxq->rxds[idx];
+		if ((rxds->rxd.meta_len_dd & PCIE_DESC_RX_DD) == 0)
+			break;
+
+		count++;
+		idx++;
+
+		/* Wrapping? */
+		if ((idx) == rxq->rx_count)
+			idx = 0;
+	}
+
+	return count;
+}
+
+static int
+nfp_net_rx_queue_setup(struct rte_eth_dev *dev,
+		       uint16_t queue_idx, uint16_t nb_desc,
+		       unsigned int socket_id,
+		       const struct rte_eth_rxconf *rx_conf,
+		       struct rte_mempool *mp)
+{
+	const struct rte_memzone *tz;
+	struct nfp_net_rxq *rxq;
+	struct nfp_net_hw *hw;
+
+	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	/* Validating number of descriptors */
+	if (((nb_desc * sizeof(struct nfp_net_rx_desc)) % 128) != 0 ||
+	    (nb_desc > NFP_NET_MAX_RX_DESC) ||
+	    (nb_desc < NFP_NET_MIN_RX_DESC)) {
+		RTE_LOG(ERR, PMD, "Wrong nb_desc value\n");
+		return (-EINVAL);
+	}
+
+	/*
+	 * Free memory prior to re-allocation if needed. This is the case after
+	 * calling nfp_net_stop
+	 */
+	if (dev->data->rx_queues[queue_idx]) {
+		nfp_net_rx_queue_release(dev->data->rx_queues[queue_idx]);
+		dev->data->rx_queues[queue_idx] = NULL;
+	}
+
+	/* Allocating rx queue data structure */
+	rxq = rte_zmalloc_socket("ethdev RX queue", sizeof(struct nfp_net_rxq),
+				 RTE_CACHE_LINE_SIZE, socket_id);
+	if (rxq == NULL)
+		return (-ENOMEM);
+
+	/* Hw queues mapping based on firmware confifguration */
+	rxq->qidx = queue_idx;
+	rxq->fl_qcidx = queue_idx * hw->stride_rx;
+	rxq->rx_qcidx = rxq->fl_qcidx + (hw->stride_rx - 1);
+	rxq->qcp_fl = hw->rx_bar + NFP_QCP_QUEUE_OFF(rxq->fl_qcidx);
+	rxq->qcp_rx = hw->rx_bar + NFP_QCP_QUEUE_OFF(rxq->rx_qcidx);
+
+	/*
+	 * Tracking mbuf size for detecting a potential mbuf overflow due to
+	 * RX offset
+	 */
+	rxq->mem_pool = mp;
+	rxq->mbuf_size = rxq->mem_pool->elt_size;
+	rxq->mbuf_size -= (sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM);
+	hw->flbufsz = rxq->mbuf_size;
+
+	rxq->rx_count = nb_desc;
+	rxq->port_id = dev->data->port_id;
+	rxq->rx_free_thresh = rx_conf->rx_free_thresh;
+	rxq->crc_len = (uint8_t) ((dev->data->dev_conf.rxmode.hw_strip_crc) ? 0
+				  : ETHER_CRC_LEN);
+	rxq->drop_en = rx_conf->rx_drop_en;
+
+	/*
+	 * Allocate RX ring hardware descriptors. A memzone large enough to
+	 * handle the maximum ring size is allocated in order to allow for
+	 * resizing in later calls to the queue setup function.
+	 */
+	tz = ring_dma_zone_reserve(dev, "rx_ring", queue_idx,
+				   sizeof(struct nfp_net_rx_desc) *
+				   NFP_NET_MAX_RX_DESC, socket_id);
+
+	if (tz == NULL) {
+		RTE_LOG(ERR, PMD, "Error allocatig rx dma\n");
+		nfp_net_rx_queue_release(rxq);
+		return (-ENOMEM);
+	}
+
+	/* Saving physical and virtual addresses for the RX ring */
+	rxq->dma = (uint64_t)tz->phys_addr;
+	rxq->rxds = (struct nfp_net_rx_desc *)tz->addr;
+
+	/* mbuf pointers array for referencing mbufs linked to RX descriptors */
+	rxq->rxbufs = rte_zmalloc_socket("rxq->rxbufs",
+					 sizeof(*rxq->rxbufs) * nb_desc,
+					 RTE_CACHE_LINE_SIZE, socket_id);
+	if (rxq->rxbufs == NULL) {
+		nfp_net_rx_queue_release(rxq);
+		return (-ENOMEM);
+	}
+
+	PMD_RX_LOG(DEBUG, "rxbufs=%p hw_ring=%p dma_addr=0x%" PRIx64 "\n",
+		   rxq->rxbufs, rxq->rxds, (unsigned long int)rxq->dma);
+
+	nfp_net_reset_rx_queue(rxq);
+
+	dev->data->rx_queues[queue_idx] = rxq;
+	rxq->hw = hw;
+
+	/*
+	 * Telling the HW about the physical address of the RX ring and number
+	 * of descriptors in log2 format
+	 */
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
+	nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(queue_idx), log2(nb_desc));
+
+	return 0;
+}
+
+static int
+nfp_net_rx_fill_freelist(struct nfp_net_rxq *rxq)
+{
+	struct nfp_net_rx_buff *rxe = rxq->rxbufs;
+	uint64_t dma_addr;
+	unsigned i;
+
+	PMD_RX_LOG(DEBUG, "nfp_net_rx_fill_freelist for %u descriptors\n",
+		   rxq->rx_count);
+
+	for (i = 0; i < rxq->rx_count; i++) {
+		struct nfp_net_rx_desc *rxd;
+		struct rte_mbuf *mbuf = rte_pktmbuf_alloc(rxq->mem_pool);
+
+		if (mbuf == NULL) {
+			RTE_LOG(ERR, PMD, "RX mbuf alloc failed queue_id=%u\n",
+				(unsigned)rxq->qidx);
+			return (-ENOMEM);
+		}
+
+		dma_addr = rte_cpu_to_le_64(RTE_MBUF_DMA_ADDR_DEFAULT(mbuf));
+
+		rxd = &rxq->rxds[i];
+		rxd->fld.dd = 0;
+		rxd->fld.dma_addr_hi = (dma_addr >> 32) & 0xff;
+		rxd->fld.dma_addr_lo = dma_addr & 0xffffffff;
+		rxe[i].mbuf = mbuf;
+		PMD_RX_LOG(DEBUG, "[%d]: %" PRIx64 "\n", i, dma_addr);
+
+		rxq->wr_p++;
+	}
+
+	/* Make sure all writes are flushed before telling the hardware */
+	rte_wmb();
+
+	/* Not advertising the whole ring as the firmware gets confused if so */
+	PMD_RX_LOG(DEBUG, "Increment FL write pointer in %u\n",
+		   rxq->rx_count - 1);
+
+	nfp_qcp_ptr_add(rxq->qcp_fl, NFP_QCP_WRITE_PTR, rxq->rx_count - 1);
+
+	return 0;
+}
+
+static int
+nfp_net_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
+		       uint16_t nb_desc, unsigned int socket_id,
+		       const struct rte_eth_txconf *tx_conf)
+{
+	const struct rte_memzone *tz;
+	struct nfp_net_txq *txq;
+	uint16_t tx_free_thresh;
+	struct nfp_net_hw *hw;
+
+	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	/* Validating number of descriptors */
+	if (((nb_desc * sizeof(struct nfp_net_tx_desc)) % 128) != 0 ||
+	    (nb_desc > NFP_NET_MAX_TX_DESC) ||
+	    (nb_desc < NFP_NET_MIN_TX_DESC)) {
+		RTE_LOG(ERR, PMD, "Wrong nb_desc value\n");
+		return -EINVAL;
+	}
+
+	tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ?
+				    tx_conf->tx_free_thresh :
+				    DEFAULT_TX_FREE_THRESH);
+
+	if (tx_free_thresh > (nb_desc)) {
+		RTE_LOG(ERR, PMD,
+			"tx_free_thresh must be less than the number of TX "
+			"descriptors. (tx_free_thresh=%u port=%d "
+			"queue=%d)\n", (unsigned int)tx_free_thresh,
+			(int)dev->data->port_id, (int)queue_idx);
+		return -(EINVAL);
+	}
+
+	/*
+	 * Free memory prior to re-allocation if needed. This is the case after
+	 * calling nfp_net_stop
+	 */
+	if (dev->data->tx_queues[queue_idx]) {
+		PMD_TX_LOG(DEBUG, "Freeing memory prior to re-allocation %d\n",
+			   queue_idx);
+		nfp_net_tx_queue_release(dev->data->tx_queues[queue_idx]);
+		dev->data->tx_queues[queue_idx] = NULL;
+	}
+
+	/* Allocating tx queue data structure */
+	txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct nfp_net_txq),
+				 RTE_CACHE_LINE_SIZE, socket_id);
+	if (txq == NULL) {
+		RTE_LOG(ERR, PMD, "Error allocating tx dma\n");
+		return (-ENOMEM);
+	}
+
+	/*
+	 * Allocate TX ring hardware descriptors. A memzone large enough to
+	 * handle the maximum ring size is allocated in order to allow for
+	 * resizing in later calls to the queue setup function.
+	 */
+	tz = ring_dma_zone_reserve(dev, "tx_ring", queue_idx,
+				   sizeof(struct nfp_net_tx_desc) *
+				   NFP_NET_MAX_TX_DESC, socket_id);
+	if (tz == NULL) {
+		RTE_LOG(ERR, PMD, "Error allocating tx dma\n");
+		nfp_net_tx_queue_release(txq);
+		return (-ENOMEM);
+	}
+
+	txq->tx_count = nb_desc;
+	txq->tail = 0;
+	txq->tx_free_thresh = tx_free_thresh;
+	txq->tx_pthresh = tx_conf->tx_thresh.pthresh;
+	txq->tx_hthresh = tx_conf->tx_thresh.hthresh;
+	txq->tx_wthresh = tx_conf->tx_thresh.wthresh;
+
+	/* queue mapping based on firmware configuration */
+	txq->qidx = queue_idx;
+	txq->tx_qcidx = queue_idx * hw->stride_tx;
+	txq->qcp_q = hw->tx_bar + NFP_QCP_QUEUE_OFF(txq->tx_qcidx);
+
+	txq->port_id = dev->data->port_id;
+	txq->txq_flags = tx_conf->txq_flags;
+
+	/* Saving physical and virtual addresses for the TX ring */
+	txq->dma = (uint64_t)tz->phys_addr;
+	txq->txds = (struct nfp_net_tx_desc *)tz->addr;
+
+	/* mbuf pointers array for referencing mbufs linked to TX descriptors */
+	txq->txbufs = rte_zmalloc_socket("txq->txbufs",
+					 sizeof(*txq->txbufs) * nb_desc,
+					 RTE_CACHE_LINE_SIZE, socket_id);
+	if (txq->txbufs == NULL) {
+		nfp_net_tx_queue_release(txq);
+		return (-ENOMEM);
+	}
+	PMD_TX_LOG(DEBUG, "txbufs=%p hw_ring=%p dma_addr=0x%" PRIx64 "\n",
+		   txq->txbufs, txq->txds, (unsigned long int)txq->dma);
+
+	nfp_net_reset_tx_queue(txq);
+
+	dev->data->tx_queues[queue_idx] = txq;
+	txq->hw = hw;
+
+	/*
+	 * Telling the HW about the physical address of the TX ring and number
+	 * of descriptors in log2 format
+	 */
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
+	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), log2(nb_desc));
+
+	return 0;
+}
+
+/* nfp_net_tx_cksum - Set TX CSUM offload flags in TX descriptor */
+static inline void
+nfp_net_tx_cksum(struct nfp_net_txq *txq, struct nfp_net_tx_desc *txd,
+		 struct rte_mbuf *mb)
+{
+	uint16_t ol_flags;
+	struct nfp_net_hw *hw = txq->hw;
+
+	if (!(hw->cap & NFP_NET_CFG_CTRL_TXCSUM))
+		return;
+
+	ol_flags = mb->ol_flags;
+
+	/* IPv6 does not need checksum */
+	if (ol_flags & PKT_TX_IP_CKSUM)
+		txd->flags |= PCIE_DESC_TX_IP4_CSUM;
+
+	switch (ol_flags & PKT_TX_L4_MASK) {
+	case PKT_TX_UDP_CKSUM:
+		txd->flags |= PCIE_DESC_TX_UDP_CSUM;
+		break;
+	case PKT_TX_TCP_CKSUM:
+		txd->flags |= PCIE_DESC_TX_TCP_CSUM;
+		break;
+	}
+
+	txd->flags |= PCIE_DESC_TX_CSUM;
+}
+
+/* nfp_net_rx_cksum - set mbuf checksum flags based on RX descriptor flags */
+static inline void
+nfp_net_rx_cksum(struct nfp_net_rxq *rxq, struct nfp_net_rx_desc *rxd,
+		 struct rte_mbuf *mb)
+{
+	struct nfp_net_hw *hw = rxq->hw;
+
+	if (!(hw->ctrl & NFP_NET_CFG_CTRL_RXCSUM))
+		return;
+
+	/* If IPv4 and IP checksum error, fail */
+	if ((rxd->rxd.flags & PCIE_DESC_RX_IP4_CSUM) &&
+	    !(rxd->rxd.flags & PCIE_DESC_RX_IP4_CSUM_OK))
+		mb->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+
+	/* If neither UDP nor TCP return */
+	if (!(rxd->rxd.flags & PCIE_DESC_RX_TCP_CSUM) &&
+	    !(rxd->rxd.flags & PCIE_DESC_RX_UDP_CSUM))
+		return;
+
+	if ((rxd->rxd.flags & PCIE_DESC_RX_TCP_CSUM) &&
+	    !(rxd->rxd.flags & PCIE_DESC_RX_TCP_CSUM_OK))
+		mb->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+
+	if ((rxd->rxd.flags & PCIE_DESC_RX_UDP_CSUM) &&
+	    !(rxd->rxd.flags & PCIE_DESC_RX_UDP_CSUM_OK))
+		mb->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+}
+
+#define NFP_HASH_OFFSET      ((uint8_t *)mbuf->buf_addr + mbuf->data_off - 4)
+#define NFP_HASH_TYPE_OFFSET ((uint8_t *)mbuf->buf_addr + mbuf->data_off - 8)
+
+/*
+ * nfp_net_set_hash - Set mbuf hash data
+ *
+ * The RSS hash and hash-type are pre-pended to the packet data.
+ * Extract and decode it and set the mbuf fields.
+ */
+static inline void
+nfp_net_set_hash(struct nfp_net_rxq *rxq, struct nfp_net_rx_desc *rxd,
+		 struct rte_mbuf *mbuf)
+{
+	uint32_t hash;
+	uint32_t hash_type;
+	struct nfp_net_hw *hw = rxq->hw;
+
+	if (!(hw->ctrl & NFP_NET_CFG_CTRL_RSS))
+		return;
+
+	if (!(rxd->rxd.flags & PCIE_DESC_RX_RSS))
+		return;
+
+	hash = rte_be_to_cpu_32(*(uint32_t *)NFP_HASH_OFFSET);
+	hash_type = rte_be_to_cpu_32(*(uint32_t *)NFP_HASH_TYPE_OFFSET);
+
+	/*
+	 * hash type is sharing the same word with input port info
+	 * 31-8: input port
+	 * 7:0: hash type
+	 */
+	hash_type &= 0xff;
+	mbuf->hash.rss = hash;
+	mbuf->ol_flags |= PKT_RX_RSS_HASH;
+
+	switch (hash_type) {
+	case NFP_NET_RSS_IPV4:
+		mbuf->packet_type |= RTE_PTYPE_INNER_L3_IPV4;
+		break;
+	case NFP_NET_RSS_IPV6:
+		mbuf->packet_type |= RTE_PTYPE_INNER_L3_IPV6;
+		break;
+	case NFP_NET_RSS_IPV6_EX:
+		mbuf->packet_type |= RTE_PTYPE_INNER_L3_IPV6_EXT;
+		break;
+	default:
+		mbuf->packet_type |= RTE_PTYPE_INNER_L4_MASK;
+	}
+}
+
+/* nfp_net_check_port - Set mbuf in_port field */
+static void
+nfp_net_check_port(struct nfp_net_rx_desc *rxd, struct rte_mbuf *mbuf)
+{
+	uint32_t port;
+
+	if (!(rxd->rxd.flags & PCIE_DESC_RX_INGRESS_PORT)) {
+		mbuf->port = 0;
+		return;
+	}
+
+	port = rte_be_to_cpu_32(*(uint32_t *)((uint8_t *)mbuf->buf_addr +
+					      mbuf->data_off - 8));
+
+	/*
+	 * hash type is sharing the same word with input port info
+	 * 31-8: input port
+	 * 7:0: hash type
+	 */
+	port = (uint8_t)(port >> 8);
+	mbuf->port = port;
+}
+
+static inline void
+nfp_net_mbuf_alloc_failed(struct nfp_net_rxq *rxq)
+{
+	rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed++;
+}
+
+#define NFP_DESC_META_LEN(d) (d->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK)
+
+/*
+ * RX path design:
+ *
+ * There are some decissions to take:
+ * 1) How to check DD RX descriptors bit
+ * 2) How and when to allocate new mbufs
+ *
+ * Current implementation checks just one single DD bit each loop. As each
+ * descriptor is 8 bytes, it is likely a good idea to check descriptors in
+ * a single cache line instead. Tests with this change have not shown any
+ * performance improvement but it requires further investigation. For example,
+ * depending on which descriptor is next, the number of descriptors could be
+ * less than 8 for just checking those in the same cache line. This implies
+ * extra work which could be counterproductive by itself. Indeed, last firmware
+ * changes are just doing this: writing several descriptors with the DD bit
+ * for saving PCIe bandwidth and DMA operations from the NFP.
+ *
+ * Mbuf allocation is done when a new packet is received. Then the descriptor
+ * is automatically linked with the new mbuf and the old one is given to the
+ * user. The main drawback with this design is mbuf allocation is heavier than
+ * using bulk allocations allowed by DPDK with rte_mempool_get_bulk. From the
+ * cache point of view it does not seem allocating the mbuf early on as we are
+ * doing now have any benefit at all. Again, tests with this change have not
+ * shown any improvement. Also, rte_mempool_get_bulk returns all or nothing
+ * so looking at the implications of this type of allocation should be studied
+ * deeply
+ */
+
+static uint16_t
+nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
+{
+	struct nfp_net_rxq *rxq;
+	struct nfp_net_rx_desc *rxds;
+	struct nfp_net_rx_buff *rxb;
+	struct nfp_net_hw *hw;
+	struct rte_mbuf *mb;
+	struct rte_mbuf *new_mb;
+	int idx;
+	uint16_t nb_hold;
+	uint64_t dma_addr;
+	int avail;
+
+	rxq = rx_queue;
+	if (unlikely(rxq == NULL)) {
+		/*
+		 * DPDK just checks the queue is lower than max queues
+		 * enabled. But the queue needs to be configured
+		 */
+		RTE_LOG(ERR, PMD, "RX Bad queue\n");
+		return -EINVAL;
+	}
+
+	hw = rxq->hw;
+	avail = 0;
+	nb_hold = 0;
+
+	while (avail < nb_pkts) {
+		idx = rxq->rd_p % rxq->rx_count;
+
+		rxb = &rxq->rxbufs[idx];
+		if (unlikely(rxb == NULL)) {
+			RTE_LOG(ERR, PMD, "rxb does not exist!\n");
+			break;
+		}
+
+		/*
+		 * Memory barrier to ensure that we won't do other
+		 * reads before the DD bit.
+		 */
+		rte_rmb();
+
+		rxds = &rxq->rxds[idx];
+		if ((rxds->rxd.meta_len_dd & PCIE_DESC_RX_DD) == 0)
+			break;
+
+		/*
+		 * We got a packet. Let's alloc a new mbuff for refilling the
+		 * free descriptor ring as soon as possible
+		 */
+		new_mb = rte_pktmbuf_alloc(rxq->mem_pool);
+		if (unlikely(new_mb == NULL)) {
+			RTE_LOG(DEBUG, PMD, "RX mbuf alloc failed port_id=%u "
+				"queue_id=%u\n", (unsigned)rxq->port_id,
+				(unsigned)rxq->qidx);
+			nfp_net_mbuf_alloc_failed(rxq);
+			break;
+		}
+
+		nb_hold++;
+
+		/*
+		 * Grab the mbuff and refill the descriptor with the
+		 * previously allocated mbuff
+		 */
+		mb = rxb->mbuf;
+		rxb->mbuf = new_mb;
+
+		PMD_RX_LOG(DEBUG, "Packet len: %u, mbuf_size: %u\n",
+			   rxds->rxd.data_len, rxq->mbuf_size);
+
+		/* Size of this segment */
+		mb->data_len = rxds->rxd.data_len - NFP_DESC_META_LEN(rxds);
+		/* Size of the whole packet. We just support 1 segment */
+		mb->pkt_len = rxds->rxd.data_len - NFP_DESC_META_LEN(rxds);
+
+		if (unlikely((mb->data_len + hw->rx_offset) >
+			     rxq->mbuf_size)) {
+			/*
+			 * This should not happen and the user has the
+			 * responsibility of avoiding it. But we have
+			 * to give some info about the error
+			 */
+			RTE_LOG(ERR, PMD,
+				"mbuf overflow likely due to the RX offset.\n"
+				"\t\tYour mbuf size should have extra space for"
+				" RX offset=%u bytes.\n"
+				"\t\tCurrently you just have %u bytes available"
+				" but the received packet is %u bytes long",
+				hw->rx_offset,
+				rxq->mbuf_size - hw->rx_offset,
+				mb->data_len);
+			return -EINVAL;
+		}
+
+		/* Filling the received mbuff with packet info */
+		if (hw->rx_offset)
+			mb->data_off = RTE_PKTMBUF_HEADROOM + hw->rx_offset;
+		else
+			mb->data_off = RTE_PKTMBUF_HEADROOM +
+				       NFP_DESC_META_LEN(rxds);
+
+		/* No scatter mode supported */
+		mb->nb_segs = 1;
+		mb->next = NULL;
+
+		/* Checking the RSS flag */
+		nfp_net_set_hash(rxq, rxds, mb);
+
+		/* Checking the checksum flag */
+		nfp_net_rx_cksum(rxq, rxds, mb);
+
+		/* Checking the port flag */
+		nfp_net_check_port(rxds, mb);
+
+		if ((rxds->rxd.flags & PCIE_DESC_RX_VLAN) &&
+		    (hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN)) {
+			mb->vlan_tci = rte_cpu_to_le_32(rxds->rxd.vlan);
+			mb->ol_flags |= PKT_RX_VLAN_PKT;
+		}
+
+		/* Adding the mbuff to the mbuff array passed by the app */
+		rx_pkts[avail++] = mb;
+
+		/* Now resetting and updating the descriptor */
+		rxds->vals[0] = 0;
+		rxds->vals[1] = 0;
+		dma_addr = rte_cpu_to_le_64(RTE_MBUF_DMA_ADDR_DEFAULT(new_mb));
+		rxds->fld.dd = 0;
+		rxds->fld.dma_addr_hi = (dma_addr >> 32) & 0xff;
+		rxds->fld.dma_addr_lo = dma_addr & 0xffffffff;
+
+		rxq->rd_p++;
+	}
+
+	if (nb_hold == 0)
+		return nb_hold;
+
+	PMD_RX_LOG(DEBUG, "RX  port_id=%u queue_id=%u, %d packets received\n",
+		   (unsigned)rxq->port_id, (unsigned)rxq->qidx, nb_hold);
+
+	nb_hold += rxq->nb_rx_hold;
+
+	/*
+	 * FL descriptors needs to be written before incrementing the
+	 * FL queue WR pointer
+	 */
+	rte_wmb();
+	if (nb_hold > rxq->rx_free_thresh) {
+		PMD_RX_LOG(DEBUG, "port=%u queue=%u nb_hold=%u avail=%u\n",
+			   (unsigned)rxq->port_id, (unsigned)rxq->qidx,
+			   (unsigned)nb_hold, (unsigned)avail);
+		nfp_qcp_ptr_add(rxq->qcp_fl, NFP_QCP_WRITE_PTR, nb_hold);
+		nb_hold = 0;
+	}
+	rxq->nb_rx_hold = nb_hold;
+
+	return avail;
+}
+
+/*
+ * nfp_net_tx_free_bufs - Check for descriptors with a complete
+ * status
+ * @txq: TX queue to work with
+ * Returns number of descriptors freed
+ */
+int
+nfp_net_tx_free_bufs(struct nfp_net_txq *txq)
+{
+	uint32_t qcp_rd_p;
+	int todo;
+
+	PMD_TX_LOG(DEBUG, "queue %u. Check for descriptor with a complete"
+		   " status\n", txq->qidx);
+
+	/* Work out how many packets have been sent */
+	qcp_rd_p = nfp_qcp_read(txq->qcp_q, NFP_QCP_READ_PTR);
+
+	if (qcp_rd_p == txq->qcp_rd_p) {
+		PMD_TX_LOG(DEBUG, "queue %u: It seems harrier is not sending "
+			   "packets (%u, %u)\n", txq->qidx,
+			   qcp_rd_p, txq->qcp_rd_p);
+		return 0;
+	}
+
+	if (qcp_rd_p > txq->qcp_rd_p)
+		todo = qcp_rd_p - txq->qcp_rd_p;
+	else
+		todo = qcp_rd_p + txq->tx_count - txq->qcp_rd_p;
+
+	PMD_TX_LOG(DEBUG, "qcp_rd_p %u, txq->qcp_rd_p: %u, qcp->rd_p: %u\n",
+		   qcp_rd_p, txq->qcp_rd_p, txq->rd_p);
+
+	if (todo == 0)
+		return todo;
+
+	txq->qcp_rd_p += todo;
+	txq->qcp_rd_p %= txq->tx_count;
+	txq->rd_p += todo;
+
+	return todo;
+}
+
+/* Leaving always free descriptors for avoiding wrapping confusion */
+#define NFP_FREE_TX_DESC(t) (t->tx_count - (t->wr_p - t->rd_p) - 8)
+
+/*
+ * nfp_net_txq_full - Check if the TX queue free descriptors
+ * is below tx_free_threshold
+ *
+ * @txq: TX queue to check
+ *
+ * This function uses the host copy* of read/write pointers
+ */
+static inline
+int nfp_net_txq_full(struct nfp_net_txq *txq)
+{
+	return NFP_FREE_TX_DESC(txq) < txq->tx_free_thresh;
+}
+
+static uint16_t
+nfp_net_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
+{
+	struct nfp_net_txq *txq;
+	struct nfp_net_hw *hw;
+	struct nfp_net_tx_desc *txds;
+	struct rte_mbuf *pkt;
+	uint64_t dma_addr;
+	int pkt_size, dma_size;
+	uint16_t free_descs, issued_descs;
+	struct rte_mbuf **lmbuf;
+	int i;
+
+	txq = tx_queue;
+	hw = txq->hw;
+	txds = &txq->txds[txq->tail];
+
+	PMD_TX_LOG(DEBUG, "working for queue %u at pos %d and %u packets\n",
+		   txq->qidx, txq->tail, nb_pkts);
+
+	if ((NFP_FREE_TX_DESC(txq) < nb_pkts) || (nfp_net_txq_full(txq)))
+		nfp_net_tx_free_bufs(txq);
+
+	free_descs = (uint16_t)NFP_FREE_TX_DESC(txq);
+	if (unlikely(free_descs == 0))
+		return 0;
+
+	pkt = *tx_pkts;
+
+	i = 0;
+	issued_descs = 0;
+	PMD_TX_LOG(DEBUG, "queue: %u. Sending %u packets\n",
+		   txq->qidx, nb_pkts);
+	/* Sending packets */
+	while ((i < nb_pkts) && free_descs) {
+		/* Grabbing the mbuf linked to the current descriptor */
+		lmbuf = &txq->txbufs[txq->tail].mbuf;
+		/* Warming the cache for releasing the mbuf later on */
+		RTE_MBUF_PREFETCH_TO_FREE(*lmbuf);
+
+		pkt = *(tx_pkts + i);
+
+		if (unlikely((pkt->nb_segs > 1) &&
+			     !(hw->cap & NFP_NET_CFG_CTRL_GATHER))) {
+			PMD_INIT_LOG(INFO, "NFP_NET_CFG_CTRL_GATHER not set\n");
+			rte_panic("Multisegment packet unsupported\n");
+		}
+
+		/* Checking if we have enough descriptors */
+		if (unlikely(pkt->nb_segs > free_descs))
+			goto xmit_end;
+
+		/*
+		 * Checksum and VLAN flags just in the first descriptor for a
+		 * multisegment packet
+		 */
+		nfp_net_tx_cksum(txq, txds, pkt);
+
+		if ((pkt->ol_flags & PKT_TX_VLAN_PKT) &&
+		    (hw->cap & NFP_NET_CFG_CTRL_TXVLAN)) {
+			txds->flags |= PCIE_DESC_TX_VLAN;
+			txds->vlan = pkt->vlan_tci;
+		}
+
+		if (pkt->ol_flags & PKT_TX_TCP_SEG)
+			rte_panic("TSO is not supported\n");
+
+		/*
+		 * mbuf data_len is the data in one segment and pkt_len data
+		 * in the whole packet. When the packet is just one segment,
+		 * then data_len = pkt_len
+		 */
+		pkt_size = pkt->pkt_len;
+
+		while (pkt_size) {
+			/* Releasing mbuf which was prefetched above */
+			if (*lmbuf)
+				rte_pktmbuf_free_seg(*lmbuf);
+
+			dma_size = pkt->data_len;
+			dma_addr = RTE_MBUF_DATA_DMA_ADDR(pkt);
+			PMD_TX_LOG(DEBUG, "Working with mbuf at dma address:"
+				   "%" PRIx64 "\n", dma_addr);
+
+			/* Filling descriptors fields */
+			txds->dma_len = dma_size;
+			txds->data_len = pkt->pkt_len;
+			txds->dma_addr_hi = (dma_addr >> 32) & 0xff;
+			txds->dma_addr_lo = (dma_addr & 0xffffffff);
+			ASSERT(free_descs > 0);
+			free_descs--;
+
+			/*
+			 * Linking mbuf with descriptor for being released
+			 * next time descriptor is used
+			 */
+			*lmbuf = pkt;
+
+			txq->wr_p++;
+			txq->tail++;
+			if (unlikely(txq->tail == txq->tx_count)) /* wrapping?*/
+				txq->tail = 0;
+
+			pkt_size -= dma_size;
+			if (!pkt_size) {
+				/* End of packet */
+				txds->offset_eop |= PCIE_DESC_TX_EOP;
+			} else {
+				txds->offset_eop &= PCIE_DESC_TX_OFFSET_MASK;
+				pkt = pkt->next;
+			}
+			/* Referencing next free TX descriptor */
+			txds = &txq->txds[txq->tail];
+			issued_descs++;
+		}
+		i++;
+	}
+
+xmit_end:
+	/* Increment write pointers. Force memory write before we let HW know */
+	rte_wmb();
+	nfp_qcp_ptr_add(txq->qcp_q, NFP_QCP_WRITE_PTR, issued_descs);
+
+	return i;
 }

 /* Initialise and register driver with DPDK Application */
@@ -521,6 +1507,11 @@
 	.dev_start		= nfp_net_start,
 	.dev_stop		= nfp_net_stop,
 	.dev_close		= nfp_net_close,
+	.rx_queue_setup		= nfp_net_rx_queue_setup,
+	.rx_queue_release	= nfp_net_rx_queue_release,
+	.rx_queue_count		= nfp_net_rx_queue_count,
+	.tx_queue_setup		= nfp_net_tx_queue_setup,
+	.tx_queue_release	= nfp_net_tx_queue_release,
 };

 static int
@@ -538,6 +1529,8 @@
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);

 	eth_dev->dev_ops = &nfp_net_eth_dev_ops;
+	eth_dev->rx_pkt_burst = &nfp_net_recv_pkts;
+	eth_dev->tx_pkt_burst = &nfp_net_xmit_pkts;

 	/* For secondary processes, the primary has done all the work */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)


usb: renesas_usbhs: convert to devm_xxx()

Signed-off-by: Kuninori Morimoto <a3b51ccb87d18302c1692defcfbf83319d1737eb@renesas.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/usb/renesas_usbhs/common.c
+++ drivers/usb/renesas_usbhs/common.c
@@ -432,17 +432,16 @@
 	}

 	/* usb private data */
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv) {
 		dev_err(&pdev->dev, "Could not allocate priv\n");
 		return -ENOMEM;
 	}

-	priv->base = ioremap_nocache(res->start, resource_size(res));
+	priv->base = devm_request_and_ioremap(&pdev->dev, res);
 	if (!priv->base) {
 		dev_err(&pdev->dev, "ioremap error.\n");
-		ret = -ENOMEM;
-		goto probe_end_kfree;
+		return -ENOMEM;
 	}

 	/*
@@ -485,7 +484,7 @@
 	/* call pipe and module init */
 	ret = usbhs_pipe_probe(priv);
 	if (ret < 0)
-		goto probe_end_iounmap;
+		return ret;

 	ret = usbhs_fifo_probe(priv);
 	if (ret < 0)
@@ -546,10 +545,6 @@
 	usbhs_fifo_remove(priv);
 probe_end_pipe_exit:
 	usbhs_pipe_remove(priv);
-probe_end_iounmap:
-	iounmap(priv->base);
-probe_end_kfree:
-	kfree(priv);

 	dev_info(&pdev->dev, "probe failed\n");

@@ -576,8 +571,6 @@
 	usbhs_mod_remove(priv);
 	usbhs_fifo_remove(priv);
 	usbhs_pipe_remove(priv);
-	iounmap(priv->base);
-	kfree(priv);

 	return 0;
 }


net: cdc_ncm: factor out one-time device initialization

Split the parts of setup dealing with device initialization from
parts just setting defaults for attributes which might be
changed after initialization.

Some commands of the device initialization are only allowed when
the data interface is in its disabled altsetting, so we must
separate them out of we are to allow rerunning parts of setup.

Signed-off-by: Bjørn Mork <8a2957e0063f2abf61bd145b6236a74a3708ac54@mork.no>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/usb/cdc_ncm.c
+++ drivers/net/usb/cdc_ncm.c
@@ -120,19 +120,51 @@
 	ctx->tx_max = val;
 }

-static int cdc_ncm_setup(struct usbnet *dev)
+/* helpers for NCM and MBIM differences */
+static u8 cdc_ncm_flags(struct usbnet *dev)
 {
 	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
-	u32 val;
-	u8 flags;
-	u8 iface_no;
+
+	if (cdc_ncm_comm_intf_is_mbim(dev->intf->cur_altsetting) && ctx->mbim_desc)
+		return ctx->mbim_desc->bmNetworkCapabilities;
+	if (ctx->func_desc)
+		return ctx->func_desc->bmNetworkCapabilities;
+	return 0;
+}
+
+static int cdc_ncm_eth_hlen(struct usbnet *dev)
+{
+	if (cdc_ncm_comm_intf_is_mbim(dev->intf->cur_altsetting))
+		return 0;
+	return ETH_HLEN;
+}
+
+static u32 cdc_ncm_min_dgram_size(struct usbnet *dev)
+{
+	if (cdc_ncm_comm_intf_is_mbim(dev->intf->cur_altsetting))
+		return CDC_MBIM_MIN_DATAGRAM_SIZE;
+	return CDC_NCM_MIN_DATAGRAM_SIZE;
+}
+
+static u32 cdc_ncm_max_dgram_size(struct usbnet *dev)
+{
+	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+
+	if (cdc_ncm_comm_intf_is_mbim(dev->intf->cur_altsetting) && ctx->mbim_desc)
+		return le16_to_cpu(ctx->mbim_desc->wMaxSegmentSize);
+	if (ctx->ether_desc)
+		return le16_to_cpu(ctx->ether_desc->wMaxSegmentSize);
+	return CDC_NCM_MAX_DATAGRAM_SIZE;
+}
+
+/* initial one-time device setup.  MUST be called with the data interface
+ * in altsetting 0
+ */
+static int cdc_ncm_init(struct usbnet *dev)
+{
+	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+	u8 iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
 	int err;
-	int eth_hlen;
-	u16 mbim_mtu;
-	u16 ntb_fmt_supported;
-	__le16 max_datagram_size;
-
-	iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;

 	err = usbnet_read_cmd(dev, USB_CDC_GET_NTB_PARAMETERS,
 			      USB_TYPE_CLASS | USB_DIR_IN
@@ -144,7 +176,35 @@
 		return err; /* GET_NTB_PARAMETERS is required */
 	}

-	/* read correct set of parameters according to device mode */
+	/* set CRC Mode */
+	if (cdc_ncm_flags(dev) & USB_CDC_NCM_NCAP_CRC_MODE) {
+		dev_dbg(&dev->intf->dev, "Setting CRC mode off\n");
+		err = usbnet_write_cmd(dev, USB_CDC_SET_CRC_MODE,
+				       USB_TYPE_CLASS | USB_DIR_OUT
+				       | USB_RECIP_INTERFACE,
+				       USB_CDC_NCM_CRC_NOT_APPENDED,
+				       iface_no, NULL, 0);
+		if (err < 0)
+			dev_err(&dev->intf->dev, "SET_CRC_MODE failed\n");
+	}
+
+	/* set NTB format, if both formats are supported.
+	 *
+	 * "The host shall only send this command while the NCM Data
+	 *  Interface is in alternate setting 0."
+	 */
+	if (le16_to_cpu(ctx->ncm_parm.bmNtbFormatsSupported) & USB_CDC_NCM_NTH32_SIGN) {
+		dev_dbg(&dev->intf->dev, "Setting NTB format to 16-bit\n");
+		err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT,
+				       USB_TYPE_CLASS | USB_DIR_OUT
+				       | USB_RECIP_INTERFACE,
+				       USB_CDC_NCM_NTB16_FORMAT,
+				       iface_no, NULL, 0);
+		if (err < 0)
+			dev_err(&dev->intf->dev, "SET_NTB_FORMAT failed\n");
+	}
+
+	/* set initial device values */
 	ctx->rx_max = le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize);
 	ctx->tx_max = le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize);
 	ctx->tx_remainder = le16_to_cpu(ctx->ncm_parm.wNdpOutPayloadRemainder);
@@ -152,43 +212,73 @@
 	ctx->tx_ndp_modulus = le16_to_cpu(ctx->ncm_parm.wNdpOutAlignment);
 	/* devices prior to NCM Errata shall set this field to zero */
 	ctx->tx_max_datagrams = le16_to_cpu(ctx->ncm_parm.wNtbOutMaxDatagrams);
-	ntb_fmt_supported = le16_to_cpu(ctx->ncm_parm.bmNtbFormatsSupported);
-
-	/* there are some minor differences in NCM and MBIM defaults */
-	if (cdc_ncm_comm_intf_is_mbim(ctx->control->cur_altsetting)) {
-		if (!ctx->mbim_desc)
-			return -EINVAL;
-		eth_hlen = 0;
-		flags = ctx->mbim_desc->bmNetworkCapabilities;
-		ctx->max_datagram_size = le16_to_cpu(ctx->mbim_desc->wMaxSegmentSize);
-		if (ctx->max_datagram_size < CDC_MBIM_MIN_DATAGRAM_SIZE)
-			ctx->max_datagram_size = CDC_MBIM_MIN_DATAGRAM_SIZE;
-	} else {
-		if (!ctx->func_desc)
-			return -EINVAL;
-		eth_hlen = ETH_HLEN;
-		flags = ctx->func_desc->bmNetworkCapabilities;
-		ctx->max_datagram_size = le16_to_cpu(ctx->ether_desc->wMaxSegmentSize);
-		if (ctx->max_datagram_size < CDC_NCM_MIN_DATAGRAM_SIZE)
-			ctx->max_datagram_size = CDC_NCM_MIN_DATAGRAM_SIZE;
-	}
-
-	/* common absolute max for NCM and MBIM */
-	if (ctx->max_datagram_size > CDC_NCM_MAX_DATAGRAM_SIZE)
-		ctx->max_datagram_size = CDC_NCM_MAX_DATAGRAM_SIZE;

 	dev_dbg(&dev->intf->dev,
 		"dwNtbInMaxSize=%u dwNtbOutMaxSize=%u wNdpOutPayloadRemainder=%u wNdpOutDivisor=%u wNdpOutAlignment=%u wNtbOutMaxDatagrams=%u flags=0x%x\n",
 		ctx->rx_max, ctx->tx_max, ctx->tx_remainder, ctx->tx_modulus,
-		ctx->tx_ndp_modulus, ctx->tx_max_datagrams, flags);
+		ctx->tx_ndp_modulus, ctx->tx_max_datagrams, cdc_ncm_flags(dev));

 	/* max count of tx datagrams */
 	if ((ctx->tx_max_datagrams == 0) ||
 			(ctx->tx_max_datagrams > CDC_NCM_DPT_DATAGRAMS_MAX))
 		ctx->tx_max_datagrams = CDC_NCM_DPT_DATAGRAMS_MAX;

-	/* clamp rx_max and tx_max and inform device */
-	cdc_ncm_update_rxtx_max(dev, le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize), le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize));
+	return 0;
+}
+
+/* set a new max datagram size */
+static void cdc_ncm_set_dgram_size(struct usbnet *dev, int new_size)
+{
+	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+	u8 iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
+	__le16 max_datagram_size;
+	u16 mbim_mtu;
+	int err;
+
+	/* set default based on descriptors */
+	ctx->max_datagram_size = clamp_t(u32, new_size,
+					 cdc_ncm_min_dgram_size(dev),
+					 CDC_NCM_MAX_DATAGRAM_SIZE);
+
+	/* inform the device about the selected Max Datagram Size? */
+	if (!(cdc_ncm_flags(dev) & USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE))
+		goto out;
+
+	/* read current mtu value from device */
+	err = usbnet_read_cmd(dev, USB_CDC_GET_MAX_DATAGRAM_SIZE,
+			      USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE,
+			      0, iface_no, &max_datagram_size, 2);
+	if (err < 0) {
+		dev_dbg(&dev->intf->dev, "GET_MAX_DATAGRAM_SIZE failed\n");
+		goto out;
+	}
+
+	if (le16_to_cpu(max_datagram_size) == ctx->max_datagram_size)
+		goto out;
+
+	max_datagram_size = cpu_to_le16(ctx->max_datagram_size);
+	err = usbnet_write_cmd(dev, USB_CDC_SET_MAX_DATAGRAM_SIZE,
+			       USB_TYPE_CLASS | USB_DIR_OUT | USB_RECIP_INTERFACE,
+			       0, iface_no, &max_datagram_size, 2);
+	if (err < 0)
+		dev_dbg(&dev->intf->dev, "SET_MAX_DATAGRAM_SIZE failed\n");
+
+out:
+	/* set MTU to max supported by the device if necessary */
+	dev->net->mtu = min_t(int, dev->net->mtu, ctx->max_datagram_size - cdc_ncm_eth_hlen(dev));
+
+	/* do not exceed operater preferred MTU */
+	if (ctx->mbim_extended_desc) {
+		mbim_mtu = le16_to_cpu(ctx->mbim_extended_desc->wMTU);
+		if (mbim_mtu != 0 && mbim_mtu < dev->net->mtu)
+			dev->net->mtu = mbim_mtu;
+	}
+}
+
+static void cdc_ncm_fix_modulus(struct usbnet *dev)
+{
+	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+	u32 val;

 	/*
 	 * verify that the structure alignment is:
@@ -225,68 +315,26 @@
 	}

 	/* adjust TX-remainder according to NCM specification. */
-	ctx->tx_remainder = ((ctx->tx_remainder - eth_hlen) &
+	ctx->tx_remainder = ((ctx->tx_remainder - cdc_ncm_eth_hlen(dev)) &
 			     (ctx->tx_modulus - 1));
-
-	/* additional configuration */
-
-	/* set CRC Mode */
-	if (flags & USB_CDC_NCM_NCAP_CRC_MODE) {
-		err = usbnet_write_cmd(dev, USB_CDC_SET_CRC_MODE,
-				       USB_TYPE_CLASS | USB_DIR_OUT
-				       | USB_RECIP_INTERFACE,
-				       USB_CDC_NCM_CRC_NOT_APPENDED,
-				       iface_no, NULL, 0);
-		if (err < 0)
-			dev_dbg(&dev->intf->dev, "Setting CRC mode off failed\n");
-	}
-
-	/* set NTB format, if both formats are supported */
-	if (ntb_fmt_supported & USB_CDC_NCM_NTH32_SIGN) {
-		err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT,
-				       USB_TYPE_CLASS | USB_DIR_OUT
-				       | USB_RECIP_INTERFACE,
-				       USB_CDC_NCM_NTB16_FORMAT,
-				       iface_no, NULL, 0);
-		if (err < 0)
-			dev_dbg(&dev->intf->dev, "Setting NTB format to 16-bit failed\n");
-	}
-
-	/* inform the device about the selected Max Datagram Size */
-	if (!(flags & USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE))
-		goto out;
-
-	/* read current mtu value from device */
-	err = usbnet_read_cmd(dev, USB_CDC_GET_MAX_DATAGRAM_SIZE,
-			      USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE,
-			      0, iface_no, &max_datagram_size, 2);
-	if (err < 0) {
-		dev_dbg(&dev->intf->dev, "GET_MAX_DATAGRAM_SIZE failed\n");
-		goto out;
-	}
-
-	if (le16_to_cpu(max_datagram_size) == ctx->max_datagram_size)
-		goto out;
-
-	max_datagram_size = cpu_to_le16(ctx->max_datagram_size);
-	err = usbnet_write_cmd(dev, USB_CDC_SET_MAX_DATAGRAM_SIZE,
-			       USB_TYPE_CLASS | USB_DIR_OUT | USB_RECIP_INTERFACE,
-			       0, iface_no, &max_datagram_size, 2);
-	if (err < 0)
-		dev_dbg(&dev->intf->dev, "SET_MAX_DATAGRAM_SIZE failed\n");
-
-out:
-	/* set MTU to max supported by the device if necessary */
-	if (dev->net->mtu > ctx->max_datagram_size - eth_hlen)
-		dev->net->mtu = ctx->max_datagram_size - eth_hlen;
-
-	/* do not exceed operater preferred MTU */
-	if (ctx->mbim_extended_desc) {
-		mbim_mtu = le16_to_cpu(ctx->mbim_extended_desc->wMTU);
-		if (mbim_mtu != 0 && mbim_mtu < dev->net->mtu)
-			dev->net->mtu = mbim_mtu;
-	}
-
+}
+
+static int cdc_ncm_setup(struct usbnet *dev)
+{
+	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+
+	/* initialize basic device settings */
+	cdc_ncm_init(dev);
+
+	/* clamp rx_max and tx_max and inform device */
+	cdc_ncm_update_rxtx_max(dev, le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize),
+				le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize));
+
+	/* sanitize the modulus and remainder values */
+	cdc_ncm_fix_modulus(dev);
+
+	/* set max datagram size */
+	cdc_ncm_set_dgram_size(dev, cdc_ncm_max_dgram_size(dev));
 	return 0;
 }

@@ -450,9 +498,20 @@
 	}

 	/* check if we got everything */
-	if (!ctx->data || (!ctx->mbim_desc && !ctx->ether_desc)) {
-		dev_dbg(&intf->dev, "CDC descriptors missing\n");
+	if (!ctx->data) {
+		dev_dbg(&intf->dev, "CDC Union missing and no IAD found\n");
 		goto error;
+	}
+	if (cdc_ncm_comm_intf_is_mbim(intf->cur_altsetting)) {
+		if (!ctx->mbim_desc) {
+			dev_dbg(&intf->dev, "MBIM functional descriptor missing\n");
+			goto error;
+		}
+	} else {
+		if (!ctx->ether_desc || !ctx->func_desc) {
+			dev_dbg(&intf->dev, "NCM or ECM functional descriptors missing\n");
+			goto error;
+		}
 	}

 	/* claim data interface, if different from control */


OTHER: xmms2-et didn't quit if xmms2d wasn't running.

--- src/clients/et/xmms2-et.c
+++ src/clients/et/xmms2-et.c
@@ -256,6 +256,7 @@

 	if (!xmmsc_connect (conn, path)) {
 		printf ("Could not connect to xmms2d: %s\n", xmmsc_get_last_error (conn));
+		exit (1);
 	}

 	get_systemname ();


pinctrl: pinconf: remove checks on ops->pin_config_get

ops->pin_config_get() is only used in one specific path that will only be taken
for generic pinconf drivers (ops->is_generic == true) when dumping the pinconf
by using debugfs.

By removing the check in pinconf_check_ops(), let's stop pressuring people to
write a pin_config_get() function that will never be used and so will probably
never be tested.

Removing the check in pinconf_pins_show() allows driver to not implement
pin_config_get() but still get a dump of the pinconf in debugfs by implementing
pin_config_dbg_show().

Finally, not implementing pin_config_get() now results in returning -ENOTSUPP
instead of -EINVAL. While this doesn't have any real impact for now, this feels
more right.

Signed-off-by: Alexandre Belloni <a7228e626ecf0022ac91fc1cd8db88e71d0e5e0e@free-electrons.com>
Signed-off-by: Linus Walleij <9cd9d802d23c0ed5e224beabf4ae4a5c478746ef@linaro.org>


s390/cio: suppress 2nd path verification during resume

Do not trigger a path verification in the subchannel event
function during resume from hibernate. This will be started
by the pm_restore callback later.

Signed-off-by: Sebastian Ott <34be3ca399e9e73d80098c083a5b58614c3ca6da@linux.vnet.ibm.com>
Reviewed-by: Peter Oberparleiter <e296756d5edaffcdbc7b9904859492ff25d3fce5@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <52616596d8f5df0d597e85ab515377f92f939c68@de.ibm.com>

--- drivers/s390/cio/device.c
+++ drivers/s390/cio/device.c
@@ -1424,7 +1424,7 @@
 	}
 	if (device_is_disconnected(cdev))
 		return IO_SCH_REPROBE;
-	if (cdev->online)
+	if (cdev->online && !cdev->private->flags.resuming)
 		return IO_SCH_VERIFY;
 	if (cdev->private->state == DEV_STATE_NOT_OPER)
 		return IO_SCH_UNREG_ATTACH;
@@ -1469,12 +1469,6 @@
 		rc = 0;
 		goto out_unlock;
 	case IO_SCH_VERIFY:
-		if (cdev->private->flags.resuming == 1) {
-			if (cio_enable_subchannel(sch, (u32)(addr_t)sch)) {
-				ccw_device_set_notoper(cdev);
-				break;
-			}
-		}
 		/* Trigger path verification. */
 		io_subchannel_verify(sch);
 		rc = 0;


Update

Update

--- MersenneGen.c
+++ MersenneGen.c
@@ -1,13 +1,12 @@
 /*The following code generates Mersenne Prime numbers. The user inputs the number
 of Mersenne Primes to display.A Mersenne prime is of the form M = (2^N) - 1 where
-M is a prime number and N is a positive integer. Please note that due to the
+M is a prime number and N is a positive integer and is prime. Please note that due to the
 very nature of Mersenne Primes, which are exceedingly rare, this program is very
 slow for anything beyond very small input sizes.The program will also fail once it
-exceeds the precision of the standard integer format. Handling large numbers like
+exceeds the precision of the long integer format. Handling large numbers like
 Mersenne Primes require special methods not implemented here. The code can be made
 significantly more efficient using a few techniques. For example, the prime generator
 used here can be replaced by something like the Sieve of Eratosthenes or the Sieve of Atkin.
-The function isMersenne() can also be made faster by limiting the number of iterations.
 Finally, multithreading the program can result in much better performance.*/

 #include<stdio.h>
@@ -16,36 +15,34 @@
 #define TRUE 1
 #define FALSE 0

-int isPrime(int);
-int isMersenne(int);
+int isPrime(long int);
+int isMersenne(long int);

 int main()
 {
-	int num = 0, i = 0, count = 0;
+	unsigned long int num = 0, i = 2, count = 0;
 	printf("How many Mersenne Primes would you like to generate?\n");
-	scanf("%d", &num);
+	scanf("%lu", &num);
 	printf("The list is:\n");
-	while(1)
+	while(count != num)
 	{
 		if(isPrime(i) && isMersenne(i))
 		{
-			printf("%d\n", i);
+			printf("%lu\n", i);
 			count++;
 		}
-		if(count == num)
-			break;
 		i++;
 	}
 	return 0;
 } // end

-int isPrime(int n) // checks if a number is prime or not
+int isPrime(long int n) // checks if a number is prime or not
 {
-	int i = 0;
+	unsigned long int i = 0;
 	if(n <= 1 || n == 4)
 		return FALSE;
 	else
-		for(i = 2; i < n / 2; i++) // the square root of n is even more efficient here especially as n gets very large
+		for(i = 2; i < sqrt(n); i++)
 		{
 			if(n % i == 0)
 				return FALSE;
@@ -53,15 +50,15 @@
 	return TRUE;
 }

-int isMersenne(int m) // generates Mersenne Primes
+int isMersenne(long int m) // generates Mersenne Primes
 {
-	int var = 0, exp = 1;
-    while(exp < m) // the number of iterations here can be reduced using logarithms
+	unsigned long int var = 0, exp = 1;
+    while(exp <= log2(m + 1)) // M = (2^exp) - 1 => exp = log2(M + 1)
     {
-        var = (int)pow(2,exp);
-        if(var == (m + 1))
+        var = (unsigned long int)pow(2,exp);
+        if(var == (m + 1)) // follows from the definition of a Mersenne prime
 			return TRUE;
         exp++;
     }
     return FALSE;
-}
+}


ptnet: rx_poll: track rx_frame_errors

ptnet: rx_poll: track rx_frame_errors

--- LINUX/ptnet/ptnet.c
+++ LINUX/ptnet/ptnet.c
@@ -467,7 +467,10 @@
 			head = nm_next(head, lim);
 			if (unlikely(head == ring->tail)) {
 				RD(1, "Truncated RX packet, dropping");
-				break;
+				dev_kfree_skb_any(skb);
+				work_done ++;
+				pi->netdev->stats.rx_frame_errors ++;
+				goto out_of_slots;
 			}
 			slot = &ring->slot[head];
 			nmbuf = NMB(na, slot);
@@ -522,6 +525,7 @@
 							   vh->csum_offset))) {
 				dev_kfree_skb_any(skb);
 				work_done ++;
+				pi->netdev->stats.rx_frame_errors ++;
 				continue;
 			}

@@ -561,6 +565,7 @@
 		work_done ++;
 	}

+out_of_slots:
 	if (work_done < budget) {
 		/* Budget was not fully consumed, since we have no more
 		 * completed RX slots. We can enable notifications and


[S390] cio: remove unused local variable

Remove unused subchannel pointer in io_subchannel_recog_done.

Signed-off-by: Sebastian Ott <34be3ca399e9e73d80098c083a5b58614c3ca6da@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <52616596d8f5df0d597e85ab515377f92f939c68@de.ibm.com>

--- drivers/s390/cio/device.c
+++ drivers/s390/cio/device.c
@@ -1019,8 +1019,6 @@
 void
 io_subchannel_recog_done(struct ccw_device *cdev)
 {
-	struct subchannel *sch;
-
 	if (css_init_done == 0) {
 		cdev->private->flags.recog_done = 1;
 		return;
@@ -1031,7 +1029,6 @@
 		/* Remove device found not operational. */
 		if (!get_device(&cdev->dev))
 			break;
-		sch = to_subchannel(cdev->dev.parent);
 		PREPARE_WORK(&cdev->private->kick_work,
 			     ccw_device_call_sch_unregister);
 		queue_work(slow_path_wq, &cdev->private->kick_work);


veth: fix segfault at access to not created adapter rings

Remove peer in veth_netmap_krings_delete(vna) because without that
subsequent call of veth_netmap_krings_create(vna->peer) do not create rings.

--- LINUX/veth_netmap.h
+++ LINUX/veth_netmap.h
@@ -81,6 +81,7 @@
 		(struct netmap_veth_adapter *)na;
 	if (vna->peer_ref) {
 		vna->peer_ref = 0;
+		vna->peer->peer = NULL;
 		netmap_adapter_put(&vna->peer->up.up);
 	}
 }
@@ -211,6 +212,11 @@
 	}

 	netmap_pipe_krings_delete_both(na, peer_na);
+
+	netmap_adapter_put(&vna->peer->up.up);
+	vna->peer_ref = 0;
+	vna->peer->peer = NULL;
+	vna->peer = NULL;
 }

 static void


fix macOS/Linux build

fix macOS/Linux build

--- pkg2zip_sys.c
+++ pkg2zip_sys.c
@@ -199,7 +199,7 @@
     int fd = open(fname, O_RDONLY);
     if (fd < 0)
     {
-        error("ERROR: cannot open '%s' file\n", fname);
+        sys_error("ERROR: cannot open '%s' file\n", fname);
     }

     struct stat st;


[SCSI] scsi_debug: correct parameter default text

Correct the module info text for the default value of
"every_nth" to 0.

Signed-off-by: Randy Dunlap <e1d10faa7e2a0c027bf1ff1d20e7fd10154be7ea@oracle.com>
Acked-by: Douglas Gilbert <963f268e7a1bdc4d8e33d801712bc4fd67ee1d46@torque.net>
Signed-off-by: James Bottomley <407b36959ca09543ccda8f8e06721c791bc53435@SteelEye.com>

--- drivers/scsi/scsi_debug.c
+++ drivers/scsi/scsi_debug.c
@@ -2405,7 +2405,7 @@
 MODULE_PARM_DESC(delay, "# of jiffies to delay response(def=1)");
 MODULE_PARM_DESC(dev_size_mb, "size in MB of ram shared by devs(def=8)");
 MODULE_PARM_DESC(dsense, "use descriptor sense format(def=0 -> fixed)");
-MODULE_PARM_DESC(every_nth, "timeout every nth command(def=100)");
+MODULE_PARM_DESC(every_nth, "timeout every nth command(def=0)");
 MODULE_PARM_DESC(fake_rw, "fake reads/writes instead of copying (def=0)");
 MODULE_PARM_DESC(max_luns, "number of LUNs per target to simulate(def=1)");
 MODULE_PARM_DESC(no_lun_0, "no LU number 0 (def=0 -> have lun 0)");


Fix warning, fix memory leak

Fix warning, fix memory leak

--- src/checkout_conflicts.c
+++ src/checkout_conflicts.c
@@ -56,14 +56,16 @@

 int checkout_conflictdata_empty(const git_vector *conflicts, size_t idx)
 {
-	const checkout_conflictdata *conflict;
+	checkout_conflictdata *conflict;

 	if ((conflict = git_vector_get(conflicts, idx)) == NULL)
 		return -1;

-	return (conflict->ancestor == NULL &&
-		conflict->ours == NULL &&
-		conflict->theirs == NULL);
+	if (conflict->ancestor || conflict->ours || conflict->theirs)
+		return 0;
+
+	git__free(conflict);
+	return 1;
 }

 static int checkout_conflicts_load(checkout_data *data, git_vector *conflicts)
@@ -409,8 +411,7 @@
 	const char *hint_path = NULL, *suffix;
 	struct stat st;

-	assert (side == conflict->ours ||
-		side == conflict->theirs);
+	assert (side == conflict->ours || side == conflict->theirs);

 	git_buf_truncate(&data->path, data->workdir_len);
 	if (git_buf_puts(&data->path, side->path) < 0)
@@ -423,7 +424,7 @@
 		if (side == conflict->ours)
 			suffix = data->opts.our_label ? data->opts.our_label :
 				"ours";
-		else if (side == conflict->theirs)
+		else
 			suffix = data->opts.their_label ? data->opts.their_label :
 				"theirs";

@@ -456,7 +457,7 @@
 	git_merge_file_result *result)
 {
 	const char *our_label_raw, *their_label_raw, *suffix;
-	int i = 0, error = 0;
+	int error = 0;

 	if ((error = git_buf_joinpath(out, git_repository_workdir(data->repo), result->path)) < 0)
 		return error;


Bug 615290 - Fails to build with Heimdal Kerberos

--- camel/camel-sasl-gssapi.c
+++ camel/camel-sasl-gssapi.c
@@ -31,7 +31,11 @@
 #include <string.h>
 #include <sys/socket.h>
 #include <sys/types.h>
+#ifdef HAVE_HEIMDAL_KRB5
+#include <krb5.h>
+#else
 #include <krb5/krb5.h>
+#endif
 #ifdef HAVE_ET_COM_ERR_H
 #include <et/com_err.h>
 #else


exit if failed to write pid to file

exit if failed to write pid to file

--- pktgen_util.h
+++ pktgen_util.h
@@ -47,6 +47,11 @@
     umask(0);

     f = fopen("./pktgen.pid", "w+");
+
+    if (f == NULL) {
+        exit(EXIT_FAILURE);
+    }
+
     fprintf(f, "%d", getpid());
     fclose(f);


add src

add src

--- src/atf2png.c
+++ src/atf2png.c
@@ -0,0 +1,42 @@
+/*
+** ATF to PNG
+** Copyright Yinqiang Zhu 2015 (yinqiang.zhu<at>gmail.com)
+**
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+struct atf_s
+{
+    uint8_t sig;   // signture
+    uint32_t rer;  // reserved
+    uint8_t ver;   // version
+    uint32_t len;  // length
+    int8_t cmap;   // cubemap
+    int8_t fmt;    // format
+    uint8_t w;     // log2width
+    uint8_t h;     // log2height
+    uint8_t cnt;   // count
+};
+
+int
+main(int argc, char *argv[])
+{
+    FILE *fp;
+    struct atf_s
+
+    if (argc < 2)
+    {
+        fprintf(stderr, "Usage: atf2png path_to/file.atf\n");
+        return 1;
+    }
+    if ((fp = fopen(argv[1], "rb")) == NULL)
+    {
+        fprintf(stderr, "can not open file: %s\n", argv[1]);
+        return 1;
+    }
+
+
+}


set noblock for conn fd

set noblock for conn fd

--- socket_wrap.c
+++ socket_wrap.c
@@ -79,9 +79,13 @@
 {
 	int s;
 	struct sockaddr_in sa;
+	int ret;

 	if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0)
 		return -1;
+	ret = fd_set_noblock(s);
+	if (ret < 0)
+		debug_print("fd_set_noblock failed");

 	sa.sin_family = AF_INET;
 	sa.sin_port = htons(port);


[SERIAL] Rename pci_board to pciserial_board.

Signed-off-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>

--- drivers/serial/8250_pci.c
+++ drivers/serial/8250_pci.c
@@ -54,7 +54,7 @@
 /* Use the Base address register size to cap number of ports */
 #define FL_REGION_SZ_CAP	0x0100

-struct pci_board {
+struct pciserial_board {
 	unsigned int flags;
 	unsigned int num_ports;
 	unsigned int base_baud;
@@ -75,7 +75,7 @@
 	u32	subvendor;
 	u32	subdevice;
 	int	(*init)(struct pci_dev *dev);
-	int	(*setup)(struct pci_dev *dev, struct pci_board *board,
+	int	(*setup)(struct pci_dev *dev, struct pciserial_board *,
 			 struct uart_port *port, int idx);
 	void	(*exit)(struct pci_dev *dev);
 };
@@ -136,7 +136,7 @@
  * Not that ugly ;) -- HW
  */
 static int
-afavlab_setup(struct pci_dev *dev, struct pci_board *board,
+afavlab_setup(struct pci_dev *dev, struct pciserial_board *board,
 	      struct uart_port *port, int idx)
 {
 	unsigned int bar, offset = board->first_offset;
@@ -189,7 +189,7 @@
  * some serial ports are supposed to be hidden on certain models.
  */
 static int
-pci_hp_diva_setup(struct pci_dev *dev, struct pci_board *board,
+pci_hp_diva_setup(struct pci_dev *dev, struct pciserial_board *board,
 	      struct uart_port *port, int idx)
 {
 	unsigned int offset = board->first_offset;
@@ -307,7 +307,7 @@

 /* SBS Technologies Inc. PMC-OCTPRO and P-OCTAL cards */
 static int
-sbs_setup(struct pci_dev *dev, struct pci_board *board,
+sbs_setup(struct pci_dev *dev, struct pciserial_board *board,
 		struct uart_port *port, int idx)
 {
 	unsigned int bar, offset = board->first_offset;
@@ -523,7 +523,7 @@
  * Ugh, this is ugly as all hell --- TYT
  */
 static int
-pci_timedia_setup(struct pci_dev *dev, struct pci_board *board,
+pci_timedia_setup(struct pci_dev *dev, struct pciserial_board *board,
 		  struct uart_port *port, int idx)
 {
 	unsigned int bar = 0, offset = board->first_offset;
@@ -556,7 +556,8 @@
  * Some Titan cards are also a little weird
  */
 static int
-titan_400l_800l_setup(struct pci_dev *dev, struct pci_board *board,
+titan_400l_800l_setup(struct pci_dev *dev,
+		      struct pciserial_board *board,
 		      struct uart_port *port, int idx)
 {
 	unsigned int bar, offset = board->first_offset;
@@ -593,7 +594,7 @@
 }

 static int
-pci_default_setup(struct pci_dev *dev, struct pci_board *board,
+pci_default_setup(struct pci_dev *dev, struct pciserial_board *board,
 		  struct uart_port *port, int idx)
 {
 	unsigned int bar, offset = board->first_offset, maxnr;
@@ -990,7 +991,7 @@
 }

 static _INLINE_ int
-get_pci_irq(struct pci_dev *dev, struct pci_board *board, int idx)
+get_pci_irq(struct pci_dev *dev, struct pciserial_board *board, int idx)
 {
 	if (board->flags & FL_NOIRQ)
 		return 0;
@@ -1113,7 +1114,7 @@
  * see first lines of serial_in() and serial_out() in 8250.c
 */

-static struct pci_board pci_boards[] __devinitdata = {
+static struct pciserial_board pci_boards[] __devinitdata = {
 	[pbn_default] = {
 		.flags		= FL_BASE0,
 		.num_ports	= 1,
@@ -1565,7 +1566,7 @@
  * serial specs.  Returns 0 on success, 1 on failure.
  */
 static int __devinit
-serial_pci_guess_board(struct pci_dev *dev, struct pci_board *board)
+serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board)
 {
 	int num_iomem, num_port, first_port = -1, i;

@@ -1630,7 +1631,8 @@
 }

 static inline int
-serial_pci_matches(struct pci_board *board, struct pci_board *guessed)
+serial_pci_matches(struct pciserial_board *board,
+		   struct pciserial_board *guessed)
 {
 	return
 	    board->num_ports == guessed->num_ports &&
@@ -1648,7 +1650,7 @@
 pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
 {
 	struct serial_private *priv;
-	struct pci_board *board, tmp;
+	struct pciserial_board *board, tmp;
 	struct pci_serial_quirk *quirk;
 	int rc, nr_ports, i;

@@ -1669,7 +1671,7 @@
 		 * Use a copy of the pci_board entry for this;
 		 * avoid changing entries in the table.
 		 */
-		memcpy(&tmp, board, sizeof(struct pci_board));
+		memcpy(&tmp, board, sizeof(struct pciserial_board));
 		board = &tmp;

 		/*
@@ -1685,7 +1687,8 @@
 		 * detect this boards settings with our heuristic,
 		 * then we no longer need this entry.
 		 */
-		memcpy(&tmp, &pci_boards[pbn_default], sizeof(struct pci_board));
+		memcpy(&tmp, &pci_boards[pbn_default],
+		       sizeof(struct pciserial_board));
 		rc = serial_pci_guess_board(dev, &tmp);
 		if (rc == 0 && serial_pci_matches(board, &tmp))
 			moan_device("Redundant entry in serial pci_table.",


Documenting Output constructors.

Documenting Output constructors.

--- src/choreograph/Output.h
+++ src/choreograph/Output.h
@@ -65,11 +65,12 @@
     mValue( value )
   {}

-  // Assignment would modify the rhs, so we don't allow it.
-  // If we did allow it, would we want to take the Motion input with us?
+  //! Remove copy assignment since it has non-obvious semantics.
   Output<T>& operator= ( const Output<T> &rhs ) = delete;

   /*
+  // Assignment would modify the rhs, so we don't allow it.
+  // If we did allow it, would we want to take the Motion input with us?
   Output<T>& operator= ( const Output<T> &rhs ) {
     if( this != &rhs ) {
       mValue = rhs.mValue;
@@ -79,7 +80,7 @@
   }
   */

-  // Move assignment
+  //! Move assignment takes value and any input Motion.
   Output<T>& operator= ( Output<T> &&rhs ) {
     if( this != &rhs ) {
       mValue = rhs.mValue;
@@ -88,13 +89,12 @@
     return *this;
   }

+  //! Copy constructor takes value only.
   Output( const Output<T> &rhs ):
     mValue( rhs.mValue )
-  {
-    set( rhs );
-  }
+  {}

-  // Move constructor.
+  //! Move constructor takes value and any input Motion.
   Output( Output<T> &&rhs ):
     mValue( rhs.mValue )
   {


fix(storage): missing `set_multiple_options()` overload (#9196)

--- google/cloud/storage/internal/generic_request.h
+++ google/cloud/storage/internal/generic_request.h
@@ -254,6 +254,10 @@
   }

   template <typename... T>
+  Derived& set_multiple_options(google::cloud::Options const&&, T&&... tail) {
+    return set_multiple_options(std::forward<T>(tail)...);
+  }
+  template <typename... T>
   Derived& set_multiple_options(google::cloud::Options const&, T&&... tail) {
     return set_multiple_options(std::forward<T>(tail)...);
   }


Test for constant-time flag leakage in BN_CTX

This commit adds a simple unit test to make sure that the constant-time
flag does not "leak" among BN_CTX frames:

- test_ctx_consttime_flag() initializes (and later frees before
  returning) a BN_CTX object, then it calls in sequence
  test_ctx_set_ct_flag() and test_ctx_check_ct_flag() using the same
  BN_CTX object. The process is run twice, once with a "normal"
  BN_CTX_new() object, then with a BN_CTX_secure_new() one.
- test_ctx_set_ct_flag() starts a frame in the given BN_CTX and sets the
  BN_FLG_CONSTTIME flag on some of the BIGNUMs obtained from the frame
  before ending it.
- test_ctx_check_ct_flag() then starts a new frame and gets a number of
  BIGNUMs from it. In absence of leaks, none of the BIGNUMs in the new
  frame should have BN_FLG_CONSTTIME set.

In actual BN_CTX usage inside libcrypto the leak could happen at any
depth level in the BN_CTX stack, with varying results depending on the
patterns of sibling trees of nested function calls sharing the same
BN_CTX object, and the effect of unintended BN_FLG_CONSTTIME on the
called BN_* functions.

This simple unit test abstracts away this complexity and verifies that
the leak does not happen between two sibling functions sharing the same
BN_CTX object at the same level of nesting.

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

--- test/bntest.c
+++ test/bntest.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -123,7 +123,7 @@

     *out = (int)word;
     st = 1;
-err:
+ err:
     BN_free(ret);
     return st;
 }
@@ -137,7 +137,6 @@
     TEST_BN_eq(expected, actual);
     return 0;
 }
-

 /*
  * Return a "random" flag for if a BN should be negated.
@@ -150,7 +149,6 @@
     return sign[(neg++) % 8];
 }

-
 static int test_swap(void)
 {
     BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL;
@@ -166,7 +164,7 @@
     BN_bntest_rand(b, 1024, 1, 0);
     BN_copy(c, a);
     BN_copy(d, b);
-    top = BN_num_bits(a)/BN_BITS2;
+    top = BN_num_bits(a) / BN_BITS2;

     /* regular swap */
     BN_swap(a, b);
@@ -252,13 +250,12 @@
             goto err;
     }
     st = 1;
-err:
+ err:
     BN_free(a);
     BN_free(b);
     BN_free(c);
     return st;
 }
-

 static int test_div_recip(void)
 {
@@ -293,7 +290,7 @@
             goto err;
     }
     st = 1;
-err:
+ err:
     BN_free(a);
     BN_free(b);
     BN_free(c);
@@ -302,7 +299,6 @@
     BN_RECP_CTX_free(recp);
     return st;
 }
-

 static int test_mod(void)
 {
@@ -328,7 +324,7 @@
             goto err;
     }
     st = 1;
-err:
+ err:
     BN_free(a);
     BN_free(b);
     BN_free(c);
@@ -573,7 +569,7 @@

     st = 1;

-err:
+ err:
     BN_MONT_CTX_free(mont);
     BN_free(a);
     BN_free(p);
@@ -1141,7 +1137,7 @@
     }
     st = 1;

-err:
+ err:
     BN_free(a);
     BN_free(b);
     BN_free(sum);
@@ -1190,7 +1186,7 @@
         goto err;

     st = 1;
-err:
+ err:
     BN_free(a);
     BN_free(lshift1);
     BN_free(zero);
@@ -1219,7 +1215,7 @@
         goto err;

     st = 1;
-err:
+ err:
     BN_free(a);
     BN_free(lshift);
     BN_free(ret);
@@ -1249,7 +1245,7 @@
     }
     st = 1;

-err:
+ err:
     BN_free(a);
     BN_free(rshift);
     BN_free(ret);
@@ -1306,7 +1302,7 @@
 #endif

     st = 1;
-err:
+ err:
     BN_free(a);
     BN_free(square);
     BN_free(zero);
@@ -1343,7 +1339,7 @@
         goto err;

     st = 1;
-err:
+ err:
     BN_free(a);
     BN_free(b);
     BN_free(product);
@@ -1426,7 +1422,7 @@
     }

     st = 1;
-err:
+ err:
     BN_free(a);
     BN_free(b);
     BN_free(quotient);
@@ -1480,7 +1476,7 @@
     }

     st = 1;
-err:
+ err:
     BN_free(a);
     BN_free(b);
     BN_free(m);
@@ -1532,7 +1528,7 @@
         goto err;

     st = 1;
-err:
+ err:
     BN_free(a);
     BN_free(b);
     BN_free(c);
@@ -1560,7 +1556,7 @@
         goto err;

     st = 1;
-err:
+ err:
     BN_free(a);
     BN_free(e);
     BN_free(exp);
@@ -1591,7 +1587,7 @@
         goto err;

     st = 1;
-err:
+ err:
     BN_free(a);
     BN_free(p);
     BN_free(mod_sqrt);
@@ -1621,8 +1617,8 @@

     /* Test a random numbers at various byte lengths. */
     for (size_t bytes = 128 - 7; bytes <= 128; bytes++) {
-#define TOP_BIT_ON 0
-#define BOTTOM_BIT_NOTOUCH 0
+# define TOP_BIT_ON 0
+# define BOTTOM_BIT_NOTOUCH 0
         if (!TEST_true(BN_rand(n, bytes * 8, TOP_BIT_ON, BOTTOM_BIT_NOTOUCH)))
             goto err;
         if (!TEST_int_eq(BN_num_bytes(n),A) bytes
@@ -1653,7 +1649,7 @@
     }

     st = 1;
-err:
+ err:
     BN_free(n);
     return st;
 #else
@@ -1725,7 +1721,7 @@
         goto err;

     st = 1;
-err:
+ err:
     BN_free(bn);
     return st;
 }
@@ -1791,7 +1787,7 @@
         goto err;
     st = 1;

-err:
+ err:
     BN_free(bn);
     return st;
 }
@@ -1845,7 +1841,7 @@
         goto err;

     st = 1;
-err:
+ err:
     BN_free(bn);
     return st;
 }
@@ -1889,7 +1885,7 @@
     BN_free(bn2);

     st = 1;
-err:
+ err:
     BN_free(bn);
     return st;
 }
@@ -1915,7 +1911,7 @@
         goto err;

     st = 1;
-err:
+ err:
     BN_free(bn);
     return st;
 }
@@ -1979,7 +1975,7 @@
         goto err;
     st = 1;

-err:
+ err:
     BN_free(a);
     BN_free(b);
     BN_free(c);
@@ -2020,7 +2016,7 @@
     ERR_clear_error();

     if (!TEST_false(BN_mod_exp_mont_consttime(a, BN_value_one(), BN_value_one(),
-                                             zero, ctx, NULL)))
+                                              zero, ctx, NULL)))
         goto err;
     ERR_clear_error();

@@ -2042,12 +2038,12 @@
     ERR_clear_error();

     if (!TEST_false(BN_mod_exp_mont_consttime(a, BN_value_one(), BN_value_one(),
-                                  b, ctx, NULL)))
+                                              b, ctx, NULL)))
         goto err;
     ERR_clear_error();

     st = 1;
-err:
+ err:
     BN_free(a);
     BN_free(b);
     BN_free(zero);
@@ -2081,7 +2077,7 @@
         goto err;

     st = 1;
-err:
+ err:
     BN_free(zero);
     BN_free(a);
     BN_free(r);
@@ -2127,7 +2123,7 @@
     }

     ret = 1;
-err:
+ err:
     BN_free(r);
     BN_free(a);
     BN_free(p);
@@ -2148,7 +2144,7 @@
         goto err;

     st = 1;
-err:
+ err:
     BN_free(r);
     return st;
 }
@@ -2172,7 +2168,7 @@
     }

     ret = 1;
-err:
+ err:
     BN_free(r);
     return ret;
 }
@@ -2195,9 +2191,95 @@
     }

     ret = 1;
-err:
+ err:
     BN_free(r);
     return ret;
+}
+
+static int test_ctx_set_ct_flag(BN_CTX *c)
+{
+    int st = 0;
+    size_t i;
+    BIGNUM *b[15];
+
+    BN_CTX_start(c);
+    for (i = 0; i < OSSL_NELEM(b); i++) {
+        if (!TEST_ptr(b[i] = BN_CTX_get(c)))
+            goto err;
+        if (i % 2 == 1)
+            BN_set_flags(b[i], BN_FLG_CONSTTIME);
+    }
+
+    st = 1;
+ err:
+    BN_CTX_end(c);
+    return st;
+}
+
+static int test_ctx_check_ct_flag(BN_CTX *c)
+{
+    int st = 0;
+    size_t i;
+    BIGNUM *b[30];
+
+    BN_CTX_start(c);
+    for (i = 0; i < OSSL_NELEM(b); i++) {
+        if (!TEST_ptr(b[i] = BN_CTX_get(c)))
+            goto err;
+        if (!TEST_false(BN_get_flags(b[i], BN_FLG_CONSTTIME)))
+            goto err;
+    }
+
+    st = 1;
+ err:
+    BN_CTX_end(c);
+    return st;
+}
+
+static int test_ctx_consttime_flag(void)
+{
+    /*-
+     * The constant-time flag should not "leak" among BN_CTX frames:
+     *
+     * - test_ctx_set_ct_flag() starts a frame in the given BN_CTX and
+     *   sets the BN_FLG_CONSTTIME flag on some of the BIGNUMs obtained
+     *   from the frame before ending it.
+     * - test_ctx_check_ct_flag() then starts a new frame and gets a
+     *   number of BIGNUMs from it. In absence of leaks, none of the
+     *   BIGNUMs in the new frame should have BN_FLG_CONSTTIME set.
+     *
+     * In actual BN_CTX usage inside libcrypto the leak could happen at
+     * any depth level in the BN_CTX stack, with varying results
+     * depending on the patterns of sibling trees of nested function
+     * calls sharing the same BN_CTX object, and the effect of
+     * unintended BN_FLG_CONSTTIME on the called BN_* functions.
+     *
+     * This simple unit test abstracts away this complexity and verifies
+     * that the leak does not happen between two sibling functions
+     * sharing the same BN_CTX object at the same level of nesting.
+     *
+     */
+    BN_CTX *nctx = NULL;
+    BN_CTX *sctx = NULL;
+    size_t i = 0;
+    int st = 0;
+
+    if (!TEST_ptr(nctx = BN_CTX_new())
+            || !TEST_ptr(sctx = BN_CTX_secure_new()))
+        goto err;
+
+    for (i = 0; i < 2; i++) {
+        BN_CTX *c = i == 0 ? nctx : sctx;
+        if (!TEST_true(test_ctx_set_ct_flag(c))
+                || !TEST_true(test_ctx_check_ct_flag(c)))
+            goto err;
+    }
+
+    st = 1;
+ err:
+    BN_CTX_free(nctx);
+    BN_CTX_free(sctx);
+    return st;
 }

 static int file_test_run(STANZA *s)
@@ -2298,6 +2380,7 @@
         ADD_TEST(test_expmodone);
         ADD_TEST(test_smallprime);
         ADD_TEST(test_swap);
+        ADD_TEST(test_ctx_consttime_flag);
 #ifndef OPENSSL_NO_EC2M
         ADD_TEST(test_gf2m_add);
         ADD_TEST(test_gf2m_mod);


Add non-argument callback option to example.

--- example/options/options.c
+++ example/options/options.c
@@ -25,7 +25,13 @@
 static int
 callback (sc_options_t * opt, const char *theoptarg, void *data)
 {
-  SC_GLOBAL_INFOF ("%s with %s\n", (const char *) data, theoptarg);
+  if (theoptarg == NULL) {
+    SC_GLOBAL_INFOF ("%s without argument\n", (const char *) data);
+  }
+  else {
+    SC_GLOBAL_INFOF ("%s with %s\n", (const char *) data, theoptarg);
+  }
+
   return 0;
 }

@@ -55,8 +61,10 @@
   sc_options_add_int (opt, 'i', "integer1", &i1, 0, "Integer 1");
   sc_options_add_double (opt, 'd', "double", &d, 0., "Double");
   sc_options_add_string (opt, 's', "string", &s1, NULL, "String 1");
-  sc_options_add_callback (opt, 'c', "call", 1, callback, (void *) cd,
-                           "Callback");
+  sc_options_add_callback (opt, 'c', "call1", 1, callback, (void *) cd,
+                           "Callback 1");
+  sc_options_add_callback (opt, 'C', "call2", 0, callback, (void *) cd,
+                           "Callback 2");
   sc_options_add_string (opt, 't', NULL, &s2, NULL, "String 2");
   sc_options_add_inifile (opt, 'f', "inifile", ".ini file");
   sc_options_add_int (opt, '\0', "integer2", &i2, 7, "Integer 2");
@@ -76,8 +84,8 @@
     SC_GLOBAL_INFO ("Option parsing failed\n");
   }
   else {
+    SC_GLOBAL_INFO ("Option parsing successful\n");
     sc_options_print_summary (sc_package_id, SC_LP_INFO, opt);
-    SC_GLOBAL_INFO ("Option parsing successful\n");

     if (rank == 0) {
       retval = sc_options_save (sc_package_id, SC_LP_INFO, opt, "output.ini");


BUGFIX: #575701 - Message disappear from unread vfolder, when reply.

	* camel/camel-vee-summary.c: Handle the vfolder case and delay
	  folder changed event.

--- camel/camel-vee-summary.c
+++ camel/camel-vee-summary.c
@@ -145,11 +145,36 @@
 vee_info_set_user_flag(CamelMessageInfo *mi, const gchar *name, gboolean value)
 {
 	gint res = FALSE;
+	gboolean hacked_unread_folder = FALSE;
+	CamelVeeFolder *vf = (CamelVeeFolder *)mi->summary->folder;
+
+	if (camel_debug("vfolderexp"))
+		printf("Expression for vfolder '%s' is '%s'\n", mi->summary->folder->full_name, g_strescape(vf->expression, ""));
+
+	if (vf->priv->unread_vfolder == -1)
+		camel_vee_summary_load_check_unread_vfolder (CAMEL_VEE_SUMMARY (mi->summary));
+
+	if (vf->priv->unread_vfolder == 1)
+		hacked_unread_folder = TRUE;
+	else {
+		gchar *meta = camel_object_meta_get (mi->summary->folder, "vfolder:unread");
+		if (meta && strcmp (meta, "true") == 0)
+			hacked_unread_folder = TRUE;
+		g_free(meta);
+	}

 	if (mi->uid) {
 		CamelMessageInfo *rmi = camel_folder_summary_uid (((CamelVeeMessageInfo *)mi)->summary, mi->uid+8);
 		HANDLE_NULL_INFO(FALSE);
+
+		if (hacked_unread_folder)
+			camel_vee_folder_mask_event_folder_changed ((CamelVeeFolder *)mi->summary->folder, rmi->summary->folder);
+
 		res = camel_message_info_set_user_flag(rmi, name, value);
+
+		if (hacked_unread_folder)
+			camel_vee_folder_unmask_event_folder_changed ((CamelVeeFolder *)mi->summary->folder, rmi->summary->folder);
+
 		camel_message_info_free (rmi);
 	}


Blackfin SPI driver: use void __iomem * for regs_base

Signed-off-by: Bryan Wu <465f0e91e61585f5bc1128e7fe63296c33a56926@analog.com>
Cc: David Brownell <e543181633fc0fc2787945ef377537d9112d0c96@pacbell.net>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- drivers/spi/spi_bfin5xx.c
+++ drivers/spi/spi_bfin5xx.c
@@ -78,7 +78,7 @@
 	struct spi_master *master;

 	/* Regs base of SPI controller */
-	u32 regs_base;
+	void __iomem *regs_base;

 	/* BFIN hookup */
 	struct bfin5xx_spi_master *master_info;
@@ -1311,9 +1311,8 @@
 		goto out_error_get_res;
 	}

-	drv_data->regs_base = (u32) ioremap(res->start,
-					(res->end - res->start + 1));
-	if (!drv_data->regs_base) {
+	drv_data->regs_base = ioremap(res->start, (res->end - res->start + 1));
+	if (drv_data->regs_base == NULL) {
 		dev_err(dev, "Cannot map IO\n");
 		status = -ENXIO;
 		goto out_error_ioremap;
@@ -1352,7 +1351,7 @@
 		goto out_error;
 	}

-	dev_info(dev, "%s, Version %s, regs_base@0x%08x, dma channel@%d\n",
+	dev_info(dev, "%s, Version %s, regs_base@%p, dma channel@%d\n",
 		DRV_DESC, DRV_VERSION, drv_data->regs_base,
 		drv_data->dma_channel);
 	return status;


removed typo

removed typo

--- Jemuel/Alint.c
+++ Jemuel/Alint.c
@@ -81,7 +81,7 @@
 /**
  * Create a newly allocated ALInt whose value is i.
  */
-ALInt *
+ALInt * // unfinished
 int2ali (int i)
 {
   ALInt *new = (ALInt *) malloc(sizeof(ALInt));
@@ -92,7 +92,7 @@
   while (i >= 0)
   {
     ALIntDigit *new = (ALIntDigit *) malloc(sizeof(ALIntDigit));
-    new->val =
+    new->val =
   }
 }


test/xml: element index test

test/xml: element index test

Ensure elements can be referenced using the [index] path syntax.

Signed-off-by: David Disseldorp <589a549dc9f982d9f46aeeb82a09ab6d87ccf1d8@suse.de>

--- test/cm_xml.c
+++ test/cm_xml.c
@@ -68,7 +68,6 @@
  * - empty attributes
  * - multiple parse calls
  * - valgrind memory checks
- * - index based path checks
  */

 /*
@@ -611,6 +610,60 @@
 	free(val);
 }

+static void
+cm_xml_indexed(void **state)
+{
+	int ret;
+	struct xml_doc *xdoc;
+	char *val0 = NULL;
+	char *val1 = NULL;
+	char *val2 = NULL;
+	bool val0_present = false;
+	bool val1_present = false;
+	bool val2_present = false;
+
+	ret = exml_slurp(cm_xml_data_str_dup,
+			strlen(cm_xml_data_str_dup), &xdoc);
+	assert_int_equal(ret, 0);
+
+	ret = exml_str_want(xdoc,
+			   "/outer[0]/dup[0]/str",
+			   true,
+			   &val0,
+			   &val0_present);
+	assert_int_equal(ret, 0);
+
+	ret = exml_str_want(xdoc,
+			   "/outer/dup[1]/str",
+			   true,
+			   &val1,
+			   &val1_present);
+	assert_int_equal(ret, 0);
+
+	ret = exml_str_want(xdoc,
+			   "/outer/dup[2]/str",
+			   false,
+			   &val2,
+			   &val2_present);
+	assert_int_equal(ret, 0);
+
+	ret = exml_parse(xdoc);
+	assert_int_equal(ret, 0);
+
+	exml_free(xdoc);
+
+	assert_true(val0_present);
+	assert_true(val1_present);
+	assert_false(val2_present);
+	assert_non_null(val0);
+	assert_non_null(val1);
+	assert_null(val2);
+	assert_string_equal(val0, "val");
+	assert_string_equal(val1, "blah");
+	free(val0);
+	free(val1);
+}
+
 static const UnitTest cm_xml_tests[] = {
 	unit_test(cm_xml_str_basic),
 	unit_test(cm_xml_str_dup),
@@ -625,6 +678,7 @@
 	unit_test(cm_xml_attr_multi),
 	unit_test(cm_xml_xpath_relative),
 	unit_test(cm_xml_xpath_wildcard),
+	unit_test(cm_xml_indexed),
 };

 int


Staging: bcm: Remove typedef for _VENDOR_SECTION_INFO and call directly.

This patch removes typedef for _VENDOR_SECTION_INFO, and
changes the name of the struct to bcm_vendor_section_info.
In addition, any calls to typedefs VENDOR_SECTION_INFO, or
*PVENDOR_SECTION_INFO are changed to call the struct
directly.

Signed-off-by: Kevin McKinney <276c5fcfd53a88c2e5d996063a97c91e0154f2a8@gmail.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/staging/bcm/nvm.h
+++ drivers/staging/bcm/nvm.h
@@ -120,15 +120,15 @@
 	/* All expansions to the control data structure should add here */
 } FLASH2X_CS_INFO, *PFLASH2X_CS_INFO;

-typedef struct _VENDOR_SECTION_INFO {
+struct bcm_vendor_section_info {
 	u32 OffsetFromZeroForSectionStart;
 	u32 OffsetFromZeroForSectionEnd;
 	u32 AccessFlags;
 	u32 Reserved[16];
-} VENDOR_SECTION_INFO, *PVENDOR_SECTION_INFO;
+};

 struct bcm_flash2x_vendor_info {
-	VENDOR_SECTION_INFO VendorSection[TOTAL_SECTIONS];
+	struct bcm_vendor_section_info VendorSection[TOTAL_SECTIONS];
 	u32 Reserved[16];
 };


thunderbolt: Use NULL instead of 0 in nhi.c

'descriptors' is a pointer. Use NULL isntead of 0.

Signed-off-by: Sachin Kamat <1c3b1584a6008857f36c03c58f657c0fc16fc09e@samsung.com>
Acked-by: Andreas Noever <4e889c1f18b0ebb8c48dcacb749beb07ff15ae21@gmail.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/thunderbolt/nhi.c
+++ drivers/thunderbolt/nhi.c
@@ -416,7 +416,7 @@
 			  ring->size * sizeof(*ring->descriptors),
 			  ring->descriptors, ring->descriptors_dma);

-	ring->descriptors = 0;
+	ring->descriptors = NULL;
 	ring->descriptors_dma = 0;


hvc_xen: Remove unnecessary __GFP_ZERO from kzalloc

kzalloc already adds this __GFP_ZERO.

Signed-off-by: Joe Perches <16a9a54ddf4259952e3c118c763138e83693d7fd@perches.com>
Signed-off-by: Konrad Rzeszutek Wilk <da3a51b335cef0eb0e2c329c5ef6bcd6acef687a@oracle.com>


USB: autosuspend for usb printer driver

USB: autosuspend for usb printer driver

this implements autosuspend for usb printers. It compiles and is tested.

Signed-off-by: Oliver Neukum <bfee72d94d376f4e00f72b756466867d7f9eb24e@suse.de>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

--- drivers/usb/class/usblp.c
+++ drivers/usb/class/usblp.c
@@ -398,6 +398,9 @@
 	retval = 0;
 #endif

+	retval = usb_autopm_get_interface(intf);
+	if (retval < 0)
+		goto out;
 	usblp->used = 1;
 	file->private_data = usblp;

@@ -442,6 +445,7 @@
 	usblp->used = 0;
 	if (usblp->present) {
 		usblp_unlink_urbs(usblp);
+		usb_autopm_put_interface(usblp->intf);
 	} else 		/* finish cleanup from disconnect */
 		usblp_cleanup (usblp);
 	mutex_unlock (&usblp_mutex);
@@ -1203,14 +1207,9 @@
 {
 	struct usblp *usblp = usb_get_intfdata (intf);

-	/* this races against normal access and open */
-	mutex_lock (&usblp_mutex);
-	mutex_lock (&usblp->mut);
 	/* we take no more IO */
 	usblp->sleeping = 1;
 	usblp_unlink_urbs(usblp);
-	mutex_unlock (&usblp->mut);
-	mutex_unlock (&usblp_mutex);

 	return 0;
 }
@@ -1220,14 +1219,8 @@
 	struct usblp *usblp = usb_get_intfdata (intf);
 	int r;

-	mutex_lock (&usblp_mutex);
-	mutex_lock (&usblp->mut);
-
 	usblp->sleeping = 0;
 	r = handle_bidir (usblp);
-
-	mutex_unlock (&usblp->mut);
-	mutex_unlock (&usblp_mutex);

 	return r;
 }
@@ -1251,6 +1244,7 @@
 	.suspend =	usblp_suspend,
 	.resume =	usblp_resume,
 	.id_table =	usblp_ids,
+	.supports_autosuspend =	1,
 };

 static int __init usblp_init(void)


Define new hybrid parsing functions for request and response headers.

--- htp/htp.h
+++ htp/htp.h
@@ -1266,8 +1266,135 @@

      void htp_tx_set_user_data(htp_tx_t *tx, void *user_data);
     void *htp_tx_get_user_data(htp_tx_t *tx);
-
-// void htp_tx_register_response_body_data(htp_tx_t *tx, int (*callback_fn)(htp_tx_data_t *));
+
+/**
+ * Initialize hybrid parsing mode, change state to TRANSACTION_START,
+ * and invoke all registered callbacks.
+ *
+ * @param tx
+ */
+void htp_txh_state_transaction_start(htp_tx_t *tx);
+
+/**
+ * Set transaction request line.
+ *
+ * @param tx
+ * @param line
+ * @param alloc_strategy
+ */
+void htp_txh_set_req_line_c(htp_tx_t *tx, char *line, int alloc_strategy);
+
+/**
+ * Set transaction request method.
+ *
+ * @param tx
+ * @param method
+ * @param alloc_strategy
+ */
+void htp_txh_set_req_method_c(htp_tx_t *tx, char *method, int alloc_strategy);
+
+/**
+ * Set transaction request URI.
+ *
+ * @param tx
+ * @param uri
+ * @param alloc_strategy
+ */
+void htp_txh_set_req_uri_c(htp_tx_t *tx, char *uri, int alloc_strategy);
+
+/**
+ * Set transaction protocol string (e.g., "HTTP/1.0"). Do not invoke
+ * when HTTP/0.9 is used.
+ *
+ * @param tx
+ * @param protocol
+ * @param alloc_strategy
+ */
+void htp_txh_set_req_protocol_c(htp_tx_t *tx, char *protocol, int alloc_strategy);
+
+/**
+ * Change transaction state to REQUEST_LINE and invoke all
+ * registered callbacks.
+ *
+ * @param tx
+*/
+void htp_txh_state_request_line(htp_tx_t *tx);
+
+/**
+ * Set one request header. This function should be invoked once for
+ * each available header, and in the order in which headers were
+ * seen in the request.
+ *
+ * @param tx
+ * @param name
+ * @param value
+ * @param alloc_strategy
+ */
+void htp_txh_set_req_header_c(htp_tx_t *tx, char *name, char *value, int alloc_strategy);
+
+/**
+ * Change transaction state to REQUEST_HEADERS and invoke all
+ * registered callbacks.
+ *
+ * @param tx
+ */
+void htp_txh_state_request_headers(htp_tx_t *tx);
+
+// XXX trailers?
+
+/**
+ * Change transaction state to REQUEST and invoke all
+ * registered callbacks.
+ */
+void htp_txh_state_request(htp_tx_t *tx);
+
+/**
+ * Change transaction state to RESPONSE_START and invoke all
+ * registered callbacks.
+ */
+void htp_txh_state_response_start(htp_tx_t *tx);
+
+/**
+ * Set response line.
+ *
+ * @param tx
+ * @param line
+ * @param alloc_strategy
+ */
+void htp_tx_set_res_line_c(htp_tx_t *tx, char *line, int alloc_strategy);
+
+/**
+ * Change transaction state to RESPONSE_LINE and invoke all
+ * registered callbacks.
+ */
+void htp_txh_state_response_line(htp_tx_t *tx);
+
+/**
+ * Set one response header. This function should be invoked once for
+ * each available header, and in the order in which headers were
+ * seen in the response.
+ *
+ * @param tx
+ * @param name
+ * @param value
+ * @param alloc_strategy
+ */
+void htp_tx_set_res_header_c(htp_tx_t *tx, char *name, char *value, int alloc_strategy);
+
+/**
+ * Change transaction state to RESPONSE_HEADERS and invoke all
+ * registered callbacks.
+ */
+void htp_txh_state_response_headers(htp_tx_t *tx);
+
+// XXX how do we handle trailers?
+
+/**
+ * Change transaction state to RESPONSE and invoke all
+ * registered callbacks.
+ */
+void htp_txh_state_response(htp_tx_t *tx);
+

 // Parsing functions


data0data.c:   Do not test a magic number with =, use == instead :)

--- innobase/data/data0data.c
+++ innobase/data/data0data.c
@@ -114,8 +114,8 @@
 	ulint		i;

 	ut_ad(tuple1 && tuple2);
-	ut_ad(tuple1->magic_n = DATA_TUPLE_MAGIC_N);
-	ut_ad(tuple2->magic_n = DATA_TUPLE_MAGIC_N);
+	ut_ad(tuple1->magic_n == DATA_TUPLE_MAGIC_N);
+	ut_ad(tuple2->magic_n == DATA_TUPLE_MAGIC_N);
 	ut_ad(dtuple_check_typed(tuple1));
 	ut_ad(dtuple_check_typed(tuple2));

@@ -306,7 +306,7 @@
 	ulint	 	i;
 	ulint	 	j;

-	ut_a(tuple->magic_n = DATA_TUPLE_MAGIC_N);
+	ut_ad(tuple->magic_n == DATA_TUPLE_MAGIC_N);

 	n_fields = dtuple_get_n_fields(tuple);


usb: dwc2: gadget: move phy control calls out of pullup() method

This patch moves phy enable/disable calls from pullup() method to
udc_start/stop functions. This solves the issue related to limited caller
context for PHY functions, because they cannot be called from non-sleeping
context. This is also a preparation for using soft-disconnect feature of
udc controller in pullup() method.

Acked-by: Paul Zimmerman <e1f0d1b12051c0d55589ba9a6d7c10e383763d34@synopsys.com>
Signed-off-by: Marek Szyprowski <2a0259761cc3e88db42be5300c1579a67c77e65e@samsung.com>
Signed-off-by: Felipe Balbi <94dddeeef08b001e003cce128ddc162a4e2c6cd2@ti.com>


doveadm: Added "director ring status" command.

--- src/doveadm/doveadm-director.c
+++ src/doveadm/doveadm-director.c
@@ -547,6 +547,41 @@
 	director_disconnect(ctx);
 }

+static void cmd_director_ring_status(int argc, char *argv[])
+{
+	struct director_context *ctx;
+	const char *line, *const *args;
+	unsigned long l;
+
+	ctx = cmd_director_init(argc, argv, "a:", cmd_director_status);
+
+	doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE);
+	doveadm_print_header_simple("director ip");
+	doveadm_print_header_simple("port");
+	doveadm_print_header_simple("type");
+	doveadm_print_header_simple("last failed");
+
+	director_send(ctx, "DIRECTOR-LIST\n");
+	while ((line = i_stream_read_next_line(ctx->input)) != NULL) {
+		if (*line == '\0')
+			break;
+		T_BEGIN {
+			args = t_strsplit(line, "\t");
+			if (str_array_length(args) >= 4 &&
+			    str_to_ulong(args[3], &l) == 0) {
+				doveadm_print(args[0]);
+				doveadm_print(args[1]);
+				doveadm_print(args[2]);
+				if (l == 0)
+					doveadm_print("never");
+				else
+					doveadm_print(unixdate2str(l));
+			}
+		} T_END;
+	}
+	director_disconnect(ctx);
+}
+
 struct doveadm_cmd doveadm_cmd_director[] = {
 	{ cmd_director_status, "director status",
 	  "[-a <director socket path>] [<user>]" },
@@ -561,6 +596,8 @@
 	{ cmd_director_flush, "director flush",
 	  "[-a <director socket path>] <host>|all" },
 	{ cmd_director_dump, "director dump",
+	  "[-a <director socket path>]" },
+	{ cmd_director_ring_status, "director ring status",
 	  "[-a <director socket path>]" }
 };


builtin-grep: pass ignore case option to external grep

Don't just read the --ignore-case/-i option, pass the flag on to the
external grep program.

Signed-off-by: Robert Fitzsimons <313a8c2711273f8eaf8175c9680d4eac1a4b53aa@273k.net>
Signed-off-by: Junio C Hamano <dc50d1021234060e53ec42a77d526afa2fe07479@cox.net>

--- builtin-grep.c
+++ builtin-grep.c
@@ -459,6 +459,8 @@
 		push_arg("-n");
 	if (opt->regflags & REG_EXTENDED)
 		push_arg("-E");
+	if (opt->regflags & REG_ICASE)
+		push_arg("-i");
 	if (opt->word_regexp)
 		push_arg("-w");
 	if (opt->name_only)


Apply IPV6_V6ONLY only when socket is AF_INET6

--- httplib.h
+++ httplib.h
@@ -1198,20 +1198,18 @@
 #endif
 }

-template <typename T>
-inline ssize_t handle_EINTR(T fn) {
+template <typename T> inline ssize_t handle_EINTR(T fn) {
   ssize_t res = false;
   while (true) {
     res = fn();
-    if (res < 0 && errno == EINTR) {
-      continue;
-    }
+    if (res < 0 && errno == EINTR) { continue; }
     break;
   }
   return res;
 }

-#define HANDLE_EINTR(method, ...) (handle_EINTR([&]() { return method(__VA_ARGS__); }))
+#define HANDLE_EINTR(method, ...)                                              \
+  (handle_EINTR([&]() { return method(__VA_ARGS__); }))

 inline ssize_t select_read(socket_t sock, time_t sec, time_t usec) {
 #ifdef CPPHTTPLIB_USE_POLL
@@ -1231,7 +1229,8 @@
   tv.tv_sec = static_cast<long>(sec);
   tv.tv_usec = static_cast<decltype(tv.tv_usec)>(usec);

-  return HANDLE_EINTR(select, static_cast<int>(sock + 1), &fds, nullptr, nullptr, &tv);
+  return HANDLE_EINTR(select, static_cast<int>(sock + 1), &fds, nullptr,
+                      nullptr, &tv);
 #endif
 }

@@ -1253,7 +1252,8 @@
   tv.tv_sec = static_cast<long>(sec);
   tv.tv_usec = static_cast<decltype(tv.tv_usec)>(usec);

-  return HANDLE_EINTR(select, static_cast<int>(sock + 1), nullptr, &fds, nullptr, &tv);
+  return HANDLE_EINTR(select, static_cast<int>(sock + 1), nullptr, &fds,
+                      nullptr, &tv);
 #endif
 }

@@ -1270,7 +1270,7 @@
     int error = 0;
     socklen_t len = sizeof(error);
     auto res = getsockopt(sock, SOL_SOCKET, SO_ERROR,
-                      reinterpret_cast<char *>(&error), &len);
+                          reinterpret_cast<char *>(&error), &len);
     return res >= 0 && !error;
   }
   return false;
@@ -1286,7 +1286,8 @@
   tv.tv_sec = static_cast<long>(sec);
   tv.tv_usec = static_cast<decltype(tv.tv_usec)>(usec);

-  if (HANDLE_EINTR(select, static_cast<int>(sock + 1), &fdsr, &fdsw, &fdse, &tv) > 0 &&
+  if (HANDLE_EINTR(select, static_cast<int>(sock + 1), &fdsr, &fdsw, &fdse,
+                   &tv) > 0 &&
       (FD_ISSET(sock, &fdsr) || FD_ISSET(sock, &fdsw))) {
     int error = 0;
     socklen_t len = sizeof(error);
@@ -1470,14 +1471,16 @@
     setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char *>(&yes),
                sizeof(yes));

-    int no = 0;
-    setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast<char *>(&no),
-               sizeof(no));
-
 #ifdef SO_REUSEPORT
     setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, reinterpret_cast<char *>(&yes),
                sizeof(yes));
 #endif
+
+    if (rp->ai_family == AF_INET6) {
+      int no = 0;
+      setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast<char *>(&no),
+                 sizeof(no));
+    }

     // bind or connect
     if (fn(sock, *rp)) {
@@ -5127,4 +5130,3 @@
 } // namespace httplib

 #endif // CPPHTTPLIB_HTTPLIB_H
-


grep: use run-command's "dir" option for --open-files-in-pager

Git generally changes directory to the repository root on
startup.  When running "grep --open-files-in-pager" from a
subdirectory, we chdir back to the original directory before
running the pager, so that we can feed the relative
pathnames to the pager.

We currently do this chdir manually, but we can ask
run_command to do it for us. This is fewer lines of code,
and as a bonus, the chdir is limited to the child process,
which avoids any unexpected surprises for code running after
the pager (there isn't any currently, but this is
future-proofing).

Signed-off-by: Jeff King <696e3fbcf235d40b6ea1ebd61c87cbea79d444e7@peff.net>
Signed-off-by: Junio C Hamano <a6723cc3f76163bf7adb636a73ac3b0ceb3e6b9b@pobox.com>

--- builtin/grep.c
+++ builtin/grep.c
@@ -361,9 +361,7 @@
 		argv[i] = path_list->items[i].string;
 	argv[path_list->nr] = NULL;

-	if (prefix && chdir(prefix))
-		die(_("Failed to chdir: %s"), prefix);
-	status = run_command_v_opt(argv, RUN_USING_SHELL);
+	status = run_command_v_opt_cd_env(argv, RUN_USING_SHELL, prefix, NULL);
 	if (status)
 		exit(status);
 	free(argv);


More drafts for action queue

More drafts for action queue

--- DEM/Game/src/Game/ECS/Components/ActionQueueComponent.h
+++ DEM/Game/src/Game/ECS/Components/ActionQueueComponent.h
@@ -65,6 +65,10 @@
 	// Push new
 	// Push or update existing (top only? by handle? search here or always provide target handle)
 	// Remove by handle with all children. If root, requires terminal state, otherwise allows InProgress. Never allows New state?
+	// ClearChildren, possibly with setting state
+	//???state is set for popped action or for current action on the stack top?
+
+	// FindActive<Steer, Turn>(HAction From = {})

 	//=====================================================================


Removed automatic inclution of <openssl/ssl.h> with '__has_incude'

--- httplib.h
+++ httplib.h
@@ -57,14 +57,6 @@
 #include <string>
 #include <sys/stat.h>
 #include <assert.h>
-
-#ifdef __has_include
-#if __has_include(<openssl/ssl.h>)
-#ifndef CPPHTTPLIB_OPENSSL_SUPPORT
-#define CPPHTTPLIB_OPENSSL_SUPPORT
-#endif
-#endif
-#endif

 #ifdef CPPHTTPLIB_OPENSSL_SUPPORT
 #include <openssl/ssl.h>


free raw in error exit

free raw in error exit

git-svn-id: 40dd595c6684d839db675001a64203a1457e7319@14385 67ed7778-7388-44ab-90cf-0a291f65f57c

--- camlibs/stv0680/library.c
+++ camlibs/stv0680/library.c
@@ -493,8 +493,10 @@
 		break;
 	default:break;
 	}
-	if ((ret = stv0680_try_cmd(port, CMDID_STOP_VIDEO, 0, NULL, 0)!=GP_OK))
-		return ret;
+	if ((ret = stv0680_try_cmd(port, CMDID_STOP_VIDEO, 0, NULL, 0)!=GP_OK)) {
+		free (raw);
+		return ret;
+	}
 	sprintf(header, "P6\n# gPhoto2 stv0680 image\n%d %d\n255\n", w, h);
 	*data = malloc((*size * 3) + strlen(header));
 	strcpy(*data, header);


MIPS: dspr2: Added optimization for function VP8LSubtractGreenFromBlueAndRed

Change-Id: I683c73cceee4a40ca810deba15e54fbf7dbe8918

--- src/dsp/lossless_mips_dsp_r2.c
+++ src/dsp/lossless_mips_dsp_r2.c
@@ -145,6 +145,61 @@
   return temp1;
 }

+static void SubtractGreenFromBlueAndRed(uint32_t* argb_data,
+                                        int num_pixels) {
+  uint32_t temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
+  uint32_t* const p_loop1_end = argb_data + (num_pixels & ~3);
+  uint32_t* const p_loop2_end = p_loop1_end + (num_pixels & 3);
+  __asm__ volatile (
+    ".set       push                                          \n\t"
+    ".set       noreorder                                     \n\t"
+    "beq        %[argb_data],    %[p_loop1_end],     3f       \n\t"
+    " nop                                                     \n\t"
+  "0:                                                         \n\t"
+    "lw         %[temp0],        0(%[argb_data])              \n\t"
+    "lw         %[temp1],        4(%[argb_data])              \n\t"
+    "lw         %[temp2],        8(%[argb_data])              \n\t"
+    "lw         %[temp3],        12(%[argb_data])             \n\t"
+    "ext        %[temp4],        %[temp0],           8,    8  \n\t"
+    "ext        %[temp5],        %[temp1],           8,    8  \n\t"
+    "ext        %[temp6],        %[temp2],           8,    8  \n\t"
+    "ext        %[temp7],        %[temp3],           8,    8  \n\t"
+    "addiu      %[argb_data],    %[argb_data],       16       \n\t"
+    "replv.ph   %[temp4],        %[temp4]                     \n\t"
+    "replv.ph   %[temp5],        %[temp5]                     \n\t"
+    "replv.ph   %[temp6],        %[temp6]                     \n\t"
+    "replv.ph   %[temp7],        %[temp7]                     \n\t"
+    "subu.qb    %[temp0],        %[temp0],           %[temp4] \n\t"
+    "subu.qb    %[temp1],        %[temp1],           %[temp5] \n\t"
+    "subu.qb    %[temp2],        %[temp2],           %[temp6] \n\t"
+    "subu.qb    %[temp3],        %[temp3],           %[temp7] \n\t"
+    "sw         %[temp0],        -16(%[argb_data])            \n\t"
+    "sw         %[temp1],        -12(%[argb_data])            \n\t"
+    "sw         %[temp2],        -8(%[argb_data])             \n\t"
+    "bne        %[argb_data],    %[p_loop1_end],     0b       \n\t"
+    " sw        %[temp3],        -4(%[argb_data])             \n\t"
+  "3:                                                         \n\t"
+    "beq        %[argb_data],    %[p_loop2_end],     2f       \n\t"
+    " nop                                                     \n\t"
+  "1:                                                         \n\t"
+    "lw         %[temp0],        0(%[argb_data])              \n\t"
+    "addiu      %[argb_data],    %[argb_data],       4        \n\t"
+    "ext        %[temp4],        %[temp0],           8,    8  \n\t"
+    "replv.ph   %[temp4],        %[temp4]                     \n\t"
+    "subu.qb    %[temp0],        %[temp0],           %[temp4] \n\t"
+    "bne        %[argb_data],    %[p_loop2_end],     1b       \n\t"
+    " sw        %[temp0],        -4(%[argb_data])             \n\t"
+  "2:                                                         \n\t"
+    ".set       pop                                           \n\t"
+    : [argb_data]"+&r"(argb_data), [temp0]"=&r"(temp0),
+      [temp1]"=&r"(temp1), [temp2]"=&r"(temp2), [temp3]"=&r"(temp3),
+      [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [temp6]"=&r"(temp6),
+      [temp7]"=&r"(temp7)
+    : [p_loop1_end]"r"(p_loop1_end), [p_loop2_end]"r"(p_loop2_end)
+    : "memory"
+  );
+}
+
 static uint32_t Predictor12(uint32_t left, const uint32_t* const top) {
   return ClampedAddSubtractFull(left, top[0], top[-1]);
 }
@@ -165,6 +220,7 @@
   VP8LMapColor8b = MapAlpha;
   VP8LPredictors[12] = Predictor12;
   VP8LPredictors[13] = Predictor13;
+  VP8LSubtractGreenFromBlueAndRed = SubtractGreenFromBlueAndRed;
 #endif  // WEBP_USE_MIPS_DSP_R2
 }


finishing out re-typing setFilePath method. helpful to see where code can be shared.

--- DSP/extensions/SoundfileLib/TTSoundfileToSampleMatrix.h
+++ DSP/extensions/SoundfileLib/TTSoundfileToSampleMatrix.h
@@ -73,7 +73,29 @@
 		// copy the metadata to our local variable
 		memcpy(&mSoundFileInfo, soundfileInfo, sizeof(SF_INFO));

-		//// continue working here
+		// copy the new filepath to the our local variable
+		mFilePath = potentialFilePath;
+		// there is some playback specific stuff here in original
+		// should be abstracted out if we want a shared setFilePath()
+
+		// copy specific metadata pieces to separate TTSymbols
+		// in transfer from player, made this little pattern into a macro
+		#define SF_STRING_TO_TTSYMBOL(sf_info_piece, local_ttsymbol) \
+			textInfo = sf_get_string(soundfile, sf_info_piece); \
+			if (textInfo) local_ttsymbol = TT(textInfo); \
+			else local_ttsymbol = kTTSymEmpty;
+
+		// title
+		SF_STRING_TO_TTSYMBOL(SF_STR_TITLE, mTitle);
+		// artist
+		SF_STRING_TO_TTSYMBOL(SF_STR_ARTIST, mArtist);
+		// comment
+		SF_STRING_TO_TTSYMBOL(SF_STR_COMMENT, mAnnotation);
+		// date
+		SF_STRING_TO_TTSYMBOL(SF_STR_DATE, mDate);
+
+		// duration
+		mDuration = mSoundFileInfo.frames / mSoundFileInfo.samplerate;

 		return kTTErrNone;
 	} else { // if the filepath was invalid