[libcamera-devel] [PATCH] libcamera: control_serializer: Use explicit ControlTypeNone case

Kieran Bingham kieran.bingham at ideasonboard.com
Mon Mar 2 23:36:36 CET 2020


Hi Laurent,

On 02/03/2020 16:41, Laurent Pinchart wrote:
> Hi Kieran,
> 
> On Mon, Mar 02, 2020 at 03:35:23PM +0000, Kieran Bingham wrote:
>> On 01/03/2020 16:02, Laurent Pinchart wrote:
>>> Replace the default case with an explicit ControlTypeNone case in
>>> ControlSerializer::load() to catch ommissions when adding new control
>>> types.
>>
>> s/ommissions/omissions/
>>
>> This sounds good. Does it cause any issue with no default case found?
>>
>> In fact looking again, Of course this now means that the compiler will
>> warn us here if an option is not handled by the case statement.
> 
> But some gcc version still reports that the function has an exit path
> with a return statement :-( I'll have to add both.

Does adding both remove the benefit of having the compiler warn us when
we add new enum types without adding them to the case statement?

If not then that's fine.

> 
>> Excellent.
>>
>> Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
>>
>>> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
>>> ---
>>>  src/libcamera/control_serializer.cpp | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp
>>> index 5537c5466025..e78fca88cfea 100644
>>> --- a/src/libcamera/control_serializer.cpp
>>> +++ b/src/libcamera/control_serializer.cpp
>>> @@ -361,7 +361,7 @@ ControlValue ControlSerializer::load<ControlValue>(ControlType type,
>>>  		return ControlValue(value);
>>>  	}
>>>  
>>> -	default:
>>> +	case ControlTypeNone:
>>>  		return ControlValue();
>>>  	}
>>>  }
> 

-- 
Regards
--
Kieran


More information about the libcamera-devel mailing list