Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2004:
[Freeciv-Dev] (PR#8149) generate_packets.py can't handle string arrays
Home

[Freeciv-Dev] (PR#8149) generate_packets.py can't handle string arrays

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: kaufman@xxxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#8149) generate_packets.py can't handle string arrays
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 17 Mar 2004 21:06:24 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8149 >

> [kauf - Wed Mar 17 15:37:24 2004]:
> 
> On Tue, Mar 16, 2004 at 01:49:04PM -0800, Jason Short wrote:
> >
> > I get a compilation error:
> >
> > packets_gen.c: In function `dsend_packet_options_settable_control':
> > packets_gen.c:24985: warning: passing arg 1 of `mystrlcpy' from
> > incompatible pointer type
> > packets_gen.c: In function `dlsend_packet_options_settable_control':
> > packets_gen.c:24996: warning: passing arg 1 of `mystrlcpy' from
> > incompatible pointer type
> 
> this is a bug in generate_packets.py. This happens because it does not
> handle arrays of strings correctly. You only see it here because the
packet
> was small enough to have the script generate a dsend packet. add a dsend
> flag to PACKET_NATION_RULESET and you will see the same thing.
> 
> A workaround (that will fix the warning but not the problem) is to not 
> generate dsend packets unless explicitly asked to. This would be good 
> simply to cut down the amount of unused code in packets_gen.c

This is a serious bug!  This functionality is totally broken. 
packets_gen.c treats the 2d array as a 1d array and simply calls strcpy
on it.  If anyone actually tried to use the dsend function huge problems
would result.

Fixing the problem probably isn't worthwhile.  Any packet that contains
a 2d array isn't worth having a dsend function, since the caller would
have to set up the 2d array anyway.

This patch disables dsend for packets with 2d arrays.

Note to Raimar: is_array is misnamed.

jason

Index: common/generate_packets.py
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/generate_packets.py,v
retrieving revision 1.7
diff -u -r1.7 generate_packets.py
--- common/generate_packets.py  15 Jan 2004 11:52:38 -0000      1.7
+++ common/generate_packets.py  18 Mar 2004 04:59:06 -0000
@@ -521,6 +521,11 @@
             self.handle_via_packet=1
             self.want_dsend=0
 
+        for field in self.fields:
+            if (field.is_array > 1):
+                # Don't do dsend packets for 2d arrays.
+                self.want_dsend=0
+
         self.extra_send_args=""
         self.extra_send_args2=""
         self.extra_send_args3=string.join(
@@ -961,6 +966,11 @@
         if len(self.fields)>5 or string.split(self.name,"_")[1]=="ruleset":
             self.handle_via_packet=1
             self.want_dsend=0
+
+        for field in self.fields:
+            if (field.is_array > 1):
+                # Don't do dsend packets for 2d arrays.
+                self.want_dsend=0
 
         if self.dsend_given:
             self.want_dsend=1

[Prev in Thread] Current Thread [Next in Thread]