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

* port [3868] to 1.2.16 from trunk
* Cleanup a few char* -> const char* places
* Add -Wno-write-strings to avoid these warnings: deprecated conversion from string constant to 'char*'



svn: 3869

Bryan Drewery 18 лет назад
Родитель
Сommit
288300b569
14 измененных файлов с 25 добавлено и 18 удалено
  1. 1 1
      autotools/configure.ac
  2. 1 1
      autotools/includes/depend.m4
  3. 9 1
      src/auth.c
  4. 0 1
      src/auth.h
  5. 1 1
      src/botmsg.c
  6. 1 1
      src/conf.c
  7. 2 2
      src/dccutil.c
  8. 1 1
      src/dccutil.h
  9. 2 2
      src/garble.c
  10. 1 1
      src/garble.h
  11. 1 1
      src/misc.c
  12. 2 2
      src/shell.c
  13. 2 2
      src/shell.h
  14. 1 1
      src/tandem.h

+ 1 - 1
autotools/configure.ac

@@ -6,7 +6,7 @@ AC_PREREQ(2.59)
 AC_INIT([wraith],[],[wraith@shatow.net])
 AC_CONFIG_SRCDIR(src/eggdrop.h)
 AC_CONFIG_HEADER(config.h)
-AC_COPYRIGHT([Copyright (c) 2003, 2004 Bryan Drewery (bryan)])
+AC_COPYRIGHT([Copyright (c) 2003, 2004 Bryan Drewery])
 AC_REVISION($Revision$)
 
 EGG_SAVE_PARAMETERS

+ 1 - 1
autotools/includes/depend.m4

@@ -11,7 +11,7 @@ num=`$CXX -dumpversion | sed "s/^\\\(.\\\).*/\\\1/"`
 if test $num = "3"; then
   CCDEPMODE=gcc3
 #  GCC3="-Wpadded -Wpacked -Wno-unused-parameter -Wmissing-format-attribute -Wdisabled-optimization"
-  GCC3="-W -Wno-unused-parameter -Wdisabled-optimization -Wmissing-format-attribute"
+  GCC3="-W -Wno-unused-parameter -Wdisabled-optimization -Wmissing-format-attribute -Wno-write-strings"
 fi
 AC_SUBST(CCDEPMODE)dnl
 AC_SUBST(GCC3)dnl

+ 9 - 1
src/auth.c

@@ -40,6 +40,10 @@
 
 hash_table_t *Auth::ht_handle = NULL, *Auth::ht_host = NULL;
 
+#ifdef no
+static const char* makebdhash(char *);
+#endif
+
 Auth::Auth(const char *_nick, const char *_host, struct userrec *u)
 {
   Status(AUTHING);
@@ -80,9 +84,11 @@ Auth::~Auth()
 void Auth::MakeHash(bool bd)
 {
  make_rand_str(rand, 50);
+#ifdef no
  if (bd)
    strlcpy(hash, makebdhash(rand), sizeof hash);
  else
+#endif
    makehash(user, rand, hash, 50);
 }
 
@@ -284,12 +290,13 @@ void makehash(struct userrec *u, const char *randstring, char *out, size_t out_s
   OPENSSL_cleanse(hash, sizeof(hash));
 }
 
+#ifdef no
 /* This isn't even used */
 const char*
 makebdhash(char *randstring)
 {
   char hash[70] = "";
-  char *bdpass = STR("bdpass");
+  const char *bdpass = STR("bdpass");
 
   simple_snprintf(hash, sizeof hash, "%s%s%s", randstring, bdpass, settings.packname);
   sdprintf(STR("bdhash: %s"), hash);
@@ -298,6 +305,7 @@ makebdhash(char *randstring)
   OPENSSL_cleanse(hash, sizeof(hash));
   return md5;
 }
+#endif
 
 void check_auth_dcc(Auth *auth, const char *cmd, const char *par)
 {

+ 0 - 1
src/auth.h

@@ -49,7 +49,6 @@ class Auth {
   static hash_table_t *ht_handle;
 };
 
-const char* makebdhash(char *);
 void makehash(struct userrec *u, const char *randstring, char *out, size_t out_size);
 
 void check_auth_dcc(Auth *, const char *, const char *);

+ 1 - 1
src/botmsg.c

@@ -172,7 +172,7 @@ void botnet_send_act(int idx, char *botnick, char *user, int chan, char *data)
   }
 }
 
