This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[commit] const fixes for block.c
- From: David Carlton <carlton at math dot stanford dot edu>
- To: gdb-patches at sources dot redhat dot com
- Cc: Elena Zannoni <ezannoni at redhat dot com>, Jim Blandy <jimb at redhat dot com>
- Date: 02 Jun 2003 11:42:39 -0700
- Subject: [commit] const fixes for block.c
This patch updates some functions in block.c to take const struct
block *'s as arguments instead of just struct block *'s. We seem to
make some effort in various places to use const struct block *'s when
appropriate, so we might as well do that here, too.
Of course, there are still issues here: e.g. why isn't contained_in
prefixed by block_, as most of the other functions are? What about
arguments to functions in block.c that are pointers to things other
than blocks? (We're pretty inconsistent about this sort of
const-correctness: clearly we want to (but aren't) be const correct
for strings, and we're fairly const-correct about some structures, but
not about others.) If anybody wants me to clean up those, just holler
(I might do it myself anyways); I'm just patching this particular one
right now because it reduces the delta between mainline and my branch.
Tested on GCC 3.1, DWARF 2, i686-pc-linux-gnu; committed as obvious.
David Carlton
carlton@math.stanford.edu
2003-06-02 David Carlton <carlton@math.stanford.edu>
* block.c (contained_in): Add 'const' to arguments.
(block_function): Ditto.
* block.h: Update declarations for block_function and
contained_in.
Index: block.c
===================================================================
RCS file: /cvs/src/src/gdb/block.c,v
retrieving revision 1.6
diff -u -p -r1.6 block.c
--- block.c 2 Jun 2003 04:16:23 -0000 1.6
+++ block.c 2 Jun 2003 18:20:37 -0000
@@ -44,7 +44,7 @@ static void block_initialize_namespace (
Return zero otherwise. */
int
-contained_in (struct block *a, struct block *b)
+contained_in (const struct block *a, const struct block *b)
{
if (!a || !b)
return 0;
@@ -57,7 +57,7 @@ contained_in (struct block *a, struct bl
lexical block, described by a struct block BL. */
struct symbol *
-block_function (struct block *bl)
+block_function (const struct block *bl)
{
while (BLOCK_FUNCTION (bl) == 0 && BLOCK_SUPERBLOCK (bl) != 0)
bl = BLOCK_SUPERBLOCK (bl);
Index: block.h
===================================================================
RCS file: /cvs/src/src/gdb/block.h,v
retrieving revision 1.5
diff -u -p -r1.5 block.h
--- block.h 20 May 2003 03:56:27 -0000 1.5
+++ block.h 2 Jun 2003 18:20:44 -0000
@@ -187,9 +187,9 @@ struct blockvector
#define STATIC_BLOCK 1
#define FIRST_LOCAL_BLOCK 2
-extern struct symbol *block_function (struct block *);
+extern struct symbol *block_function (const struct block *);
-extern int contained_in (struct block *, struct block *);
+extern int contained_in (const struct block *, const struct block *);
extern struct blockvector *blockvector_for_pc (CORE_ADDR, int *);