From 80a2bc2ab0f8f831a45bba4bbbbad4b15cbf0645 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Fri, 1 Mar 2013 09:20:43 +0000 Subject: Fixed GCC warnings. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@342 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 10 +++ plugins/pychrysa/Makefile.am | 3 +- plugins/pychrysa/analysis/roptions.c | 6 +- plugins/pychrysa/arch/processor.c | 4 +- plugins/pychrysa/plugin.c | 129 ++++++++++++----------------------- plugins/pychrysa/quirks.c | 2 +- src/gui/menus/debug.c | 4 +- 7 files changed, 67 insertions(+), 91 deletions(-) diff --git a/ChangeLog b/ChangeLog index daab6e4..3e6fa6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +13-03-01 Cyrille Bagard + + * plugins/pychrysa/analysis/roptions.c: + * plugins/pychrysa/arch/processor.c: + * plugins/pychrysa/Makefile.am: + * plugins/pychrysa/plugin.c: + * plugins/pychrysa/quirks.c: + * src/gui/menus/debug.c: + Fix GCC warnings. + 13-02-24 Cyrille Bagard * src/analysis/disass/loop.c: diff --git a/plugins/pychrysa/Makefile.am b/plugins/pychrysa/Makefile.am index 4fe8a4e..148104f 100644 --- a/plugins/pychrysa/Makefile.am +++ b/plugins/pychrysa/Makefile.am @@ -22,7 +22,8 @@ pychrysa_la_LDFLAGS = -module -avoid-version $(LIBGTK_LIBS) $(LIBXML_LIBS) $(LIB -L../../src/plugins/.libs -lplugins -INCLUDES = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) +INCLUDES = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ + -I../../src AM_CPPFLAGS = diff --git a/plugins/pychrysa/analysis/roptions.c b/plugins/pychrysa/analysis/roptions.c index a2b72e1..5423f93 100644 --- a/plugins/pychrysa/analysis/roptions.c +++ b/plugins/pychrysa/analysis/roptions.c @@ -25,6 +25,9 @@ #include "roptions.h" +#include + + #include "../format/executable.h" @@ -89,7 +92,8 @@ static PyObject *py_rendering_options_new(PyTypeObject *type, PyObject *args, Py result = (py_rendering_options *)type->tp_alloc(type, 0); - _executable = py_executable_get_glib_instance(executable); + _executable = G_EXE_FORMAT(pygobject_get(executable)); + if (_executable == NULL) return NULL; g_object_ref(G_OBJECT(_executable)); result->glib = g_rendering_options_new(_executable); diff --git a/plugins/pychrysa/arch/processor.c b/plugins/pychrysa/arch/processor.c index cc1113a..f36b7f0 100644 --- a/plugins/pychrysa/arch/processor.c +++ b/plugins/pychrysa/arch/processor.c @@ -138,7 +138,7 @@ bool add_arch_processor_type_to_python_module(PyObject *module) Py_INCREF(&py_arch_processor_type_type); ret = PyModule_AddObject(module, "ArchProcessorType", (PyObject *)&py_arch_processor_type_type); - __test = &py_arch_processor_type_type; + __test = (PyObject *)&py_arch_processor_type_type; return (ret == 0); @@ -283,6 +283,6 @@ bool add_arch_processor_to_python_module(PyObject *module) result = add_arch_processor_type_to_python_module(module); - return (ret == 0); + return (ret == 0 && result); } diff --git a/plugins/pychrysa/plugin.c b/plugins/pychrysa/plugin.c index e2ba78b..dd2517b 100644 --- a/plugins/pychrysa/plugin.c +++ b/plugins/pychrysa/plugin.c @@ -28,6 +28,8 @@ #include +#include + #include "../../src/analysis/binary.h" #include "../../src/plugins/plugin-int.h" @@ -310,10 +312,10 @@ GPluginModule *g_python_plugin_new(const char *modname, const char *filename) G_PLUGIN_MODULE(result)->name = stradd(G_PLUGIN_MODULE(result)->name, ".py"); G_PLUGIN_MODULE(result)->filename = strdup(G_PLUGIN_MODULE(result)->name); - G_PLUGIN_MODULE(result)->init = g_python_plugin_do_init; - G_PLUGIN_MODULE(result)->get_action = g_python_plugin_get_action; + G_PLUGIN_MODULE(result)->init = (init_plugin_fc)g_python_plugin_do_init; + G_PLUGIN_MODULE(result)->get_action = (get_plugin_action_fc)g_python_plugin_get_action; - G_PLUGIN_MODULE(result)->is_matching = g_python_plugin_is_matching; + G_PLUGIN_MODULE(result)->is_matching = (is_matching_fc)g_python_plugin_is_matching; result->module = module; result->instance = instance; @@ -436,7 +438,7 @@ static MatchingFormatAction g_python_plugin_is_matching(const GPythonPlugin *plu args = PyTuple_New(2); PyTuple_SetItem(args, 0, PyString_FromString(*filename)); - PyTuple_SetItem(args, 1, PyByteArray_FromStringAndSize(*data, *length)); + PyTuple_SetItem(args, 1, PyByteArray_FromStringAndSize((char *)*data, *length)); value = run_python_method(plugin->instance, "is_matching", args); @@ -836,102 +838,61 @@ bool add_plugin_to_python_module(PyObject *module) { int ret; /* Bilan d'un appel */ + static PyMethodDef pychrysa_plugin_methods[] = { + { + "init", (PyCFunction)pychrysa_plugin_init, + METH_VARARGS, + "Initialize the plugin." + }, + { + "get_action", (PyCFunction)pychrysa_plugin_get_action, + METH_NOARGS, + "Register the plugin for given actions." + }, + { + "is_matching", (PyCFunction)pychrysa_plugin_is_matching, + METH_VARARGS, + "Define if the given file can be handled." + }, + { + "handle_debugger", (PyCFunction)pychrysa_plugin_handle_debugger, + METH_VARARGS, + "Be notify about debugger attaching or detaching." + }, + { + "run", (PyCFunction)pychrysa_plugin_run, + METH_VARARGS, + "Run the plugin for a specific action." + }, + { NULL } + }; -static PyMethodDef pychrysa_plugin_methods[] = { - { - "init", (PyCFunction)pychrysa_plugin_init, - METH_VARARGS, - "Initialize the plugin." - }, - { - "get_action", (PyCFunction)pychrysa_plugin_get_action, - METH_NOARGS, - "Register the plugin for given actions." - }, - { - "is_matching", (PyCFunction)pychrysa_plugin_is_matching, - METH_VARARGS, - "Define if the given file can be handled." - }, - { - "handle_debugger", (PyCFunction)pychrysa_plugin_handle_debugger, - METH_VARARGS, - "Be notify about debugger attaching or detaching." - }, - { - "run", (PyCFunction)pychrysa_plugin_run, - METH_VARARGS, - "Run the plugin for a specific action." - }, - NULL -}; - + static PyTypeObject pychrysa_plugin_type = { -static PyTypeObject pychrysa_plugin_type = { + PyObject_HEAD_INIT(NULL) - PyObject_HEAD_INIT(NULL) + .tp_name = "plugin.Plugin", + .tp_basicsize = sizeof(pychrysa_plugin), -#if PY_VERSION_HEX < 0x03000000 - 0, /*ob_size*/ -#endif + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - "plugin.Plugin", /* tp_name */ - sizeof(pychrysa_plugin), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved / tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "PyCHRYSA Plugin objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - pychrysa_plugin_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - (newfunc)pychrysa_plugin_new, /* tp_new */ -}; + .tp_doc = "PyChrysalide plugin objects", + .tp_methods = pychrysa_plugin_methods, + .tp_new = (newfunc)pychrysa_plugin_new + }; if (PyType_Ready(&pychrysa_plugin_type) < 0) return false; - if (!pychrysa_plugin_define_constants(pychrysa_plugin_type.tp_dict)) return false; - - - Py_INCREF(&pychrysa_plugin_type); - PyModule_AddObject(module, "Plugin", (PyObject *)&pychrysa_plugin_type); - - - return true; /* FIXME */ + ret = PyModule_AddObject(module, "Plugin", (PyObject *)&pychrysa_plugin_type); + return (ret == 0); } diff --git a/plugins/pychrysa/quirks.c b/plugins/pychrysa/quirks.c index 2813fb2..eee4027 100644 --- a/plugins/pychrysa/quirks.c +++ b/plugins/pychrysa/quirks.c @@ -56,7 +56,7 @@ static GQuark pygobject_wrapper_key_fake = 0; static void pygobject_data_free_fake(PyGObjectData_fake *data) { - PyGILState_STATE state; /* Etat interne de Python */ + //PyGILState_STATE state; /* Etat interne de Python */ GSList *iter; /* Boucle de parcours */ GSList *old; /* Sauvegarde avant libération */ diff --git a/src/gui/menus/debug.c b/src/gui/menus/debug.c index 666a605..eb58835 100644 --- a/src/gui/menus/debug.c +++ b/src/gui/menus/debug.c @@ -93,10 +93,10 @@ GtkWidget *build_menu_debug(GObject *ref, GtkAccelGroup *accgroup) static void mcb_debug_start_stop(GtkMenuItem *menuitem, GObject *ref) { - GLoadedBinary *binary; /* Edition courante */ + //GLoadedBinary *binary; /* Edition courante */ GBinaryDebugger *debugger; /* Module prêt à emploi */ - binary = (GLoadedBinary *)g_object_get_data(ref, "current_binary"); + //binary = (GLoadedBinary *)g_object_get_data(ref, "current_binary"); debugger = NULL;//get_main_debugger_for_binary(get_current_openida_project(), binary); if (debugger == NULL) -- cgit v0.11.2-87-g4458