mirror of
https://github.com/reactos/syzkaller-ros.git
synced 2025-03-03 08:57:06 +00:00
csource: compile with -Werror
Check for compiler warnings during compilation. Don't require -std=c99. Fix existing compiler warnings.
This commit is contained in:
parent
43d5c364a2
commit
c5f38186d2
@ -49,8 +49,9 @@ const int kRetryStatus = 69;
|
||||
|
||||
__attribute__((noreturn)) void doexit(int status)
|
||||
{
|
||||
volatile unsigned i;
|
||||
syscall(__NR_exit_group, status);
|
||||
for (volatile unsigned i = 0;; i++) {
|
||||
for (i = 0;; i++) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -649,7 +650,6 @@ void loop()
|
||||
uint64_t start = current_time_ms();
|
||||
for (;;) {
|
||||
int res = waitpid(-1, &status, __WALL | WNOHANG);
|
||||
int errno0 = errno;
|
||||
if (res == pid)
|
||||
break;
|
||||
usleep(1000);
|
||||
|
@ -108,7 +108,7 @@ func generateTestFunc(w io.Writer, opts Options, calls []string, name string) {
|
||||
if !opts.Threaded && !opts.Collide {
|
||||
fmt.Fprintf(w, "void %v()\n{\n", name)
|
||||
if opts.Repro {
|
||||
fmt.Fprintf(w, "\twrite(1, \"executing program\\n\", strlen(\"executing program\\n\"));\n")
|
||||
fmt.Fprintf(w, "\tsyscall(SYS_write, 1, \"executing program\\n\", strlen(\"executing program\\n\"));\n")
|
||||
}
|
||||
fmt.Fprintf(w, "\tmemset(r, -1, sizeof(r));\n")
|
||||
for _, c := range calls {
|
||||
@ -131,7 +131,7 @@ func generateTestFunc(w io.Writer, opts Options, calls []string, name string) {
|
||||
fmt.Fprintf(w, "\tpthread_t th[%v];\n", 2*len(calls))
|
||||
fmt.Fprintf(w, "\n")
|
||||
if opts.Repro {
|
||||
fmt.Fprintf(w, "\twrite(1, \"executing program\\n\", strlen(\"executing program\\n\"));\n")
|
||||
fmt.Fprintf(w, "\tsyscall(SYS_write, 1, \"executing program\\n\", strlen(\"executing program\\n\"));\n")
|
||||
}
|
||||
fmt.Fprintf(w, "\tmemset(r, -1, sizeof(r));\n")
|
||||
fmt.Fprintf(w, "\tsrand(getpid());\n")
|
||||
@ -297,18 +297,18 @@ func preprocessCommonHeader(opts Options, handled map[string]int) (string, error
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Build builds a C/C++ program from source file src
|
||||
// and returns name of the resulting binary.
|
||||
func Build(src string) (string, error) {
|
||||
// Build builds a C/C++ program from source src and returns name of the resulting binary.
|
||||
// lang can be "c" or "c++".
|
||||
func Build(lang, src string) (string, error) {
|
||||
bin, err := ioutil.TempFile("", "syzkaller")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to create temp file: %v", err)
|
||||
}
|
||||
bin.Close()
|
||||
out, err := exec.Command("gcc", "-x", "c", "-std=gnu99", src, "-o", bin.Name(), "-pthread", "-static", "-O1", "-g").CombinedOutput()
|
||||
out, err := exec.Command("gcc", "-x", lang, "-Wall", "-Werror", src, "-o", bin.Name(), "-pthread", "-static", "-O1", "-g").CombinedOutput()
|
||||
if err != nil {
|
||||
// Some distributions don't have static libraries.
|
||||
out, err = exec.Command("gcc", "-x", "c++", "-std=gnu++11", src, "-o", bin.Name(), "-pthread", "-O1", "-g").CombinedOutput()
|
||||
out, err = exec.Command("gcc", "-x", lang, "-Wall", "-Werror", src, "-o", bin.Name(), "-pthread", "-O1", "-g").CombinedOutput()
|
||||
}
|
||||
if err != nil {
|
||||
os.Remove(bin.Name())
|
||||
|
@ -78,7 +78,7 @@ func testOne(t *testing.T, p *prog.Prog, opts Options) {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
defer os.Remove(srcf)
|
||||
bin, err := Build(srcf)
|
||||
bin, err := Build("c", srcf)
|
||||
if err != nil {
|
||||
t.Logf("program:\n%s\n", p.Serialize())
|
||||
t.Fatalf("%v", err)
|
||||
|
@ -59,8 +59,9 @@ const int kRetryStatus = 69;
|
||||
// So call the syscall directly.
|
||||
__attribute__((noreturn)) void doexit(int status)
|
||||
{
|
||||
volatile unsigned i;
|
||||
syscall(__NR_exit_group, status);
|
||||
for (volatile unsigned i = 0;; i++) {
|
||||
for (i = 0;; i++) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -693,7 +694,6 @@ void loop()
|
||||
uint64_t start = current_time_ms();
|
||||
for (;;) {
|
||||
int res = waitpid(-1, &status, __WALL | WNOHANG);
|
||||
int errno0 = errno;
|
||||
if (res == pid)
|
||||
break;
|
||||
usleep(1000);
|
||||
|
@ -30,7 +30,7 @@ func buildSource(t *testing.T, src []byte) string {
|
||||
}
|
||||
|
||||
func buildProgram(t *testing.T, src string) string {
|
||||
bin, err := csource.Build(src)
|
||||
bin, err := csource.Build("c++", src)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ func (ctx *context) repro(entries []*prog.LogEntry, crashStart int) (*Result, er
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
bin, err := csource.Build(srcf)
|
||||
bin, err := csource.Build("c", srcf)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user