Fix strchr call triggering gcc 4.3 & 4.4 bug

Replacing the strchr call with two variables through a strstr call.
Calling strchr with two variables triggers a gcc 4.3/4.4
bug when used in combination with -Wlogical-op and at least -O1.
This commit is contained in:
Stefan Berger 2011-11-15 12:48:07 -05:00
parent c2cc02ea98
commit 39d91e9f88

View File

@ -466,7 +466,11 @@ virBufferEscape(virBufferPtr buf, const char *toescape,
cur = str; cur = str;
out = escaped; out = escaped;
while (*cur != 0) { while (*cur != 0) {
if (strchr(toescape, *cur)) /* strchr work-around for gcc 4.3 & 4.4 bug with -Wlogical-op
* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36513
*/
char needle[2] = { *cur, 0 };
if (strstr(toescape, needle))
*out++ = '\\'; *out++ = '\\';
*out++ = *cur; *out++ = *cur;
cur++; cur++;