Skip to content

Commit cce612f

Browse files
committed
[WIP] [GR-57232] C warnigs as errors, take 2.
PullRequest: graalpython/3442
2 parents 72c3880 + 112935f commit cce612f

File tree

14 files changed

+28
-35
lines changed

14 files changed

+28
-35
lines changed

graalpython/com.oracle.graal.python.cext/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#
2929
cmake_minimum_required(VERSION 3.22)
3030
project(com.oracle.graal.python.cext)
31-
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
3231

3332
function(require_var var)
3433
if (NOT DEFINED ${var})
@@ -61,7 +60,11 @@ set(TARGET_LIBPYTHON "python-${LLVM_MODE}")
6160
# common variables and compile/link options (for all build targets)
6261
######################################################################
6362

64-
set(CFLAGS_WARNINGS -Wno-int-to-pointer-cast -Wno-int-conversion -Wno-void-pointer-to-int-cast
63+
set(CFLAGS_WARNINGS -Wall -Werror -Wno-unused-function -Wno-unused-variable -Wno-unused-const-variable
64+
-Wno-tautological-constant-out-of-range-compare # fileutils.c: wchar_t > MAX_UNICODE is always false on Windows
65+
-Wno-unused-but-set-variable # sqlite.c: BOOL bRc
66+
-Wno-ignored-pragmas # sre.c: #pragma optimize("agtw", on)
67+
-Wno-int-to-pointer-cast -Wno-int-conversion -Wno-void-pointer-to-int-cast
6568
-Wno-incompatible-pointer-types-discards-qualifiers -Wno-pointer-type-mismatch
6669
-Wno-braced-scalar-init -Wno-deprecated-declarations)
6770

graalpython/com.oracle.graal.python.cext/src/capi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ static inline int get_method_flags_wrapper(int flags) {
254254
return JWRAPPER_UNSUPPORTED;
255255
}
256256

257-
void register_native_slots(PyTypeObject* managed_class, PyGetSetDef* getsets, PyMemberDef* members);
257+
// looked up by NFI, so exported
258+
PyAPI_FUNC(void) register_native_slots(PyTypeObject* managed_class, PyGetSetDef* getsets, PyMemberDef* members);
258259

259260
// export the SizeT arg parse functions, because we use them in contrast to cpython on windows for core modules that we link dynamically
260261
PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, const char *, ...);

graalpython/com.oracle.graal.python.cext/src/import.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2551,7 +2551,10 @@ static struct PyModuleDef imp_module = {
25512551
PyMODINIT_FUNC
25522552
PyInit__imp(void)
25532553
{
2554-
return PyModuleDef_Init(&imp_module);
2554+
// GraalPy change: we intrinsify this module in Java, no one should call this directly,
2555+
// so to be safe we bail out
2556+
printf("Function PyInit__imp not implemented in GraalPy. The _imp module is available, but not implemented as extension.\n");
2557+
exit(-1);
25552558
}
25562559

25572560

graalpython/com.oracle.graal.python.cext/src/longobject.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,10 @@ PyLong_FromString(const char *str, char **pend, int base)
19811981
overflow = 1;
19821982
}
19831983

