[PATCH] Don't check PST is NULL in read_symtab

Joel Brobecker brobecker@adacore.com
Fri Jan 11 15:06:00 GMT 2013


> IMO, we don't need an assertion to check PST, because the function is
> used in this way,
> 
>   (*pst->read_symtab) (objfile, pst);

I am fine without the assertion as well. But if we followed your
argument, we would never need an assertion. For me, assertions
achieve two goals:
  1. Clearly document an expectation;
  2. Cause a semi-friendly abortion, rather than a mysterious behavior
     or crash.
As of today, the way this function is called indeed guarantees that
PST is never NULL. But someone adding a call at a later date might
introduce a bug and cause it to be called with PST == NULL...

> 2013-01-11  Yao Qi  <yao@codesourcery.com>
> 
> 	* dwarf2read.c (dwarf2_psymtab_to_symtab): Code indent.

Let's take an example to show you what I meant in my first suggestion.
Attached is a bogus change I made a function in dwarf2read. I added
an "else" around a large block of code. The first patch shows the
actual change, with code reindentation. That's the real patch which
would be checked in eventually - but it's barely readable. So,
to better show the real changes, I also attach the result of
"git diff/show -b", where whitespace-only changes are ignored.

-- 
Joel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dwarf2read-actual.diff
Type: text/x-diff
Size: 2678 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20130111/f5de1ec2/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dwarf2read-spaces_ignored.diff
Type: text/x-diff
Size: 733 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20130111/f5de1ec2/attachment-0001.bin>


More information about the Gdb-patches mailing list