[libcamera-devel] [PATCH] cam: Support base 16 and base 8 when parsing integer options

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Jun 19 12:50:47 CEST 2019


Integer options have to use base 10. This isn't user-friendly when
specifying pixel formats. Detect the base automatically to support base
16. As a side effect, integer values starting with 0 will be interpreted
in base 8.

Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 src/cam/options.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/cam/options.cpp b/src/cam/options.cpp
index bea4a600d1d5..7c3948df3b5c 100644
--- a/src/cam/options.cpp
+++ b/src/cam/options.cpp
@@ -79,7 +79,7 @@ bool OptionsBase<T>::parseValue(const T &opt, const Option &option,
 
 		if (optarg) {
 			char *endptr;
-			integer = strtoul(optarg, &endptr, 10);
+			integer = strtoul(optarg, &endptr, 0);
 			if (*endptr != '\0')
 				return false;
 		} else {
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list