Complete.Org: Mailing Lists: Archives: freeciv-dev: April 1999:
[Freeciv-Dev] patch: fix Sun cc warnings
Home

[Freeciv-Dev] patch: fix Sun cc warnings

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] patch: fix Sun cc warnings
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Sat, 24 Apr 1999 17:06:27 +1000 (EST)

This patch fixes some warnings from Sun's cc on Solaris.
(Well, some fixes, and some cases where I just tried
casting the problem away ;-)

(Another warning in gamelog.c is already fixed in mem.diff;
there is one other warning, in dialogs.c, which I'm not sure
how best to fix:
%"dialogs.c", line 1210: warning: assignment type mismatch:
%        pointer to function(pointer to struct _WidgetRec {}, pointer to char, 
pointer to char) returning void "=" pointer to void

-- David
diff -u -r --exclude-from exclude freeciv-cvs/client/gui-xaw/mapctrl.c 
freeciv-mod/client/gui-xaw/mapctrl.c
--- freeciv-cvs/client/gui-xaw/mapctrl.c        Tue Apr 13 21:08:53 1999
+++ freeciv-mod/client/gui-xaw/mapctrl.c        Sat Apr 24 16:58:46 1999
@@ -157,8 +157,8 @@
     input_dialog_create(toplevel, "shellnewcityname", 
                        "What should we call our new city?",
                        city_name_suggestion(game.player_ptr),
-                       name_new_city_callback, (XtPointer)punit->id,
-                       name_new_city_callback, (XtPointer)0);
+                       (void*)name_new_city_callback, (XtPointer)punit->id,
+                       (void*)name_new_city_callback, (XtPointer)0);
   }
   else {
     struct packet_unit_request req;
diff -u -r --exclude-from exclude freeciv-cvs/common/packets.c 
freeciv-mod/common/packets.c
--- freeciv-cvs/common/packets.c        Sat Mar 20 15:52:37 1999
+++ freeciv-mod/common/packets.c        Sat Apr 24 16:54:07 1999
@@ -300,8 +300,9 @@
 **************************************************************************/
 unsigned char *put_string(unsigned char *buffer, char *mystring)
 {
-  strcpy(buffer, mystring);
-  return buffer+strlen(mystring)+1;
+  int len = strlen(mystring) + 1;
+  memcpy(buffer, mystring, len);
+  return buffer+len;
 }
 
 
@@ -310,9 +311,16 @@
 **************************************************************************/
 unsigned char *get_string(unsigned char *buffer, char *mystring)
 {
-  if(mystring)
-    strcpy(mystring, buffer);
-  return buffer+strlen(mystring)+1;
+  unsigned char *c;
+  int len;
+
+  /* avoid using strlen (or strcpy) on an (unsigned char*)  --dwp */
+  for(c=buffer; *c; c++) ;
+  len = c-buffer+1;
+  if(mystring) {
+    memcpy(mystring, buffer, len);
+  }
+  return buffer+len;
 }
 
 /**************************************************************************
diff -u -r --exclude-from exclude freeciv-cvs/server/meta.c 
freeciv-mod/server/meta.c
--- freeciv-cvs/server/meta.c   Sat Apr 10 15:16:40 1999
+++ freeciv-mod/server/meta.c   Sat Apr 24 16:56:54 1999
@@ -46,7 +46,7 @@
   cptr=put_string(cptr, info);
   put_int16(buffer, cptr-buffer);
   
-  n=sendto(sockfd, buffer, cptr-buffer,0, 
+  n=sendto(sockfd, (const void*)buffer, cptr-buffer,0, 
           (struct sockaddr *) &serv_addr, sizeof(serv_addr) );
   
   return 1;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] patch: fix Sun cc warnings, David Pfitzner <=