rtlwifi: Eliminate raw reads and writes from PCIe portion

The PCIe driver used raw reads and writes on the PCIe hardware.
As all of these are only affecting the configuration space, all of
then can be converted to pci_{read,write}_config_XX calls.

Signed-off-by: Larry Finger <ed0f1d78b8c21b2970494a178da4bdfa8beba2a7@lwfinger.net>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>

--- drivers/net/wireless/rtlwifi/pci.c
+++ drivers/net/wireless/rtlwifi/pci.c
@@ -218,7 +218,6 @@
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
 	u8 pcibridge_vendor = pcipriv->ndis_adapter.pcibridge_vendor;
-	u32 pcicfg_addrport = pcipriv->ndis_adapter.pcicfg_addrport;
 	u8 num4bytes = pcipriv->ndis_adapter.num4bytes;
 	/*Retrieve original configuration settings. */
 	u8 linkctrl_reg = pcipriv->ndis_adapter.linkctrl_reg;
@@ -254,9 +253,8 @@
 	udelay(50);

 	/*4 Disable Pci Bridge ASPM */
-	rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS,
-				     pcicfg_addrport + (num4bytes << 2));
-	rtl_pci_raw_write_port_uchar(PCI_CONF_DATA, pcibridge_linkctrlreg);
+	pci_write_config_byte(rtlpci->pdev, (num4bytes << 2),
+			      pcibridge_linkctrlreg);

 	udelay(50);
 }
@@ -277,7 +275,6 @@
 	u8 pcibridge_devnum = pcipriv->ndis_adapter.pcibridge_devnum;
 	u8 pcibridge_funcnum = pcipriv->ndis_adapter.pcibridge_funcnum;
 	u8 pcibridge_vendor = pcipriv->ndis_adapter.pcibridge_vendor;
-	u32 pcicfg_addrport = pcipriv->ndis_adapter.pcicfg_addrport;
 	u8 num4bytes = pcipriv->ndis_adapter.num4bytes;
 	u16 aspmlevel;
 	u8 u_pcibridge_aspmsetting;
@@ -293,8 +290,6 @@
 	}

 	/*4 Enable Pci Bridge ASPM */
-	rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS,
-				     pcicfg_addrport + (num4bytes << 2));

 	u_pcibridge_aspmsetting =
 	    pcipriv->ndis_adapter.pcibridge_linkctrlreg |
@@ -303,7 +298,8 @@
 	if (pcibridge_vendor == PCI_BRIDGE_VENDOR_INTEL)
 		u_pcibridge_aspmsetting &= ~BIT(0);

-	rtl_pci_raw_write_port_uchar(PCI_CONF_DATA, u_pcibridge_aspmsetting);
+	pci_write_config_byte(rtlpci->pdev, (num4bytes << 2),
+			      u_pcibridge_aspmsetting);

 	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
 		 ("PlatformEnableASPM():PciBridge busnumber[%x], "
@@ -335,25 +331,18 @@

 static bool rtl_pci_get_amd_l1_patch(struct ieee80211_hw *hw)
 {
-	struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
-	u32 pcicfg_addrport = pcipriv->ndis_adapter.pcicfg_addrport;
+	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));

 	bool status = false;
 	u8 offset_e0;
 	unsigned offset_e4;

-	rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS,
-			pcicfg_addrport + 0xE0);
-	rtl_pci_raw_write_port_uchar(PCI_CONF_DATA, 0xA0);
-
-	rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS,
-			pcicfg_addrport + 0xE0);
-	rtl_pci_raw_read_port_uchar(PCI_CONF_DATA, &offset_e0);
+	pci_write_config_byte(rtlpci->pdev, 0xe0, 0xa0);
+
+	pci_read_config_byte(rtlpci->pdev, 0xe0, &offset_e0);

 	if (offset_e0 == 0xA0) {
-		rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS,
-					     pcicfg_addrport + 0xE4);
-		rtl_pci_raw_read_port_ulong(PCI_CONF_DATA, &offset_e4);
+		pci_read_config_dword(rtlpci->pdev, 0xe4, &offset_e4);
 		if (offset_e4 & BIT(23))
 			status = true;
 	}
@@ -364,17 +353,15 @@
 static void rtl_pci_get_linkcontrol_field(struct ieee80211_hw *hw)
 {
 	struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
+	struct rtl_pci *rtlpci = rtl_pcidev(pcipriv);
 	u8 capabilityoffset = pcipriv->ndis_adapter.pcibridge_pciehdr_offset;
-	u32 pcicfg_addrport = pcipriv->ndis_adapter.pcicfg_addrport;
 	u8 linkctrl_reg;
 	u8 num4bbytes;

 	num4bbytes = (capabilityoffset + 0x10) / 4;

 	/*Read  Link Control Register */
-	rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS,
-				     pcicfg_addrport + (num4bbytes << 2));
-	rtl_pci_raw_read_port_uchar(PCI_CONF_DATA, &linkctrl_reg);
+	pci_read_config_byte(rtlpci->pdev, (num4bbytes << 2), &linkctrl_reg);

 	pcipriv->ndis_adapter.pcibridge_linkctrlreg = linkctrl_reg;
 }
@@ -1718,10 +1705,6 @@
 		    PCI_SLOT(bridge_pdev->devfn);
 		pcipriv->ndis_adapter.pcibridge_funcnum =
 		    PCI_FUNC(bridge_pdev->devfn);
-		pcipriv->ndis_adapter.pcicfg_addrport =
-		    (pcipriv->ndis_adapter.pcibridge_busnum << 16) |
-		    (pcipriv->ndis_adapter.pcibridge_devnum << 11) |
-		    (pcipriv->ndis_adapter.pcibridge_funcnum << 8) | (1 << 31);
 		pcipriv->ndis_adapter.pcibridge_pciehdr_offset =
 		    pci_pcie_cap(bridge_pdev);
 		pcipriv->ndis_adapter.num4bytes =


Adding useful typedefs to unlock_object.

--- autowiring/unlock_object.h
+++ autowiring/unlock_object.h
@@ -8,13 +8,14 @@
 ///
 ///<remarks>
 ///An unlock_object cannot be copied by construction or assignment since it maintains access.
