Просмотр исходного кода

* Cleanup some g++ 4.2.1 warnings (much more left)

svn: 3849
Bryan Drewery 18 лет назад
Родитель
Сommit
f022617512

+ 1 - 1
src/botnet.c

@@ -871,7 +871,7 @@ int users_in_subtree(tand_t *bot)
 
 /* Break link with a tandembot
  */
-int botunlink(int idx, char *nick, char *reason)
+int botunlink(int idx, const char *nick, const char *reason)
 {
   register int i;
   int bots, users;

+ 1 - 1
src/botnet.h

@@ -20,7 +20,7 @@ void tell_bots(int, int, const char *);
 void tell_bottree(int);
 void dump_links(int);
 int botlink(char *, int, char *);
-int botunlink(int, char *, char *);
+int botunlink(int, const char *, const char *);
 void addbot(char *, char *, char *, char, int, time_t, int, char *);
 void updatebot(int, char *, char, int, time_t, int, char *);
 void rembot(const char *);

+ 2 - 2
src/chanprog.c

@@ -674,9 +674,9 @@ void reload()
  */
 int isowner(char *name)
 {
-  if (!owner || !*owner)
+  if (!owner[0])
     return (0);
-  if (!name || !*name)
+  if (!name || !name[0])
     return (0);
 
   char *pa = owner, *pb = owner;

+ 1 - 1
src/cmds.c

@@ -699,7 +699,7 @@ static void cmd_help(int idx, char *par)
       }
     }
   }
-  if (buf && buf[0])
+  if (buf[0])
     dprintf(idx, "%s\n", buf);
   if (fnd) 
     dprintf(idx, "--End help listing\n");

+ 2 - 2
src/cmds.h

@@ -15,9 +15,9 @@ typedef struct {
 
 typedef struct {
   int type;
-  char *cmd;
+  const char *cmd;
   int garble;
-  char *desc;
+  const char *desc;
 } help_t;
 
 typedef struct {

+ 2 - 0
src/compat/inet_ntop.c

@@ -119,7 +119,9 @@ egg_inet_ntop6(const u_char *src, char *dst, socklen_t size)
 	for (i = 0; i < NS_IN6ADDRSZ; i += 2)
 		words[i >> 1] = (src[i] << 8) | src[i + 1];
 	best.base = -1;
+        best.len = 0;
 	cur.base = -1;
+        cur.len = 0;
 	for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
 		if (words[i] == 0) {
 			if (cur.base == -1)

+ 2 - 2
src/conf.c

@@ -262,7 +262,7 @@ confedit()
       run = (char *) my_calloc(1, size);
       /* child */
       simple_snprintf(run, size, "%s %s", editor, tmpconf.file);
-      execlp("/bin/sh", "/bin/sh", "-c", run, NULL);
+      execlp("/bin/sh", "/bin/sh", "-c", run, (char*)NULL);
       perror(editor);
       exit(1);
      /*NOTREACHED*/}
@@ -437,7 +437,7 @@ checkpid(const char *nick, conf_bot *bot)
     fclose(f);
     remove_crlf(buf);
 
-    if (!buf || !buf[0])
+    if (!buf[0])
       return 0;
   
     bufp = buf;

+ 2 - 2
src/dccutil.c

@@ -191,7 +191,7 @@ colorbuf(char *buf, size_t len, int idx)
         }
       }
     }
-    simple_snprintf(buf3, sizeof(buf3), "%s%s", (buf3 && buf3[0]) ? buf3 : "", (buf2 && buf2[0]) ? buf2 : "");
+    simple_snprintf(buf3, sizeof(buf3), "%s%s", buf3[0] ? buf3 : "", buf2[0] ? buf2 : "");
   }
   buf3[strlen(buf3)] = 0;
   strcpy(buf, buf3);
@@ -787,7 +787,7 @@ detect_dcc_flood(time_t * timer, struct chat_info *chat, int idx)
 /* Handle someone being booted from dcc chat.
  */
 void
