Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly cast return types in environment functions #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions m3module.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ put_arg_on_stack(uint64_t *s, M3ValueType type, PyObject *arg)
}

static PyObject *
get_arg_from_stack(uint64_t *s, M3ValueType type)
get_arg_from_stack(const uint64_t *s, M3ValueType type)
{
switch (type) {
case c_m3Type_i32: return PyLong_FromLong( *(int32_t*)s); break;
Expand All @@ -113,7 +113,7 @@ M3_Environment_new_runtime(m3_environment *env, PyObject *stack_size_bytes)
Py_INCREF(env);
self->env = env;
self->r = m3_NewRuntime(env->e, n, NULL);
return self;
return (PyObject*)self;
}

static PyObject *
Expand All @@ -136,7 +136,7 @@ M3_Environment_parse_module(m3_environment *env, PyObject *bytes)
self->env = env;
self->m = m;
self->total_gas = self->current_gas = 0;
return self;
return (PyObject*)self;
}

static PyMethodDef M3_Environment_methods[] = {
Expand Down Expand Up @@ -188,7 +188,7 @@ M3_Runtime_find_function(m3_runtime *runtime, PyObject *name)
Py_INCREF(runtime);
self->f = func;
self->r = runtime->r;
return self;
return (PyObject*)self;
}

static PyObject *
Expand Down Expand Up @@ -437,13 +437,13 @@ get_result_from_stack(m3_function *func)
}

if (nRets == 1) {
return get_arg_from_stack(valptrs[0], m3_GetRetType(func->f, 0));
return get_arg_from_stack((uint64_t*)valptrs[0], m3_GetRetType(func->f, 0));
} else {
PyObject *ret = PyTuple_New(nRets);
if (ret) {
Py_ssize_t i;
for (i = 0; i < nRets; ++i) {
PyObject *val = get_arg_from_stack(valptrs[i], m3_GetRetType(func->f, i));
PyObject *val = get_arg_from_stack((uint64_t*)valptrs[i], m3_GetRetType(func->f, i));
PyTuple_SET_ITEM(ret, i, val);
}
}
Expand Down