tpcmv2: dpm: Rename attempt_mode_entry/exit functions

This CL renames these two functions as part of DPM refactoring. In
addition, the functions are moved in the file to be adjacent to the
state handler functions.

This CL does not change any functionality. Instead this change is
intended to help track the changes to these 2 functions for the
subsequent CL which adds a msg_wait state.

BUG=b:194504052
BRANCH=none
LOW_COVERAGE_REASON=trivial change which is only renaming 2
functions and moving their location in a file
TEST=Verified that mode entry/exit is successful for DP, TBT, and
USB4 on Voxel.
ectool typeccontrol <port> 0 -> exit mode
ectool typeccontrol <port> 2 0 -> DP
ectool typeccontrol <port> 2 1 -> TBT
ectool typeccontrol <port> 2 2 -> USB4

Signed-off-by: Scott Collyer <7d40b3eb9e17bf55d972074a5e77a7ea4159f9dd@google.com>
Change-Id: I9ea39368ae819ade972eebb771f863d3c7e5bd58
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3965270
Code-Coverage: Zoss <345cf107e82c70959d46f59d98bddc98ce458aff@prod.google.com>
Commit-Queue: Scott Collyer <7d40b3eb9e17bf55d972074a5e77a7ea4159f9dd@chromium.org>
Tested-by: Scott Collyer <7d40b3eb9e17bf55d972074a5e77a7ea4159f9dd@chromium.org>
Reviewed-by: Abe Levkoy <2e1ad7039298f93262cf06bbb457275fb3e2ecb5@chromium.org>

--- common/usbc/usb_pd_dpm.c
+++ common/usbc/usb_pd_dpm.c
@@ -340,236 +340,6 @@
 		CPRINTS("C%d: Received unexpected VDM NAK for SVID %d", port,
 			svid);
 	}
-}
-
-/*
- * Requests that the PE send one VDM, whichever is next in the mode entry
- * sequence. This only happens if preconditions for mode entry are met. If
- * CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY is enabled, this function waits for the
- * AP to direct mode entry.
- */
-static void dpm_attempt_mode_entry(int port)
-{
-	int vdo_count = 0;
-	uint32_t vdm[VDO_MAX_SIZE];
-	enum tcpci_msg_type tx_type = TCPCI_MSG_SOP;
-	bool enter_mode_requested =
-		IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) ? false : true;
-	enum dpm_msg_setup_status status = MSG_SETUP_UNSUPPORTED;
-
-	if (pd_get_data_role(port) != PD_ROLE_DFP) {
-		if (DPM_CHK_FLAG(port, DPM_FLAG_ENTER_DP | DPM_FLAG_ENTER_TBT |
-					       DPM_FLAG_ENTER_USB4))
-			DPM_CLR_FLAG(port, DPM_FLAG_ENTER_DP |
-						   DPM_FLAG_ENTER_TBT |
-						   DPM_FLAG_ENTER_USB4);
-		/*
-		 * TODO(b/168030639): Notify the AP that the enter mode request
-		 * failed.
-		 */
-		return;
-	}
-
-#ifdef CONFIG_AP_POWER_CONTROL
-	/*
-	 * Do not try to enter mode while CPU is off.
-	 * CPU transitions (e.g b/158634281) can occur during the discovery
-	 * phase or during enter/exit negotiations, and the state
-	 * of the modes can get out of sync, causing the attempt to
-	 * enter the mode to fail prematurely.
-	 */
-	if (!chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON))
-		return;
-#endif
-	/*
-	 * If discovery has not occurred for modes, do not attempt to switch
-	 * to alt mode.
-	 */
-	if (pd_get_svids_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE ||
-	    pd_get_modes_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE)
-		return;
-
-	if (dp_entry_is_done(port) ||
-	    (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) &&
-	     tbt_entry_is_done(port)) ||
-	    (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port))) {
-		dpm_set_mode_entry_done(port);
-		return;
-	}
-
-	/*
-	 * If muxes are still settling, then wait on our next VDM.  We must
-	 * ensure we correctly sequence actions such as USB safe state with TBT
-	 * entry or DP configuration.
-	 */
-	if (IS_ENABLED(CONFIG_USBC_SS_MUX) && !usb_mux_set_completed(port))
-		return;
-
-	if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) &&
-	    IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) &&
-	    DPM_CHK_FLAG(port, DPM_FLAG_ENTER_ANY) &&
-	    !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED) &&
-	    !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) {
-		pd_dpm_request(port, DPM_REQUEST_DATA_RESET);
-		DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED);
-		return;
-	}
-
-	if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) &&
-	    IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) &&
-	    !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) {
-		return;
-	}
-
-	/* Check if port, port partner and cable support USB4. */
-	if (IS_ENABLED(CONFIG_USB_PD_USB4) && board_is_tbt_usb4_port(port) &&
-	    enter_usb_port_partner_is_capable(port) &&
-	    enter_usb_cable_is_capable(port) &&
-	    dpm_mode_entry_requested(port, TYPEC_MODE_USB4)) {
-		/*
-		 * For certain cables, enter Thunderbolt alt mode with the
-		 * cable and USB4 mode with the port partner.
-		 */
-		if (tbt_cable_entry_required_for_usb4(port)) {
-			vdo_count = ARRAY_SIZE(vdm);
-			status = tbt_setup_next_vdm(port, &vdo_count, vdm,
-						    &tx_type);
-		} else {
-			pd_dpm_request(port, DPM_REQUEST_ENTER_USB);
-			return;
-		}
-	}
-
-	/* If not, check if they support Thunderbolt alt mode. */
-	if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) &&
-	    board_is_tbt_usb4_port(port) &&
-	    pd_is_mode_discovered_for_svid(port, TCPCI_MSG_SOP,
-					   USB_VID_INTEL) &&
-	    dpm_mode_entry_requested(port, TYPEC_MODE_TBT)) {
-		enter_mode_requested = true;
-		vdo_count = ARRAY_SIZE(vdm);
-		status = tbt_setup_next_vdm(port, &vdo_count, vdm, &tx_type);
-	}
-
-	/* If not, check if they support DisplayPort alt mode. */
-	if (status == MSG_SETUP_UNSUPPORTED &&
-	    !DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE) &&
-	    pd_is_mode_discovered_for_svid(port, TCPCI_MSG_SOP,
-					   USB_SID_DISPLAYPORT) &&
-	    dpm_mode_entry_requested(port, TYPEC_MODE_DP)) {
-		enter_mode_requested = true;
-		vdo_count = ARRAY_SIZE(vdm);
-		status = dp_setup_next_vdm(port, &vdo_count, vdm);
-	}
-
-	/* Not ready to send a VDM, check again next cycle */
-	if (status == MSG_SETUP_MUX_WAIT)
-		return;
-
-	/*
-	 * If the PE didn't discover any supported (requested) alternate mode,
-	 * just mark setup done and get out of here.
-	 */
-	if (status != MSG_SETUP_SUCCESS &&
-	    !DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE)) {
-		if (enter_mode_requested) {
-			/*
-			 * TODO(b/168030639): Notify the AP that mode entry
-			 * failed.
-			 */
-			CPRINTS("C%d: No supported alt mode discovered", port);
-		}
-		/*
-		 * If the AP did not request mode entry, it may do so in the
-		 * future, but the DPM is done trying for now.
-		 */
-		dpm_set_mode_entry_done(port);
-		return;
-	}
-
-	if (status != MSG_SETUP_SUCCESS) {
-		dpm_set_mode_entry_done(port);
-		CPRINTS("C%d: Couldn't construct alt mode VDM", port);
-		return;
-	}
-
-	/*
-	 * TODO(b/155890173): Provide a host command to request that the PE send
-	 * an arbitrary VDM via this mechanism.
-	 */
-	if (!pd_setup_vdm_request(port, tx_type, vdm, vdo_count)) {
-		dpm_set_mode_entry_done(port);
-		return;
-	}
-
-	pd_dpm_request(port, DPM_REQUEST_VDM);
-}
-
-static void dpm_attempt_mode_exit(int port)
-{
-	uint32_t vdm[VDO_MAX_SIZE];
-	int vdo_count = ARRAY_SIZE(vdm);
-	enum dpm_msg_setup_status status = MSG_SETUP_ERROR;
-	enum tcpci_msg_type tx_type = TCPCI_MSG_SOP;
-
-	/* First, try Data Reset. If Data Reset completes, all the alt mode
-	 * state checked below will reset to its inactive state. If Data Reset
-	 * is not supported, exit active modes individually.
-	 */
-	if (IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG)) {
-		if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED) &&
-		    !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) {
-			pd_dpm_request(port, DPM_REQUEST_DATA_RESET);
-			DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED);
-			return;
-		} else if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) {
-			return;
-		}
-	}
-
-	/* TODO(b/209625351): Data Reset is the only real way to exit from USB4
-	 * mode. If that failed, the TCPM shouldn't try anything else.
-	 */
-	if (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port)) {
-		CPRINTS("C%d: USB4 teardown", port);
-		usb4_exit_mode_request(port);
-	}
-
-	/*
-	 * If muxes are still settling, then wait on our next VDM.  We must
-	 * ensure we correctly sequence actions such as USB safe state with TBT
-	 * or DP mode exit.
-	 */
-	if (IS_ENABLED(CONFIG_USBC_SS_MUX) && !usb_mux_set_completed(port))
-		return;
-
-	if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && tbt_is_active(port)) {
-		/*
-		 * When the port is in USB4 mode and receives an exit request,
-		 * it leaves USB4 SOP in active state.
-		 */
-		CPRINTS("C%d: TBT teardown", port);
-		tbt_exit_mode_request(port);
-		status = tbt_setup_next_vdm(port, &vdo_count, vdm, &tx_type);
-	} else if (dp_is_active(port)) {
-		CPRINTS("C%d: DP teardown", port);
-		status = dp_setup_next_vdm(port, &vdo_count, vdm);
-	} else {
-		/* Clear exit mode request */
-		dpm_clear_mode_exit_request(port);
-		return;
-	}
-
-	/* This covers error, wait mux, and unsupported cases */
-	if (status != MSG_SETUP_SUCCESS)
-		return;
-
-	if (!pd_setup_vdm_request(port, tx_type, vdm, vdo_count)) {
-		dpm_clear_mode_exit_request(port);
-		return;
-	}
-
-	pd_dpm_request(port, DPM_REQUEST_VDM);
 }

 static void dpm_send_req_vdm(int port)
@@ -1238,6 +1008,236 @@
 	return bist_shared_mode_enabled;
 }

