aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2011-06-03 11:28:20 +1000
committerSteve Bennett <steveb@workware.net.au>2011-06-03 11:34:00 +1000
commit878daf4a1b7442755d672664fe0a6f4eadbd992b (patch)
tree40d36188e85e7aa0c9fb5bbd2e188c72693af958
parentd32b0d91e91d3a20022826c7d81c700c375b578b (diff)
downloadjimtcl-878daf4a1b7442755d672664fe0a6f4eadbd992b.zip
jimtcl-878daf4a1b7442755d672664fe0a6f4eadbd992b.tar.gz
jimtcl-878daf4a1b7442755d672664fe0a6f4eadbd992b.tar.bz2
Fix some clang warnings
And also a potentially undefined integer left shift Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r--jim-exec.c8
-rw-r--r--jim.c7
-rw-r--r--linenoise.c4
3 files changed, 17 insertions, 2 deletions
diff --git a/jim-exec.c b/jim-exec.c
index 475cc5b..84dcd3b 100644
--- a/jim-exec.c
+++ b/jim-exec.c
@@ -35,6 +35,12 @@
extern char **environ;
+#if defined(__GNUC__) && !defined(__clang__)
+#define IGNORE_RC(EXPR) ((EXPR) < 0 ? -1 : 0)
+#else
+#define IGNORE_RC(EXPR) EXPR
+#endif
+
/* These two could be moved into the Tcl core */
static void Jim_SetResultErrno(Jim_Interp *interp, const char *msg)
{
@@ -899,7 +905,7 @@ badargs:
execvp(execName, &arg_array[firstArg]);
/* we really can ignore the error here! */
- write(2, execerr, execerrlen) < 0 ? -1 : 0;
+ IGNORE_RC(write(2, execerr, execerrlen));
_exit(127);
}
diff --git a/jim.c b/jim.c
index 58fcb84..b3eed2f 100644
--- a/jim.c
+++ b/jim.c
@@ -7047,13 +7047,18 @@ static int JimExprOpIntBin(Jim_Interp *interp, struct JimExprState *e)
unsigned long uA = (unsigned long)wA;
const unsigned int S = sizeof(unsigned long) * 8;
- wC = (unsigned long)((uA << wB) | (uA >> (S - wB)));
+ /* Shift left by the word size or more is undefined. */
+ wB %= S;
+
+ wC = (unsigned long)(uA << wB) | (uA >> (S - wB));
break;
}
case JIM_EXPROP_ROTR:{
unsigned long uA = (unsigned long)wA;
const unsigned int S = sizeof(unsigned long) * 8;
+ wB %= S;
+
wC = (unsigned long)((uA >> wB) | (uA << (S - wB)));
break;
}
diff --git a/linenoise.c b/linenoise.c
index 17000fa..2d1002d 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -211,7 +211,11 @@ struct current {
};
/* gcc/glibc insists that we care about the return code of write! */
+#if defined(__GNUC__) && !defined(__clang__)
#define IGNORE_RC(EXPR) ((EXPR) < 0 ? -1 : 0)
+#else
+#define IGNORE_RC(EXPR) EXPR
+#endif
/* This is fd_printf() on some systems, but use a different
* name to avoid conflicts