Skip to content

Commit 37161c5

Browse files
committed
fb: open fd in rw, don't cast mmap
1 parent 391b49f commit 37161c5

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/common/fb.nim

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,20 @@ const
2121
arr
2222

2323
proc fbclear*() =
24-
let fd = open("/dev/fb0", O_RDONLY)
24+
let fd = open("/dev/fb0", O_RDWR)
2525
if fd < 0:
2626
raise newException(IOError, "Unable to open framebuffer")
2727

2828
defer: discard fd.close()
2929

30-
let fbMap = cast[ptr UncheckedArray[uint16]](
31-
mmap(nil, FbSize, PROT_READ or PROT_WRITE, MAP_SHARED, fd, 0)
32-
)
30+
let fbMap = mmap(nil, FbSize, PROT_READ or PROT_WRITE, MAP_SHARED, fd, 0)
3331

34-
if fbMap == cast[ptr UncheckedArray[uint16]](MAP_FAILED):
32+
if fbMap == MAP_FAILED:
3533
raise newException(IOError, "Unable to map framebuffer")
3634

3735
defer: discard munmap(fbMap, FbSize)
3836

3937
zeroMem(fbMap, FbSize)
40-
4138

4239
proc fbscreenshot*(output: string) =
4340
let fbFile = open("/dev/fb0", fmRead)

0 commit comments

Comments
 (0)