+/*
+ * Requests that the PE send one VDM, whichever is next in the mode entry
+ * sequence. This only happens if preconditions for mode entry are met. If
+ * CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY is enabled, this function waits for the
+ * AP to direct mode entry.
+ */
+static void dpm_dfp_enter_mode_msg(int port)
+{
+	int vdo_count = 0;
+	uint32_t vdm[VDO_MAX_SIZE];
+	enum tcpci_msg_type tx_type = TCPCI_MSG_SOP;
+	bool enter_mode_requested =
+		IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) ? false : true;
+	enum dpm_msg_setup_status status = MSG_SETUP_UNSUPPORTED;
+
+	if (pd_get_data_role(port) != PD_ROLE_DFP) {
+		if (DPM_CHK_FLAG(port, DPM_FLAG_ENTER_DP | DPM_FLAG_ENTER_TBT |
+					       DPM_FLAG_ENTER_USB4))
+			DPM_CLR_FLAG(port, DPM_FLAG_ENTER_DP |
+						   DPM_FLAG_ENTER_TBT |
+						   DPM_FLAG_ENTER_USB4);
+		/*
+		 * TODO(b/168030639): Notify the AP that the enter mode request
+		 * failed.
+		 */
+		return;
+	}
+
+#ifdef CONFIG_AP_POWER_CONTROL
+	/*
+	 * Do not try to enter mode while CPU is off.
+	 * CPU transitions (e.g b/158634281) can occur during the discovery
+	 * phase or during enter/exit negotiations, and the state
+	 * of the modes can get out of sync, causing the attempt to
+	 * enter the mode to fail prematurely.
+	 */
+	if (!chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON))
+		return;
+#endif
+	/*
+	 * If discovery has not occurred for modes, do not attempt to switch
+	 * to alt mode.
+	 */
+	if (pd_get_svids_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE ||
+	    pd_get_modes_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE)
+		return;
+
+	if (dp_entry_is_done(port) ||
+	    (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) &&
+	     tbt_entry_is_done(port)) ||
+	    (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port))) {
+		dpm_set_mode_entry_done(port);
+		return;
+	}
+
+	/*
+	 * If muxes are still settling, then wait on our next VDM.  We must
+	 * ensure we correctly sequence actions such as USB safe state with TBT
+	 * entry or DP configuration.
+	 */
+	if (IS_ENABLED(CONFIG_USBC_SS_MUX) && !usb_mux_set_completed(port))
+		return;
+
+	if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) &&
+	    IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) &&
+	    DPM_CHK_FLAG(port, DPM_FLAG_ENTER_ANY) &&
+	    !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED) &&
+	    !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) {
+		pd_dpm_request(port, DPM_REQUEST_DATA_RESET);
+		DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED);
+		return;
+	}
+
+	if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) &&
+	    IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) &&
+	    !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) {
+		return;
+	}
+
+	/* Check if port, port partner and cable support USB4. */
+	if (IS_ENABLED(CONFIG_USB_PD_USB4) && board_is_tbt_usb4_port(port) &&
+	    enter_usb_port_partner_is_capable(port) &&
+	    enter_usb_cable_is_capable(port) &&
+	    dpm_mode_entry_requested(port, TYPEC_MODE_USB4)) {
+		/*
+		 * For certain cables, enter Thunderbolt alt mode with the
+		 * cable and USB4 mode with the port partner.
+		 */
+		if (tbt_cable_entry_required_for_usb4(port)) {
+			vdo_count = ARRAY_SIZE(vdm);
+			status = tbt_setup_next_vdm(port, &vdo_count, vdm,
+						    &tx_type);
+		} else {
+			pd_dpm_request(port, DPM_REQUEST_ENTER_USB);
+			return;
+		}
+	}
+
+	/* If not, check if they support Thunderbolt alt mode. */
+	if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) &&
+	    board_is_tbt_usb4_port(port) &&
+	    pd_is_mode_discovered_for_svid(port, TCPCI_MSG_SOP,
+					   USB_VID_INTEL) &&
+	    dpm_mode_entry_requested(port, TYPEC_MODE_TBT)) {
+		enter_mode_requested = true;
+		vdo_count = ARRAY_SIZE(vdm);
+		status = tbt_setup_next_vdm(port, &vdo_count, vdm, &tx_type);
+	}
+
+	/* If not, check if they support DisplayPort alt mode. */
+	if (status == MSG_SETUP_UNSUPPORTED &&
+	    !DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE) &&
+	    pd_is_mode_discovered_for_svid(port, TCPCI_MSG_SOP,
+					   USB_SID_DISPLAYPORT) &&
+	    dpm_mode_entry_requested(port, TYPEC_MODE_DP)) {
+		enter_mode_requested = true;
+		vdo_count = ARRAY_SIZE(vdm);
+		status = dp_setup_next_vdm(port, &vdo_count, vdm);
+	}
+
+	/* Not ready to send a VDM, check again next cycle */
+	if (status == MSG_SETUP_MUX_WAIT)
+		return;
+
+	/*
+	 * If the PE didn't discover any supported (requested) alternate mode,
+	 * just mark setup done and get out of here.
+	 */
+	if (status != MSG_SETUP_SUCCESS &&
+	    !DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE)) {
+		if (enter_mode_requested) {
+			/*
+			 * TODO(b/168030639): Notify the AP that mode entry
+			 * failed.
+			 */
+			CPRINTS("C%d: No supported alt mode discovered", port);
+		}
+		/*
+		 * If the AP did not request mode entry, it may do so in the
+		 * future, but the DPM is done trying for now.
+		 */
+		dpm_set_mode_entry_done(port);
+		return;
+	}
+
+	if (status != MSG_SETUP_SUCCESS) {
+		dpm_set_mode_entry_done(port);
+		CPRINTS("C%d: Couldn't construct alt mode VDM", port);
+		return;
+	}
+
+	/*
+	 * TODO(b/155890173): Provide a host command to request that the PE send
+	 * an arbitrary VDM via this mechanism.
+	 */
+	if (!pd_setup_vdm_request(port, tx_type, vdm, vdo_count)) {
+		dpm_set_mode_entry_done(port);
+		return;
+	}
+
+	pd_dpm_request(port, DPM_REQUEST_VDM);
+}
+
+static void dpm_dfp_exit_mode_msg(int port)
+{
+	uint32_t vdm[VDO_MAX_SIZE];
+	int vdo_count = ARRAY_SIZE(vdm);
+	enum dpm_msg_setup_status status = MSG_SETUP_ERROR;
+	enum tcpci_msg_type tx_type = TCPCI_MSG_SOP;
+
+	/* First, try Data Reset. If Data Reset completes, all the alt mode
+	 * state checked below will reset to its inactive state. If Data Reset
+	 * is not supported, exit active modes individually.
+	 */
+	if (IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG)) {
+		if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED) &&
+		    !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) {
+			pd_dpm_request(port, DPM_REQUEST_DATA_RESET);
+			DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED);
+			return;
+		} else if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) {
+			return;
+		}
+	}
+
+	/* TODO(b/209625351): Data Reset is the only real way to exit from USB4
+	 * mode. If that failed, the TCPM shouldn't try anything else.
+	 */
+	if (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port)) {
+		CPRINTS("C%d: USB4 teardown", port);
+		usb4_exit_mode_request(port);
+	}
+
+	/*
+	 * If muxes are still settling, then wait on our next VDM.  We must
+	 * ensure we correctly sequence actions such as USB safe state with TBT
+	 * or DP mode exit.
+	 */
+	if (IS_ENABLED(CONFIG_USBC_SS_MUX) && !usb_mux_set_completed(port))
+		return;
+
+	if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && tbt_is_active(port)) {
+		/*
+		 * When the port is in USB4 mode and receives an exit request,
+		 * it leaves USB4 SOP in active state.
+		 */
+		CPRINTS("C%d: TBT teardown", port);
+		tbt_exit_mode_request(port);
+		status = tbt_setup_next_vdm(port, &vdo_count, vdm, &tx_type);
+	} else if (dp_is_active(port)) {
+		CPRINTS("C%d: DP teardown", port);
+		status = dp_setup_next_vdm(port, &vdo_count, vdm);
+	} else {
+		/* Clear exit mode request */
+		dpm_clear_mode_exit_request(port);
+		return;
+	}
+
+	/* This covers error, wait mux, and unsupported cases */
+	if (status != MSG_SETUP_SUCCESS)
+		return;
+
+	if (!pd_setup_vdm_request(port, tx_type, vdm, vdo_count)) {
+		dpm_clear_mode_exit_request(port);
+		return;
+	}
+
+	pd_dpm_request(port, DPM_REQUEST_VDM);
+}
+
 void dpm_run(int port, int evt, int en)
 {
 	switch (local_state[port]) {
@@ -1301,9 +1301,9 @@
 	if (pd_get_data_role(port) == PD_ROLE_DFP) {
 		/* Run DFP related DPM requests */
 		if (DPM_CHK_FLAG(port, DPM_FLAG_EXIT_REQUEST))
-			dpm_attempt_mode_exit(port);
+			dpm_dfp_exit_mode_msg(port);
 		else if (!DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE))
-			dpm_attempt_mode_entry(port);
+			dpm_dfp_enter_mode_msg(port);

 		/* Run USB PD Power button state machine */
 		dpm_run_pd_button_sm(port);


Arrange across all desktops when handling struts

Fixes #1165.

--- src/window.c
+++ src/window.c
@@ -81,7 +81,9 @@

 	if (!ignore_ewmh_struts && ewmh_handle_struts(win)) {
 		for (monitor_t *m = mon_head; m != NULL; m = m->next) {
-			arrange(m, m->desk);
+			for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
+				arrange(m, d);
+			}
 		}
 	}


spell check

spell check

git-svn-id: e2fa1b4f04257a65cc3162f75ad5f19d327daceb@614 85bd2434-ea95-11dd-8fb1-9960f2a117f8

--- src/QXmppArchiveManager.h
+++ src/QXmppArchiveManager.h
@@ -51,11 +51,11 @@
     void retrieveCollection(const QString &jid, const QDateTime &start, int max = 0);

 signals:
-    /// This signal is emmitted when archive list is received
+    /// This signal is emitted when archive list is received
     /// after calling listCollections()
     void archiveListReceived(const QList<QXmppArchiveChat>&);

-    /// This signal is emmitted when archive chat is received
+    /// This signal is emitted when archive chat is received
     /// after calling retrieveCollection()
     void archiveChatReceived(const QXmppArchiveChat&);


use evtimer_pending() instead of event struct access

--- src/worker.c
+++ src/worker.c
@@ -28,8 +28,6 @@
     struct instance *instance = (struct instance*)ctx;
     pid_t pid;

-    instance->respawn_event.ev_events = 0;
-
     if (instance->should_exit ||
         instance->num_children >= instance->config.num_workers)
         return;
@@ -46,7 +44,7 @@
 {
     if (!instance->should_exit &&
         instance->num_children < instance->config.num_workers &&
-        instance->respawn_event.ev_events == 0) {
+        evtimer_pending(&instance->respawn_event, NULL) == 0) {
         static struct timeval tv = {
             .tv_sec = 1,
             .tv_usec = 0,
@@ -86,8 +84,6 @@
 create_child(struct instance *instance)
 {
     pid_t pid;
-
-    assert(instance->respawn_event.ev_events == 0);

     deinit_signals(instance);
     children_event_del();


Worker list checks for invalid children

Worker list checks for invalid children

--- src/worker.h
+++ src/worker.h
@@ -30,6 +30,7 @@
 #include <list>
 #include <mutex>
 #include <memory>
+#include <cassert>

 class Worker : public std::enable_shared_from_this<Worker> {
@@ -76,6 +77,7 @@

 	template<typename T>
 	inline WorkerList::iterator _attach(T&& child) {
+		assert(child);
 		L_OBJ(this, "Worker child [%p] attached to [%p]", child.get(), this);
 		return _children.insert(_children.end(), std::forward<T>(child));
 	}
@@ -112,10 +114,14 @@

 		for (auto it = _children.begin(); it != _children.end();) {
 			auto child = *it++;
-			lk.unlock();
-			child->shutdown(asap, now);
-			lk.lock();
-			if (now) {
+			if (child) {
+				lk.unlock();
+				child->shutdown(asap, now);
+				lk.lock();
+				if (now) {
+					_detach(child);
+				}
+			} else {
 				_detach(child);
 			}
 		}


Remove unused SERD_URI enum value.

Remove unused SERD_URI enum value.

git-svn-id: 3ef324c313953cf23400aadf260ac472ecaf2802@438 490d8e77-9747-427b-9fa3-0b8f29cee8a0

--- src/writer.c
+++ src/writer.c
@@ -97,7 +97,6 @@
 };

 typedef enum {
-	WRITE_URI,
 	WRITE_STRING,
 	WRITE_LONG_STRING
 } TextContext;


Fix bug #7261: events do not signal the end of replies for that sequence number.

--- src/xcb_in.c
+++ src/xcb_in.c
@@ -108,8 +108,8 @@
             }
             c->in.request_completed = c->in.request_read - 1;
         }
-        if(genrep.response_type != XCBReply) /* error or event */
-            c->in.request_completed = c->in.request_read; /* XXX: does event/error imply no more replies? */
+        if(genrep.response_type == XCBError)
+            c->in.request_completed = c->in.request_read;

         while(c->in.pending_replies &&
 	      XCB_SEQUENCE_COMPARE (c->in.pending_replies->request, <=, c->in.request_completed))


stupid macros breaking compilation

stupid macros breaking compilation

--- sse/vector.h
+++ sse/vector.h
@@ -52,6 +52,13 @@
 #include "intrinsics.h"
 #include <algorithm>
 #include <limits>
+
+#ifdef isfinite
+#undef isfinite
+#endif
+#ifdef isnan
+#undef isnan
+#endif

 #ifndef _M128
 # define _M128 __m128


some fixes and make command line parser reusable

--- src/os/win32/peb.c
+++ src/os/win32/peb.c
@@ -80,6 +80,32 @@
     return SIGAR_OK;
 }

+static int sigar_parse_proc_args(sigar_t *sigar, WCHAR *buf,
+                                 sigar_proc_args_t *procargs)
+{
+    char arg[SIGAR_CMDLINE_MAX];
+    LPWSTR *args;
+    int num, i;
+
+    sigar_proc_args_create(procargs);
+
+    args = CommandLineToArgvW(buf, &num);
+
+    if (args == NULL) {
+        return SIGAR_OK;
+    }
+
+    for (i=0; i<num; i++) {
+        SIGAR_W2A(args[i], arg, SIGAR_CMDLINE_MAX);
+        SIGAR_PROC_ARGS_GROW(procargs);
+        procargs->data[procargs->number++] = strdup(arg);
+    }
+
+    GlobalFree(args);
+
+    return SIGAR_OK;
+}
+
 int sigar_proc_args_peb_get(sigar_t *sigar, HANDLE proc,
                             sigar_proc_args_t *procargs)
 {
@@ -87,9 +113,6 @@
     LPBYTE scratch;
     DWORD base;
     WCHAR buf[SIGAR_CMDLINE_MAX];
-    char arg[SIGAR_CMDLINE_MAX];
-    LPWSTR *args;
-    int num, i;

     if ((status = sigar_peb_get(sigar, proc, &base)) != SIGAR_OK) {
         return status;
@@ -104,20 +127,5 @@
     wcsncpy(buf, (LPWSTR)scratch, SIGAR_CMDLINE_MAX);
     buf[SIGAR_CMDLINE_MAX-1] = L'\0';

-    args = CommandLineToArgvW(buf, &num);
-
-    sigar_proc_args_create(procargs);
-
-    for (i=0; i<=num; i++) {
-        if (!iswprint(*args[i])) {
-            continue; /* seen trailing garbage */
-        }
-        SIGAR_PROC_ARGS_GROW(procargs);
-        SIGAR_W2A(args[i], arg, SIGAR_CMDLINE_MAX);
-        procargs->data[procargs->number++] = strdup(arg);
-    }
-
-    GlobalFree(args);
-
-    return SIGAR_OK;
+    return sigar_parse_proc_args(sigar, buf, procargs);
 }


Fixed _MSC_VAR reference

Fixed _MSC_VAR reference

git-svn-id: 23b6355f2bb369032457de4eb5f713ee134f73a8@3288 16af8721-9629-0410-8352-f15c8da7e697

--- src/osg/dxtctool.h
+++ src/osg/dxtctool.h
@@ -43,7 +43,7 @@
 #include <osg/GL>
 #include <osg/Texture>

-#ifndef MSV_VER
+#if !defined(_MSC_VER)
 typedef char        __int8;
 typedef short       __int16;
 typedef int         __int32;


Fix compilation without OPENSSL_NO_COMP :-)

--- ssl/s3_enc.c
+++ ssl/s3_enc.c
@@ -358,9 +358,7 @@
 	const EVP_MD *hash;
 	int num;
 	int ret = 0;
-#ifdef OPENSSL_NO_COMP
 	SSL_COMP *comp;
-#endif

 	if (s->s3->tmp.key_block_length != 0)
 		return(1);


oops revert test code accidentally committed

--- ssl/s3_pkt.c
+++ ssl/s3_pkt.c
@@ -330,7 +330,7 @@
 #if 0
 fprintf(stderr, "Record type=%d, Length=%d\n", rr->type, rr->length);
 #endif
-fprintf(stderr, "RX version %x, Expecting %x\n", version, s->version);
+
 		/* Lets check version */
 		if (!s->first_packet)
 			{
@@ -736,7 +736,7 @@

 	*(p++)=(s->version>>8);
 	*(p++)=s->version&0xff;
-fprintf(stderr, "Wrote version %x\n", s->version);
+
 	/* field where we are to write out packet length */
 	plen=p;
 	p+=2;


c++/infra: make clang static analyzer happy

--- macroslib/src/cpp/rust_option.h
+++ macroslib/src/cpp/rust_option.h
@@ -18,10 +18,13 @@
 };

 #ifdef __cplusplus
+#include <cstring>
+
 template<typename T>
 inline T c_option_empty()
 {
     T a;
+    std::memset(&a.val, 0, sizeof(a.val));
     a.is_some = 0;
     return a;
 }


Additional CVE-2014-0224 protection.

Additional CVE-2014-0224 protection.

Return a fatal error if an attempt is made to use a zero length
master secret.
(cherry picked from commit 006cd7083f76ed5cb0d9a914857e9231ef1bc317)

--- ssl/s3_pkt.c
+++ ssl/s3_pkt.c
@@ -1727,7 +1727,7 @@

 	if (s->s3->tmp.key_block == NULL)
 		{
-		if (s->session == NULL)
+		if (s->session == NULL || s->session->master_key_length == 0)
 			{
 			/* might happen if dtls1_read_bytes() calls this */
 			SSLerr(SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC,SSL_R_CCS_RECEIVED_EARLY);


fix debug -> info in main

fix debug -> info in main

--- src/pngtile/main.c
+++ src/pngtile/main.c
@@ -331,29 +331,29 @@
         // update if stale
         if (status != PT_CACHE_FRESH || force_update) {
             if (status == PT_CACHE_NONE)
-                log_debug("\tImage cache is missing");
+                log_info("\tImage cache is missing");

             else if (status == PT_CACHE_STALE)
-                log_debug("\tImage cache is stale");
+                log_info("\tImage cache is stale");

             else if (status == PT_CACHE_INCOMPAT)
-                log_debug("\tImage cache is incompatible");
+                log_info("\tImage cache is incompatible");

             else if (status == PT_CACHE_FRESH)
-                log_debug("\tImage cache is fresh");
+                log_info("\tImage cache is fresh");

             else
                 log_warn("\tImage cache status is unknown");

             if (!no_update) {
-                log_debug("\tUpdating image cache...");
+                log_info("\tUpdating image cache...");

                 if ((err = pt_image_update(image, &update_params))) {
                     log_error("pt_image_update: %s: %s", img_path, pt_strerror(err));
                     goto error;
                 }

-                log_info("\tUpdated image cache");
+                log_debug("\tUpdated image cache");

             } else {
                 log_warn("\tSupressing cache update");
@@ -363,7 +363,7 @@
             log_debug("\tImage cache is fresh");

             // ensure it's loaded
-            log_debug("\tLoad image cache...");
+            log_info("\tLoad image cache...");

             if ((err = pt_image_load(image))) {
                 log_errno("pt_image_load: %s", pt_strerror(err));


am 570370da: Merge "Fixes style nitpick"

* commit '570370da5de2d9db8f5a48b5feb718b1a14b2727':
  Fixes style nitpick

--- compiler/output_stream.h
+++ compiler/output_stream.h
@@ -18,8 +18,9 @@
 #define ART_COMPILER_OUTPUT_STREAM_H_

 #include <stdint.h>
+#include <sys/types.h>
+
 #include <string>
-#include <sys/types.h>

 #include "base/macros.h"


tls1_heartbeat: check for NULL after allocating buf

Signed-off-by: Kurt Roeckx <bb87b47479d83cec3c76132206933257ded727b2@roeckx.be>
Reviewed-by: Matt Caswell <1fa2ef4755a9226cb9a0a4840bd89b158ac71391@openssl.org>

--- ssl/t1_lib.c
+++ ssl/t1_lib.c
@@ -4094,6 +4094,11 @@
 	 *  - Padding
 	 */
 	buf = OPENSSL_malloc(1 + 2 + payload + padding);
+	if (buf == NULL)
+		{
+		SSLerr(SSL_F_TLS1_HEARTBEAT,ERR_R_MALLOC_FAILURE);
+		return -1;
+		}
 	p = buf;
 	/* Message Type */
 	*p++ = TLS1_HB_REQUEST;


add EPERM to the list of return codes to expect from opening directories based on Vista results

--- src/port/copydir.c
+++ src/port/copydir.c
@@ -11,7 +11,7 @@
  *	as a service.
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/port/copydir.c,v 1.34 2010/02/28 21:05:30 stark Exp $
+ *	  $PostgreSQL: pgsql/src/port/copydir.c,v 1.35 2010/03/01 00:04:06 stark Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -234,8 +234,10 @@
 						   O_RDONLY | PG_BINARY,
 						   S_IRUSR | S_IWUSR);

-	/* Some OSs don't allow us to open directories at all */
-	if (fd < 0 && isdir && errno == EISDIR)
+	/* Some OSs don't allow us to open directories at all
+	 * (Windows returns EPERM)
+	 */
+	if (fd < 0 && isdir && (errno == EISDIR || errno == EPERM))
 		return;

 	else if (fd < 0)


DISPATCH-288 - Configure wakeup-pipe FDs as non-blocking.

--- src/posix/driver.c
+++ src/posix/driver.c
@@ -217,7 +217,7 @@
 }

-static void qdpn_configure_sock(qdpn_driver_t *driver, int sock)
+static void qdpn_configure_sock(qdpn_driver_t *driver, int sock, bool tcp)
 {
     //
     // Set the socket to be non-blocking for asynchronous operation.
@@ -233,9 +233,11 @@
     // Note:  It would be more correct for the "level" argument to be SOL_TCP.  However, there
     //        are portability issues with this macro so we use IPPROTO_TCP instead.
     //
-    int tcp_nodelay = 1;
-    if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void*) &tcp_nodelay, sizeof(tcp_nodelay)) < 0)
-        qdpn_log_errno(driver, "setsockopt");
+    if (tcp) {
+        int tcp_nodelay = 1;
+        if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void*) &tcp_nodelay, sizeof(tcp_nodelay)) < 0)
+            qdpn_log_errno(driver, "setsockopt");
+    }
 }

