[mw-devel] MW3 r881 - branches/portable/src
pwb at sucs.org
pwb at sucs.org
Sun Apr 30 01:08:19 BST 2006
Author: pwb
Date: 2006-04-30 01:08:18 +0100 (Sun, 30 Apr 2006)
New Revision: 881
Modified:
branches/portable/src/incoming.c
branches/portable/src/talker.c
Log:
A hack to make messages work properly for now. A pid_t was being put in an int which was assumed to be 4 bytes long, then memcpy'd into a string. This patch forces it to be 4 bytes long by using a uint32_t.
This might mean lossage with a 64 bit pid_t, in the very, very unlikely scenario that the pid is bigger than can be held in 32 bits. A proper fix would be to get enough x's to hold a pid_t however long that happens to be, but that would be Effort :)
Modified: branches/portable/src/incoming.c
===================================================================
--- branches/portable/src/incoming.c 2006-04-29 21:06:46 UTC (rev 880)
+++ branches/portable/src/incoming.c 2006-04-30 00:08:18 UTC (rev 881)
@@ -440,7 +440,7 @@
void handle_mesg()
{
- static int mesg_pid;
+ static uint32_t mesg_pid;
long mesg_posn;
static struct person mesg_user;
int fl;
Modified: branches/portable/src/talker.c
===================================================================
--- branches/portable/src/talker.c 2006-04-29 21:06:46 UTC (rev 880)
+++ branches/portable/src/talker.c 2006-04-30 00:08:18 UTC (rev 881)
@@ -1345,7 +1345,7 @@
struct person u;
struct who w;
int ufile,wfile;
- int mypid;
+ uint32_t mypid; // XXX: this might not be big enough to hold a pid_t
int sproof=0;
char *qtext;
@@ -1397,8 +1397,8 @@
/* overwrite the xxxx with our PID */
mypid=getpid();
- memcpy(&buff[1], &mypid, sizeof(userposn));
- memcpy(&gbuff[1], &mypid, sizeof(userposn));
+ memcpy(&buff[1], &mypid, sizeof(mypid));
+ memcpy(&gbuff[1], &mypid, sizeof(mypid));
free(qtext);
wfile=openwhofile(O_RDONLY);
More information about the mw-devel
mailing list