Re: [PATCH v2 1/3] blktrace: introduce 'blk_trace_{start,stop}' helper
From: Christoph Hellwig
Date: Tue Oct 18 2022 - 11:53:21 EST
> +static int blk_trace_start(struct blk_trace *bt)
> +{
> + /*
> + * For starting a trace, we can transition from a setup or stopped
> + * trace.
> + */
That's pretty obvious from the check, isn't it?
> + if (bt->trace_state == Blktrace_setup ||
> + bt->trace_state == Blktrace_stopped) {
I'd invert the check and return early from the function for the error
case so that the real starting code is in the main path.
> +static int blk_trace_stop(struct blk_trace *bt)
> +{
> + /*
> + * For stopping a trace, the state must be running
> + */
> + if (bt->trace_state == Blktrace_running) {
The same two comments apply here as well.