osmo-pocsag icon indicating copy to clipboard operation
osmo-pocsag copied to clipboard

Function even_parity is actually odd_parity

Open glinders opened this issue 5 years ago • 3 comments

Function even_parity(uint32_t x) in file src/pocsag.c returns a '1' if parity is odd and a '0' if parity is even.

The name of the function suggests that it returns 'true' (i.e. '1') if parity is even.

Refer to attached source file: parity.zip

Compile and run with: gcc parity.c -o parity && ./parity

glinders avatar Jun 13 '19 00:06 glinders

it's a question of the point of view and the expectation: a) check if the parity is even and then return true b) make the sum of all all bits (including the returned one) even

so dependent if you want "check" or "make" the expectation is different

nospam2000 avatar Jun 13 '19 05:06 nospam2000

Yes, I agree but the name of your function doesn't give a clear hint as to what it does and there is no API description either.

I normally add an 'action verb' in the function name to make it clear; is_parity_even(val) or send_pocsag_message(msg).

glinders avatar Jun 13 '19 22:06 glinders

I completely agree with you!

nospam2000 avatar Jun 14 '19 04:06 nospam2000