NetBSD Problem Report #38447

From martin@duskware.de  Wed Apr 16 20:05:04 2008
Return-Path: <martin@duskware.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 51EC263B874
	for <gnats-bugs@gnats.netbsd.org>; Wed, 16 Apr 2008 20:05:04 +0000 (UTC)
Message-Id: <20080416190032.4F01563B293@narn.NetBSD.org>
Date: Wed, 16 Apr 2008 19:00:32 +0000 (UTC)
From: srcshelton@gmail.com
Reply-To: srcshelton@gmail.com
To: netbsd-bugs-owner@NetBSD.org
Subject: Patches to allow chat/bitlbee-1.2 to successfully build on IRIX/MIPSpro
X-Send-Pr-Version: www-1.0

>Number:         38447
>Category:       pkg
>Synopsis:       Patches to allow chat/bitlbee-1.2 to successfully build on IRIX/MIPSpro
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    tonio
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 16 20:10:00 +0000 2008
>Last-Modified:  Mon Apr 21 13:55:39 +0000 2008
>Originator:     Stuart Shelton
>Release:        pkgsrc latest from CVS
>Organization:
>Environment:
IRIX64 octane 6.5 07202013 IP30; IRIX 6.5.30; MIPSpro Compilers Version 7.4.4m
>Description:

The latest bitlbee contains a number of GNU-isms, and also manages to hit some weird gotchas in the MIPSpro compiler (who would have thought that the 'continue' instruction could ever fail to be implemented?!)

I suggest the following change to the package Makefile:

--- Makefile.dist       2008-04-16 19:02:55.914426280 +0100
+++ Makefile    2008-04-16 19:05:05.238633680 +0100
@@ -22,6 +22,12 @@ CONFIGURE_ARGS+=     --config=${STATEDIR}
 CONFIGURE_ARGS+=       --flood=0
 CONFIGURE_ARGS+=       --ssl=openssl

+# The following warning means that the execution of the program is seriously
+# different from that intended:
+# cc-1999 cc: WARNING File = nogaim.c, Line = 1171
+# "jumping out of a block containing VLAs" is not currently implemented
+CFLAGS.IRIX+=          -DEBUG:error=1999
+
 PKG_SYSCONFSUBDIR=     bitlbee
 CONF_FILES=            ${DATADIR}/motd.txt ${PKG_SYSCONFDIR}/motd.txt
 CONF_FILES+=           ${EGDIR}/bitlbee.conf ${PKG_SYSCONFDIR}/bitlbee.conf

>How-To-Repeat:

First, a couple of very platform-specific patches...

bitlbee seems to ignore some environment variables:

--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/Makefile.settings.dist       2008-04-16 18:22:36.704828960 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/Makefile.settings    2008-04-16 18:26:16.680496320 +0100
@@ -14,17 +14,17 @@ CPU=IP30
 OUTFILE=bitlbee

 DESTDIR=
-LFLAGS=
-EFLAGS=
-CFLAGS=-c99 -O2 -n32 -mips4 -r14000 -apo -float_const -use_readonly_const -TARG:isa=mips4:platform=ip30:processor=r14000 -TENV:zeroinit_in_bss=ON -OPT:fast_io=ON:Olimit=8192:reorg_common=ON:swp=ON -LNO:auto_dist=ON:fusion_peeling_limit=8:gather_scatter=2 -woff 1174,1183,1185,1552,3970,3968 -DEBUG:error=1999 -n32 -I/usr/bsd/include -I/usr/include
+LFLAGS=-v -x -n32 -mips4 -rdata_shared -allow_jump_at_eop
+EFLAGS=-Wl,-v -Wl,-s -Wl,-x -n32 -mips4 -rdata_shared -Wl,-allow_jump_at_eop
+CFLAGS=-c99 -O2 -n32 -mips4 -r14000 -apo -float_const -use_readonly_const -TARG:isa=mips4:platform=ip30:processor=r14000 -TENV:zeroinit_in_bss=ON -OPT:fast_io=ON:Olimit=8192:reorg_common=ON:swp=ON -LNO:auto_dist=ON:fusion_peeling_limit=8:gather_scatter=2 -woff 1174,1183,1185,1498,1552,3201,3970,3968
 CFLAGS+=-I/usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2 -I/usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/lib -I/usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols -I.
 CFLAGS+=-DHAVE_CONFIG_H
