formatting

SVN revision: 77704
This commit is contained in:
Mike Blumenkrantz 2012-10-10 07:31:26 +00:00
parent c5e5f1e5fb
commit 1cdf725b70
1 changed files with 196 additions and 188 deletions

View File

@ -90,7 +90,8 @@ precache(void)
fd = open(buf + 2, O_RDONLY); fd = open(buf + 2, O_RDONLY);
if (fd >= 0) if (fd >= 0)
{ {
while (read(fd, tbuf, 256 * 1024) > 0); while (read(fd, tbuf, 256 * 1024) > 0)
;
close(fd); close(fd);
} }
} }
@ -99,7 +100,8 @@ precache(void)
fd = open(buf + 2, O_RDONLY); fd = open(buf + 2, O_RDONLY);
if (fd >= 0) if (fd >= 0)
{ {
while (read(fd, tbuf, 256 * 1024) > 0); while (read(fd, tbuf, 256 * 1024) > 0)
;
close(fd); close(fd);
} }
} }
@ -134,7 +136,8 @@ find_valgrind(char *path, size_t path_len)
if (p) p_len = p - env; if (p) p_len = p - env;
else p_len = strlen(env); else p_len = strlen(env);
if (p_len <= 0) goto next; if (p_len <= 0) goto next;
else if (p_len + sizeof("/valgrind") >= path_len) goto next; else if (p_len + sizeof("/valgrind") >= path_len)
goto next;
memcpy(path, env, p_len); memcpy(path, env, p_len);
memcpy(path + p_len, "/valgrind", sizeof("/valgrind")); memcpy(path + p_len, "/valgrind", sizeof("/valgrind"));
if (access(path, X_OK | R_OK) == 0) return 1; if (access(path, X_OK | R_OK) == 0) return 1;
@ -146,7 +149,6 @@ next:
return 0; return 0;
} }
/* maximum number of arguments added above */ /* maximum number of arguments added above */
#define VALGRIND_MAX_ARGS 10 #define VALGRIND_MAX_ARGS 10
/* bitmask with all supported bits set */ /* bitmask with all supported bits set */
@ -163,6 +165,7 @@ valgrind_append(char **dst, int valgrind_gdbserver, int valgrind_mode, int valgr
switch (valgrind_tool) switch (valgrind_tool)
{ {
case 1: dst[i++] = "--tool=massif"; break; case 1: dst[i++] = "--tool=massif"; break;
case 2: dst[i++] = "--tool=callgrind"; break; case 2: dst[i++] = "--tool=callgrind"; break;
} }
return i; return i;
@ -193,7 +196,8 @@ valgrind_append(char **dst, int valgrind_gdbserver, int valgrind_mode, int valgr
static void static void
copy_args(char **dst, char **src, size_t count) copy_args(char **dst, char **src, size_t count)
{ {
for (; count > 0; count--, dst++, src++) *dst = *src; for (; count > 0; count--, dst++, src++)
*dst = *src;
} }
static void static void
@ -289,7 +293,8 @@ main(int argc, char **argv)
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
{ {
if (!strcmp(argv[i], "-no-precache")) do_precache = 0; if (!strcmp(argv[i], "-no-precache")) do_precache = 0;
else if (!strcmp(argv[i], "-valgrind-gdb")) valgrind_gdbserver = 1; else if (!strcmp(argv[i], "-valgrind-gdb"))
valgrind_gdbserver = 1;
else if (!strncmp(argv[i], "-valgrind", sizeof("-valgrind") - 1)) else if (!strncmp(argv[i], "-valgrind", sizeof("-valgrind") - 1))
{ {
const char *val = argv[i] + sizeof("-valgrind") - 1; const char *val = argv[i] + sizeof("-valgrind") - 1;
@ -313,8 +318,10 @@ main(int argc, char **argv)
else else
printf("Unknown valgrind option: %s\n", argv[i]); printf("Unknown valgrind option: %s\n", argv[i]);
} }
else if (!strcmp(argv[i], "-massif")) valgrind_tool = 1; else if (!strcmp(argv[i], "-massif"))
else if (!strcmp(argv[i], "-callgrind")) valgrind_tool = 2; valgrind_tool = 1;
else if (!strcmp(argv[i], "-callgrind"))
valgrind_tool = 2;
else if ((!strcmp(argv[i], "-h")) || else if ((!strcmp(argv[i], "-h")) ||
(!strcmp(argv[i], "-help")) || (!strcmp(argv[i], "-help")) ||
(!strcmp(argv[i], "--help"))) (!strcmp(argv[i], "--help")))
@ -493,3 +500,4 @@ done:
perror("execv"); perror("execv");
return -1; return -1;
} }