diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2010-03-18 10:10:32 +0100 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2010-03-18 10:10:32 +0100 |
commit | 05cb2b9c62b323a1278c81b6cbe00b2e4186b4f4 (patch) | |
tree | 898185b02c06b47450c88fc8731cf508c056568d | |
parent | e9c99cb0a353ed18bd7c6ea6e93ec2fea326bbb4 (diff) | |
download | fetchmail-05cb2b9c62b323a1278c81b6cbe00b2e4186b4f4.tar.gz fetchmail-05cb2b9c62b323a1278c81b6cbe00b2e4186b4f4.tar.bz2 fetchmail-05cb2b9c62b323a1278c81b6cbe00b2e4186b4f4.zip |
Fix lots of warnings, most around string literals...
...that were converted to char* when they should have been converted to
const char *.
Use braces for empty if/else statements.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | cram.c | 6 | ||||
-rw-r--r-- | driver.c | 11 | ||||
-rw-r--r-- | env.c | 2 | ||||
-rw-r--r-- | fetchmail.c | 4 | ||||
-rw-r--r-- | fetchmail.h | 18 | ||||
-rw-r--r-- | gssapi.c | 3 | ||||
-rw-r--r-- | imap.c | 2 | ||||
-rw-r--r-- | interface.c | 11 | ||||
-rw-r--r-- | md5.h | 2 | ||||
-rw-r--r-- | netrc.c | 2 | ||||
-rw-r--r-- | opie.c | 2 | ||||
-rw-r--r-- | rcfile_l.l | 4 | ||||
-rw-r--r-- | rfc2047e.c | 2 | ||||
-rw-r--r-- | rfc822.c | 2 | ||||
-rw-r--r-- | sink.c | 7 | ||||
-rw-r--r-- | socket.c | 4 | ||||
-rw-r--r-- | socket.h | 4 | ||||
-rw-r--r-- | transact.c | 3 | ||||
-rw-r--r-- | ucs/norm_charmap.c | 2 | ||||
-rw-r--r-- | unmime.c | 4 |
21 files changed, 55 insertions, 42 deletions
diff --git a/configure.ac b/configure.ac index 428fc3d3..69e38390 100644 --- a/configure.ac +++ b/configure.ac @@ -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([ @@ -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; @@ -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, @@ -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) */ diff --git a/fetchmail.c b/fetchmail.c index e0ec1758..4e0ea519 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -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 */ diff --git a/fetchmail.h b/fetchmail.h index b43999f9..51562933 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -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> */ @@ -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; @@ -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]; diff --git a/interface.c b/interface.c index 0b0d5791..86332300 100644 --- a/interface.c +++ b/interface.c @@ -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'; @@ -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); @@ -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 @@ -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]; @@ -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; @@ -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> @@ -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 @@ -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@"; @@ -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; @@ -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 */ @@ -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) { diff --git a/ucs/norm_charmap.c b/ucs/norm_charmap.c index f00dcc26..e2a9aaf9 100644 --- a/ucs/norm_charmap.c +++ b/ucs/norm_charmap.c @@ -40,7 +40,7 @@ static char buf[16]; const char *norm_charmap(const char *name) { - char *p; + const char *p; if (!name) return name; @@ -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 |