For your specific example you can use:
if ((bits != 12 && bits != 16) || addressSize != 32) { isValid = false; printf("Invalid!");} else { offsetMask = (1u << bits) - 1;}
However it depends what you mean by "better".There are many different aspects like memory footprint, performance, readability.
I think the code in the question is more readable but probably less efficient than the one I proposed.