Re: [Soup-list] [PATCH] soup: union initialization should use named initializers (#32833)

Dan Winship <[email protected]> 25 Oct 2002 10:32:11 -0400
Newsgroups gmane.comp.gnome.evolution.patches,gmane.comp.gnome.ximian.soup
Message-ID <[email protected]>
On Thu, 2002-10-24 at 15:39, Jeremy Katz wrote:
> soup does a cast from char * to a gint in a union initialization which
> won't work for 64-bit platforms.  This patch changes to using named
> initializers for the union.

Here's a counterproposal that should fix the problem without introducing
a C99 dependency. Alex/Joe, can you verify that this is sane?

-- Dan
32833.diff (text/x-patch, 2.3 KB)
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/soup/ChangeLog,v
retrieving revision 1.229.2.40.2.51
diff -u -w -r1.229.2.40.2.51 ChangeLog
--- ChangeLog	16 Oct 2002 19:44:35 -0000	1.229.2.40.2.51
+++ ChangeLog	25 Oct 2002 14:24:15 -0000
@@ -1,3 +1,12 @@
+2002-10-25  Dan Winship  <[email protected]>
+
+	* src/libsoup/soup-message.c (global_handlers): Change the
+	redirect handler to be a RESPONSE_ERROR_CLASS_HANDLER for
+	SOUP_ERROR_CLASS_REDIRECT rather than a RESPONSE_HEADER_HANDLER
+	for "Location" to get around the non-64-bit-clean union
+	initialization pointed out by Jeremy Katz <[email protected]>.
+	(redirect_handler): Update for that.
+
 2002-10-16  Joe Shaw  <[email protected]>
 
 	* src/libsoup/soup-misc.c: Don't set SSL environment variables,
Index: src/libsoup/soup-message.c
===================================================================
RCS file: /cvs/gnome/soup/src/libsoup/soup-message.c,v
retrieving revision 1.46.2.12.2.11
diff -u -w -r1.46.2.12.2.11 soup-message.c
--- src/libsoup/soup-message.c	4 Oct 2002 03:35:19 -0000	1.46.2.12.2.11
+++ src/libsoup/soup-message.c	25 Oct 2002 14:24:17 -0000
@@ -931,17 +931,17 @@
 redirect_handler (SoupMessage *msg, gpointer user_data)
 {
 	const gchar *new_loc;
-
-	if (msg->errorclass != SOUP_ERROR_CLASS_REDIRECT || 
-	    msg->priv->msg_flags & SOUP_MESSAGE_NO_REDIRECT) return;
-
-	new_loc = soup_message_get_header (msg->response_headers, "Location");
-
-	if (new_loc) {
 		const SoupUri *old_uri;
 		SoupUri *new_uri;
 		SoupContext *new_ctx;
 
+	if (msg->priv->msg_flags & SOUP_MESSAGE_NO_REDIRECT)
+		return;
+
+	new_loc = soup_message_get_header (msg->response_headers, "Location");
+	if (!new_loc)
+		return;
+
 		old_uri = soup_context_get_uri (msg->context);
 
 		new_uri = soup_uri_new (new_loc);
@@ -968,8 +968,6 @@
 		soup_context_unref (new_ctx);
 
 		soup_message_requeue (msg);
-	}
-
 	return;
 
  INVALID_REDIRECT:
@@ -999,14 +997,14 @@
 
 static SoupHandlerData global_handlers [] = {
 	/* 
-	 * Handle redirect response codes 300, 301, 302, 303, and 305.
+	 * Handle redirect response codes.
 	 */
 	{
 		SOUP_HANDLER_PRE_BODY,
 		redirect_handler, 
 		NULL, 
-		RESPONSE_HEADER_HANDLER, 
-		{ (guint) "Location" }
+		RESPONSE_ERROR_CLASS_HANDLER, 
+		{ SOUP_ERROR_CLASS_REDIRECT }
 	},
 	/* 
 	 * Handle authorization.