summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das>2009-06-30 00:56:29 (GMT)
committerdas <das>2009-06-30 00:56:29 (GMT)
commitcddcc530147879e27bcf91025fc6728fb087d8e2 (patch)
tree486c789f1ba88a841ef3162ce8911a86ac67a5ff
parent8f9b8fd63b4da5f6f27b46c438c89f2baa15f0e8 (diff)
downloadtk-cddcc530147879e27bcf91025fc6728fb087d8e2.zip
tk-cddcc530147879e27bcf91025fc6728fb087d8e2.tar.gz
tk-cddcc530147879e27bcf91025fc6728fb087d8e2.tar.bz2
* generic/tkInt.h: add assert macros for clang static
analyzer and redefine Tcl_Panic to assert after panic in clang PURIFY builds. * generic/tkImgPhInstance.c: small fixes to make clang static * generic/tkTextDisp.c: analyzer happier. * generic/tkConfig.c: add clang assert for false positives * generic/tkUndo.c: from static analyzer.
-rw-r--r--ChangeLog13
-rw-r--r--generic/tkConfig.c3
-rw-r--r--generic/tkImgPhInstance.c8
-rw-r--r--generic/tkInt.h16
-rw-r--r--generic/tkTextDisp.c6
-rw-r--r--generic/tkUndo.c3
6 files changed, 41 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index bf9a18f..9df2df9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-06-30 Daniel Steffen <das@users.sourceforge.net>
+
+ * generic/tkInt.h: add assert macros for clang static
+ analyzer and redefine Tcl_Panic to
+ assert after panic in clang PURIFY
+ builds.
+
+ * generic/tkImgPhInstance.c: small fixes to make clang static
+ * generic/tkTextDisp.c: analyzer happier.
+
+ * generic/tkConfig.c: add clang assert for false positives
+ * generic/tkUndo.c: from static analyzer.
+
2009-06-29 Daniel Steffen <das@users.sourceforge.net>
Merge of TkAqua Cocoa port <http://github.com/das/tcltk/tree/de-carbon>
diff --git a/generic/tkConfig.c b/generic/tkConfig.c
index 27a48cb..ccdfdb0 100644
--- a/generic/tkConfig.c
+++ b/generic/tkConfig.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkConfig.c,v 1.30 2009/02/03 23:55:47 nijtmans Exp $
+ * RCS: @(#) $Id: tkConfig.c,v 1.31 2009/06/30 00:56:29 das Exp $
*/
/*
@@ -1435,6 +1435,7 @@ Tk_RestoreSavedOptions(
if (specPtr->internalOffset >= 0) {
register char *ptr = (char *) &savePtr->items[i].internalForm;
+ CLANG_ASSERT(internalPtr);
switch (specPtr->type) {
case TK_OPTION_BOOLEAN:
*((int *) internalPtr) = *((int *) ptr);
diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c
index 07fa0c0..816169e 100644
--- a/generic/tkImgPhInstance.c
+++ b/generic/tkImgPhInstance.c
@@ -17,7 +17,7 @@
* Department of Computer Science,
* Australian National University.
*
- * RCS: @(#) $Id: tkImgPhInstance.c,v 1.2 2009/02/06 08:12:07 das Exp $
+ * RCS: @(#) $Id: tkImgPhInstance.c,v 1.3 2009/06/30 00:56:29 das Exp $
*/
#include "tkImgPhoto.h"
@@ -337,7 +337,11 @@ TkImgPhotoGet(
}
XFree((char *) visInfoPtr);
- sprintf(buf, ((mono) ? "%d": "%d/%d/%d"), nRed, nGreen, nBlue);
+ if (mono) {
+ sprintf(buf, "%d", nRed);
+ } else {
+ sprintf(buf, "%d/%d/%d", nRed, nGreen, nBlue);
+ }
instancePtr->defaultPalette = Tk_GetUid(buf);
/*
diff --git a/generic/tkInt.h b/generic/tkInt.h
index badad64..672160c 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: $Id: tkInt.h,v 1.103 2009/06/27 19:33:35 nijtmans Exp $
+ * RCS: $Id: tkInt.h,v 1.104 2009/06/30 00:56:29 das Exp $
*/
#ifndef _TKINT
@@ -982,6 +982,20 @@ MODULE_SCOPE Tcl_HashTable tkPredefBitmapTable;
#endif
/*
+ * Macros for clang static analyzer
+ */
+
+#if defined(PURIFY) && defined(__clang__) && !defined(CLANG_ASSERT)
+#include <assert.h>
+#define CLANG_ASSERT(x) assert(x)
+#define Tcl_PanicEx Tcl_Panic
+#undef Tcl_Panic
+#define Tcl_Panic(f, ...) Tcl_PanicEx(f,##__VA_ARGS__); CLANG_ASSERT(0)
+#elif !defined(CLANG_ASSERT)
+#define CLANG_ASSERT(x)
+#endif
+
+/*
* The following magic value is stored in the "send_event" field of FocusIn
* and FocusOut events. This allows us to separate "real" events coming from
* the server from those that we generated.
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 4d20b50..164fc5d 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkTextDisp.c,v 1.72 2008/12/09 21:22:56 dgp Exp $
+ * RCS: @(#) $Id: tkTextDisp.c,v 1.73 2009/06/30 00:56:29 das Exp $
*/
#include "tkInt.h"
@@ -6721,10 +6721,10 @@ DlineXOfIndex(
* coordinate. */
{
register TkTextDispChunk *chunkPtr = dlPtr->chunkPtr;
- int x;
+ int x = 0;
if (byteIndex == 0 || chunkPtr == NULL) {
- return 0;
+ return x;
}
/*
diff --git a/generic/tkUndo.c b/generic/tkUndo.c
index 8371f04..1150cef 100644
--- a/generic/tkUndo.c
+++ b/generic/tkUndo.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUndo.c,v 1.15 2009/02/06 08:12:07 das Exp $
+ * RCS: @(#) $Id: tkUndo.c,v 1.16 2009/06/30 00:56:29 das Exp $
*/
#include "tkInt.h"
@@ -394,6 +394,7 @@ TkUndoSetDepth(
prevelem = elem;
elem = elem->next;
}
+ CLANG_ASSERT(prevelem);
prevelem->next = NULL;
while (elem != NULL) {
prevelem = elem;