Commit 4f36463d 4f36463dfe2d17b2932a656fffee9aeb7832abe4 by Sergey Poznyakoff

Variois fixes (mostly to placate gcc)

* examples/base64.c, examples/mta.c,
imap4d/auth_gss.c, imap4d/imap4d.c,
imap4d/preauth.c, libmu_auth/ldap.c,
libmu_auth/virtual.c, libmu_scm/mu_body.c,
libmu_scm/mu_port.c, libproto/mailer/smtp.c,
mailbox/acl.c, mailbox/secret.c, pop3d/pop3d.c,
python/libmu_py/address.c, sql/odbc.c: Fix argument
signedness.

* imap4d/fetch.c, imap4d/store.c (closures):
Change type of `count' to int, to match the
signature of util_msgset.
* include/mailutils/guile.h (mu_scm_message_get): Fix
return type (const is useless here).
* libmu_scm/mu_message.c (mu_scm_message_get): Likewise.
(scm_mu_message_copy): Fix type of the `wr' automatic variable.
* libmu_scm/mu_mime.c (mu_scm_mime_get): Remove const qualifier
from the return type.
* libmu_argp/cmdline.c: Include stdlib.h.
1 parent f0cc7bda
......@@ -94,7 +94,8 @@ main (int argc, char * argv [])
MU_ASSERT (mu_stdio_stream_create (&out, stdout, 0));
MU_ASSERT (mu_stream_open (out));
while (mu_stream_read (flt, &buffer, sizeof (buffer), total, &size) == 0
while (mu_stream_read (flt, (char*) &buffer,
sizeof (buffer), total, &size) == 0
&& size > 0)
{
if (printable && !ISPRINT (buffer))
......@@ -104,7 +105,7 @@ main (int argc, char * argv [])
mu_stream_sequential_write (out, outbuf, strlen (outbuf));
}
else
mu_stream_sequential_write (out, &buffer, size);
mu_stream_sequential_write (out, (char*) &buffer, size);
total += size;
}
......
......@@ -803,7 +803,8 @@ mta_smtp (int argc, char **argv)
{
fd_set rfds;
struct sockaddr_in his_addr;
int sfd, len, status;
int sfd, status;
socklen_t len;
FD_ZERO (&rfds);
FD_SET (fd, &rfds);
......
......@@ -114,7 +114,7 @@ auth_gssapi (struct imap4d_command *command,
{
gss_buffer_desc tokbuf, outbuf;
OM_uint32 maj_stat, min_stat, min_stat2;
OM_uint32 cflags;
int cflags;
OM_uint32 sec_level, mech;
gss_ctx_id_t context;
gss_cred_id_t cred_handle, server_creds;
......@@ -170,8 +170,10 @@ auth_gssapi (struct imap4d_command *command,
for (;;)
{
OM_uint32 ret_flags;
imap4d_getline (&token_str, &token_size, &token_len);
mu_base64_decode (token_str, token_len, &tmp, &size);
mu_base64_decode ((unsigned char*) token_str, token_len, &tmp, &size);
tokbuf.value = tmp;
tokbuf.length = size;
......@@ -183,7 +185,7 @@ auth_gssapi (struct imap4d_command *command,
&client,
&mech_type,
&outbuf,
&cflags, NULL, &cred_handle);
&ret_flags, NULL, &cred_handle);
free (tmp);
if (maj_stat == GSS_S_CONTINUE_NEEDED)
{
......@@ -234,7 +236,7 @@ auth_gssapi (struct imap4d_command *command,
free (tmp);
imap4d_getline (&token_str, &token_size, &token_len);
mu_base64_decode (token_str, token_len,
mu_base64_decode ((unsigned char *) token_str, token_len,
(unsigned char **) &tokbuf.value, &tokbuf.length);
free (token_str);
......
......@@ -63,7 +63,7 @@ struct fetch_parse_closure
int isuid;
mu_list_t fnlist;
size_t *set;
size_t count;
int count;
};
......
......@@ -412,7 +412,7 @@ imap4d_session_setup (char *username)
int
get_client_address (int fd, struct sockaddr_in *pcs)
{
int len = sizeof *pcs;
socklen_t len = sizeof *pcs;
if (getpeername (fd, (struct sockaddr *) pcs, &len) < 0)
{
......
......@@ -141,7 +141,7 @@ des_cbc_cksum (gl_des_ctx *ctx, unsigned char *buf, size_t bufsize,
}
bufsize = 0;
}
gl_des_ecb_crypt (ctx, key, key, 0);
gl_des_ecb_crypt (ctx, (char*) key, (char*) key, 0);
}
}
......@@ -194,8 +194,8 @@ des_string_to_key (char *buf, size_t bufsize, unsigned char key[8])
}
des_fixup_key_parity (key);
gl_des_setkey (&context, key);
des_cbc_cksum (&context, buf, bufsize, key, key);
gl_des_setkey (&context, (char*) key);
des_cbc_cksum (&context, (unsigned char*) buf, bufsize, key, key);
memset (&context, 0, sizeof context);
des_fixup_key_parity (key);
}
......@@ -215,7 +215,7 @@ decode64_buf (const char *name, unsigned char **pbuf, size_t *psize)
MU_STREAM_READ | MU_STREAM_NO_CHECK);
mu_stream_open (str);
mu_stream_sequential_write (str, name, namelen);
mu_stream_read (flt, buf, sizeof buf, 0, &size);
mu_stream_read (flt, (char*) buf, sizeof buf, 0, &size);
mu_stream_destroy (&flt, NULL);
mu_stream_destroy (&str, NULL);
*pbuf = malloc (size);
......@@ -281,7 +281,7 @@ ident_decrypt (const char *file, const char *name)
gl_des_ctx ctx;
des_string_to_key (keybuf, sizeof (keybuf), key);
gl_des_setkey (&ctx, key);
gl_des_setkey (&ctx, (char*) key);
memcpy (id.chars, buf, size);
......@@ -469,9 +469,9 @@ int
imap4d_preauth_setup (int fd)
{
struct sockaddr clt_sa, *pclt_sa;
int clt_len = sizeof clt_sa;
socklen_t clt_len = sizeof clt_sa;
struct sockaddr srv_sa, *psrv_sa;
int srv_len = sizeof srv_sa;
socklen_t srv_len = sizeof srv_sa;
char *username = NULL;
if (getsockname (fd, &srv_sa, &srv_len) == -1)
......
......@@ -28,7 +28,7 @@ struct store_parse_closure
int type;
int isuid;
size_t *set;
size_t count;
int count;
};
static int
......
......@@ -54,7 +54,7 @@ extern int mu_scm_is_mailbox (SCM scm);
extern void mu_scm_message_init (void);
extern SCM mu_scm_message_create (SCM owner, mu_message_t msg);
extern int mu_scm_is_message (SCM scm);
extern const mu_message_t mu_scm_message_get (SCM MESG);
extern mu_message_t mu_scm_message_get (SCM MESG);
extern int mu_scm_is_body (SCM scm);
extern void mu_scm_body_init (void);
......
......@@ -19,6 +19,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include "cmdline.h"
static struct mu_cmdline_capa *all_cmdline_capa[] = {
......
......@@ -130,7 +130,7 @@ _mu_conn_setup (LDAP **pld)
/* if no host but a DN is provided, try DNS SRV to gather the
host list */
char *domain = NULL, *hostlist = NULL, **hosts = NULL;
size_t hostcnt;
int hostcnt;
int i;
int len_proto = strlen(lud->lud_scheme);
......@@ -319,8 +319,7 @@ _mu_ldap_bind (LDAP *ld)
|| refs)
{
/* FIXME: Use mu_debug_t for that */
mu_error ("ldap_bind: %s (%d)%s",
ldap_err2string (err), err, msgbuf ? msgbuf : "");
mu_error ("ldap_bind: %s (%d)%s", ldap_err2string (err), err, msgbuf);
if (matched && *matched)
mu_error ("matched DN: %s", matched);
......@@ -600,7 +599,7 @@ chk_md5 (const char *db_pass, const char *pass)
mu_stream_open (str);
mu_stream_sequential_write (str, db_pass, strlen (db_pass));
mu_stream_read (flt, d1, sizeof d1, 0, NULL);
mu_stream_read (flt, (char*) d1, sizeof d1, 0, NULL);
mu_stream_destroy (&flt, NULL);
mu_stream_destroy (&str, NULL);
......@@ -633,7 +632,7 @@ chk_smd5 (const char *db_pass, const char *pass)
return ENOMEM;
}
mu_stream_read (flt, d1, size, 0, &size);
mu_stream_read (flt, (char*) d1, size, 0, &size);
mu_stream_destroy (&flt, NULL);
mu_stream_destroy (&str, NULL);
......@@ -672,7 +671,7 @@ chk_sha (const char *db_pass, const char *pass)
mu_stream_open (str);
mu_stream_sequential_write (str, db_pass, strlen (db_pass));
mu_stream_read (flt, d1, sizeof d1, 0, NULL);
mu_stream_read (flt, (char*) d1, sizeof d1, 0, NULL);
mu_stream_destroy (&flt, NULL);
mu_stream_destroy (&str, NULL);
......@@ -705,7 +704,7 @@ chk_ssha (const char *db_pass, const char *pass)
return ENOMEM;
}
mu_stream_read (flt, d1, size, 0, &size);
mu_stream_read (flt, (char*) d1, size, 0, &size);
mu_stream_destroy (&flt, NULL);
mu_stream_destroy (&str, NULL);
......
......@@ -116,7 +116,7 @@ getpwnam_ip_virtual (const char *u)
{
struct sockaddr_in addr;
struct passwd *pw = NULL;
int len = sizeof (addr);
socklen_t len = sizeof (addr);
if (getsockname (0, (struct sockaddr *)&addr, &len) == 0)
{
......
......@@ -108,7 +108,7 @@ SCM_DEFINE (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0,
#define FUNC_NAME s_scm_mu_body_read_line
{
struct mu_body *mbp;
int n, nread;
size_t n, nread;
int status;
SCM_ASSERT (mu_scm_is_body (BODY), BODY, SCM_ARG1, FUNC_NAME);
......
......@@ -168,7 +168,7 @@ mu_scm_message_add_owner (SCM MESG, SCM owner)
mum->mbox = cell;
}
const mu_message_t
mu_message_t
mu_scm_message_get (SCM MESG)
{
struct mu_message *mum = (struct mu_message *) SCM_CDR (MESG);
......@@ -234,7 +234,7 @@ SCM_DEFINE (scm_mu_message_copy, "mu-message-copy", 1, 0, 0,
== 0
&& n != 0)
{
int wr;
size_t wr;
int rc;
rc = mu_stream_write (out, buffer, n, off, &wr);
......
......@@ -72,7 +72,7 @@ mu_scm_mime_create (SCM owner, mu_mime_t mime)
SCM_RETURN_NEWSMOB (mime_tag, mum);
}
const mu_mime_t
mu_mime_t
mu_scm_mime_get (SCM MIME)
{
struct mu_mime *mum = (struct mu_mime *) SCM_CDR (MIME);
......
......@@ -121,7 +121,8 @@ mu_port_flush (SCM port)
if (wrsize)
{
if (mu_stream_write (mp->stream, pt->write_buf, wrsize, mp->offset, &n))
if (mu_stream_write (mp->stream, (char*) pt->write_buf,
wrsize, mp->offset, &n))
return;
mp->offset += n;
}
......@@ -162,7 +163,7 @@ mu_port_fill_input (SCM port)
size_t nread = 0;
int status;
status = mu_stream_read (mp->stream, pt->read_buf, pt->read_buf_size,
status = mu_stream_read (mp->stream, (char*) pt->read_buf, pt->read_buf_size,
mp->offset, &nread);
if (status)
mu_scm_error ("mu_port_fill_input", status,
......
......@@ -632,7 +632,7 @@ smtp_starttls (smtp_t smtp)
}
static void
cram_md5 (char *secret, char *challenge, unsigned char *digest)
cram_md5 (char *secret, unsigned char *challenge, unsigned char *digest)
{
struct mu_md5_ctx context;
unsigned char ipad[64];
......@@ -645,7 +645,7 @@ cram_md5 (char *secret, char *challenge, unsigned char *digest)
return;
secret_len = strlen (secret);
challenge_len = strlen (challenge);
challenge_len = strlen ((char*) challenge);
memset (ipad, 0, sizeof (ipad));
memset (opad, 0, sizeof (opad));
......@@ -670,7 +670,7 @@ cram_md5 (char *secret, char *challenge, unsigned char *digest)
mu_md5_init_ctx (&context);
mu_md5_process_bytes (ipad, sizeof (ipad), &context);
mu_md5_process_bytes ((unsigned char *) challenge, challenge_len, &context);
mu_md5_process_bytes (challenge, challenge_len, &context);
mu_md5_finish_ctx (&context, digest);
mu_md5_init_ctx (&context);
......@@ -766,7 +766,7 @@ smtp_auth (smtp_t smtp)
p = strchr (smtp->buffer, ' ') + 1;
mu_rtrim_cset (p, "\r\n");
mu_base64_decode (p, strlen (p), &chl, &chlen);
mu_base64_decode ((unsigned char*) p, strlen (p), &chl, &chlen);
cram_md5 ((char *) mu_secret_password (secret), chl, digest);
mu_secret_password_unref (secret);
......@@ -777,7 +777,7 @@ smtp_auth (smtp_t smtp)
mu_asnprintf (&buf, &buflen, "%s %s", user, ascii_digest);
buflen = strlen (buf);
mu_base64_encode (buf, buflen, &b64buf, &b64buflen);
mu_base64_encode ((unsigned char*) buf, buflen, &b64buf, &b64buflen);
b64buf[b64buflen] = '\0';
free (buf);
......@@ -819,7 +819,7 @@ smtp_auth (smtp_t smtp)
if (buf[c] == '^')
buf[c] = '\0';
}
mu_base64_encode (buf, buflen, &b64buf, &b64buflen);
mu_base64_encode ((unsigned char*) buf, buflen, &b64buf, &b64buflen);
b64buf[b64buflen] = '\0';
free (buf);
......
......@@ -766,7 +766,7 @@ int
mu_acl_check_fd (mu_acl_t acl, int fd, mu_acl_result_t *pres)
{
struct sockaddr_in cs;
int len = sizeof cs;
socklen_t len = sizeof cs;
if (getpeername (fd, (struct sockaddr *) &cs, &len) < 0)
{
......
......@@ -55,7 +55,7 @@ mu_secret_create (mu_secret_t *psec, const char *value, size_t len)
return ENOMEM;
sec->obptr = (unsigned char*)(sec + 1);
sec->clptr = sec->obptr + len + 1;
obfuscate (value, sec->obptr, len);
obfuscate ((unsigned char *) value, sec->obptr, len);
sec->length = len;
*psec = sec;
mu_secret_ref (sec);
......
......@@ -268,7 +268,7 @@ pop3d_get_client_address (int fd, struct sockaddr_in *pcs)
}
else
{
int len = sizeof *pcs;
socklen_t len = sizeof *pcs;
if (getpeername (fd, (struct sockaddr*) pcs, &len) < 0)
{
mu_diag_output (MU_DIAG_ERROR,
......
......@@ -269,7 +269,8 @@ api_address_get_route (PyObject *self, PyObject *args)
static PyObject *
api_address_to_string (PyObject *self, PyObject *args)
{
int status, n;
int status;
size_t n;
char buf[256];
PyAddress *py_addr;
......
......@@ -160,7 +160,7 @@ odbc_query (mu_sql_connection_t conn, char *query)
return MU_ERR_SQL;
}
rc = SQLExecDirect (dp->stmt, query, SQL_NTS);
rc = SQLExecDirect (dp->stmt, (SQLCHAR*) query, SQL_NTS);
if (rc != SQL_SUCCESS)
{
mu_odbc_diag (dp, SQL_HANDLE_STMT, dp->stmt, "SQLExecDirect");
......@@ -305,7 +305,7 @@ odbc_get_field_number (mu_sql_connection_t conn, const char *fname,
dp->fnames[i] = name;
ret = SQLDescribeCol (dp->stmt,
i + 1,
name,
(SQLCHAR*) name,
namelen + 1,
&namelen,
NULL,
......@@ -340,7 +340,7 @@ static const char *
odbc_errstr (mu_sql_connection_t conn)
{
struct mu_odbc_data *dp = conn->data;
char state[16];
SQLCHAR state[16];
char nbuf[64];
SQLINTEGER nerror;
SQLSMALLINT msglen;
......@@ -365,14 +365,14 @@ odbc_errstr (mu_sql_connection_t conn)
snprintf (nbuf, sizeof nbuf, "%d", (int) nerror);
length = strlen (dp->err.what) + 1
+ strlen (state) + 1
+ strlen ((char*) state) + 1
+ strlen (nbuf) + 1
+ strlen (dp->err.msg) + 1;
+ strlen ((char*) dp->err.msg) + 1;
if (dp->err.text)
free (dp->err.text);
dp->err.text = malloc (length);
if (!dp->err.text)
return dp->err.msg;
return (char*) dp->err.msg;
snprintf (dp->err.text, length, "%s %s %s %s", dp->err.what, state, nbuf,
dp->err.msg);
......