Patch from Colin Watson intended to give a clean Unix compile with GCC 4.
authorjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Sat, 30 Dec 2006 23:00:14 +0000 (23:00 +0000)
committerjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Sat, 30 Dec 2006 23:00:14 +0000 (23:00 +0000)
(Since we choose to compile with -Werror, this is particularly important.)

I haven't yet checked that the resulting source actually compiles cleanly with
GCC 4, hence not marking `gcc4-warnings' as fixed just yet.

git-svn-id: svn://svn.tartarus.org/sgt/putty@7041 cda61777-01e9-0310-a592-d414129be87e

cmdgen.c
misc.c
ssh.c
ssh.h
sshpubk.c
sshzlib.c
tree234.c
unix/gtkdlg.c
unix/gtkwin.c

index 763d05e..dfca9dc 100644 (file)
--- a/cmdgen.c
+++ b/cmdgen.c
@@ -233,7 +233,7 @@ static int move(char *from, char *to)
     return TRUE;
 }
 
-static char *blobfp(char *alg, int bits, char *blob, int bloblen)
+static char *blobfp(char *alg, int bits, unsigned char *blob, int bloblen)
 {
     char buffer[128];
     unsigned char digest[16];
@@ -270,7 +270,8 @@ int main(int argc, char **argv)
     int sshver = 0;
     struct ssh2_userkey *ssh2key = NULL;
     struct RSAKey *ssh1key = NULL;
-    char *ssh2blob = NULL, *ssh2alg = NULL;
+    unsigned char *ssh2blob = NULL;
+    char *ssh2alg = NULL;
     const struct ssh_signkey *ssh2algf = NULL;
     int ssh2bloblen;
     char *passphrase = NULL;
@@ -715,12 +716,12 @@ int main(int argc, char **argv)
            ssh1key = snew(struct RSAKey);
            if (!load_encrypted) {
                void *vblob;
-               char *blob;
+               unsigned char *blob;
                int n, l, bloblen;
 
                ret = rsakey_pubblob(&infilename, &vblob, &bloblen,
                                     &origcomment, &error);
-               blob = (char *)vblob;
+               blob = (unsigned char *)vblob;
 
                n = 4;                 /* skip modulus bits */
                
diff --git a/misc.c b/misc.c
index 3a27572..fbfc34f 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -102,7 +102,7 @@ prompts_t *new_prompts(void *frontend)
 void add_prompt(prompts_t *p, char *promptstr, int echo, size_t len)
 {
     prompt_t *pr = snew(prompt_t);
-    unsigned char *result = snewn(len, unsigned char);
+    char *result = snewn(len, char);
     pr->prompt = promptstr;
     pr->echo = echo;
     pr->result = result;
diff --git a/ssh.c b/ssh.c
index fc75e91..eed4e64 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -1489,6 +1489,7 @@ static struct Packet *construct_packet(Ssh ssh, int pkttype, va_list ap)
 
     while ((argtype = va_arg(ap, int)) != PKT_END) {
        unsigned char *argp, argchar;
+       char *sargp;
        unsigned long argint;
        int arglen;
        switch (argtype) {
@@ -1507,8 +1508,8 @@ static struct Packet *construct_packet(Ssh ssh, int pkttype, va_list ap)
            ssh_pkt_adddata(pkt, argp, arglen);
            break;
          case PKT_STR:
-           argp = va_arg(ap, unsigned char *);
-           ssh_pkt_addstring(pkt, argp);
+           sargp = va_arg(ap, char *);
+           ssh_pkt_addstring(pkt, sargp);
            break;
          case PKT_BIGNUM:
            bn = va_arg(ap, Bignum);
@@ -1654,7 +1655,7 @@ static void ssh_pkt_addstring(struct Packet *pkt, char *data)
 static void ssh1_pkt_addmp(struct Packet *pkt, Bignum b)
 {
     int len = ssh1_bignum_length(b);
-    unsigned char *data = snewn(len, char);
+    unsigned char *data = snewn(len, unsigned char);
     (void) ssh1_write_bignum(data, b);
     ssh_pkt_adddata(pkt, data, len);
     sfree(data);
diff --git a/ssh.h b/ssh.h
index e45c653..fede996 100644 (file)
--- a/ssh.h
+++ b/ssh.h
@@ -403,9 +403,9 @@ extern struct ssh2_userkey ssh2_wrong_passphrase;
 int ssh2_userkey_encrypted(const Filename *filename, char **comment);
 struct ssh2_userkey *ssh2_load_userkey(const Filename *filename,
                                       char *passphrase, const char **errorstr);
-char *ssh2_userkey_loadpub(const Filename *filename, char **algorithm,
-                          int *pub_blob_len, char **commentptr,
-                          const char **errorstr);
+unsigned char *ssh2_userkey_loadpub(const Filename *filename, char **algorithm,
+                                   int *pub_blob_len, char **commentptr,
+                                   const char **errorstr);
 int ssh2_save_userkey(const Filename *filename, struct ssh2_userkey *key,
                      char *passphrase);
 const struct ssh_signkey *find_pubkey_alg(const char *name);
index 812a8e9..79b224c 100644 (file)
--- a/sshpubk.c
+++ b/sshpubk.c
@@ -868,9 +868,9 @@ struct ssh2_userkey *ssh2_load_userkey(const Filename *filename,
     return ret;
 }
 
-char *ssh2_userkey_loadpub(const Filename *filename, char **algorithm,
-                          int *pub_blob_len, char **commentptr,
-                          const char **errorstr)
+unsigned char *ssh2_userkey_loadpub(const Filename *filename, char **algorithm,
+                                   int *pub_blob_len, char **commentptr,
+                                   const char **errorstr)
 {
     FILE *fp;
     char header[40], *b;
@@ -940,7 +940,7 @@ char *ssh2_userkey_loadpub(const Filename *filename, char **algorithm,
        *pub_blob_len = public_blob_len;
     if (algorithm)
        *algorithm = alg->name;
-    return (char *)public_blob;
+    return public_blob;
 
     /*
      * Error processing.
index 94f0b80..9c80132 100644 (file)
--- a/sshzlib.c
+++ b/sshzlib.c
@@ -224,6 +224,7 @@ static void lz77_compress(struct LZ77Context *ctx,
     }
     st->npending -= i;
 
+    defermatch.distance = 0; /* appease compiler */
     defermatch.len = 0;
     deferchr = '\0';
     while (len > 0) {
index b5895d0..84e8c18 100644 (file)
--- a/tree234.c
+++ b/tree234.c
@@ -136,6 +136,7 @@ static void *add234_internal(tree234 * t, void *e, int index)
        return orig_e;
     }
 
+    n = NULL; /* placate gcc; will always be set below since t->root != NULL */
     np = &t->root;
     while (*np) {
        int childnum;
index 0847431..b7947b5 100644 (file)
@@ -2696,7 +2696,7 @@ void eventlog_selection_get(GtkWidget *widget, GtkSelectionData *seldata,
     struct eventlog_stuff *es = (struct eventlog_stuff *)data;
 
     gtk_selection_data_set(seldata, seldata->target, 8,
-                           es->seldata, es->sellen);
+                           (unsigned char *)es->seldata, es->sellen);
 }
 
 gint eventlog_selection_clear(GtkWidget *widget, GdkEventSelection *seldata,
index 5aeeaf0..c4c255a 100644 (file)
@@ -1466,22 +1466,23 @@ void palette_reset(void *frontend)
  */
 void init_cutbuffers()
 {
+    unsigned char empty[] = "";
     XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
-                   XA_CUT_BUFFER0, XA_STRING, 8, PropModeAppend, "", 0);
+                   XA_CUT_BUFFER0, XA_STRING, 8, PropModeAppend, empty, 0);
     XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
-                   XA_CUT_BUFFER1, XA_STRING, 8, PropModeAppend, "", 0);
+                   XA_CUT_BUFFER1, XA_STRING, 8, PropModeAppend, empty, 0);
     XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
-                   XA_CUT_BUFFER2, XA_STRING, 8, PropModeAppend, "", 0);
+                   XA_CUT_BUFFER2, XA_STRING, 8, PropModeAppend, empty, 0);
     XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
-                   XA_CUT_BUFFER3, XA_STRING, 8, PropModeAppend, "", 0);
+                   XA_CUT_BUFFER3, XA_STRING, 8, PropModeAppend, empty, 0);
     XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
-                   XA_CUT_BUFFER4, XA_STRING, 8, PropModeAppend, "", 0);
+                   XA_CUT_BUFFER4, XA_STRING, 8, PropModeAppend, empty, 0);
     XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
-                   XA_CUT_BUFFER5, XA_STRING, 8, PropModeAppend, "", 0);
+                   XA_CUT_BUFFER5, XA_STRING, 8, PropModeAppend, empty, 0);
     XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
-                   XA_CUT_BUFFER6, XA_STRING, 8, PropModeAppend, "", 0);
+                   XA_CUT_BUFFER6, XA_STRING, 8, PropModeAppend, empty, 0);
     XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
-                   XA_CUT_BUFFER7, XA_STRING, 8, PropModeAppend, "", 0);
+                   XA_CUT_BUFFER7, XA_STRING, 8, PropModeAppend, empty, 0);
 }
 
 /* Store the data in a cut-buffer. */
@@ -1601,15 +1602,16 @@ void selection_get(GtkWidget *widget, GtkSelectionData *seldata,
     struct gui_data *inst = (struct gui_data *)data;
     if (seldata->target == utf8_string_atom)
        gtk_selection_data_set(seldata, seldata->target, 8,
-                              inst->pasteout_data_utf8,
+                              (unsigned char *)inst->pasteout_data_utf8,
                               inst->pasteout_data_utf8_len);
     else if (seldata->target == compound_text_atom)
        gtk_selection_data_set(seldata, seldata->target, 8,
-                              inst->pasteout_data_ctext,
+                              (unsigned char *)inst->pasteout_data_ctext,
                               inst->pasteout_data_ctext_len);
     else
        gtk_selection_data_set(seldata, seldata->target, 8,
-                              inst->pasteout_data, inst->pasteout_data_len);
+                              (unsigned char *)inst->pasteout_data,
+                              inst->pasteout_data_len);
 }
 
 gint selection_clear(GtkWidget *widget, GdkEventSelection *seldata,
@@ -2488,15 +2490,16 @@ int do_cmdline(int argc, char **argv, int do_everything,
            cfg->line_codepage[sizeof(cfg->line_codepage)-1] = '\0';
 
        } else if (!strcmp(p, "-geometry")) {
-           int flags, x, y, w, h;
+           int flags, x, y;
+           unsigned int w, h;
            EXPECTS_ARG;
            SECOND_PASS_ONLY;
 
            flags = XParseGeometry(val, &x, &y, &w, &h);
            if (flags & WidthValue)
-               cfg->width = w;
+               cfg->width = (int)w;
            if (flags & HeightValue)
-               cfg->height = h;
+               cfg->height = (int)h;
 
             if (flags & (XValue | YValue)) {
                 inst->xpos = x;