netdev: bfin_mac: fix memory leak when freeing dma descriptors

The size of the desc array is not the size of the desc structure, so
when we try to free up things, we leak some parts.

Reported-by: Regis Dargent <ee83856ad5bc64f6e53034df32ad152a915d1825@edevice.com>
Signed-off-by: Sonic Zhang <c93d368f28096020dd845c4879a931e9d13ab23f@analog.com>
Signed-off-by: Mike Frysinger <8f3f75c74bd5184edcfa6534cab3c13a00a2f794@gentoo.org>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@conan.davemloft.net>

--- drivers/net/bfin_mac.c
+++ drivers/net/bfin_mac.c
@@ -52,13 +52,13 @@
 MODULE_ALIAS("platform:bfin_mac");

 #if defined(CONFIG_BFIN_MAC_USE_L1)
-# define bfin_mac_alloc(dma_handle, size)  l1_data_sram_zalloc(size)
-# define bfin_mac_free(dma_handle, ptr)    l1_data_sram_free(ptr)
+# define bfin_mac_alloc(dma_handle, size, num)  l1_data_sram_zalloc(size*num)
+# define bfin_mac_free(dma_handle, ptr, num)    l1_data_sram_free(ptr)
 #else
-# define bfin_mac_alloc(dma_handle, size) \
-	dma_alloc_coherent(NULL, size, dma_handle, GFP_KERNEL)
-# define bfin_mac_free(dma_handle, ptr) \
-	dma_free_coherent(NULL, sizeof(*ptr), ptr, dma_handle)
+# define bfin_mac_alloc(dma_handle, size, num) \
+	dma_alloc_coherent(NULL, size*num, dma_handle, GFP_KERNEL)
+# define bfin_mac_free(dma_handle, ptr, num) \
+	dma_free_coherent(NULL, sizeof(*ptr)*num, ptr, dma_handle)
 #endif

 #define PKT_BUF_SZ 1580
@@ -95,7 +95,7 @@
 				t = t->next;
 			}
 		}
-		bfin_mac_free(dma_handle, tx_desc);
+		bfin_mac_free(dma_handle, tx_desc, CONFIG_BFIN_TX_DESC_NUM);
 	}

 	if (rx_desc) {
@@ -109,7 +109,7 @@
 				r = r->next;
 			}
 		}
-		bfin_mac_free(dma_handle, rx_desc);
+		bfin_mac_free(dma_handle, rx_desc, CONFIG_BFIN_RX_DESC_NUM);
 	}
 }

@@ -126,13 +126,13 @@
 #endif

 	tx_desc = bfin_mac_alloc(&dma_handle,
-				sizeof(struct net_dma_desc_tx) *
+				sizeof(struct net_dma_desc_tx),
 				CONFIG_BFIN_TX_DESC_NUM);
 	if (tx_desc == NULL)
 		goto init_error;

 	rx_desc = bfin_mac_alloc(&dma_handle,
-				sizeof(struct net_dma_desc_rx) *
+				sizeof(struct net_dma_desc_rx),
 				CONFIG_BFIN_RX_DESC_NUM);
 	if (rx_desc == NULL)
 		goto init_error;


netdev: bfin_mac: clean up printk messages

Use netdev_* and pr_* helper funcs for output rather than printk.

Signed-off-by: Mike Frysinger <8f3f75c74bd5184edcfa6534cab3c13a00a2f794@gentoo.org>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/bfin_mac.c
+++ drivers/net/bfin_mac.c
@@ -7,6 +7,11 @@
  *
  * Licensed under the GPL-2 or later.
  */
+
+#define DRV_VERSION	"1.1"
+#define DRV_DESC	"Blackfin on-chip Ethernet MAC driver"
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

 #include <linux/init.h>
 #include <linux/module.h>
@@ -41,12 +46,7 @@

 #include "bfin_mac.h"

-#define DRV_NAME	"bfin_mac"
-#define DRV_VERSION	"1.1"
-#define DRV_AUTHOR	"Bryan Wu, Luke Yang"
-#define DRV_DESC	"Blackfin on-chip Ethernet MAC driver"
-
-MODULE_AUTHOR(DRV_AUTHOR);
+MODULE_AUTHOR("Bryan Wu, Luke Yang");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION(DRV_DESC);
 MODULE_ALIAS("platform:bfin_mac");
@@ -189,8 +189,7 @@
 		/* allocate a new skb for next time receive */
 		new_skb = dev_alloc_skb(PKT_BUF_SZ + NET_IP_ALIGN);
 		if (!new_skb) {
-			printk(KERN_NOTICE DRV_NAME
-			       ": init: low on mem - packet dropped\n");
+			pr_notice("init: low on mem - packet dropped\n");
 			goto init_error;
 		}
 		skb_reserve(new_skb, NET_IP_ALIGN);
@@ -240,7 +239,7 @@

 init_error:
 	desc_list_free();
