4 ms·
btw. this is how I would make the code more robust: https://lore.kernel.org/lkml/20220225185431.2617232-4-max.kellermann@gmail.com/ https://lore.kernel.org/lkml
by max_k 5y ago
btw. this is how I would make the code more robust: https://lore.kernel.org/lkml/20220225185431.2617232-4-max.kellermann@gmail.com/ https://lore.kernel.org/lkml/20220225185431.2617232-4-max.ke...
I'm a C++ guy, and the lack of constructors is one of many things that bothers me with C.
- wtarreau 5y agoI tend to agree but only partially. I'm doing myself a lot of init functions for plenty of stuff, but I've faced plenty of issues due to the fact that these functions do not always initialize everything (and your patch above does exactly that for a good reason) and that it's much less obvious for those using them. And if they initialize too much, they can equally be a pain to work with. It's not uncommon to require 2 or 3 different init functions depending on what you're doing, but the name should explicitly indicate the promise, and that's where it's difficult.
- max_k 5y agoThen let's have those 2 or 3 documented init functions. That's not perfect, but still much better than spraying different (undocumented) copies of the init code everywhere, that have to be located and adjusted every time somebody refactors something.
- wtarreau 5y agoIn any case, definitely ;-)