builtin,os: fix unused return C warnings for real (#9814)

pull/9833/head
Nicolas Sauzede 2021-04-20 16:28:58 +02:00 committed by GitHub
parent 0b0a5de9e5
commit 258be508f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 17 deletions

View File

@ -120,12 +120,12 @@ pub fn eprintln(s string) {
C.fprintf(C.stderr, c'%.*s\n', s.len, s.str) C.fprintf(C.stderr, c'%.*s\n', s.len, s.str)
} }
} $else { } $else {
_ := 0 mut n := 0
if s.str == 0 { if s.str == 0 {
_ = C.write(2, c'eprintln(NIL)\n', 14) n = C.write(2, c'eprintln(NIL)\n', 14)
} else { } else {
_ = C.write(2, s.str, s.len) n = C.write(2, s.str, s.len)
_ = C.write(2, c'\n', 1) n = C.write(2, c'\n', 1)
} }
} }
C.fflush(C.stderr) C.fflush(C.stderr)
@ -158,11 +158,11 @@ pub fn eprint(s string) {
C.fprintf(C.stderr, c'%.*s', s.len, s.str) C.fprintf(C.stderr, c'%.*s', s.len, s.str)
} }
} $else { } $else {
_ := 0 mut n := 0
if s.str == 0 { if s.str == 0 {
_ = C.write(2, c'eprint(NIL)', 11) n = C.write(2, c'eprint(NIL)', 11)
} else { } else {
_ = C.write(2, s.str, s.len) n = C.write(2, s.str, s.len)
} }
} }
C.fflush(C.stderr) C.fflush(C.stderr)
@ -172,7 +172,7 @@ pub fn eprint(s string) {
// print prints a message to stdout. Unlike `println` stdout is not automatically flushed. // print prints a message to stdout. Unlike `println` stdout is not automatically flushed.
// A call to `flush()` will flush the output buffer to stdout. // A call to `flush()` will flush the output buffer to stdout.
pub fn print(s string) { pub fn print(s string) {
_ := 0 mut n := 0
$if android { $if android {
C.fprintf(C.stdout, c'%.*s', s.len, s.str) C.fprintf(C.stdout, c'%.*s', s.len, s.str)
} $else $if ios { } $else $if ios {
@ -181,7 +181,7 @@ pub fn print(s string) {
} $else $if freestanding { } $else $if freestanding {
bare_print(s.str, u64(s.len)) bare_print(s.str, u64(s.len))
} $else { } $else {
_ = C.write(1, s.str, s.len) n = C.write(1, s.str, s.len)
} }
} }
@ -194,7 +194,7 @@ fn C.asl_log(voidptr, voidptr, int, charptr)
*/ */
// println prints a message with a line end, to stdout. stdout is flushed. // println prints a message with a line end, to stdout. stdout is flushed.
pub fn println(s string) { pub fn println(s string) {
_ := 0 mut n := 0
if s.str == 0 { if s.str == 0 {
$if android { $if android {
C.fprintf(C.stdout, c'println(NIL)\n') C.fprintf(C.stdout, c'println(NIL)\n')
@ -204,7 +204,7 @@ pub fn println(s string) {
bare_print(s.str, u64(s.len)) bare_print(s.str, u64(s.len))
bare_print(c'println(NIL)\n', 13) bare_print(c'println(NIL)\n', 13)
} $else { } $else {
_ = C.write(1, c'println(NIL)\n', 13) n = C.write(1, c'println(NIL)\n', 13)
} }
return return
} }
@ -216,8 +216,8 @@ pub fn println(s string) {
bare_print(s.str, u64(s.len)) bare_print(s.str, u64(s.len))
bare_print(c'\n', 1) bare_print(c'\n', 1)
} $else { } $else {
_ = C.write(1, s.str, s.len) n = C.write(1, s.str, s.len)
_ = C.write(1, c'\n', 1) n = C.write(1, c'\n', 1)
} }
} }

View File

@ -740,10 +740,11 @@ pub fn is_link(path string) bool {
// chdir changes the current working directory to the new directory in `path`. // chdir changes the current working directory to the new directory in `path`.
pub fn chdir(path string) { pub fn chdir(path string) {
mut n := 0
$if windows { $if windows {
C._wchdir(path.to_wide()) C._wchdir(path.to_wide())
} $else { } $else {
C.chdir(&char(path.str)) n = C.chdir(&char(path.str))
} }
} }

View File

@ -3,11 +3,12 @@ module os
fn C.setpgid(pid int, pgid int) int fn C.setpgid(pid int, pgid int) int
fn (mut p Process) unix_spawn_process() int { fn (mut p Process) unix_spawn_process() int {
mut n := 0
mut pipeset := [6]int{} mut pipeset := [6]int{}
if p.use_stdio_ctl { if p.use_stdio_ctl {
C.pipe(&pipeset[0]) // pipe read end 0 <- 1 pipe write end n = C.pipe(&pipeset[0]) // pipe read end 0 <- 1 pipe write end
C.pipe(&pipeset[2]) // pipe read end 2 <- 3 pipe write end n = C.pipe(&pipeset[2]) // pipe read end 2 <- 3 pipe write end
C.pipe(&pipeset[4]) // pipe read end 4 <- 5 pipe write end n = C.pipe(&pipeset[4]) // pipe read end 4 <- 5 pipe write end
} }
pid := fork() pid := fork()
if pid != 0 { if pid != 0 {