-CC=cc
+CC=c99
 LD=ld
 EFLAGS+=-Wl,-rpath,/usr/bsd/lib -L/usr/bsd/lib -lgmodule-2.0 -lglib-2.0 -lintl -liconv  
 CFLAGS+=-I/usr/bsd/include/glib/glib-2.0 -I/usr/bsd/lib/glib-2.0/include  
 EVENT_HANDLER=events_glib.o
-EFLAGS+=-lssl -lcrypto
+EFLAGS+=-lssl -lcrypto -lmp
 SSL_CLIENT=ssl_openssl.o
 STORAGE_OBJS= storage_text.o storage_xml.o
 STRIP=strip

... and LDFLAGS should *not* be passed to $CC!:

--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/Makefile.dist        2008-04-16 18:22:30.358961640 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/Makefile     2008-04-16 18:22:51.900285800 +0100
@@ -107,7 +107,7 @@ $(objects): Makefile Makefile.settings c

 $(OUTFILE): $(objects) $(subdirs)
        @echo '*' Linking $(OUTFILE)
-       @$(CC) $(objects) $(subdirobjs) -o $(OUTFILE) $(LFLAGS) $(EFLAGS)
+       @$(CC) $(objects) $(subdirobjs) -o $(OUTFILE) $(EFLAGS)
 ifndef DEBUG
        @echo '*' Stripping $(OUTFILE)
        @-$(STRIP) $(OUTFILE)

>Fix:

And now the actual bitlbee code patches.

--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/bitlbee.h.dist       2008-04-16 18:26:56.209677240 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/bitlbee.h    2008-04-16 18:42:01.133536480 +0100
@@ -39,6 +39,7 @@
 #endif

 #include <fcntl.h>
+#include <unistd.h>
 #include <time.h>
 #include <sys/stat.h>
 #include <sys/types.h>