-	printk(KERN_ERR DRV_NAME ": kmalloc failed\n");
+	pr_err("kmalloc failed\n");
 	return -ENOMEM;
 }

@@ -259,8 +258,7 @@
 	while ((bfin_read_EMAC_STAADD()) & STABUSY) {
 		udelay(1);
 		if (timeout_cnt-- < 0) {
-			printk(KERN_ERR DRV_NAME
-			": wait MDC/MDIO transaction to complete timeout\n");
+			pr_err("wait MDC/MDIO transaction to complete timeout\n");
 			return -ETIMEDOUT;
 		}
 	}
@@ -350,9 +348,9 @@
 					opmode &= ~RMII_10;
 					break;
 				default:
-					printk(KERN_WARNING
-						"%s: Ack!  Speed (%d) is not 10/100!\n",
-						DRV_NAME, phydev->speed);
+					netdev_warn(dev,
+						"Ack! Speed (%d) is not 10/100!\n",
+						phydev->speed);
 					break;
 				}
 				bfin_write_EMAC_OPMODE(opmode);
@@ -417,14 +415,13 @@

 	/* now we are supposed to have a proper phydev, to attach to... */
 	if (!phydev) {
-		printk(KERN_INFO "%s: Don't found any phy device at all\n",
-			dev->name);
+		netdev_err(dev, "no phy device found\n");
 		return -ENODEV;
 	}

 	if (phy_mode != PHY_INTERFACE_MODE_RMII &&
 		phy_mode != PHY_INTERFACE_MODE_MII) {
-		printk(KERN_INFO "%s: Invalid phy interface mode\n", dev->name);
+		netdev_err(dev, "invalid phy interface mode\n");
 		return -EINVAL;
 	}

@@ -432,7 +429,7 @@
 			0, phy_mode);

 	if (IS_ERR(phydev)) {
-		printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
+		netdev_err(dev, "could not attach PHY\n");
 		return PTR_ERR(phydev);
 	}

@@ -453,11 +450,10 @@
 	lp->old_duplex = -1;
 	lp->phydev = phydev;

-	printk(KERN_INFO "%s: attached PHY driver [%s] "
-	       "(mii_bus:phy_addr=%s, irq=%d, mdc_clk=%dHz(mdc_div=%d)"
-	       "@sclk=%dMHz)\n",
-	       DRV_NAME, phydev->drv->name, dev_name(&phydev->dev), phydev->irq,
-	       MDC_CLK, mdc_div, sclk/1000000);
+	pr_info("attached PHY driver [%s] "
+	        "(mii_bus:phy_addr=%s, irq=%d, mdc_clk=%dHz(mdc_div=%d)@sclk=%dMHz)\n",
+	        phydev->drv->name, dev_name(&phydev->dev), phydev->irq,
+	        MDC_CLK, mdc_div, sclk/1000000);

 	return 0;
 }
