aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFrank Busse <bb0xfb@gmail.com>2019-08-15 12:18:57 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2019-08-15 15:50:46 +0100
commitae521364b55dc4e47dc9248cdc6035e7bfa3070e (patch)
tree77dec04ecd8effcbb9c99b80dca8b6d1b2a84e3e
parent8c99f6e1ba894ee1b10fdbc290b8834ef3a6550c (diff)
downloadklee-ae521364b55dc4e47dc9248cdc6035e7bfa3070e.tar.gz
replace fprintf with fputs/fputc
-rw-r--r--tools/gen-bout/gen-bout.cpp30
-rw-r--r--tools/klee-replay/file-creator.c18
-rw-r--r--tools/klee-replay/klee-replay.c42
3 files changed, 42 insertions, 48 deletions
diff --git a/tools/gen-bout/gen-bout.cpp b/tools/gen-bout/gen-bout.cpp
index 477c302b..f6f11f2a 100644
--- a/tools/gen-bout/gen-bout.cpp
+++ b/tools/gen-bout/gen-bout.cpp
@@ -49,23 +49,15 @@ static void push_range(KTest *b, const char *name, unsigned value) {
void print_usage_and_exit(char *program_name) {
fprintf(stderr,
- "%s: Tool for generating a ktest file from concrete input, "
- "e.g., for using a concrete crashing input as a ktest seed.\n"
- "Usage: %s <arguments>\n"
- " <arguments> are the command-line arguments of the "
- "program, with the following treated as special:\n"
- " --bout-file <filename> - Specifying the output "
- "file name for the ktest file (default: file.bout).\n"
- " --sym-stdin <filename> - Specifying a file that "
- "is the content of stdin (only once).\n"
- " --sym-stdout <filename> - Specifying a file that "
- "is the content of stdout (only once).\n"
- " --sym-file <filename> - Specifying a file that "
- "is the content of a file named A provided for the program "
- "(only once).\n"
- " Ex: %s -o -p -q file1 --sym-stdin file2 --sym-file file3 "
- "--sym-stdout file4\n",
- program_name, program_name, program_name);
+ "%s: Tool for generating a ktest file from concrete input, e.g., for using a concrete crashing input as a ktest seed.\n"
+ "Usage: %s <arguments>\n"
+ " <arguments> are the command-line arguments of the program, with the following treated as special:\n"
+ " --bout-file <filename> - Specifying the output file name for the ktest file (default: file.bout).\n"
+ " --sym-stdin <filename> - Specifying a file that is the content of stdin (only once).\n"
+ " --sym-stdout <filename> - Specifying a file that is the content of stdout (only once).\n"
+ " --sym-file <filename> - Specifying a file that is the content of a file named A provided for the program (only once).\n"
+ " Ex: %s -o -p -q file1 --sym-stdin file2 --sym-file file3 --sym-stdout file4\n",
+ program_name, program_name, program_name);
exit(1);
}
@@ -163,7 +155,7 @@ int main(int argc, char *argv[]) {
unsigned char *file_content, *fptr;
if ((file_content = (unsigned char *)malloc(nbytes)) == NULL) {
- fprintf(stderr, "Memory allocation failure\n");
+ fputs("Memory allocation failure\n", stderr);
exit(1);
}
@@ -204,7 +196,7 @@ int main(int argc, char *argv[]) {
unsigned char *file_content, *fptr;
if ((file_content = (unsigned char *)malloc(file_stat.st_size)) == NULL) {
- fprintf(stderr, "Memory allocation failure\n");
+ fputs("Memory allocation failure\n", stderr);
exit(1);
}
diff --git a/tools/klee-replay/file-creator.c b/tools/klee-replay/file-creator.c
index a41e02e2..f843a1eb 100644
--- a/tools/klee-replay/file-creator.c
+++ b/tools/klee-replay/file-creator.c
@@ -148,7 +148,7 @@ static int create_char_dev(const char *fname, exe_disk_file_t *dfile,
}
if (symlink(name, fname) == -1) {
- fprintf(stderr, "KLEE-REPLAY: ERROR: unable to create sym link to tty\n");
+ fputs("KLEE-REPLAY: ERROR: unable to create sym link to tty\n", stderr);
perror("symlink");
}
@@ -162,7 +162,7 @@ static int create_char_dev(const char *fname, exe_disk_file_t *dfile,
} else if (pid == 0) {
close(amaster);
- fprintf(stderr, "KLEE-REPLAY: NOTE: pty slave: setting raw mode\n");
+ fputs("KLEE-REPLAY: NOTE: pty slave: setting raw mode\n", stderr);
{
struct termios mode;
@@ -185,14 +185,14 @@ static int create_char_dev(const char *fname, exe_disk_file_t *dfile,
} else {
unsigned pos = 0;
int status;
- fprintf(stderr, "KLEE-REPLAY: NOTE: pty master: starting\n");
+ fputs("KLEE-REPLAY: NOTE: pty master: starting\n", stderr);
close(aslave);
while (pos < flen) {
ssize_t res = write(amaster, &contents[pos], flen - pos);
if (res<0) {
if (errno != EINTR) {
- fprintf(stderr, "KLEE-REPLAY: NOTE: pty master: write error\n");
+ fputs("KLEE-REPLAY: NOTE: pty master: write error\n", stderr);
perror("errno");
break;
}
@@ -205,7 +205,7 @@ static int create_char_dev(const char *fname, exe_disk_file_t *dfile,
if (wait_for_timeout_or_exit(pid, "pty master", &status))
goto pty_exit;
- fprintf(stderr, "KLEE-REPLAY: NOTE: pty master: closing & waiting\n");
+ fputs("KLEE-REPLAY: NOTE: pty master: closing & waiting\n", stderr);
close(amaster);
while (1) {
pid_t res = waitpid(pid, &status, 0);
@@ -219,7 +219,7 @@ static int create_char_dev(const char *fname, exe_disk_file_t *dfile,
pty_exit:
close(amaster);
- fprintf(stderr, "KLEE-REPLAY: NOTE: pty master: done\n");
+ fputs("KLEE-REPLAY: NOTE: pty master: done\n", stderr);
process_status(status, 0, "PTY MASTER");
}
}
@@ -250,7 +250,7 @@ static int create_pipe(const char *fname, exe_disk_file_t *dfile,
} else {
unsigned pos = 0;
int status;
- fprintf(stderr, "KLEE-REPLAY: NOTE: pipe master: starting\n");
+ fputs("KLEE-REPLAY: NOTE: pipe master: starting\n", stderr);
close(fds[0]);
while (pos < flen) {
@@ -266,7 +266,7 @@ static int create_pipe(const char *fname, exe_disk_file_t *dfile,
if (wait_for_timeout_or_exit(pid, "pipe master", &status))
goto pipe_exit;
- fprintf(stderr, "KLEE-REPLAY: NOTE: pipe master: closing & waiting\n");
+ fputs("KLEE-REPLAY: NOTE: pipe master: closing & waiting\n", stderr);
close(fds[1]);
while (1) {
pid_t res = waitpid(pid, &status, 0);
@@ -280,7 +280,7 @@ static int create_pipe(const char *fname, exe_disk_file_t *dfile,
pipe_exit:
close(fds[1]);
- fprintf(stderr, "KLEE-REPLAY: NOTE: pipe master: done\n");
+ fputs("KLEE-REPLAY: NOTE: pipe master: done\n", stderr);
process_status(status, 0, "PTY MASTER");
}
}
diff --git a/tools/klee-replay/klee-replay.c b/tools/klee-replay/klee-replay.c
index 456c477d..1d35079f 100644
--- a/tools/klee-replay/klee-replay.c
+++ b/tools/klee-replay/klee-replay.c
@@ -53,10 +53,10 @@ static struct option long_options[] = {
};
static void stop_monitored(int process) {
- fprintf(stderr, "KLEE-REPLAY: NOTE: TIMEOUT: ATTEMPTING GDB EXIT\n");
+ fputs("KLEE-REPLAY: NOTE: TIMEOUT: ATTEMPTING GDB EXIT\n", stderr);
int pid = fork();
if (pid < 0) {
- fprintf(stderr, "KLEE-REPLAY: ERROR: gdb_exit: fork failed\n");
+ fputs("KLEE-REPLAY: ERROR: gdb_exit: fork failed\n", stderr);
} else if (pid == 0) {
/* Run gdb in a child process. */
const char *gdbargs[] = {
@@ -75,11 +75,11 @@ static void stop_monitored(int process) {
/* Make sure gdb doesn't talk to the user */
close(0);
- fprintf(stderr, "KLEE-REPLAY: NOTE: RUNNING GDB: ");
+ fputs("KLEE-REPLAY: NOTE: RUNNING GDB: ", stderr);
unsigned i;
for (i = 0; i != 5; ++i)
fprintf(stderr, "%s ", gdbargs[i]);
- fprintf(stderr, "\n");
+ fputc('\n', stderr);
execvp(gdbargs[0], (char * const *) gdbargs);
perror("execvp");
@@ -252,7 +252,7 @@ void ensure_capsyschroot(const char *executable) {
cap_get_flag(caps, CAP_SYS_CHROOT, CAP_PERMITTED, &chroot_permitted);
cap_get_flag(caps, CAP_SYS_CHROOT, CAP_EFFECTIVE, &chroot_effective);
if (chroot_permitted != CAP_SET || chroot_effective != CAP_SET) {
- fprintf(stderr, "KLEE-REPLAY: ERROR: chroot: No CAP_SYS_CHROOT capability.\n");
+ fputs("KLEE-REPLAY: ERROR: chroot: No CAP_SYS_CHROOT capability.\n", stderr);
exit(1);
}
cap_free(caps);
@@ -260,14 +260,16 @@ void ensure_capsyschroot(const char *executable) {
#endif
static void usage(void) {
- fprintf(stderr, "Usage: %s [option]... <executable> <ktest-file>...\n", progname);
- fprintf(stderr, " or: %s --create-files-only <ktest-file>\n", progname);
- fprintf(stderr, "\n");
- fprintf(stderr, "-r, --chroot-to-dir=DIR use chroot jail, requires CAP_SYS_CHROOT\n");
- fprintf(stderr, "-k, --keep-replay-dir do not delete replay directory\n");
- fprintf(stderr, "-h, --help display this help and exit\n");
- fprintf(stderr, "\n");
- fprintf(stderr, "Use KLEE_REPLAY_TIMEOUT environment variable to set a timeout (in seconds).\n");
+ fprintf(stderr,
+ "Usage: %s [option]... <executable> <ktest-file>...\n"
+ " or: %s --create-files-only <ktest-file>\n"
+ "\n"
+ "-r, --chroot-to-dir=DIR use chroot jail, requires CAP_SYS_CHROOT\n"
+ "-k, --keep-replay-dir do not delete replay directory\n"
+ "-h, --help display this help and exit\n"
+ "\n"
+ "Use KLEE_REPLAY_TIMEOUT environment variable to set a timeout (in seconds).\n",
+ progname, progname);
exit(1);
}
@@ -331,7 +333,7 @@ int main(int argc, char** argv) {
/* rootdir should be a prefix of executable's path. */
if (rootdir && strstr(executable, rootdir) != executable) {
- fprintf(stderr, "KLEE-REPLAY: ERROR: chroot: root dir should be a parent dir of executable.\n");
+ fputs("KLEE-REPLAY: ERROR: chroot: root dir should be a parent dir of executable.\n", stderr);
exit(1);
}
@@ -361,15 +363,15 @@ int main(int argc, char** argv) {
prg_argv[0] = argv[optind];
klee_init_env(&prg_argc, &prg_argv);
if (idx > 2)
- fprintf(stderr, "\n");
- fprintf(stderr, "KLEE-REPLAY: NOTE: Test file: %s\n", input_fname);
- fprintf(stderr, "KLEE-REPLAY: NOTE: Arguments: ");
+ fputc('\n', stderr);
+ fprintf(stderr, "KLEE-REPLAY: NOTE: Test file: %s\n"
+ "KLEE-REPLAY: NOTE: Arguments: ", input_fname);
for (i=0; i != (unsigned) prg_argc; ++i) {
char *s = prg_argv[i];
if (s[0]=='A' && s[1] && !s[2]) s[1] = '\0';
fprintf(stderr, "\"%s\" ", prg_argv[i]);
}
- fprintf(stderr, "\n");
+ fputc('\n', stderr);
/* Create the input files, pipes, etc. */
replay_create_files(&__exe_fs);
@@ -431,7 +433,7 @@ void klee_warning_once(char *name) {
unsigned klee_assume(uintptr_t x) {
if (!x) {
- fprintf(stderr, "KLEE-REPLAY: klee_assume(0)!\n");
+ fputs("KLEE-REPLAY: klee_assume(0)!\n", stderr);
}
return 0;
}
@@ -482,7 +484,7 @@ int klee_range(int start, int end, const char* name) {
int r;
if (start >= end) {
- fprintf(stderr, "KLEE-REPLAY: ERROR: klee_range: invalid range\n");
+ fputs("KLEE-REPLAY: ERROR: klee_range: invalid range\n", stderr);
exit(1);
}