[eggheads-patches] Some bugfixes and other cosmetic changes

Matyas Koszik koszik at sirklabs.hu
Sun Jan 19 13:28:00 CST 2003


I made this patch against the current snapshot version of the 1.6 branch.

List of changes:

 * main.c: in main(), line 1004, there's something similar to
           'The last C bug of the world':
	   while (1)
	   {
	     status = GetRadarStatus();
	     if (status = 1) LaunchMissiles();
	   }
 * misc.c: 'buf' is 3 bytes long, so don't try to write to the 4th byte.
           (Also, this bug caused that buf[2] had an unspecified value.)
 * channels.c: in get_mode_protect, 'ok' was unused
 * filesys.mod/dbcompat.c: in convert_version1 and convert_version2, 'where'
                           was unused
 * irc.mod/chan.c: chan->floodwho[which] is 81 bytes long, not 82
 * irc.mod/msgcmds.c: in msg_hello, 'fr' was unused (two times)
 * server.mod/server.c: this version of 'strict_host' was never used
 * server.mod/servmsg.c: in function gotnick, 'u' was unused
 * uptime.mod/uptime.h: storage class should be first
 * wire.mod/wire.c: "\[" has no special meaning in C
 * tcl.c: someone forgot to restore the value of 'protect_readonly'
 * tclhash.c: in bind_bind_entry, tm_last was unused