@@ -502,7 +498,7 @@
 static void bfin_mac_ethtool_getdrvinfo(struct net_device *dev,
 					struct ethtool_drvinfo *info)
 {
-	strcpy(info->driver, DRV_NAME);
+	strcpy(info->driver, KBUILD_MODNAME);
 	strcpy(info->version, DRV_VERSION);
 	strcpy(info->fw_version, "N/A");
 	strcpy(info->bus_info, dev_name(&dev->dev));
@@ -827,8 +823,7 @@
 		while ((!(bfin_read_EMAC_PTP_ISTAT() & TXTL)) && (--timeout_cnt))
 			udelay(1);
 		if (timeout_cnt == 0)
-			printk(KERN_ERR DRV_NAME
-					": fails to timestamp the TX packet\n");
+			netdev_err(netdev, "timestamp the TX packet failed\n");
 		else {
 			struct skb_shared_hwtstamps shhwtstamps;
 			u64 ns;
@@ -1083,8 +1078,7 @@
 	 * we which case we simply drop the packet
 	 */
 	if (current_rx_ptr->status.status_word & RX_ERROR_MASK) {
-		printk(KERN_NOTICE DRV_NAME
-		       ": rx: receive error - packet dropped\n");
+		netdev_notice(dev, "rx: receive error - packet dropped\n");
 		dev->stats.rx_dropped++;
 		goto out;
 	}
@@ -1094,8 +1088,7 @@

 	new_skb = dev_alloc_skb(PKT_BUF_SZ + NET_IP_ALIGN);
 	if (!new_skb) {
-		printk(KERN_NOTICE DRV_NAME
-		       ": rx: low on mem - packet dropped\n");
+		netdev_notice(dev, "rx: low on mem - packet dropped\n");
 		dev->stats.rx_dropped++;
 		goto out;
 	}
@@ -1213,7 +1206,7 @@
 	int ret;
 	u32 opmode;

-	pr_debug("%s: %s\n", DRV_NAME, __func__);
+	pr_debug("%s\n", __func__);

 	/* Set RX DMA */
 	bfin_write_DMA1_NEXT_DESC_PTR(&(rx_list_head->desc_a));
@@ -1323,7 +1316,7 @@
 	u32 sysctl;

 	if (dev->flags & IFF_PROMISC) {
-		printk(KERN_INFO "%s: set to promisc mode\n", dev->name);
+		netdev_info(dev, "set promisc mode\n");
 		sysctl = bfin_read_EMAC_OPMODE();
 		sysctl |= PR;
 		bfin_write_EMAC_OPMODE(sysctl);
@@ -1393,7 +1386,7 @@
 	 * address using ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
 	 */
 	if (!is_valid_ether_addr(dev->dev_addr)) {
-		printk(KERN_WARNING DRV_NAME ": no valid ethernet hw addr\n");
+		netdev_warn(dev, "no valid ethernet hw addr\n");
 		return -EINVAL;
 	}

@@ -1558,7 +1551,7 @@
 	bfin_mac_hwtstamp_init(ndev);

 	/* now, print out the card info, in a short format.. */
-	dev_info(&pdev->dev, "%s, Version %s\n", DRV_DESC, DRV_VERSION);
+	netdev_info(ndev, "%s, Version %s\n", DRV_DESC, DRV_VERSION);

 	return 0;

@@ -1650,7 +1643,7 @@
 	 * so set the GPIO pins to Ethernet mode
 	 */
 	pin_req = mii_bus_pd->mac_peripherals;
-	rc = peripheral_request_list(pin_req, DRV_NAME);
+	rc = peripheral_request_list(pin_req, KBUILD_MODNAME);
 	if (rc) {
 		dev_err(&pdev->dev, "Requesting peripherals failed!\n");
 		return rc;
@@ -1739,7 +1732,7 @@
 	.resume = bfin_mac_resume,
 	.suspend = bfin_mac_suspend,
 	.driver = {
-		.name = DRV_NAME,
+		.name = KBUILD_MODNAME,
 		.owner	= THIS_MODULE,
 	},
 };


Fix loop initial declarations

Fix loop initial declarations

--- ext/consistent_hash/consistent_hash.c
+++ ext/consistent_hash/consistent_hash.c
@@ -2,8 +2,9 @@

 VALUE consistent_hash(VALUE string) {
   uint32_t h = 0;
+  int i;

-  for (int i = 0; i < RSTRING_LEN(string); i++) {
+  for (i = 0; i < RSTRING_LEN(string); i++) {
     uint32_t c = RSTRING_PTR(string)[i];
     h = h * 31 + c;
   }


[PATCH] sundance: expand reset mask

[PATCH] sundance: expand reset mask

Expand the mask used when reseting the chip to include the GlobalReset
bit.  This fix comes from ICPlus and seems to be required for some
cards.

Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>
Signed-off-by: Jeff Garzik <15f615bf7d20c2937c7eb5aa759110fd6768848c@pobox.com>

--- drivers/net/sundance.c
+++ drivers/net/sundance.c
@@ -691,7 +691,7 @@
 	/* Reset the chip to erase previous misconfiguration. */
 	if (netif_msg_hw(np))
 		printk("ASIC Control is %x.\n", ioread32(ioaddr + ASICCtrl));
-	iowrite16(0x007f, ioaddr + ASICCtrl + 2);
+	iowrite16(0x00ff, ioaddr + ASICCtrl + 2);
 	if (netif_msg_hw(np))
 		printk("ASIC Control is now %x.\n", ioread32(ioaddr + ASICCtrl));


Added fast (but libgnomecanvas buggy) rendering.

When using polylines on the Gnome Canvas, you sometimes get the following
error message: 'attempt to put segment in horiz list twice'.  This is an
error in libgnomecanvas, because the polylines are valid.

The workaround in the gcw driver is to plot out the polyline as a series
of line segments.  The rendering in this case is slower.  This is not
usually a problem, but can become so for real-time displays (e.g., the
plplotcanvas_animation).  So, a new function,
plplot_canvas_use_fast_rendering(), has been added.

The default is to use the slower rendering, because this always works.
Fast rendering works most of the time, but sometimes produces error
messages and obviously wonky plots for 3D contour plots and vector plots.

A better solution will need to be found in collaboration with the gnome
team.

svn path=/trunk/; revision=6036

--- drivers/plplotcanvas.c
+++ drivers/plplotcanvas.c
@@ -90,6 +90,7 @@
   klass->set_size=plplot_canvas_set_size;
   klass->get_viewport=plplot_canvas_get_viewport;
   klass->use_text=plplot_canvas_use_text;
+  klass->use_fast_rendering=plplot_canvas_use_fast_rendering;
   klass->use_foreground_group=plplot_canvas_use_foreground_group;
   klass->use_background_group=plplot_canvas_use_background_group;
   klass->use_default_group=plplot_canvas_use_default_group;
@@ -123,6 +124,10 @@

   PlplotCanvas *canvas;
   canvas = PLPLOT_CANVAS(g_object_new(PLPLOT_TYPE_CANVAS,"aa",aa,NULL));
+
+  /* Turn off text handling if this isn't an antialiased canvas */
+  if(!aa) plplot_canvas_use_text(canvas,FALSE); /* Defaults true */
+
   return canvas;
 }

@@ -163,6 +168,13 @@
 {
   plsstrm(self->Nstream); /* Select stream before plplot call */
   gcw_use_text(GNOME_CANVAS(self),use_text);
+}
+
+void plplot_canvas_use_fast_rendering(PlplotCanvas* self,
+				      gboolean use_fast_rendering)
+{
+  plsstrm(self->Nstream); /* Select stream before plplot call */
+  gcw_use_fast_rendering(GNOME_CANVAS(self),use_fast_rendering);
 }

 void plplot_canvas_use_foreground_group(PlplotCanvas* self)


usb: dwc3: ep0: split the special cases on ep0_queue

We can return early from each if () branch
and split the special cases for clarity. While
at that also add a comment to the delayed_status
case.

Signed-off-by: Felipe Balbi <94dddeeef08b001e003cce128ddc162a4e2c6cd2@ti.com>

--- drivers/usb/dwc3/ep0.c
+++ drivers/usb/dwc3/ep0.c
@@ -155,13 +155,23 @@

 		dep->flags &= ~(DWC3_EP_PENDING_REQUEST |
 				DWC3_EP0_DIR_IN);
-	} else if (dwc->delayed_status) {
+
+		return 0;
+	}
+
+	/*
+	 * In case gadget driver asked us to delay the STATUS phase,
+	 * handle it here.
+	 */
+	if (dwc->delayed_status) {
 		dwc->delayed_status = false;

 		if (dwc->ep0state == EP0_STATUS_PHASE)
 			__dwc3_ep0_do_control_status(dwc, dwc->eps[1]);
 		else
 			dev_dbg(dwc->dev, "too early for delayed status\n");
+
+		return 0;
 	}

 	return 0;


Fix build for iOS simulator because it doesn't support NEON

--- Source/BufferCopy.c
+++ Source/BufferCopy.c
@@ -8,7 +8,10 @@

 #include "BufferCopy.h"
 #include <string.h>
+
+#ifdef __ARM_NEON
 #include <arm_neon.h>
+#endif

 void CopyBufferNV12(uint8_t * __restrict srcY, uint8_t * __restrict srcUV, size_t srcYRowBytes, size_t srcUVRowBytes,
                            uint8_t * __restrict dstY, uint8_t * __restrict dstUV, size_t dstYRowBytes, size_t dstUVRowBytes,
@@ -73,28 +76,7 @@
     }
 }

-#if 0
-// doesn't auto-vectorize at all
-uint32_t Luminance(uint8_t *Y, size_t YRowBytes, size_t width, size_t height)
-{
-    size_t i;
-    size_t j;
-    uint32_t luminance = 0;
-
-    for (i = 0; i < height; i++)
-    {
-        uint8_t *y = Y;
-#pragma clang loop vectorize(enable) interleave(enable)
-        for (j = 0; j < width; j++)
-        {
-            luminance += y++;
-        }
-        Y += YRowBytes;
-    }
-
-    return (luminance);
-}
-#endif
+#ifdef __ARM_NEON

 uint32_t Luminance(uint8_t *Y, size_t YRowBytes, size_t width, size_t height)
 {
@@ -134,3 +116,27 @@
     return (luminance/(width*height));
 }

+#else
+
+uint32_t Luminance(uint8_t *Y, size_t YRowBytes, size_t width, size_t height)
+{
+    size_t i;
+    size_t j;
+    uint32_t luminance = 0;
+
+    for (i = 0; i < height; i++)
+    {
+        uint8_t *y = Y;
+#pragma clang loop vectorize(enable) interleave(enable)
+        for (j = 0; j < width; j++)
+        {
+            luminance += y++;
+        }
+        Y += YRowBytes;
+    }
+
+    return (luminance);
+}
+#endif
+
+


Fix "Possible access violation when calling into CS_usrdr" as part of RFC6

The CS_usrdr() function free's the extern'ed pointer cs_CsKeyNames, cs_DtKeyNames, cs_ElKeyNames but does not sets them to NULL afterwards.
This results in an access violation when for example using the [CScsKeyNames()] function before (as this malloc's CScsKeyNames).

Fixed by setting all 3 pointers to NULL after calling CS_free.

git-svn-id: a2bff39a7848988ed2ca894f77eecdfa44a5cc3b@2317 4e78687f-474d-0410-85f9-8d5e500ac6b2

--- Source/CS_general.c
+++ Source/CS_general.c
@@ -211,8 +211,12 @@
 exit:
 	//now that a new directory has been setup, we've to cleanup all of our internal "definition" caches
 	CS_free(cs_CsKeyNames);
+	cs_CsKeyNames = NULL;
 	CS_free(cs_DtKeyNames);
+	cs_DtKeyNames = NULL;
 	CS_free(cs_ElKeyNames);
+	cs_ElKeyNames = NULL;
+
 	CSrlsCategories();

 	return 0;


gallium/radeon: always do the full store in store_value_to_array

Doing the write-back of the temporary vector in radeon_llvm_emit_store makes
no sense.

This also allows us to get rid of get_alloca_for_array.

Reviewed-by: Marek Olšák <8c7344a1abdb103e79ecfd488098373070c3c70e@amd.com>

--- src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
+++ src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
@@ -156,23 +156,6 @@
 	return range;
 }

-static LLVMValueRef get_alloca_for_array(struct lp_build_tgsi_context *bld_base,
-					 unsigned file,
-					 unsigned index,
-					 const struct tgsi_ind_register *reg)
-{
-	const struct radeon_llvm_array *array;
-
-	if (file != TGSI_FILE_TEMPORARY)
-		return NULL;
-
-	array = get_temp_array(bld_base, index, reg);
-	if (!array)
-		return NULL;
-
-	return array->alloca;
-}
-
 static LLVMValueRef
 emit_array_index(struct lp_build_tgsi_soa_context *bld,
 		 const struct tgsi_ind_register *reg,
@@ -306,7 +289,7 @@
 	}
 }

-static LLVMValueRef
+static void
 store_value_to_array(struct lp_build_tgsi_context *bld_base,
 		     LLVMValueRef value,
 		     unsigned file,
@@ -323,13 +306,36 @@
 	ptr = get_pointer_into_array(ctx, file, chan_index, reg_index, reg_indirect);
 	if (ptr) {
 		LLVMBuildStore(builder, value, ptr);
-		return NULL;
 	} else {
+		unsigned i, size;
 		struct tgsi_declaration_range range = get_array_range(bld_base, file, reg_index, reg_indirect);
 		LLVMValueRef index = emit_array_index(bld, reg_indirect, reg_index - range.First);
 		LLVMValueRef array =
 			emit_array_fetch(bld_base, file, TGSI_TYPE_FLOAT, range, chan_index);
-		return LLVMBuildInsertElement(builder, array, value, index, "");
+		LLVMValueRef temp_ptr;
+
+		array = LLVMBuildInsertElement(builder, array, value, index, "");
+
+		size = range.Last - range.First + 1;
+		for (i = 0; i < size; ++i) {
+			switch(file) {
+			case TGSI_FILE_OUTPUT:
+				temp_ptr = bld->outputs[i + range.First][chan_index];
+				break;
+
+			case TGSI_FILE_TEMPORARY:
+				if (range.First + i >= ctx->temps_count)
+					continue;
+				temp_ptr = ctx->temps[(i + range.First) * TGSI_NUM_CHANNELS + chan_index];
+				break;
+
+			default:
+				continue;
+			}
+			value = LLVMBuildExtractElement(builder, array,
+				lp_build_const_int32(gallivm, i), "");
+			LLVMBuildStore(builder, value, temp_ptr);
+		}
 	}
 }

@@ -644,37 +650,10 @@
 			value = bitcast(bld_base, TGSI_TYPE_FLOAT, value);

 		if (reg->Register.Indirect) {
-			struct tgsi_declaration_range range = get_array_range(bld_base,
-				reg->Register.File, reg->Register.Index, &reg->Indirect);
-
-        		unsigned i, size = range.Last - range.First + 1;
 			unsigned file = reg->Register.File;
 			unsigned reg_index = reg->Register.Index;
-			LLVMValueRef array = store_value_to_array(bld_base, value, file, chan_index,
-			                                          reg_index, &reg->Indirect);
-	                if (get_alloca_for_array(bld_base, file, reg_index, &reg->Indirect)) {
-				continue;
-			}
-        		for (i = 0; i < size; ++i) {
-				switch(reg->Register.File) {
-				case TGSI_FILE_OUTPUT:
-					temp_ptr = bld->outputs[i + range.First][chan_index];
-					break;
-
-				case TGSI_FILE_TEMPORARY:
-					if (range.First + i >= ctx->temps_count)
-						continue;
-					temp_ptr = ctx->temps[(i + range.First) * TGSI_NUM_CHANNELS + chan_index];
-					break;
-
-				default:
-					continue;
-				}
-				value = LLVMBuildExtractElement(builder, array,
-					lp_build_const_int32(gallivm, i), "");
-				LLVMBuildStore(builder, value, temp_ptr);
-			}
-
+			store_value_to_array(bld_base, value, file, chan_index,
+					     reg_index, &reg->Indirect);
 		} else {
 			switch(reg->Register.File) {
 			case TGSI_FILE_OUTPUT:


ws/vmware: Check DRM version also when bootstrapping in dri2 mode.

Signed-off-by: Thomas Hellstrom <a26490dfbee4be3d38287ad6448444504f58193c@vmware.com>

--- src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c
+++ src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c
@@ -85,6 +85,23 @@
    struct pipe_screen *screen;
    struct dri1_create_screen_arg *dri1;

+   if (!arg || arg->mode == DRM_CREATE_NORMAL) {
+      struct dri1_api_version drm_ver;
+      drmVersionPtr ver;
+
+      ver = drmGetVersion(fd);
+      if (ver == NULL)
+	 return NULL;
+
+      drm_ver.major = ver->version_major;
+      drm_ver.minor = ver->version_minor;
+
+      drmFreeVersion(ver);
+      if (!vmw_dri1_check_version(&drm_ver, &drm_required,
+				  &drm_compat, "vmwgfx drm driver"))
+	 return NULL;
+   }
+
    if (arg != NULL) {
       switch (arg->mode) {
       case DRM_CREATE_NORMAL:


Fix typo

Fix typo

--- Source/OCHamcrest.h
+++ Source/OCHamcrest.h
@@ -49,4 +49,4 @@
 #import <OCHamcrest/HCCollect.h>
 #import <OCHamcrest/HCRequireNonNilObject.h>
 #import <OCHamcrest/HCStringDescription.h>
-#import <OCHamcrest/HCWrapInMatcher.h.h>+#import <OCHamcrest/HCWrapInMatcher.h>


Remove redundant docs.

Remove redundant docs.

--- src/Doxygen.h
+++ src/Doxygen.h
@@ -75,33 +75,6 @@
  * - Peter Nelson
  * - Craig Gilchrist
  * - Atsushi Nagase
- *
- *
Nimbus' Background

- *
- * Nimbus has been built with much inspiration from the Three20 framework. That being said, there
- * are a number of fundamental problems with Three20 that Nimbus works very hard to avoid.
- * Among them:
- *
- * - Poor documentation.
- * - Spaghetti dependencies.
- * - Suffering from a "kitchen sink" complex.
- * - A complex build structure.
- * - An enormous number of difficult-to-solve bugs.
- * - Next-to-zero test coverage.
- *
- * For its weaknesses, Three20 does provide a good deal of value through its feature set. It is
- * used in over 100 apps in the app store by companies such as Facebook, LinkedIn, Posterous,
- * Meetup, and SCVNGR.
- *
- * Nimbus hopes to one day provide as much value as Three20 does on a feature-by-feature
- * comparison, but with the invaluable benefit of sublime documentation and test coverage.
- *
- *
Nimbus' Development Roadmap

- *
- * Most of the discussion revolving around Nimbus' roadmap is in the Github issue tracker. In
- * particular, check out the grab bag of tasks that are actively being worked on here:
- *
- * https://github.com/jverkoey/nimbus/issues?milestone=5&sort=created&direction=desc&state=open
  */

 /**


sfc: Remove unnecessary tests of efx->membase

These cleanup functions will never be called if the MMIO region could
not be mapped.

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

--- drivers/net/sfc/efx.c
+++ drivers/net/sfc/efx.c
@@ -2022,10 +2022,6 @@
  */
 static void efx_pci_remove_main(struct efx_nic *efx)
 {
-	/* Skip everything if we never obtained a valid membase */
-	if (!efx->membase)
-		return;
-
 	falcon_fini_interrupt(efx);
 	efx_fini_channels(efx);
 	efx_fini_port(efx);
@@ -2055,9 +2051,6 @@

 	/* Allow any queued efx_resets() to complete */
 	rtnl_unlock();
-
-	if (efx->membase == NULL)
-		goto out;

 	efx_unregister_netdev(efx);

@@ -2071,7 +2064,6 @@

 	efx_pci_remove_main(efx);

-out:
 	efx_fini_io(efx);
 	EFX_LOG(efx, "shutdown successful\n");


Pull queuing improvements. Still not quite there.

--- src/EFSPull.c
+++ src/EFSPull.c
@@ -5,7 +5,7 @@

 #define URI_MAX 1024
 #define READER_COUNT 4
-#define QUEUE_SIZE 10
+#define QUEUE_SIZE 8

 struct EFSPull {
 	int64_t pullID;
@@ -85,12 +85,12 @@
 		}

 		assertf(!pull->blocked_reader, "Reader already waiting");
-		if(pull->count + 2 >= QUEUE_SIZE) {
+		if(pull->count + 2 > QUEUE_SIZE) {
 			pull->blocked_reader = co_active();
 			co_switch(yield);
 			pull->blocked_reader = NULL;
 			if(pull->stop) continue;
-			assertf(pull->count < QUEUE_SIZE, "Reader didn't wait long enough");
+			assertf(pull->count + 2 <= QUEUE_SIZE, "Reader didn't wait long enough");
 			// We still might not be unblocked, but the writer did its job.
 		}
 		index_t pos = (pull->cur + pull->count) % QUEUE_SIZE;
@@ -116,7 +116,19 @@
 	for(;;) {
 		if(pull->stop) break;

-		if(!pull->count || !pull->filled[pull->cur]) {
+		// lock
+		EFSSubmissionRef queue[QUEUE_SIZE];
+		count_t count = 0;
+		for(index_t i = 0; i < pull->count; ++i) {
+			index_t const pos = (pull->cur + i) % QUEUE_SIZE;
+			if(!pull->filled[pos]) break;
+			queue[i] = pull->queue[pos];
+			pull->queue[pos] = NULL;
+			pull->filled[pos] = false;
+			count++;
+		}
+		if(0 == count) {
+			// unlock
 			pull->blocked_writer = co_active();
 			co_switch(yield);
 			pull->blocked_writer = NULL;
@@ -124,37 +136,32 @@
 			assertf(pull->filled[pull->cur], "Writer woke up early");
 			continue;
 		}
-
-		count_t written = 0;
+		pull->cur = (pull->cur + count) % QUEUE_SIZE;
+		pull->count -= count;
+		// unlock
+
+		if(pull->blocked_reader) async_wakeup(pull->blocked_reader);
+
 		for(;;) {
 			sqlite3 *db = EFSRepoDBConnect(EFSSessionGetRepo(pull->session));
 			EXEC(QUERY(db, "SAVEPOINT store"));
 			err_t err = 0;
 			index_t i;
-			for(i = 0; i < pull->count; ++i) {
-				index_t const pos = (pull->cur + i) % QUEUE_SIZE;
-				if(!pull->filled[pos]) break;
-				if(!pull->queue[pos]) continue; // Empty submissions enqueued for various reasons.
-				err = EFSSubmissionStore(pull->queue[pos], db);
+			for(i = 0; i < count; ++i) {
+				if(!queue[i]) continue; // Empty submissions enqueued for various reasons.
+				err = EFSSubmissionStore(queue[i], db);
 				if(err < 0) break;
 			}
-			written = i;
 			if(err < 0) EXEC(QUERY(db, "ROLLBACK TO store"));
 			EXEC(QUERY(db, "RELEASE store"));
 			EFSRepoDBClose(EFSSessionGetRepo(pull->session), &db);
 			if(err >= 0) break;
 			async_sleep(1000 * 5);
 		}
-		for(index_t i = 0; i < written; ++i) {
-			index_t const pos = (pull->cur + i) % QUEUE_SIZE;
-			EFSSubmissionFree(&pull->queue[pos]);
-			pull->filled[pos] = false;
-		}
-		pull->cur = (pull->cur + written) % QUEUE_SIZE;
-		pull->count -= written;
-		pull->written += written; // Profiling
-
-		if(pull->blocked_reader) async_wakeup(pull->blocked_reader);
+		for(index_t i = 0; i < count; ++i) {
+			EFSSubmissionFree(&queue[i]);
+		}
+//		pull->written += count; // Profiling

 	}

@@ -180,10 +187,10 @@
 	async_wakeup(co_create(STACK_DEFAULT, writer));
 	// TODO: It'd be even better to have one writer shared between all pulls...

-	pull->written = 0;
+/*	pull->written = 0;
 	pull->profiler.data = pull;
 	uv_timer_init(loop, &pull->profiler);
-	uv_timer_start(&pull->profiler, profile, 1000 * 10, 1000 * 10);
+	uv_timer_start(&pull->profiler, profile, 1000 * 10, 1000 * 10);*/

 	return 0;
 }
@@ -299,7 +306,7 @@
 	if(exists) goto enqueue;

 	// TODO: We're logging out of order when we do it like this...
-//	fprintf(stderr, "Pulling %s\n", URI);
+	fprintf(stderr, "Pulling %s\n", URI);

 	if(!*conn) *conn = HTTPConnectionCreateOutgoing(pull->host);
 	HTTPMessageRef msg = HTTPMessageCreate(*conn);


Replace basename by oscap_basename in xccdf_session.c

--- src/XCCDF/xccdf_session.c
+++ src/XCCDF/xccdf_session.c
@@ -860,7 +860,7 @@

 	for (int i = 0; oval_filenames[i];) {
 		resources[i] = malloc(sizeof(struct oval_content_resource));
-		resources[i]->href = strdup(basename(oval_filenames[i]));
+		resources[i]->href = oscap_basename(oval_filenames[i]);
 		resources[i]->source = oscap_source_new_from_file(oval_filenames[i]);
 		resources[i]->source_owned = true;
 		i++;


Kick off the build

Kick off the build

--- src/Encrypt.c
+++ src/Encrypt.c
@@ -513,6 +513,18 @@
 	return true;
 }

+/*! brief Retrieve header parameter from an enveloped message structure
+*
+* Retrieve a header parameter from the message.
+* Retrieved object is the same as the one in the message - do not delete it
+*
+* @param[in]	h	Handle of recipient object
+* @param[in]    key	Key to look for
+* @param[in]	flags	What buckets should we look for the message
+* @param[out]	perror	Location to return error codes
+* @return	Object which is found or NULL
+*/
+
 cn_cbor * COSE_Enveloped_map_get_int(HCOSE_ENVELOPED h, int key, int flags, cose_errback * perror)
 {
 	if (!IsValidEnvelopedHandle(h)) {


Fix broken save/restore and undo

Fix broken save/restore and undo

--- Source/Z/ZMachine.h
+++ Source/Z/ZMachine.h
@@ -869,7 +869,7 @@

       uint8_t ret = fetchByte();
       varWrite(ret, 2);
-      varWrite(ret, ZState::save(options.save_dir, story) ? 1 : 0);
+      varWrite(ret, ZState::save(options.save_dir, name) ? 1 : 0);
    }

    void opE_restore_undo()
@@ -880,7 +880,7 @@
       char name[12];
       sprintf(name, "undo_%x", undo_index);

-      if(!ZState::restore(options.save_dir, story)) varWrite(fetchByte(), 0);
+      if(!ZState::restore(options.save_dir, name)) varWrite(fetchByte(), 0);
    }

    void opE_print_unicode()


Refactoring regarding user_tailoring_file and cid in xccdf_session

--- src/XCCDF/xccdf_session.c
+++ src/XCCDF/xccdf_session.c
@@ -98,8 +98,10 @@
 		bool check_engine_plugins_results; ///< Shall the check engine plugins results be exported?
 	} export;					///< Settings of Session export
 	char *user_cpe;					///< Path to CPE dictionary required by user
-	char *user_tailoring_file;      ///< Path to Tailoring file requested by the user
-	char *user_tailoring_cid;       ///< Component ID of the Tailoring file requested by the user
+	struct {
+		struct oscap_source *user_file; ///< Tailoring file requested by the user
+		char *user_component_id;    ///< Component ID of the Tailoring requested by the user
+	} tailoring;
 	bool validate;					///< False value indicates to skip any XSD validation.
 	bool full_validation;				///< True value indicates that every possible step will be validated by XSD.

@@ -163,8 +165,8 @@
 	if (session->temp_dir != NULL)
 		oscap_acquire_cleanup_dir((char **) &(session->temp_dir));
 	oscap_source_free(session->source);
-	oscap_free(session->user_tailoring_file);
-	oscap_free(session->user_tailoring_cid);
+	oscap_source_free(session->tailoring.user_file);
+	oscap_free(session->tailoring.user_component_id);
 	oscap_free(session);
 }

@@ -234,14 +236,15 @@

 void xccdf_session_set_user_tailoring_file(struct xccdf_session *session, const char *user_tailoring_file)
 {
-	oscap_free(session->user_tailoring_file);
-	session->user_tailoring_file = oscap_strdup(user_tailoring_file);
+	oscap_source_free(session->tailoring.user_file);
+	session->tailoring.user_file = user_tailoring_file != NULL ?
+		oscap_source_new_from_file(user_tailoring_file) : NULL;
 }

 void xccdf_session_set_user_tailoring_cid(struct xccdf_session *session, const char *user_tailoring_cid)
 {
-	oscap_free(session->user_tailoring_cid);
-	session->user_tailoring_cid = oscap_strdup(user_tailoring_cid);
+	oscap_free(session->tailoring.user_component_id);
+	session->tailoring.user_component_id = oscap_strdup(user_tailoring_cid);
 }

 void xccdf_session_set_remote_resources(struct xccdf_session *session, bool allowed, download_progress_calllback_t callback)
@@ -775,16 +778,16 @@
 	bool from_sds = false;
 	struct oscap_source *tailoring_source = NULL;

-	if (session->user_tailoring_file != NULL) {
-		tailoring_source = oscap_source_new_from_file(session->user_tailoring_file);
-	}
-	else if (session->user_tailoring_cid != NULL) {
+	if (session->tailoring.user_file != NULL) {
+		tailoring_source = session->tailoring.user_file;
+	}
+	else if (session->tailoring.user_component_id != NULL) {
 		if (!xccdf_session_is_sds(session)) {
 			oscap_seterr(OSCAP_EFAMILY_OSCAP, "Can't use given tailoring component ID because file isn't a source datastream.");
 			return 1;
 		}

-		tailoring_source = ds_sds_session_select_tailoring(xccdf_session_get_ds_sds_session(session), session->user_tailoring_cid);
+		tailoring_source = ds_sds_session_select_tailoring(xccdf_session_get_ds_sds_session(session), session->tailoring.user_component_id);
 		if (tailoring_source == NULL) {
 			return 1;
 		}
@@ -811,9 +814,6 @@

 	struct xccdf_benchmark *benchmark = xccdf_policy_model_get_benchmark(session->xccdf.policy_model);
 	struct xccdf_tailoring *tailoring = xccdf_tailoring_import_source(tailoring_source, benchmark);
-	if (session->user_tailoring_file != NULL) {
-		oscap_source_free(tailoring_source);
-	}

 	if (tailoring == NULL)
 		return 1;