69 lines
2.9 KiB
Diff
69 lines
2.9 KiB
Diff
From b92e5f1264fb53bbaa975c15682cb2293a16508b Mon Sep 17 00:00:00 2001
|
||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||
Date: Fri, 12 Jul 2019 18:40:47 +0200
|
||
Subject: [PATCH 1/2] blosc_extenion: constify char pointers for Py_BuildValue
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
|
||
This fixes warnings from the compiler:
|
||
|
||
blosc/blosc_extension.c: In function ‘PyBlosc_compressor_list’:
|
||
blosc/blosc_extension.c:104:8: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
|
||
104 | list = blosc_list_compressors();
|
||
| ^
|
||
blosc/blosc_extension.c: In function ‘PyBlosc_code_to_name’:
|
||
blosc/blosc_extension.c:123:40: warning: passing argument 2 of ‘blosc_compcode_to_compname’ from incompatible pointer type [-Wincompatible-pointer-types]
|
||
123 | if (blosc_compcode_to_compname(code, &name) < 0)
|
||
| ^~~~~
|
||
| |
|
||
| char **
|
||
In file included from blosc/blosc_extension.c:13:
|
||
/usr/include/blosc.h:389:72: note: expected ‘const char **’ but argument is of type ‘char **’
|
||
389 | BLOSC_EXPORT int blosc_compcode_to_compname(int compcode, const char **compname);
|
||
| ~~~~~~~~~~~~~^~~~~~~~
|
||
blosc/blosc_extension.c: In function ‘PyBlosc_get_clib’:
|
||
blosc/blosc_extension.c:345:8: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
|
||
345 | clib = blosc_cbuffer_complib(input);
|
||
| ^
|
||
|
||
https://docs.python.org/3/c-api/arg.html#c.Py_BuildValue
|
||
> When memory buffers are passed as parameters to supply data to build
|
||
> objects, as for the s and s# formats, the required data is
|
||
> copied. Buffers provided by the caller are never referenced by the
|
||
> objects created by Py_BuildValue().
|
||
---
|
||
blosc/blosc_extension.c | 6 +++---
|
||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||
|
||
diff --git a/blosc/blosc_extension.c b/blosc/blosc_extension.c
|
||
index 870581a217..237f2e46a7 100644
|
||
--- a/blosc/blosc_extension.c
|
||
+++ b/blosc/blosc_extension.c
|
||
@@ -99,7 +99,7 @@ PyDoc_STRVAR(compressor_list__doc__,
|
||
static PyObject *
|
||
PyBlosc_compressor_list(PyObject *self)
|
||
{
|
||
- char *list;
|
||
+ const char *list;
|
||
|
||
list = blosc_list_compressors();
|
||
|
||
@@ -115,7 +115,7 @@ static PyObject *
|
||
PyBlosc_code_to_name(PyObject *self, PyObject *args)
|
||
{
|
||
int code;
|
||
- char *name;
|
||
+ const char *name;
|
||
|
||
if (!PyArg_ParseTuple(args, "i:code_to_name", &code))
|
||
return NULL;
|
||
@@ -341,7 +341,7 @@ PyBlosc_get_clib(PyObject *self, PyObject *args)
|
||
{
|
||
void *input;
|
||
size_t cbytes;
|
||
- char *clib;
|
||
+ const char *clib;
|
||
|
||
/* require Python string object, typesize, clevel and shuffle agrs */
|
||
if (!PyArg_ParseTuple(args, "s#:get_clib", &input, &cbytes))
|