From: msnyder@sonic.net
To: gdb-patches@sourceware.org
Cc: drow@false.org
Subject: Re: FW: [PATCH] jv-lang, guard against NULL
Date: Thu, 02 Aug 2007 21:30:00 -0000 [thread overview]
Message-ID: <12786.12.7.175.2.1186090201.squirrel@webmail.sonic.net> (raw)
In-Reply-To: <655C3D4066B7954481633935A40BB36F22BA4C@ussunex02.svl.access-company.c om>
[-- Attachment #1: Type: text/plain, Size: 651 bytes --]
>
> On Tue, Jul 31, 2007 at 04:25:12PM -0700, Michael Snyder wrote:
>> ! if (name != NULL && (i = strlen (name)) > 2
>> ! && name[i - 1] == ']' && tsuper != NULL)
>
> Can we avoid assignments inside the if statement?
Yeah, I tried, but it ended up looking really awkward.
Test 'name', then do the strlen, then test name again.
> Also, there's an
> unprotected call to strrchr above. Maybe this should be an assert
> instead, at the top of the function.
Good idea -- except, can we really be sure that name can
never legitimately be null? Oh, yeah, I guess the unprotected
strrchr sort of tells us that, doesn't it?
OK, how about this?
[-- Attachment #2: 255b.txt --]
[-- Type: text/plain, Size: 1403 bytes --]
2007-07-31 Michael Snyder <msnyder@access-company.com>
* jv-lang.c (java_link_class_type): Guard against NULL.
Index: jv-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/jv-lang.c,v
retrieving revision 1.47
diff -p -r1.47 jv-lang.c
*** jv-lang.c 13 Jun 2007 17:30:01 -0000 1.47
--- jv-lang.c 2 Aug 2007 21:29:07 -0000
*************** java_link_class_type (struct type *type,
*** 351,363 ****
struct objfile *objfile = get_dynamics_objfile ();
struct type *tsuper;
unqualified_name = strrchr (name, '.');
if (unqualified_name == NULL)
unqualified_name = name;
temp = clas;
temp = value_struct_elt (&temp, NULL, "superclass", NULL, "structure");
! if (name != NULL && strcmp (name, "java.lang.Object") == 0)
{
tsuper = get_java_object_type ();
if (tsuper && TYPE_CODE (tsuper) == TYPE_CODE_PTR)
--- 351,364 ----
struct objfile *objfile = get_dynamics_objfile ();
struct type *tsuper;
+ gdb_assert (name != NULL);
unqualified_name = strrchr (name, '.');
if (unqualified_name == NULL)
unqualified_name = name;
temp = clas;
temp = value_struct_elt (&temp, NULL, "superclass", NULL, "structure");
! if (strcmp (name, "java.lang.Object") == 0)
{
tsuper = get_java_object_type ();
if (tsuper && TYPE_CODE (tsuper) == TYPE_CODE_PTR)
next prev parent reply other threads:[~2007-08-02 21:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-31 23:29 msnyder
2007-08-02 21:06 ` Daniel Jacobowitz
[not found] ` <655C3D4066B7954481633935A40BB36F22BA4C@ussunex02.svl.access-company.com>
[not found] ` <655C3D4066B7954481633935A40BB36F22BA4C@ussunex02.svl.access-company.c om>
2007-08-02 21:30 ` msnyder [this message]
2007-08-02 21:37 ` FW: " Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12786.12.7.175.2.1186090201.squirrel@webmail.sonic.net \
--to=msnyder@sonic.net \
--cc=drow@false.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox