From d7e6a4f2f07464acfe4fe98b4e4038c67c7b2975 Mon Sep 17 00:00:00 2001 From: Vince Harron Date: Wed, 13 May 2015 00:25:54 +0000 Subject: Fixed a ton of gcc compile warnings Removed some unused variables, added some consts, changed some casts to const_cast. I don't think any of these changes are very controversial. Differential Revision: http://reviews.llvm.org/D9674 llvm-svn: 237218 --- lldb/source/Interpreter/ScriptInterpreterPython.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp') diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index 7ecef310b5c..1baf484cc79 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -382,6 +382,13 @@ ScriptInterpreterPython::LeaveSession () m_session_is_active = false; } +static PyObject * +PyFile_FromFile_Const(FILE *fp, const char *name, const char *mode, int (*close)(FILE *)) +{ + // Read through the Python source, doesn't seem to modify these strings + return PyFile_FromFile(fp, const_cast(name), const_cast(mode), close); +} + bool ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags, FILE *in, @@ -447,7 +454,7 @@ ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags, { m_saved_stdin.Reset(sys_module_dict.GetItemForKey("stdin")); // This call can deadlock your process if the file is locked - PyObject *new_file = PyFile_FromFile (in, (char *) "", (char *) "r", nullptr); + PyObject *new_file = PyFile_FromFile_Const (in, "", "r", nullptr); sys_module_dict.SetItemForKey ("stdin", new_file); Py_DECREF (new_file); } @@ -459,7 +466,7 @@ ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags, { m_saved_stdout.Reset(sys_module_dict.GetItemForKey("stdout")); - PyObject *new_file = PyFile_FromFile (out, (char *) "", (char *) "w", nullptr); + PyObject *new_file = PyFile_FromFile_Const (out, "", "w", nullptr); sys_module_dict.SetItemForKey ("stdout", new_file); Py_DECREF (new_file); } @@ -472,7 +479,7 @@ ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags, { m_saved_stderr.Reset(sys_module_dict.GetItemForKey("stderr")); - PyObject *new_file = PyFile_FromFile (err, (char *) "", (char *) "w", nullptr); + PyObject *new_file = PyFile_FromFile_Const (err, "", "w", nullptr); sys_module_dict.SetItemForKey ("stderr", new_file); Py_DECREF (new_file); } -- cgit v1.2.3