Re: [hatari-devel] Coding style

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Am Sat, 2 May 2020 18:02:26 +0300
schrieb Eero Tamminen <oak@xxxxxxxxxxxxxx>:

> Hi,
> 
> Regarding this commit:
> --------------------------
> commit 976e2238d24c413b76e2c2f0bb2937ee34dd5363
> Author: Thomas Huth <huth@xxxxxxxxxxxxx>
> Date:   Sat May 2 09:23:52 2020 +0200
> 
>      Fix coding style in statusbar.c
> 
>      statusbar.c is not derived from another
>      project, so we should use the main Hatari
>      coding style here and put curly braces on
>      new lines.
> ---------------------------
> 
> It didn't fix anything.

It did. The style there was already inconsistent, see e.g.:

https://git.tuxfamily.org/hatari/hatari.git/tree/src/statusbar.c?id=c9c6a3e2#n922

> 
> Our coding style document:
> https://hatari.tuxfamily.org/doc/coding.txt
> 
> Says:
> ---------------------------
> ...
> try to adapt to the coding style of the file that
> you're currently editing.
> 
> - For new files, pick one of the existing coding
>    styles, don't add a new one.

It still makes sense that you pick the coding style that is used in the
other files in the same folder, i.e. use the traditional coding style
in the src/ folder, use the WinUAE coding style in src/cpu/, etc.

> Because our main upstream projects are WinUAE,
> Qemu and Aranym [3], and all of those use brace-
> on-same-line style, I'm proposing that we adopt
> that as the default style for rest of the Hatari
> code too, for consistency's sake.

Hmm, I guess 10 or 15 years ago, I'd screamed "heretic idea!" now, but
acutally, I've done quite a lot of QEMU and Linux kernel development in
my job in the past years, so I'm fine with both coding style nowadays
(I just dislike mixing the style in one file - that's really too
confusing).

Nicolas, what's your opinion?

> If agreed, I can convert src/debug/*.c files to
> that convention as I'm nowadays doing most of
> maintenance for that code, and several of the
> files there already use brace-on-same-line style
> [4].

There are also tools like "astyle" which can be used to do the change
automatically.

> Rest of the files could be converted later on, but
> that needs input from Previous downstream project
> in case it is still synching some code with
> Hatari.

It's been quite a while since we last exchanged some code ... but
looking at
https://sourceforge.net/p/previous/code/HEAD/tree/trunk/src/scsi.c
for example, it seems that they use the brace-on-same-line style in new
files, too.

> [5] Qemu uses brace-on-same-line, but different
> indenting:
> https://git.qemu.org/?p=qemu.git;a=blob_plain;f=CODING_STYLE.rst;hb=HEAD

The code that we've got from QEMU is mostly ide.c - which is completely
out of sync anway and has also mostly been turned into the base Hatari
coding style in the course of time, so I don't think that we have to
consider the QEMU-way of indenting with spaces instead of tabs.

 Thomas



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/