This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Accelerate blocks sorting
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> + return (BLOCK_START (b) > BLOCK_START (a))
Jan> + - (BLOCK_START (b) < BLOCK_START (a));
Tom> This expression needs parens around it, according to GNU rules.
Jan> GNU Coding Standards provides this sample code line:
Jan> return ++x + bar ();
Jan> Moreover it has no sample code (and found no rules) with `return'
Jan> using parens. GDB uses `return' with parens a lot but I find it
Jan> a GNU style violation by GDB fixing it along in the patches.
Jan> Sure no problem to change it but is there any backing for such parens?
Yeah. It isn't the return, but the splitting.
>From (info "(standards) Formatting") :
Insert extra parentheses so that Emacs will indent the code properly.
For example, the following indentation looks nice if you do it by hand,
v = rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
+ rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000;
but Emacs would alter it. Adding a set of parentheses produces
something that looks equally nice, and which Emacs will preserve:
v = (rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
+ rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000);
And, yes, the GNU style is partly defined as "make it work nicely in
Emacs".
Tom> I think you don't actually need a cleanup here, as nothing here can
Tom> call error. However, if you want to leave it, that is also ok with
Tom> me.
Jan> I did not notice, still I find the code safer that way.
Sounds good.
Tom