If switch case if cannot cover all cases, then the return value is undefined.
Even though orientation
is an enum with only two values (right now), it can still have a different value for any of the following reasons:
- In the future, you may change the header to include other values in the enum, so it's defensive programming to assume that this will happen (and your compiler is being nice and warning you now).
side
might be uninitialized, so it could be neitherleft
norright
side
might have been assigned another value via typecasting, e.g.*((int*)&side) = 2
Possible solutions include:
- Replace the second
if
with anelse
as suggested by sth. -
Change it to be:
if(side == left) { return ...; } else if(side == right) { return ...; } else { ...handle error... }