]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Style improvements in gdb/python
authorTom Tromey <tom@tromey.com>
Wed, 2 Jan 2019 16:30:49 +0000 (09:30 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 2 Jan 2019 16:32:06 +0000 (09:32 -0700)
This fixes a few minor style issues I found in gdb/python: some
unnecessary casts, the removal of an unnecessary local variable, and
one instance of incorrect formatting.

Tested by rebuilding and re-running gdb.python.

gdb/ChangeLog
2019-01-02  Tom Tromey  <tom@tromey.com>

* python/py-inferior.c (gdbpy_initialize_inferior): Fix
indentation.
* python/py-frame.c (frapy_older): Remove cast.
(frapy_newer): Likewise.
* python/py-breakpoint.c (local_setattro): Remove cast.
* python/py-arch.c (archpy_name): Remove local variable.
* python/py-type.c (gdbpy_lookup_type): Remove cast.

gdb/ChangeLog
gdb/python/py-arch.c
gdb/python/py-breakpoint.c
gdb/python/py-frame.c
gdb/python/py-inferior.c
gdb/python/py-type.c

index 5f48a6e17ee1b1d3704cda3d74831d9716af78e8..23503ae515b8df957a2e9632fbf35bd87aedfdfb 100644 (file)
@@ -1,3 +1,13 @@
+2019-01-02  Tom Tromey  <tom@tromey.com>
+
+       * python/py-inferior.c (gdbpy_initialize_inferior): Fix
+       indentation.
+       * python/py-frame.c (frapy_older): Remove cast.
+       (frapy_newer): Likewise.
+       * python/py-breakpoint.c (local_setattro): Remove cast.
+       * python/py-arch.c (archpy_name): Remove local variable.
+       * python/py-type.c (gdbpy_lookup_type): Remove cast.
+
 2019-01-02  Joel Brobecker  <brobecker@adacore.com>
 
        * unittests/basic_string_view/element_access/char/empty.cc:
index 64f6563e8869ad9fb1a3f0f34ba10a3ebec8bfda..cbdd8818732dd51a10d936a1d19f1fcdfd08cb9c 100644 (file)
@@ -97,14 +97,11 @@ archpy_name (PyObject *self, PyObject *args)
 {
   struct gdbarch *gdbarch = NULL;
   const char *name;
-  PyObject *py_name;
 
   ARCHPY_REQUIRE_VALID (self, gdbarch);
 
   name = (gdbarch_bfd_arch_info (gdbarch))->printable_name;
-  py_name = PyString_FromString (name);
-
-  return py_name;
+  return PyString_FromString (name);
 }
 
 /* Implementation of
index 1d0c3d2e848fba2f0363eece51e00af620de8815..f41d88dbf51560c07b57cb36622b7f0f74539c51 100644 (file)
@@ -1196,7 +1196,7 @@ local_setattro (PyObject *self, PyObject *name, PyObject *v)
        }
     }
 
-  return PyObject_GenericSetAttr ((PyObject *)self, name, v);
+  return PyObject_GenericSetAttr (self, name, v);
 }
 
 static gdb_PyGetSetDef breakpoint_object_getset[] = {
index d7f62c2c032e7df7d415da93ccb7ae51f9df083b..88a50e73e2abef080cba9a95083db105bb1dc51f 100644 (file)
@@ -416,7 +416,7 @@ frapy_older (PyObject *self, PyObject *args)
   END_CATCH
 
   if (prev)
-    prev_obj = (PyObject *) frame_info_to_frame_object (prev);
+    prev_obj = frame_info_to_frame_object (prev);
   else
     {
       Py_INCREF (Py_None);
@@ -449,7 +449,7 @@ frapy_newer (PyObject *self, PyObject *args)
   END_CATCH
 
   if (next)
-    next_obj = (PyObject *) frame_info_to_frame_object (next);
+    next_obj = frame_info_to_frame_object (next);
   else
     {
       Py_INCREF (Py_None);
index 1c62a2c60e7cd55551a84e55842fad230044486a..b1b9e947ae8de107141dd46ea42fa2f46c137b9c 100644 (file)
@@ -958,8 +958,8 @@ gdbpy_initialize_inferior (void)
   if (PyType_Ready (&membuf_object_type) < 0)
     return -1;
 
-  return gdb_pymodule_addobject (gdb_module, "Membuf", (PyObject *)
-                                &membuf_object_type);
+  return gdb_pymodule_addobject (gdb_module, "Membuf",
+                                (PyObject *) &membuf_object_type);
 }
 
 static gdb_PyGetSetDef inferior_object_getset[] =
index 0196eb2af934ac0198f4e429813740a34114396f..88770fcc9f392923f381a66e0cc9f2cf984dbcfd 100644 (file)
@@ -1402,7 +1402,7 @@ gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw)
   if (! type)
     return NULL;
 
-  return (PyObject *) type_to_type_object (type);
+  return type_to_type_object (type);
 }
 
 int