@@ -401,7 +403,7 @@
             close(sock);
             return 0;
         } else {
-            qdpn_configure_sock(l->driver, sock);
+            qdpn_configure_sock(l->driver, sock, true);
             snprintf(name, PN_NAME_MAX-1, "%s:%s", host, serv);
         }
     }
@@ -496,7 +498,7 @@
         return 0;
     }

-    qdpn_configure_sock(driver, sock);
+    qdpn_configure_sock(driver, sock, true);

     if (connect(sock, addr->ai_addr, addr->ai_addrlen) == -1) {
         if (errno != EINPROGRESS) {
@@ -846,6 +848,9 @@
     if (pipe(d->ctrl)) {
         perror("Can't create control pipe");
     }
+
+    qdpn_configure_sock(d, d->ctrl[0], false);
+    qdpn_configure_sock(d, d->ctrl[1], false);

     return d;
 }


(_UPTi_find_unwind_table): Add dummy x86 implementation.
(_UPT_find_proc_info): On ia64, when returning info about the kernel's unwind
	table, copy the unwind info into a malloc'd buffer and use
	unw_local_addr_space to search the table, since the table is stored
	in local memory.

(Logical change 1.71)

--- src/_UPT_find_proc_info.c
+++ src/_UPT_find_proc_info.c
@@ -149,7 +149,16 @@
   return &ui->di_cache;
 }

-#endif /* UNW_TARGET_IA64 */
+#elif UNW_TARGET_X86
+
+HIDDEN unw_dyn_info_t *
+_UPTi_find_unwind_table (struct UPT_info *ui, unw_addr_space_t as,
+			 char *path, unw_word_t segbase, unw_word_t mapoff)
+{
+  return NULL;
+}
+
+#endif /* UNW_TARGET_X86 */

 static unw_dyn_info_t *
 get_unwind_info (struct UPT_info *ui, unw_addr_space_t as, unw_word_t ip)
@@ -205,5 +214,29 @@
   if (!di)
     return -UNW_ENOINFO;

-  return _Uia64_search_unwind_table (as, ip, di, pi, need_unwind_info, arg);
-}
+#if UNW_TARGET_IA64
+  if (di == &ui->ktab)
+    {
+      /* The kernel unwind table resides in local memory, so we have
+	 to use the local address space to search it.  Since
+	 _UPT_put_unwind_info() has no easy way of detecting this
+	 case, we simply make a copy of the unwind-info, so
+	 _UPT_put_unwind_info() can always free() the unwind-info
+	 without ill effects.  */
+      int ret = tdep_search_unwind_table (unw_local_addr_space, ip, di, pi,
+					  need_unwind_info, arg);
+      if (ret >= 0 && need_unwind_info)
+	{
+	  void *mem = malloc (pi->unwind_info_size);
+
+	  if (!mem)
+	    return -UNW_ENOMEM;
+	  memcpy (mem, pi->unwind_info, pi->unwind_info_size);
+	  pi->unwind_info = mem;
+	}
+      return ret;
+    }
+  else
+#endif
+  return tdep_search_unwind_table (as, ip, di, pi, need_unwind_info, arg);
+}


tree printer NEW submodule print

tree printer NEW submodule print

--- src/printer/tree.c
+++ src/printer/tree.c
@@ -681,7 +681,11 @@
     char *indent = malloc((level * 4 + 1) * sizeof (char));
     strcpy(indent, "   ");

-    fprintf(f, "module: %s\n", module->name);
+    if (module->type) {
+        fprintf(f, "submodule: %s (belongs-to %s)\n", module->name, ((struct ly_submodule *)module)->belongsto->name);
+    } else {
+        fprintf(f, "module: %s\n", module->name);
+    }

     /* included submodules */
     for (i = 0; i < module->inc_size; i++) {


newlib: fix compilation error when no timers are enabled in menuconfig

--- components/newlib/time.c
+++ components/newlib/time.c
@@ -55,14 +55,16 @@
 #endif // WITH_RTC

-// time from Epoch to the first boot time
+// s_boot_time: time from Epoch to the first boot time
 #ifdef WITH_RTC
 static RTC_DATA_ATTR struct timeval s_boot_time;
-#else
+#elif defined(WITH_FRC1)
 static struct timeval s_boot_time;
 #endif
+
+#if defined(WITH_RTC) || defined(WITH_FRC1)
 static _lock_t s_boot_time_lock;
-
+#endif

 #ifdef WITH_FRC1
 #define FRC1_PRESCALER 16
@@ -121,6 +123,7 @@
     return (clock_t) tv.tv_sec;
 }

+#if defined( WITH_FRC1 ) || defined( WITH_RTC )
 static uint64_t get_time_since_boot()
 {
     uint64_t microseconds = 0;
@@ -140,6 +143,7 @@
 #endif
     return microseconds;
 }
+#endif // defined( WITH_FRC1 ) || defined( WITH_RTC )

 int IRAM_ATTR _gettimeofday_r(struct _reent *r, struct timeval *tv, void *tz)
 {
@@ -176,7 +180,7 @@
     }
     return 0;
 #else
-    __errno_r(r) = ENOSYS;
+    errno = ENOSYS;
     return -1;
 #endif
 }


printer_tree REFACTOR printing implicit case-node

--- src/printer_tree.c
+++ src/printer_tree.c
@@ -3842,14 +3842,14 @@
  *
  * @param[in] node is child of implicit case.
  * @param[in] wr is wrapper for printing identation before node.
- * @param[in] ca contains inherited data from ancestors.
  * @param[in] pc contains mainly functions for printing.
  * @param[in] tc is tree context. Its settings should be the same as
  * before the function call.
- */
-static void
-trb_print_implicit_node_case_subtree(struct trt_node node, struct trt_wrapper wr,
-        struct trt_parent_cache ca, struct trt_printer_ctx *pc, struct trt_tree_ctx *tc)
+ * @return new indentation wrapper for @p node.
+ */
+static struct trt_wrapper
+trb_print_implicit_node(struct trt_node node, struct trt_wrapper wr, struct trt_printer_ctx *pc,
+        struct trt_tree_ctx *tc)
 {
     struct trt_node case_node;
     struct trt_wrapper wr_case_child;
@@ -3857,10 +3857,10 @@
     case_node = tro_create_implicit_case_node(node);
     ly_print_(pc->out, "\n");
     trb_print_entire_node(case_node, 0, wr, pc, tc);
+    ly_print_(pc->out, "\n");
     wr_case_child = pc->fp.read.if_sibling_exists(tc) ?
             trp_wrapper_set_mark(wr) : trp_wrapper_set_shift(wr);
-    ly_print_(pc->out, "\n");
-    trb_print_subtree_nodes(node, 0, wr_case_child, ca, pc, tc);
+    return wr_case_child;
 }

 /**
@@ -3991,15 +3991,12 @@
 trb_print_subtree_nodes(struct trt_node node, uint32_t max_gap_before_type, struct trt_wrapper wr,
         struct trt_parent_cache ca, struct trt_printer_ctx *pc, struct trt_tree_ctx *tc)
 {
-    struct trt_parent_cache new_ca;
-    ly_bool sibling_flag = 0;
-
     /* print root node */
     trb_print_entire_node(node, max_gap_before_type, wr, pc, tc);

     /* go to the child */
-    new_ca = tro_parent_cache_for_child(ca, tc);
-    node = pc->fp.modify.next_child(new_ca, tc);
+    ca = tro_parent_cache_for_child(ca, tc);
+    node = pc->fp.modify.next_child(ca, tc);
     if (trp_node_is_empty(node)) {
         /* No child. */
         return;
@@ -4010,20 +4007,22 @@
             trp_wrapper_set_shift(wr) : trp_wrapper_set_mark(wr);

     /* try unified indentation for children */
-    max_gap_before_type = trb_try_unified_indent(new_ca, pc, tc);
+    max_gap_before_type = trb_try_unified_indent(ca, pc, tc);

     do {
         if (!trb_need_implicit_node_case(tc)) {
             /* normal behavior */
             ly_print_(pc->out, "\n");
-            trb_print_subtree_nodes(node, max_gap_before_type, wr, new_ca, pc, tc);
+            trb_print_subtree_nodes(node, max_gap_before_type, wr, ca, pc, tc);
         } else {
-            trb_print_implicit_node_case_subtree(node, wr, new_ca, pc, tc);
+            struct trt_wrapper wr_case_child;
+
+            wr_case_child = trb_print_implicit_node(node, wr, pc, tc);
+            trb_print_subtree_nodes(node, max_gap_before_type, wr_case_child, ca, pc, tc);
         }
         /* go to the actual node's sibling */
-        node = pc->fp.modify.next_sibling(new_ca, tc);
-        sibling_flag = !trp_node_is_empty(node);
-    } while (sibling_flag);
+        node = pc->fp.modify.next_sibling(ca, tc);
+    } while (!trp_node_is_empty(node));

     /* get back from child node to root node */
     pc->fp.modify.parent(tc);


*** empty log message ***

*** empty log message ***

--- src/afterstep/winstatus.c
+++ src/afterstep/winstatus.c
@@ -642,13 +642,14 @@

 	if (!check_frame_offscreen (asw))
 	    for( i = 0 ; i < FRAME_SIDES ; ++i )
-		{
-           	handle_canvas_config (asw->frame_sides[i]);
-    	    if(!check_frame_side_offscreen (asw, i))
-        	{   /* canvas has been resized - resize tbars!!! */
-	            on_frame_bars_moved( asw, i, od);
-    	    }
-		}
+			if (asw->frame_sides[i])
+			{
+           		handle_canvas_config (asw->frame_sides[i]);
+    	    	if(!check_frame_side_offscreen (asw, i))
+        		{   /* canvas has been resized - resize tbars!!! */
+	            	on_frame_bars_moved( asw, i, od);
+    	    	}
+			}
 }

 void


Usage of the kernel/user space function macros

--- src/read/objects.c
+++ src/read/objects.c
@@ -27,10 +27,10 @@
 	unsigned int object_offset = 0;
 	unsigned int function_offset = 0;

-	file->data_object_head = malloc(CTF_DATA_OBJECT_HEAD_SIZE);
+	file->data_object_head = CTF_MALLOC(CTF_DATA_OBJECT_HEAD_SIZE);
 	TAILQ_INIT(file->data_object_head);

-	file->function_head = malloc(CTF_FUNCTION_HEAD_SIZE);
+	file->function_head = CTF_MALLOC(CTF_FUNCTION_HEAD_SIZE);
 	TAILQ_INIT(file->function_head);

 	for (unsigned int i = 0; i < symbol_count; i++)
@@ -72,8 +72,8 @@
 				type_reference = *((uint16_t*)(object_section->data + object_offset));
 				object_offset += sizeof(uint16_t);

-				struct ctf_data_object* data_object = malloc(CTF_DATA_OBJECT_SIZE);
-				data_object->name = strdup(name);
+				struct ctf_data_object* data_object = CTF_MALLOC(CTF_DATA_OBJECT_SIZE);
+				data_object->name = CTF_STRDUP(name);
 				data_object->type = _ctf_lookup_type(file, type_reference);

 				TAILQ_INSERT_TAIL(file->data_object_head, data_object, data_objects);
@@ -91,9 +91,9 @@
 				type_reference = *(fp + function_offset);
 				function_offset++;

-				function = malloc(CTF_FUNCTION_SIZE);
-				function->name = strdup(name);
-				function->argument_head = malloc(CTF_ARGUMENT_HEAD_SIZE);
+				function = CTF_MALLOC(CTF_FUNCTION_SIZE);
+				function->name = CTF_STRDUP(name);
+				function->argument_head = CTF_MALLOC(CTF_ARGUMENT_HEAD_SIZE);
 				function->return_type = _ctf_lookup_type(file, type_reference);

 				TAILQ_INIT(function->argument_head);
@@ -102,7 +102,7 @@
 					type_reference = *(fp + function_offset);
 					function_offset++;

-					argument = malloc(CTF_ARGUMENT_SIZE);
+					argument = CTF_MALLOC(CTF_ARGUMENT_SIZE);
 					argument->type = _ctf_lookup_type(file, type_reference);
 					TAILQ_INSERT_TAIL(function->argument_head, argument, arguments);
 				}


Fix address aliasing in sendmmsg0

Fix address aliasing in sendmmsg0

Motivation:

When epoll datagram channel invokes sendmmsg0, _all_ of the messages go
on the wire with the address of the _last_ packet in the list.

Modifications:

An array of addresses equal to the length of the messages is allocated
on the stack to hold the address for each msg_hdr.msg_name.

Result:

Each message goes on the wire with the correct address.

--- transport-native-epoll/src/main/c/netty_epoll_native.c
+++ transport-native-epoll/src/main/c/netty_epoll_native.c
@@ -232,24 +232,24 @@

 static jint netty_epoll_native_sendmmsg0(JNIEnv* env, jclass clazz, jint fd, jobjectArray packets, jint offset, jint len) {
     struct mmsghdr msg[len];
+    struct sockaddr_storage addr[len];
     int i;

     memset(msg, 0, sizeof(msg));

     for (i = 0; i < len; i++) {
-        struct sockaddr_storage addr;

         jobject packet = (*env)->GetObjectArrayElement(env, packets, i + offset);
         jbyteArray address = (jbyteArray) (*env)->GetObjectField(env, packet, packetAddrFieldId);
         jint scopeId = (*env)->GetIntField(env, packet, packetScopeIdFieldId);
         jint port = (*env)->GetIntField(env, packet, packetPortFieldId);

-        if (netty_unix_socket_initSockaddr(env, address, scopeId, port, &addr) == -1) {
+        if (netty_unix_socket_initSockaddr(env, address, scopeId, port, &addr[i]) == -1) {
             return -1;
         }

-        msg[i].msg_hdr.msg_name = &addr;
-        msg[i].msg_hdr.msg_namelen = sizeof(addr);
+        msg[i].msg_hdr.msg_name = &addr[i];
+        msg[i].msg_hdr.msg_namelen = sizeof(addr[i]);

         msg[i].msg_hdr.msg_iov = (struct iovec*) (intptr_t) (*env)->GetLongField(env, packet, packetMemoryAddressFieldId);
         msg[i].msg_hdr.msg_iovlen = (*env)->GetIntField(env, packet, packetCountFieldId);;


-- Express Boolean OR correctly.

-- Express Boolean OR correctly.

--- pathfinder/compiler/algebra/prop/prop_trace_names.c
+++ pathfinder/compiler/algebra/prop/prop_trace_names.c
@@ -424,7 +424,7 @@

     /* infer properties for children */
     for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++)
-        found_goal = find_goal (n->child[i], goal) | found_goal;
+        found_goal = find_goal (n->child[i], goal) || found_goal;

     return found_goal;
 }


In aggregate's min & max, track the precision of the current minimum or
maximum value instead of the greates precision found in that input field.

git-svn-id: 036a1c5f902f528d79fbac72fb947c91fe594755@425 9f305d85-0c50-0410-b3e0-65f4174694de

--- src/aggregate/aggregate.c
+++ src/aggregate/aggregate.c
@@ -345,14 +345,13 @@
                                 delim);
         if (tmplen > 0) {
           double cur_val;
-          n = float_str_precision(tmpbuf);
-          if (conf.mins.precisions[i] < n)
-            conf.mins.precisions[i] = n;
           n = sscanf(tmpbuf, "%lf", &cur_val);
           if (n) {
             if (cur_val < value->numeric_mins[i] ||
-                ! value->mins_initialized[i])
+                ! value->mins_initialized[i]) {
               value->numeric_mins[i] = cur_val;
+              conf.mins.precisions[i] = float_str_precision(tmpbuf);
+            }
             value->mins_initialized[i] = 1;
           }
         }
@@ -365,14 +364,13 @@
                                 delim);
         if (tmplen > 0) {
           double cur_val;
-          n = float_str_precision(tmpbuf);
-          if (conf.maxs.precisions[i] < n)
-            conf.maxs.precisions[i] = n;
           n = sscanf(tmpbuf, "%lf", &cur_val);
           if (n) {
             if (cur_val > value->numeric_maxs[i] ||
-                ! value->maxs_initialized[i])
+                ! value->maxs_initialized[i]) {
               value->numeric_maxs[i] = cur_val;
+              conf.maxs.precisions[i] = float_str_precision(tmpbuf);
+            }
             value->maxs_initialized[i] = 1;
           }
         }


Remove debug statements

Remove debug statements

--- src/readstat_sas.c
+++ src/readstat_sas.c
@@ -877,29 +877,24 @@
 static readstat_error_t submit_columns(sas_ctx_t *ctx) {
     readstat_error_t retval = READSTAT_OK;
     if (ctx->info_handler) {
-        printf("Calling info handler...\n");
         if (ctx->info_handler(ctx->total_row_count, ctx->column_count, ctx->user_ctx)) {
             retval = READSTAT_ERROR_USER_ABORT;
             goto cleanup;
         }
-        printf("Finished calling info handler.\n");
     }
     if (ctx->variable_handler) {
         int i;
         for (i=0; i<ctx->column_count; i++) {
-            printf("Initializing variable...\n");
             readstat_variable_t *variable = sas_init_variable(ctx, i, &retval);
             if (variable == NULL)
                 break;

-            printf("Calling variable handler on variable %i...\n", i);
             int cb_retval = ctx->variable_handler(i, variable, variable->format, ctx->user_ctx);
             free(variable);
             if (cb_retval) {
                 retval = READSTAT_ERROR_USER_ABORT;
                 goto cleanup;
             }
-            printf("Finished calling variable handler.\n");
         }
     }
 cleanup:
@@ -1057,15 +1052,12 @@
     }
     if (data) {
         if (!ctx->did_submit_columns) {
-            printf("Submitting columns...\n");
             if ((retval = submit_columns(ctx)) != READSTAT_OK) {
                 goto cleanup;
             }
-            printf("Finished submitting columns\n");
             ctx->did_submit_columns = 1;
         }
         if (ctx->value_handler) {
-            printf("Parsing rows...\n");
             retval = sas_parse_rows(data, ctx);
         }
     }
@@ -1097,7 +1089,6 @@
         goto cleanup;
     }

-    printf("Seeking to end of file\n");
     ctx->file_size = readstat_lseek(fd, 0, SEEK_END);
     if (ctx->file_size == -1) {
         retval = READSTAT_ERROR_SEEK;
@@ -1108,7 +1099,6 @@
         goto cleanup;
     }