-///An unlock_object cannot be used to extend the existence of an atomic_object.
+///An unlock_object cannot be used to extend the existence of an atomic_object beyond the
+///span of existence of the unlock_object.
 ///</remarks>
 template<class object_type, class lock_type = std::mutex>
 class unlock_object {
 public:
-  typedef object_type object;
   typedef atomic_object<object_type, lock_type> atomic;
+  typedef typename atomic::object object;
   typedef typename atomic::lock lock;
   typedef typename atomic::shared shared;

@@ -36,7 +37,7 @@
   ///Construction references the object and maintains a lock, yielding bool(*this) == true;
   ///
   ///<param name="should_try">If true, the returned unlock_object might hold no reference or lock</param>
-  unlock_object(shared& source, bool should_try = false) {
+  unlock_object(shared source, bool should_try = false) {
     acquire(source, should_try);
   }

@@ -68,7 +69,7 @@
   ///This method is idempotent, including when called repeatedly with the same argument.
   ///However, acquire(source) always releases the any currently held lock.
   ///</remarks>
-  void acquire(shared& source, bool should_try = false) {
+  void acquire(shared source, bool should_try = false) {
     release();
     if (!source) {
       return;


evas/evas_object_smart - simpler code.

evas/evas_object_smart - simpler code.

git-svn-id: 24a995eca3b83137dd7eab3408044d7832e202f7@71531 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/lib/canvas/evas_object_smart.c
+++ src/lib/canvas/evas_object_smart.c
@@ -929,12 +929,9 @@
      }
    if ((obj->cur.map != obj->prev.map) ||
        (obj->cur.usemap != obj->prev.usemap))
-     {
-        evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes, obj);
-        goto done;
-     }
-done:
-   obj->pre_render_done = 1;
+     evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes, obj);
+
+   obj->pre_render_done = EINA_TRUE;
 }

 static void


wl12xx: allow 11a AP-mode for wl127x devices

There was a check preventing 127x devices from using the 11a band when
operating as AP. Since we now support this functionality, remove the
check.

With this patch, a 11a AP starts ok on 127x cards.

Signed-off-by: Arik Nemtsov <1a5d131848a166677cc209f94fa988cee9378c32@wizery.com>
Signed-off-by: Eliad Peller <fdf5551f20996bc0613832b4b54eb06eecaffd38@wizery.com>
Signed-off-by: Luciano Coelho <d1ef580865f8eb2e1d1c65bc406aba322cc98f3e@ti.com>

--- drivers/net/wireless/wl12xx/boot.c
+++ drivers/net/wireless/wl12xx/boot.c
@@ -294,9 +294,7 @@
 		 */
 		if (wl->nvs_len == sizeof(struct wl1271_nvs_file) ||
 		    wl->nvs_len == WL1271_INI_LEGACY_NVS_FILE_SIZE) {
-			/* for now 11a is unsupported in AP mode */
-			if (wl->bss_type != BSS_TYPE_AP_BSS &&
-			    nvs->general_params.dual_mode_select)
+			if (nvs->general_params.dual_mode_select)
 				wl->enable_11a = true;
 		}


flush stdout after every line, this makes avahi-browse more useful in shell scripts where pipes are involved (closes #48)

git-svn-id: ff687e355030673c307e7da231f59639d58f56d5@1232 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

--- avahi-utils/avahi-browse.c
+++ avahi-utils/avahi-browse.c
@@ -148,6 +148,7 @@
            interface != AVAHI_IF_UNSPEC ? if_indextoname(interface, ifname) : "n/a",
            protocol != AVAHI_PROTO_UNSPEC ? avahi_proto_to_string(protocol) : "n/a",
            n_columns-35, name, type, domain);
+    fflush(stdout);
 }

 static void service_resolver_callback(
@@ -206,6 +207,7 @@
     assert(n_resolving > 0);
     n_resolving--;
     check_terminate(i->config);
+    fflush(stdout);
 }

 static ServiceInfo *add_service(Config *c, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain) {


item_allocator_init checks now if it is already initialized

--- src/lib/container/item_allocator.c
+++ src/lib/container/item_allocator.c
@@ -7,7 +7,7 @@
 #include "macros.h"
 #include "item_allocator.h"

-#define ITEM_ALLOCATOR_SIZE 1000
+#define ITEM_ALLOCATOR_SIZE 1024

 static pthread_mutex_t _mutex_pool;
@@ -23,6 +23,9 @@
 int item_allocator_init(int size)
 {
     int err;
+
+    if(_pool)
+        return 0;

     _pool = mempool_new(size, sizeof(struct item));
     if(!_pool) {


wl12xx: enable/disable role on interface add/remove

According to the new multi-role flow, we have to enable the
role before using (starting) it, and disable it on cleanup
(after it's no longer needed).

Signed-off-by: Eliad Peller <fdf5551f20996bc0613832b4b54eb06eecaffd38@wizery.com>
Signed-off-by: Luciano Coelho <d1ef580865f8eb2e1d1c65bc406aba322cc98f3e@ti.com>

--- drivers/net/wireless/wl12xx/main.c
+++ drivers/net/wireless/wl12xx/main.c
@@ -1779,6 +1779,21 @@
 	wl1271_debug(DEBUG_MAC80211, "mac80211 stop");
 }

+static u8 wl12xx_get_role_type(struct wl1271 *wl)
+{
+	switch (wl->bss_type) {
+	case BSS_TYPE_AP_BSS:
+		return WL1271_ROLE_AP;
+
+	case BSS_TYPE_STA_BSS:
+		return WL1271_ROLE_STA;
+
+	default:
+		wl1271_error("invalid bss_type: %d", wl->bss_type);
+	}
+	return WL12XX_INVALID_ROLE_TYPE;
+}
+
 static int wl1271_op_add_interface(struct ieee80211_hw *hw,
 				   struct ieee80211_vif *vif)
 {
@@ -1786,6 +1801,7 @@
 	struct wiphy *wiphy = hw->wiphy;
 	int retries = WL1271_BOOT_RETRIES;
 	int ret = 0;
+	u8 role_type;
 	bool booted = false;

 	wl1271_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM",
@@ -1826,6 +1842,11 @@
 		goto out;
 	}

+	role_type = wl12xx_get_role_type(wl);
+	if (role_type == WL12XX_INVALID_ROLE_TYPE) {
+		ret = -EINVAL;
+		goto out;
+	}
 	memcpy(wl->mac_addr, vif->addr, ETH_ALEN);

 	if (wl->state != WL1271_STATE_OFF) {
@@ -1844,6 +1865,10 @@
 		ret = wl1271_boot(wl);
 		if (ret < 0)
 			goto power_off;
+
+		ret = wl12xx_cmd_role_enable(wl, role_type, &wl->role_id);
+		if (ret < 0)
+			goto irq_disable;

 		ret = wl1271_hw_init(wl);
 		if (ret < 0)
@@ -1909,6 +1934,7 @@
 static void __wl1271_op_remove_interface(struct wl1271 *wl,
 					 bool reset_tx_queues)
 {
+	int ret;

 	wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface");

@@ -1932,6 +1958,21 @@
 		wl->scan.req = NULL;
 		ieee80211_scan_completed(wl->hw, true);
 	}
+
+	if (!test_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags)) {
+		/* disable active roles */
+		ret = wl1271_ps_elp_wakeup(wl);
+		if (ret < 0)
+			goto deinit;
+
+		ret = wl12xx_cmd_role_disable(wl, &wl->role_id);
+		if (ret < 0)
+			goto deinit;
+
+		wl1271_ps_elp_sleep(wl);
+	}
+deinit:
+	wl->sta_hlid = WL12XX_INVALID_LINK_ID;

 	/*
 	 * this must be before the cancel_work calls below, so that the work


interface scrollable: Adjusted to Eo2.

interface scrollable: Adjusted to Eo2.

--- src/lib/elm_interface_scrollable.c
+++ src/lib/elm_interface_scrollable.c
@@ -215,7 +215,7 @@
    eo_do_super(obj, MY_PAN_CLASS, eo_constructor());
    eo_do(obj,
          evas_obj_type_set(MY_PAN_CLASS_NAME_LEGACY),
-         evas_obj_smart_callbacks_descriptions_set(_smart_callbacks, NULL));
+         evas_obj_smart_callbacks_descriptions_set(_smart_callbacks));
 }

 static void
@@ -1167,7 +1167,7 @@
 _elm_scroll_x_mirrored_get(const Evas_Object *obj,
                            Evas_Coord x)
 {
-   Evas_Coord cw, ch, w, ret;
+   Evas_Coord cw = 0, ch = 0, w = 0, ret;

    ELM_SCROLL_IFACE_DATA_GET_OR_RETURN_VAL(obj, sid, x);

@@ -1217,7 +1217,7 @@
    if ((sid->down.bounce_x_animator) || (sid->down.bounce_y_animator)) return;
    if (sid->down.momentum_animator)
      {
-        Evas_Coord px, py;
+        Evas_Coord px = 0, py = 0;
         eo_do(sid->obj, elm_interface_scrollable_content_pos_get(&px, &py));
         _elm_scroll_wanted_coordinates_update(sid, px, py);

@@ -1351,7 +1351,7 @@
 static void
 _elm_scroll_bounce_eval(Elm_Scrollable_Smart_Interface_Data *sid)
 {
-   Evas_Coord mx, my, px, py, bx, by, b2x, b2y, minx = 0, miny = 0;
+   Evas_Coord mx = 0, my = 0, px = 0, py = 0, bx, by, b2x, b2y, minx = 0, miny = 0;

    if (!sid->pan_obj) return;

@@ -2055,7 +2055,7 @@
 _elm_scroll_page_y_get(Elm_Scrollable_Smart_Interface_Data *sid,
                        int offset, Eina_Bool limit)
 {
-   Evas_Coord x, y, w, h, dy, cw, ch, miny = 0;
+   Evas_Coord x, y, w = 0, h = 0, dy, cw = 0, ch = 0, miny = 0;

    if (!sid->pan_obj) return 0;

@@ -2171,7 +2171,7 @@
                         double t_in,
                         Evas_Coord pos_y)
 {
-   Evas_Coord px, py, x, y, w, h;
+   Evas_Coord px = 0, py = 0, x, y, w, h;
    double t;

    if (!sid->pan_obj) return;
@@ -2214,7 +2214,7 @@
                         double t_in,
                         Evas_Coord pos_x)
 {
-   Evas_Coord px, py, x, y, w, h;
+   Evas_Coord px = 0, py = 0, x, y, w, h;
    double t;

    if (!sid->pan_obj) return;
@@ -2926,7 +2926,7 @@
 {
    double t, td;
    double vx, vy;
-   Evas_Coord x, y, ox, oy;
+   Evas_Coord x, y, ox = 0, oy = 0;
    Elm_Scrollable_Smart_Interface_Data *sid;

    sid = data;
@@ -3001,7 +3001,7 @@
    if ((sid->scrollto.x.animator) && (!sid->hold) && (!sid->freeze) &&
        !(sid->block & ELM_SCROLLER_MOVEMENT_BLOCK_HORIZONTAL))
      {
-        Evas_Coord px;
+        Evas_Coord px = 0;
         ELM_SAFE_FREE(sid->scrollto.x.animator, ecore_animator_del);
         eo_do(sid->pan_obj, elm_obj_pan_pos_get(&px, NULL));
         sid->down.sx = px;
@@ -3011,7 +3011,7 @@
    if ((sid->scrollto.y.animator) && (!sid->hold) && (!sid->freeze) &&
        !(sid->block & ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL))
      {
-        Evas_Coord py;
+        Evas_Coord py = 0;
         ELM_SAFE_FREE(sid->scrollto.y.animator, ecore_animator_del);
         eo_do(sid->pan_obj, elm_obj_pan_pos_get(NULL, &py));
         sid->down.sy = py;
@@ -3190,7 +3190,7 @@
                     }
                }
              {
-                Evas_Coord minx, miny, mx, my;
+                Evas_Coord minx = 0, miny = 0, mx, my;

                 eo_do(sid->pan_obj, elm_obj_pan_pos_min_get(&minx, &miny));
                 eo_do(sid->pan_obj, elm_obj_pan_pos_max_get(&mx, &my));
@@ -3610,7 +3610,7 @@
                           Evas_Object *obj EINA_UNUSED,
                           void *event_info EINA_UNUSED)
 {
-   Evas_Coord w, h;
+   Evas_Coord w = 0, h = 0;
    Elm_Scrollable_Smart_Interface_Data *sid = data;

    if (sid->cb_func.content_viewport_resize)
@@ -3627,7 +3627,7 @@
                            Evas_Object *obj EINA_UNUSED,
                            void *event_info EINA_UNUSED)
 {
-   Evas_Coord w, h;
+   Evas_Coord w = 0, h = 0;
    Elm_Scrollable_Smart_Interface_Data *sid = data;

    if (!sid->pan_obj) return;
@@ -3662,7 +3662,7 @@
 EOLIAN static void
 _elm_interface_scrollable_content_set(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid, Evas_Object *content)
 {
-   Evas_Coord w, h;
+   Evas_Coord w = 0, h = 0;
    Evas_Object *o;

    if (!sid->edje_obj) return;
@@ -4183,7 +4183,7 @@
 EOLIAN static void
 _elm_interface_scrollable_page_show(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid, int pagenumber_h, int pagenumber_v)
 {
-   Evas_Coord w, h;
+   Evas_Coord w = 0, h = 0;
    Evas_Coord x = 0;
    Evas_Coord y = 0;

@@ -4212,7 +4212,7 @@
 EOLIAN static void
 _elm_interface_scrollable_page_bring_in(Eo *obj, Elm_Scrollable_Smart_Interface_Data *sid, int pagenumber_h, int pagenumber_v)
 {
-   Evas_Coord w, h;
+   Evas_Coord w = 0, h = 0;
    Evas_Coord x = 0;
    Evas_Coord y = 0;


pci: pcie-designware: Remove irq_desc abuse

There is no reason to care about irq_desc in that context, escpecially
as irq_data for that interrupt is retrieved as well.

Use the proper accessor for the msi descriptor

Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>
Cc: Peter Zijlstra <3fddac958924aef220f202ca567388ddab3f14a8@infradead.org>
Acked-by: Bjorn Helgaas <f10ec01be0c6b54271af5c550cd257810bdf3268@google.com>
Acked-by: Jingoo Han <fc379137a64feb86ce38ec5811a14280acc1ccfc@samsung.com>
Cc: Mohit Kumar <e81db36ab52392345806c7bc8596be7c3b491eae@st.com>
Cc: pci <c6ec3e7b985c17ad0107cdbe9b999c23f1042f60@vger.kernel.org>
Link: 2608a111debd93b91318d17e40f789d8221ffba1@linutronix.de
Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>

--- drivers/pci/host/pcie-designware.c
+++ drivers/pci/host/pcie-designware.c
@@ -294,14 +294,12 @@
 static void clear_irq(unsigned int irq)
 {
 	unsigned int pos, nvec;
-	struct irq_desc *desc;
 	struct msi_desc *msi;
 	struct pcie_port *pp;
 	struct irq_data *data = irq_get_irq_data(irq);

 	/* get the port structure */
-	desc = irq_to_desc(irq);
-	msi = irq_desc_get_msi_desc(desc);
+	msi = irq_data_get_msi(data);
 	pp = sys_to_pcie(msi->dev->bus->sysdata);
 	if (!pp) {
 		BUG();


PCI/AER: Reset link for devices below Root Port or Downstream Port

When a PCIe device reports a fatal error, we reset the link leading
to it.  Previously we only did this for devices below Downstream Ports,
not for devices directly below Root Ports.

This patch changes that so we reset the link leading to devices below
Root Ports just like we do for those below Downstream Ports.

[bhelgaas: changelog, keep dev_printk(KERN_DEBUG)]
Signed-off-by: Betty Dall <1f3f83a7a52d4543206d9f2d5199313537aea940@hp.com>
Signed-off-by: Bjorn Helgaas <f10ec01be0c6b54271af5c550cd257810bdf3268@google.com>

--- drivers/pci/pcie/aer/aerdrv_core.c
+++ drivers/pci/pcie/aer/aerdrv_core.c
@@ -400,16 +400,16 @@
 }

 /**
- * default_downstream_reset_link - default reset function for Downstream Port
- * @dev: pointer to downstream port's pci_dev data structure
- *
- * Invoked when performing link reset at Downstream Port w/ no aer driver.
- */
-static pci_ers_result_t default_downstream_reset_link(struct pci_dev *dev)
+ * default_reset_link - default reset function
+ * @dev: pointer to pci_dev data structure
+ *
+ * Invoked when performing link reset on a Downstream Port or a
+ * Root Port with no aer driver.
+ */
+static pci_ers_result_t default_reset_link(struct pci_dev *dev)
 {
 	aer_do_secondary_bus_reset(dev);
-	dev_printk(KERN_DEBUG, &dev->dev,
-		"Downstream Port link has been reset\n");
+	dev_printk(KERN_DEBUG, &dev->dev, "downstream link has been reset\n");
 	return PCI_ERS_RESULT_RECOVERED;
 }

@@ -458,8 +458,9 @@

 	if (driver && driver->reset_link) {
 		status = driver->reset_link(udev);
-	} else if (pci_pcie_type(udev) == PCI_EXP_TYPE_DOWNSTREAM) {
-		status = default_downstream_reset_link(udev);
+	} else if (pci_pcie_type(udev) == PCI_EXP_TYPE_DOWNSTREAM ||
+		pci_pcie_type(udev) == PCI_EXP_TYPE_ROOT_PORT) {
+		status = default_reset_link(udev);
 	} else {
 		dev_printk(KERN_DEBUG, &dev->dev,
 			"no link-reset support at upstream device %s\n",


sh-pfc: emev2 - Fix mangled author name

sh-pfc: emev2 - Fix mangled author name

Signed-off-by: Geert Uytterhoeven <a1ff81395f7e6bf5b509fe9aab06bf3419493e1d@glider.be>
Fixes: 1e7d5d849cf4f0c5 ("sh-pfc: Add emev2 pinmux support")
Signed-off-by: Linus Walleij <9cd9d802d23c0ed5e224beabf4ae4a5c478746ef@linaro.org>

--- drivers/pinctrl/sh-pfc/pfc-emev2.c
+++ drivers/pinctrl/sh-pfc/pfc-emev2.c
@@ -1,7 +1,7 @@
 /*
  * Pin Function Controller Support
  *
- * Copyright (C) 2015 Niklas SÃ¶derlund
+ * Copyright (C) 2015 Niklas Söderlund
  *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive


esas2r: fir error handling in do_fm_api

esas2r: fir error handling in do_fm_api

This patch fixes an error path and rearranges error handling.

Signed-off-by: Tomas Henzl <ed03cdd404c1c501a81ee6cc756c3c81b1d33f83@redhat.com>
Acked-by: Bradley Grove <513d3c36f1f203ee9ef3f8b73e4e9a45780c0e17@attotech.com>
Signed-off-by: Christoph Hellwig <923f7720577207a44b32e59bbfbea59d27f1ae8e@lst.de>

--- drivers/scsi/esas2r/esas2r_ioctl.c
+++ drivers/scsi/esas2r/esas2r_ioctl.c
@@ -117,9 +117,8 @@

 	rq = esas2r_alloc_request(a);
 	if (rq == NULL) {
-		up(&a->fm_api_semaphore);
 		fi->status = FI_STAT_BUSY;
-		return;
+		goto free_sem;
 	}

 	if (fi == &a->firmware.header) {
@@ -135,7 +134,7 @@
 		if (a->firmware.header_buff == NULL) {
 			esas2r_debug("failed to allocate header buffer!");
 			fi->status = FI_STAT_BUSY;
-			return;
+			goto free_req;
 		}

 		memcpy(a->firmware.header_buff, fi,
@@ -171,9 +170,10 @@
 				  a->firmware.header_buff,
 				  (dma_addr_t)a->firmware.header_buff_phys);
 	}
-
+free_req:
+	esas2r_free_request(a, (struct esas2r_request *)rq);
+free_sem:
 	up(&a->fm_api_semaphore);
-	esas2r_free_request(a, (struct esas2r_request *)rq);
 	return;

 }


staging: sm750fb: fix 'switch and case' indentation

Fix according to checkpatch.pl message:
"ERROR: switch and case should be at the same indent"

Signed-off-by: Anatoly Stepanov <c71c9c284ad18c9474c9a9b3399f52c70f5ce2ac@gmail.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/staging/sm750fb/sm750_hw.c
+++ drivers/staging/sm750fb/sm750_hw.c
@@ -153,15 +153,15 @@
 		}

 		switch (spec_share->state.pnltype) {
-			case sm750_doubleTFT:
-			case sm750_24TFT:
-			case sm750_dualTFT:
-			POKE32(PANEL_DISPLAY_CTRL,
-				FIELD_VALUE(PEEK32(PANEL_DISPLAY_CTRL),
-							PANEL_DISPLAY_CTRL,
-							TFT_DISP,
-							spec_share->state.pnltype));
-			break;
+		case sm750_doubleTFT:
+		case sm750_24TFT:
+		case sm750_dualTFT:
+		POKE32(PANEL_DISPLAY_CTRL,
+			FIELD_VALUE(PEEK32(PANEL_DISPLAY_CTRL),
+						PANEL_DISPLAY_CTRL,
+						TFT_DISP,
+						spec_share->state.pnltype));
+		break;
 		}
 	} else {
 		/* for 750LE ,no DVI chip initilization makes Monitor no signal */
@@ -267,17 +267,17 @@
 	share = container_of(crtc, struct lynxfb_par, crtc)->share;

 	switch (var->bits_per_pixel) {
-		case 8:
-		case 16:
-			break;
-		case 32:
-			if (share->revid == SM750LE_REVISION_ID) {
-				pr_debug("750le do not support 32bpp\n");
-				return -EINVAL;
-			}
-			break;
-		default:
+	case 8:
+	case 16:
+		break;
+	case 32:
+		if (share->revid == SM750LE_REVISION_ID) {
+			pr_debug("750le do not support 32bpp\n");
 			return -EINVAL;
+		}
+		break;
+	default:
+		return -EINVAL;

 	}

@@ -307,16 +307,16 @@
 	if (!share->accel_off) {
 		/* set 2d engine pixel format according to mode bpp */
 		switch (var->bits_per_pixel) {
-			case 8:
-				fmt = 0;
-				break;
-			case 16:
-				fmt = 1;
-				break;
-			case 32:
-			default:
-				fmt = 2;
-				break;
+		case 8:
+			fmt = 0;
+			break;
+		case 16:
+			fmt = 1;
+			break;
+		case 32:
+		default:
+			fmt = 2;
+			break;
 		}
 		hw_set2dformat(&share->accel, fmt);
 	}
@@ -427,45 +427,45 @@

 	switch (blank) {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-		case FB_BLANK_UNBLANK:
-#else
-		case VESA_NO_BLANKING:
-#endif
-			dpms = CRT_DISPLAY_CTRL_DPMS_0;
-			crtdb = CRT_DISPLAY_CTRL_BLANK_OFF;
-			break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-		case FB_BLANK_NORMAL:
-			dpms = CRT_DISPLAY_CTRL_DPMS_0;
-			crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-			break;
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-		case FB_BLANK_VSYNC_SUSPEND:
-#else
-		case VESA_VSYNC_SUSPEND:
-#endif
-			dpms = CRT_DISPLAY_CTRL_DPMS_2;
-			crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-			break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-		case FB_BLANK_HSYNC_SUSPEND:
-#else
-		case VESA_HSYNC_SUSPEND:
-#endif
-			dpms = CRT_DISPLAY_CTRL_DPMS_1;
-			crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-			break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-		case FB_BLANK_POWERDOWN:
-#else
-		case VESA_POWERDOWN:
-#endif
-			dpms = CRT_DISPLAY_CTRL_DPMS_3;
-			crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-			break;
-		default:
-			return -EINVAL;
+	case FB_BLANK_UNBLANK:
+#else
+	case VESA_NO_BLANKING:
+#endif
+		dpms = CRT_DISPLAY_CTRL_DPMS_0;
+		crtdb = CRT_DISPLAY_CTRL_BLANK_OFF;
+		break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
+	case FB_BLANK_NORMAL:
+		dpms = CRT_DISPLAY_CTRL_DPMS_0;
+		crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+		break;
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
+	case FB_BLANK_VSYNC_SUSPEND:
+#else
+	case VESA_VSYNC_SUSPEND:
+#endif
+		dpms = CRT_DISPLAY_CTRL_DPMS_2;
+		crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+		break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
+	case FB_BLANK_HSYNC_SUSPEND:
+#else
+	case VESA_HSYNC_SUSPEND:
+#endif
+		dpms = CRT_DISPLAY_CTRL_DPMS_1;
+		crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+		break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
+	case FB_BLANK_POWERDOWN:
+#else
+	case VESA_POWERDOWN:
+#endif
+		dpms = CRT_DISPLAY_CTRL_DPMS_3;
+		crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+		break;
+	default:
+		return -EINVAL;
 	}

 	if (output->paths & sm750_crt) {
@@ -483,50 +483,50 @@

 	switch (blank) {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-		case FB_BLANK_UNBLANK:
-#else
-		case VESA_NO_BLANKING:
-#endif
-			pr_info("flag = FB_BLANK_UNBLANK \n");
-			dpms = SYSTEM_CTRL_DPMS_VPHP;
-			pps = PANEL_DISPLAY_CTRL_DATA_ENABLE;
-			crtdb = CRT_DISPLAY_CTRL_BLANK_OFF;
-			break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-		case FB_BLANK_NORMAL:
-			pr_info("flag = FB_BLANK_NORMAL \n");
-			dpms = SYSTEM_CTRL_DPMS_VPHP;
-			pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
-			crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-			break;
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-		case FB_BLANK_VSYNC_SUSPEND:
-#else
-		case VESA_VSYNC_SUSPEND:
-#endif
-			dpms = SYSTEM_CTRL_DPMS_VNHP;
-			pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
-			crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-			break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-		case FB_BLANK_HSYNC_SUSPEND:
-#else
-		case VESA_HSYNC_SUSPEND:
-#endif
-			dpms = SYSTEM_CTRL_DPMS_VPHN;
-			pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
-			crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-			break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-		case FB_BLANK_POWERDOWN:
-#else
-		case VESA_POWERDOWN:
-#endif
-			dpms = SYSTEM_CTRL_DPMS_VNHN;
-			pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
-			crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-			break;
+	case FB_BLANK_UNBLANK:
+#else
+	case VESA_NO_BLANKING:
+#endif
+		pr_info("flag = FB_BLANK_UNBLANK \n");
+		dpms = SYSTEM_CTRL_DPMS_VPHP;
+		pps = PANEL_DISPLAY_CTRL_DATA_ENABLE;
+		crtdb = CRT_DISPLAY_CTRL_BLANK_OFF;
+		break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
+	case FB_BLANK_NORMAL:
+		pr_info("flag = FB_BLANK_NORMAL \n");
+		dpms = SYSTEM_CTRL_DPMS_VPHP;
+		pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
+		crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+		break;
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
+	case FB_BLANK_VSYNC_SUSPEND:
+#else
+	case VESA_VSYNC_SUSPEND:
+#endif
+		dpms = SYSTEM_CTRL_DPMS_VNHP;
+		pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
+		crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+		break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
+	case FB_BLANK_HSYNC_SUSPEND:
+#else
+	case VESA_HSYNC_SUSPEND:
+#endif
+		dpms = SYSTEM_CTRL_DPMS_VPHN;
+		pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
+		crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+		break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
+	case FB_BLANK_POWERDOWN:
+#else
+	case VESA_POWERDOWN:
+#endif
+		dpms = SYSTEM_CTRL_DPMS_VNHN;
+		pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
+		crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+		break;
 	}

 	if (output->paths & sm750_crt) {


Staging: wlags49_h2: remove unused function prototype

With today linux-next I got a compile error in staging/wlags49_h2 driver
due an unused function prototype that use a data type (event_callback_args_t)
that doesn't exist anymore in the pcmcia code.

Current patch solves the issue removing the function prototype.

Signed-off-by: Javier Martinez Canillas <07d7d8b97f07df629b11b70f3903e2991d35e296@gmail.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

--- drivers/staging/wlags49_h2/wl_cs.h
+++ drivers/staging/wlags49_h2/wl_cs.h
@@ -72,8 +72,6 @@

 void wl_adapter_release(struct pcmcia_device *link);

-int wl_adapter_event(event_t event, int priority, event_callback_args_t *args );
-
 int wl_adapter_init_module( void );

 void wl_adapter_cleanup_module( void );


thermal: rockchip: make temperature reporting much more accurate

In general, the kernel should report temperature readings exactly as
reported by the hardware. The cpu / gpu thermal driver works in 5 degree
increments,but we ought to do more accurate. The temperature will do
linear interpolation between the entries in the table.

Test= $md5sum /dev/zero &
$while true; do grep "" /sys/class/thermal/thermal_zone[1-2]/temp;
sleep .5; done

e.g. We can get the result as follows:
    /sys/class/thermal/thermal_zone1/temp:39994
    /sys/class/thermal/thermal_zone2/temp:39086
    /sys/class/thermal/thermal_zone1/temp:39994
    /sys/class/thermal/thermal_zone2/temp:39540
    /sys/class/thermal/thermal_zone1/temp:39540
    /sys/class/thermal/thermal_zone2/temp:39540
    /sys/class/thermal/thermal_zone1/temp:39540
    /sys/class/thermal/thermal_zone2/temp:39994

Reviewed-by: Dmitry Torokhov <6b8646d310837fed93a129ed3c979b90c7f2674f@gmail.com>
Reviewed-by: Daniel Kurtz <31914e832df1cd8e5daa417106c0c6f5297b27d7@chromium.org>
Signed-off-by: Caesar Wang <6a97ab1d8fae3a62719c8e695586fe709398a94a@rock-chips.com>
Signed-off-by: Eduardo Valentin <19583d7f5a73f900a77b3924aabdcb631a4c7608@gmail.com>

--- drivers/thermal/rockchip_thermal.c
+++ drivers/thermal/rockchip_thermal.c
@@ -193,19 +193,20 @@

 static long rk_tsadcv2_code_to_temp(u32 code)
 {
-	int high, low, mid;
-
-	low = 0;
-	high = ARRAY_SIZE(v2_code_table) - 1;
-	mid = (high + low) / 2;
-
-	if (code > v2_code_table[low].code || code < v2_code_table[high].code)
-		return 125000; /* No code available, return max temperature */
-
-	while (low <= high) {
-		if (code >= v2_code_table[mid].code && code <
-		    v2_code_table[mid - 1].code)
-			return v2_code_table[mid].temp;
+	unsigned int low = 0;
+	unsigned int high = ARRAY_SIZE(v2_code_table) - 1;
+	unsigned int mid = (low + high) / 2;
+	unsigned int num;
+	unsigned long denom;
+
+	/* Invalid code, return -EAGAIN */
+	if (code > TSADCV2_DATA_MASK)
+		return -EAGAIN;
+
+	while (low <= high && mid) {
+		if (code >= v2_code_table[mid].code &&
+		    code < v2_code_table[mid - 1].code)
+			break;
 		else if (code < v2_code_table[mid].code)
 			low = mid + 1;
 		else
@@ -213,7 +214,16 @@
 		mid = (low + high) / 2;
 	}

-	return 125000;
+	/*
+	 * The 5C granularity provided by the table is too much. Let's
+	 * assume that the relationship between sensor readings and
+	 * temperature between 2 table entries is linear and interpolate
+	 * to produce less granular result.
+	 */
+	num = v2_code_table[mid].temp - v2_code_table[mid - 1].temp;
+	num *= v2_code_table[mid - 1].code - code;
+	denom = v2_code_table[mid - 1].code - v2_code_table[mid].code;
+	return v2_code_table[mid - 1].temp + (num / denom);
 }

 /**


tty: xuartps: Fix "may be used uninitialized" build warning

Initialize varibles for which a 'may be used uninitalized' warning is
issued.

Signed-off-by: Soren Brinkmann <f9793267bd24439886cd4a142f9642a9bcc6364b@xilinx.com>
Reported-by: kbuild test robot <24f7fe9d205c8a9f6ade0c2894e14303ca16087f@intel.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/tty/serial/xilinx_uartps.c
+++ drivers/tty/serial/xilinx_uartps.c
@@ -389,7 +389,7 @@
 		unsigned int baud)
 {
 	unsigned int calc_baud;
-	u32 cd, bdiv;
+	u32 cd = 0, bdiv = 0;
 	u32 mreg;
 	int div8;
 	struct xuartps *xuartps = port->private_data;


usb: chipidea: msm: add missing section annotation

No functional changes, it will just free up some
code if we don't have hotplug.

Signed-off-by: Felipe Balbi <94dddeeef08b001e003cce128ddc162a4e2c6cd2@ti.com>
Signed-off-by: Alexander Shishkin <0125b3d2989cefbb754a245b989e89659aa67db8@linux.intel.com>
Signed-off-by: Richard Zhao <bbd97e76288330e4315e9a841fcfb77b747adc43@freescale.com>
Acked-by: Marek Vasut <f40600653b33f5282fa4c5daf377dfc444fb4625@denx.de>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/usb/chipidea/ci13xxx_msm.c
+++ drivers/usb/chipidea/ci13xxx_msm.c
@@ -55,7 +55,7 @@
 	.notify_event		= ci13xxx_msm_notify_event,
 };

-static int ci13xxx_msm_probe(struct platform_device *pdev)
+static int __devinit ci13xxx_msm_probe(struct platform_device *pdev)
 {
 	struct platform_device *plat_ci;
 	int ret;


USB: INTOVA Pixtreme camera mass storage device

FIX_CAPACITY is all that's needed.

Cc: Alan Stern <75ea6bb7bfc1186f92d26164de5f9268c9a45b59@rowland.harvard.edu>
Cc: Phil Dibowitz <e888d2bd6f13f82caa51a37c03d034c76f661ba3@ipom.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

--- drivers/usb/storage/unusual_devs.h
+++ drivers/usb/storage/unusual_devs.h
@@ -1349,6 +1349,13 @@
 		US_SC_DEVICE, US_PR_DEVICE, NULL,
 		US_FL_FIX_INQUIRY),

+/* Reported by Rohan Hart <rohan.hart17@gmail.com> */
+UNUSUAL_DEV(  0x2770, 0x915d, 0x0010, 0x0010,
+		"INTOVA",
+		"Pixtreme",
+		US_SC_DEVICE, US_PR_DEVICE, NULL,
+		US_FL_FIX_CAPACITY ),
+
 /*
  * Entry for Jenoptik JD 5200z3
  *


C API: implementation (pt.2) for Check()/Download()/Install()

Signed-off-by: Mykola Chekhovoi <16e13a19651209f8ea6446a9a235cfc29e69905f@here.com>

--- src/libaktualizr-c/test/api-test.c
+++ src/libaktualizr-c/test/api-test.c
@@ -66,54 +66,68 @@
   }

   u = Aktualizr_updates_check(a);
-  if (u) {
-    size_t n = Aktualizr_get_targets_num(u);
-    printf("Found new updates for %zu target(s)\n", n);
-    for (size_t i = 0; i < n; i++) {
-      t = Aktualizr_get_nth_target(u, i);
-      char *name = Aktualizr_get_target_name(t);
-      printf("Downloading target %s\n", name);
-      free(name);
-      name = NULL;
+  if (u == NULL) {
+    return EXIT_FAILURE;
+  }

-      Aktualizr_download_target(a, t);
-      printf("Installing...\n");
+  size_t targets_num = Aktualizr_get_targets_num(u);
+  printf("Found new updates for %zu target(s)\n", targets_num);
+  if (targets_num == 0) {
+    return EXIT_FAILURE;
+  }

-      Aktualizr_install_target(a, t);
-      printf("Installation completed\n");
+  for (size_t i = 0; i < targets_num; i++) {
+    t = Aktualizr_get_nth_target(u, i);
+    char *name = Aktualizr_get_target_name(t);
+    if (name == NULL) {
+      return EXIT_FAILURE;
+    }
+    printf("Downloading target %s\n", name);

-      void *handle = Aktualizr_open_stored_target(a, t);
-      if (!handle) {
-        return EXIT_FAILURE;
-      }
+    err = Aktualizr_download_target(a, t);
+    printf("Installing...\n");
+    if (err) {
+      return EXIT_FAILURE;
+    }

-      const size_t bufSize = 1024;
-      uint8_t *buf = malloc(bufSize);
-      size_t size = Aktualizr_read_stored_target(handle, buf, bufSize);
-      name = Aktualizr_get_target_name(t);
-      printf("Downloading target %s: extracted %li bytes (buffer size = %li), content:\n", name, (long int)size,
-             (long int)bufSize);
-      free(name);
-      name = NULL;
+    err = Aktualizr_install_target(a, t);
+    printf("Installation completed\n");
+    if (err) {
+      return EXIT_FAILURE;
+    }

-      for (size_t iBuf = 0; iBuf < size; ++iBuf) {
-        printf("%c", buf[iBuf]);
-      }
-      if (size == bufSize) {
-        printf(" ... (end of content skipped)");
-      }
-      free(buf);
-      buf = NULL;
-      if (size == 0) {
-        return EXIT_FAILURE;
-      }
+    void *handle = Aktualizr_open_stored_target(a, t);
+    if (!handle) {
+      return EXIT_FAILURE;
+    }

-      err = Aktualizr_close_stored_target(handle);
-      if (err) {
-        return EXIT_FAILURE;
-      }
+    const size_t bufSize = 1024;
+    uint8_t *buf = malloc(bufSize);
+    size_t size = Aktualizr_read_stored_target(handle, buf, bufSize);
+    printf("Downloading target %s: extracted %li bytes (buffer size = %li), content:\n", name, (long int)size,
+           (long int)bufSize);
+    free(name);
+    name = NULL;
+
+    if (size == 0) {
+      return EXIT_FAILURE;
+    }
+
+    for (size_t iBuf = 0; iBuf < size; ++iBuf) {
+      printf("%c", buf[iBuf]);
+    }
+    if (size == bufSize) {
+      printf(" ... (end of content skipped)");
+    }
+    free(buf);
+    buf = NULL;
+
+    err = Aktualizr_close_stored_target(handle);
+    if (err) {
+      return EXIT_FAILURE;
     }
   }
+
 #if 0
   err = Aktualizr_uptane_cycle(a);
   if (err) {


lib/repo: [scan-build] Quiet a dead store warning

False positive, just add a pacifier.

--- src/libostree/ostree-repo-commit.c
+++ src/libostree/ostree-repo-commit.c
@@ -1588,7 +1588,6 @@
                                  GCancellable   *cancellable,
                                  GError        **error)
 {
-  g_autoptr(_OstreeRepoAutoTransaction) txn = NULL;
   guint64 reserved_bytes = 0;

   g_return_val_if_fail (self->in_transaction == FALSE, FALSE);
@@ -1596,7 +1595,8 @@
   g_debug ("Preparing transaction in repository %p", self);

   /* Set up to abort the transaction if we return early from this function. */
-  txn = self;
+  g_autoptr(_OstreeRepoAutoTransaction) txn = self;
+  (void) txn; /* Add use to silence static analysis */

   memset (&self->txn.stats, 0, sizeof (OstreeRepoTransactionStats));

@@ -1652,7 +1652,7 @@
     return FALSE;

   /* Success: do not abort the transaction when returning. */
-  txn = NULL;
+  txn = NULL; (void) txn;

   if (out_transaction_resume)
     *out_transaction_resume = ret_transaction_resume;


Return on error immediately in export-trie parsing

--- src/macho_file_parse_export_trie.c
+++ src/macho_file_parse_export_trie.c
@@ -69,12 +69,12 @@
         return iter;
     }

+    if (unlikely(iter == end)) {
+        return NULL;
+    }
+
     uint8_t bits = uleb_byte_get_bits(byte);
     uint32_t result = bits;
-
-    if (unlikely(iter == end)) {
-        return NULL;
-    }

     for (uint8_t shift = 7; shift != 28; shift += 7) {
         byte = *iter;
@@ -157,12 +157,12 @@
         return iter;
     }

+    if (unlikely(iter == end)) {
+        return NULL;
+    }
+
     uint8_t bits = uleb_byte_get_bits(byte);
     uint64_t result = bits;
-
-    if (unlikely(iter == end)) {
-        return NULL;
-    }

     for (uint8_t shift = 7; shift != 63; shift += 7) {
         byte = *iter;


Add function to remove shapes from LineLayout

--- src/alfons/lineLayout.h
+++ src/alfons/lineLayout.h
@@ -109,6 +109,17 @@
         m_shapes.insert(m_shapes.end(), _shapes.begin(), _shapes.end());
     }

+    void removeShapes(size_t _start, size_t _end) {
+        if (_start > _end || _end > shapes().size()) { return; }
+
+        auto it = m_shapes.begin() + _start;
+        const auto end = m_shapes.begin() + _end;
+
+        for (; it != end; ++it) { m_advance -= it->advance;}
+
+        m_shapes.erase(m_shapes.begin() + _start, end);
+    }
+
     std::vector<Shape>& shapes() { return m_shapes; }
     const std::vector<Shape>& shapes() const { return m_shapes; }


minor style changes

minor style changes

--- chasean.adventure.c
+++ chasean.adventure.c
@@ -3,7 +3,15 @@
  chasean

-I used the prototype-first method for building this assignment for the following reasons:
+MY IMPLEMENTATION USES (EMOJI): UNICODE CODEPOINTS BETWEEN U+1F3E0 AND U+1F3E9.
+IF YOUR TERMINAL DOES NOT SUPPORT THESE
+CODEPOINTS GRAPHICALLY THE PROGRAM MAY BE DIFFICULT TO USE.
+
+
+I used the prototype-first method for building this assignment.
+I drafted the solution in a seperate prototype.py and ported the app to c.
+
+I followed the prototype-first method for the following reasons:

 * I've never used the prototype-first method and I wanted to try it
 * I have more practice in python than in c so I wanted to think through the problem in a familiar language
@@ -11,20 +19,22 @@
 * This assignment had basically two parts:
 - Figuring out the solution
 - Figuring out how to actually write the solution in c
- (so it makes sense to figure out the solution in a different language)
-
-My experience with the prototype-first solution:
-
- Overall it felt longer, but I liked it because I was able to flesh out the solution
+ (so it makes sense to figure out the solution in a higher-level language)
+
+How I felt about the prototype-first method:
+
+ Overall it felt longer, but I liked it because I was able to build out a solution
  and get a really strong feeling for its correctness before I dove in and did the implementation.
- (Honestly it probably overall would have taken longer to start in c first, but it did FEEL longer)
-
- It gave me a strong structure to start with which I liked and allowed me to just bypass any "writers block" or
+ (Honestly it may have overall taken longer to start in c first, but it did FEEL longer)
+
+ It gave me a strong structure to start with which I liked and allowed me to just bypass any "writer's block" or
  distractions I might have had with minor c details starting in c. In that way I think it was less risky
  time-wise to start an implementation in python first.

  "Computer-runnable pseudo-code" <- I definitely got that impression. I was also able to get a sense of what my
  data structures should look like while running so that was a huge plus while debugging.
+
+

  */
 #include <stdio.h>
@@ -95,7 +105,6 @@
 // From: http://stackoverflow.com/a/7775172
 void strip(char *buf) { for (int i = 0, j = 0; (buf[j] = buf[i]); j += !isspace(buf[i++])); }

-//       Helper functions
 // -------------------------

 // Converts a room name to its index in the room_index
@@ -166,7 +175,6 @@
     }
 }

-// Build all rooms
 void build_rooms() {
     assert(start_room != end_room);
     int i = 0;
@@ -184,6 +192,7 @@
     }
 }

+// This resets the game data so it can be read back in.
 void reset() {
     start_room = 0;
     end_room = 0;
@@ -213,9 +222,9 @@
         sscanf(buf, room_file_format_footer, room_type);
     }
     assert(this_room_index != -1);
-    if (strcmp(room_type, "START_ROOM") == 0)
+    if (strcmp(room_type, room_types[START_ROOM]) == 0)
         start_room = this_room_index;
-    if (strcmp(room_type, "END_ROOM") == 0)
+    if (strcmp(room_type, room_types[END_ROOM]) == 0)
         end_room = this_room_index;
 }

@@ -244,7 +253,7 @@
     int input_room_index = room_name_to_room_index(buf);
     int in_room_index = room_index != -1;
     if (in_room_index && in_room_connections(buf, room_index)) {
-        steps += 1;
+        steps++;
         sprintf(buf, "%s", room_path_buffer);
         sprintf(room_path_buffer, "%s%s\n", buf, room_names[input_room_index]);
         if (input_room_index == end_room) {
@@ -296,4 +305,4 @@
     enter_room(room_names[start_room]);

     return 0;
-}+}


Fix Texture:setFilter;

Fix Texture:setFilter;

--- src/api/types/texture.c
+++ src/api/types/texture.c
@@ -91,7 +91,7 @@
 int l_lovrTextureSetFilter(lua_State* L) {
   Texture* texture = luax_checktype(L, 1, Texture);
   FilterMode mode = luaL_checkoption(L, 2, NULL, FilterModes);
-  float anisotropy = luaL_optnumber(L, 4, 1.);
+  float anisotropy = luaL_optnumber(L, 3, 1.);
   TextureFilter filter = { .mode = mode, .anisotropy = anisotropy };
   lovrTextureSetFilter(texture, filter);
   return 0;


mec1322: handle dummy GPIO gracefully

mec1322: handle dummy GPIO gracefully

When a GPIO signal is defined by GPIO_SIGNAL_NOT_IMPLEMENTED, it should
still be able to call various GPIO methods on that GPIO signal. Since
__builtin_clz dies when the value passed in is zero, we need to check
this before calling __builtin_clz.

BUG=chrome-os-partner:24107
TEST='sysjump RW' and the system doesn't crash
BRANCH=None

Change-Id: I5025a2f218d549316fe096c07bd3c7207fe9dbc2
Signed-off-by: Vic (Chun-Ju) Yang <5fd92abeee651458f98e2856f4f200ee971cee4d@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/180183
Reviewed-by: Randall Spangler <62698fdbb84d1779579ee80c3f39fac22017e5bc@chromium.org>

--- chip/mec1322/gpio.c
+++ chip/mec1322/gpio.c
@@ -46,8 +46,13 @@
 test_mockable int gpio_get_level(enum gpio_signal signal)
 {
 	uint32_t mask = gpio_list[signal].mask;
-	int i = 31 - __builtin_clz(mask);
-	uint32_t val = MEC1322_GPIO_CTL(gpio_list[signal].port, i);
+	int i;
+	uint32_t val;
+
+	if (mask == 0)
+		return 0;
+	i = 31 - __builtin_clz(mask);
+	val = MEC1322_GPIO_CTL(gpio_list[signal].port, i);

 	if (val & (1 << 9)) /* Output */
 		return (val & (1 << 16)) ? 1 : 0;
@@ -58,7 +63,12 @@
 void gpio_set_level(enum gpio_signal signal, int value)
 {
 	uint32_t mask = gpio_list[signal].mask;
-	int i = 31 - __builtin_clz(mask);
+	int i;
+
+	if (mask == 0)
+		return;
+	i = 31 - __builtin_clz(mask);
+
 	if (value)
 		MEC1322_GPIO_CTL(gpio_list[signal].port, i) |= (1 << 16);
 	else
@@ -132,10 +142,15 @@

 int gpio_enable_interrupt(enum gpio_signal signal)
 {
-	int i = 31 - __builtin_clz(gpio_list[signal].mask);
-	int port = gpio_list[signal].port;
-	int girq_id = int_map[port].girq_id;
-	int bit_id = (port - int_map[port].port_offset) * 8 + i;
+	int i, port, girq_id, bit_id;
+
+	if (gpio_list[signal].mask == 0)
+		return EC_SUCCESS;
+
+	i = 31 - __builtin_clz(gpio_list[signal].mask);
+	port = gpio_list[signal].port;
+	girq_id = int_map[port].girq_id;
+	bit_id = (port - int_map[port].port_offset) * 8 + i;

 	MEC1322_INT_ENABLE(girq_id) |= (1 << bit_id);
 	MEC1322_INT_BLK_EN |= (1 << girq_id);
@@ -145,10 +160,15 @@

 int gpio_disable_interrupt(enum gpio_signal signal)
 {
-	int i = 31 - __builtin_clz(gpio_list[signal].mask);
-	int port = gpio_list[signal].port;
-	int girq_id = int_map[port].girq_id;
-	int bit_id = (port - int_map[port].port_offset) * 8 + i;
+	int i, port, girq_id, bit_id;
+
+	if (gpio_list[signal].mask == 0)
+		return EC_SUCCESS;
+
+	i = 31 - __builtin_clz(gpio_list[signal].mask);
+	port = gpio_list[signal].port;
+	girq_id = int_map[port].girq_id;
+	bit_id = (port - int_map[port].port_offset) * 8 + i;

 	MEC1322_INT_DISABLE(girq_id) |= (1 << bit_id);


i2c call init when pull or frequency are modified

--- hydrabus/hydrabus_mode_i2c.c
+++ hydrabus/hydrabus_mode_i2c.c
@@ -86,6 +86,7 @@
 				proto->dev_gpio_pull = MODE_CONFIG_DEV_GPIO_NOPULL;
 				break;
 			}
+			bsp_i2c_init(proto->dev_num, proto);
 			break;
 		case T_FREQUENCY:
 			t += 2;
@@ -100,6 +101,7 @@
 				cprintf(con, "Invalid frequency.\r\n");
 				return t;
 			}
+			bsp_i2c_init(proto->dev_num, proto);
 			break;
 		default:
 			return 0;


INTEGRATION: CWS ooo19126 (1.2.102); FILE MERGED 2005/09/05 17:39:45 rt 1.2.102.1: #i54170# Change license header: remove SISSL

--- idlc/source/preproc/tokens.c
+++ idlc/source/preproc/tokens.c
@@ -1,61 +1,35 @@
 /*************************************************************************
  *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
  *  $RCSfile: tokens.c,v $
  *
- *  $Revision: 1.2 $
- *
- *  last change: $Author: hr $ $Date: 2003-03-26 12:11:12 $
- *
- *  The Contents of this file are made available subject to the terms of
- *  either of the following licenses
- *
- *         - GNU Lesser General Public License Version 2.1
- *         - Sun Industry Standards Source License Version 1.1
- *
- *  Sun Microsystems Inc., October, 2000
- *
- *  GNU Lesser General Public License Version 2.1
- *  =============================================
- *  Copyright 2000 by Sun Microsystems, Inc.
- *  901 San Antonio Road, Palo Alto, CA 94303, USA
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License version 2.1, as published by the Free Software Foundation.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- *  MA  02111-1307  USA
- *
- *
- *  Sun Industry Standards Source License Version 1.1
- *  =================================================
- *  The contents of this file are subject to the Sun Industry Standards
- *  Source License Version 1.1 (the "License"); You may not use this file
- *  except in compliance with the License. You may obtain a copy of the
- *  License at http://www.openoffice.org/license.html.
- *
- *  Software provided under this License is provided on an "AS IS" basis,
- *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- *  See the License for the specific provisions governing your rights and
- *  obligations concerning the Software.
- *
- *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- *  Copyright: 2000 by Sun Microsystems, Inc.
- *
- *  All Rights Reserved.
- *
- *  Contributor(s): _______________________________________
- *
+ *  $Revision: 1.3 $
+ *
+ *  last change: $Author: rt $ $Date: 2005-09-07 18:16:16 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    This library is free software; you can redistribute it and/or
+ *    modify it under the terms of the GNU Lesser General Public
+ *    License version 2.1, as published by the Free Software Foundation.
+ *
+ *    This library is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *    Lesser General Public License for more details.
+ *
+ *    You should have received a copy of the GNU Lesser General Public
+ *    License along with this library; if not, write to the Free Software
+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ *    MA  02111-1307  USA
  *
  ************************************************************************/
 #include <stdio.h>


Code Word はキャッシュせず、動的に生成するように変更した。これによりクラス数の多い問題に対しても適用できるようになった。

git-svn-id: 3507153f7f2a502978d43a270f21b34bb2e07470@999 b31369ee-dac5-0310-8161-cccb92f82ee5

--- mist/machine_learning.h
+++ mist/machine_learning.h
@@ -60,6 +60,7 @@
 #define __ASYMMETRIC_WEIGHTING__		1
 #define __ONE_PER_CLASS_CODE_WORD__		0
 #define __DEBUG_OUTPUT_LEVEL__			0
+#define __NUMBER_OF_INNER_LOOPS__		10

 // mistOԂ̎n܂
 _MIST_BEGIN
@@ -563,33 +564,6 @@
 #else
 				// code word  ECC x[Xō
 				size_type nhypothesis = categories_.size( ) == 2 ? 2 : __power_of_two__( categories_.size( ) - 1 ) - 1;
-				mist::matrix< bool > code_word_pool( categories_.size( ), nhypothesis );
-
-				if( nhypothesis == 2 )
-				{
-					code_word_pool( 0, 0 ) = true;
-					code_word_pool( 1, 1 ) = true;
-				}
-				else
-				{
-					for( size_type c = 0 ; c < code_word_pool.cols( ) ; c++ )
-					{
-						code_word_pool( 0, c ) = true;
-					}
-
-					for( size_type r = 1 ; r < code_word_pool.rows( ); r++ )
-					{
-						size_type d = ( code_word_pool.cols( ) + 1 ) / __power_of_two__( r );
-
-						for( size_type c = 0 ; c < code_word_pool.cols( ) ; c++ )
-						{
-							if( ( c / d ) % 2 == 1 )
-							{
-								code_word_pool( r, c ) = true;
-							}
-						}
-					}
-				}
 #endif

 				// AdaBoost ɂ苭ʊwK
@@ -602,16 +576,15 @@
 #if defined( __ONE_PER_CLASS_CODE_WORD__ ) && __ONE_PER_CLASS_CODE_WORD__ == 1
 					myu[ t % categories_.size( ) ] = true;
 #else
-					for( size_type c = 0 ; c < code_word_pool.rows( ); c++ )
-					{
-						myu[ c ] = code_word_pool( c, t % nhypothesis );
+					myu[ 0 ] = true;
+					for( size_type r = 1 ; r < myu.size( ) ; r++ )
+					{
+						// code word  ECC x[XœIɍ
+						size_type c = t % nhypothesis;
+						size_type d = ( nhypothesis + 1 ) / __power_of_two__( r );
+						myu[ r ] = ( c / d ) % 2 == 1;
 					}
 #endif
-					// ㎯ʊ̊wKpJeSf[^
-					for( size_type i = 0 ; i < fcategories.size( ) ; i++ )
-					{
-						fcategories[ i ] = myu[ fcatemap[ i ] ];
-					}

 #if defined( __DEBUG_OUTPUT_LEVEL__ ) && __DEBUG_OUTPUT_LEVEL__ >= 3
 					// ㎯ʊ̊wKpJeSf[^
@@ -626,8 +599,14 @@
 					weak_classifiers_.push_back( weak_classifier_type( ) );
 					weak_classifier_type &weak = weak_classifiers_.back( );

-					for( size_type m = 0 ; m < 10 ; m++ )
-					{
+					for( size_type m = 0 ; m < __NUMBER_OF_INNER_LOOPS__ ; m++ )
+					{
+						// ㎯ʊ̊wKpJeSf[^
+						for( size_type i = 0 ; i < fcategories.size( ) ; i++ )
+						{
+							fcategories[ i ] = myu[ fcatemap[ i ] ];
+						}
+
 						// d݂𐳋K
 						double Ut = 0.0;
 						for( size_type i = 0 ; i < features.size( ) ; i++ )
@@ -669,7 +648,7 @@
 						weak.learn( features, fcategories );
 						//std::cout << "l: " << weak.threshold( ) << ", : " << ( weak.sign( ) < 0.0 ? "-" : "+" ) << ", ԍ: " << weak.index( ) << std::endl;

-						if( m < 9 )
+						if( m < __NUMBER_OF_INNER_LOOPS__ - 1 )
 						{
 							for( size_type i = 0 ; i < rpweight.size( ) ; i++ )
 							{
@@ -711,12 +690,6 @@
 							{
 								// OƂ܂Ȃ̂ŏI
 								break;
-							}
-
-							// ㎯ʊ̊wKpJeSf[^
-							for( size_type i = 0 ; i < fcategories.size( ) ; i++ )
-							{
-								fcategories[ i ] = myu[ fcatemap[ i ] ];
 							}
 						}
 					}
@@ -832,7 +805,7 @@
 						D[ i ] /= Zt;
 					}

-					if( ( ( t + 1 ) % 5 ) == 0 )
+					//if( ( ( t + 1 ) % 5 ) == 0 )
 					{
 						double __classification_error__ = error_rate( features );


audio_thread_alsa: select capture device

--- src/audio_thread_alsa.c
+++ src/audio_thread_alsa.c
@@ -320,7 +320,7 @@
 static
 audio_stream *
 alsa_create_stream(audio_stream_direction direction, unsigned int sample_rate,
-                   unsigned int sample_frame_count)
+                   unsigned int sample_frame_count, const char *pcm_name)
 {
     audio_stream *as;
     snd_pcm_hw_params_t *hw_params;
@@ -347,11 +347,10 @@
         }                                                                               \
     } while (0)

-    // TODO: select device
     if (direction == STREAM_PLAYBACK)
-        CHECK_A(snd_pcm_open, (&as->pcm, "default", SND_PCM_STREAM_PLAYBACK, 0));
+        CHECK_A(snd_pcm_open, (&as->pcm, pcm_name, SND_PCM_STREAM_PLAYBACK, 0));
     else
-        CHECK_A(snd_pcm_open, (&as->pcm, "default", SND_PCM_STREAM_CAPTURE, 0));
+        CHECK_A(snd_pcm_open, (&as->pcm, pcm_name, SND_PCM_STREAM_CAPTURE, 0));

     CHECK_A(snd_pcm_hw_params_malloc, (&hw_params));
     CHECK_A(snd_pcm_hw_params_any, (as->pcm, hw_params));
@@ -418,13 +417,70 @@
 alsa_create_playback_stream(unsigned int sample_rate, unsigned int sample_frame_count,
                             audio_stream_playback_cb_f *cb, void *cb_user_data)
 {
-    audio_stream *as = alsa_create_stream(STREAM_PLAYBACK, sample_rate, sample_frame_count);
+    audio_stream *as = alsa_create_stream(STREAM_PLAYBACK, sample_rate, sample_frame_count,
+                                          "default");
     if (!as)
         return NULL;

     as->playback_cb = cb;
     as->cb_user_data = cb_user_data;
     return as;
+}
+
+static
+char *
+find_pcm_name(const char *device_longname)
+{
+    char *pcm_name = NULL;
+    int   card = -1;
+    int   done = 0;
+
+    if (!device_longname)
+        return strdup("default");
+
+    while (!done) {
+        int err = snd_card_next(&card);
+        if (err != 0)
+            break;
+        if (card == -1)
+            break;
+
+        char *longname = NULL;
+        if (snd_card_get_longname(card, &longname) != 0)
+            goto next_0;
+
+        if (!longname)
+            goto next_0;
+
+        if (strcmp(device_longname, longname) != 0)
+            goto next_2;
+
+        void **hints;
+        if (snd_device_name_hint(card, "pcm", &hints) != 0)
+            goto next_2;
+
+        for (int k = 0; hints[k] != NULL; k ++) {
+            pcm_name = snd_device_name_get_hint(hints[k], "NAME");
+            if (strncmp(pcm_name, "default:", strlen("default:")) == 0) {
+                done = 1;
+                goto next_3;
+            }
+            free(pcm_name);
+            pcm_name = NULL;
+        }
+
+    next_3:
+        snd_device_name_free_hint(hints);
+    next_2:
+        free(longname);
+    next_0:
+        continue;
+    }
+
+    if (!pcm_name)
+        pcm_name = strdup("default");
+
+    return pcm_name;
 }

 static
@@ -433,8 +489,10 @@
                            audio_stream_capture_cb_f *cb, void *cb_user_data,
                            const char *longname)
 {
-    // TODO: implement card selection
-    audio_stream *as = alsa_create_stream(STREAM_CAPTURE, sample_rate, sample_frame_count);
+    char *pcm_name = find_pcm_name(longname);
+    audio_stream *as = alsa_create_stream(STREAM_CAPTURE, sample_rate, sample_frame_count,
+                                          pcm_name);
+    free(pcm_name);

     if (!as)
         return NULL;


When saving password, add scheme prefix also if password begins with { but doesn't contain }. This fixes an assert-crash later.

--- src/auth/auth-request.c
+++ src/auth/auth-request.c
@@ -961,7 +961,11 @@
 			return;
 		}

-		if (*value == '{') {
+		/* if the password starts with '{' it most likely contains
+		   also '}'. check it anyway to make sure, because we
+		   assert-crash later if it doesn't exist. this could happen
+		   if plaintext passwords are used. */
+		if (*value == '{' && strchr(value, '}') != NULL) {
 			request->passdb_password =
 				p_strdup(request->pool, value);
 		} else {


If trying to log in with password having illegal characters, make sure we
fail early.

--HG--
branch : HEAD

--- src/auth/auth-request.c
+++ src/auth/auth-request.c
@@ -426,6 +426,23 @@
 	auth_request_verify_plain_callback_finish(result, request);
 }

+static bool password_has_illegal_chars(const char *password)
+{
+	for (; *password != '\0'; password++) {
+		switch (*password) {
+		case '\001':
+		case '\t':
+		case '\r':
+		case '\n':
+			/* these characters have a special meaning in internal
+			   protocols, make sure the password doesn't
+			   accidentally get there unescaped. */
+			return TRUE;
+		}
+	}
+	return FALSE;
+}
+
 void auth_request_verify_plain(struct auth_request *request,
 			       const char *password,
 			       verify_plain_callback_t *callback)
@@ -443,7 +460,14 @@
 			"Attempted master login with no master passdbs");
 		callback(PASSDB_RESULT_USER_UNKNOWN, request);
 		return;
-        }
+	}
+
+	if (password_has_illegal_chars(password)) {
+		auth_request_log_info(request, "passdb",
+			"Attempted login with password having illegal chars");
+		callback(PASSDB_RESULT_USER_UNKNOWN, request);
+		return;
+	}

         passdb = request->passdb->passdb;
 	if (request->mech_password == NULL)


Fixed pass=yes with blocking passdbs. Also master_user wasn't exported correctly to blocking passdbs.

--- src/auth/auth-request.c
+++ src/auth/auth-request.c
@@ -123,7 +123,7 @@
 	str_append(str, request->service);

         if (request->master_user != NULL) {
-                str_append(str, "master_user=");
+                str_append(str, "\tmaster_user=");
                 str_append(str, request->master_user);
         }

@@ -145,6 +145,8 @@
 	}
 	if (request->secured)
 		str_append(str, "\tsecured=1");
+	if (request->skip_password_check)
+		str_append(str, "\tskip_password_check=1");
 }

 bool auth_request_import(struct auth_request *request,
@@ -175,7 +177,10 @@
 		request->secured = TRUE;
 	else if (strcmp(key, "nologin") == 0)
 		request->no_login = TRUE;
-	else
+	else if (strcmp(key, "skip_password_check") == 0) {
+		i_assert(request->master_user !=  NULL);
+		request->skip_password_check = TRUE;
+	} else
 		return FALSE;

 	return TRUE;


Remove prefix to make shrinker ocurrences clearer

Removing 'shrinker' prefix from some messages in order to make shrinker occurrences clearer.

Example:
shrinker:       processing request to free %08d bytes.
                starting with %d things.
                finishing with %d things.
                %08d bytes of memory were freed!

--- memory-hog.c
+++ memory-hog.c
@@ -53,7 +53,7 @@
         return 0;
     }
     printf("shrinker:\tprocessing request to free %08d bytes.\n", target);
-    printf("shrinker:\tstarting with %d things.\n", thing_count(cache.head));
+    printf("\t\tstarting with %d things.\n", thing_count(cache.head));
     thing = cache.head;
     while (freed <= target) {
         cache.head = thing->next;
@@ -61,7 +61,7 @@
         freed += sizeof(struct item);
         thing = cache.head;
     }
-    printf("shrinker:\tfinishing with %d things.\n", thing_count(cache.head));
+    printf("\t\tfinishing with %d things.\n", thing_count(cache.head));
     printf("\t\t%08d bytes of memory were freed!\n", freed);
     sleep(2);
     pthread_mutex_unlock(&cache.lock);


Code cleanup: Don't mix up '\0' and NULL.

--- src/auth/passdb-cache.c
+++ src/auth/passdb-cache.c
@@ -118,12 +118,10 @@
 	*result_r = PASSDB_RESULT_OK;
 	*password_r = list[0];
 	*scheme_r = password_get_scheme(password_r);
-	i_assert(*scheme_r != NULL || *password_r == '\0');
+	i_assert(*scheme_r != NULL || *password_r == NULL);

-	if (*password_r == '\0') {
-		*password_r = NULL;
+	if (*password_r == NULL)
 		*result_r = PASSDB_RESULT_SCHEME_NOT_AVAILABLE;
-	}
 	return TRUE;
 }


#258 Change C binding load.c file generation to include package header

--- generator/c/project/src/c_project.c
+++ generator/c/project/src/c_project.c
@@ -10,6 +10,7 @@
     cx_id filename;
     g_file file;
     cx_string snippet;
+    cx_id topLevelName;

     sprintf(filename, "%s__load.c", g_getName(g));

@@ -23,7 +24,7 @@
     g_fileWrite(file, " * This file is generated. Only insert code in appropriate places.\n");
     g_fileWrite(file, " */\n\n");

-    g_fileWrite(file, "#include \"%s__meta.h\"\n\n", g_getName(g));
+    g_fileWrite(file, "#include \"%s.h\"\n\n", g_fullOid(g, g_getCurrent(g), topLevelName));

     if ((snippet = g_fileLookupHeader(file, ""))) {
         g_fileWrite(file, "/* $header()");


added sony rx100m3

added sony rx100m3

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -1037,6 +1037,9 @@
 	/* https://sourceforge.net/p/gphoto/feature-requests/456/ */
 	{"Sony:Alpha-A7S (MTP)",      0x054c, 0x08e2, 0},

+	/* David Farrier <farrier@iglou.com> */
+	{"Sony:RX100M3 (MTP)",        0x054c, 0x08e3, 0},
+
 	/* Markus Oertel */
 	{"Sony:Alpha-A5100 (MTP)",    0x054c, 0x08e7, 0},

@@ -8625,6 +8628,7 @@
 				int mode = 0x15;	/* default for EOS M and newer Powershot SX */

 				if (!strcmp(params->deviceinfo.Model,"Canon EOS M6 Mark II")) mode = 0x1;
+				if (!strcmp(params->deviceinfo.Model,"Canon EOS M10")) mode = 0x1;

 				/* according to reporter only needed in config.c part
 				if (!strcmp(params->deviceinfo.Model,"Canon PowerShot G5 X")) mode = 0x11;


Small doc fix

Small doc fix

--- include/serialbox/Core/Frontend/STELLA/DataFieldInfo.h
+++ include/serialbox/Core/Frontend/STELLA/DataFieldInfo.h
@@ -154,22 +154,22 @@
   /// \brief The size of the halo in positive i-direction
   int iPlusHaloSize() const;

-  /// \brief The size of the halo in negative i-direction
+  /// \brief The size of the halo in negative j-direction
   int jMinusHaloSize() const;

-  /// \brief The size of the halo in positive i-direction
+  /// \brief The size of the halo in positive j-direction
   int jPlusHaloSize() const;

-  /// \brief The size of the halo in negative i-direction
+  /// \brief The size of the halo in negative k-direction
   int kMinusHaloSize() const;

-  /// \brief The size of the halo in positive i-direction
+  /// \brief The size of the halo in positive k-direction
   int kPlusHaloSize() const;

-  /// \brief The size of the halo in negative i-direction
+  /// \brief The size of the halo in negative l-direction
   int lMinusHaloSize() const;

-  /// \brief The size of the halo in positive i-direction
+  /// \brief The size of the halo in positive l-direction
   int lPlusHaloSize() const;

   /// \brief The number of bytes occupied by the field


backend/headless: create renderer after wlr_backend_init

We were calling wlr_renderer_autocreate before wlr_backend_init,
which caused a NULL dereference on wlr_backend.impl.

--- backend/headless/backend.c
+++ backend/headless/backend.c
@@ -120,6 +120,14 @@
 	wl_list_init(&backend->input_devices);

 	backend->allocator = allocator;
+
+	if (renderer == NULL) {
+		renderer = wlr_renderer_autocreate(&backend->backend);
+		if (!renderer) {
+			wlr_log(WLR_ERROR, "Failed to create renderer");
+			return false;
+		}
+	}
 	backend->renderer = renderer;

 	const struct wlr_drm_format_set *formats =
@@ -219,66 +227,9 @@
 		goto error_dup;
 	}

-	struct wlr_renderer *renderer = wlr_renderer_autocreate(&backend->backend);
-	if (!renderer) {
-		wlr_log(WLR_ERROR, "Failed to create renderer");
-		goto error_renderer;
-	}
-
-	if (!backend_init(backend, display, &gbm_alloc->base, renderer)) {
+	if (!backend_init(backend, display, &gbm_alloc->base, NULL)) {
 		goto error_init;
 	}
-
-	return &backend->backend;
-
-error_init:
-	wlr_renderer_destroy(renderer);
-error_renderer:
-	wlr_allocator_destroy(&gbm_alloc->base);
-error_dup:
-	close(backend->drm_fd);
-error_drm_fd:
-	free(backend);
-	return NULL;
-}
-
-struct wlr_backend *wlr_headless_backend_create_with_renderer(
-		struct wl_display *display, struct wlr_renderer *renderer) {
-	wlr_log(WLR_INFO, "Creating headless backend with parent renderer");
-
-	struct wlr_headless_backend *backend =
-		calloc(1, sizeof(struct wlr_headless_backend));
-	if (!backend) {
-		wlr_log(WLR_ERROR, "Failed to allocate wlr_headless_backend");
-		return NULL;
-	}
-	backend->has_parent_renderer = true;
-
-	backend->drm_fd = wlr_renderer_get_drm_fd(renderer);
-	if (backend->drm_fd < 0) {
-		wlr_log(WLR_ERROR, "Failed to get DRM device FD from renderer");
-		goto error_drm_fd;
-	}
-
-	int drm_fd = fcntl(backend->drm_fd, F_DUPFD_CLOEXEC, 0);
-	if (drm_fd < 0) {
-		wlr_log_errno(WLR_ERROR, "fcntl(F_DUPFD_CLOEXEC) failed");
-		goto error_dup;
-	}
-
-	struct wlr_gbm_allocator *gbm_alloc = wlr_gbm_allocator_create(drm_fd);
-	if (gbm_alloc == NULL) {
-		wlr_log(WLR_ERROR, "Failed to create GBM allocator");
-		close(drm_fd);
-		goto error_dup;
-	}
-
-	if (!backend_init(backend, display, &gbm_alloc->base, renderer)) {
-		goto error_init;
-	}
-
-	backend->renderer_destroy.notify = handle_renderer_destroy;
-	wl_signal_add(&renderer->events.destroy, &backend->renderer_destroy);

 	return &backend->backend;

@@ -291,6 +242,55 @@
 	return NULL;
 }

+struct wlr_backend *wlr_headless_backend_create_with_renderer(
+		struct wl_display *display, struct wlr_renderer *renderer) {
+	wlr_log(WLR_INFO, "Creating headless backend with parent renderer");
+
+	struct wlr_headless_backend *backend =
+		calloc(1, sizeof(struct wlr_headless_backend));
+	if (!backend) {
+		wlr_log(WLR_ERROR, "Failed to allocate wlr_headless_backend");
+		return NULL;
+	}
+	backend->has_parent_renderer = true;
+
+	backend->drm_fd = wlr_renderer_get_drm_fd(renderer);
+	if (backend->drm_fd < 0) {
+		wlr_log(WLR_ERROR, "Failed to get DRM device FD from renderer");
+		goto error_drm_fd;
+	}
+
+	int drm_fd = fcntl(backend->drm_fd, F_DUPFD_CLOEXEC, 0);
+	if (drm_fd < 0) {
+		wlr_log_errno(WLR_ERROR, "fcntl(F_DUPFD_CLOEXEC) failed");
+		goto error_dup;
+	}
+
+	struct wlr_gbm_allocator *gbm_alloc = wlr_gbm_allocator_create(drm_fd);
+	if (gbm_alloc == NULL) {
+		wlr_log(WLR_ERROR, "Failed to create GBM allocator");
+		close(drm_fd);
+		goto error_dup;
+	}
+
+	if (!backend_init(backend, display, &gbm_alloc->base, renderer)) {
+		goto error_init;
+	}
+
+	backend->renderer_destroy.notify = handle_renderer_destroy;
+	wl_signal_add(&renderer->events.destroy, &backend->renderer_destroy);
+
+	return &backend->backend;
+
+error_init:
+	wlr_allocator_destroy(&gbm_alloc->base);
+error_dup:
+	close(backend->drm_fd);
+error_drm_fd:
+	free(backend);
+	return NULL;
+}
+
 bool wlr_backend_is_headless(struct wlr_backend *backend) {
 	return backend->impl == &backend_impl;
 }


fix(compression): only support inlined databases with a single clip when merging

--- includes/acl/compression/impl/compress.database.impl.h
+++ includes/acl/compression/impl/compress.database.impl.h
@@ -98,6 +98,12 @@
 		if (!database->contains(*tracks))
 			return error_result("Compressed database doesn't contain the compressed tracks");

+		if (!database->is_bulk_data_inline())
+			return error_result("Compressed database does not have inline bulk data");
+
+		if (database->get_num_clips() != 1)
+			return error_result("Compressed database already contains more than 1 clip");
+
 		return error_result();
 	}


Allocate memory until crash.

Allocate memory until crash.

Can the shrinker save this program?

Signed-off-by: Don Marti <f3fc5392bb003ef5a2c59213ea4f6bad539cc2ef@cloudius-systems.com>

--- memory-hog.c
+++ memory-hog.c
@@ -1,5 +1,41 @@
 #include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#define SIZE 31337 * 4096
+
+struct item {
+    char stuff[SIZE];
+    struct item * prev;
+    struct item * next;
+};
+
+struct item * head;
+struct item * tail;
+
+void hog_memory() {
+    struct item * thing;
+    thing = malloc(sizeof(struct item));
+    if (tail) {
+        tail->next = thing;
+        tail = thing;
+    } else {
+        head = thing;
+	tail = thing;
+    }
+    printf("Oink!\n");
+    sleep(1);
+}
+
+/* TODO: Callback function here.  Should free some
+ * items. */

 int main (int argc, int **argv) {
-    printf("I'm a memory hog! Oink!\n");
+    head = NULL;
+    tail = NULL;
+    printf("I'm a memory hog!\n");
+    /* TODO: Register a callback here? */
+    for(;;) {
+        hog_memory();
+    }
 }


implement optimized ploadu for MSVC10: this also fix bad code generation in gebp_kernel :)

--- Eigen/src/Core/arch/SSE/PacketMath.h
+++ Eigen/src/Core/arch/SSE/PacketMath.h
@@ -222,7 +222,20 @@
 template<> EIGEN_STRONG_INLINE Packet4i pload<Packet4i>(const int*     from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_si128(reinterpret_cast<const Packet4i*>(from)); }

 #if defined(_MSC_VER)
-  template<> EIGEN_STRONG_INLINE Packet4f ploadu<Packet4f>(const float*  from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_ps(from); }
+  template<> EIGEN_STRONG_INLINE Packet4f ploadu<Packet4f>(const float*  from) {
+    EIGEN_DEBUG_UNALIGNED_LOAD
+    #if (_MSC_VER==1600)
+    // NOTE Some version of MSVC10 generates bad code when using _mm_loadu_ps
+    // (i.e., it does not generate an unaligned load!!
+    // TODO On most architectures this version should also be faster than a single _mm_loadu_ps
+    // so we could also enable it for MSVC08 but first we have to make this later does not generate crap when doing so...
+    __m128 res = _mm_loadl_pi(res, (const __m64*)(from));
+    res = _mm_loadh_pi(res, (const __m64*)(from+2));
+    return res;
+    #else
+    return _mm_loadu_ps(from);
+    #endif
+  }
   template<> EIGEN_STRONG_INLINE Packet2d ploadu<Packet2d>(const double* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_pd(from); }
   template<> EIGEN_STRONG_INLINE Packet4i ploadu<Packet4i>(const int*    from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_si128(reinterpret_cast<const Packet4i*>(from)); }
 #else


Manually parse some GVariant properties

Manually parse some GVariant properties

This mitigates a memory corruption issue that causes critical errors to
be printed in the console when using JSON-GLib to convert JSON into
GVariant for array-based properties that GJS does not support.

The memory corruption is still there, and will present itself given
enough random application launches of some of the knowledge apps.

https://phabricator.endlessm.com/T19561

--- ekncontent/ekncontent/eknc-utils.c
+++ ekncontent/ekncontent/eknc-utils.c
@@ -21,6 +21,132 @@
 eknc_content_object_error_quark (void)
 {
   return g_quark_from_static_string("eknc-content-object-error-quark");
+}
+
+static GVariant *
+string_array_from_json (JsonNode *node,
+                        GError **error)
+{
+  if (!JSON_NODE_HOLDS_ARRAY (node))
+    {
+      g_set_error_literal (error, EKNC_CONTENT_OBJECT_ERROR,
+                           EKNC_CONTENT_OBJECT_ERROR_BAD_FORMAT,
+                           "Expected JSON array");
+      return NULL;
+    }
+
+  JsonArray *array = json_node_get_array (node);
+  guint n_elements = json_array_get_length (array);
+
+  GVariantBuilder builder;
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
+
+  for (guint i = 0; i < n_elements; i++)
+    {
+      const char *str = json_array_get_string_element (array, i);
+
+      if (str == NULL || *str == '\0')
+        continue;
+
+      GVariant *v = g_variant_new_string (str);
+      g_variant_builder_add_value (&builder, v);
+    }
+
+  return g_variant_builder_end (&builder);
+}
+
+static GVariant *
+dict_from_json (JsonNode *node,
+                GError **error)
+{
+  if (!JSON_NODE_HOLDS_OBJECT (node))
+    {
+      g_set_error_literal (error, EKNC_CONTENT_OBJECT_ERROR,
+                           EKNC_CONTENT_OBJECT_ERROR_BAD_FORMAT,
+                           "Expected JSON object");
+      return NULL;
+    }
+
+  JsonObject *object = json_node_get_object (node);
+  GList *members = json_object_get_members (object);
+
+  GVariantBuilder builder;
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+
+  for (GList *l = members; l != NULL; l = l->next)
+    {
+      const char *member_name = l->data;
+      JsonNode *node = json_object_get_member (object, member_name);
+      GVariant *value;
+
+      if (JSON_NODE_HOLDS_VALUE (node))
+        {
+          GType value_type = json_node_get_value_type (node);
+
+          if (value_type == G_TYPE_STRING)
+            value = g_variant_new_string (json_node_get_string (node));
+          else if (value_type == G_TYPE_INT64)
+            value = g_variant_new_int64 (json_node_get_int (node));
+          else if (value_type == G_TYPE_DOUBLE)
+            value = g_variant_new_double (json_node_get_double (node));
+          else if (value_type == G_TYPE_BOOLEAN)
+            value = g_variant_new_boolean (json_node_get_boolean (node));
+          else
+            {
+              g_critical ("Invalid JSON value '%s'", g_type_name (value_type));
+              continue;
+            }
+        }
+      else
+        value = json_gvariant_deserialize (node, "v", NULL);
+
+      if (value == NULL)
+        {
+          const char *type_name = g_type_name (json_node_get_value_type (node));
+          g_autofree char *str = json_to_string (node, FALSE);
+          g_critical ("Invalid variant string; type: '%s', value: '%s'", type_name, str);
+          continue;
+        }
+
+      g_variant_builder_open (&builder, G_VARIANT_TYPE ("{sv}"));
+      g_variant_builder_add (&builder, "s", member_name);
+      g_variant_builder_add (&builder, "v", value);
+      g_variant_builder_close (&builder);
+    }
+
+  g_list_free (members);
+
+  return g_variant_builder_end (&builder);
+}
+
+static GVariant *
+dict_array_from_json (JsonNode *node,
+                      GError **error)
+{
+  if (!JSON_NODE_HOLDS_ARRAY (node))
+    {
+      g_set_error_literal (error, EKNC_CONTENT_OBJECT_ERROR,
+                           EKNC_CONTENT_OBJECT_ERROR_BAD_FORMAT,
+                           "Expected JSON array");
+      return NULL;
+    }
+
+  JsonArray *array = json_node_get_array (node);
+  guint n_elements = json_array_get_length (array);
+
+  GVariantBuilder builder;
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}"));
+
+  for (guint i = 0; i < n_elements; i++)
+    {
+      GVariant *v = dict_from_json (json_array_get_element (array, i), error);
+      if (v == NULL)
+        return NULL;
+
+      g_variant_builder_add_value (&builder, v);
+    }
+
+  return g_variant_builder_end (&builder);
 }

 /**
@@ -35,35 +161,52 @@
                                          GParamSpec *pspec,
                                          GArray *params)
 {
-  g_autoptr(GError) error = NULL;
-  GParameter param = { NULL, { 0, }};
-
-  if (!node)
+  GParameter param = { NULL, G_VALUE_INIT };
+
+  if (node == NULL)
     return;

   param.name = pspec->name;
+
   g_value_init (&param.value, pspec->value_type);

   if (G_IS_PARAM_SPEC_VARIANT (pspec))
     {
       GVariantType *type = G_PARAM_SPEC_VARIANT (pspec)->type;
-      GVariant *variant = json_gvariant_deserialize (node,
-                                                     g_variant_type_peek_string (type),
-                                                     &error);
+      GVariant *variant = NULL;
+
+      g_autoptr(GError) error = NULL;
+
+      if (g_variant_type_equal (type, G_VARIANT_TYPE ("as")))
+        variant = string_array_from_json (node, &error);
+      else if (g_variant_type_equal (type, G_VARIANT_TYPE ("aa{sv}")))
+        variant = dict_array_from_json (node, &error);
+      else
+        variant = json_gvariant_deserialize (node, g_variant_type_peek_string (type), &error);
+
+      if (error != NULL)
+        {
+          g_critical ("Unable to convert field '%s' from JSON to a '%s' variant: %s",
+                      pspec->name,
+                      g_variant_type_peek_string (type),
+                      error->message);
+          return;
+        }
+
       g_value_set_variant (&param.value, variant);
     }
   else if (JSON_NODE_HOLDS_VALUE (node))
     {
-      GValue value = { 0, };
       GType type = json_node_get_value_type (node);
+      GValue value = G_VALUE_INIT;

       // Most of our integer properties are stored in json as strings.
       // ImageObject for example was originally trying to follow
       // https://schema.org/ImageObject for its width and height properties,
       // though in practice it is always a string. May be worth a future cleanup,
       // but for now try to parse if we hit this case.
-      if (type == G_TYPE_STRING && (pspec->value_type == G_TYPE_INT ||
-                                    pspec->value_type == G_TYPE_UINT))
+      if (type == G_TYPE_STRING &&
+          (pspec->value_type == G_TYPE_INT || pspec->value_type == G_TYPE_UINT))
         {
           g_value_init (&value, G_TYPE_INT);
           g_value_set_int (&value, atoi (json_node_get_string (node)));
@@ -73,25 +216,30 @@
           json_node_get_value (node, &value);
         }

-      if (g_value_type_transformable (pspec->value_type, type))
-        g_value_transform (&value, &param.value);
+      if (!g_type_is_a (type, pspec->value_type))
+        {
+          if (!g_value_transform (&value, &param.value))
+            {
+              g_value_unset (&value);
+              g_critical ("Unexpected type '%s', expected '%s'",
+                          g_type_name (type),
+                          g_type_name (pspec->value_type));
+              return;
+            }
+        }
       else
-        g_set_error (&error, EKNC_CONTENT_OBJECT_ERROR, EKNC_CONTENT_OBJECT_ERROR_BAD_FORMAT,
-                     "Unexpected type %s", g_type_name (type));
-      g_value_unset(&value);
+        g_value_copy (&value, &param.value);
+
+      g_value_unset (&value);
     }
   else
     {
-      g_set_error (&error, EKNC_CONTENT_OBJECT_ERROR, EKNC_CONTENT_OBJECT_ERROR_BAD_FORMAT,
-                   "Unexpected json value");
-    }
-
-  if (error)
-    g_critical ("Error parsing model property %s: %s",
-                pspec->name,
-                error->message);
-  else
-    g_array_append_val (params, param);
+      g_critical ("Unexpected JSON type '%s'",
+                  g_type_name (json_node_get_value_type (node)));
+      return;
+    }
+
+  g_array_append_val (params, param);
 }

 /**


added p7100

added p7100

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

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -715,6 +715,9 @@
 	/* Kévin Ottens <ervin@ipsquad.net> */
 	{"Nikon:Coolpix S9100 (PTP mode)",0x04b0, 0x0186, 0},

+	/* Dale Pontius <DEPontius@edgehp.net> */
+	{"Nikon:Coolpix P7100 (PTP mode)",0x04b0, 0x018b, 0},
+
 	{"Nikon:Coolpix SQ (PTP mode)",   0x04b0, 0x0202, 0},
 	/* lars marowski bree, 16.8.2004 */
 	{"Nikon:Coolpix 4200 (PTP mode)", 0x04b0, 0x0204, 0},


sound: ASoC: Fix an error path in neo1973_wm8753

The error handling in neo1973_init is incorrect:

* If platform_device_add fails, we go on with the rest of the
  initialization instead of bailing out. Things will break when the
  module is removed (platform_device_unregister called on a device
  that wasn't registered.)

* If i2c_add_driver fails, we return an error so the module will not
  load, but we don't unregister neo1973_snd_device, so we are leaking
  resources.

Add the missing error handling.

Signed-off-by: Jean Delvare <49ad6a9f5aa17024c23048df346d55bda6837e01@linux-fr.org>
Cc: Tim Niemeyer <ce6a50f4f8e62545ee777e70b84669efae4eb271@mastersword.de>
Cc: Graeme Gregory <9c5184f256fa4e0f47ed2cae81d34eab896094fe@openmoko.org>
Cc: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@opensource.wolfsonmicro.com>
Signed-off-by: Jaroslav Kysela <72edd5e1a572f82f059ccbb83c92b74d6cb051ff@perex.cz>

--- sound/soc/s3c24xx/neo1973_wm8753.c
+++ sound/soc/s3c24xx/neo1973_wm8753.c
@@ -717,12 +717,16 @@
 	neo1973_snd_devdata.dev = &neo1973_snd_device->dev;
 	ret = platform_device_add(neo1973_snd_device);

-	if (ret)
+	if (ret) {
 		platform_device_put(neo1973_snd_device);
+		return ret;
+	}

 	ret = i2c_add_driver(&lm4857_i2c_driver);
-	if (ret != 0)
+	if (ret != 0) {
 		printk(KERN_ERR "can't add i2c driver");
+		platform_device_unregister(neo1973_snd_device);
+	}

 	return ret;
 }


fixed misnamed include guard

fixed misnamed include guard

--- ovk/core/MPIUtils.h
+++ ovk/core/MPIUtils.h
@@ -1,8 +1,8 @@
 // Copyright (c) 2018 Matthew J. Smith and Overkit contributors
 // License: MIT (http://opensource.org/licenses/MIT)

-#ifndef OVK_CORE_PARALLEL_UTILS_INCLUDED
-#define OVK_CORE_PARALLEL_UTILS_INCLUDED
+#ifndef OVK_CORE_MPI_UTILS_INCLUDED
+#define OVK_CORE_MPI_UTILS_INCLUDED

 #include "ovk/core/Global.h"
 #include "ovk/core/OrderedMap.h"


made rec_dir_iter inherit from std::iterator

--- src/filesystem/recursive_directory_iterator.h
+++ src/filesystem/recursive_directory_iterator.h
@@ -1,19 +1,16 @@
 #ifndef GUARD_RECURSIVE_DIRECTORY_ITERATOR_H
 #define GUARD_RECURSIVE_DIRECTORY_ITERATOR_H 1

+#include <iterator>
 #include "directory_iterator.h"

 namespace filesystem {
 inline namespace v1 {

 class recursive_directory_iterator
+  : public std::iterator<std::input_iterator_tag, directory_entry>
 {
-public:
-	typedef directory_entry         value_type;
-	typedef ptrdiff_t               difference_type;
-	typedef const directory_entry * pointer;
-	typedef const directory_entry & reference;
-	typedef std::input_iterator_tag iterator_category;
+ public:

 	// constructors and destructor
 	recursive_directory_iterator() noexcept;
@@ -33,17 +30,6 @@

 	~recursive_directory_iterator();

-	// observers
-	directory_options options() const;
-
-	int depth() const;
-
-	bool recursion_pending() const;
-
-	const directory_entry& operator*() const;
-
-	const directory_entry* operator->() const;
-
 	// modifiers
 	recursive_directory_iterator &
 	  operator = (const recursive_directory_iterator & rhs);
@@ -58,6 +44,17 @@
 	void pop();

 	void disable_recursion_pending();
+	// observers
+	directory_options options() const;
+
+	int depth() const;
+
+	bool recursion_pending() const;
+
+	const directory_entry& operator*() const;
+
+	const directory_entry* operator->() const;
+
 };


Missing a struct in osk.

Missing a struct in osk.

--- psl1ght/include/io/osk.h
+++ psl1ght/include/io/osk.h
@@ -56,12 +56,17 @@
 } oskContinuousMode;

 typedef struct{
+	int layoutMode;
+	oskPoint position;
+} oskLayoutInfo;
+
+typedef struct{
 	oskContinuousMode continuous;
 	s32 mask;
 	s32 inputWidth;
 	float inputFieldTransparacy;
-	oskDialogLayoutInfo *inputFieldLayoutInfo;
-	oskDialogLayoutInfo *inputPanelLayoutInfo;
+	oskLayoutInfo *inputFieldLayoutInfo;
+	oskLayoutInfo *inputPanelLayoutInfo;
 	u32 reserved;
 } oskSeparateWindowOption;


xfreerdp: fix egfx SurfaceToSurface off-by-one

--- client/X11/xf_gfx.c
+++ client/X11/xf_gfx.c
@@ -27,9 +27,6 @@
 {
 	xfContext* xfc = (xfContext*) context->custom;

-	printf("xf_ResetGraphics: width: %d height: %d\n",
-			resetGraphics->width, resetGraphics->height);
-
 	if (xfc->rfx)
 	{
 		rfx_context_free(xfc->rfx);
@@ -376,9 +373,6 @@
 	xfGfxSurface* surface;
 	xfContext* xfc = (xfContext*) context->custom;

-	printf("xf_CreateSurface: surfaceId: %d width: %d height: %d format: 0x%02X\n",
-			createSurface->surfaceId, createSurface->width, createSurface->height, createSurface->pixelFormat);
-
 	surface = (xfGfxSurface*) calloc(1, sizeof(xfGfxSurface));

 	if (!surface)
@@ -408,8 +402,6 @@
 	xfGfxSurface* surface = NULL;

 	surface = (xfGfxSurface*) context->GetSurfaceData(context, deleteSurface->surfaceId);
-
-	printf("xf_DeleteSurface: surfaceId: %d\n", deleteSurface->surfaceId);

 	if (surface)
 	{
@@ -496,8 +488,8 @@
 	if (!surfaceSrc || !surfaceDst)
 		return -1;

-	nWidth = rectSrc->right - rectSrc->left + 1;
-	nHeight = rectSrc->bottom - rectSrc->top + 1;
+	nWidth = rectSrc->right - rectSrc->left;
+	nHeight = rectSrc->bottom - rectSrc->top;

 	for (index = 0; index < surfaceToSurface->destPtsCount; index++)
 	{


added d800

added d800

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -831,6 +831,8 @@
 	/* IRC Reporter popolon */
 	{"Nikon:DSC D5100 (PTP mode)",    0x04b0, 0x0429, PTP_CAP|PTP_CAP_PREVIEW},

+	/* "François G." <francois@webcampak.com> */
+	{"Nikon:DSC D800",	          0x04b0, 0x042a, PTP_CAP|PTP_CAP_PREVIEW},
 	/* t.ludewig@gmail.com */
 	{"Nikon:DSC D600",	          0x04b0, 0x042d, PTP_CAP|PTP_CAP_PREVIEW},
 	/* Roderick Stewart <roderick.stewart@gmail.com> */


#250: return the same NIC names as the other net_* functions

--- psutil/_psutil_windows.c
+++ psutil/_psutil_windows.c
@@ -3163,10 +3163,7 @@

 /*
  * Provides stats about NIC interfaces installed on the system.
- * TODO: filter what's not a NIC
- * TODO: return the same (friendly) names as net_io_counters() and
-         net_if_addrs()
- * TODO: get 'duplex' (currently it's hard coded to '2', aka
+ * TODO: get 'duplex' (currently it's hard coded to '2', aka
          'full duplex')
  */
 static PyObject *
@@ -3177,18 +3174,28 @@
     DWORD dwRetVal = 0;
     MIB_IFTABLE *pIfTable;
     MIB_IFROW *pIfRow;
-
+    PIP_ADAPTER_ADDRESSES pAddresses = NULL;
+    PIP_ADAPTER_ADDRESSES pCurrAddresses = NULL;
+    char friendly_name[MAX_PATH];
+    char descr[MAX_PATH];
+    int ifname_found;
+
     PyObject *py_retdict = PyDict_New();
     PyObject *py_ifc_info = NULL;
     PyObject *py_is_up = NULL;

     if (py_retdict == NULL)
         return NULL;
+
+    pAddresses = psutil_get_nic_addresses();
+    if (pAddresses == NULL)
+        goto error;
+
     pIfTable = (MIB_IFTABLE *) malloc(sizeof (MIB_IFTABLE));
     if (pIfTable == NULL) {
         PyErr_NoMemory();
         goto error;
-    }
+    }
     dwSize = sizeof(MIB_IFTABLE);
     if (GetIfTable(pIfTable, &dwSize, FALSE) == ERROR_INSUFFICIENT_BUFFER) {
         free(pIfTable);
@@ -3206,8 +3213,30 @@
     }

     for (i = 0; i < (int) pIfTable->dwNumEntries; i++) {
-        pIfRow = (MIB_IFROW *) & pIfTable->table[i];
-
+        pIfRow = (MIB_IFROW *) & pIfTable->table[i];
+
+        // GetIfTable is not able to give us NIC with "friendly names"
+        // so we determine them via GetAdapterAddresses() which
+        // provides friendly names *and* descriptions and find the
+        // ones that match.
+        ifname_found = 0;
+        pCurrAddresses = pAddresses;
+        while (pCurrAddresses) {
+            sprintf(descr, "%wS", pCurrAddresses->Description);
+            if (lstrcmp(descr, pIfRow->bDescr) == 0) {
+                sprintf(friendly_name, "%wS", pCurrAddresses->FriendlyName);
+                ifname_found = 1;
+                break;
+            }
+            pCurrAddresses = pCurrAddresses->Next;
+        }
+        if (ifname_found == 0) {
+            // Name not found means GetAdapterAddresses() doesn't list
+            // this NIC, only GetIfTable, meaning it's not really a NIC
+            // interface so we skip it.
+            continue;
+        }
+
         // is up?
 		if((pIfRow->dwOperStatus == MIB_IF_OPER_STATUS_CONNECTED ||
                 pIfRow->dwOperStatus == MIB_IF_OPER_STATUS_OPERATIONAL) &&
@@ -3218,24 +3247,24 @@
 			py_is_up = Py_False;
 		}
         Py_INCREF(py_is_up);
-
+
         py_ifc_info = Py_BuildValue(
-            "(Oikk)",
-            py_is_up,
+            "(Oikk)",
+            py_is_up,
             2,  // there's no way to know duplex so let's assume 'full'
             pIfRow->dwSpeed / 1000000,  // expressed in bytes, we want Mb
             pIfRow->dwMtu
         );
         if (!py_ifc_info)
             goto error;
-        if (PyDict_SetItemString(py_retdict, pIfRow->bDescr, py_ifc_info))
+        if (PyDict_SetItemString(py_retdict, friendly_name, py_ifc_info))
             goto error;
         Py_DECREF(py_ifc_info);
     }
-
+
     free(pIfTable);
     return py_retdict;
-
+
 error:
     Py_XDECREF(py_is_up);
     Py_XDECREF(py_ifc_info);


eliminate zeros in sum_duplicates

eliminate zeros in sum_duplicates

--- Lib/sparse/sparsetools/sparsetools.h
+++ Lib/sparse/sparsetools/sparsetools.h
@@ -443,14 +443,15 @@
     while(head != -2){
         I curr = head; //current column
         head   = next[curr];
-
-        Aj[NNZ] = curr;
-        Ax[NNZ] = sums[curr];
-
+
+        if(sums[curr] != 0){
+            Aj[NNZ] = curr;
+            Ax[NNZ] = sums[curr];
+            NNZ++;
+        }
+
         next[curr] = -1;
         sums[curr] =  0;
-
-        NNZ++;
     }
     Ap[i+1] = NNZ;
   }


u_primconvert: Fix leak of the upload BO on context destroy.

v2: Conditionalize it on having done any uploads (Turns out
    u_upload_destroy() isn't safe with a NULL arg).

Reviewed-by: Dave Airlie <f2295d84e358395675bc8031be58672073ae065e@redhat.com> (v1)

--- src/gallium/auxiliary/indices/u_primconvert.c
+++ src/gallium/auxiliary/indices/u_primconvert.c
@@ -74,6 +74,8 @@
 void
 util_primconvert_destroy(struct primconvert_context *pc)
 {
+   if (pc->upload)
+      u_upload_destroy(pc->upload);
    util_primconvert_save_index_buffer(pc, NULL);
    FREE(pc);
 }


added Panasonic DMC-LC1

added Panasonic DMC-LC1

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

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -431,6 +431,8 @@
 	{"Panasonic:DMC-FZ20 (alternate id)", 0x04da, 0x2372, 0},
 	/* http://sourceforge.net/tracker/index.php?func=detail&aid=1350226&group_id=8874&atid=208874 */
 	{"Panasonic:DMC-LZ2",             0x04da, 0x2372, 0},
+	/* https://sourceforge.net/tracker/index.php?func=detail&aid=1405541&group_id=8874&atid=358874 */
+	{"Panasonic:DMC-LC1",             0x04da, 0x2372, 0},

 	/* http://sourceforge.net/tracker/index.php?func=detail&aid=1275100&group_id=8874&atid=358874 */
 	{"Panasonic:Lumix FZ5",           0x04da, 0x2372, 0},


util/primconvert: Avoid point arithmetic; apply offset on all cases.

Matches what u_vbuf_get_minmax_index() does.

Reviewed-by: Ilia Mirkin <bcbbb7aa705ec3a5fc5824c01a845186c3d62fca@alum.mit.edu>

--- src/gallium/auxiliary/indices/u_primconvert.c
+++ src/gallium/auxiliary/indices/u_primconvert.c
@@ -137,8 +137,9 @@
       src = ib->user_buffer;
       if (!src) {
          src = pipe_buffer_map(pc->pipe, ib->buffer,
-                               PIPE_TRANSFER_READ, &src_transfer) + ib->offset;
+                               PIPE_TRANSFER_READ, &src_transfer);
       }
+      src = (const uint8_t *)src + ib->offset;
    }
    else {
       u_index_generator(pc->primtypes_mask,


Increase default delay between commands to 5/100s

--- train_control_panel.c
+++ train_control_panel.c
@@ -49,7 +49,7 @@
 #define TRAIN_COMMAND_BUFFER_MAX 100
 #define TRAIN_COMMAND_PAUSE_TIMEOUT 100
 #define TRAIN_COMMAND_DEBUG_LINES 15
-#define TRAIN_COMMAND_DELAY 1
+#define TRAIN_COMMAND_DELAY 5
 #define TRAIN_REVERSE 15
 #define TRAIN_REVERSE_DELAY 100


Added an equivalent to the non-existent std::make_unqiue_ptr

Change-Id: I93cb72193a99b8fc90ab96bf57be76965eff7328
Reviewed-on: https://wn-project.dnsalias.net/64
Reviewed-by: devpow112 <bef84a74f4a3947934cc58306a6aae518eaf1936@gmail.com>
Tested-by: devpow112 <bef84a74f4a3947934cc58306a6aae518eaf1936@gmail.com>

--- Libraries/WNMemory/inc/WNUniquePtr.h
+++ Libraries/WNMemory/inc/WNUniquePtr.h
@@ -8,7 +8,7 @@
 #define __WN_MEMORY_UNIQUE_PTR_H__

 #include "WNMemory/inc/WNBasic.h"
-
+#include <memory>
 namespace wn {
 namespace memory {

@@ -285,6 +285,11 @@
     construct_aligned<T>(std::forward<Args>(args)...)));
 }

+template <typename T, typename... Args>
+WN_FORCE_INLINE std::unique_ptr<T> make_std_unique(Args&&... args) {
+  return(std::unique_ptr<T>(new T(std::forward<Args>(args)...)));
+}
+
 } // namespace memory
 } // namespace wn


moved curwrite += result to the right place (before progress report).

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

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -736,9 +736,9 @@
 		result = gp_port_write (camera->port, (char*)(bytes + curwrite), towrite);
 		if (result < 0)
 			break;
+		curwrite += result;
 		if (usecontext && (oldsize/CONTEXT_BLOCK_SIZE < curwrite/CONTEXT_BLOCK_SIZE))
 			gp_context_progress_update (context, progressid, curwrite/CONTEXT_BLOCK_SIZE);
-		curwrite += result;
 		if (result < towrite) /* short writes happen */
 			break;
 	}


gallium/util: comments and whitespace fixes

--- src/gallium/auxiliary/util/u_simple_shaders.c
+++ src/gallium/auxiliary/util/u_simple_shaders.c
@@ -44,13 +44,15 @@

 /**
  * Make simple vertex pass-through shader.
+ * \param num_attribs  number of attributes to pass through
+ * \param semantic_names  array of semantic names for each attribute
+ * \param semantic_indexes  array of semantic indexes for each attribute
  */
 void *
 util_make_vertex_passthrough_shader(struct pipe_context *pipe,
                                     uint num_attribs,
                                     const uint *semantic_names,
                                     const uint *semantic_indexes)
-
 {
    struct ureg_program *ureg;
    uint i;
@@ -78,8 +80,6 @@
 }

-
-
 /**
  * Make simple fragment texture shader:
  *  IMM {0,0,0,1}                         // (if writemask != 0xf)
@@ -125,6 +125,12 @@
    return ureg_create_shader_and_destroy( ureg, pipe );
 }

+
+/**
+ * Make a simple fragment shader that sets the output color to a color
+ * taken from a texture.
+ * \param tex_target  one of PIPE_TEXTURE_x
+ */
 void *
 util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target )
 {
@@ -132,6 +138,7 @@
                                                    tex_target,
                                                    TGSI_WRITEMASK_XYZW );
 }
