[2016-09-08 13:58] markus schnalke <mei...@marmaro.de> > > part text/plain 1630 > Should this be a generic function (included into sbr/)? > There probably are other places where we create files > with reduced permissions. This patch here does not fully > convince me -- it pays the encapsulation of a few lines > with an additional lookup --, but it might be a starting > point for a larger improvement. Then the deal could be > much better.
I would move to sbr/ after I locate another call site. About lookup -- you look at function name and understand that file is created and FILE* is returned. Since it is assigned to `out' variable, it is created for write. No need to lookup actual code. And, it is much easier to locate code duplication when you have many "several lines" functions, than when you have many code in every function. Probably, following quotes from Linux coding style (doc/CodingStyle) can be convincing: GLOBAL variables (to be used only if you _really_ need them) need to have descriptive names, as do global functions. If you have a function that counts the number of active users, you should call that "count_active_users()" or similar, you should _not_ call it "cntusr()". Functions should be short and sweet, and do just one thing. They should fit on one or two screenfuls of text (the ISO/ANSI screen size is 80x24, as we all know), and do one thing and do that well. Another measure of the function is the number of local variables. They shouldn't exceed 5-10, or you're doing something wrong. [...]