dynStructureAddr = &_DYNAMIC;
# endif
- if (dynStructureAddr == 0) {
+ if (0 == COVERT_DATAFLOW(dynStructureAddr)) {
/* _DYNAMIC symbol not resolved. */
return(0);
}
/* zero (otherwise a compiler might issue a warning). */
return FALSE;
# else
- return (dl_iterate_phdr == 0); /* implicit conversion to function ptr */
+ return 0 == COVERT_DATAFLOW(dl_iterate_phdr);
# endif
}
{
static struct link_map *cachedResult = 0;
- if (0 == (ptr_t)_DYNAMIC) {
+ if (0 == COVERT_DATAFLOW(_DYNAMIC)) {
/* _DYNAMIC symbol not resolved. */
return(0);
}
/* A tagging macro (for a code static analyzer) to indicate that the */
/* string obtained from an untrusted source (e.g., argv[], getenv) is */
/* safe to use in a vulnerable operation (e.g., open, exec). */
-#define TRUSTED_STRING(s) (s)
+#define TRUSTED_STRING(s) (char*)COVERT_DATAFLOW(s)
/* Get environment entry */
#ifdef GC_READ_ENV_FILE
# define GC_CLANG_PREREQ_FULL(major, minor, patchlevel) 0
#endif
+#ifdef LINT2
+ /* A macro (based on a tricky expression) to prevent false warnings */
+ /* like "Array compared to 0", "Comparison of identical expressions", */
+ /* "Untrusted loop bound" output by some static code analysis tools. */
+ /* The argument should not be a literal value. The result is */
+ /* converted to word type. (Actually, GC_word is used instead of */
+ /* word type as the latter might be undefined at the place of use.) */
+# define COVERT_DATAFLOW(w) (~(GC_word)(w)^(~(GC_word)0))
+#else
+# define COVERT_DATAFLOW(w) ((GC_word)(w))
+#endif
+
/* Machine dependent parameters. Some tuning parameters can be found */
/* near the top of gc_private.h. */
# endif
} else
# endif
- /* else */ if ((ptr_t)__data_start != 0) {
+ /* else */ if (COVERT_DATAFLOW(__data_start) != 0) {
GC_data_start = (ptr_t)(__data_start);
} else {
GC_data_start = (ptr_t)(data_start);
}
- if (GC_data_start != NULL) {
+ if (COVERT_DATAFLOW(GC_data_start) != 0) {
if ((word)GC_data_start > (word)data_end)
ABORT_ARG2("Wrong __data_start/_end pair",
": %p .. %p", (void *)GC_data_start, (void *)data_end);
/* Include gc_priv.h is done after including GC public headers, so */
/* that GC_BUILD has no effect on the public prototypes. */
-#include "private/gc_priv.h" /* for CLOCK_TYPE and GC_random */
+#include "private/gc_priv.h" /* for CLOCK_TYPE, COVERT_DATAFLOW, GC_random */
#ifdef LINT2
# undef rand
return 1;
}
if (argc == 2) {
- model_min = model_max = atoi(argv[1]);
+ model_min = model_max = (int)COVERT_DATAFLOW(atoi(argv[1]));
if (model_min < 0 || model_max > 2)
exit(2);
}
x = 0;
# endif
if (argc != 2
- || (n = atoi(argv[1])) <= 0
-# ifdef LINT2
- || n >= (int)(~0U >> 1) - 1
-# endif
- ) {
+ || (n = (int)COVERT_DATAFLOW(atoi(argv[1]))) <= 0) {
GC_printf("usage: test_cpp number-of-iterations\n"
"Assuming 10 iters\n");
n = 10;