+

 /**
  * Make a simple fragment texture shader which reads an X component from
@@ -177,6 +184,7 @@
    return ureg_create_shader_and_destroy( ureg, pipe );
 }

+
 /**
  * Make simple fragment color pass-through shader.
  */
@@ -186,6 +194,10 @@
    return util_make_fragment_clonecolor_shader(pipe, 1);
 }

+
+/**
+ * Make a fragment shader that copies the input color to N output colors.
+ */
 void *
 util_make_fragment_clonecolor_shader(struct pipe_context *pipe, int num_cbufs)
 {


also added DSC-RX0M2 here for intiial wait, see https://github.com/gphoto/gphoto2/issues/349

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -4673,7 +4673,8 @@
 	if (params->deviceinfo.Model && (
 		!strcmp(params->deviceinfo.Model, "ZV-1")		||
 		!strcmp(params->deviceinfo.Model, "DSC-RX100M7")	||
-		!strcmp(params->deviceinfo.Model, "ILCE-7RM4")
+		!strcmp(params->deviceinfo.Model, "ILCE-7RM4")		||
+		!strcmp(params->deviceinfo.Model, "DSC-RX0M2")
 	)) {
 		/* For some as yet unknown reason the ZV-1, the RX100M7 and the A7 R4 need around 3 seconds startup time
 		 * to be able to capture. I looked for various trigger events or property changes on the ZV-1


gallium/i915: plug in aaline draw stage

gallium/i915: plug in aaline draw stage

--- src/gallium/drivers/i915simple/i915_context.c
+++ src/gallium/drivers/i915simple/i915_context.c
@@ -298,9 +298,13 @@
    i915_init_string_functions(i915);
    i915_init_texture_functions(i915);

+   /* not working yet:
+   draw_install_aapoint_stage(i915->draw, &i915->pipe);
+   */
+   draw_install_aaline_stage(i915->draw, &i915->pipe);
+
    i915->pci_id = pci_id;
    i915->flags.is_i945 = is_i945;
-

    i915->dirty = ~0;
    i915->hardware_dirty = ~0;


check events on eos

check events on eos

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

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -1455,6 +1455,17 @@
 		iconv_close(camera->pl->params.cd_locale_to_ucs2);
 #endif
 		if (params->eos_captureenabled) {
+                        if (camera->pl->checkevents) {
+                                PTPCanon_changes_entry entry;
+
+                                _ptp_check_eos_events (params);
+                                while (_ptp_get_one_eos_event (params, &entry)) {
+                                        gp_log (GP_LOG_DEBUG, "camera_exit", "missed EOS ptp type %d", entry.type);
+                                        if (entry.type == PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN)
+                                                free (entry.u.info);
+                                }
+                                camera->pl->checkevents = 0;
+                        }
 			if (params->eos_viewfinderenabled)
 				ptp_canon_eos_end_viewfinder (params);
 			camera_unprepare_capture (camera, context);


llvmpipe: Also test compressed formats in lp_test_format()

--- src/gallium/drivers/llvmpipe/lp_test_format.c
+++ src/gallium/drivers/llvmpipe/lp_test_format.c
@@ -244,6 +244,8 @@
    enum pipe_format format;
    boolean success = TRUE;

+   util_format_s3tc_init();
+
    for (format = 1; format < PIPE_FORMAT_COUNT; ++format) {
       const struct util_format_description *format_desc;


error 3 might mean

error 3 might mean

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

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -2440,6 +2440,10 @@
 		gp_context_error (context, _("Canon EOS Capture failed to release: Perhaps no focus?"));
 		return GP_ERROR;
 	}
+	if (result == 3) {
+		gp_context_error (context, _("Canon EOS Capture failed to release: Perhaps mirror up?"));
+		return GP_ERROR;
+	}
 	if (result == 7) {
 		gp_context_error (context, _("Canon EOS Capture failed to release: Perhaps no more memory on card?"));
 		return GP_ERROR_NO_MEMORY;