[Pkg-electronics-commits] [gtkwave] 01/03: Imported Upstream version 3.3.59

أحمد المحمودي (Ahmed El-Mahmoudy) aelmahmoudy at sabily.org
Thu May 1 19:05:07 UTC 2014


This is an automated email from the git hooks/post-receive script.

aelmahmoudy-guest pushed a commit to branch master
in repository gtkwave.

commit 3fe5e9e9ae1cb031a29b468001e5ca167cc7a035
Author: أحمد المحمودي (Ahmed El-Mahmoudy) <aelmahmoudy at sabily.org>
Date:   Thu May 1 10:22:45 2014 +0200

    Imported Upstream version 3.3.59
---
 ChangeLog                                 |  10 ++
 LICENSE.TXT                               |   2 +-
 configure                                 |  20 ++--
 configure.ac                              |   2 +-
 contrib/bundle_for_osx/Info-gtkwave.plist |   6 +-
 doc/gtkwave.odt                           | Bin 1394936 -> 1395012 bytes
 man/gtkwave.1                             |   4 +-
 src/baseconvert.c                         |   4 +-
 src/file.c                                |   2 +-
 src/ghwlib.c                              |  26 ++++-
 src/helpers/fst/fstapi.c                  | 181 +++++++++++++++++++++++++-----
 src/helpers/vcd2fst.c                     |  25 ++++-
 src/helpers/vzt_read.c                    |   2 +-
 src/ptranslate.c                          |   2 +-
 src/ttranslate.c                          |   1 +
 15 files changed, 228 insertions(+), 59 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f15b70c..42a8df0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1461,3 +1461,13 @@
 		Change [1] at end of struct to C99 [] notation with appropriate
 		allocation size modification.
 		System_profiler speed fix for OSX.
+3.3.59	26apr14	Use Duff's Device for 8 byte -> 1 byte binary value compression 
+		algorithm in FST writer.
+		Warnings fixes from cppcheck.
+		Moved MinGW for FST to using different windows tempfile 
+		generation instead of tmpfile().
+		Removed fflush() in FST for MinGW in places that can cause
+		crashes with read only files.
+		Updated man page for gtkwave.1 indicating that XID is in hex.
+		Allow decimal conversions on popcnt filtered vectors that are
+		greater than 64 bits (they will never overflow).
diff --git a/LICENSE.TXT b/LICENSE.TXT
index ab981fd..2023c8c 100644
--- a/LICENSE.TXT
+++ b/LICENSE.TXT
@@ -1,6 +1,6 @@
 ##########################################################################
 
-GTKWave 3.3.58 Wave Viewer is Copyright (C) 1999-2014 Tony Bybell.  
+GTKWave 3.3.59 Wave Viewer is Copyright (C) 1999-2014 Tony Bybell.  
 Portions of GTKWave are Copyright (C) 1999-2014 Udi Finkelstein. 
 Context support is Copyright (C) 2007-2014 Kermin Elliott Fleming.
 Trace group support is  Copyright (C) 2009-2014 Donald Baltus.
diff --git a/configure b/configure
index bbf8fab..cb17732 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for gtkwave 3.3.58.
+# Generated by GNU Autoconf 2.69 for gtkwave 3.3.59.
 #
 # Report bugs to <bybell at rocketmail.com>.
 #
@@ -580,8 +580,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='gtkwave'
 PACKAGE_TARNAME='gtkwave'
-PACKAGE_VERSION='3.3.58'
-PACKAGE_STRING='gtkwave 3.3.58'
+PACKAGE_VERSION='3.3.59'
+PACKAGE_STRING='gtkwave 3.3.59'
 PACKAGE_BUGREPORT='bybell at rocketmail.com'
 PACKAGE_URL=''
 
