summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Stanley <joel@jms.id.au>2017-11-16 14:21:19 +1030
committerAlistair Popple <alistair@popple.id.au>2017-11-22 10:35:08 +1100
commit58950eef124fcb37687f856fc5ee7936cb4e31cc (patch)
tree4800ddb59c55727f167fec04dd025e836280d25d
parentc056b947eb43842c7f752af6b67cca983d316a82 (diff)
downloadpdbg-58950eef124fcb37687f856fc5ee7936cb4e31cc.tar.gz
pdbg-58950eef124fcb37687f856fc5ee7936cb4e31cc.zip
Error out when no device type is specified
The host and FSI backend require the device type to be specified. When a user forgets, we pass a null pointer to strcmp and segfault. Signed-off-by: Joel Stanley <joel@jms.id.au>
-rw-r--r--src/main.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 7c410a1..66097ab 100644
--- a/src/main.c
+++ b/src/main.c
@@ -867,6 +867,10 @@ static int target_select(void)
break;
case FSI:
+ if (device_node == NULL) {
+ PR_ERROR("FSI backend requires a device type\n");
+ return -1;
+ }
if (!strcmp(device_node, "p8"))
targets_init(&_binary_p8_fsi_dtb_o_start);
else if (!strcmp(device_node, "p9w") || !strcmp(device_node, "witherspoon"))
@@ -890,6 +894,10 @@ static int target_select(void)
break;
case HOST:
+ if (device_node == NULL) {
+ PR_ERROR("Host backend requires a device type\n");
+ return -1;
+ }
if (!strcmp(device_node, "p8"))
targets_init(&_binary_p8_host_dtb_o_start);
else if (!strcmp(device_node, "p9"))
OpenPOWER on IntegriCloud