-    printf("Seeking to beginning of file\n");
     if (readstat_lseek(fd, 0, SEEK_SET) == -1) {
         retval = READSTAT_ERROR_SEEK;
         if (ctx->error_handler) {
@@ -1143,8 +1133,6 @@
         goto cleanup;
     }

-    printf("Page count: %lld  Page size: %lld\n", hinfo->page_count, hinfo->page_size);
-
     /* look for META and MIX pages at beginning... */
     for (i=0; i<hinfo->page_count; i++) {
         if (readstat_lseek(fd, start_pos + i*hinfo->page_size, SEEK_SET) == -1) {
@@ -1190,7 +1178,6 @@

     /* ...then AMD pages at the end */
     for (i=hinfo->page_count-1; i>last_examined_page_pass1; i--) {
-        printf("Seeking to page %lld\n", i);
         if (readstat_lseek(fd, start_pos + i*hinfo->page_size, SEEK_SET) == -1) {
             retval = READSTAT_ERROR_SEEK;
             if (ctx->error_handler) {
@@ -1225,13 +1212,11 @@
             goto cleanup;
         }

-        printf("Parsing page %lld (Pass 1)\n", i);
         if ((retval = sas_parse_page_pass1(page, hinfo->page_size, ctx)) != READSTAT_OK) {
             goto cleanup;
         }
     }

-    printf("Seeking to starting position\n");
     if (readstat_lseek(fd, start_pos, SEEK_SET) == -1) {
         retval = READSTAT_ERROR_SEEK;
         if (ctx->error_handler) {
@@ -1245,25 +1230,21 @@
         if ((retval = sas_update_progress(fd, ctx)) != READSTAT_OK) {
             goto cleanup;
         }
-        printf("Reading page %lld\n", i);
         if (read(fd, page, hinfo->page_size) < hinfo->page_size) {
             retval = READSTAT_ERROR_READ;
             goto cleanup;
         }

-        printf("Parsing page %lld (Pass 2)\n", i);
         if ((retval = sas_parse_page_pass2(page, hinfo->page_size, ctx)) != READSTAT_OK) {
             goto cleanup;
         }
     }

     if (!ctx->did_submit_columns) {
-        printf("Submitting columns...\n");
         if ((retval = submit_columns(ctx)) != READSTAT_OK) {
             goto cleanup;
         }
         ctx->did_submit_columns = 1;
-        printf("Finished submitting columns\n");
     }

     if (ctx->value_handler && ctx->parsed_row_count != ctx->total_row_count) {
@@ -1290,7 +1271,6 @@
     if (retval == READSTAT_ERROR_OPEN ||
             retval == READSTAT_ERROR_READ ||
             retval == READSTAT_ERROR_SEEK) {
-        printf("Reporting errors...\n");
         if (ctx->error_handler) {
             snprintf(error_buf, sizeof(error_buf), "ReadStat: %s (retval = %d): %s (errno = %d)\n",
                     readstat_error_message(retval), retval, strerror(errno), errno);
@@ -1298,7 +1278,6 @@
         }
     }

-    printf("Freeing...\n");
     if (page)
         free(page);
     if (ctx)


ANSI CPP does not like stuff after macros

--- src/rimp2/output.h
+++ src/rimp2/output.h
@@ -22,6 +22,6 @@
 #   define DGEWR2	SGEWR2
 #   define DSYWR	SSYWR
 #   define DSPWR        SSPWR
-#endif SNGLPR
+#endif

-#endif !_OUTPUT_
+#endif


Avoid recursion in ts_node__prev_sibling

--- src/runtime/node.c
+++ src/runtime/node.c
@@ -129,54 +129,53 @@
   return ts_node__null();
 }

-static inline bool ts_node__last_child_before(TSNode self, TSNode target,
-                                              bool include_anonymous, TSNode *result) {
-  TSNode child;
-  TSNode earlier_child = ts_node__null();
-  bool earlier_child_is_relevant = false;
-  bool found_child_containing_target = false;
-  NodeChildIterator iterator = ts_node_child_iterator_begin(&self);
-  uint32_t target_end_byte = ts_node_end_byte(target);
-  while (ts_node_child_iterator_next(&iterator, &child)) {
-    if (iterator.position.bytes >= target_end_byte) {
-      found_child_containing_target = true;
-      break;
-    }
-
-    if (ts_node__is_relevant(child, include_anonymous)) {
-      earlier_child = child;
-      earlier_child_is_relevant = true;
-    } else if (ts_node__relevant_child_count(child, include_anonymous) > 0) {
-      earlier_child = child;
-      earlier_child_is_relevant = false;
-    }
-  }
-
-  if (found_child_containing_target && child.subtree != target.subtree) {
-    if (ts_node__last_child_before(child, target, include_anonymous, result)) {
-      return true;
-    }
-  }
-
-  if (earlier_child_is_relevant) {
-    *result = earlier_child;
-    return true;
-  }
-
-  if (earlier_child.subtree) {
-    return ts_node__last_child_before(earlier_child, target, include_anonymous, result);
-  }
-
-  return false;
-}
-
 static inline TSNode ts_node__prev_sibling(TSNode self, bool include_anonymous) {
-  TSNode result = ts_node__null();
-  TSNode parent = ts_node_parent(self);
-  if (parent.subtree) {
-    ts_node__last_child_before(parent, self, include_anonymous, &result);
-  }
-  return result;
+  uint32_t target_end_byte = ts_node_end_byte(self);
+
+  TSNode node = ts_node_parent(self);
+  TSNode earlier_node = ts_node__null();
+  bool earlier_node_is_relevant = false;
+
+  while (node.subtree) {
+    TSNode earlier_child = ts_node__null();
+    bool earlier_child_is_relevant = false;
+    bool found_child_containing_target = false;
+
+    TSNode child;
+    NodeChildIterator iterator = ts_node_child_iterator_begin(&node);
+    while (ts_node_child_iterator_next(&iterator, &child)) {
+      if (iterator.position.bytes >= target_end_byte) {
+        found_child_containing_target = child.subtree != self.subtree;
+        break;
+      }
+
+      if (ts_node__is_relevant(child, include_anonymous)) {
+        earlier_child = child;
+        earlier_child_is_relevant = true;
+      } else if (ts_node__relevant_child_count(child, include_anonymous) > 0) {
+        earlier_child = child;
+        earlier_child_is_relevant = false;
+      }
+    }
+
+    if (found_child_containing_target) {
+      if (earlier_child.subtree) {
+        earlier_node = earlier_child;
+        earlier_node_is_relevant = earlier_child_is_relevant;
+      }
+      node = child;
+    } else if (earlier_child_is_relevant) {
+      return earlier_child;
+    } else if (earlier_child.subtree) {
+      node = earlier_child;
+    } else if (earlier_node_is_relevant) {
+      return earlier_node;
+    } else {
+      node = earlier_node;
+    }
+  }
+
+  return ts_node__null();
 }

 static inline TSNode ts_node__next_sibling(TSNode self, bool include_anonymous) {


include root_cbf cost

include root_cbf cost

--- src/search_inter.c
+++ src/search_inter.c
@@ -2016,9 +2016,14 @@
     false);

   double bits = 0;
-  *inter_cost = kvz_cu_rd_cost_luma(state, SUB_SCU(x), SUB_SCU(y), depth, cur_cu, lcu, &bits);
-  if (reconstruct_chroma) {
-    *inter_cost += kvz_cu_rd_cost_chroma(state, SUB_SCU(x), SUB_SCU(y), depth, cur_cu, lcu, &bits);
+  int cbf = cbf_is_set_any(cur_cu->cbf, depth);
+  *inter_bitcost += CTX_ENTROPY_FBITS(&state->cabac.ctx.cu_qt_root_cbf_model, !!cbf);
+
+  if(cbf) {
+    *inter_cost = kvz_cu_rd_cost_luma(state, SUB_SCU(x), SUB_SCU(y), depth, cur_cu, lcu, &bits);
+    if (reconstruct_chroma) {
+      *inter_cost += kvz_cu_rd_cost_chroma(state, SUB_SCU(x), SUB_SCU(y), depth, cur_cu, lcu, &bits);
+    }
   }

   FILE_BITS(bits, x, y, depth, "inter rd 2 bits");


Switch to new intra pred in kvz_search_cu_intra

--- src/search_intra.c
+++ src/search_intra.c
@@ -343,41 +343,25 @@
  */
 static int8_t search_intra_rough(encoder_state_t * const state,
                                  kvz_pixel *orig, int32_t origstride,
-                                 kvz_pixel *rec, int16_t recstride,
-                                 int width, int8_t *intra_preds,
+                                 kvz_intra_references *refs,
+                                 int log2_width, int8_t *intra_preds,
                                  int8_t modes[35], double costs[35])
 {
+  assert(log2_width >= 2 && log2_width <= 5);
+  int_fast8_t width = 1 << log2_width;
   cost_pixel_nxn_func *satd_func = kvz_pixels_get_satd_func(width);
   cost_pixel_nxn_func *sad_func = kvz_pixels_get_sad_func(width);

   // Temporary block arrays
-  kvz_pixel _pred[LCU_WIDTH * LCU_WIDTH + 1 + SIMD_ALIGNMENT];
+  kvz_pixel _pred[32 * 32 + SIMD_ALIGNMENT];
   kvz_pixel *pred = ALIGNED_POINTER(_pred, SIMD_ALIGNMENT);

-  kvz_pixel _orig_block[LCU_WIDTH * LCU_WIDTH + 1 + SIMD_ALIGNMENT];
+  kvz_pixel _orig_block[32 * 32 + SIMD_ALIGNMENT];
   kvz_pixel *orig_block = ALIGNED_POINTER(_orig_block, SIMD_ALIGNMENT);
-
-  kvz_pixel rec_filtered_temp[(LCU_WIDTH * 2 + 8) * (LCU_WIDTH * 2 + 8) + 1];
-
-  kvz_pixel *recf = &rec_filtered_temp[recstride + 1];
-
-  assert(width == 4 || width == 8 || width == 16 || width == 32);

   // Store original block for SAD computation
   kvz_pixels_blit(orig, orig_block, width, width, origstride, width);

-  // Generate filtered reference pixels.
-  {
-    int16_t x, y;
-    for (y = -1; y < recstride; y++) {
-      recf[y*recstride - 1] = rec[y*recstride - 1];
-    }
-    for (x = 0; x < recstride; x++) {
-      recf[x - recstride] = rec[x - recstride];
-    }
-    kvz_intra_filter(recf, recstride, width, 0);
-  }
-
   int8_t modes_selected = 0;
   unsigned min_cost = UINT_MAX;
   unsigned max_cost = 0;
@@ -387,18 +371,15 @@
   int offset;
   if (state->encoder_control->full_intra_search) {
     offset = 1;
-  } else if (width == 4) {
-    offset = 2;
-  } else if (width == 8) {
-    offset = 4;
   } else {
-    offset = 8;
+    static const int8_t offsets[4] = { 2, 4, 8, 8 };
+    offset = offsets[log2_width - 2];
   }

   // Calculate SAD for evenly spaced modes to select the starting point for
   // the recursive search.
   for (int mode = 2; mode <= 34; mode += offset) {
-    kvz_intra_get_pred(state->encoder_control, rec, recf, recstride, pred, width, mode, 0);
+    kvz_intra_get_pred_new(refs, log2_width, mode, COLOR_Y, pred);
     costs[modes_selected] = get_cost(state, pred, orig_block, satd_func, sad_func, width);
     modes[modes_selected] = mode;

@@ -421,7 +402,7 @@
       int8_t center_node = best_mode;
       int8_t mode = center_node - offset;
       if (mode >= 2) {
-        kvz_intra_get_pred(state->encoder_control, rec, recf, recstride, pred, width, mode, 0);
+        kvz_intra_get_pred_new(refs, log2_width, mode, COLOR_Y, pred);
         costs[modes_selected] = get_cost(state, pred, orig_block, satd_func, sad_func, width);
         modes[modes_selected] = mode;
         if (costs[modes_selected] < best_cost) {
@@ -433,7 +414,7 @@

       mode = center_node + offset;
       if (mode <= 34) {
-        kvz_intra_get_pred(state->encoder_control, rec, recf, recstride, pred, width, mode, 0);
+        kvz_intra_get_pred_new(refs, log2_width, mode, COLOR_Y, pred);
         costs[modes_selected] = get_cost(state, pred, orig_block, satd_func, sad_func, width);
         modes[modes_selected] = mode;
         if (costs[modes_selected] < best_cost) {
@@ -460,7 +441,7 @@
     }

     if (!has_mode) {
-      kvz_intra_get_pred(state->encoder_control, rec, recf, recstride, pred, width, mode, 0);
+      kvz_intra_get_pred_new(refs, log2_width, mode, COLOR_Y, pred);
       costs[modes_selected] = get_cost(state, pred, orig_block, satd_func, sad_func, width);
       modes[modes_selected] = mode;
       ++modes_selected;
@@ -776,11 +757,14 @@
   const vector2d_t lcu_cu = { lcu_px.x >> 3, lcu_px.y >> 3 };
   const int8_t cu_width = (LCU_WIDTH >> (depth));
   const int cu_index = LCU_CU_OFFSET + lcu_cu.x + lcu_cu.y * LCU_T_CU_WIDTH;
+  const int_fast8_t log2_width = LOG2_LCU_WIDTH - depth;

   cu_info_t *cur_cu = &lcu->cu[cu_index];

   kvz_pixel rec_buffer[(LCU_WIDTH * 2 + 1) * (LCU_WIDTH * 2 + 1)];
   kvz_pixel *cu_in_rec_buffer = &rec_buffer[cu_width * 2 + 8 + 1];
+
+  kvz_intra_references refs;

   int8_t candidate_modes[3];

@@ -798,12 +782,16 @@
   kvz_intra_get_dir_luma_predictor(x_px, y_px, candidate_modes, cur_cu, left_cu, above_cu);

   if (depth > 0) {
-  // Build reconstructed block to use in prediction with extrapolated borders
-  kvz_intra_build_reference_border(state->encoder_control, x_px, y_px, cu_width * 2 + 8,
-                               rec_buffer, cu_width * 2 + 8, 0,
-                               frame->width,
-                               frame->height,
-                               lcu);
+    // Build reconstructed block to use in prediction with extrapolated borders
+    kvz_intra_build_reference_border(state->encoder_control, x_px, y_px, cu_width * 2 + 8,
+                                 rec_buffer, cu_width * 2 + 8, 0,
+                                 frame->width,
+                                 frame->height,
+                                 lcu);
+
+    const vector2d_t luma_px = { x_px, y_px };
+    const vector2d_t pic_px = { state->tile->frame->width, state->tile->frame->height };
+    kvz_intra_build_reference(log2_width, COLOR_Y, &luma_px, &pic_px, lcu, &refs);
   }

   int8_t modes[35];
@@ -817,10 +805,10 @@
   bool skip_rough_search = (depth == 0 || state->encoder_control->rdo >= 3);
   if (!skip_rough_search) {
     number_of_modes = search_intra_rough(state,
-                                              ref_pixels, LCU_WIDTH,
-                                              cu_in_rec_buffer, cu_width * 2 + 8,
-                                              cu_width, candidate_modes,
-                                              modes, costs);
+                                         ref_pixels, LCU_WIDTH,
+                                         &refs,
+                                         log2_width, candidate_modes,
+                                         modes, costs);
   } else {
     number_of_modes = 35;
     for (int i = 0; i < number_of_modes; ++i) {


Really handle a couple error cases with realloc()

--- src/socket/netdb.c
+++ src/socket/netdb.c
@@ -267,7 +267,10 @@
 	{
 		/* XXX only realloc() once */
 		if((p = realloc(ret, len + 2)) == NULL)
-			break;
+		{
+			free(ret);
+			return NULL;
+		}
 		ret = p;
 		p[len++] = **s;
 	}
@@ -391,7 +394,10 @@
 	{
 		/* XXX only realloc() once */
 		if((p = realloc(ret, len + 2)) == NULL)
-			break;
+		{
+			free(ret);
+			return NULL;
+		}
 		ret = p;
 		p[len++] = **s;
 	}


Implement fclose

Implement fclose

error: pathspec 'src/stdio/fclose.c' did not match any file(s) known to git

--- src/stdio/fclose.c
+++ src/stdio/fclose.c
@@ -0,0 +1,17 @@
+#include "FILE.h"
+#include <stdio.h>
+
+extern _Thread_local int errno;
+
+int __close(int);
+
+int fclose(FILE stream[static 1])
+{
+    int status = __close(stream->fd);
+
+    if (status >= 0)
+        return status;
+
+    errno = -status;
+    return EOF;
+}


Bug null pointer fixed

Bug null pointer fixed

--- src/table_parser.c
+++ src/table_parser.c
@@ -149,7 +149,7 @@
     int kraj = section_length - 1;
     int poc = program_info_length + 3 + 9;
     int i = 0;
-    teletekst = 0;
+    *teletekst = 0;
     for (i = 0; poc < kraj; i++)
     {
         pmtServiceInfoArray[i].stream_type = (uint8_t) (*(buffer + poc));


tendCalc.c no longer used; tend calc has been replaced by tend estim

git-svn-id: 9e9401559e51101c165cdce4d49b411eb20436ed@2979 3d70eeeb-363e-0410-a505-8a46323a89f2

--- src/ten/tendCalc.c
+++ src/ten/tendCalc.c
@@ -1,81 +0,0 @@
-/*
-  Teem: Tools to process and visualize scientific data and images
-  Copyright (C) 2005  Gordon Kindlmann
-  Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998  University of Utah
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public License
-  (LGPL) as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-  The terms of redistributing and/or modifying this software also
-  include exceptions to the LGPL that facilitate static linking.
-
-  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 "ten.h"
-#include "privateTen.h"
-
-#define INFO "Calculate tensors from DW images"
-char *_tend_calcInfoL =
-  (INFO
-   ".  The tensors are calculated everwhere but the threshold and slope "
-   "arguments determine what the confidence values are.  The output is a "
-   "volume with 7 values per float: confidence, Dxx, Dxy, Dxz, Dyy, Dyz, "
-   "Dzz.  The confidence values range from 0.0 to 1.0");
-
-int
-tend_calcMain(int argc, char **argv, char *me, hestParm *hparm) {
-  int pret, version;
-  hestOpt *hopt = NULL;
-  char *perr, *err;
-  airArray *mop;
-
-  Nrrd *nin, *nout;
-  char *outS;
-  float thresh, slope, b;
-
-  hestOptAdd(&hopt, "t", "thresh", airTypeFloat, 1, 1, &thresh, NULL,
-             "confidence threshold");
-  hestOptAdd(&hopt, "s", "slope", airTypeFloat, 1, 1, &slope, "0.01",
-             "d(confidence)/dv at threshold");
-  hestOptAdd(&hopt, "b", "b", airTypeFloat, 1, 1, &b, "1",
-             "b value from scan");
-  hestOptAdd(&hopt, "v", "version", airTypeInt, 1, 1, &version, "1",
-             "which set of gradient directions are used, either 1 or 2");
-  hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-",
-             "input volume of diffusion-weighted images",
-             NULL, NULL, nrrdHestNrrd);
-  hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-",
-             "output image (floating point)");
-
-  mop = airMopNew();
-  airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
-  USAGE(_tend_calcInfoL);
-  PARSE();
-  airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
-
-  nout = nrrdNew();
-  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
-  if (tenCalcTensor(nout, nin, version, thresh, slope, b)) {
-    airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways);
-    fprintf(stderr, "%s: tenCalcTensor failed:\n%s", me, err);
-    airMopError(mop); return 1;
-  }
-  if (nrrdSave(outS, nout, NULL)) {
-    airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways);
-    fprintf(stderr, "%s: trouble writing:\n%s\n", me, err);
-    airMopError(mop); return 1;
-  }
-
-  airMopOkay(mop);
-  return 0;
-}
-TEND_CMD(calc, INFO);


tests/matrix: Ensure that rotations are additive

Rotating by 45° → 15° is equivalent to rotating by 60°.

--- src/tests/matrix.c
+++ src/tests/matrix.c
@@ -65,6 +65,14 @@

   graphene_matrix_rotate (&m, 45.0f, graphene_vec3_x_axis ());
   graphene_matrix_init_rotate (&m2, 45.0f, graphene_vec3_x_axis ());
+
+  if (g_test_verbose ())
+    graphene_matrix_print (&m);
+
+  compare_matrices (&m, &m2);
+
+  graphene_matrix_rotate (&m, 15.0f, graphene_vec3_x_axis ());
+  graphene_matrix_init_rotate (&m2, 60.0f, graphene_vec3_x_axis ());

   if (g_test_verbose ())
     graphene_matrix_print (&m);


Fix luax_checkendpoints when direction is not normalized;

--- src/api/l_graphics_pass.c
+++ src/api/l_graphics_pass.c
@@ -656,11 +656,13 @@
   float forward[4] = { 0.f, 0.f, -1.f, 0.f };
   float direction[4];
   vec3_sub(vec3_init(direction, u), v);
+  float length = vec3_length(direction);
+  vec3_normalize(direction);
   quat_between(orientation, forward, direction);
   mat4_identity(transform);
   mat4_translate(transform, (v[0] + u[0]) / 2.f, (v[1] + u[1]) / 2.f, (v[2] + u[2]) / 2.f);
   mat4_rotateQuat(transform, orientation);
-  mat4_scale(transform, radius, radius, vec3_length(direction));
+  mat4_scale(transform, radius, radius, length);
   return true;
 }


Issue: remove trailing spaces.

Issue: remove trailing spaces.

--- src/api/libcellml/issue.h
+++ src/api/libcellml/issue.h
@@ -46,7 +46,7 @@
      *   auto issue = libcellml::Issue::create();
      *
      * or an issue with one of the following types as a parameter::
-     *
+     *
      *   - libcellml::ComponentPtr (defaults the item type to ItemType::COMPONENT);
      *   - libcellml::ImportSourcePtr (defaults the item type to ItemType::IMPORT);
      *   - libcellml::ModelPtr (defaults the item type to ItemType::MODEL);
@@ -284,7 +284,7 @@

     /**
      * @brief Set the component relevant to this issue.
-     *
+     *
      * The internal type will be set to @c ItemType::COMPONENT.
      *
      * @param component A @c ComponentPtr relevant to this issue.
@@ -294,7 +294,7 @@
     /**
      * Get the component relevant to this issue.
      *
-     * @return A @c Component relevant to this issue, or
+     * @return A @c Component relevant to this issue, or
      *         a @c nullptr if the internal type is not @c ItemType::COMPONENT.
      */
     ComponentPtr component() const;
@@ -311,7 +311,7 @@
     /**
      * Get the import source relevant to this issue.
      *
-     * @return An @c ImportSourcePtr relevant to this issue, or
+     * @return An @c ImportSourcePtr relevant to this issue, or
      *         a @c nullptr if the internal type is not @c ItemType::IMPORT.
      */
     ImportSourcePtr importSource() const;
@@ -328,7 +328,7 @@
     /**
      * Get the model relevant to this issue.
      *
-     * @return A @c ModelPtr relevant to this issue, or
+     * @return A @c ModelPtr relevant to this issue, or
      *         a @c nullptr if the internal type is not @c ItemType::MODEL.
      */
     ModelPtr model() const;
@@ -345,7 +345,7 @@
     /**
      * Get the units relevant to this issue.
      *
-     * @return A @c UnitsPtr relevant to this issue, or
+     * @return A @c UnitsPtr relevant to this issue, or
      *         a @c nullptr if the internal type is not @c ItemType::UNITS.
      */
     UnitsPtr units() const;
@@ -362,7 +362,7 @@
     /**
      * Get the variable relevant to this issue.
      *
-     * @return A @c VariablePtr relevant to this issue, or
+     * @return A @c VariablePtr relevant to this issue, or
      *         a @c nullptr if the internal type is not @c ItemType::VARIABLE.
      */
     VariablePtr variable() const;
@@ -386,7 +386,7 @@

     /**
      * @brief Set the component whose MathML is relevant to this issue.
-     *
+     *
      * The internal type will be set to @c ItemType::MATHML.
      *
      * @param component The @c ComponentPtr whose MathML is relevant to this issue.
@@ -395,7 +395,7 @@

     /**
      * Get the component whose MathML is relevant to this issue.
-     *
+     *
      * @return A @c ComponentPtr whose MathML is relevant to this issue, or @c nullptr
      *         if the internal type is not @c ItemType::MATHML.
      */
@@ -403,7 +403,7 @@

     /**
      * @brief Set the connection relevant to this issue.
-     *
+     *
      * The internal type will be set to @c ItemType::CONNECTION.
      *
      * @param pair The @c VariablePair whose connection is relevant to this issue.
@@ -412,7 +412,7 @@

     /**
      * Get the connection relevant to this issue.
-     *
+     *
      * @return A @c VariablePair representing the connection relevant to this issue,
      *         or @c std::pair(nullptr,nullptr) if the internal type is not @c ItemType::CONNECTION.
      */
@@ -420,7 +420,7 @@

     /**
      * @brief Set the variable mapping relevant to this issue.
-     *
+     *
      * The internal type will be set to @c ItemType::MAP_VARIABLES.
      *
      * @param pair The @c VariablePair whose equivalence is relevant to this issue.
@@ -429,7 +429,7 @@

     /**
      * Get the equivalent variable pair relevant to this issue.
-     *
+     *
      * @return A @c VariablePair representing the variable equivalence relevant to this issue,
      *         or @c std::pair(nullptr,nullptr) if the internal type is not @c ItemType::MAP_VARIABLES.
      */
@@ -437,7 +437,7 @@

     /**
      * @brief Set the reset whose reset value is relevant to this issue.
-     *
+     *
      * The internal type will be set to @c ItemType::RESET_VALUE.
      *
      * @param reset A @c ResetPtr whose reset value is relevant to this issue.
@@ -454,7 +454,7 @@

     /**
      * @brief Set the reset whose test value is relevant to this issue.
-     *
+     *
      * The internal type will be set to @c ItemType::TEST_VALUE.
      *
      * @param reset A @c ResetPtr whose test value is relevant to this issue.
@@ -471,7 +471,7 @@

     /**
      * @brief Set the @c UnitItem whose relevant to this issue.
-     *
+     *
      * The internal type will be set to @c ItemType::UNIT.
      *
      * @param unit A @c UnitItem relevant to this issue.
@@ -488,7 +488,7 @@

     /**
      * @brief Set the @c ModelPtr whose encapsulation is relevant to this issue.
-     *
+     *
      * The internal type will be set to @c ItemType::ENCAPSULATION.
      *
      * @param model A @c ModelPtr whose encapsulation is relevant to this issue.
@@ -505,7 +505,7 @@

     /**
      * @brief Set the @c ComponentPtr whose encapsulation position is relevant to this issue.
-     *
+     *
      * The internal type will be set to @c ItemType::COMPONENT_REF.
      *
      * @param component A @c ComponentPtr whose encapsulation position is relevant to this issue.
@@ -524,14 +524,14 @@
      * @brief Get the @ref ItemType enum for the stored item.
      *
      * Get the @ref ItemType enum for the stored item.
-     *
+     *
      * @return The @ref ItemType enum for the stored item, or @ref ItemType::UNDEFINED if none.
      */
     ItemType itemType() const;

     /**
      * @brief Set an @c std::any item relevant to this issue.
-     *
+     *
      * Set an @c std::any item relevant to this issue.
      *
      * @param item An @c std::any item relevant to this issue.
@@ -541,17 +541,17 @@

     /**
      * Get the stored item as an @c std::any item.
-     *
+     *
      * Get the stored item as an @c std::any item.
      * Note that the stored @ref ItemType can be retrieved using itemType().
-     *
+     *
      * @return A @c std::any item related to this issue.
      */
     std::any item() const;

     /**
      * @brief Clear the stored item.
-     *
+     *
      * Clear the issue returning it to its initial state.
      */
     void clear();


Model: no need for Parser to be a friend class.

--- src/api/libcellml/model.h
+++ src/api/libcellml/model.h
@@ -39,8 +39,6 @@
                               public std::enable_shared_from_this<Model>
 #endif
 {
-    friend class Parser;
-
 public:
     ~Model() override; /**< Destructor. */
     Model(const Model &rhs) = delete; /**< Copy constructor. */


x86: Disable breakpoints in VCPUs

x86: Disable breakpoints in VCPUs

This change allows CONFIG_VTX to work with CONFIG_HARDWARE_BREAKPOINT_SUPPORT
We do not allow for setting hardware breakpoints to be triggered during
guest execution, rather we disable any breakpoints when switching to a VCPU

In addition to disabling any breakpoints before switching to a guest the
hardware will reload DR7 on guest exit to not have any breakpoints set.
Thus the guest is already prevented from setting breakpoints that can get
triggered once we exit the guest. Although our breakpoint state has been
cleared if we then switch to a native thread all of the breakpoint state
will already get reloaded.

--- src/arch/x86/32/c_traps.c
+++ src/arch/x86/32/c_traps.c
@@ -35,6 +35,10 @@
 static void NORETURN restore_vmx(void)
 {
     restoreVMCS();
+#ifdef CONFIG_HARDWARE_DEBUG_API
+    /* Do not support breakpoints in VMs, so just disable all breakpoints */
+    loadAllDisabledBreakpointState(&NODE_STATE(ksCurThread)->tcbArch);
+#endif
 #if CONFIG_MAX_NUM_NODES > 1
     NODE_STATE(ksCurThread)->tcbArch.vcpu->kernelSP = ((word_t)kernel_stack_alloc[getCurrentCPUIndex()]) + 0xffc;
 #endif


added transport support for ForceClear and OwnerClear

--- src/tspi/tsp_own.c
+++ src/tspi/tsp_own.c
@@ -4,7 +4,7 @@
  *
  * trousers - An open source TCG Software Stack
  *
- * (C) Copyright International Business Machines Corp. 2004, 2005
+ * (C) Copyright International Business Machines Corp. 2004-2007
  *
  */

@@ -160,3 +160,37 @@

 	return TSS_SUCCESS;
 }
+
+#ifdef TSS_BUILD_TRANSPORT
+TSS_RESULT
+Transport_OwnerClear(TSS_HCONTEXT tspContext,	/* in */
+		     TPM_AUTH * ownerAuth)	/* in, out */
+{
+	TSS_RESULT result;
+	UINT32 handlesLen = 0;
+
+	if ((result = obj_context_transport_init(tspContext)))
+		return result;
+
+	LogDebugFn("Executing in a transport session");
+
+	return obj_context_transport_execute(tspContext, TPM_ORD_OwnerClear, 0, NULL, NULL,
+					     &handlesLen, NULL, ownerAuth, NULL, NULL, NULL);
+}
+
+TSS_RESULT
+Transport_ForceClear(TSS_HCONTEXT tspContext)	/* in */
+{
+	TSS_RESULT result;
+	UINT32 handlesLen = 0;
+
+	if ((result = obj_context_transport_init(tspContext)))
+		return result;
+
+	LogDebugFn("Executing in a transport session");
+
+	return obj_context_transport_execute(tspContext, TPM_ORD_ForceClear, 0, NULL, NULL,
+					     &handlesLen, NULL, NULL, NULL, NULL, NULL);
+}
+#endif
+


Set f.lux to use ol_color_channel_t

Set f.lux to use ol_color_channel_t

--- src/backend/kelvin/flux.c
+++ src/backend/kelvin/flux.c
@@ -42,7 +42,8 @@

 /*** F.lux's windows algorithm, as of 21 april 2016 ***/

-double _ol_flux_curve(double curvei, double kelvin)
+double
+_ol_flux_curve(double curvei, double kelvin)
 {
   return
     pow(curvei * 0.000000001, -5.0) *
@@ -51,15 +52,16 @@

 extern float* ol_backend_kelvin_flux_data;

-void _ol_flux_kelvinkore(double kelvin,
-                         float* red,
-                         float* green,
-                         float* blue)
+void
+_ol_flux_kelvinkore(double kelvin,
+                    ol_color_channel_t* red,
+                    ol_color_channel_t* green,
+                    ol_color_channel_t* blue)
 {
   int curvei;
   float *datap = ol_backend_kelvin_flux_data;
-  float curve;
-  double temp;
+  double curve;
+  ol_color_channel_t temp;

   *red = 0.0;
   *green = 0.0;
@@ -78,12 +80,13 @@
     }
 }

-void _ol_flux_normkk(double kelvin,
-                     float* red,
-                     float* green,
-                     float* blue)
-{
-  float total;
+void
+_ol_flux_normkk(double kelvin,
+                ol_color_channel_t* red,
+                ol_color_channel_t* green,
+                ol_color_channel_t* blue)
+{
+  ol_color_channel_t total;

   _ol_flux_kelvinkore(kelvin, red, green, blue);

@@ -94,9 +97,10 @@
   *blue  /= total;
 }

-double _ol_flux_processchannel(float channel)
-{
-  float temp;
+ol_color_channel_t
+_ol_flux_processchannel(ol_color_channel_t channel)
+{
+  ol_color_channel_t temp;

   if (channel > 0.0031308)
     {
@@ -109,11 +113,12 @@
     }
 }

-void _ol_flux_normrgb(float* red,
-                      float* green,
-                      float* blue)
-{
-  double maxchannel = *red;
+void
+_ol_flux_normrgb(ol_color_channel_t* red,
+                 ol_color_channel_t* green,
+                 ol_color_channel_t* blue)
+{
+  ol_color_channel_t maxchannel = *red;

   if (maxchannel < *green)
     maxchannel = *green;
@@ -141,12 +146,13 @@

 }

-void _ol_flux_processrgb(float ired,
-                         float igreen,
-                         float iblue,
-                         float* ored,
-                         float* ogreen,
-                         float* oblue)
+void
+_ol_flux_processrgb(ol_color_channel_t ired,
+                    ol_color_channel_t igreen,
+                    ol_color_channel_t iblue,
+                    ol_color_channel_t* ored,
+                    ol_color_channel_t* ogreen,
+                    ol_color_channel_t* oblue)
 {
   *ored   = (ired * 3.2406)   - (igreen * 1.5372) - (iblue * 0.4986);
   *ogreen = (igreen * 1.8758) - (ired * 0.9689)   + (iblue * 0.0415);
@@ -159,34 +165,36 @@
   _ol_flux_normrgb(ored, ogreen, oblue);
 }

-void _ol_flux_kelvin_raw(float kelvin,
-                         float* ored,
-                         float* ogreen,
-                         float* oblue)
-{
-  float red;
-  float green;
-  float blue;
+void
+_ol_flux_kelvin_raw(double kelvin,
+                    ol_color_channel_t* ored,
+                    ol_color_channel_t* ogreen,
+                    ol_color_channel_t* oblue)
+{
+  ol_color_channel_t red;
+  ol_color_channel_t green;
+  ol_color_channel_t blue;

   _ol_flux_normkk(kelvin, &red, &green, &blue);

   if (red != 0.0 && green != 0.0 && blue != 0.0)
     {
       _ol_flux_processrgb( red,  green,  blue,
-                          ored, ogreen, oblue);
-    }
-}
-
-float _ol_flux_whitekred   = 0.0;
-float _ol_flux_whitekgreen = 0.0;
-float _ol_flux_whitekblue  = 0.0;
-
-void _ol_flux_kelvin(float kelvin,
-                     float* red,
-                     float* green,
-                     float* blue)
-{
-  float temp;
+                           ored, ogreen, oblue);
+    }
+}
+
+ol_color_channel_t _ol_flux_whitekred   = 0.0;
+ol_color_channel_t _ol_flux_whitekgreen = 0.0;
+ol_color_channel_t _ol_flux_whitekblue  = 0.0;
+
+void
+_ol_flux_kelvin(double kelvin,
+                ol_color_channel_t* red,
+                ol_color_channel_t* green,
+                ol_color_channel_t* blue)
+{
+  ol_color_channel_t temp;

   if (_ol_flux_whitekred == 0.0)
     {
@@ -230,12 +238,7 @@
   ol_color_channel_t green = 0.;
   ol_color_channel_t blue  = 0.;

-  float rgb1, rgb2, rgb3;
-
-  _ol_flux_kelvin(kelvin, &rgb1, &rgb2, &rgb3);
-  red   = rgb1;
-  green = rgb2;
-  blue  = rgb3;
+  _ol_flux_kelvin(kelvin, &red, &green, &blue);

   red   = OL_COLOR_LIMIT(red);
   green = OL_COLOR_LIMIT(green);


remove unnecessary evas_get call

remove unnecessary evas_get call

SVN revision: 73238

--- src/bin/e_config_dialog.c
+++ src/bin/e_config_dialog.c
@@ -197,7 +197,7 @@
      {
         if (cfd->view->advanced.create_widgets)
           {
-             o = e_widget_list_add(e_win_evas_get(cfd->dia->win), 0, 0);
+             o = e_widget_list_add(evas, 0, 0);
              ob = cfd->view->basic.create_widgets(cfd, evas, cfd->cfdata);
              if (cfd->view->scroll)
                {


Need an e_win_show here as the border may not have been 'iconified' but
rather 'hidden' completely.

git-svn-id: 6ac5796aeae0cef97fb47bcc287d4ce899c6fa6e@48137 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/bin/e_config_dialog.c
+++ src/bin/e_config_dialog.c
@@ -96,6 +96,7 @@

 	     z = e_util_zone_current_get(e_manager_current_get());
 	     e_border_uniconify(cfd->dia->win->border);
+             e_win_show(cfd->dia->win);
 	     e_win_raise(cfd->dia->win);
 	     if (z->container == cfd->dia->win->border->zone->container)
 	       e_border_desk_set(cfd->dia->win->border, e_desk_current_get(z));


Handle out of memory in gpfdist

Handle out of memory in gpfdist

Make sure all memory allocations properly checks the returned pointer
for success, and exit immediately on out of memory.

Also do minor stylistic cleanups around the allocations when passing
by and change one malloc/free to realloc.

Reviewed-by: Heikki Linnakangas <9304c20251d03f4d84fc732cc8196e9ef6638e64@pivotal.io>

--- src/bin/gpfdist/gpfdist.c
+++ src/bin/gpfdist/gpfdist.c
@@ -2818,7 +2818,10 @@

 void *gfile_malloc(size_t size)
 {
-	return malloc(size);
+	void *p = malloc(size);
+	if (!p)
+		gfatal(NULL, "Out of memory");
+	return p;
 }

 void gfile_free(void *a)
@@ -3683,20 +3686,22 @@
 int verify_buf_size(char** pBuf, const char* _in_val)
 {
 	int val_len, new_len;
+	char *p;

 	val_len = (int)strlen(_in_val);
 	if (val_len >= CMD_LINE_ARG_SIZE)
 	{
 		new_len = ((val_len+1) >= CMD_LINE_ARG_MAX_SIZE) ? CMD_LINE_ARG_MAX_SIZE : (val_len+1);
-		free(*pBuf);
-		*pBuf = (char*)malloc(new_len);
+		p = realloc(*pBuf, new_len);
+		if (p == NULL)
+			return 0;
+		*pBuf = p;
 		memset(*pBuf, 0, new_len);
 	}
 	else
 	{
 		new_len = val_len;
 	}
-

 	return new_len;
 }
@@ -3708,6 +3713,8 @@
 	for (i = 0; i < CMD_LINE_ARG_NUM; i++)
 	{
 		cmd_line_buffer[i] = (char*)malloc(CMD_LINE_ARG_SIZE);
+		if (cmd_line_buffer[i] == NULL)
+			gfatal(NULL, "Out of memory");
 		memset(cmd_line_buffer[i], 0, CMD_LINE_ARG_SIZE);
 	}

@@ -3729,6 +3736,8 @@
 	{
 		int len;
 		len = verify_buf_size(&cmd_line_buffer[i], argv[i]);
+		if (!len)
+			gfatal(NULL, "Out of memory");
 		memcpy(cmd_line_buffer[i], argv[i], len);
 	}
 }
@@ -3931,16 +3940,17 @@
 	if ( RAND_poll() == 0 )
 		gfatal(NULL,"Can't generate random seed for SSL");

-	/* The size of the string will consist of the path and the filename (the longest one) */
-	// +1 for the '/' character (/filename)
-	// +1 for the \0,
-	stringSize = find_max( strlen(CertificateFilename), find_max(strlen(PrivateKeyFilename),strlen(TrustedCaFilename)) ) + strlen(opt.ssl) + 2;
+	/*
+	 * The size of the string will consist of the path and the filename (the
+	 * longest one)
+	 * +1 for the '/' character (/filename)
+	 * +1 for the \0
+	 */
+	stringSize = find_max(strlen(CertificateFilename), find_max(strlen(PrivateKeyFilename), strlen(TrustedCaFilename))) + strlen(opt.ssl) + 2;
 	/* Allocate the memory for the file name */
-	fileName = (char *) calloc( (stringSize), sizeof(char) );
-	if ( fileName == NULL )
-	{
+	fileName = (char *) calloc((stringSize), sizeof(char));
+	if (fileName == NULL)
 		gfatal (NULL,"Unable to allocate memory for SSL initialization");
-	}

 #ifdef WIN32
 	slash = '\\';


unix: put child process stdio fds in blocking mode

Remove the O_NONBLOCK flag from file descriptors 0-2, most applications don't
expect EAGAIN errors when dealing with stdio.

--- src/unix/process.c
+++ src/unix/process.c
@@ -240,6 +240,9 @@
     } else {
       uv__cloexec(use_fd, 0);
     }
+
+    if (fd <= 2)
+      uv__nonblock(fd, 0);
   }

   if (options.cwd && chdir(options.cwd)) {


pg_dump: improve EXTERNAL TABLE query whitespace

Whitespace diff only; no other changes.

--- src/bin/pg_dump/pg_dump.c
+++ src/bin/pg_dump/pg_dump.c
@@ -11233,75 +11233,75 @@
 		if (gpdb5OrLater)
 		{
 			appendPQExpBuffer(query,
-						  "SELECT x.urilocation, x.execlocation, x.fmttype, x.fmtopts, x.command, "
-								  "x.rejectlimit, x.rejectlimittype, "
-						      "(SELECT relname "
-						          "FROM pg_catalog.pg_class "
-								  "WHERE Oid=x.fmterrtbl) AS errtblname, "
-								  "x.fmterrtbl = x.reloid AS errortofile , "
-								  "pg_catalog.pg_encoding_to_char(x.encoding), "
-								  "x.writable, "
-								  "array_to_string(ARRAY( "
-								  "SELECT pg_catalog.quote_ident(option_name) || ' ' || "
-								  "pg_catalog.quote_literal(option_value) "
-								  "FROM pg_options_to_table(x.options) "
-								  "ORDER BY option_name"
-								  "), E',\n    ') AS options "
-						  "FROM pg_catalog.pg_exttable x, pg_catalog.pg_class c "
-						  "WHERE x.reloid = c.oid AND c.oid = '%u'::oid ", tbinfo->dobj.catId.oid);
+					"SELECT x.urilocation, x.execlocation, x.fmttype, x.fmtopts, x.command, "
+						   "x.rejectlimit, x.rejectlimittype, "
+						   "(SELECT relname "
+							"FROM pg_catalog.pg_class "
+							"WHERE Oid=x.fmterrtbl) AS errtblname, "
+						   "x.fmterrtbl = x.reloid AS errortofile , "
+						   "pg_catalog.pg_encoding_to_char(x.encoding), "
+						   "x.writable, "
+						   "array_to_string(ARRAY( "
+						   "SELECT pg_catalog.quote_ident(option_name) || ' ' || "
+						   "pg_catalog.quote_literal(option_value) "
+						   "FROM pg_options_to_table(x.options) "
+						   "ORDER BY option_name"
+						   "), E',\n    ') AS options "
+					"FROM pg_catalog.pg_exttable x, pg_catalog.pg_class c "
+					"WHERE x.reloid = c.oid AND c.oid = '%u'::oid ", tbinfo->dobj.catId.oid);
 		}
 		else if (g_fout->remoteVersion >= 80214)
 		{
 			appendPQExpBuffer(query,
-					   "SELECT x.location, "
-							  "CASE WHEN x.command <> '' THEN x.location "
-								   "ELSE '{ALL_SEGMENTS}' "
-							  "END AS execlocation, "
-							  "x.fmttype, x.fmtopts, x.command, "
-							  "x.rejectlimit, x.rejectlimittype, "
-						 "n.nspname AS errnspname, d.relname AS errtblname, "
-					"pg_catalog.pg_encoding_to_char(x.encoding), x.writable "
-							  "FROM pg_catalog.pg_class c "
-					 "JOIN pg_catalog.pg_exttable x ON ( c.oid = x.reloid ) "
-				"LEFT JOIN pg_catalog.pg_class d ON ( d.oid = x.fmterrtbl ) "
-							  "LEFT JOIN pg_catalog.pg_namespace n ON ( n.oid = d.relnamespace ) "
-							  "WHERE c.oid = '%u'::oid ",
-							  tbinfo->dobj.catId.oid);
+					"SELECT x.location, "
+						   "CASE WHEN x.command <> '' THEN x.location "
+								"ELSE '{ALL_SEGMENTS}' "
+						   "END AS execlocation, "
+						   "x.fmttype, x.fmtopts, x.command, "
+						   "x.rejectlimit, x.rejectlimittype, "
+						   "n.nspname AS errnspname, d.relname AS errtblname, "
+						   "pg_catalog.pg_encoding_to_char(x.encoding), x.writable "
+					"FROM pg_catalog.pg_class c "
+					"JOIN pg_catalog.pg_exttable x ON ( c.oid = x.reloid ) "
+					"LEFT JOIN pg_catalog.pg_class d ON ( d.oid = x.fmterrtbl ) "
+					"LEFT JOIN pg_catalog.pg_namespace n ON ( n.oid = d.relnamespace ) "
+					"WHERE c.oid = '%u'::oid ",
+					tbinfo->dobj.catId.oid);
 		}
 		else if (g_fout->remoteVersion >= 80205)
 		{

 			appendPQExpBuffer(query,
-					   "SELECT x.location, "
-							  "CASE WHEN x.command <> '' THEN x.location "
-								   "ELSE '{ALL_SEGMENTS}' "
-							  "END AS execlocation, "
-							  "x.fmttype, x.fmtopts, x.command, "
-							  "x.rejectlimit, x.rejectlimittype, "
-						 "n.nspname AS errnspname, d.relname AS errtblname, "
-			  "pg_catalog.pg_encoding_to_char(x.encoding), null as writable "
-							  "FROM pg_catalog.pg_class c "
-					 "JOIN pg_catalog.pg_exttable x ON ( c.oid = x.reloid ) "
-				"LEFT JOIN pg_catalog.pg_class d ON ( d.oid = x.fmterrtbl ) "
-							  "LEFT JOIN pg_catalog.pg_namespace n ON ( n.oid = d.relnamespace ) "
-							  "WHERE c.oid = '%u'::oid ",
-							  tbinfo->dobj.catId.oid);
+					"SELECT x.location, "
+						   "CASE WHEN x.command <> '' THEN x.location "
+								"ELSE '{ALL_SEGMENTS}' "
+						   "END AS execlocation, "
+						   "x.fmttype, x.fmtopts, x.command, "
+						   "x.rejectlimit, x.rejectlimittype, "
+						   "n.nspname AS errnspname, d.relname AS errtblname, "
+						   "pg_catalog.pg_encoding_to_char(x.encoding), null as writable "
+					"FROM pg_catalog.pg_class c "
+					"JOIN pg_catalog.pg_exttable x ON ( c.oid = x.reloid ) "
+					"LEFT JOIN pg_catalog.pg_class d ON ( d.oid = x.fmterrtbl ) "
+					"LEFT JOIN pg_catalog.pg_namespace n ON ( n.oid = d.relnamespace ) "
+					"WHERE c.oid = '%u'::oid ",
+					tbinfo->dobj.catId.oid);
 		}
 		else
 		{
 			/* not SREH and encoding colums yet */
 			appendPQExpBuffer(query,
-					   "SELECT x.location, "
-							  "CASE WHEN x.command <> '' THEN x.location "
-								   "ELSE '{ALL_SEGMENTS}' "
-							  "END AS execlocation, "
-							  "x.fmttype, x.fmtopts, x.command, "
-							  "-1 as rejectlimit, null as rejectlimittype,"
-							  "null as errnspname, null as errtblname, "
-							  "null as encoding, null as writable "
-					  "FROM pg_catalog.pg_exttable x, pg_catalog.pg_class c "
-							  "WHERE x.reloid = c.oid AND c.oid = '%u'::oid",
-							  tbinfo->dobj.catId.oid);
+					"SELECT x.location, "
+						   "CASE WHEN x.command <> '' THEN x.location "
+								"ELSE '{ALL_SEGMENTS}' "
+						   "END AS execlocation, "
+						   "x.fmttype, x.fmtopts, x.command, "
+						   "-1 as rejectlimit, null as rejectlimittype,"
+						   "null as errnspname, null as errtblname, "
+						   "null as encoding, null as writable "
+					"FROM pg_catalog.pg_exttable x, pg_catalog.pg_class c "
+					"WHERE x.reloid = c.oid AND c.oid = '%u'::oid",
+					tbinfo->dobj.catId.oid);
 		}

 		res = PQexec(g_conn, query->data);


re-arranging code, and adding long-overdue airMop-based error handling

git-svn-id: 9e9401559e51101c165cdce4d49b411eb20436ed@5318 3d70eeeb-363e-0410-a505-8a46323a89f2

--- src/unrrdu/histo.c
+++ src/unrrdu/histo.c
@@ -35,9 +35,9 @@
   hestOpt *opt = NULL;
   char *out, *err;
   Nrrd *nin, *nout, *nwght;
-  char *_minStr, *_maxStr, *minStr, *maxStr, *mmStr;
+  char *_minStr, *_maxStr, *minStr, *maxStr;
   int type, pret, blind8BitRange,
-    minPerc=AIR_FALSE, maxPerc=AIR_FALSE, *mmPerc;
+    minPerc=AIR_FALSE, maxPerc=AIR_FALSE;
   unsigned int bins, mmIdx;
   double min, max, minval, maxval, *mm=NULL;
   NrrdRange *range;
@@ -53,7 +53,8 @@
              NULL, NULL, nrrdHestNrrd);
   hestOptAdd(&opt, "min,minimum", "value", airTypeString, 1, 1,
              &_minStr, "nan",
-             "Value at low end of histogram, given explicitly as a regular number, "
+             "Value at low end of histogram, given explicitly as a "
+             "regular number, "
              "*or*, if the number is given with a \"" MINMAX_PERC_SUFF
              "\" suffix, this "
              "minimum is specified in terms of the percentage of samples in "
@@ -83,18 +84,16 @@
   PARSE();
   airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

-  nout = nrrdNew();
-  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
-
   /* HEY COPY AND PASTE from quantize.c */
   minStr = airStrdup(_minStr);
   airMopAdd(mop, minStr, airFree, airMopAlways);
   maxStr = airStrdup(_maxStr);
   airMopAdd(mop, maxStr, airFree, airMopAlways);
-
   /* parse min and max */
   min = max = AIR_NAN;
   for (mmIdx=0; mmIdx<=1; mmIdx++) {
+    char *mmStr;
+    int *mmPerc;
     if (0 == mmIdx) {
       mm = &min;
       mmStr = minStr;
@@ -178,6 +177,9 @@
     maxval = max;
   }

+  nout = nrrdNew();
+  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
+
   /* If the input nrrd never specified min and max, then they'll be
      AIR_NAN, and nrrdRangeSafeSet will find them, and will do so
      according to blind8BitRange */
@@ -185,9 +187,9 @@
   airMopAdd(mop, range, (airMopper)nrrdRangeNix, airMopAlways);
   nrrdRangeSafeSet(range, nin, blind8BitRange);
   if (nrrdHisto(nout, nin, range, nwght, bins, type)) {
-    err = biffGet(NRRD);
+    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
     fprintf(stderr, "%s: error calculating histogram:\n%s", me, err);
-    free(err);
+    airMopError(mop);
     return 1;
   }


Fix minor memory leak in pg_dump

Fix minor memory leak in pg_dump

A query used to read default ACL information from the catalogs did not
free a set of PQExpBuffer.

Oversight in commit e2090d9, so backpatch down to 9.6.

Author: Jie Zhang
Reviewed-by: Sawada Masahiko
Discussion: e9f33d68f1042288859e78d5d58add3038dc59d9@G08CNEXMBPEKD06.g08.fujitsu.local
Backpatch-through: 9.6
(cherry picked from commit 8f4ee44bcdbcd437f860f2d048125a118335b088)

--- src/bin/pg_dump/pg_dump.c
+++ src/bin/pg_dump/pg_dump.c
@@ -10319,6 +10319,11 @@
 						  racl_subquery->data,
 						  initacl_subquery->data,
 						  initracl_subquery->data);
+
+		destroyPQExpBuffer(acl_subquery);
+		destroyPQExpBuffer(racl_subquery);
+		destroyPQExpBuffer(initacl_subquery);
+		destroyPQExpBuffer(initracl_subquery);
 	}
 	else
 	{


adding FFR code in PRCv9

adding FFR code in PRCv9

error: pathspec 'platforms/m3/prc_v9/software/FFRv1_sleep/FFRv1_sleep.c' did not match any file(s) known to git

--- platforms/m3/prc_v9/software/FFRv1_sleep/FFRv1_sleep.c
+++ platforms/m3/prc_v9/software/FFRv1_sleep/FFRv1_sleep.c
@@ -0,0 +1,121 @@
+//*******************************************************************
+//Author: ZhiYoong Foo
+//        Gyouho Kim
+//        Derived from hyeonseok_FFRv1.c under prc_v8
+//Description: FFRv1 Functionality Tests
+//*******************************************************************
+#include "mbus.h"
+#include "PRCv9.h"
+#include "FFRv1.h"
+
+#define FFR_ADDR 0x4
+#define WAKEUP_PERIOD 2
+
+//***************************************************
+// Global variables
+//***************************************************
+//Test Declerations
+volatile uint32_t enumerated;
+
+
+//***************************************************
+//Interrupt Handlers
+//Must clear pending bit!
+//***************************************************
+void handler_ext_int_0(void) __attribute__ ((interrupt ("IRQ")));
+void handler_ext_int_1(void) __attribute__ ((interrupt ("IRQ")));
+void handler_ext_int_2(void) __attribute__ ((interrupt ("IRQ")));
+void handler_ext_int_3(void) __attribute__ ((interrupt ("IRQ")));
+void handler_ext_int_0(void){
+  *((volatile uint32_t *) 0xE000E280) = 0x1;
+}
+void handler_ext_int_1(void){
+  *((volatile uint32_t *) 0xE000E280) = 0x2;
+}
+void handler_ext_int_2(void){
+  *((volatile uint32_t *) 0xE000E280) = 0x4;
+}
+void handler_ext_int_3(void){
+  *((volatile uint32_t *) 0xE000E280) = 0x8;
+}
+
+int main() {
+
+  //FFRv1 Register Declerations
+  ffrv1_r0_t ffrv1_r0 = FFRv1_R0_DEFAULT;
+  ffrv1_r1_t ffrv1_r1 = FFRv1_R1_DEFAULT;
+  ffrv1_r2_t ffrv1_r2 = FFRv1_R2_DEFAULT;
+  ffrv1_r3_t ffrv1_r3 = FFRv1_R3_DEFAULT;
+  ffrv1_r4_t ffrv1_r4 = FFRv1_R4_DEFAULT;
+
+  //Clear All Pending Interrupts
+  *((volatile uint32_t *) 0xE000E280) = 0xF;
+  //Enable Interrupts
+  *((volatile uint32_t *) 0xE000E100) = 0xF;
+
+
+  if (enumerated != 0xDEADBEEF){
+    //delay(1000);
+    //Enumeration
+    enumerate(FFR_ADDR);
+    //asm ("wfi;");
+    enumerated = 0xDEADBEEF;
+
+    ///////////////
+    //Start Testing
+    ///////////////
+
+    // Set PMU Strength & division threshold
+    // Change PMU_CTRL Register
+    // 0x8F770089 = Original
+    // Increase active oscillator freq
+    //*((volatile uint32_t *) 0xA200000C) = 0x8F772049;
+
+    delay(1000);
+
+
+    //FFRv1 R0
+    ffrv1_r0.TX_VCO_b = 0x70; //Tuning at 10GHz
+    ffrv1_r0.TX_pulse_b = 0xF ; //max pulse width
+    write_mbus_register(FFR_ADDR,0,ffrv1_r0.as_int);
+
+    //FFRv1 R1
+    ffrv1_r1.TX_FSM_TX_DATA = 0xFFFFFF;
+    write_mbus_register(FFR_ADDR,1,ffrv1_r1.as_int);
+
+    //FFRv1 R2
+    ffrv1_r2.TX_FSM_N_HEADER = 0xF ; //Send 16 "1" headers
+    write_mbus_register(FFR_ADDR,2,ffrv1_r2.as_int);
+
+    //FFRv1 R3
+    ffrv1_r3.I_LIMIT_IL_EN = 0x1;		//Disable Limiter, should set to 1
+    ffrv1_r3.I_LIMIT_IL_iTune = 0x3F;	//Turn on all tail current FETs for amplifier, No effect on the output
+    ffrv1_r3.I_LIMIT_IL_bypass = 0x0;	//Bypass all Resistors -> Increase the output power
+    write_mbus_register(FFR_ADDR,3,ffrv1_r3.as_int);
+
+    //FFRv1 R4
+    ffrv1_r4.CLKGEN_RINGSEL = 0x0;
+    write_mbus_register(FFR_ADDR,1,ffrv1_r4.as_int);
+
+  }
+
+  ffrv1_r2.TX_FSM_START = 0;
+  write_mbus_register(FFR_ADDR,2,ffrv1_r2.as_int);
+  ffrv1_r2.TX_FSM_START = 1;
+  write_mbus_register(FFR_ADDR,2,ffrv1_r2.as_int);
+  read_mbus_register(FFR_ADDR,2, 0x13);
+  delay(10000);
+  //   read_mbus_register(FFR_ADDR,2, 0x13);
+  //   delay(10000);
+
+  // Go to sleep
+  set_wakeup_timer(WAKEUP_PERIOD, 0x1, 0x1);
+  sleep();
+
+  ///////////////
+  //End Testing
+  ///////////////
+
+  //Never Ends
+  while (1){}
+}