--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/oscar/conn.c.dist  2008-04-16 18:29:04.073007960 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/oscar/conn.c       2008-04-16 18:35:50.562833000 +0100
@@ -614,7 +614,7 @@ int aim_conn_completeconnect(aim_session
        } 

        if (FD_ISSET(conn->fd, &fds) || FD_ISSET(conn->fd, &wfds)) {
-               unsigned int len = sizeof(error);
+               socklen_t len = sizeof(error);

                if (getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
                        error = errno;


--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/lib/events.h.dist    2008-04-16 18:50:01.001568400 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/lib/events.h 2008-04-16 18:50:27.658691160 +0100
@@ -58,7 +58,7 @@ typedef gboolean (*b_event_handler)(gpoi
 #define GAIM_ERR_COND   (G_IO_HUP | G_IO_ERR | G_IO_NVAL)

 /* #define event_debug( x... ) printf( x ) */
-#define event_debug( x... )
+#define event_debug( ... )

 /* Call this once when the program starts. It'll initialize the event handler
    library (if necessary) and then return immediately. */


--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/jabber/jabber.c.dist       2008-04-16 19:24:36.467930200 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/jabber/jabber.c    2008-04-16 19:25:41.180820960 +0100
@@ -350,7 +350,7 @@ static void jabber_get_info( struct im_c
                imcb_log( ic, "Buddy %s (%d) information:\nAway state: %s\nAway message: %s",
                                   bud->full_jid, bud->priority,
                                   bud->away_state ? bud->away_state->full_name : "(none)",
-                                  bud->away_message ? : "(none)" );
+                                  bud->away_message ? bud->away_message : "(none)" );
                bud = bud->next;
        }



--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/jabber/jabber_util.c.dist  2008-04-16 19:27:30.143595400 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/jabber/jabber_util.c       2008-04-16 19:28:06.742458880 +0100
@@ -196,7 +196,7 @@ xt_status jabber_cache_handle_packet( st
        if( entry == NULL )
        {
                imcb_log( ic, "Warning: Received %s-%s packet with unknown/expired ID %s!",
-                             node->name, xt_find_attr( node, "type" ) ? : "(no type)", s );
+                             node->name, xt_find_attr( node, "type" ) ? xt_find_attr( node, "type" ) : "(no type)", s );
        }
        else if( entry->func )
        {


--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/yahoo/libyahoo2.c.dist     2008-04-16 19:37:01.656549600 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/yahoo/libyahoo2.c  2008-04-16 19:42:12.580802600 +0100
@@ -1466,19 +1466,19 @@ static void yahoo_process_status(struct 

        while (users) {
                YList *t = users;
-               struct user *u = users->data;
+               struct user *ud = users->data;

-               if (u->name != NULL) {
-                       if (pkt->service == YAHOO_SERVICE_LOGOFF || u->flags == 0) {
-                               YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0);
+               if (ud->name != NULL) {
+                       if (pkt->service == YAHOO_SERVICE_LOGOFF || ud->flags == 0) {
+                               YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, ud->name, YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0);
                        } else {
-                               YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, u->state, u->msg, u->away, u->idle, u->mobile);
+                               YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, ud->name, ud->state, ud->msg, ud->away, ud->idle, ud->mobile);
                        }
                }

                users = y_list_remove_link(users, users);
                y_list_free_1(t);
-               FREE(u);
+               FREE(ud);
        }
 }



--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/jabber/message.c.dist      2008-04-16 19:30:12.257000760 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/jabber/message.c   2008-04-16 19:30:39.369440480 +0100
@@ -54,7 +54,7 @@ xt_status jabber_pkt_message( struct xt_
                        if( bud )
                        {
                                bud->last_act = time( NULL );
-                               from = bud->ext_jid ? : bud->bare_jid;
+                               from = bud->ext_jid ? bud->ext_jid : bud->bare_jid;
                        }
                        else
                                *s = 0; /* We need to generate a bare JID now. */


--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/msn/msn.c.dist     2008-04-16 19:20:50.663228400 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/msn/msn.c  2008-04-16 19:21:37.196604240 +0100
@@ -163,8 +163,6 @@ static int msn_buddy_msg( struct im_conn

                return( 1 );
        }
-       
-       return( 0 );
 }

 static GList *msn_away_states( struct im_connection *ic )
@@ -290,8 +288,6 @@ static struct groupchat *msn_chat_with( 
                /* FIXME: Can I try to return something here already? */
                return NULL;
        }
-       
-       return NULL;
 }

 static void msn_keepalive( struct im_connection *ic )


--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/msn/msn.h.dist     2008-04-16 18:28:46.837894880 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/msn/msn.h  2008-04-16 18:35:26.976346320 +0100
@@ -29,9 +29,9 @@
 #define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r"

 #ifdef DEBUG
-#define debug( text... ) imcb_log( ic, text );
+#define debug( ... ) imcb_log( ic, ... );
 #else
-#define debug( text... )
+#define debug( ... )
 #endif

 #define QRY_NAME "msmsgs@msnmsgr.com"


--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/nogaim.c.dist      2008-04-16 19:14:21.330958800 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/nogaim.c   2008-04-16 19:17:27.498604800 +0100
@@ -505,7 +505,7 @@ void show_got_added_yes( gpointer w, str
        data->ic->acc->prpl->add_buddy( data->ic, data->handle, NULL );
        /* imcb_add_buddy( data->ic, NULL, data->handle, data->handle ); */

-       return show_got_added_no( w, data );
+       show_got_added_no( w, data );
 }

 void imcb_ask_add( struct im_connection *ic, char *handle, const char *realname )
@@ -1155,10 +1155,10 @@ void imcb_clean_handle( struct im_connec
           outside 33-127 (ASCII printable excl spaces), @ (only one
           is allowed) and ! and : */
        char out[strlen(handle)+1];
-       int s, d;
+       int s, d, found;

-       s = d = 0;
-       while( handle[s] )
+       s = d = found = 0;
+       while( handle[s] && found == 0 )
        {
                if( handle[s] > ' ' && handle[s] != '!' && handle[s] != ':' &&
                    ( handle[s] & 0x80 ) == 0 )
@@ -1168,12 +1168,17 @@ void imcb_clean_handle( struct im_connec
                                /* See if we got an @ already? */
                                out[d] = 0;
                                if( strchr( out, '@' ) )
+                                       found = 1;
+                                       /* This line generates MIPSpro warning 1999 on IRIX
                                        continue;
+                                        */
                        }

-                       out[d++] = handle[s];
+                       if( found == 0 )
+                               out[d++] = handle[s];
                }
-               s ++;
+               if( found == 0 )
+                       s ++;
        }
        out[d] = handle[s];



