From 04df0be8426eab29b94774a8ca9210f2ec6e371d Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 23 Mar 2002 22:50:24 +0000 Subject: [PATCH] Cleanups both for and from Splint. svn path=/trunk/yasm/; revision=546 --- frontends/yasm/yasm.c | 39 +++++++++++++++++++++++---------------- libyasm/errwarn.c | 22 +++++++++++++--------- src/errwarn.c | 22 +++++++++++++--------- src/main.c | 39 +++++++++++++++++++++++---------------- 4 files changed, 72 insertions(+), 50 deletions(-) diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index cdebcc15..4fb9fb17 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -51,10 +51,10 @@ /*@null@*/ /*@only@*/ static char *obj_filename = NULL, *in_filename = NULL; static int special_options = 0; -static preproc *cur_preproc = NULL; +/*@null@*/ /*@dependent@*/ static preproc *cur_preproc = NULL; static int preproc_only = 0; -static FILE *open_obj(void); +/*@null@*/ /*@dependent@*/ static FILE *open_obj(void); static void cleanup(sectionhead *sections); /* Forward declarations: cmd line parser handlers */ @@ -85,22 +85,23 @@ static opt_option options[] = }; /* version message */ -static const char version_msg[] = N_( - "yasm " VERSION "\n" - "Copyright (c) 2001-2002 Peter Johnson and other " PACKAGE " developers\n" - "This program is free software; you may redistribute it under the terms\n" - "of the GNU General Public License. Portions of this program are\n" - "licensed under the GNU Lesser General Public License or the 3-clause\n" - "BSD license; see individual file comments for details. This program\n" - "has absolutely no warranty; not even for merchantability or fitness for\n" - "a particular purpose.\n" - "Compiled on " __DATE__ ".\n"); +/*@observer@*/ static const char *version_msg[] = { + N_("yasm " VERSION "\n"), + N_("Copyright (c) 2001-2002 Peter Johnson and other " PACKAGE " developers\n"), + N_("This program is free software; you may redistribute it under the\n"), + N_("terms of the GNU General Public License. Portions of this program\n"), + N_("are licensed under the GNU Lesser General Public License or the\n"), + N_("3-clause BSD license; see individual file comments for details.\n"), + N_("This program has absolutely no warranty; not even for\n"), + N_("merchantibility or fitness for a particular purpose.\n"), + N_("Compiled on " __DATE__ ".\n"), +}; /* help messages */ -static const char help_head[] = N_( +/*@observer@*/ static const char help_head[] = N_( "usage: yasm [option]* file\n" "Options:\n"); -static const char help_tail[] = N_( +/*@observer@*/ static const char help_tail[] = N_( "\n" "Files are asm sources to be assembled.\n" "\n" @@ -116,6 +117,7 @@ main(int argc, char *argv[]) { /*@null@*/ FILE *in = NULL, *obj = NULL; sectionhead *sections; + size_t i; #if defined(HAVE_SETLOCALE) && defined(HAVE_LC_MESSAGES) setlocale(LC_MESSAGES, ""); @@ -135,7 +137,8 @@ main(int argc, char *argv[]) countof(options, opt_option)); return EXIT_SUCCESS; case SPECIAL_SHOW_VERSION: - printf("%s", gettext(version_msg)); + for (i=0; i 0) { if (obj != stdout) remove(obj_filename); + xfree(preproc_buf); return EXIT_FAILURE; } xfree(obj_filename); + xfree(preproc_buf); return EXIT_SUCCESS; } diff --git a/libyasm/errwarn.c b/libyasm/errwarn.c index c00b0572..1cd9577e 100644 --- a/libyasm/errwarn.c +++ b/libyasm/errwarn.c @@ -28,16 +28,12 @@ # include #endif -#ifdef gettext_noop -#define N_(String) gettext_noop(String) -#else -#define N_(String) (String) -#endif - #include "globals.h" #include "errwarn.h" +#define MSG_MAXSIZE 1024 + /* ALL warnings are disabled if this is nonzero. */ int warnings_disabled = 0; @@ -49,7 +45,7 @@ int warning_error = 0; /* Default enabled warnings. See errwarn.h for a list. */ unsigned long warning_flags = - (1<= 0 on finish. */ @@ -81,7 +77,7 @@ typedef struct errwarn_s { unsigned long line; /* FIXME: This should not be a fixed size. But we don't have vasprintf() * right now. */ - char msg[1024]; + char msg[MSG_MAXSIZE]; } errwarn; /* Line number of the previous error. Set and checked by Error(). */ @@ -132,7 +128,7 @@ ParserError(const char *s) void InternalError_(const char *file, unsigned int line, const char *message) { - fprintf(stderr, _("INTERNAL ERROR at %s, line %d: %s\n"), file, line, + fprintf(stderr, _("INTERNAL ERROR at %s, line %u: %s\n"), file, line, message); #ifdef HAVE_ABORT abort(); @@ -184,7 +180,11 @@ Error(const char *fmt, ...) assert(we != NULL); va_start(ap, fmt); +#ifdef HAVE_VSNPRINTF + vsnprintf(we->msg, MSG_MAXSIZE, fmt, ap); +#else vsprintf(we->msg, fmt, ap); +#endif va_end(ap); /*@-branchstate@*/ @@ -220,7 +220,11 @@ Warning(const char *fmt, ...) we->type = WE_WARNING; we->line = line_index; va_start(ap, fmt); +#ifdef HAVE_VSNPRINTF + vsnprintf(we->msg, MSG_MAXSIZE, fmt, ap); +#else vsprintf(we->msg, fmt, ap); +#endif va_end(ap); if (!errwarns) { diff --git a/src/errwarn.c b/src/errwarn.c index c00b0572..1cd9577e 100644 --- a/src/errwarn.c +++ b/src/errwarn.c @@ -28,16 +28,12 @@ # include #endif -#ifdef gettext_noop -#define N_(String) gettext_noop(String) -#else -#define N_(String) (String) -#endif - #include "globals.h" #include "errwarn.h" +#define MSG_MAXSIZE 1024 + /* ALL warnings are disabled if this is nonzero. */ int warnings_disabled = 0; @@ -49,7 +45,7 @@ int warning_error = 0; /* Default enabled warnings. See errwarn.h for a list. */ unsigned long warning_flags = - (1<= 0 on finish. */ @@ -81,7 +77,7 @@ typedef struct errwarn_s { unsigned long line; /* FIXME: This should not be a fixed size. But we don't have vasprintf() * right now. */ - char msg[1024]; + char msg[MSG_MAXSIZE]; } errwarn; /* Line number of the previous error. Set and checked by Error(). */ @@ -132,7 +128,7 @@ ParserError(const char *s) void InternalError_(const char *file, unsigned int line, const char *message) { - fprintf(stderr, _("INTERNAL ERROR at %s, line %d: %s\n"), file, line, + fprintf(stderr, _("INTERNAL ERROR at %s, line %u: %s\n"), file, line, message); #ifdef HAVE_ABORT abort(); @@ -184,7 +180,11 @@ Error(const char *fmt, ...) assert(we != NULL); va_start(ap, fmt); +#ifdef HAVE_VSNPRINTF + vsnprintf(we->msg, MSG_MAXSIZE, fmt, ap); +#else vsprintf(we->msg, fmt, ap); +#endif va_end(ap); /*@-branchstate@*/ @@ -220,7 +220,11 @@ Warning(const char *fmt, ...) we->type = WE_WARNING; we->line = line_index; va_start(ap, fmt); +#ifdef HAVE_VSNPRINTF + vsnprintf(we->msg, MSG_MAXSIZE, fmt, ap); +#else vsprintf(we->msg, fmt, ap); +#endif va_end(ap); if (!errwarns) { diff --git a/src/main.c b/src/main.c index cdebcc15..4fb9fb17 100644 --- a/src/main.c +++ b/src/main.c @@ -51,10 +51,10 @@ /*@null@*/ /*@only@*/ static char *obj_filename = NULL, *in_filename = NULL; static int special_options = 0; -static preproc *cur_preproc = NULL; +/*@null@*/ /*@dependent@*/ static preproc *cur_preproc = NULL; static int preproc_only = 0; -static FILE *open_obj(void); +/*@null@*/ /*@dependent@*/ static FILE *open_obj(void); static void cleanup(sectionhead *sections); /* Forward declarations: cmd line parser handlers */ @@ -85,22 +85,23 @@ static opt_option options[] = }; /* version message */ -static const char version_msg[] = N_( - "yasm " VERSION "\n" - "Copyright (c) 2001-2002 Peter Johnson and other " PACKAGE " developers\n" - "This program is free software; you may redistribute it under the terms\n" - "of the GNU General Public License. Portions of this program are\n" - "licensed under the GNU Lesser General Public License or the 3-clause\n" - "BSD license; see individual file comments for details. This program\n" - "has absolutely no warranty; not even for merchantability or fitness for\n" - "a particular purpose.\n" - "Compiled on " __DATE__ ".\n"); +/*@observer@*/ static const char *version_msg[] = { + N_("yasm " VERSION "\n"), + N_("Copyright (c) 2001-2002 Peter Johnson and other " PACKAGE " developers\n"), + N_("This program is free software; you may redistribute it under the\n"), + N_("terms of the GNU General Public License. Portions of this program\n"), + N_("are licensed under the GNU Lesser General Public License or the\n"), + N_("3-clause BSD license; see individual file comments for details.\n"), + N_("This program has absolutely no warranty; not even for\n"), + N_("merchantibility or fitness for a particular purpose.\n"), + N_("Compiled on " __DATE__ ".\n"), +}; /* help messages */ -static const char help_head[] = N_( +/*@observer@*/ static const char help_head[] = N_( "usage: yasm [option]* file\n" "Options:\n"); -static const char help_tail[] = N_( +/*@observer@*/ static const char help_tail[] = N_( "\n" "Files are asm sources to be assembled.\n" "\n" @@ -116,6 +117,7 @@ main(int argc, char *argv[]) { /*@null@*/ FILE *in = NULL, *obj = NULL; sectionhead *sections; + size_t i; #if defined(HAVE_SETLOCALE) && defined(HAVE_LC_MESSAGES) setlocale(LC_MESSAGES, ""); @@ -135,7 +137,8 @@ main(int argc, char *argv[]) countof(options, opt_option)); return EXIT_SUCCESS; case SPECIAL_SHOW_VERSION: - printf("%s", gettext(version_msg)); + for (i=0; i 0) { if (obj != stdout) remove(obj_filename); + xfree(preproc_buf); return EXIT_FAILURE; } xfree(obj_filename); + xfree(preproc_buf); return EXIT_SUCCESS; } -- 2.40.0