pkg/csource: init res var in generated call

It seems that gcc in ubuntu on travis got dumber:

<stdin>: In function ‘execute_call’:
<stdin>:1741:6: error: ‘res’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
cc1: all warnings being treated as errors
compiler invocation: arm-linux-gnueabi-gcc [-o /tmp/syz-executor675297211 -DGOOS_linux=1 -DGOARCH_arm=1 -DHOSTGOOS_linux=1 -x c - -O2 -pthread -Wall -Werror -Wparentheses -Wframe-larger-than=16384 -D__LINUX_ARM_ARCH__=6 -march=armv6 -static -Wno-overflow]

https://travis-ci.com/github/dvyukov/syzkaller/jobs/327487382

Though, we generate the same code and res seems to be initialized on all paths.

Initialize it explicitly.
This commit is contained in:
Dmitry Vyukov 2020-05-04 19:00:30 +02:00
parent 71db69869e
commit 9941337c5f

View File

@ -116,7 +116,7 @@ func (ctx *context) generateSyscalls(calls []string, hasVars bool) string {
}
} else {
if hasVars || opts.Trace {
fmt.Fprintf(buf, "\tintptr_t res;")
fmt.Fprintf(buf, "\tintptr_t res = 0;\n")
}
fmt.Fprintf(buf, "\tswitch (call) {\n")
for i, c := range calls {