Fixes (mostly from Colin Watson, a couple redone by me) to make Unix
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 7 May 2011 10:57:19 +0000 (10:57 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 7 May 2011 10:57:19 +0000 (10:57 +0000)
PuTTY compile cleanly under gcc 4.6.0 without triggering any of its
new warnings.

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

cmdgen.c
minibidi.c
ssh.c
terminal.c
unix/gtkwin.c
unix/uxplink.c
unix/uxser.c

index ae40520..9911db1 100644 (file)
--- a/cmdgen.c
+++ b/cmdgen.c
@@ -316,25 +316,47 @@ int main(int argc, char **argv)
                            *p++ = '\0';
                            val = p;
                        } else
-                           val = NULL;
+                            val = NULL;
+
                        if (!strcmp(opt, "-help")) {
-                           help();
-                           nogo = TRUE;
+                            if (val) {
+                                errs = TRUE;
+                                fprintf(stderr, "puttygen: option `-%s'"
+                                        " expects no argument\n", opt);
+                            } else {
+                                help();
+                                nogo = TRUE;
+                            }
                        } else if (!strcmp(opt, "-version")) {
-                           showversion();
-                           nogo = TRUE;
+                            if (val) {
+                                errs = TRUE;
+                                fprintf(stderr, "puttygen: option `-%s'"
+                                        " expects no argument\n", opt);
+                            } else {
+                                showversion();
+                                nogo = TRUE;
+                            }
                        } else if (!strcmp(opt, "-pgpfp")) {
-                            /* support "-pgpfp" for consistency with others */
-                            pgp_fingerprints();
-                            nogo = TRUE;
+                            if (val) {
+                                errs = TRUE;
+                                fprintf(stderr, "puttygen: option `-%s'"
+                                        " expects no argument\n", opt);
+                            } else {
+                                /* support --pgpfp for consistency */
+                                pgp_fingerprints();
+                                nogo = TRUE;
+                            }
                         }
                        /*
-                        * A sample option requiring an argument:
+                        * For long options requiring an argument, add
+                        * code along the lines of
                         * 
                         * else if (!strcmp(opt, "-output")) {
-                        *     if (!val)
-                        *         errs = TRUE, error(err_optnoarg, opt);
-                        *     else
+                        *     if (!val) {
+                        *         errs = TRUE;
+                         *         fprintf(stderr, "puttygen: option `-%s'"
+                         *                 " expects an argument\n", opt);
+                        *     } else
                         *         ofile = val;
                         * }
                         */
index b211dc8..c0197a5 100644 (file)
@@ -1194,7 +1194,7 @@ int do_bidi(bidi_char *line, int count)
     unsigned char currentEmbedding;
     unsigned char currentOverride;
     unsigned char tempType;
-    int i, j, imax, yes, bover;
+    int i, j, yes, bover;
 
     /* Check the presence of R or AL types as optimization */
     yes = 0;
@@ -1604,17 +1604,14 @@ int do_bidi(bidi_char *line, int count)
      * level or higher
      */
     /* we flip the character string and leave the level array */
-    imax = 0;
     i=0;
     tempType = levels[0];
     while (i < count) {
-       if (levels[i] > tempType) {
+       if (levels[i] > tempType)
            tempType = levels[i];
-           imax=i;
-       }
        i++;
     }
-    /* maximum level in tempType, its index in imax. */
+    /* maximum level in tempType. */
     while (tempType > 0) {     /* loop from highest level to the least odd, */
         /* which i assume is 1 */
        flipThisRun(line, levels, tempType, count);
diff --git a/ssh.c b/ssh.c
index 95fa2f2..c3c3f11 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -9131,10 +9131,9 @@ static void ssh2_msg_debug(Ssh ssh, struct Packet *pktin)
     /* log the debug message */
     char *msg;
     int msglen;
-    int always_display;
 
-    /* XXX maybe we should actually take notice of this */
-    always_display = ssh2_pkt_getbool(pktin);
+    /* XXX maybe we should actually take notice of the return value */
+    ssh2_pkt_getbool(pktin);
     ssh_pkt_getstring(pktin, &msg, &msglen);
 
     logeventf(ssh, "Remote debug message: %.*s", msglen, msg);
index 0ba3060..73ab393 100644 (file)
@@ -4775,7 +4775,6 @@ static void do_paint(Terminal *term, Context ctx, int may_optimise)
        termchar *lchars;
        int dirty_line, dirty_run, selected;
        unsigned long attr = 0, cset = 0;
-       int updated_line = 0;
        int start = 0;
        int ccount = 0;
        int last_run_dirty = 0;
@@ -4973,8 +4972,6 @@ static void do_paint(Terminal *term, Context ctx, int may_optimise)
                    if (attr & (TATTR_ACTCURS | TATTR_PASCURS))
                        do_cursor(ctx, start, i, ch, ccount, attr,
                                  ldata->lattr);
-
-                   updated_line = 1;
                }
                start = j;
                ccount = 0;
@@ -5059,8 +5056,6 @@ static void do_paint(Terminal *term, Context ctx, int may_optimise)
            if (attr & (TATTR_ACTCURS | TATTR_PASCURS))
                do_cursor(ctx, start, i, ch, ccount, attr,
                          ldata->lattr);
-
-           updated_line = 1;
        }
 
        unlineptr(ldata);
@@ -5256,7 +5251,7 @@ static void clipme(Terminal *term, pos top, pos bottom, int rect, int desel)
            sprintf(cbuf, "<U+%04x>", (ldata[top.x] & 0xFFFF));
 #else
            wchar_t cbuf[16], *p;
-           int set, c;
+           int c;
            int x = top.x;
 
            if (ldata->chars[x].chr == UCSWIDE) {
@@ -5290,7 +5285,6 @@ static void clipme(Terminal *term, pos top, pos bottom, int rect, int desel)
                    break;
                }
 
-               set = (uc & CSET_MASK);
                c = (uc & ~CSET_MASK);
 #ifdef PLATFORM_IS_UTF16
                if (uc > 0x10000 && uc < 0x110000) {
index e4af628..be8b2c3 100644 (file)
@@ -3540,15 +3540,29 @@ int pt_main(int argc, char **argv)
 
        inst->menu = gtk_menu_new();
 
-#define MKMENUITEM(title, func) do { \
-    menuitem = title ? gtk_menu_item_new_with_label(title) : \
-    gtk_menu_item_new(); \
-    gtk_container_add(GTK_CONTAINER(inst->menu), menuitem); \
-    gtk_widget_show(menuitem); \
-    if (func != NULL) \
-       gtk_signal_connect(GTK_OBJECT(menuitem), "activate", \
-                              GTK_SIGNAL_FUNC(func), inst); \
-} while (0)
+#define MKMENUITEM(title, func) do                                      \
+        {                                                               \
+            menuitem = gtk_menu_item_new_with_label(title);             \
+            gtk_container_add(GTK_CONTAINER(inst->menu), menuitem);     \
+            gtk_widget_show(menuitem);                                  \
+            gtk_signal_connect(GTK_OBJECT(menuitem), "activate",        \
+                               GTK_SIGNAL_FUNC(func), inst);            \
+        } while (0)
+
+#define MKSUBMENU(title) do                                             \
+        {                                                               \
+            menuitem = gtk_menu_item_new_with_label(title);             \
+            gtk_container_add(GTK_CONTAINER(inst->menu), menuitem);     \
+            gtk_widget_show(menuitem);                                  \
+        } while (0)
+
+#define MKSEP() do                                                      \
+        {                                                               \
+            menuitem = gtk_menu_item_new();                             \
+            gtk_container_add(GTK_CONTAINER(inst->menu), menuitem);     \
+            gtk_widget_show(menuitem);                                  \
+        } while (0)
+
        if (new_session)
            MKMENUITEM("New Session...", new_session_menuitem);
         MKMENUITEM("Restart Session", restart_session_menuitem);
@@ -3563,27 +3577,29 @@ int pt_main(int argc, char **argv)
            gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem),
                                      inst->sessionsmenu);
        }
-       MKMENUITEM(NULL, NULL);
+       MKSEP();
         MKMENUITEM("Change Settings...", change_settings_menuitem);
-       MKMENUITEM(NULL, NULL);
+       MKSEP();
        if (use_event_log)
            MKMENUITEM("Event Log", event_log_menuitem);
-       MKMENUITEM("Special Commands", NULL);
+       MKSUBMENU("Special Commands");
        inst->specialsmenu = gtk_menu_new();
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), inst->specialsmenu);
        inst->specialsitem1 = menuitem;
-       MKMENUITEM(NULL, NULL);
+       MKSEP();
        inst->specialsitem2 = menuitem;
        gtk_widget_hide(inst->specialsitem1);
        gtk_widget_hide(inst->specialsitem2);
        MKMENUITEM("Clear Scrollback", clear_scrollback_menuitem);
        MKMENUITEM("Reset Terminal", reset_terminal_menuitem);
        MKMENUITEM("Copy All", copy_all_menuitem);
-       MKMENUITEM(NULL, NULL);
+       MKSEP();
        s = dupcat("About ", appname, NULL);
        MKMENUITEM(s, about_menuitem);
        sfree(s);
 #undef MKMENUITEM
+#undef MKSUBMENU
+#undef MKSEP
     }
 
     inst->textcursor = make_mouse_ptr(inst, GDK_XTERM);
index 55d1663..d76bbca 100644 (file)
@@ -588,7 +588,6 @@ int main(int argc, char **argv)
     int errors;
     int use_subsystem = 0;
     int got_host = FALSE;
-    void *ldisc;
     long now;
 
     fdlist = NULL;
@@ -901,7 +900,7 @@ int main(int argc, char **argv)
            return 1;
        }
        back->provide_logctx(backhandle, logctx);
-       ldisc = ldisc_create(&cfg, NULL, back, backhandle, NULL);
+       ldisc_create(&cfg, NULL, back, backhandle, NULL);
        sfree(realhost);
     }
     connopen = 1;
index 59f8aa7..2155b92 100644 (file)
@@ -352,13 +352,11 @@ static void serial_free(void *handle)
 static void serial_reconfig(void *handle, Config *cfg)
 {
     Serial serial = (Serial) handle;
-    const char *err;
-
-    err = serial_configure(serial, cfg);
 
     /*
-     * FIXME: what should we do if err returns something?
+     * FIXME: what should we do if this returns an error?
      */
+    serial_configure(serial, cfg);
 }
 
 static int serial_select_result(int fd, int event)