BTW I sent a mail one week ago to webmaster at eggheads.org, to register my
bot to the uptime contest, but there was no reply. Is this procedure
always as slow as now?
-------------- next part --------------
diff -bur eggdrop1.6/src/main.c eggdrop1.6-fix/src/main.c
--- eggdrop1.6/src/main.c	2002-12-24 06:00:06.000000000 +0100
+++ eggdrop1.6-fix/src/main.c	2003-01-18 20:21:04.000000000 +0100
@@ -1001,7 +1001,7 @@
     } else if (xx == -2 && errno != EINTR) {	/* select() error */
       putlog(LOG_MISC, "*", "* Socket error #%d; recovering.", errno);
       for (i = 0; i < dcc_total; i++) {
-	if ((fcntl(dcc[i].sock, F_GETFD, 0) == -1) && (errno = EBADF)) {
+	if ((fcntl(dcc[i].sock, F_GETFD, 0) == -1) && (errno == EBADF)) {
 	  putlog(LOG_MISC, "*",
 		 "DCC socket %d (type %d, name '%s') expired -- pfft",
 		 dcc[i].sock, dcc[i].type, dcc[i].nick);
diff -bur eggdrop1.6/src/misc.c eggdrop1.6-fix/src/misc.c
--- eggdrop1.6/src/misc.c	2002-12-24 06:00:06.000000000 +0100
+++ eggdrop1.6-fix/src/misc.c	2003-01-18 20:22:19.000000000 +0100
@@ -1453,7 +1453,7 @@
   char		 buf[3];
   register char	*s, *p;
 
-  buf[3] = 0;
+  buf[2] = 0;
   for (s = p = str; *s; s++, p++) {
     if (*s == esc_char) {	/* Found escape character.		*/
       /* Convert code to character. */
diff -bur eggdrop1.6/src/mod/channels.mod/channels.c eggdrop1.6-fix/src/mod/channels.mod/channels.c
--- eggdrop1.6/src/mod/channels.mod/channels.c	2002-12-28 06:00:05.000000000 +0100
+++ eggdrop1.6-fix/src/mod/channels.mod/channels.c	2003-01-18 20:25:23.000000000 +0100
@@ -177,11 +177,10 @@
 static void get_mode_protect(struct chanset_t *chan, char *s)
 {
   char *p = s, s1[121];
-  int ok = 0, i, tst;
+  int i, tst;
 
   s1[0] = 0;
   for (i = 0; i < 2; i++) {
-    ok = 0;
     if (i == 0) {
       tst = chan->mode_pls_prot;
       if ((tst) || (chan->limit_prot != 0) || (chan->key_prot[0]))
diff -bur eggdrop1.6/src/mod/filesys.mod/dbcompat.c eggdrop1.6-fix/src/mod/filesys.mod/dbcompat.c
--- eggdrop1.6/src/mod/filesys.mod/dbcompat.c	2002-12-24 06:00:08.000000000 +0100
+++ eggdrop1.6-fix/src/mod/filesys.mod/dbcompat.c	2003-01-18 20:26:14.000000000 +0100
@@ -147,12 +147,10 @@
  */
 static void convert_version1(FILE *fdb_s, FILE *fdb_t)
 {
-  long where;
   filedb1 fdb1;
 
   fseek(fdb_s, 0L, SEEK_SET);
   while (!feof(fdb_s)) {
-    where = ftell(fdb_s);
     fread(&fdb1, sizeof(filedb1), 1, fdb_s);
     if (!feof(fdb_s)) {
       if (!(fdb1.stat & FILE_UNUSED)) {
@@ -184,12 +182,10 @@
  */
 static void convert_version2(FILE *fdb_s, FILE *fdb_t)
 {
-  long where;
   filedb2 fdb2;
 
   fseek(fdb_s, 0L, SEEK_SET);
   while (!feof(fdb_s)) {
-    where = ftell(fdb_s);
     fread(&fdb2, sizeof(filedb2), 1, fdb_s);
     if (!feof(fdb_s)) {
       if (!(fdb2.stat & FILE_UNUSED)) {
diff -bur eggdrop1.6/src/mod/irc.mod/chan.c eggdrop1.6-fix/src/mod/irc.mod/chan.c
--- eggdrop1.6/src/mod/irc.mod/chan.c	2002-12-24 06:00:08.000000000 +0100
+++ eggdrop1.6-fix/src/mod/irc.mod/chan.c	2003-01-18 20:27:03.000000000 +0100
@@ -231,8 +231,8 @@
       return 0;
   }
   if (rfc_casecmp(chan->floodwho[which], p)) {	/* new */
-    strncpy(chan->floodwho[which], p, 81);
-    chan->floodwho[which][81] = 0;
+    strncpy(chan->floodwho[which], p, 80);
+    chan->floodwho[which][80] = 0;
     chan->floodtime[which] = now;
     chan->floodnum[which] = 1;
     return 0;
diff -bur eggdrop1.6/src/mod/irc.mod/msgcmds.c eggdrop1.6-fix/src/mod/irc.mod/msgcmds.c
--- eggdrop1.6/src/mod/irc.mod/msgcmds.c	2002-12-24 06:00:08.000000000 +0100
+++ eggdrop1.6-fix/src/mod/irc.mod/msgcmds.c	2003-01-18 20:57:09.000000000 +0100
@@ -30,7 +30,6 @@
   int common = 0;
   int atr = 0;
   struct chanset_t *chan;
-  struct flag_record fr = {FR_GLOBAL, 0, 0, 0, 0, 0};
 
   if (!learn_users && !make_userfile)
     return 0;
@@ -44,9 +43,6 @@
   }
   strncpyz(handle, nick, sizeof(handle));
   if (get_user_by_handle(userlist, handle)) {
-    struct flag_record fr = {FR_GLOBAL, 0, 0, 0, 0, 0};
-    fr.global = atr;
-
     dprintf(DP_HELP, IRC_BADHOST1, nick);
     dprintf(DP_HELP, IRC_BADHOST2, nick, botname);
     return 1;
@@ -86,8 +82,6 @@
     dprintf(DP_HELP, "NOTICE %s :%s\n", nick, IRC_SALUT2B);
   }
   if (make_userfile) {
-    fr.global = sanity_check(default_flags | USER_OWNER);
-
     dprintf(DP_HELP, "NOTICE %s :%s\n", nick, IRC_INITOWNER1);
     dprintf(DP_HELP, IRC_NEWBOT1, nick, botname);
     dprintf(DP_HELP, IRC_NEWBOT2, nick);
@@ -96,8 +90,6 @@
     write_userfile(-1);
     add_note(handle, botnetnick, IRC_INITNOTE, -1, 0);
   } else {
-    fr.global = default_flags;
-
     dprintf(DP_HELP, IRC_INTRO1, nick, botname);
   }
   if (strlen(nick) > HANDLEN)
diff -bur eggdrop1.6/src/mod/server.mod/server.c eggdrop1.6-fix/src/mod/server.mod/server.c
--- eggdrop1.6/src/mod/server.mod/server.c	2002-12-24 06:00:08.000000000 +0100
+++ eggdrop1.6-fix/src/mod/server.mod/server.c	2003-01-18 21:01:57.000000000 +0100
@@ -32,7 +32,6 @@
 
 static int ctcp_mode;
 static int serv;		/* sock # of server currently */
-static int strict_host;		/* strict masking of hosts ? */
 static char newserver[121];	/* new server? */
 static int newserverport;	/* new server port? */
 static char newserverpass[121];	/* new server password? */
@@ -1851,7 +1850,6 @@
    * globally.
    */
   serv = -1;
-  strict_host = 1;
   botname[0] = 0;
   trying_server = 0L;
   server_lag = 0;
diff -bur eggdrop1.6/src/mod/server.mod/servmsg.c eggdrop1.6-fix/src/mod/server.mod/servmsg.c
--- eggdrop1.6/src/mod/server.mod/servmsg.c	2003-01-02 06:00:05.000000000 +0100
+++ eggdrop1.6-fix/src/mod/server.mod/servmsg.c	2003-01-18 20:32:23.000000000 +0100
@@ -900,9 +900,7 @@
 static int gotnick(char *from, char *msg)
 {
   char *nick, *alt = get_altbotnick();
-  struct userrec *u;
 
-  u = get_user_by_host(from);
   nick = splitnick(&from);
   fixcolon(msg);
   check_queues(nick, msg);
diff -bur eggdrop1.6/src/mod/uptime.mod/uptime.h eggdrop1.6-fix/src/mod/uptime.mod/uptime.h
--- eggdrop1.6/src/mod/uptime.mod/uptime.h	2002-12-24 06:00:08.000000000 +0100
+++ eggdrop1.6-fix/src/mod/uptime.mod/uptime.h	2003-01-18 20:32:57.000000000 +0100
@@ -25,8 +25,8 @@
 #ifndef _EGG_MOD_UPTIME_UPTIME_H
 #define _EGG_MOD_UPTIME_UPTIME_H
 
-const static int uptime_type = 2;
-const static int uptime_port = 9969;
-const static char *uptime_host = "uptime.eggheads.org";
+static const int uptime_type = 2;
+static const int uptime_port = 9969;
+static const char *uptime_host = "uptime.eggheads.org";
 
 #endif /* _EGG_MOD_UPTIME_UPTIME_H */
diff -bur eggdrop1.6/src/mod/wire.mod/wire.c eggdrop1.6-fix/src/mod/wire.mod/wire.c
--- eggdrop1.6/src/mod/wire.mod/wire.c	2002-12-24 06:00:08.000000000 +0100
+++ eggdrop1.6-fix/src/mod/wire.mod/wire.c	2003-01-18 21:04:17.000000000 +0100
@@ -125,11 +125,11 @@
 	  mins = ((now2 - dcc[idx].timeval) -
 		  (hrs * 3600)) / 60;
 	  if (Days > 0)
-	    sprintf(idle, " \[%s %lud%luh]", WIRE_IDLE, Days, hrs);
+	    sprintf(idle, " [%s %lud%luh]", WIRE_IDLE, Days, hrs);
 	  else if (hrs > 0)
-	    sprintf(idle, " \[%s %luh%lum]", WIRE_IDLE, hrs, mins);
+	    sprintf(idle, " [%s %luh%lum]", WIRE_IDLE, hrs, mins);
 	  else
-	    sprintf(idle, " \[%s %lum]", WIRE_IDLE, mins);
+	    sprintf(idle, " [%s %lum]", WIRE_IDLE, mins);
 	} else
 	  idle[0] = 0;
 	sprintf(wirereq, "----- %c%-9s %-9s  %s%s",
@@ -254,11 +254,11 @@
 	hrs = ((now2 - dcc[idx2].timeval) - (Days * 86400)) / 3600;
 	mins = ((now2 - dcc[idx2].timeval) - (hrs * 3600)) / 60;
 	if (Days > 0)
-	  sprintf(idle, " \[%s %lud%luh]", WIRE_IDLE, Days, hrs);
+	  sprintf(idle, " [%s %lud%luh]", WIRE_IDLE, Days, hrs);
 	else if (hrs > 0)
-	  sprintf(idle, " \[%s %luh%lum]", WIRE_IDLE, hrs, mins);
+	  sprintf(idle, " [%s %luh%lum]", WIRE_IDLE, hrs, mins);
 	else
-	  sprintf(idle, " \[%s %lum]", WIRE_IDLE, mins);
+	  sprintf(idle, " [%s %lum]", WIRE_IDLE, mins);
       } else
 	idle[0] = 0;
       dprintf(idx, "----- %c%-9s %-9s  %s%s\n",
@@ -591,7 +591,7 @@
 
 char *wire_start(Function * global_funcs)
 {
-  p_tcl_bind_list H_temp;
+  p_tcl_bind_list H_temp; /* variable "H_temp" was set but never used */
 
   global = global_funcs;
 
diff -bur eggdrop1.6/src/tcl.c eggdrop1.6-fix/src/tcl.c
--- eggdrop1.6/src/tcl.c	2002-12-24 06:00:06.000000000 +0100
+++ eggdrop1.6-fix/src/tcl.c	2003-01-18 20:50:46.000000000 +0100
@@ -745,6 +745,7 @@
     tmp = protect_readonly;
     protect_readonly = 0;
     tcl_eggstr((ClientData) st, interp, list[i].name, NULL, TCL_TRACE_WRITES);
+    protect_readonly = tmp;
     tcl_eggstr((ClientData) st, interp, list[i].name, NULL, TCL_TRACE_READS);
     Tcl_TraceVar(interp, list[i].name, TCL_TRACE_READS | TCL_TRACE_WRITES |
 		 TCL_TRACE_UNSETS, tcl_eggstr, (ClientData) st);
diff -bur eggdrop1.6/src/tclhash.c eggdrop1.6-fix/src/tclhash.c
--- eggdrop1.6/src/tclhash.c	2002-12-26 06:00:05.000000000 +0100
+++ eggdrop1.6-fix/src/tclhash.c	2003-01-18 20:23:39.000000000 +0100
@@ -375,10 +375,10 @@
 			   const char *cmd, const char *proc)
 {
   tcl_cmd_t		*tc;
-  tcl_bind_mask_t	*tm, *tm_last;
+  tcl_bind_mask_t	*tm;
 
   /* Search for matching bind in bind list. */
-  for (tm = tl->first, tm_last = NULL; tm; tm_last = tm, tm = tm->next) {
+  for (tm = tl->first; tm; tm = tm->next) {
     if (tm->flags & TBM_DELETED)
       continue;
     if (!strcmp(cmd, tm->mask))


More information about the Patches mailing list