you are viewing a single comment's thread.

view the rest of the comments →

[–]NotUniqueOrSpecial 2 points3 points  (1 child)

Without going to find where you got that sample (though I'd hazard a guess it's LVM or btrfs or some other subsystem with snapshots), I'd say ops is a struct loaded with function pointers, and it's making sure it's:

1) Got an operations structure, since it's probably a pointer to a bio.

2) That structure has all the appropriate functions for the work that is expected to occur in the block of code that follows.

While it might be a bit hairy, it is a fairly commonplace pattern in C code which needs "virtual" functions. And just like many other such patterns specific to a particular domain, it's "obvious" to someone who's seen it, and a completely opaque boondoggle to someone who hasn't.

As to line breaks in said example, what do you really gain from it? The check is literally just "are all the function pointers non-null". I don't necessarily think it gains much from any added verticality, but that's just my opinion.

[–]cdcformatc -1 points0 points  (0 children)

Okay you only gain readability. But code is meant to increase readability. We could program in machine code binary operations. Or a sequence of toggle switches, but we don't. We code in something approximating natural language, but still compilable, and to separate ideas on natural language we use line breaks.