diff mbox series

[01/10] main: Convert target_selection() to return a boolean

Message ID 20181002060430.3344784-2-amitay@ozlabs.org
State Superseded
Headers show
Series Device tree path base targeting | expand

Commit Message

Amitay Isaacs Oct. 2, 2018, 6:04 a.m. UTC
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 src/main.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

Alistair Popple Oct. 26, 2018, 3:51 a.m. UTC | #1
Reviewed-by: Alistair Popple <alistair@popple.id.au>

On Tuesday, 2 October 2018 4:04:22 PM AEDT Amitay Isaacs wrote:
> Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> ---
>  src/main.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/src/main.c b/src/main.c
> index d6dffcd..cbcf612 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -597,7 +597,7 @@ void for_each_target_release(char *class)
>  	}
>  }
> 
> -static int target_selection(void)
> +static bool target_selection(void)
>  {
>  	struct pdbg_target *fsi, *pib, *chip, *thread;
> 
> @@ -610,7 +610,7 @@ static int target_selection(void)
>  	case FSI:
>  		if (device_node == NULL) {
>  			PR_ERROR("FSI backend requires a device type\n");
> -			return -1;
> +			return false;
>  		}
>  		if (!strcmp(device_node, "p8"))
>  			pdbg_targets_init(&_binary_p8_fsi_dtb_o_start);
> @@ -622,14 +622,14 @@ static int target_selection(void)
>  			pdbg_targets_init(&_binary_p9z_fsi_dtb_o_start);
>  		else {
>  			PR_ERROR("Invalid device type specified\n");
> -			return -1;
> +			return false;
>  		}
>  		break;
> 
>  	case KERNEL:
>  		if (device_node == NULL) {
>  			PR_ERROR("kernel backend requires a device type\n");
> -                        return -1;
> +                        return false;
>  		}
>  		if (!strcmp(device_node, "p8"))
>  			pdbg_targets_init(&_binary_p8_kernel_dtb_o_start);
> @@ -643,7 +643,7 @@ static int target_selection(void)
>  	case HOST:
>  		if (device_node == NULL) {
>  			PR_ERROR("Host backend requires a device type\n");
> -			return -1;
> +			return false;
>  		}
>  		if (!strcmp(device_node, "p8"))
>  			pdbg_targets_init(&_binary_p8_host_dtb_o_start);
> @@ -651,7 +651,7 @@ static int target_selection(void)
>  			pdbg_targets_init(&_binary_p9_host_dtb_o_start);
>  		else {
>  			PR_ERROR("Unsupported device type for host backend\n");
> -			return -1;
> +			return false;
>  		}
>  		break;
>  #endif
> @@ -664,7 +664,7 @@ static int target_selection(void)
>  		/* parse_options deals with parsing user input, so it should be
>  		 * impossible to get here */
>  		assert(0);
> -		return -1;
> +		return false;
>  	}
> 
>  	/* At this point we should have a device-tree loaded. We want
> @@ -719,7 +719,7 @@ static int target_selection(void)
>  			target_unselect(fsi);
>  	}
> 
> -	return 0;
> +	return true;
>  }
> 
>  void print_target(struct pdbg_target *target, int level)
> @@ -811,7 +811,7 @@ int main(int argc, char *argv[])
>  		device_node = default_target(backend);
> 
>  	/* Disable unselected targets */
> -	if (target_selection())
> +	if (!target_selection())
>  		return 1;
> 
>  	atexit(atexit_release);
diff mbox series

Patch

diff --git a/src/main.c b/src/main.c
index d6dffcd..cbcf612 100644
--- a/src/main.c
+++ b/src/main.c
@@ -597,7 +597,7 @@  void for_each_target_release(char *class)
 	}
 }
 
-static int target_selection(void)
+static bool target_selection(void)
 {
 	struct pdbg_target *fsi, *pib, *chip, *thread;
 
@@ -610,7 +610,7 @@  static int target_selection(void)
 	case FSI:
 		if (device_node == NULL) {
 			PR_ERROR("FSI backend requires a device type\n");
-			return -1;
+			return false;
 		}
 		if (!strcmp(device_node, "p8"))
 			pdbg_targets_init(&_binary_p8_fsi_dtb_o_start);
@@ -622,14 +622,14 @@  static int target_selection(void)
 			pdbg_targets_init(&_binary_p9z_fsi_dtb_o_start);
 		else {
 			PR_ERROR("Invalid device type specified\n");
-			return -1;
+			return false;
 		}
 		break;
 
 	case KERNEL:
 		if (device_node == NULL) {
 			PR_ERROR("kernel backend requires a device type\n");
-                        return -1;
+                        return false;
 		}
 		if (!strcmp(device_node, "p8"))
 			pdbg_targets_init(&_binary_p8_kernel_dtb_o_start);
@@ -643,7 +643,7 @@  static int target_selection(void)
 	case HOST:
 		if (device_node == NULL) {
 			PR_ERROR("Host backend requires a device type\n");
-			return -1;
+			return false;
 		}
 		if (!strcmp(device_node, "p8"))
 			pdbg_targets_init(&_binary_p8_host_dtb_o_start);
@@ -651,7 +651,7 @@  static int target_selection(void)
 			pdbg_targets_init(&_binary_p9_host_dtb_o_start);
 		else {
 			PR_ERROR("Unsupported device type for host backend\n");
-			return -1;
+			return false;
 		}
 		break;
 #endif
@@ -664,7 +664,7 @@  static int target_selection(void)
 		/* parse_options deals with parsing user input, so it should be
 		 * impossible to get here */
 		assert(0);
-		return -1;
+		return false;
 	}
 
 	/* At this point we should have a device-tree loaded. We want
@@ -719,7 +719,7 @@  static int target_selection(void)
 			target_unselect(fsi);
 	}
 
-	return 0;
+	return true;
 }
 
 void print_target(struct pdbg_target *target, int level)
@@ -811,7 +811,7 @@  int main(int argc, char *argv[])
 		device_node = default_target(backend);
 
 	/* Disable unselected targets */
-	if (target_selection())
+	if (!target_selection())
 		return 1;
 
 	atexit(atexit_release);