On Mon, Feb 03, 2020 at 07:58:21PM -0800, Taylor Blau wrote: > I think that this seems like a good step that we should probably take, > but I don't think that it's necessary for the series at hand. The > pattern in this function is to define a local variable which has the > same value as in split_opts, or a reasonable default if split_opts is > NULL (c.f., 'max_commits' and 'size_mult'). > > So, I think that a safe thing to do which prevents the segv and doesn't > change the pattern too much is to write: > > enum commit_graph_split_flags flags = COMMIT_GRAPH_SPLIT_MERGE_AUTO; > if (ctx->split_opts) { > /* ... */ > flags = ctx->split_opts->flags; > } > > /* ... */ > > if (flags != COMMIT_GRAPH_SPLIT_MERGE_PROHIBITED) { > while ( ... ) { ... } > } > > This is adding another local variable, which seems like an odd thing to > do *every* time that we add another member to split_opts. So for that > reason it seems like in the longer-term we should either force the > caller to pass in a blank, or do something else that doesn't require > this, but I think that the intermediate cost isn't too bad. It would perhaps be simpler to turn NULL into a _single_ default-filled split_opts variable, and then just use it throughout the function. And since presumably zero-initialization would yield good defaults (or we'd define an INIT macro for the convenience of callers), it would be a one-liner that we'd only have to do once. But I think that can wait; the "if" solution discussed seems like a straightforward way to make this patch correct both on top of master, and when merged with next. -Peff