]> Pileus Git - ~andy/fetchmail/commitdiff
Fix lots of warnings, most around string literals...
authorMatthias Andree <matthias.andree@gmx.de>
Thu, 18 Mar 2010 09:10:32 +0000 (10:10 +0100)
committerMatthias Andree <matthias.andree@gmx.de>
Thu, 18 Mar 2010 09:10:32 +0000 (10:10 +0100)
...that were converted to char* when they should have been converted to
const char *.

Use braces for empty if/else statements.

21 files changed:
configure.ac
cram.c
driver.c
env.c
fetchmail.c
fetchmail.h
gssapi.c
imap.c
interface.c
md5.h
netrc.c
opie.c
rcfile_l.l
rfc2047e.c
rfc822.c
sink.c
socket.c
socket.h
transact.c
ucs/norm_charmap.c
unmime.c

index 428fc3d38bde4ed3a5c24e0af02de621f74c9ad8..69e38390e6a9d4197dd09c6f3e76a3e134797935 100644 (file)
@@ -187,7 +187,7 @@ AC_CHECK_FUNCS(tcsetattr stty setsid geteuid seteuid dnl
   atexit inet_aton strftime setrlimit socketpair dnl
   sigaction strdup setlocale)
 
-AC_CHECK_DECLS(strerror)
+AC_CHECK_DECLS([strerror,getenv])
 dnl INET6 is used by KAME/getnameinfo
 AC_CACHE_CHECK(for AF_INET6/PF_INET6,ac_cv_inet6,
 AC_COMPILE_IFELSE([
diff --git a/cram.c b/cram.c
index ee97475a54aa23a3cbf49000f6273ddd7110647c..16591b8d9540a960df6f7a06786b62f7a043f5fa 100644 (file)
--- a/cram.c
+++ b/cram.c
@@ -17,8 +17,8 @@
 #include  "i18n.h"
 #include "md5.h"
 
-void hmac_md5 (char *password,  size_t pass_len,
-               char *challenge, size_t chal_len,
+void hmac_md5 (const char *password,  size_t pass_len,
+               const char *challenge, size_t chal_len,
                unsigned char *response,  size_t resp_len)
 {
     int i;
@@ -60,7 +60,7 @@ void hmac_md5 (char *password,  size_t pass_len,
     MD5Final (response, &ctx);
 }
 
-int do_cram_md5 (int sock, char *command, struct query *ctl, char *strip)
+int do_cram_md5 (int sock, const char *command, struct query *ctl, const char *strip)
 /* authenticate as per RFC2195 */
 {
     int result;
index 7785b89cf337586087ec26e9d85616c0e4c190cd..32cfffb1182d9bd2e224fdec5366d900fc58b709 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -492,10 +492,13 @@ static int fetch_messages(int mailserver_socket, struct query *ctl,
 
        /* check if the message is old
         * Note: the size of the message may not be known here */
-       if (ctl->fetchall || force_retrieval)
-           ;
-       else if (ctl->server.base_protocol->is_old && (ctl->server.base_protocol->is_old)(mailserver_socket,ctl,num))
-           msgcode = MSGLEN_OLD;
+       if (ctl->fetchall || force_retrieval) {
+           /* empty */
+       } else { 
+           if (ctl->server.base_protocol->is_old && (ctl->server.base_protocol->is_old)(mailserver_socket,ctl,num)) {
+                   msgcode = MSGLEN_OLD;
+           }
+        }
        if (msgcode == MSGLEN_OLD)
        {
                /* To avoid flooding the syslog when using --keep,
diff --git a/env.c b/env.c
index 5dd54032188192dc2a86f9b5b161ab8c74269bb7..3b50d926fb08bbf2c974d106b3da698e8c1ee40c 100644 (file)
--- a/env.c
+++ b/env.c
@@ -30,7 +30,9 @@
 #include <locale.h>
 #endif
 
+#ifndef HAVE_DECL_GETENV
 extern char *getenv(const char *);     /* needed on sysV68 R3V7.1. */
+#endif
 
 void envquery(int argc, char **argv)
 /* set up basic stuff from the environment (including the rc file name) */
index e0ec175826778300233230b207602fdba5abe705..4e0ea519d824668161fd3a42d05160bc30c5d0c5 100644 (file)
@@ -72,9 +72,9 @@ flag versioninfo;         /* emit only version info */
 char *user;                /* the name of the invoking user */
 char *home;                /* invoking user's home directory */
 char *fmhome;              /* fetchmail's home directory */
-char *program_name;        /* the name to prefix error messages with */
+const char *program_name;   /* the name to prefix error messages with */
 flag configdump;           /* dump control blocks for configurator */
-char *fetchmailhost;       /* either `localhost' or the host's FQDN */
+const char *fetchmailhost;  /* either `localhost' or the host's FQDN */
 
 static int quitonly;       /* if we should quit after killing the running daemon */
 
index b43999f911f7915ccd93d8e0296cb4b55cb60ccb..51562933150e45124c03bee5e6e996f3eeaabe53 100644 (file)
@@ -176,7 +176,7 @@ struct runctl
     char       *logfile;       /** where to write log information */
     char       *idfile;        /** where to store UID data */
     char       *pidfile;       /** where to record the PID of daemon mode processes */
-    char       *postmaster;
+    const char *postmaster;
     char       *properties;
     int                poll_interval;  /** poll interval in seconds (daemon mode, 0 == off) */
     flag       bouncemail;
@@ -255,7 +255,7 @@ struct hostdata             /* shared among all user connections to given server */
     struct idlist *akalist;            /* server name first, then akas */
     struct idlist *localdomains;       /* list of pass-through domains */
     int protocol;                      /* protocol type */
-    char *service;                     /* service name */
+    const char *service;               /* service name */
     int interval;                      /* # cycles to skip between polls */
     int authenticate;                  /* authentication mode to try */
     int timeout;                       /* inactivity timout in seconds */
@@ -454,7 +454,7 @@ extern char *home;          /* home directory of invoking user */
 extern char *fmhome;           /* fetchmail home directory */
 extern int pass;               /* number of re-polling pass */
 extern flag configdump;                /* dump control blocks as Python dictionary */
-extern char *fetchmailhost;    /* either "localhost" or an FQDN */
+extern const char *fetchmailhost; /* either "localhost" or an FQDN */
 extern int suppress_tags;      /* suppress tags in tagged protocols? */
 extern char shroud[PASSWORDLEN*2+3];   /* string to shroud in debug output */
 #ifdef SDPS_ENABLE
@@ -638,10 +638,10 @@ int doETRN (struct query *);
 int doODMR (struct query *);
 
 /* authentication functions */
-int do_cram_md5(int sock, char *command, struct query *ctl, char *strip);
-int do_rfc1731(int sock, char *command, char *truename);
-int do_gssauth(int sock, char *command, char *service, char *hostname, char *username);
-int do_otp(int sock, char *command, struct query *ctl);
+int do_cram_md5(int sock, const char *command, struct query *ctl, const char *strip);
+int do_rfc1731(int sock, const char *command, const char *truename);
+int do_gssauth(int sock, const char *command, const char *service, const char *hostname, const char *username);
+int do_otp(int sock, const char *command, struct query *ctl);
 
 /* miscellanea */
 
@@ -652,7 +652,7 @@ struct query *hostalloc(struct query *);
 int parsecmdline (int, char **, struct runctl *, struct query *);
 char *prependdir (const char *, const char *);
 char *MD5Digest (unsigned const char *);
-void hmac_md5 (char *, size_t, char *, size_t, unsigned char *, size_t);
+void hmac_md5 (const char *, size_t, const char *, size_t, unsigned char *, size_t);
 int POP3_auth_rpa(char *, char *, int socket);
 typedef RETSIGTYPE (*SIGHANDLERTYPE) (int);
 void deal_with_sigchld(void);
@@ -723,7 +723,7 @@ char *stpcpy(char *, const char*);
 #endif /* __CYGWIN__ */
 
 extern int mailserver_socket_temp;
-extern char *program_name;
+extern const char *program_name;
 
 /* POSIX space characters,
  * <tab>;<newline>;<vertical-tab>;<form-feed>;<carriage-return>;<space> */
index 8189552ab37ab7b4c4cdae525eaa93dfa90d36a5..4f8e766c4f3a33ab4b1bfdd013c7a8760a4d5a6b 100644 (file)
--- a/gssapi.c
+++ b/gssapi.c
@@ -42,7 +42,8 @@
 #define GSSAUTH_P_INTEGRITY 2
 #define GSSAUTH_P_PRIVACY   4
 
-int do_gssauth(int sock, char *command, char *service, char *hostname, char *username)
+int do_gssauth(int sock, const char *command, const char *service,
+               const char *hostname, const char *username)
 {
     gss_buffer_desc request_buf, send_token;
     gss_buffer_t sec_token;
diff --git a/imap.c b/imap.c
index 501f60e193725dd7808bc17906049811d8b1de1c..35b3bd07941000f961d5934a24bcdd09823a2b64 100644 (file)
--- a/imap.c
+++ b/imap.c
@@ -418,7 +418,7 @@ static void capa_probe(int sock, struct query *ctl)
     peek_capable = (imap_version >= IMAP4);
 }
 
-static int do_authcert (int sock, char *command, const char *name)
+static int do_authcert (int sock, const char *command, const char *name)
 /* do authentication "external" (authentication provided by client cert) */
 {
     char buf[256];
index 0b0d5791e6102d66fd89298b0322f1f1275c2f2a..86332300ca18f79ddffcfbf72f110cfccee1d07f 100644 (file)
@@ -74,7 +74,7 @@ struct interface_pair_s {
 #ifdef linux
 #define have_interface_init
 
-static char *netdevfmt;
+static const char *netdevfmt;
 
 void interface_init(void)
 /* figure out which /proc/net/dev format to use */
@@ -173,13 +173,13 @@ static int get_ifinfo(const char *ifname, ifinfo_t *ifinfo)
                result = FALSE;
        else
        {
-           char        *sp = strchr(ifname, '/');
+           char *tmp = xstrdup(ifname);
+           char *sp = strchr(tmp, '/');
            /* hide slash and trailing info from ifname */
            if (sp)
                *sp = '\0';
            result = _get_ifinfoGT_(socket_fd, stats_file, ifname, ifinfo);
-           if (sp)
-               *sp = '/';
+           free(tmp);
        }
        if (socket_fd >= 0)
            SockClose(socket_fd);
@@ -579,6 +579,7 @@ void interface_parse(char *buf, struct hostdata *hp)
 /* parse 'interface' specification */
 {
        char *cp1, *cp2;
+       char mask1[] = "255.255.255.255";
 
        hp->interface = xstrdup(buf);
 
@@ -593,7 +594,7 @@ void interface_parse(char *buf, struct hostdata *hp)
 
        /* find and isolate just the netmask */
        if (!(cp2 = strchr(cp1, '/')))
-               cp2 = "255.255.255.255";
+               cp2 = mask1;
        else
                *cp2++ = '\000';
 
diff --git a/md5.h b/md5.h
index 19530bcab60411c72bbdef35409abb9b1155b860..83b748c4f89114850949c6fe91ef33280aa21042 100644 (file)
--- a/md5.h
+++ b/md5.h
@@ -22,7 +22,7 @@ struct MD5Context {
 void MD5Init(struct MD5Context *context);
 void MD5Update(struct MD5Context *context, const void *buf, unsigned len);
 void MD5Final(void *digest, struct MD5Context *context);
-void MD5Transform(uint32 buf[4], uint32 const in[16]);
+void MD5Transform(uint32 buf[], uint32 const in[]);
 
 char *MD5Digest (unsigned const char *s);
 
diff --git a/netrc.c b/netrc.c
index 196db6715c65657d82f3618091f4ecd537024c56..de29cc8cf74dea5989d3f7ec868e85a61f3aa6c6 100644 (file)
--- a/netrc.c
+++ b/netrc.c
@@ -28,7 +28,7 @@
 # define xmalloc malloc
 # define xrealloc realloc
 
-char *program_name = "netrc";
+const char *program_name = "netrc";
 #endif
 
 /* Maybe add NEWENTRY to the account information list, LIST.  NEWENTRY is
diff --git a/opie.c b/opie.c
index 395de2dd4f5fc65d132a24a5849a655d4dd2d254..94fd59b4c87de894177c97abad43e792c41d525b 100644 (file)
--- a/opie.c
+++ b/opie.c
@@ -26,7 +26,7 @@ extern "C" {
 }
 #endif
 
-int do_otp(int sock, char *command, struct query *ctl)
+int do_otp(int sock, const char *command, struct query *ctl)
 {
     int i, rval;
     char buffer[128];
index 9a1fe637bac22fcc76004d90a8cbe92a64bbf771..8dcd8af1b0a99acdc6d047a1abe8b5a0b522d874 100644 (file)
@@ -19,6 +19,8 @@ int prc_lineno = 1;
 #define SETSTATE(n)    BEGIN(n)
 #endif /* LEXDEBUG */
 
+#define YY_NO_INPUT
+
 %}
 
 /* this doesn't work with Linux lex, see the INSTALL file */
@@ -244,7 +246,7 @@ void escapes(const char *cp /** source string with escapes */,
         * always succeed! */
        if (*cp == '\\' && cp[1] && strchr("0123456789xX", cp[1]))
        {
-           char *dp;
+           const char *dp;
            const char *hex = "00112233445566778899aAbBcCdDeEfF";
            int dcount = 0;
 
index 28777a300d5aa7d49f8bdfdd6127a60a8fc2c6cb..e6f8f32bcc4913b5d0d1800dd69197f273f11699 100644 (file)
@@ -17,7 +17,9 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 #include "fetchmail.h"
 
 #include <string.h>
index beff379db9c5034ae5ba08a91dbc6de2c8268ebf..97f2677131145ce10beed83cc7a7aec5a07df0cf 100644 (file)
--- a/rfc822.c
+++ b/rfc822.c
@@ -31,7 +31,7 @@ MIT license.  Compile with -DMAIN to build the demonstrator.
 #else
 #include  <unistd.h>
 static int verbose;
-char *program_name = "rfc822";
+const char *program_name = "rfc822";
 #endif /* MAIN */
 
 #ifndef TRUE
diff --git a/sink.c b/sink.c
index f4fbf4fd8837821d114fd520c2b41fcaaee038ec..76cd2bb5abfb7bb94809933495b03e8149ad15c6 100644 (file)
--- a/sink.c
+++ b/sink.c
@@ -131,7 +131,7 @@ int smtp_setup(struct query *ctl)
        for (idp = ctl->smtphunt; idp; idp = idp->next)
        {
            char        *cp;
-           char        *portnum = SMTP_PORT;
+           const char  *portnum = SMTP_PORT;
 
            ctl->smtphost = idp->id;  /* remember last host tried. */
            if (ctl->smtphost[0]=='/')
@@ -262,12 +262,13 @@ char *rcpt_address(struct query *ctl, const char *id,
 }
 
 static int send_bouncemail(struct query *ctl, struct msgblk *msg,
-                          int userclass, char *message /* should have \r\n at the end */,
+                          int userclass, const char *message /* should have \r\n at the end */,
                           int nerrors, char *errors[])
 /* bounce back an error report a la RFC 1892 */
 {
     char daemon_name[15 + HOSTLEN] = "MAILER-DAEMON@";
-    char boundary[BUFSIZ], *bounce_to;
+    char boundary[BUFSIZ];
+    const char *bounce_to;
     int sock;
     static char *fqdn_of_host = NULL;
     const char *md1 = "MAILER-DAEMON", *md2 = "MAILER-DAEMON@";
index f987040a29985781027ffb908072916328abaa25..061322b9af9559b701749b79082a287f92c85230 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -385,7 +385,7 @@ static      SSL *_ssl_context[FD_SETSIZE];
 static SSL     *SSLGetContext( int );
 #endif /* SSL_ENABLE */
 
-int SockWrite(int sock, char *buf, int len)
+int SockWrite(int sock, const char *buf, int len)
 {
     int n, wrlen = 0;
 #ifdef SSL_ENABLE
@@ -813,7 +813,7 @@ static const char *SSLCertGetCN(const char *mycert,
  * uses SSL *ssl global variable, which is currently defined
  * in this file
  */
-int SSLOpen(int sock, char *mycert, char *mykey, char *myproto, int certck, char *certpath,
+int SSLOpen(int sock, char *mycert, char *mykey, const char *myproto, int certck, char *certpath,
     char *fingerprint, char *servercname, char *label, char **remotename)
 {
         struct stat randstat;
index a32a342279151c4e65ac1e479385a12f8b5c9db5..b340c4ce13f90b363e64a6c680a1a5c662e21750 100644 (file)
--- a/socket.h
+++ b/socket.h
@@ -44,7 +44,7 @@ int SockPeek(int sock);
 Write a chunk of bytes to the socket (matches interface of fwrite).
 Returns number of bytes successfully written.
 */
-int SockWrite(int sock, char *buf, int size);
+int SockWrite(int sock, const char *buf, int size);
 
 /* from /usr/include/sys/cdefs.h */
 #if !defined __GNUC__ || __GNUC__ < 2
@@ -75,7 +75,7 @@ FIXME: document this
 int UnixOpen(const char *path);
 
 #ifdef SSL_ENABLE
-int SSLOpen(int sock, char *mycert, char *mykey, char *myproto, int certck, char *certpath,
+int SSLOpen(int sock, char *mycert, char *mykey, const char *myproto, int certck, char *certpath,
     char *fingerprint, char *servercname, char *label, char **remotename);
 #endif /* SSL_ENABLE */
 
index 85d8b009d958877c02d61d394c0f1f5ec48fc26a..5201ceefe7cf0f9aa028ada435251a09f2719d63 100644 (file)
@@ -799,9 +799,10 @@ eoh:
         */
        if ((already_has_return_path==FALSE) && !strncasecmp("Return-Path:", line, 12) && (cp = nxtaddr(line)))
        {
+           char nulladdr[] = "<>";
            already_has_return_path = TRUE;
            if (cp[0]=='\0')    /* nxtaddr() strips the brackets... */
-               cp="<>";
+               cp=nulladdr;
            strncpy(msgblk.return_path, cp, sizeof(msgblk.return_path));
            msgblk.return_path[sizeof(msgblk.return_path)-1] = '\0';
            if (!ctl->mda) {
index f00dcc26df8956f6e4dae3c4579cd7db2beffdc3..e2a9aaf9671bfbf2d7fbd84b6e240f1b771cae44 100644 (file)
@@ -40,7 +40,7 @@ static char buf[16];
 
 const char *norm_charmap(const char *name)
 {
-  char *p;
+  const char *p;
   
   if (!name)
     return name;
index 1c0c8245727bddb4e6d74989922678f200286b70..8ff782a55686bd1ed7a872a89d887221a516b870 100644 (file)
--- a/unmime.c
+++ b/unmime.c
@@ -337,7 +337,7 @@ static int CheckContentType(char *CntType)
    * be really careful if you change this.
    */
 
-  static char *DecodedTypes[] = {
+  static const char *DecodedTypes[] = {
     "text/",        /* Will match ALL content-type's starting with 'text/' */
     "message/rfc822", 
     NULL
@@ -651,7 +651,7 @@ int UnMimeBodyline(char **bufp, flag delimited, flag softline)
 #include <stdio.h>
 #include <unistd.h>
 
-char *program_name = "unmime";
+const char *program_name = "unmime";
 int outlevel = 0;
 
 #define BUFSIZE_INCREMENT 4096