Wrap PyObject_Get/HasAttrString in a function with second arg having const qualifier.
authorSiva Chandra <sivachandra@chromium.org>
Wed, 4 Jun 2014 17:50:11 +0000 (10:50 -0700)
committerSiva Chandra <sivachandra@chromium.org>
Tue, 10 Jun 2014 18:52:12 +0000 (11:52 -0700)
This is done to avoid errors when compiled with -Werror against Python-2.4
which did not have the const qualifier for the second argument of these
functions.

gdb/
* python/python-internal.h (gdb_PyObject_GetAttrString)
(gdb_PyObject_HasAttrString): New inline function definitions.
* py-value.c (get_field_flag): Remove the now unnecessary cast to
char * of the second argument to PyObject_GetAttrString.

gdb/ChangeLog
gdb/python/py-value.c
gdb/python/python-internal.h

index 61464c823923f7e61945b590ee8d5bb750cec2bd..9fd45e0c3d1b4616ca22784f39a6bfc443a8284e 100644 (file)
@@ -1,3 +1,10 @@
+2014-06-10  Siva Chandra Reddy  <sivachandra@google.com>
+
+       * python/python-internal.h (gdb_PyObject_GetAttrString)
+       (gdb_PyObject_HasAttrString): New inline function definitions.
+       * py-value.c (get_field_flag): Remove the now unnecessary cast to
+       char * of the second argument to PyObject_GetAttrString.
+       
 2014-06-10  Joel Brobecker  <brobecker@adacore.com>
 
        * serial.c (serial_write): Fix index of character to be printed
index 54da67a226ee238250c2d8e3767d64883725ad7c..8532da69da46c4e0b117288c6a99444b6aa1802b 100644 (file)
@@ -554,8 +554,7 @@ static int
 get_field_flag (PyObject *field, const char *flag_name)
 {
   int flag_value;
-  /* Python 2.4 did not have a 'const' here.  */
-  PyObject *flag_object = PyObject_GetAttrString (field, (char *) flag_name);
+  PyObject *flag_object = PyObject_GetAttrString (field, flag_name);
 
   if (flag_object == NULL)
     return -1;
index 9c06621cf304b605a379f6348c9024b1871746d4..0198e9d2944dfce72b01860d6208a6a92fc0dbdf 100644 (file)
@@ -187,6 +187,32 @@ gdb_Py_DECREF (void *op) /* ARI: editCase function */
 #undef Py_DECREF
 #define Py_DECREF(op) gdb_Py_DECREF (op)
 
+/* The second argument to PyObject_GetAttrString was missing the 'const'
+   qualifier in Python-2.4.  Hence, we wrap it in a function to avoid errors
+   when compiled with -Werror.  */
+
+static inline PyObject *
+gdb_PyObject_GetAttrString (PyObject *obj,
+                           const char *attr) /* ARI: editCase function */
+{
+  return PyObject_GetAttrString (obj, (char *) attr);
+}
+
+#define PyObject_GetAttrString(obj, attr) gdb_PyObject_GetAttrString (obj, attr)
+
+/* The second argument to PyObject_HasAttrString was also missing the 'const'
+   qualifier in Python-2.4.  Hence, we wrap it also in a function to avoid
+   errors when compiled with -Werror.  */
+
+static inline int
+gdb_PyObject_HasAttrString (PyObject *obj,
+                           const char *attr)  /* ARI: editCase function */
+{
+  return PyObject_HasAttrString (obj, (char *) attr);
+}
+
+#define PyObject_HasAttrString(obj, attr) gdb_PyObject_HasAttrString (obj, attr)
+
 /* In order to be able to parse symtab_and_line_to_sal_object function
    a real symtab_and_line structure is needed.  */
 #include "symtab.h"
This page took 0.029665 seconds and 4 git commands to generate.