console-server: Don't require a configuration file
Not requiring a configuration file makes it marginally less irritating
to test obmc-console-server.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ibdf898933284bb4028861d25640bea3c58fb05bf
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3c3cb21..b891bad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,6 +28,11 @@
underlying TTY device is a UART and not a VUART nor PTY (where baud is not
applicable)
+2. console-server: Don't require a configuration file
+
+ Passing the `--config` option is no longer required when invoking
+ `obmc-console-server`.
+
### Deprecated
1. obmc-console: Introduce console-id, deprecate socket-id
diff --git a/config.c b/config.c
index 5a2f4f0..707c024 100644
--- a/config.c
+++ b/config.c
@@ -47,6 +47,10 @@
{
struct config_item *item;
+ if (!config) {
+ return NULL;
+ }
+
for (item = config->items; item; item = item->next) {
if (!strcasecmp(item->name, name)) {
return item->value;
@@ -168,6 +172,10 @@
struct config_item *item;
struct config_item *next;
+ if (!config) {
+ return;
+ }
+
for (item = config->items; item; item = next) {
next = item->next;
free(item->name);
diff --git a/console-server.c b/console-server.c
index 99cf1c7..c73ebb7 100644
--- a/console-server.c
+++ b/console-server.c
@@ -847,11 +847,6 @@
console->rb = ringbuffer_init(buffer_size);
config = config_init(config_filename);
- if (!config) {
- warnx("Can't read configuration, exiting.");
- rc = -1;
- goto out_free;
- }
if (set_socket_info(console, config, console_id)) {
rc = -1;
@@ -876,7 +871,6 @@
out_config_fini:
config_fini(config);
-out_free:
free(console->pollers);
free(console->pollfds);
free(console);