瀏覽代碼

* Port [3899] to 1.2.16 from trunk
* Cleanup 64-bit warnings/errors


svn: 3900

Bryan Drewery 17 年之前
父節點
當前提交
7af777c792
共有 15 個文件被更改,包括 56 次插入48 次删除
  1. 3 2
      src/auth.c
  2. 7 4
      src/botnet.c
  3. 12 12
      src/cmds.c
  4. 1 1
      src/crypto/cleanse.c
  5. 6 4
      src/dcc.c
  6. 2 2
      src/dccutil.c
  7. 1 1
      src/enclink.c
  8. 2 2
      src/hash_table.c
  9. 1 1
      src/main.c
  10. 2 2
      src/misc.c
  11. 4 4
      src/mod/irc.mod/cmdsirc.c
  12. 4 2
      src/mod/server.mod/servmsg.c
  13. 2 2
      src/net.c
  14. 2 2
      src/stringfix.c
  15. 7 7
      src/users.c

+ 3 - 2
src/auth.c

@@ -265,7 +265,8 @@ sdprintf(STR("GETIDX: auth: %s, idx: %d"), nick, idx);
 static int auth_tell_walk(const void *key, void *data, void *param)
 {
   Auth *auth = *(Auth **)data;
-  int idx = (int) param;
+  long lparam = (long) param;
+  int idx = (int) lparam;
 
 //  dprintf(idx, "%s(%s!%s) [%s] authtime: %li, atime: %li, Status: %d\n", auth->bd ? "x " : "", auth->nick, 
   dprintf(idx, "(%s!%s) [%s] authtime: %li, atime: %li, Status: %d\n", auth->nick, 
@@ -276,7 +277,7 @@ static int auth_tell_walk(const void *key, void *data, void *param)
 
 void Auth::TellAuthed(int idx)
 {
-  hash_table_walk(ht_host, auth_tell_walk, (void *) idx);
+  hash_table_walk(ht_host, auth_tell_walk, (void *) (long) idx);
 }
 
 void makehash(struct userrec *u, const char *randstring, char *out, size_t out_size)

+ 7 - 4
src/botnet.c

@@ -1028,7 +1028,7 @@ int botlink(char *linker, int idx, char *nick)
       dcc[i].u.dns->ibuf = idx;
       dcc[i].bot = 1;
 
-      int dns_id = egg_dns_lookup(bi->address, 20, botlink_dns_callback, (void *) i);
+      int dns_id = egg_dns_lookup(bi->address, 20, botlink_dns_callback, (void *) (long)i);
        /* dns_id 
         * -1 means it was cached and the callback already called
         * -2 means it's already being looked up.. try again later .. */
@@ -1048,7 +1048,8 @@ int botlink(char *linker, int idx, char *nick)
 
 static void botlink_dns_callback(int id, void *client_data, const char *host, char **ips)
 {
-  int i = (int) client_data;
+  long data = (long) client_data;
+  int i = (int) data;
 
   if (!valid_dns_id(i, id))
     return;
@@ -1195,7 +1196,7 @@ void tandem_relay(int idx, char *nick, register int i)
   dcc[i].timeval = now;
   dcc[i].u.dns->ibuf = idx;
   
-  int dns_id = egg_dns_lookup(bi->address, 20, tandem_relay_dns_callback, (void *) i);
+  int dns_id = egg_dns_lookup(bi->address, 20, tandem_relay_dns_callback, (void *) (long) i);
   if (dns_id >= 0)
     dcc[i].dns_id = dns_id;
 
@@ -1205,7 +1206,9 @@ void tandem_relay(int idx, char *nick, register int i)
 
 static void tandem_relay_dns_callback(int id, void *client_data, const char *host, char **ips)
 {
-  int i = (int) client_data, idx = -1;
+  //64bit hacks
+  long data = (long) client_data;
+  int i = (int) data, idx = -1;
 
   if (!valid_dns_id(i, id))
     return;

+ 12 - 12
src/cmds.c

@@ -105,12 +105,12 @@ static void tell_who(int idx, int chan)
     if (dcc[i].type && dcc[i].type == &DCC_CHAT)
       if (dcc[i].u.chat->channel == chan) {
 	if (atr & USER_OWNER) {
-	  simple_snprintf(format, sizeof format, "  [%%.2li]  %%c%%-%us %%s", nicklen);
+	  simple_snprintf(format, sizeof format, "  [%%.2li]  %%c%%-%zus %%s", nicklen);
 	  egg_snprintf(s, sizeof(s), format,
 		  dcc[i].sock, (geticon(i) == '-' ? ' ' : geticon(i)),
 		  dcc[i].nick, dcc[i].host);
 	} else {
-	  simple_snprintf(format, sizeof format, "  %%c%%-%us %%s", nicklen);
+	  simple_snprintf(format, sizeof format, "  %%c%%-%zus %%s", nicklen);
 	  egg_snprintf(s, sizeof(s), format,
 		  (geticon(i) == '-' ? ' ' : geticon(i)),
 		  dcc[i].nick, dcc[i].host);
@@ -145,14 +145,13 @@ static void tell_who(int idx, int chan)
       egg_strftime(s, 20, "%d %b %H:%M %Z", gmtime(&dcc[i].timeval));
       s[20] = 0;
       if (atr & USER_OWNER) {
-        simple_snprintf(format, sizeof format, "  [%%.2lu]  %%s%%c%%-%us (%%s) %%s\n", 
-			    nicklen);
+        simple_snprintf(format, sizeof format, "  [%%.2lu]  %%s%%c%%-%zus (%%s) %%s\n", nicklen);
 	dprintf(idx, format,
 		dcc[i].sock, dcc[i].status & STAT_CALLED ? "<-" : "->",
 		dcc[i].status & STAT_SHARE ? '+' : ' ',
 		dcc[i].nick, s, dcc[i].u.bot->version);
       } else {
-        simple_snprintf(format, sizeof format, "  %%s%%c%%-%us (%%s) %%s\n", nicklen);
+        simple_snprintf(format, sizeof format, "  %%s%%c%%-%zus (%%s) %%s\n", nicklen);
 	dprintf(idx, format,
 		dcc[i].status & STAT_CALLED ? "<-" : "->",
 		dcc[i].status & STAT_SHARE ? '+' : ' ',
@@ -168,13 +167,12 @@ static void tell_who(int idx, int chan)
 	dprintf(idx, "Other people on the bot:\n");
       }
       if (atr & USER_OWNER) {
-	simple_snprintf(format, sizeof format, "  [%%.2lu]  %%c%%-%us ", nicklen);
+	simple_snprintf(format, sizeof format, "  [%%.2lu]  %%c%%-%zus ", nicklen);
 	egg_snprintf(s, sizeof(s), format, dcc[i].sock,
 		(geticon(i) == '-' ? ' ' : geticon(i)), dcc[i].nick);
       } else {
-	simple_snprintf(format, sizeof format, "  %%c%%-%us ", nicklen);
-	egg_snprintf(s, sizeof(s), format,
-		(geticon(i) == '-' ? ' ' : geticon(i)), dcc[i].nick);
+	simple_snprintf(format, sizeof format, "  %%c%%-%zus ", nicklen);
+	egg_snprintf(s, sizeof(s), format, (geticon(i) == '-' ? ' ' : geticon(i)), dcc[i].nick);
       }
       if (atr & USER_MASTER) {
 	if (dcc[i].u.chat->channel < 0)
@@ -4044,7 +4042,9 @@ static void cmd_crontab(int idx, char *par) {
 
 static void my_dns_callback(int id, void *client_data, const char *host, char **ips)
 {
-  int idx = (int) client_data;
+  //64bit hacks
+  long data = (long) client_data;
+  int idx = (int) data;
 
   if (!valid_idx(idx))
     return;
@@ -4074,11 +4074,11 @@ static void cmd_dns(int idx, char *par)
   }
   if (is_dotted_ip(par)) {
     dprintf(idx, "Reversing %s ...\n", par);
-    egg_dns_reverse(par, 20, my_dns_callback, (void *) idx);
+    egg_dns_reverse(par, 20, my_dns_callback, (void *) (long) idx);
 
   } else {
     dprintf(idx, "Looking up %s ...\n", par);
-    egg_dns_lookup(par, 20, my_dns_callback, (void *) idx);
+    egg_dns_lookup(par, 20, my_dns_callback, (void *) (long) idx);
   }
 }
 

+ 1 - 1
src/crypto/cleanse.c

@@ -63,7 +63,7 @@ void OPENSSL_cleanse(void *ptr, size_t len)
         while(loop--)
                 {
                 *(p++) = cleanse_ctr;
-                cleanse_ctr += (17 + (unsigned char)((int)p & 0xF));
+                cleanse_ctr += (17 + (unsigned char)((long)p & 0xF));
                 }
         if(memchr(ptr, cleanse_ctr, len))
                 cleanse_ctr += 63;

+ 6 - 4
src/dcc.c

@@ -260,8 +260,8 @@ bot_version(int idx, char *par)
   size_t l = atol(newsplit(&par));
 
   if (l != HANDLEN) {
-    putlog(LOG_BOTS, "*", "Non-matching handle lengths with %s, they use %d characters.", dcc[idx].nick, l);
-    dprintf(idx, "error Non-matching handle length: mine %d, yours %d\n", HANDLEN, l);
+    putlog(LOG_BOTS, "*", "Non-matching handle lengths with %s, they use %zu characters.", dcc[idx].nick, l);
+    dprintf(idx, "error Non-matching handle length: mine %d, yours %zu\n", HANDLEN, l);
     dprintf(idx, "bye %s\n", "bad handlen");
     killsock(dcc[idx].sock);
     lostdcc(idx);
@@ -1387,14 +1387,16 @@ dcc_telnet(int idx, char *buf, int ii)
 
   dcc[i].u.dns->ibuf = idx;
 
-  int dns_id = egg_dns_reverse(s, 20, dcc_telnet_dns_callback, (void *) i);
+  int dns_id = egg_dns_reverse(s, 20, dcc_telnet_dns_callback, (void *) (long) i);
   if (dns_id >= 0)
     dcc[i].dns_id = dns_id;
 }
 
 static void dcc_telnet_dns_callback(int id, void *client_data, const char *ip, char **hosts)
 {
-  int i = (int) client_data;
+  // 64bit hacks
+  long data = (long) client_data;
+  int i = (int) data;
 
   if (!valid_dns_id(i, id))
     return;

+ 2 - 2
src/dccutil.c

@@ -586,12 +586,12 @@ tell_dcc(int idx)
   if (nicklen < 9)
     nicklen = 9;
 
-  simple_snprintf(format, sizeof format, "%%-4s %%-4s %%-8s %%-5s %%-%us %%-40s %%s\n", nicklen);
+  simple_snprintf(format, sizeof format, "%%-4s %%-4s %%-8s %%-5s %%-%zus %%-40s %%s\n", nicklen);
   dprintf(idx, format, "SOCK", "IDX", "ADDR", "PORT", "NICK", "HOST", "TYPE");
   dprintf(idx, format, "----", "---", "--------", "-----", "---------",
           "----------------------------------------", "----");
 
-  simple_snprintf(format, sizeof format, "%%-4d %%-4d %%08X %%5u %%-%us %%-40s %%s\n", nicklen);
+  simple_snprintf(format, sizeof format, "%%-4d %%-4d %%08X %%5u %%-%zus %%-40s %%s\n", nicklen);
 
   dprintf(idx, "dccn: %d, dcc_total: %d\n", dccn, dcc_total);
   dprintf(idx, "dns_idx: %d, servidx: %d\n", dns_idx, servidx);

+ 1 - 1
src/enclink.c

@@ -67,7 +67,7 @@ static void ghost_link_case(int idx, direction_t direction)
     strlcpy(keyp, SHA1(tmp), ENC_KEY_LEN + 1);
 #ifdef DEBUG
     putlog(LOG_DEBUG, "@", "Link hash for %s: %s", dcc[idx].nick, tmp);
-    putlog(LOG_DEBUG, "@", "outkey (%d): %s", strlen(keyp), keyp);
+    putlog(LOG_DEBUG, "@", "outkey (%zu): %s", strlen(keyp), keyp);
 #endif
     OPENSSL_cleanse(tmp, sizeof(tmp));
 

+ 2 - 2
src/hash_table.c

@@ -231,7 +231,7 @@ int hash_table_walk(hash_table_t *ht, hash_table_node_func callback, void *param
 
 static int my_int_cmp(const void *left, const void *right)
 {
-	return((int) left - (int) right);
+	return((long) left - (long) right);
 }
 
 static unsigned int my_string_hash(const void *key)
@@ -273,7 +273,7 @@ static unsigned int my_string_hash(const void *key)
 
 static unsigned int my_int_hash(const void *key)
 {
-	return((unsigned int)key);
+	return((unsigned long)key);
 }
 
 static unsigned int my_mixed_hash (const void *key)

+ 1 - 1
src/main.c

@@ -340,7 +340,7 @@ static void dtx_arg(int& argc, char *argv[])
       case '2':		/* used for testing new binary through update */
         exit(2);
       case '3':		/* return the size of our settings struct */
-        printf("%d %d\n", SETTINGS_VER, sizeof(settings_t));
+        printf("%d %zu\n", SETTINGS_VER, sizeof(settings_t));
         exit(0);
       case '4':
         readconf(optarg, CONF_ENC);

+ 2 - 2
src/misc.c

@@ -430,7 +430,7 @@ void show_channels(int idx, char *handle)
       total++;
   }
 
-  egg_snprintf(format, sizeof format, "  %%c%%-%us %%-s%%-s%%-s%%-s%%-s%%-s\n", (l+2));
+  simple_snprintf(format, sizeof(format), "  %%c%%-%zus %%-s%%-s%%-s%%-s%%-s%%-s\n", (l+2));
 
   for (chan = chanset;chan;chan = chan->next) {
     get_user_flagrec(u, &fr, chan->dname);
@@ -959,7 +959,7 @@ int updatebin(int idx, char *par, int secs)
       egg_timeval_t howlong;
       howlong.sec = secs;
       howlong.usec = 0;
-      timer_create_complex(&howlong, STR("restarting for update"), (Function) restart, (void *) idx, 0);
+      timer_create_complex(&howlong, STR("restarting for update"), (Function) restart, (void *) (long) idx, 0);
     } else
       restart(idx);
 

+ 4 - 4
src/mod/irc.mod/cmdsirc.c

@@ -1477,7 +1477,7 @@ static void cmd_channel(int idx, char *par)
     if (maxhandlen < 9) maxhandlen = 9;
     
     dprintf(idx, "(n = owner, m = master, o = op, d = deop, b = bot) CAP:global\n");
-    egg_snprintf(format, sizeof format, " %%-%us %%-%us %%-6s %%-4s %%-5s %%s %%s\n", 
+    simple_snprintf(format, sizeof format, " %%-%zus %%-%zus %%-6s %%-4s %%-5s %%s %%s\n", 
 			maxnicklen, maxhandlen);
     dprintf(idx, format, "NICKNAME", "HANDLE", " JOIN", "  HOPS", "IDLE", "USER@HOST", "USER@IP");
     for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
@@ -1559,13 +1559,13 @@ static void cmd_channel(int idx, char *par)
 
       if (chan_issplit(m)) {
         simple_snprintf(format, sizeof format, 
-			"%%c%%c%%-%us %%-%us %%s %%c     <- netsplit, %%lus\n", 
+			"%%c%%c%%-%zus %%-%zus %%s %%c     <- netsplit, %%lus\n", 
 			maxnicklen, maxhandlen);
 	dprintf(idx, format, chanflag[0],chanflag[1], m->nick, handle, s, atrflag,
 		now - (m->split));
       } else if (!rfc_casecmp(m->nick, botname)) {
         simple_snprintf(format, sizeof format, 
-			"%%c%%c%%-%us %%-%us %%s %%c     <- it's me!\n", 
+			"%%c%%c%%-%zus %%-%zus %%s %%c     <- it's me!\n", 
 			maxnicklen, maxhandlen);
 	dprintf(idx, format, chanflag[0], chanflag[1], m->nick, handle, s, atrflag);
       } else {
@@ -1578,7 +1578,7 @@ static void cmd_channel(int idx, char *par)
 	  egg_snprintf(s1, sizeof s1, "%2dm", (int) ((now - (m->last)) / 60));
 	else
 	  strlcpy(s1, "   ", sizeof s1);
-	simple_snprintf(format, sizeof format, "%%c%%c%%-%us %%-%us %%s %%c   %%d %%s  %%s %%s\n", 
+	simple_snprintf(format, sizeof format, "%%c%%c%%-%zus %%-%zus %%s %%c   %%d %%s  %%s %%s\n", 
 			maxnicklen, maxhandlen);
 	dprintf(idx, format, chanflag[0], chanflag[1], m->nick,	handle, s, atrflag, m->hops,
                      s1, m->userhost, m->userip);

+ 4 - 2
src/mod/server.mod/servmsg.c

@@ -1644,7 +1644,7 @@ static void connect_server(void)
     /* I'm resolving... don't start another server connect request */
     resolvserv = 1;
     /* Resolve the hostname. */
-    int dns_id = egg_dns_lookup(botserver, 20, server_dns_callback, (void *) newidx);
+    int dns_id = egg_dns_lookup(botserver, 20, server_dns_callback, (void *) (long) newidx);
     if (dns_id >= 0)
       dcc[newidx].dns_id = dns_id;
     /* wait for async reply */
@@ -1653,7 +1653,9 @@ static void connect_server(void)
 
 static void server_dns_callback(int id, void *client_data, const char *host, char **ips)
 {
-  int idx = (int) client_data;
+  //64bit hacks
+  long data = (long) client_data;
+  int idx = (int) data;
 
   resolvserv = 0;
 

+ 2 - 2
src/net.c

@@ -1684,9 +1684,9 @@ void tell_netdebug(int idx)
       if (socklist[i].flags & SOCK_NONSOCK)
 	strlcat(s, " (file)", sizeof(s));
       if (socklist[i].inbuf != NULL)
-	sprintf(&s[strlen(s)], " (inbuf: %04X)", strlen(socklist[i].inbuf));
+	simple_sprintf(&s[strlen(s)], " (inbuf: %zu)", strlen(socklist[i].inbuf));
       if (socklist[i].outbuf != NULL)
-	sprintf(&s[strlen(s)], " (outbuf: %06lX)", (unsigned long) socklist[i].outbuflen);
+	simple_sprintf(&s[strlen(s)], " (outbuf: %zu)", socklist[i].outbuflen);
       if (socklist[i].host)
         simple_sprintf(&s[strlen(s)], " (%s:%d)", socklist[i].host, socklist[i].port);
       strlcat(s, ",", sizeof(s));

+ 2 - 2
src/stringfix.c

@@ -83,9 +83,9 @@ void garble(char **inptr, char **outptr)
     }
 
     if (help)
-      sprintf(*outptr, "%d, \"%s\"", chars, obuf);
+      sprintf(*outptr, "%zu, \"%s\"", chars, obuf);
     else
-      sprintf(*outptr, "degarble(%d, \"%s\")", chars, obuf);
+      sprintf(*outptr, "degarble(%zu, \"%s\")", chars, obuf);
     *outptr += strlen(*outptr);
     in = p + 2;
   } else {

+ 7 - 7
src/users.c

@@ -395,10 +395,10 @@ tell_user(int idx, struct userrec *u)
       egg_strftime(s1, 6, "%H:%M", gmtime(&li->laston));
   }
   if (!u->bot) {
-    egg_snprintf(format, sizeof format, "%%-%us %%-5s %%-15s %%s (%%-10.10s)\n", HANDLEN);
+    simple_snprintf(format, sizeof format, "%%-%us %%-5s %%-15s %%s (%%-10.10s)\n", HANDLEN);
     dprintf(idx, format, u->handle, get_user(&USERENTRY_PASS, u) ? "yes" : "no", s, s1, (li && li->lastonplace) ? li->lastonplace : "nowhere");
   } else {	/* BOT */
-    egg_snprintf(format, sizeof format, "%%-%us %%-8s %%s (%%-10.10s)\n", HANDLEN);
+    simple_snprintf(format, sizeof format, "%%-%us %%-8s %%s (%%-10.10s)\n", HANDLEN);
     dprintf(idx, format, u->handle, s, s1, (li && li->lastonplace) ? li->lastonplace : "nowhere");
   }  
   /* channel flags? */
@@ -420,7 +420,7 @@ tell_user(int idx, struct userrec *u)
         fr.match = FR_CHAN;
         fr.chan = ch->flags;
         build_flags(s, &fr, NULL);
-        egg_snprintf(format, sizeof format, "%%%us  %%-18s %%-15s %%s\n", HANDLEN-9);
+        simple_snprintf(format, sizeof format, "%%%us  %%-18s %%-15s %%s\n", HANDLEN-9);
         dprintf(idx, format, " ", ch->channel, s, s1);
         if (ch->info != NULL)
   	  dprintf(idx, "    INFO: %s\n", ch->info);
@@ -452,10 +452,10 @@ void tell_user_ident(int idx, char *id)
   char format[81] = "";
 
   if (u->bot) {
-    egg_snprintf(format, sizeof format, "%%-%us FLAGS    LAST\n", HANDLEN);
+    simple_snprintf(format, sizeof format, "%%-%us FLAGS    LAST\n", HANDLEN);
     dprintf(idx, format, "BOTNICK");
   } else {
-    egg_snprintf(format, sizeof format, "%%-%us PASS FLAGS           LAST\n", HANDLEN);
+    simple_snprintf(format, sizeof format, "%%-%us PASS FLAGS           LAST\n", HANDLEN);
     dprintf(idx, format, "HANDLE");
   }
   tell_user(idx, u);
@@ -474,10 +474,10 @@ void tell_users_match(int idx, char *mtch, int start, int limit, char *chname, i
 
   dprintf(idx, "*** Matching '%s':\n", mtch);
   if (isbot) {
-    egg_snprintf(format, sizeof format, "%%-%us FLAGS    LAST\n", HANDLEN);
+    simple_snprintf(format, sizeof format, "%%-%us FLAGS    LAST\n", HANDLEN);
     dprintf(idx, format, "BOTNICK");
   } else {
-    egg_snprintf(format, sizeof format, "%%-%us PASS FLAGS           LAST\n", HANDLEN);
+    simple_snprintf(format, sizeof format, "%%-%us PASS FLAGS           LAST\n", HANDLEN);
     dprintf(idx, format, "HANDLE");
   }
   if (start > 1)