[gmime: 1/27] clean up warnings in tests and examples
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime: 1/27] clean up warnings in tests and examples
- Date: Thu, 23 Nov 2017 15:43:59 +0000 (UTC)
commit 6dca4b48ddc33172d1235ce8c2a7fa8e16b4a8be
Author: Daniel Kahn Gillmor <dkg fifthhorseman net>
Date: Sun Nov 5 10:42:33 2017 +0100
clean up warnings in tests and examples
examples/basic-example.c | 23 ++---------------------
examples/imap-example.c | 1 -
tests/test-autocrypt.c | 5 +++--
tests/test-cat.c | 2 +-
tests/test-headers.c | 7 +------
tests/test-mbox.c | 8 ++++----
tests/test-mime.c | 6 +++---
tests/test-partial.c | 1 -
tests/test-pgpmime.c | 3 ---
tests/test-pkcs7.c | 1 -
tests/test-streams.c | 5 ++---
tests/testsuite.c | 7 +++++--
12 files changed, 21 insertions(+), 48 deletions(-)
---
diff --git a/examples/basic-example.c b/examples/basic-example.c
index 87f8649..d34785c 100644
--- a/examples/basic-example.c
+++ b/examples/basic-example.c
@@ -34,22 +34,6 @@
#include <fcntl.h>
#include <errno.h>
-#ifndef G_OS_WIN32
-static const char *passphrase = "no.secret";
-
-static gboolean
-request_passwd (GMimeCryptoContext *ctx, const char *user_id, const char *prompt_ctx, gboolean reprompt,
GMimeStream *response, GError **err)
-{
- if (g_mime_stream_write_string (response, passphrase) == -1 ||
- g_mime_stream_write (response, "\n", 1) == -1) {
- g_set_error (err, GMIME_ERROR, errno, "%s", g_strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
-#endif /* ! G_OS_WIN32 */
-
static GMimeMessage *
parse_message (int fd)
{
@@ -135,6 +119,7 @@ count_parts_in_message (GMimeMessage *message)
}
#ifndef G_OS_WIN32
+#ifdef ENABLE_CRYPTOGRAPHY
static void
verify_foreach_callback (GMimeObject *parent, GMimeObject *part, gpointer user_data)
{
@@ -181,6 +166,7 @@ verify_signed_parts (GMimeMessage *message)
g_mime_message_foreach (message, verify_foreach_callback, NULL);
}
#endif
+#endif
static void
write_message_to_screen (GMimeMessage *message)
@@ -207,9 +193,7 @@ static void
add_a_mime_part (GMimeMessage *message)
{
GMimeMultipart *multipart;
- GMimeDataWrapper *content;
GMimeTextPart *mime_part;
- GMimeStream *stream;
/* create the new part that we are going to add... */
mime_part = g_mime_text_part_new_with_subtype ("plain");
@@ -261,9 +245,6 @@ remove_a_mime_part (GMimeMessage *message)
int main (int argc, char **argv)
{
-#ifndef G_OS_WIN32
- GMimeCryptoContext *ctx;
-#endif
GMimeMessage *message;
int fd;
diff --git a/examples/imap-example.c b/examples/imap-example.c
index 711b7c7..353291f 100644
--- a/examples/imap-example.c
+++ b/examples/imap-example.c
@@ -437,7 +437,6 @@ decode_qstring (unsigned char **in, unsigned char *inend)
static gboolean
decode_param (unsigned char **in, unsigned char *inend, char **name, char **value)
{
- GMimeParam *param;
char *n, *v;
if (!(n = decode_qstring (in, inend)))
diff --git a/tests/test-autocrypt.c b/tests/test-autocrypt.c
index bc72ae0..900d1b6 100644
--- a/tests/test-autocrypt.c
+++ b/tests/test-autocrypt.c
@@ -53,7 +53,7 @@ _gen_header (const struct _ah_gen_test *t)
return NULL;
}
if (t->keydatacount)
- if (!(keydata = g_byte_array_new_take (g_strnfill (t->keydatacount, t->keybyte),
t->keydatacount))) {
+ if (!(keydata = g_byte_array_new_take ((guint8*) g_strnfill (t->keydatacount, t->keybyte),
t->keydatacount))) {
fprintf (stderr, "failed to make a new keydata");
g_object_unref (ah);
return NULL;
@@ -345,7 +345,8 @@ _acheaderlists_compare (GMimeAutocryptHeaderList *expected, GMimeAutocryptHeader
char *e = g_mime_autocrypt_header_get_string (ahe);
char *g = g_mime_autocrypt_header_get_string (ahg);
char *ret = g_strdup_printf ("comparing <%s> got cmp = %d \nexpected:
\n%s\n\ngot:\n%s\n",
- g_mime_autocrypt_header_get_address (ahe), cmp, e, g);
+ internet_address_mailbox_get_idn_addr
(g_mime_autocrypt_header_get_address (ahe)),
+ cmp, e, g);
g_free(e);
g_free(g);
return ret;
diff --git a/tests/test-cat.c b/tests/test-cat.c
index 26fc8df..a329321 100644
--- a/tests/test-cat.c
+++ b/tests/test-cat.c
@@ -84,7 +84,7 @@ randf (void)
static GMimeStream *
random_whole_stream (const char *datadir, char **filename)
{
- size_t nwritten, buflen, total = 0, size, i;
+ size_t nwritten, buflen, total = 0, size;
GMimeStream *stream;
char buf[4096];
ssize_t n;
diff --git a/tests/test-headers.c b/tests/test-headers.c
index 07a7413..8116f3b 100644
--- a/tests/test-headers.c
+++ b/tests/test-headers.c
@@ -71,13 +71,11 @@ test_indexing (void)
const char *name, *value, *raw_value;
GMimeHeaderList *list;
GMimeHeader *header;
- int index, count;
+ int index;
size_t len;
list = header_list_new ();
- count = g_mime_header_list_get_count (list);
-
/* make sure indexing works as expected */
for (index = 0; index < G_N_ELEMENTS (initial); index++) {
testsuite_check ("headers[%d]", index);
@@ -124,7 +122,6 @@ test_remove (void)
const char *name, *value;
GMimeHeaderList *list;
GMimeHeader *header;
- guint i;
list = header_list_new ();
@@ -181,7 +178,6 @@ test_remove_at (void)
GMimeHeaderList *list;
GMimeHeader *header;
int count;
- guint i;
list = header_list_new ();
@@ -420,7 +416,6 @@ test_address_sync (void)
InternetAddress *addr, *ia;
InternetAddressList *list;
GMimeHeaderList *headers;
- GMimeParamList *params;
GMimeMessage *message;
GMimeObject *object;
GMimeHeader *header;
diff --git a/tests/test-mbox.c b/tests/test-mbox.c
index 9ba8a88..74d0b1a 100644
--- a/tests/test-mbox.c
+++ b/tests/test-mbox.c
@@ -102,7 +102,7 @@ xevcb (GMimeParser *parser, const char *header, const char *value, gint64 offset
static void
test_parser (GMimeParser *parser, GMimeStream *mbox, GMimeStream *summary)
{
- gint64 message_begin, message_end, headers_begin, headers_end, marker_offset;
+ gint64 message_begin, message_end, headers_begin, headers_end;
GMimeFormatOptions *format = g_mime_format_options_get_default ();
InternetAddressList *list;
GMimeMessage *message;
@@ -127,7 +127,6 @@ test_parser (GMimeParser *parser, GMimeStream *mbox, GMimeStream *summary)
g_mime_stream_printf (summary, "header offsets: %" G_GINT64_FORMAT ", %" G_GINT64_FORMAT "\n",
headers_begin, headers_end);
- marker_offset = g_mime_parser_get_mbox_marker_offset (parser);
marker = g_mime_parser_get_mbox_marker (parser);
g_mime_stream_printf (summary, "%s\n", marker);
@@ -282,9 +281,10 @@ int main (int argc, char **argv)
const char *path;
struct stat st;
GDir *dir;
- int fd, i;
-
+ int i;
#ifdef ENABLE_MBOX_MATCH
+ int fd;
+
if (mkdir ("./tmp", 0755) == -1 && errno != EEXIST)
return 0;
#endif
diff --git a/tests/test-mime.c b/tests/test-mime.c
index 4ad1329..f770e3b 100644
--- a/tests/test-mime.c
+++ b/tests/test-mime.c
@@ -348,7 +348,7 @@ static void
test_date_parser (void)
{
GDateTime *date;
- Exception *ex;
+ Exception *newex;
int tz_offset;
GTimeSpan tz;
time_t time;
@@ -384,9 +384,9 @@ test_date_parser (void)
buf = g_mime_utils_header_format_date (date);
if (strcmp (dates[i].out, buf) != 0) {
- ex = exception_new ("date strings do not match: %s vs %s", buf, dates[i].out);
+ newex = exception_new ("date strings do not match: %s vs %s", buf,
dates[i].out);
g_free (buf);
- throw (ex);
+ throw (newex);
}
g_free (buf);
diff --git a/tests/test-partial.c b/tests/test-partial.c
index f9f6036..c9118c8 100644
--- a/tests/test-partial.c
+++ b/tests/test-partial.c
@@ -142,7 +142,6 @@ int main (int argc, char **argv)
int inlen, outlen;
GDir *data, *dir;
const char *dent;
- struct stat st;
size_t i, n;
char *path;
diff --git a/tests/test-pgpmime.c b/tests/test-pgpmime.c
index 236337b..5668b4c 100644
--- a/tests/test-pgpmime.c
+++ b/tests/test-pgpmime.c
@@ -350,14 +350,12 @@ test_multipart_encrypted (GMimeCryptoContext *ctx, gboolean sign,
GMimeStream *test_stream;
GMimeMultipartEncrypted *mpe;
GMimeDecryptResult *result;
- GMimeDataWrapper *content;
GMimeObject *decrypted;
GMimeMessage *message;
Exception *ex = NULL;
GMimeParser *parser;
GByteArray *buf[2];
GError *err = NULL;
- GMimePart *part;
char *ret = NULL;
g_mime_stream_reset (stream);
@@ -615,7 +613,6 @@ int main (int argc, char *argv[])
const char *datadir = "data/pgpmime";
char *session_key = NULL;
GMimeCryptoContext *ctx;
- GError *err = NULL;
char *gpg, *key;
struct stat st;
int i;
diff --git a/tests/test-pkcs7.c b/tests/test-pkcs7.c
index 231c959..93f8e24 100644
--- a/tests/test-pkcs7.c
+++ b/tests/test-pkcs7.c
@@ -227,7 +227,6 @@ static void
test_export (GMimeCryptoContext *ctx, const char *path)
{
GMimeStream *istream, *ostream;
- register const char *inptr;
const char *inbuf, *outbuf;
size_t inlen, outlen;
Exception *ex = NULL;
diff --git a/tests/test-streams.c b/tests/test-streams.c
index d9a725e..aab86ed 100644
--- a/tests/test-streams.c
+++ b/tests/test-streams.c
@@ -144,7 +144,6 @@ static void
test_stream_gets (GMimeStream *stream, const char *filename)
{
char sbuf[100], rbuf[100];
- ssize_t slen;
FILE *fp;
/* '0x1a' character is treated as EOF (Ctrl+Z) on Windows if file is opened in text mode,
@@ -155,7 +154,7 @@ test_stream_gets (GMimeStream *stream, const char *filename)
while (!g_mime_stream_eos (stream)) {
rbuf[0] = '\0';
- slen = g_mime_stream_buffer_gets (stream, sbuf, sizeof (sbuf));
+ g_mime_stream_buffer_gets (stream, sbuf, sizeof (sbuf));
if (!fgets (rbuf, sizeof (rbuf), fp))
break;
@@ -488,7 +487,7 @@ test_streams (GDir *dir, const char *datadir, const char *filename)
static size_t
gen_random_stream (int randfd, GMimeStream *stream)
{
- size_t nwritten, buflen, total = 0, size, i;
+ size_t nwritten, buflen, total = 0, size;
char buf[4096];
ssize_t n;
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 1655a73..cd1580c 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -423,11 +423,14 @@ testsuite_can_safely_override_session_key (const char *gpg)
int
testsuite_setup_gpghome (const char *gpg)
{
+ char *command;
+ FILE *fp;
+#if DEBUG_GNUPG
const char *files[] = { "./tmp/.gnupg/gpg.conf", "./tmp/.gnupg/gpgsm.conf",
"./tmp/.gnupg/gpg-agent.conf", "./tmp/.gnupg/dirmngr.conf", NULL };
const char debug[] = "log-file socket://%s/tmp/.gnupg/S.log\ndebug 1024\nverbose\n";
- char *command, *cwd;
- FILE *fp;
int i;
+ char *cwd;
+#endif
/* reset .gnupg config directory */
if (system ("/bin/rm -rf ./tmp") != 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]