Comment by azinman2
1 day ago
Looking at that code I’m shocked that Postgres allows two-liner if statements without a matching {} (I’m sure someone pedantically will point out that I’m using the wrong terminology or that it was actually several lines of conditionals).
This practice is very bug prone, and has lead to high profile failures like goto fail
The project history goes back to 1982. There may have been rewrites in the later 80s, but it's some of the oldest C around, and a very conservative codebase (e.g. Linux kernel gets much more aggressive refactorings regularly).
That particular git repository has history imported from 1996 onward, but Postgres was a very established project by then: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit...
These days people might not blink an eye at gofmt/rustfmt rewriting the AST to clean it up, but those toolchains were built that way largley because automating anything about large C codebases is so hard.
Except this was new code.
Generally, large C projects have their own style that is followed whether the code is new or not.
2 replies →
These days, there are compiler diagnostics for that. There's also a pgindent tool, which will align the visual presentation of the code with its syntactic structure.
What issue are you taking with the code? Line breaks in the condition?
Presumably the last if statement in the diff.
There aren’t {} brackets after the if
Are you saying they should always be present? Or only when the condition takes multiple lines; i.e. do you take issue with the ifs in zone_name_pref too?
Personally I think the indentation does a good enough job here.
1 reply →