Re: [alsa-devel] ALSA: pcsp: Use common error handling code in snd_card_pcsp_probe()

From: Takashi Iwai
Date: Tue Aug 22 2017 - 10:07:43 EST


On Tue, 22 Aug 2017 15:15:02 +0200,
SF Markus Elfring wrote:
>
> >> Is it appropriate to treat non-zero values as error codes there generally?
> >
> > No, it can't be in general.
>
> I got the impression that the functions which are called at the updated places
> by the function âsnd_card_pcsp_probeâ indicate a successful execution
> only by zero so far.

You have the impression, great. And what's the reason to drop the
negative check? It's not clearer, not better readable.
And, the worst part is that you've done it silently even without
mentioning in the change log at all. That's really bad.
Just don't do it.

> > Lots of functions return a positive value, too.
>
> Would you like to point any example out from the programming interface?

For example, the control API functions may return the positive number
when the value got changed, 0 for else, and a negative number for the
error. The functions returning some numbers may return positive
numbers, of course.


Takashi