1984-
if (overflow) {
1984+
if (overflow || (error_if_nonzero && value != 0)) {
1985+
if (error_if_nonzero) {
1986+
base = 0;
1987+
}
19851988
PyObject* string = PyUnicode_FromStringAndSize(numberStart, digits);
19861989
PyObject* result = GraalPyTruffleLong_FromString(string, base, negative);
19871990
Py_DecRef(string);

graalpython/com.oracle.graal.python.cext/src/memoryobject.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ PyObject *
754754
PyMemoryView_FromBuffer(const Py_buffer *info)
755755
{
756756
// GraalPy change: different implementation
757-
Py_ssize_t ndim = info->ndim;
758757
if (info->buf == NULL) {
759758
PyErr_SetString(PyExc_ValueError,
760759
"PyMemoryView_FromBuffer(): info->buf must not be NULL");
@@ -3334,7 +3333,6 @@ PyTruffle_MemoryViewFromObject(PyObject *v, int flags)
33343333
if (PyObject_GetBuffer(v, buffer, flags) < 0) {
33353334
return NULL;
33363335
}
3337-
Py_ssize_t ndim = buffer->ndim;
33383336
int needs_release = 0;
33393337
if (buffer->obj != NULL) {
33403338
PyBufferProcs *pb;

graalpython/com.oracle.graal.python.cext/src/obmalloc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ int PyTruffle_AllocMemory(size_t size) {
8484
PyTruffle_Log(PY_TRUFFLE_LOG_CONFIG, "PyTruffle_AllocMemory: exceeding PyTruffle_NativeMemoryGCBarrier (%lu) with allocation of size %lu, current PyTruffle_AllocatedMemory: %lu\n", PyTruffle_NativeMemoryGCBarrier, size, PyTruffle_AllocatedMemory);
8585

8686
size_t delay = 0;
87-
int iteration = 0;
8887
for (int iteration = 0; iteration < MAX_COLLECTION_RETRIES; iteration++) {
8988
GraalPyTruffle_TriggerGC(delay);
9089
delay += COLLECTION_DELAY_INCREMENT;

graalpython/com.oracle.graal.python.cext/src/structseq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ _PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc,
532532
#endif // GraalPy change
533533

534534
if (PyType_Ready(type) < 0) {
535-
PyMem_Free(members);
535+
// GraalPy change: not initialized
536+
// PyMem_Free(members);
536537
return -1;
537538
}
538539
Py_INCREF(type);

graalpython/com.oracle.graal.python.cext/src/tupleobject.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ PyTuple_GetItem(PyObject *op, Py_ssize_t i) {
114114
PyErr_BadInternalCall();
115115
return NULL;
116116
}
117-
PyObject *res;
118117
PyObject **ob_item;
119118
if (points_to_py_handle_space(op)) {
120119
const PyObject *ptr = pointer_to_stub((PyObject *) op);
@@ -1363,7 +1362,6 @@ PyTruffleTuple_GetItems(PyObject *op)
13631362
#ifdef GRAALVM_PYTHON_LLVM_MANAGED
13641363
return GraalPy_get_PyTupleObject_ob_item((PyTupleObject*) op);
13651364
#else /* GRAALVM_PYTHON_LLVM_MANAGED */
1366-
PyObject *res;
13671365
PyObject **ob_item;
13681366
if (points_to_py_handle_space(op)) {
13691367
GraalPyVarObject *ptr = (GraalPyVarObject *) pointer_to_stub(op);

graalpython/com.oracle.graal.python.cext/src/typeobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5721,7 +5721,7 @@ type_add_members(PyTypeObject *type)
57215721
PyObject *dict = type->tp_dict;
57225722
for (; memb->name != NULL; memb++) {
57235723
// GraalPy change
5724-
if (GraalPyTruffleType_AddMember(type, type->tp_dict, memb->name, memb->type, memb->offset, (memb->flags & READONLY) == 0, memb->doc) < 0)
5724+
if (GraalPyTruffleType_AddMember(type, dict, memb->name, memb->type, memb->offset, (memb->flags & READONLY) == 0, memb->doc) < 0)
57255725
return -1;
57265726
}
57275727
return 0;
@@ -5740,7 +5740,7 @@ type_add_getset(PyTypeObject *type)
57405740
for (; gsp->name != NULL; gsp++) {
57415741
// GraalPy change
57425742
if (GraalPyTruffleType_AddGetSet(type,
5743-
type->tp_dict,
5743+
dict,
57445744
gsp->name,
57455745
gsp->get,
57465746
gsp->set,

graalpython/com.oracle.graal.python.hpy.llvm/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#
2929
cmake_minimum_required(VERSION 3.22)
3030
project(com.oracle.graal.python.hpy.llvm)
31-
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
3231

3332
function(require_var var)
3433
if (NOT DEFINED ${var})

0 commit comments

Comments
 (0)