From 22351a6fb7c2ec2787188351118e1d3ea2691294 Mon Sep 17 00:00:00 2001 From: Nicolas Sauzede Date: Mon, 19 Apr 2021 13:14:27 +0200 Subject: [PATCH] builtin: remove `unused return` C warnings (#9797) --- Makefile | 4 ++-- vlib/builtin/builtin.c.v | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index d3f23001c9..225ab2e56c 100644 --- a/Makefile +++ b/Makefile @@ -80,11 +80,11 @@ endif all: latest_vc latest_tcc ifdef WIN32 $(CC) $(CFLAGS) -g -std=c99 -municode -w -o $(V) $(VC)/$(VCFILE) $(LDFLAGS) - $(V) -o v2.exe cmd/v + $(V) -o v2.exe $(VFLAGS) cmd/v move /y v2.exe v.exe else $(CC) $(CFLAGS) -g -std=gnu99 -w -o $(V) $(VC)/$(VCFILE) -lm -lpthread $(LDFLAGS) - $(V) -o v2.exe cmd/v + $(V) -o v2.exe $(VFLAGS) cmd/v mv -f v2.exe v endif @echo "V has been successfully built" diff --git a/vlib/builtin/builtin.c.v b/vlib/builtin/builtin.c.v index d88c229be8..4bfa0a5989 100644 --- a/vlib/builtin/builtin.c.v +++ b/vlib/builtin/builtin.c.v @@ -120,11 +120,12 @@ pub fn eprintln(s string) { C.fprintf(C.stderr, c'%.*s\n', s.len, s.str) } } $else { + _ := 0 if s.str == 0 { - C.write(2, c'eprintln(NIL)\n', 14) + _ = C.write(2, c'eprintln(NIL)\n', 14) } else { - C.write(2, s.str, s.len) - C.write(2, c'\n', 1) + _ = C.write(2, s.str, s.len) + _ = C.write(2, c'\n', 1) } } C.fflush(C.stderr) @@ -157,10 +158,11 @@ pub fn eprint(s string) { C.fprintf(C.stderr, c'%.*s', s.len, s.str) } } $else { + _ := 0 if s.str == 0 { - C.write(2, c'eprint(NIL)', 11) + _ = C.write(2, c'eprint(NIL)', 11) } else { - C.write(2, s.str, s.len) + _ = C.write(2, s.str, s.len) } } C.fflush(C.stderr) @@ -170,6 +172,7 @@ pub fn eprint(s string) { // print prints a message to stdout. Unlike `println` stdout is not automatically flushed. // A call to `flush()` will flush the output buffer to stdout. pub fn print(s string) { + _ := 0 $if android { C.fprintf(C.stdout, c'%.*s', s.len, s.str) } $else $if ios { @@ -178,7 +181,7 @@ pub fn print(s string) { } $else $if freestanding { bare_print(s.str, u64(s.len)) } $else { - C.write(1, s.str, s.len) + _ = C.write(1, s.str, s.len) } } @@ -191,6 +194,7 @@ fn C.asl_log(voidptr, voidptr, int, charptr) */ // println prints a message with a line end, to stdout. stdout is flushed. pub fn println(s string) { + _ := 0 if s.str == 0 { $if android { C.fprintf(C.stdout, c'println(NIL)\n') @@ -200,7 +204,7 @@ pub fn println(s string) { bare_print(s.str, u64(s.len)) bare_print(c'println(NIL)\n', 13) } $else { - C.write(1, c'println(NIL)\n', 13) + _ = C.write(1, c'println(NIL)\n', 13) } return } @@ -212,8 +216,8 @@ pub fn println(s string) { bare_print(s.str, u64(s.len)) bare_print(c'\n', 1) } $else { - C.write(1, s.str, s.len) - C.write(1, c'\n', 1) + _ = C.write(1, s.str, s.len) + _ = C.write(1, c'\n', 1) } }