Karl O. Pinc wrote: > I do have a question here regards code formatting. > The patch now contains: > > if (log_filepath == NULL) > { > /* Bad data. Avoid segfaults etc. and return NULL to caller. */ > break; > } > > I'm not sure how this fits in with PG coding style, > whether the {} should be removed or what. I've looked > around and can't find an example of an if with a single > line then block and a comment. Maybe this means that > I shouldn't be doing this, but if I put the comment above > the if then it will "run into" the comment block which > immediately precedes the above code which describes > a larger body of code. So perhaps someone should look > at this and tell me how to improve it.
I think this style is good. Following the style guide to the letter would lead to remove the braces and keep the comment where it is; pgindent will correctly keep at its current indentation. We do use that style in a couple of places. It looks a bit clunky. In most places we do keep those braces, for readability and future-proofing in case somebody inadvertently introduces another statement to the "block". We don't automatically remove braces anyway. (We used to do that, but stopped a few years ago shortly after introducing PG_TRY). Putting the comment outside (above) the "if" would be wrong, too; you'd have to rephrase the comment in a conditional tense. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers