This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FW: [PATCH] jv-lang, guard against NULL


>
> 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: 255b.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]