Compiler warnings in ccache 3.2.3
Tom Lane <[email protected]> Sun, 16 Aug 2015 17:07:19 -0400
| Newsgroups | gmane.comp.compilers.ccache |
|---|---|
| Message-ID | <[email protected]> |
I got a few warnings about assignments of pointers to "bool" values. I think these are legitimate gripes, because on platforms where bool is only a byte wide, the net effect will be to assign the pointer's low-order byte to the bool. There's at least a 1-in-256 chance of a non-null pointer erroneously converting to a "false" boolean value (maybe more than that, if the pointer is likely to be aligned ...). I propose the attached patches to fix this. regards, tom lane _______________________________________________ ccache mailing list [email protected] https://lists.samba.org/mailman/listinfo/ccache
fix-bool-conversions.patch
(text/x-diff, 1.9 KB)
diff -c -r orig/ccache-3.2.3/ccache.c ccache-3.2.3/ccache.c
*** orig/ccache-3.2.3/ccache.c Sun Aug 16 08:12:05 2015
--- ccache-3.2.3/ccache.c Sun Aug 16 14:59:46 2015
***************
*** 1263,1269 ****
compiler_is_clang(struct args *args)
{
char *name = basename(args->argv[0]);
! bool is = strstr(name, "clang");
free(name);
return is;
}
--- 1263,1269 ----
compiler_is_clang(struct args *args)
{
char *name = basename(args->argv[0]);
! bool is = strstr(name, "clang") != NULL;
free(name);
return is;
}
diff -c -r orig/ccache-3.2.3/conf.c ccache-3.2.3/conf.c
*** orig/ccache-3.2.3/conf.c Sun Aug 16 08:12:05 2015
--- ccache-3.2.3/conf.c Sun Aug 16 15:01:12 2015
***************
*** 58,64 ****
char **value = (char **)result;
free(*value);
*value = subst_env_in_string(str, errmsg);
! return *value;
}
static bool
--- 58,64 ----
char **value = (char **)result;
free(*value);
*value = subst_env_in_string(str, errmsg);
! return *value != NULL;
}
static bool
diff -c -r orig/ccache-3.2.3/language.c ccache-3.2.3/language.c
*** orig/ccache-3.2.3/language.c Sun Aug 16 08:12:05 2015
--- ccache-3.2.3/language.c Sun Aug 16 15:01:01 2015
***************
*** 149,155 ****
bool
language_is_supported(const char *language)
{
! return p_language_for_language(language);
}
bool
--- 149,155 ----
bool
language_is_supported(const char *language)
{
! return p_language_for_language(language) != NULL;
}
bool
diff -c -r orig/ccache-3.2.3/util.c ccache-3.2.3/util.c
*** orig/ccache-3.2.3/util.c Sun Aug 16 08:12:05 2015
--- ccache-3.2.3/util.c Sun Aug 16 15:00:41 2015
***************
*** 1638,1644 ****
if (curly) {
if (*q != '}') {
*errmsg = format("syntax error: missing '}' after \"%s\"", p);
! return NULL;
}
}
--- 1638,1644 ----
if (curly) {
if (*q != '}') {
*errmsg = format("syntax error: missing '}' after \"%s\"", p);
! return false;
}
}