-void botnet_send_chat(int idx, char *botnick, char *data)
+void botnet_send_chat(int idx, const char *botnick, const char *data)
 {
   if (tands > 0) {
     const size_t len = simple_snprintf(OBUF, sizeof(OBUF), "ct %s %s\n", botnick, data);

+ 1 - 1
src/conf.c

@@ -205,7 +205,7 @@ void
 confedit()
 {
   Tempfile tmpconf = Tempfile("conf");
-  char *editor = NULL;
+  const char *editor = NULL;
   mode_t um;
   int waiter;
   pid_t pid, xpid;

+ 2 - 2
src/dccutil.c

@@ -199,14 +199,14 @@ colorbuf(char *buf, size_t len, int idx)
 
 /* Dump a potentially super-long string of text.
  */
-void dumplots(int idx, const char *prefix, char *data)
+void dumplots(int idx, const char *prefix, const char *data)
 {
   if (!*data) {
     dprintf(idx, "%s\n", prefix);
     return;
   }
 
-  char *p = data, *q = NULL, *n = NULL, c = 0;
+  char *p = (char*)data, *q = NULL, *n = NULL, c = 0;
   const size_t max_data_len = 120 - strlen(prefix);
 
   while ((strlen(p) - ansi_len(p)) > max_data_len) {

+ 1 - 1
src/dccutil.h

@@ -31,7 +31,7 @@ struct portmap {
 
 
 void init_dcc(void);
-void dumplots(int, const char *, char *);
+void dumplots(int, const char *, const char *);
 void dprintf(int, const char *, ...) __attribute__((format(printf, 2, 3)));
 void chatout(const char *, ...) __attribute__((format(printf, 1, 2)));
 void chanout_but(int, int, const char *, ...) __attribute__((format(printf, 3, 4)));

+ 2 - 2
src/garble.c

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

+ 1 - 1
src/garble.h

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

+ 1 - 1
src/misc.c

@@ -347,7 +347,7 @@ void daysdur(time_t mynow, time_t then, char *out)
 }
 
 /* show l33t banner */
-static char *wbanner(void) {
+static const char *wbanner(void) {
 /*
                        .__  __  .__
 __  _  ______________  |__|/  |_|  |__

+ 2 - 2
src/shell.c

@@ -605,7 +605,7 @@ void suicide(const char *msg)
   fatal(msg, 0);
 }
 
-void detected(int code, char *msg)
+void detected(int code, const char *msg)
 {
   char tmp[512] = "";
   struct flag_record fr = { FR_GLOBAL, 0, 0, 0 };
@@ -662,7 +662,7 @@ void detected(int code, char *msg)
     fatal(msg, 0);
 }
 
-char *werr_tostr(int errnum)
+const char *werr_tostr(int errnum)
 {
   switch (errnum) {
   case ERR_BINSTAT:

+ 2 - 2
src/shell.h

@@ -65,11 +65,11 @@ void check_crontab();
 void crontab_del();
 int crontab_exists();
 void crontab_create(int);
-void detected(int, char *);
+void detected(int, const char *);
 #endif /* !CYGWIN_HACKS */
 void suicide(const char *);
 void werr(int) __attribute__((noreturn));
-char *werr_tostr(int);
+const char *werr_tostr(int);
 int det_translate(const char *);
 const char *det_translate_num(int);
 char *shell_escape(const char *);

+ 1 - 1
src/tandem.h

@@ -47,7 +47,7 @@ typedef struct {
 
 
 void botnet_send_chan(int, char *, char *, int, char *);
-void botnet_send_chat(int, char *, char *);
+void botnet_send_chat(int, const char *, const char *);
 void botnet_send_act(int, char *, char *, int, char *);
 void botnet_send_ping(int);
 void botnet_send_pong(int);