Skip to content

Commit 0eb3875

Browse files
committed
Merge pull request #16076 from bicycle1885/flush-return-nothing
make flush(stream) return nothing
2 parents 1a97f06 + 166115b commit 0eb3875

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

base/iostream.jl

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ function flush(s::IOStream)
3535
bad = ccall(:ios_flush, Cint, (Ptr{Void},), s.ios) != 0
3636
sigatomic_end()
3737
systemerror("flush", bad)
38-
s
3938
end
4039
iswritable(s::IOStream) = ccall(:ios_get_writable, Cint, (Ptr{Void},), s.ios)!=0
4140
isreadable(s::IOStream) = ccall(:ios_get_readable, Cint, (Ptr{Void},), s.ios)!=0

base/stream.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -831,14 +831,14 @@ end
831831

832832
function flush(s::LibuvStream)
833833
if isnull(s.sendbuf)
834-
return s
834+
return
835835
end
836836
buf = get(s.sendbuf)
837837
if nb_available(buf) > 0
838838
arr = takebuf_array(buf) # Array of UInt8s
839839
uv_write(s, arr)
840840
end
841-
return s
841+
return
842842
end
843843

844844
buffer_writes(s::LibuvStream, bufsize) = (s.sendbuf=PipeBuffer(bufsize); s)
@@ -1043,4 +1043,4 @@ end
10431043

10441044
# If buffer_writes is called, it will delay notifying waiters till a flush is called.
10451045
buffer_writes(s::BufferStream, bufsize=0) = (s.buffer_writes=true; s)
1046-
flush(s::BufferStream) = (notify(s.r_c; all=true); s)
1046+
flush(s::BufferStream) = (notify(s.r_c; all=true); nothing)

test/iobuffer.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ let bstream = BufferStream()
197197
a = rand(UInt8,10)
198198
write(bstream,a)
199199
@test !eof(bstream)
200-
flush(bstream)
200+
@test flush(bstream) === nothing
201201
b = read(bstream,UInt8)
202202
@test a[1] == b
203203
b = read(bstream,UInt8)

test/read.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,8 @@ f2 = Base.Filesystem.open(f, Base.Filesystem.JL_O_RDWR)
473473
@test skip(f2, 10) == f2
474474
@test eof(f1)
475475
@test eof(f2)
476-
@test write(f1, '*') == 1; @test flush(f1) == f1
476+
@test write(f1, '*') == 1
477+
@test flush(f1) === nothing
477478
@test !eof(f2)
478479
@test skip(f2, 1) == f2
479480
@test write(f2, '*') == 1

0 commit comments

Comments
 (0)