Bug 47493

Summary: protocol-native: XOR asserts are expressed in a roundabout way
Product: PulseAudio Reporter: Arun Raghavan <arun>
Component: coreAssignee: Parin Porecha <parinporecha>
Status: RESOLVED FIXED QA Contact: pulseaudio-bugs
Severity: normal    
Priority: medium CC: lennart, parinporecha
Version: unspecifiedKeywords: love
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Arun Raghavan 2012-03-19 01:59:26 UTC
protocol-native.c has a bunch of asserts like this ...

CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || name, tag, PA_ERR_INVALID);
CHECK_VALIDITY(c->pstream, idx == PA_INVALID_INDEX || !name, tag, PA_ERR_INVALID);
CHECK_VALIDITY(c->pstream, !name || idx == PA_INVALID_INDEX, tag, PA_ERR_INVALID);

... that could be written as a single, more readable, XOR like this ...

CHECK_VALIDITY(c->pstream, (idx != PA_INVALID_INDEX) ^ (name != NULL), tag, PA_ERR_INVALID);

Ergo, we should do this. :)
Comment 1 Parin Porecha 2013-11-19 15:31:48 UTC
I've mailed the patch for this bug on the pulseaudio-discuss mailing list
(http://lists.freedesktop.org/archives/pulseaudio-discuss/2013-November/019183.html)

Please review it

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.