From: Thomas E. Dickey Date: Sun, 22 May 2011 00:54:42 +0000 (+0000) Subject: ncurses 5.9 - patch 20110521 X-Git-Tag: v6.0~204 X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=commitdiff_plain;h=c120fddebe9e9c1e2b29dbd744a6b1d03652bf8b ncurses 5.9 - patch 20110521 + fix warnings from clang 2.7 "--analyze" --- diff --git a/NEWS b/NEWS index 7b2b35e9..ce060b4b 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.1703 2011/05/14 21:49:54 tom Exp $ +-- $Id: NEWS,v 1.1704 2011/05/21 19:01:38 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,9 @@ See the AUTHORS file for the corresponding full names. Changes through 1.9.9e did not credit all contributions; it is not possible to add this information. +20110521 + + fix warnings from clang 2.7 "--analyze" + 20110514 + compiler-warning fixes in panel and progs. + modify CF_PKG_CONFIG macro, from changes to tin -TD diff --git a/dist.mk b/dist.mk index 6dfe3a24..92c4856a 100644 --- a/dist.mk +++ b/dist.mk @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.816 2011/05/14 17:22:21 tom Exp $ +# $Id: dist.mk,v 1.817 2011/05/21 17:35:14 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -37,7 +37,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 5 NCURSES_MINOR = 9 -NCURSES_PATCH = 20110514 +NCURSES_PATCH = 20110521 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/menu/m_driver.c b/menu/m_driver.c index deeff471..dcc1c55d 100644 --- a/menu/m_driver.c +++ b/menu/m_driver.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. * + * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -37,7 +37,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_driver.c,v 1.29 2010/01/23 21:20:10 tom Exp $") +MODULE_ID("$Id: m_driver.c,v 1.30 2011/05/21 18:56:41 tom Exp $") /* Macros */ @@ -537,7 +537,11 @@ menu_driver(MENU * menu, int c) result = E_UNKNOWN_COMMAND; } - if (E_OK == result) + if (item == 0) + { + result = E_BAD_STATE; + } + else if (E_OK == result) { /* Adjust the top row if it turns out that the current item unfortunately doesn't appear in the menu window */ diff --git a/ncurses/base/wresize.c b/ncurses/base/wresize.c index 9a6ea500..bc6b5732 100644 --- a/ncurses/base/wresize.c +++ b/ncurses/base/wresize.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. * + * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -33,7 +33,7 @@ #include -MODULE_ID("$Id: wresize.c,v 1.34 2010/06/05 22:36:26 tom Exp $") +MODULE_ID("$Id: wresize.c,v 1.35 2011/05/21 18:55:07 tom Exp $") static int cleanup_lines(struct ldat *data, int length) @@ -175,9 +175,10 @@ wresize(WINDOW *win, int ToLines, int ToCols) for (col = 0; col <= ToCols; ++col) s[col] = win->_nc_bkgd; } - } else { - assert(pline != 0); + } else if (pline != 0 && pline[win->_pary + row].text != 0) { s = &pline[win->_pary + row].text[win->_parx]; + } else { + s = 0; } if_USE_SCROLL_HINTS(new_lines[row].oldindex = row); diff --git a/ncurses/tinfo/comp_expand.c b/ncurses/tinfo/comp_expand.c index 71012b63..84024008 100644 --- a/ncurses/tinfo/comp_expand.c +++ b/ncurses/tinfo/comp_expand.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2008,2010 Free Software Foundation, Inc. * + * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -35,7 +35,7 @@ #include #include -MODULE_ID("$Id: comp_expand.c,v 1.21 2010/01/16 17:11:23 tom Exp $") +MODULE_ID("$Id: comp_expand.c,v 1.22 2011/05/21 18:55:07 tom Exp $") static int trailing_spaces(const char *src) @@ -61,15 +61,15 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers) size_t need = (2 + strlen(str)) * 4; int ch; -#if NO_LEAKS if (srcp == 0) { +#if NO_LEAKS if (buffer != 0) { FreeAndNull(buffer); length = 0; } +#endif return 0; } -#endif if (buffer == 0 || need > length) { if ((buffer = typeRealloc(char, length = need, buffer)) == 0) return 0; diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c index 992b8c71..40af877b 100644 --- a/ncurses/tinfo/lib_setup.c +++ b/ncurses/tinfo/lib_setup.c @@ -47,7 +47,7 @@ #include #endif -MODULE_ID("$Id: lib_setup.c,v 1.136 2011/04/16 15:32:45 tom Exp $") +MODULE_ID("$Id: lib_setup.c,v 1.137 2011/05/21 17:35:14 tom Exp $") /**************************************************************************** * @@ -547,7 +547,7 @@ _nc_locale_breaks_acs(TERMINAL * termp) int value; int result = 0; - if ((env = getenv(env_name)) != 0) { + if (getenv(env_name) != 0) { result = _nc_getenv_num(env_name); } else if ((value = tigetnum("U8")) >= 0) { result = value; /* use extension feature */ diff --git a/ncurses/tinfo/lib_tparm.c b/ncurses/tinfo/lib_tparm.c index 7cd12f7f..b1d79248 100644 --- a/ncurses/tinfo/lib_tparm.c +++ b/ncurses/tinfo/lib_tparm.c @@ -42,7 +42,7 @@ #include #include -MODULE_ID("$Id: lib_tparm.c,v 1.82 2011/01/15 22:19:12 tom Exp $") +MODULE_ID("$Id: lib_tparm.c,v 1.83 2011/05/21 18:11:56 tom Exp $") /* * char * @@ -522,7 +522,7 @@ tparam_internal(bool use_TPARM_ARG, const char *string, va_list ap) } #ifdef TRACE if (USE_TRACEF(TRACE_CALLS)) { - for (i = 0; i < popcount; i++) { + for (i = 0; i < num_args; i++) { if (p_is_s[i] != 0) save_text(", %s", _nc_visbuf(p_is_s[i]), 0); else diff --git a/panel/panel.priv.h b/panel/panel.priv.h index ce4f9893..016a84c1 100644 --- a/panel/panel.priv.h +++ b/panel/panel.priv.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. * + * Copyright (c) 1998-2009,2011 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ -/* $Id: panel.priv.h,v 1.23 2009/04/11 20:33:55 tom Exp $ */ +/* $Id: panel.priv.h,v 1.24 2011/05/21 18:55:07 tom Exp $ */ #ifndef NCURSES_PANEL_PRIV_H #define NCURSES_PANEL_PRIV_H 1 @@ -160,7 +160,7 @@ struct screen; /* forward declaration */ ---------------------------------------------------------------------------*/ #define PANEL_UPDATE(pan,panstart)\ { PANEL* pan2 = ((panstart) ? (panstart) : _nc_bottom_panel);\ - while(pan2) {\ + while(pan2 && pan2->win) {\ if ((pan2 != pan) && PANELS_OVERLAPPED(pan,pan2)) {\ int y, ix1, ix2, iy1, iy2;\ COMPUTE_INTERSECTION(pan, pan2, ix1, ix2, iy1, iy2);\ diff --git a/progs/tabs.c b/progs/tabs.c index e0e042b3..2f6915de 100644 --- a/progs/tabs.c +++ b/progs/tabs.c @@ -37,7 +37,7 @@ #define USE_LIBTINFO #include -MODULE_ID("$Id: tabs.c,v 1.20 2011/05/14 22:34:36 tom Exp $") +MODULE_ID("$Id: tabs.c,v 1.21 2011/05/21 18:31:21 tom Exp $") static void usage(void) GCC_NORETURN; @@ -353,7 +353,6 @@ main(int argc, char *argv[]) bool no_op = FALSE; int n, ch; NCURSES_CONST char *term_name = 0; - const char *mar_list = 0; /* ignored */ char *append = 0; const char *tab_list = 0; @@ -446,7 +445,11 @@ main(int argc, char *argv[]) while ((ch = *++option) != '\0') { switch (ch) { case 'm': - mar_list = option; + /* + * The "+mXXX" option is unimplemented because only the long-obsolete + * att510d implements smgl, which is needed to support + * this option. + */ break; default: /* special case of relative stops separated by spaces? */ diff --git a/progs/tic.c b/progs/tic.c index 62f1f0a3..739e7ed7 100644 --- a/progs/tic.c +++ b/progs/tic.c @@ -44,7 +44,7 @@ #include #include -MODULE_ID("$Id: tic.c,v 1.149 2011/05/14 23:24:57 tom Exp $") +MODULE_ID("$Id: tic.c,v 1.150 2011/05/21 18:15:45 tom Exp $") const char *_nc_progname = "tic"; @@ -339,23 +339,23 @@ put_translate(int c) static char * stripped(char *src) { + char *dst = 0; + while (isspace(UChar(*src))) src++; + if (*src != '\0') { - char *dst; size_t len; - if ((dst = strdup(src)) == NULL) + if ((dst = strdup(src)) == NULL) { failed("strdup"); - - assert(dst != 0); - - len = strlen(dst); - while (--len != 0 && isspace(UChar(dst[len]))) - dst[len] = '\0'; - return dst; + } else { + len = strlen(dst); + while (--len != 0 && isspace(UChar(dst[len]))) + dst[len] = '\0'; + } } - return 0; + return dst; } static FILE * diff --git a/progs/toe.c b/progs/toe.c index 3203b5bd..eff8cc84 100644 --- a/progs/toe.c +++ b/progs/toe.c @@ -44,7 +44,7 @@ #include #endif -MODULE_ID("$Id: toe.c,v 1.53 2011/05/14 22:35:49 tom Exp $") +MODULE_ID("$Id: toe.c,v 1.54 2011/05/21 18:32:13 tom Exp $") #define isDotname(name) (!strcmp(name, ".") || !strcmp(name, "..")) @@ -61,6 +61,8 @@ ExitProgram(int code) } #endif +static void failed(const char *) GCC_NORETURN; + static void failed(const char *msg) { diff --git a/progs/tset.c b/progs/tset.c index 615226a7..71a1845f 100644 --- a/progs/tset.c +++ b/progs/tset.c @@ -119,7 +119,7 @@ char *ttyname(int fd); #include #include -MODULE_ID("$Id: tset.c,v 1.83 2011/05/14 22:50:45 tom Exp $") +MODULE_ID("$Id: tset.c,v 1.84 2011/05/21 18:55:32 tom Exp $") /* * SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS, @@ -148,6 +148,10 @@ extern char **environ; #undef CTRL #define CTRL(x) ((x) & 0x1f) +static void failed(const char *) GCC_NORETURN; +static void exit_error(void) GCC_NORETURN; +static void err(const char *,...) GCC_NORETURN; + const char *_nc_progname = "tset"; static TTY mode, oldmode, original; diff --git a/test/ditto.c b/test/ditto.c index 636a6eec..36644f12 100644 --- a/test/ditto.c +++ b/test/ditto.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. * + * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,7 +29,7 @@ /* * Author: Thomas E. Dickey (1998-on) * - * $Id: ditto.c,v 1.40 2010/11/14 01:06:47 tom Exp $ + * $Id: ditto.c,v 1.41 2011/05/21 18:55:07 tom Exp $ * * The program illustrates how to set up multiple screens from a single * program. @@ -98,6 +98,9 @@ typedef struct { DITTO *ditto; /* data for all screens */ } DDATA; +static void failed(const char *) GCC_NORETURN; +static void usage(void) GCC_NORETURN; + static void failed(const char *s) { diff --git a/test/ncurses.c b/test/ncurses.c index 29000345..df2d064c 100644 --- a/test/ncurses.c +++ b/test/ncurses.c @@ -40,7 +40,7 @@ AUTHOR Author: Eric S. Raymond 1993 Thomas E. Dickey (beginning revision 1.27 in 1996). -$Id: ncurses.c,v 1.367 2011/04/23 21:16:43 tom Exp $ +$Id: ncurses.c,v 1.368 2011/05/21 18:50:56 tom Exp $ ***************************************************************************/ @@ -1394,7 +1394,7 @@ show_attr(int row, int skip, bool arrow, chtype attr, const char *name) if (!(termattrs() & test)) { printw(" (N/A)"); } else { - if (ncv > 0 && (getbkgd(stdscr) & A_COLOR)) { + if (ncv > 0 && stdscr && (getbkgd(stdscr) & A_COLOR)) { static const chtype table[] = { A_STANDOUT, @@ -4269,8 +4269,10 @@ acs_and_scroll(void) neww->next = current ? current->next : 0; neww->last = current; - neww->last->next = neww; - neww->next->last = neww; + if (neww->last != 0) + neww->last->next = neww; + if (neww->next != 0) + neww->next->last = neww; neww->wind = getwin(fp); diff --git a/test/redraw.c b/test/redraw.c index 1fc306f5..96c6b0f3 100644 --- a/test/redraw.c +++ b/test/redraw.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: redraw.c,v 1.6 2011/04/23 20:13:21 tom Exp $ + * $Id: redraw.c,v 1.7 2011/05/21 18:38:35 tom Exp $ * * Demonstrate the redrawwin() and wredrawln() functions. * Thomas Dickey - 2006/11/4 @@ -71,7 +71,7 @@ test_redraw(WINDOW *win) keypad(win, TRUE); getmaxyx(win, max_y, max_x); getbegyx(win, beg_y, beg_x); - while (!done) { + while (!done && win != 0) { ch = wgetch(win); getyx(win, y, x); switch (ch) { diff --git a/test/view.c b/test/view.c index 3b6591e7..97511ca2 100644 --- a/test/view.c +++ b/test/view.c @@ -50,7 +50,7 @@ * scroll operation worked, and the refresh() code only had to do a * partial repaint. * - * $Id: view.c,v 1.82 2011/05/14 17:43:12 tom Exp $ + * $Id: view.c,v 1.83 2011/05/21 18:40:49 tom Exp $ */ #include @@ -121,6 +121,8 @@ static NCURSES_CH_T **vec_lines; static NCURSES_CH_T **lptr; static int num_lines; +static void usage(void) GCC_NORETURN; + static void usage(void) {