From 3ab798412da7dbfc26af43a06e92c13a7b9abf43 Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 7 May 2011 10:57:19 +0000 Subject: [PATCH] Fixes (mostly from Colin Watson, a couple redone by me) to make Unix 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 | 46 ++++++++++++++++++++++++++++++++++------------ minibidi.c | 9 +++------ ssh.c | 5 ++--- terminal.c | 8 +------- unix/gtkwin.c | 44 ++++++++++++++++++++++++++++++-------------- unix/uxplink.c | 3 +-- unix/uxser.c | 6 ++---- 7 files changed, 73 insertions(+), 48 deletions(-) diff --git a/cmdgen.c b/cmdgen.c index ae405208..9911db15 100644 --- 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; * } */ diff --git a/minibidi.c b/minibidi.c index b211dc85..c0197a5e 100644 --- a/minibidi.c +++ b/minibidi.c @@ -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 95fa2f2c..c3c3f117 100644 --- 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); diff --git a/terminal.c b/terminal.c index 0ba3060d..73ab393e 100644 --- a/terminal.c +++ b/terminal.c @@ -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, "", (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) { diff --git a/unix/gtkwin.c b/unix/gtkwin.c index e4af6280..be8b2c3b 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -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); diff --git a/unix/uxplink.c b/unix/uxplink.c index 55d1663d..d76bbcaa 100644 --- a/unix/uxplink.c +++ b/unix/uxplink.c @@ -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; diff --git a/unix/uxser.c b/unix/uxser.c index 59f8aa74..2155b924 100644 --- a/unix/uxser.c +++ b/unix/uxser.c @@ -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) -- 2.11.0