@@ -1382,7 +1382,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures gtkwave 3.3.58 to adapt to many kinds of systems.
+\`configure' configures gtkwave 3.3.59 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1448,7 +1448,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of gtkwave 3.3.58:";;
+     short | recursive ) echo "Configuration of gtkwave 3.3.59:";;
    esac
   cat <<\_ACEOF
 
@@ -1593,7 +1593,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-gtkwave configure 3.3.58
+gtkwave configure 3.3.59
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2237,7 +2237,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by gtkwave $as_me 3.3.58, which was
+It was created by gtkwave $as_me 3.3.59, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3104,7 +3104,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='gtkwave'
- VERSION='3.3.58'
+ VERSION='3.3.59'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -10959,7 +10959,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by gtkwave $as_me 3.3.58, which was
+This file was extended by gtkwave $as_me 3.3.59, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -11025,7 +11025,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-gtkwave config.status 3.3.58
+gtkwave config.status 3.3.59
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index efc84bd..99c7742 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.59)
-AC_INIT(gtkwave, 3.3.58, bybell at rocketmail.com)
+AC_INIT(gtkwave, 3.3.59, bybell at rocketmail.com)
 AC_CONFIG_SRCDIR([src/vcd.c])
 AM_INIT_AUTOMAKE
 AC_CONFIG_HEADER([config.h])
diff --git a/contrib/bundle_for_osx/Info-gtkwave.plist b/contrib/bundle_for_osx/Info-gtkwave.plist
index 367566a..a6f6f91 100644
--- a/contrib/bundle_for_osx/Info-gtkwave.plist
+++ b/contrib/bundle_for_osx/Info-gtkwave.plist
@@ -8,7 +8,7 @@
     <key>CFBundleExecutable</key>
     <string>gtkwave</string>
     <key>CFBundleGetInfoString</key>
-    <string>3.3.58, (C) 1999-2014 Tony Bybell http://gtkwave.sourceforge.net</string>
+    <string>3.3.59, (C) 1999-2014 Tony Bybell http://gtkwave.sourceforge.net</string>
     <key>CFBundleIconFile</key>
     <string>gtkwave.icns</string>
     <key>CFBundleIdentifier</key>
@@ -18,11 +18,11 @@
     <key>CFBundlePackageType</key>
     <string>APPL</string>
     <key>CFBundleShortVersionString</key>
-    <string>3.3.58</string>
+    <string>3.3.59</string>
     <key>CFBundleSignature</key>
     <string>????</string>
     <key>CFBundleVersion</key>
-    <string>3.3.58</string>
+    <string>3.3.59</string>
     <key>NSHumanReadableCopyright</key>
     <string>Copyright 1999 - 2014 Tony Bybell, GNU General Public License.</string>
     <key>LSMinimumSystemVersion</key>
diff --git a/doc/gtkwave.odt b/doc/gtkwave.odt
index f5e0855..41525b5 100644
Binary files a/doc/gtkwave.odt and b/doc/gtkwave.odt differ
diff --git a/man/gtkwave.1 b/man/gtkwave.1
index 50ff5b5..cb09dd0 100644
--- a/man/gtkwave.1
+++ b/man/gtkwave.1
@@ -1,4 +1,4 @@
-.TH "GTKWAVE" "1" "3.3.29" "Anthony Bybell" "Simulation Wave Viewer"
+.TH "GTKWAVE" "1" "3.3.59" "Anthony Bybell" "Simulation Wave Viewer"
 .SH "NAME"
 .LP 
 gtkwave \- Visualization tool for VCD, LXT, LXT2, VZT, FST, and GHW files
@@ -94,7 +94,7 @@ Specify Tcl command script for periodic execution.
 Specifies delay in milliseconds between successive executions of the repscript.  Default is 500.
 .TP
 \fB\-X\fR,\fB\-\-xid\fR <\fIXID\fP>
-Specify XID of window for a GtkPlug to connect to.  GTKWave does not directly render to a window but instead renders into a 
+Specify XID (in hexadecimal) of window for a GtkPlug to connect to.  GTKWave does not directly render to a window but instead renders into a 
 GtkPlug expecting a GtkSocket at the other end.  Note that there are issues with accelerators working properly so menus are
 disabled in the componentized version of GTKWave when it functions as a plug-in.
 .TP 
diff --git a/src/baseconvert.c b/src/baseconvert.c
index 75b0e5e..1203ee0 100644
--- a/src/baseconvert.c
+++ b/src/baseconvert.c
@@ -330,7 +330,7 @@ if(flags&TR_ASCII)
 	if(GLOBALS->show_base) { *(pnt++)='"'; }
 	*(pnt)=0x00; /* scan build : remove dead increment */
 	}
-else if((flags&TR_HEX)||((flags&(TR_DEC|TR_SIGNED))&&(nbits>64)))
+else if((flags&TR_HEX)||((flags&(TR_DEC|TR_SIGNED))&&(nbits>64)&&(!(flags&TR_POPCNT))))
 	{
 	char *parse;
 
@@ -990,7 +990,7 @@ if(flags&TR_ASCII)
 	if(GLOBALS->show_base) { *(pnt++)='"'; }
 	*(pnt)=0x00; /* scan build : remove dead increment */
 	}
-else if((flags&TR_HEX)||((flags&(TR_DEC|TR_SIGNED))&&(nbits>64)))
+else if((flags&TR_HEX)||((flags&(TR_DEC|TR_SIGNED))&&(nbits>64)&&(!(flags&TR_POPCNT))))
 	{
 	char *parse;
 
diff --git a/src/file.c b/src/file.c
index 58432f4..176685d 100644
--- a/src/file.c
+++ b/src/file.c
@@ -174,7 +174,7 @@ if((!pattn)||(!strcmp(pattn, "*")))
 	}
 	else
 	{
-	sprintf(lpstrFilter, "%s%c%s%c%s%c%s%c", pattn, 0, pattn, 0, "All", 0, "*.*"); 
+	sprintf(lpstrFilter, "%s%c%s%c%s%c%s%c", pattn, 0, pattn, 0, "All", 0, "*.*", 0); /* cppcheck */
 	ofn.nFilterIndex = 0;
 	}
 
diff --git a/src/ghwlib.c b/src/ghwlib.c
index 1dd57d1..452a19e 100644
--- a/src/ghwlib.c
+++ b/src/ghwlib.c
@@ -524,7 +524,10 @@ ghw_read_type (struct ghw_handler *h)
 	    e->wkt = ghw_wkt_unknown;
 	    e->name = ghw_read_strid (h);
 	    if (ghw_read_uleb128 (h, (uint32_t *)&e->nbr) != 0)
-	      return -1;
+		{
+		free(e); /* cppcheck */
+	      	return -1;
+		}
 	    e->lits = (const char **) calloc (1, e->nbr * sizeof (char *));
 	    if (h->flag_verbose > 1)
 	      printf ("enum %s:", e->name);
@@ -568,13 +571,20 @@ ghw_read_type (struct ghw_handler *h)
 		int ix;
 
 		if (ghw_read_uleb128 (h, &ph->nbr_units) != 0)
-		  return -1;
+			{
+			free(ph); /* cppcheck */
+		  	return -1;
+			}
 		ph->units = calloc (ph->nbr_units, sizeof (struct ghw_unit));
 		for (ix = 0; ix < ph->nbr_units; ix++)
 		  {
 		    ph->units[ix].name = ghw_read_strid (h);
 		    if (ghw_read_lsleb128 (h, &ph->units[ix].val) < 0)
-		      return -1;
+			{
+			free(ph->units); /* missed by cppcheck */
+			free(ph); /* missed by cppcheck */
+		      	return -1;
+			}
 		  }
 	      }
 	    if (h->flag_verbose > 1)
@@ -606,7 +616,10 @@ ghw_read_type (struct ghw_handler *h)
 	    arr->name = ghw_read_strid (h);
 	    arr->el = ghw_read_typeid (h);
 	    if (ghw_read_uleb128 (h, (uint32_t *)&arr->nbr_dim) != 0)
-	      return -1;
+		{
+		free(arr); /* cppcheck */
+	      	return -1;
+		}
 	    arr->dims = (union ghw_type **)
 	      calloc (arr->nbr_dim, sizeof (union ghw_type *));
 	    for (j = 0; j < arr->nbr_dim; j++)
@@ -650,7 +663,10 @@ ghw_read_type (struct ghw_handler *h)
 	    rec->kind = t;
 	    rec->name = ghw_read_strid (h);
 	    if (ghw_read_uleb128 (h, (uint32_t *)&rec->nbr_fields) != 0)
-	      return -1;
+		{
+		free(rec); /* cppcheck */
+	      	return -1;
+		}
 	    rec->el = calloc
 	      (rec->nbr_fields, sizeof (struct ghw_record_element));
 	    nbr_el = 0;
diff --git a/src/helpers/fst/fstapi.c b/src/helpers/fst/fstapi.c
index 9535111..4ff229c 100644
--- a/src/helpers/fst/fstapi.c
+++ b/src/helpers/fst/fstapi.c
@@ -26,6 +26,7 @@
  * FST_DYNAMIC_ALIAS_DISABLE : dynamic aliases are not processed
  * FST_DYNAMIC_ALIAS2_DISABLE : new encoding for dynamic aliases is not generated
  * FST_WRITEX_DISABLE : fast write I/O routines are disabled
+ * FST_DISABLE_DUFFS_DEVICE : only if indirect branches are incredibly bad on host arch
  *
  * possible enables:
  *
@@ -51,6 +52,10 @@
 #include <pthread.h>
 #endif
 
+#ifdef __MINGW32__
+#include <windows.h>
+#endif
+
 #if HAVE_ALLOCA_H
 #include <alloca.h>
 #elif defined(__GNUC__)
@@ -139,8 +144,14 @@ void **JenkinsIns(void *base_i, const unsigned char *mem, uint32_t length, uint3
 #endif
 #endif
 
-
-/* the recoded "extra" values... */ 
+/*
+ * the recoded "extra" values...
+ * note that FST_RCV_Q is currently unused and is for future expansion.
+ * its intended use is as another level of escape such that any arbitrary
+ * value can be stored as the value: { time_delta, 8 bits, FST_RCV_Q }.
+ * this is currently not implemented so that the branchless decode is:
+ * uint32_t shcnt = 2 << (vli & 1); tdelta = vli >> shcnt;
+ */
 #define FST_RCV_X (1 | (0<<1))
 #define FST_RCV_Z (1 | (1<<1))
 #define FST_RCV_H (1 | (2<<1))
@@ -148,6 +159,7 @@ void **JenkinsIns(void *base_i, const unsigned char *mem, uint32_t length, uint3
 #define FST_RCV_W (1 | (4<<1))
 #define FST_RCV_L (1 | (5<<1))
 #define FST_RCV_D (1 | (6<<1))
+#define FST_RCV_Q (1 | (7<<1))
 
 #define FST_RCV_STR "xzhuwl-?"
 /*                   01234567 */
@@ -163,6 +175,82 @@ return(fopen(nam, mode));
 }
 
 
+/*
+ * system-specific temp file handling
+ */
+#ifdef __MINGW32__
+
+static FILE* tmpfile_open(char **nam)
+{
+char *fname = NULL;
+TCHAR szTempFileName[MAX_PATH];
+TCHAR lpTempPathBuffer[MAX_PATH];
+DWORD dwRetVal = 0;
+UINT uRetVal = 0;
+FILE *fh = NULL;
+
+dwRetVal = GetTempPath(MAX_PATH, lpTempPathBuffer);
+if((dwRetVal > MAX_PATH) || (dwRetVal == 0))
+        {
+        fprintf(stderr, "GetTempPath() failed in "__FILE__" line %d, exiting.\n", __LINE__);
+	exit(255);
+        }
+        else   
+        {
+        uRetVal = GetTempFileName(lpTempPathBuffer, TEXT("FSTW"), 0, szTempFileName);
+        if (uRetVal == 0)
+                {
+                fprintf(stderr, "GetTempFileName() failed in "__FILE__" line %d, exiting.\n", __LINE__);
+		exit(255);
+                }
+                else
+                {
+                fname = strdup(szTempFileName);
+                }
+        }
+
+if(fname)
+	{
+	if(nam) { *nam = fname; }
+	fh = unlink_fopen("fname", "w+b");
+	}
+
+return(fh);
+}
+
+#else
+
+static FILE* tmpfile_open(char **nam)
+{
+FILE *f = tmpfile(); /* replace with mkstemp() + fopen(), etc if this is not good enough */
+if(nam) { *nam = NULL; }
+return(f);
+}
+
+#endif
+
+
+static void tmpfile_close(FILE **f, char **nam)
+{
+if(f)
+	{
+	if(*f) { fclose(*f); *f = NULL; }
+	}
+
+if(nam)
+	{
+	if(*nam) 
+		{ 
+		unlink(*nam); 
+		free(*nam);
+		*nam = NULL; 
+		}
+	}
+}
+
+/*****************************************/
+
+
 /* 
  * to remove warn_unused_result compile time messages
  * (in the future there needs to be results checking)
@@ -694,6 +782,11 @@ Pvoid_t path_array;
 uint32_t path_array_count;
 
 unsigned fseek_failed : 1;
+
+char *geom_handle_nam;
+char *valpos_handle_nam;
+char *curval_handle_nam;
+char *tchn_handle_nam;
 };
 
 
@@ -1010,7 +1103,8 @@ struct fstWriterContext *xc = calloc(1, sizeof(struct fstWriterContext));
 xc->compress_hier = use_compressed_hier;
 fstDetermineBreakSize(xc);
 
-if((!nam)||(!(xc->handle=unlink_fopen(nam, "w+b"))))
+if((!nam)||
+	(!(xc->handle=unlink_fopen(nam, "w+b"))))
         {
         free(xc);
         xc=NULL;
@@ -1024,14 +1118,13 @@ if((!nam)||(!(xc->handle=unlink_fopen(nam, "w+b"))))
 	strcpy(hf + flen, ".hier");
 	xc->hier_handle = unlink_fopen(hf, "w+b");
 
-	xc->geom_handle = tmpfile();	/* .geom */
-	xc->valpos_handle = tmpfile();	/* .offs */
-	xc->curval_handle = tmpfile();	/* .bits */
-	xc->tchn_handle = tmpfile();	/* .tchn */
+	xc->geom_handle = tmpfile_open(&xc->geom_handle_nam);		/* .geom */
+	xc->valpos_handle = tmpfile_open(&xc->valpos_handle_nam);	/* .offs */
+	xc->curval_handle = tmpfile_open(&xc->curval_handle_nam);	/* .bits */
+	xc->tchn_handle = tmpfile_open(&xc->tchn_handle_nam);		/* .tchn */
 	xc->vchg_alloc_siz = xc->fst_break_size + xc->fst_break_add_size;
 	xc->vchg_mem = malloc(xc->vchg_alloc_siz);
 
-	free(hf);
 	if(xc->hier_handle && xc->geom_handle && xc->valpos_handle && xc->curval_handle && xc->vchg_mem && xc->tchn_handle)
 		{
 	        xc->filename = strdup(nam);
@@ -1047,15 +1140,18 @@ if((!nam)||(!(xc->handle=unlink_fopen(nam, "w+b"))))
 		}
 		else
 		{
-		if(xc->hier_handle) fclose(xc->hier_handle);
-		if(xc->geom_handle) fclose(xc->geom_handle);
-		if(xc->valpos_handle) fclose(xc->valpos_handle);
-		if(xc->curval_handle) fclose(xc->curval_handle);
-		if(xc->tchn_handle) fclose(xc->tchn_handle);
+		fclose(xc->handle);
+		if(xc->hier_handle) { fclose(xc->hier_handle); unlink(hf); }
+		tmpfile_close(&xc->geom_handle, &xc->geom_handle_nam);
+		tmpfile_close(&xc->valpos_handle, &xc->valpos_handle_nam);
+		tmpfile_close(&xc->curval_handle, &xc->curval_handle_nam);
+		tmpfile_close(&xc->tchn_handle, &xc->tchn_handle_nam);
 		free(xc->vchg_mem);
 	        free(xc);
 	        xc=NULL;
 		}
+
+	free(hf);
 	}
 
 return(xc);
@@ -1161,7 +1257,7 @@ hashmask |= hashmask >> 16;
 #endif
 #endif
 
-if((!xc)||(xc->vchg_siz <= 1)||(xc->already_in_flush)) return;
+if((xc->vchg_siz <= 1)||(xc->already_in_flush)) return;
 xc->already_in_flush = 1; /* should really do this with a semaphore */
 
 xc->section_header_only = 0;
@@ -1291,6 +1387,8 @@ for(i=0;i<xc->maxhandle;i++)
 				if(is_binary)
 					{
 					unsigned char acc = 0;
+#ifdef FST_DISABLE_DUFFS_DEVICE
+					/* old algorithm */
 					int shift = 7 - ((vm4ip[1]-1) & 7);
 					for(idx=vm4ip[1]-1;idx>=0;idx--)
 						{
@@ -1303,6 +1401,24 @@ for(i=0;i<xc->maxhandle;i++)
 							acc = 0;
 							}						
 						}					
+#else
+                                        /* new algorithm */
+                                        idx = ((vm4ip[1]+7) & ~7);
+                                        switch(vm4ip[1] & 7)
+                                                {
+                                                case 0: do {    acc  = (pnt[idx+7-8] & 1) << 0;
+                                                case 7:         acc |= (pnt[idx+6-8] & 1) << 1;
+                                                case 6:         acc |= (pnt[idx+5-8] & 1) << 2;
+                                                case 5:         acc |= (pnt[idx+4-8] & 1) << 3;
+                                                case 4:         acc |= (pnt[idx+3-8] & 1) << 4;
+                                                case 3:         acc |= (pnt[idx+2-8] & 1) << 5;
+                                                case 2:         acc |= (pnt[idx+1-8] & 1) << 6;
+                                                case 1:         acc |= (pnt[idx+0-8] & 1) << 7;
+                                                                *(--scratchpnt) = acc;
+                                                                idx -= 8;
+                                                        } while(idx);
+                                                }
+#endif
 
 	                                scratchpnt = fstCopyVarint32ToLeft(scratchpnt, (time_delta << 1));
 					}
@@ -1660,7 +1776,7 @@ free(xc->curval_mem);
 #endif
 free(xc->valpos_mem);
 free(xc->vchg_mem);
-fclose(xc->tchn_handle);
+tmpfile_close(&xc->tchn_handle, &xc->tchn_handle_nam);
 free(xc);
 
 return(NULL);
@@ -1703,7 +1819,7 @@ if(xc->parallel_enabled)
 	        }
 
 	xc->tchn_cnt = xc->tchn_idx = 0;
-	xc->tchn_handle = tmpfile();
+	xc->tchn_handle = tmpfile_open(&xc->tchn_handle_nam); /* child thread will deallocate file/name */
 	fstWriterFseeko(xc, xc->tchn_handle, 0, SEEK_SET);
 	fstFtruncate(fileno(xc->tchn_handle), 0);
 
@@ -1975,11 +2091,11 @@ if(xc && !xc->already_in_close && !xc->already_in_flush)
 	fstWriterUint64(xc->handle, xc->secnum);
 	fflush(xc->handle);
 	
-	if(xc->tchn_handle) { fclose(xc->tchn_handle); xc->tchn_handle = NULL; }
+	tmpfile_close(&xc->tchn_handle, &xc->tchn_handle_nam);
 	free(xc->vchg_mem); xc->vchg_mem = NULL;
-	if(xc->curval_handle) { fclose(xc->curval_handle); xc->curval_handle = NULL; }
-	if(xc->valpos_handle) { fclose(xc->valpos_handle); xc->valpos_handle = NULL; }
-	if(xc->geom_handle) { fclose(xc->geom_handle); xc->geom_handle = NULL; }
+	tmpfile_close(&xc->curval_handle, &xc->curval_handle_nam);
+	tmpfile_close(&xc->valpos_handle, &xc->valpos_handle_nam);
+	tmpfile_close(&xc->geom_handle, &xc->geom_handle_nam);
 	if(xc->hier_handle) { fclose(xc->hier_handle); xc->hier_handle = NULL; }
 	if(xc->handle) 
 		{ 
@@ -2988,6 +3104,9 @@ int writex_pos;
 int writex_fd;
 unsigned char writex_buf[FST_WRITEX_MAX];
 #endif
+
+char *f_nam;
+char *fh_nam;
 };
 
 
@@ -3465,7 +3584,6 @@ while (value)
 static int fstVcdIDForFwrite(char *buf, unsigned int value)
 {
 char *pnt = buf;
-unsigned int vmod;
 
 /* zero is illegal for a value...it is assumed they start at one */
 while (value)
@@ -3508,14 +3626,16 @@ if(!xc->fh)
 	sprintf(fnam, "%s.hier_%d_%p", xc->filename, getpid(), (void *)xc);
 	fstReaderFseeko(xc, xc->f, xc->hier_pos, SEEK_SET);
 	uclen = fstReaderUint64(xc->f);
+#ifndef __MINGW32__
 	fflush(xc->f);
-
+#endif
 	if(htyp == FST_BL_HIER)
 		{
 		fstReaderFseeko(xc, xc->f, xc->hier_pos, SEEK_SET);
 		uclen = fstReaderUint64(xc->f);
+#ifndef __MINGW32__
 		fflush(xc->f);
-
+#endif
 		zfd = dup(fileno(xc->f));
 		zhandle = gzdopen(zfd, "rb");
 		if(!zhandle)
@@ -3532,7 +3652,9 @@ if(!xc->fh)
 		fstReaderFseeko(xc, xc->f, xc->hier_pos - 8, SEEK_SET); /* get section len */
 		clen =  fstReaderUint64(xc->f) - 16;
 		uclen = fstReaderUint64(xc->f);
+#ifndef __MINGW32__
 		fflush(xc->f);
+#endif
 		}
 
 #ifndef __MINGW32__
@@ -3540,10 +3662,11 @@ if(!xc->fh)
         if(!xc->fh)
 #endif
                 {
-                xc->fh = tmpfile();  
+                xc->fh = tmpfile_open(&xc->fh_nam);  
                 free(fnam); fnam = NULL;
                 if(!xc->fh)
 			{
+			tmpfile_close(&xc->fh, &xc->fh_nam);
 			free(mem);
 			return(0);
 			}
@@ -4131,9 +4254,9 @@ if(sectype == FST_BL_ZWRAPPER)
 	fcomp = fopen(hf, "w+b");
 	if(!fcomp)
 		{
-		fcomp = tmpfile();
+		fcomp = tmpfile_open(&xc->f_nam);
 		free(hf); hf = NULL;
-		if(!fcomp) return(0);
+		if(!fcomp) { tmpfile_close(&fcomp, &xc->f_nam); return(0); } 
 		}
 
 #if defined(FST_MACOSX)
@@ -4152,7 +4275,9 @@ if(sectype == FST_BL_ZWRAPPER)
 #endif
 
 	fstReaderFseeko(xc, xc->f, 1+8+8, SEEK_SET);
+#ifndef __MINGW32__
 	fflush(xc->f);
+#endif
 
 	zfd = dup(fileno(xc->f));
 	zhandle = gzdopen(zfd, "rb");
@@ -4501,12 +4626,12 @@ if(xc)
 
 	if(xc->fh) 
 		{ 
-		fclose(xc->fh); xc->fh = NULL;
+		tmpfile_close(&xc->fh, &xc->fh_nam); 
 		}
 
 	if(xc->f) 
 		{ 
-		fclose(xc->f); xc->f = NULL; 
+		tmpfile_close(&xc->f, &xc->f_nam); 
 		if(xc->filename_unpacked)
 			{
 			unlink(xc->filename_unpacked);
diff --git a/src/helpers/vcd2fst.c b/src/helpers/vcd2fst.c
index c6487fd..578cc00 100644
--- a/src/helpers/vcd2fst.c
+++ b/src/helpers/vcd2fst.c
@@ -55,6 +55,20 @@
 static uint32_t var_direction_idx = 0;
 static unsigned char *var_direction = NULL;
 
+
+static void *realloc_2(void *ptr, size_t siz) /* cppcheck */
+{
+void *pnt = realloc(ptr, siz);
+if(!pnt)
+	{
+	fprintf(stderr, "ERROR: Out of memory in realloc(), exiting!\n"); /* normally free(ptr) here */
+	exit(255);
+	}
+
+return(pnt);
+}
+
+
 /*********************************************************/
 /*** vvv extload component type name determination vvv ***/
 /*********************************************************/
@@ -380,7 +394,7 @@ fgets_rc = fgets(*wbuf, (*len) + 1, f);
 while(((*wbuf)[*len] != 1) && !feof(f))
 	{
 	/* fprintf(stderr, "overflow %d\n", (int)(*len)); */
-	*wbuf = realloc(*wbuf, (*len) * 2 + 1);
+	*wbuf = realloc_2(*wbuf, (*len) * 2 + 1);
 	(*wbuf)[(*len) * 2] = 1;
 
 	fgets_rc = fgets(*wbuf + (*len), (*len) + 1, f);	
@@ -507,6 +521,7 @@ if(!f)
 	{
 	printf("Could not open '%s', exiting.\n", vname);
 	free(bin_fixbuff); bin_fixbuff = NULL;
+	free(vname); free(fstname);
 	exit(255);
 	}
 
@@ -516,6 +531,8 @@ if(!ctx)
 	{
 	printf("Could not open '%s', exiting.\n", fstname);
 	free(bin_fixbuff); bin_fixbuff = NULL;
+	free(vname); free(fstname);
+	fclose(f);
 	exit(255);
 	}
 
@@ -1350,7 +1367,7 @@ for(;;) /* was while(!feof(f)) */
 					if(node_len >= bin_fixbuff_len)
 						{
 						bin_fixbuff_len = node_len + 1;
-						bin_fixbuff = realloc(bin_fixbuff, bin_fixbuff_len);
+						bin_fixbuff = realloc_2(bin_fixbuff, bin_fixbuff_len);
 						}
 
 					memset(bin_fixbuff, buf[1] != '1' ? buf[1] : '0', delta);
@@ -1376,7 +1393,7 @@ for(;;) /* was while(!feof(f)) */
 						if(node_len >= bin_fixbuff_len)
 							{
 							bin_fixbuff_len = node_len + 1;
-							bin_fixbuff = realloc(bin_fixbuff, bin_fixbuff_len);
+							bin_fixbuff = realloc_2(bin_fixbuff, bin_fixbuff_len);
 							}
 
 						memset(bin_fixbuff, buf[1] != '1' ? buf[1] : '0', delta);
@@ -1428,7 +1445,7 @@ for(;;) /* was while(!feof(f)) */
 			if(p_len >= bin_fixbuff_len)
 				{
 				bin_fixbuff_len = p_len + 1;
-				bin_fixbuff = realloc(bin_fixbuff, bin_fixbuff_len);
+				bin_fixbuff = realloc_2(bin_fixbuff, bin_fixbuff_len);
 				}
 			pnt = bin_fixbuff;
 
diff --git a/src/helpers/vzt_read.c b/src/helpers/vzt_read.c
index c263cb9..1f6b300 100644
--- a/src/helpers/vzt_read.c
+++ b/src/helpers/vzt_read.c
@@ -1436,7 +1436,7 @@ struct vzt_pth_args *vpa = malloc(sizeof(struct vzt_pth_args));
 vpa->lt = lt;
 vpa->b = b;
 
-vzt_rd_pthread_create(lt, &b->pth, &b->pth_attr, vzt_rd_decompress_blk_pth_actual, vpa);
+vzt_rd_pthread_create(lt, &b->pth, &b->pth_attr, vzt_rd_decompress_blk_pth_actual, vpa); /* cppcheck misfires thinking vpa is not freed even though vzt_rd_decompress_blk_pth_actual() does it */
 }
 
 /*
diff --git a/src/ptranslate.c b/src/ptranslate.c
index 738d667..1eef012 100644
--- a/src/ptranslate.c
+++ b/src/ptranslate.c
@@ -140,8 +140,8 @@ static void load_proc_filter(int which, char *name)
   if((strlen(abs_path) == 0)||(!result))
     {
       status_text("Could not find filter process!\n");
+      pclose(stream); /* cppcheck */
       return;
-
     }
 
   pclose(stream);
diff --git a/src/ttranslate.c b/src/ttranslate.c
index 67cdd4e..df152a7 100644
--- a/src/ttranslate.c
+++ b/src/ttranslate.c
@@ -159,6 +159,7 @@ static void load_ttrans_filter(int which, char *name)
   if((strlen(abs_path) == 0)||(!result))
     {
       status_text("Could not find transaction filter process!\n");
+      pclose(stream); /* cppcheck */
       return;
 
     }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-electronics/gtkwave.git



More information about the Pkg-electronics-commits mailing list