Re: [hatari-devel] Patch to fix crash saving midi preferences on Mac

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


Hi,

On 28.5.2022 20.38, Chris Jenkins wrote:
Ok, so that header change in b8b80c4d broke it.

In my haste to get it working last night, I completely missed the fact that
the size of the buffer changed in the above commit! Thanks for pointing
that out.

Could you change your patch to use sizeof() and strlcpy() like the
commit b8b80c4d6 does (to make it more robust and smaller), test that it
still works, and send it to list / me?


Please see attached a new patch which uses sizeof(<the buffer>) instead of
a constant. I also followed Thomas's suggestion and used strlcpy instead of
strncpy, which matches the way the SDL GUI does this as well. I've tested
on my Mac and it appears to work ok (no crash when saving the config).

How does it look now?

Good, thanks!  I've pushed it.

(I added relevant commit IDs to commit message
and fixed indenting, as your code editor seems to have replaced some tabs with 4 spaces.)


	- Eero

PS. Within last year or two I've learned Golang, which is fairly nice mix between C and Python. While I have some reservations for the language itself, I'm in love with its tooling.

E.g. code formatting is a builtin feature which means that one run "go fmt" after every change / before commits, without even needing to check the results, which is not the case with C (and Objective-C used by Mac GUI).

And Golang tooling is lightning fast as parsing speed is one of the design goals of the language...



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