--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/lib/proxy.c.dist     2008-04-16 18:27:39.406072400 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/lib/proxy.c  2008-04-16 18:34:08.505846440 +0100
@@ -81,7 +81,7 @@ static struct sockaddr_in *gaim_gethostb
 static gboolean gaim_io_connected(gpointer data, gint source, b_input_condition cond)
 {
        struct PHB *phb = data;
-       unsigned int len;
+       socklen_t len;
        int error = ETIMEDOUT;
        len = sizeof(error);

@@ -185,7 +185,7 @@ static gboolean http_canwrite(gpointer d
 {
        char cmd[384];
        struct PHB *phb = data;
-       unsigned int len;
+       socklen_t len;
        int error = ETIMEDOUT;
        if (phb->inpa > 0)
                b_event_remove(phb->inpa);
@@ -280,7 +280,7 @@ static gboolean s4_canwrite(gpointer dat
        unsigned char packet[12];
        struct hostent *hp;
        struct PHB *phb = data;
-       unsigned int len;
+       socklen_t len;
        int error = ETIMEDOUT;
        if (phb->inpa > 0)
                b_event_remove(phb->inpa);
@@ -472,7 +472,7 @@ static gboolean s5_canwrite(gpointer dat
        unsigned char buf[512];
        int i;
        struct PHB *phb = data;
-       unsigned int len;
+       socklen_t len;
        int error = ETIMEDOUT;
        if (phb->inpa > 0)
                b_event_remove(phb->inpa);


--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/msn/sb.c.dist      2008-04-16 19:21:55.655705160 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/protocols/msn/sb.c   2008-04-16 19:24:05.505022400 +0100
@@ -393,8 +393,6 @@ static int msn_sb_command( gpointer data
                }
                else if( tot > 1 )
                {
-                       char buf[1024];
-                       
                        if( num == 1 )
                        {
                                g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session );


--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/unix.c.dist  2008-04-16 18:53:42.748413120 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/unix.c       2008-04-16 18:55:00.338127160 +0100
@@ -135,7 +135,7 @@ int main( int argc, char *argv[], char *
        {
                char *fn = ipc_master_save_state();
                char **args;
-               int n, i;
+               int n, j;

                chdir( old_cwd );

@@ -147,12 +147,12 @@ int main( int argc, char *argv[], char *
                        args[n++] = "-R";
                        args[n++] = fn;
                }
-               for( i = 1; argv[i] && i < argc; i ++ )
+               for( j = 1; argv[j] && j < argc; j ++ )
                {
-                       if( strcmp( argv[i], "-R" ) == 0 )
-                               i += 2;
+                       if( strcmp( argv[j], "-R" ) == 0 )
+                               j += 2;

-                       args[n++] = argv[i];
+                       args[n++] = argv[j];
                }

                close( global.listen_socket );


--- /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/lib/xmltree.c.dist   2008-04-16 18:56:16.629911680 +0100
+++ /usr/bsd/var/tmp/chat/bitlbee/work/bitlbee-1.2/lib/xmltree.c        2008-04-16 18:58:21.254902320 +0100
@@ -214,7 +214,11 @@ void xt_cleanup( struct xt_parser *xt, s
                return;

        if( node == NULL )
-               return xt_cleanup( xt, xt->root, depth );
+       {
+               xt_cleanup( xt, xt->root, depth );
+               
+               return;
+       }

        if( node->flags & XT_SEEN && node == xt->root )
        {



Admittedly, some of these patches solve largely cosmetic problems (such as non-reachable statements, or declarations hiding existing variables still in scope, etc.) but the majority fix GNU-isms or typing issues.

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->tonio
Responsible-Changed-By: reed@NetBSD.org
Responsible-Changed-When: Mon, 21 Apr 2008 13:55:39 +0000
Responsible-Changed-Why:
Assign to maintainer.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.