Skip to content

Commit 96086c3

Browse files
authored
Fix const discard warnings in fletcher32 (#728)
When accessing a pointer from a `const` typed-memoryview, make sure the pointer itself is also typed as `const` to avoid compiler warnings about discarding `const`.
1 parent 197a03d commit 96086c3

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

docs/release.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,25 @@ Release notes
1414

1515
.. _unreleased:
1616

17+
Unreleased
18+
----------
19+
20+
Enhancements
21+
~~~~~~~~~~~~
22+
23+
Improvements
24+
~~~~~~~~~~~~
25+
26+
Fixes
27+
~~~~~
28+
29+
* Fix ``const`` discard warnings in ``fletcher32``.
30+
By :user:`John Kirkham <jakirkham>`, :issue:`728`
31+
32+
Maintenance
33+
~~~~~~~~~~~
34+
35+
1736
0.16.0
1837
------
1938

numcodecs/fletcher32.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Fletcher32(Codec):
7676
"""Return buffer plus a footer with the fletcher checksum (4-bytes)"""
7777
buf = ensure_contiguous_ndarray(buf).ravel().view('uint8')
7878
cdef const uint8_t[::1] b_mv = buf
79-
cdef uint8_t* b_ptr = &b_mv[0]
79+
cdef const uint8_t* b_ptr = &b_mv[0]
8080
cdef Py_ssize_t b_len = len(b_mv)
8181

8282
cdef Py_ssize_t out_len = b_len + FOOTER_LENGTH
@@ -92,7 +92,7 @@ class Fletcher32(Codec):
9292
"""Check fletcher checksum, and return buffer without it"""
9393
b = ensure_contiguous_ndarray(buf).view('uint8')
9494
cdef const uint8_t[::1] b_mv = b
95-
cdef uint8_t* b_ptr = &b_mv[0]
95+
cdef const uint8_t* b_ptr = &b_mv[0]
9696
cdef Py_ssize_t b_len = len(b_mv)
9797

9898
val = _fletcher32(b_mv[:-FOOTER_LENGTH])

0 commit comments

Comments
 (0)