Skip to content

Commit

Permalink
libnfb-ext-python: [FIX] remove assert in read function
Browse files Browse the repository at this point in the history
  • Loading branch information
martinspinler committed Aug 23, 2024
1 parent 84e3493 commit 2e5eea9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ext/libnfb_ext_python/libnfb_ext_python/libnfb_ext_python.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@ cdef ssize_t nfb_pynfb_bus_read(void *p, void *buf, size_t nbyte, off_t offset)
cdef PyObject* _bus = <PyObject *> p
cdef object bus = <object> _bus
cdef bytes data
cdef ssize_t ret

nfb, comp_node, bus_node = bus
data = nfb.read(bus_node, comp_node, offset, nbyte)
assert len(data) == int(nbyte)
memcpy(buf, <const char*>data, nbyte)
ret = len(data)
if ret > int(nbyte):
ret = -1

return nbyte
if ret > 0:
memcpy(buf, <const char*>data, ret)

return ret

cdef ssize_t nfb_pynfb_bus_write(void *p, const void *buf, size_t nbyte, off_t offset) noexcept:
cdef PyObject* _bus = <PyObject *> p
Expand Down

0 comments on commit 2e5eea9

Please sign in to comment.