-do_boot(int idx, char *by, char *reason)
+do_boot(int idx, const char *by, const char *reason)
 {
   dprintf(idx, DCC_BOOTED1);
   dprintf(idx, DCC_BOOTED2, by, reason[0] ? ": " : ".", reason);

+ 1 - 1
src/dccutil.h

@@ -48,7 +48,7 @@ int new_dcc(struct dcc_table *, int);
 void del_dcc(int);
 char *add_cr(char *);
 void changeover_dcc(int, struct dcc_table *, int);
-void do_boot(int, char *, char *);
+void do_boot(int, const char *, const char *);
 int detect_dcc_flood(time_t *, struct chat_info *, int);
 void identd_open(const char * = NULL, const char * = NULL);
 void identd_close();

+ 1 - 1
src/garble.c

@@ -17,7 +17,7 @@ unsigned char *garble_buffer[GARBLE_BUFFERS] = {
 
 int garble_ptr = (-1);
 
-char *degarble(int len, char *g)
+char *degarble(int len, const char *g)
 {
   unsigned char x = 0;
 

+ 1 - 1
src/garble.h

@@ -3,6 +3,6 @@
 
 #define STR(x) x
 
-char *degarble(int, char *);
+char *degarble(int, const char *);
 
 #endif /* !_GARBLE_H */

+ 1 - 1
src/makeres.c

@@ -144,7 +144,7 @@ enum {\n");
 #ifndef _RESPONSES_H\n\
 #define _RESPONSES_H\n\
 \n\
-typedef char * res_t;\n\n");
+typedef const char * res_t;\n\n");
 
   while ((!feof(inf)) && ((buffer = step_thru_file(inf)) != NULL) ) {
     line++;

+ 3 - 3
src/misc.c

@@ -70,9 +70,9 @@ bool		use_exempts = 0;
 /* low-level stuff for other modules
  */
 
-size_t my_strcpy(register char *a, register char *b)
+size_t my_strcpy(register char *a, register const char *b)
 {
-  register char *c = b;
+  register const char *c = b;
 
   while (*b)
     *a++ = *b++;
@@ -1071,7 +1071,7 @@ char* replace_vars(char *buf) {
   return replace(buf, "$n", botname);
 }
 
-void showhelp(int idx, struct flag_record *flags, char *string)
+void showhelp(int idx, struct flag_record *flags, const char *string)
 {
   struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0 };
   char *helpstr = (char *) my_calloc(1, strlen(string) + 1000 + 1);

+ 2 - 2
src/misc.h

@@ -18,14 +18,14 @@ int coloridx(int);
 const char *color(int, int, int);
 void shuffle(char *, char *);
 void shuffleArray(char **, size_t);
-void showhelp(int, struct flag_record *, char *);
+void showhelp(int, struct flag_record *, const char *);
 char *replace(const char *, const char *, const char *);
 char *replace_vars(char*);
 int goodpass(char *, int, char *);
 int bot_aggressive_to(struct userrec *);
 void readsocks(const char *);
 int updatebin(int, char *, int);
-size_t my_strcpy(char *, char *);
+size_t my_strcpy(char *, const char *);
 void maskhost(const char *, char *);
 char *stristr(char *, char *);
 void splitc(char *, char *, char);

+ 1 - 1
src/mod/channels.mod/cmdschan.c

@@ -1144,7 +1144,7 @@ void show_int(int idx, char *work, int *cnt, const char *desc, int state, const
       strcat(tmp2, chr_state);
     }
     strcat(tmp2, BOLD_END(idx));
-    egg_snprintf(tmp, sizeof tmp, "%-30s %-20s %s", desc, tmp2, (tmp3 && tmp3[0]) ? tmp3 : "");
+    egg_snprintf(tmp, sizeof tmp, "%-30s %-20s %s", desc, tmp2, tmp3[0] ? tmp3 : "");
     strcat(work, tmp);
   }
   if (*cnt >= INT_COLS)

+ 1 - 1
src/mod/channels.mod/tclchan.c

@@ -237,7 +237,7 @@ int SplitList(char *resultBuf, const char *list, int *argcPtr, const char ***arg
     const char *l = NULL;
     const char *element = NULL;
     char *p = NULL;
-    int result, brace;
+    int result, brace = 0;
     size_t size = 2;		/* initialized to 1 for NULL pointer */
     size_t length, elSize, i = 0;
 

+ 1 - 1
src/mod/irc.mod/chan.c

@@ -1098,7 +1098,7 @@ void enforce_closed(struct chanset_t *chan) {
   if (chan->closed_private && !(chan->channel.mode & CHANPRIV) && !(chan->mode_mns_prot & CHANPRIV))
     *p++ = 'p';
   *p = 0;
-  if (buf && buf[0])
+  if (buf[0])
     dprintf(DP_MODE, "MODE %s +%s\n", chan->name, buf);
   priority_do(chan, 0, PRIO_KICK);
 }

+ 2 - 1
src/mod/irc.mod/irc.c

@@ -1587,7 +1587,8 @@ void
 irc_report(int idx, int details)
 {
   struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0 };
-  char ch[1024] = "", q[160] = "", *p = NULL;
+  char ch[1024] = "", q[160] = "";
+  const char *p = NULL;
   int k = 10;
   size_t len;
 

+ 3 - 3
src/shell.c

@@ -832,7 +832,7 @@ char *homedir(bool useconf)
 {
   static char homedir_buf[DIRMAX] = "";
 
-  if (!homedir_buf || (homedir_buf && !homedir_buf[0])) {
+  if (!homedir_buf[0]) {
     char tmp[DIRMAX] = "";
 
     if (conf.homedir && useconf)
@@ -862,7 +862,7 @@ char *my_username()
 {
   static char username[DIRMAX] = "";
 
-  if (!username || (username && !username[0])) {
+  if (!username[0]) {
 #ifdef CYGWIN_HACKS
     simple_snprintf(username, sizeof username, "cygwin");
 #else /* !CYGWIN_HACKS */
@@ -931,7 +931,7 @@ char *my_uname()
 {
   static char os_uname[250] = "";
 
-  if (!os_uname || (os_uname && !os_uname[0])) {
+  if (!os_uname[0]) {
     char *unix_n = NULL, *vers_n = NULL;
     struct utsname un;
 

+ 1 - 1
src/userrec.c

@@ -331,7 +331,7 @@ int u_pass_match(struct userrec *u, char *in)
 
   if (!cmp && (!pass[0] || (pass[0] == '-')))
     return 1;
-  if (!cmp || !pass || !pass[0] || (pass[0] == '-'))
+  if (!cmp || !pass[0] || (pass[0] == '-'))
     return 0;
   if (u->bot) {
     if (!strcmp(cmp, pass))