summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormdejong <mdejong>2007-03-16 00:57:35 (GMT)
committermdejong <mdejong>2007-03-16 00:57:35 (GMT)
commit8bdda3336b26381617a3da78b450ee0d3eeead8c (patch)
treecbaf9ab8771bfda0f7d2b621a92953c38a713e96
parent3151441166a62084e4d9c1a15b6f3aa133efe129 (diff)
downloadtcl-8bdda3336b26381617a3da78b450ee0d3eeead8c.zip
tcl-8bdda3336b26381617a3da78b450ee0d3eeead8c.tar.gz
tcl-8bdda3336b26381617a3da78b450ee0d3eeead8c.tar.bz2
* generic/tclIOUtil.c (Tcl_Stat): Reimplement workaround
to avoid gcc warning by using local variables. When the macro argument is of type long long instead of long, the incorrect warning is not generated.
-rw-r--r--ChangeLog7
-rw-r--r--generic/tclIOUtil.c37
2 files changed, 27 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 3ccac78..0c9de6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2007-03-15 Mo DeJong <mdejong@users.sourceforge.net>
+ * generic/tclIOUtil.c (Tcl_Stat): Reimplement workaround
+ to avoid gcc warning by using local variables. When
+ the macro argument is of type long long instead
+ of long, the incorrect warning is not generated.
+
+2007-03-15 Mo DeJong <mdejong@users.sourceforge.net>
+
* win/Makefile.in: Fully qualify LIBRARY_DIR so
that `make test` does not depend on working dir.
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index a8401f7..d4b0667 100644
--- a/generic/tclIOUtil.c
+++ b/generic/tclIOUtil.c
@@ -17,7 +17,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIOUtil.c,v 1.140 2007/02/20 23:24:04 nijtmans Exp $
+ * RCS: @(#) $Id: tclIOUtil.c,v 1.141 2007/03/16 00:57:36 mdejong Exp $
*/
#include "tclInt.h"
@@ -68,37 +68,40 @@ Tcl_Stat(
Tcl_StatBuf buf;
Tcl_Obj *pathPtr = Tcl_NewStringObj(path,-1);
+ Tcl_WideInt tmp1, tmp2;
+#ifdef HAVE_ST_BLOCKS
+ Tcl_WideInt tmp3;
+#endif
+
Tcl_IncrRefCount(pathPtr);
ret = Tcl_FSStat(pathPtr, &buf);
Tcl_DecrRefCount(pathPtr);
if (ret != -1) {
#ifndef TCL_WIDE_INT_IS_LONG
-# define OUT_OF_RANGE(x) \
+# define OUT_OF_RANGE(x) \
(((Tcl_WideInt)(x)) < Tcl_LongAsWide(LONG_MIN) || \
((Tcl_WideInt)(x)) > Tcl_LongAsWide(LONG_MAX))
-#if defined(__GNUC__) && __GNUC__ >= 2
-/*
- * Workaround gcc warning of "comparison is always false due to limited range of
- * data type" in this macro by checking max type size, and when necessary ANDing
- * with the complement of ULONG_MAX instead of the comparison:
- */
-# define OUT_OF_URANGE(x) \
- ((((Tcl_WideUInt)(~ (__typeof__(x)) 0)) > (Tcl_WideUInt)ULONG_MAX) && \
- (((Tcl_WideUInt)(x)) & ~(Tcl_WideUInt)ULONG_MAX))
-#else
-# define OUT_OF_URANGE(x) \
- (((Tcl_WideUInt)(x)) > (Tcl_WideUInt)ULONG_MAX)
-#endif
+# define OUT_OF_URANGE(x) \
+ (((Tcl_WideUInt)(x)) > ((Tcl_WideUInt)ULONG_MAX))
/*
* Perform the result-buffer overflow check manually.
*
* Note that ino_t/ino64_t is unsigned...
+ *
+ * Workaround gcc warning of "comparison is always false due to limited range of
+ * data type" by assigning to tmp var of type Tcl_WideInt.
*/
- if (OUT_OF_URANGE(buf.st_ino) || OUT_OF_RANGE(buf.st_size)
+ tmp1 = (Tcl_WideInt) buf.st_ino;
+ tmp2 = (Tcl_WideInt) buf.st_size;
+#ifdef HAVE_ST_BLOCKS
+ tmp3 = (Tcl_WideInt) buf.st_blocks;
+#endif
+
+ if (OUT_OF_URANGE(tmp1) || OUT_OF_RANGE(tmp2)
#ifdef HAVE_ST_BLOCKS
- || OUT_OF_RANGE(buf.st_blocks)
+ || OUT_OF_RANGE(tmp3)
#endif
) {
#ifdef EFBIG