[31/36] libcamera: global_configuration: Populate empty configuration
diff mbox series

Message ID 20260113000808.15395-32-laurent.pinchart@ideasonboard.com
State New
Headers show
Series
  • libcamera: Global configuration file improvements
Related show

Commit Message

Laurent Pinchart Jan. 13, 2026, 12:08 a.m. UTC
If no configuration file can be parsed, populate an empty configuration.
This will serve as a base to store the configuration options set through
environment variables.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/global_configuration.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Barnabás Pőcze Jan. 13, 2026, 1:30 p.m. UTC | #1
2026. 01. 13. 1:08 keltezéssel, Laurent Pinchart írta:
> If no configuration file can be parsed, populate an empty configuration.
> This will serve as a base to store the configuration options set through
> environment variables.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>   src/libcamera/global_configuration.cpp | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/global_configuration.cpp b/src/libcamera/global_configuration.cpp
> index 4d154c026e44..a759a086b9a4 100644
> --- a/src/libcamera/global_configuration.cpp
> +++ b/src/libcamera/global_configuration.cpp
> @@ -93,7 +93,12 @@ void GlobalConfiguration::load()
>   
>   	for (const auto &path : globalConfigurationFiles) {
>   		if (loadFile(path))
> -			return;
> +			break;
> +	}

This misses the earlier `loadFile()` call in the `if (!userConfigurationDirectory.empty()) {` block.


> +
> +	if (configuration_->isEmpty()) {
> +		configuration_->add("version", std::make_unique<ValueNode>(1));
> +		configuration_->add("configuration", std::make_unique<ValueNode>());
>   	}
>   }
>
Laurent Pinchart Jan. 13, 2026, 2:15 p.m. UTC | #2
On Tue, Jan 13, 2026 at 02:30:39PM +0100, Barnabás Pőcze wrote:
> 2026. 01. 13. 1:08 keltezéssel, Laurent Pinchart írta:
> > If no configuration file can be parsed, populate an empty configuration.
> > This will serve as a base to store the configuration options set through
> > environment variables.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >   src/libcamera/global_configuration.cpp | 7 ++++++-
> >   1 file changed, 6 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/libcamera/global_configuration.cpp b/src/libcamera/global_configuration.cpp
> > index 4d154c026e44..a759a086b9a4 100644
> > --- a/src/libcamera/global_configuration.cpp
> > +++ b/src/libcamera/global_configuration.cpp
> > @@ -93,7 +93,12 @@ void GlobalConfiguration::load()
> >   
> >   	for (const auto &path : globalConfigurationFiles) {
> >   		if (loadFile(path))
> > -			return;
> > +			break;
> > +	}
> 
> This misses the earlier `loadFile()` call in the `if (!userConfigurationDirectory.empty()) {` block.

Indeed. I'll reorganize the code.

> > +
> > +	if (configuration_->isEmpty()) {
> > +		configuration_->add("version", std::make_unique<ValueNode>(1));
> > +		configuration_->add("configuration", std::make_unique<ValueNode>());
> >   	}
> >   }
> >   
>

Patch
diff mbox series

diff --git a/src/libcamera/global_configuration.cpp b/src/libcamera/global_configuration.cpp
index 4d154c026e44..a759a086b9a4 100644
--- a/src/libcamera/global_configuration.cpp
+++ b/src/libcamera/global_configuration.cpp
@@ -93,7 +93,12 @@  void GlobalConfiguration::load()
 
 	for (const auto &path : globalConfigurationFiles) {
 		if (loadFile(path))
-			return;
+			break;
+	}
+
+	if (configuration_->isEmpty()) {
+		configuration_->add("version", std::make_unique<ValueNode>(1));
+		configuration_->add("configuration", std::make_unique<ValueNode>());
 	}
 }