News for hackers. Stuff that matters.
Re:OpenBSD's safe, new file(1) implementation by userbinator on Saturday April 25, 2015 @11:20PM (#9440406)
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/file/fi...

I'm not so familiar with FreeBSD coding standards and design practices but it looks like that could still be refactored even more by getting rid of all the extra memory allocations (and deallocations), making future changes less likely to introduce bugs. For example it's allocating one structure for each file given as input, and making copies of all the paths... which I'm pretty sure isn't necessary as file tests each of its input files independently; the code misleadingly implies, however, that they are somehow dependent. The old version was better in this respect.

That said, compared to the much more complex old version, the rest of it is an improvement.

Re:OpenBSD's safe, new file(1) implementation by rjcz on Sunday April 26, 2015 @06:40AM (#9441289)
OpenBSD != FreeBSD

This[0] is a good place to start. Other than than, just read the code.

[0] http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man9/...

Re:OpenBSD's safe, new file(1) implementation by userbinator on Sunday April 26, 2015 @10:14AM (#9441820)
Getting that wrong shows how much I work with the different variants of * BSD...

That's a syntactic style guide; I was referring to higher-level issues at the design level, like "avoid dynamic allocation unless absolutely necessary", which are between syntax and the general very-high-level "follow the UNIX philosophy" type of guidelines.

To answer the sibling comments about preparing a patch and sending it in: this was just an observation I had from a brief glance at the code; I don't have the resources to delve into the research and find out if this is actually something they would want to change, if there is a reason behind doing it this way, or only the norm for the project (e.g. the Java community largely has a very different notion of what it means to "simplify" code) - so if someone wants to take these ideas and follow through, they are more than welcome to.

Re:OpenBSD's safe, new file(1) implementation by stsp on Sunday April 26, 2015 @04:22AM (#9440994)
Please take the time to send diffs to tech@ instead of writing code review comments on hackernews which will most likely not be read by relevent people and therefore have no effect whatsoever. Thanks.
Re:OpenBSD's safe, new file(1) implementation by musername on Sunday April 26, 2015 @06:03AM (#9441196)
Is I'm pretty sure yet enough to warrant a report?
Re:OpenBSD's safe, new file(1) implementation by iwwr on Sunday April 26, 2015 @06:08AM (#9441209)
There's nothing stopping you from submitting a patch for a small sample of the issues and a friendly question on their mailing list.