diff mbox series

[RFC,10/12] libpdbg: Make probe result matches the backend status

Message ID 20190806013723.4047-11-alistair@popple.id.au
State Superseded
Headers show
Series Split backends from system description | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (d0a0d919cccbd69631aaef0d37f1dba8d53e86e0)
snowpatch_ozlabs/build-multiarch success Test build-multiarch on branch master

Commit Message

Alistair Popple Aug. 6, 2019, 1:37 a.m. UTC
If a target has a backend assigned make sure the status reflects the
status of the selected backend.

Signed-off-by: Alistair Popple <alistair@popple.id.au>
---
 libpdbg/target.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Amitay Isaacs Aug. 20, 2019, 4:07 a.m. UTC | #1
We don't need this.

On Tue, 2019-08-06 at 11:37 +1000, Alistair Popple wrote:
> If a target has a backend assigned make sure the status reflects the
> status of the selected backend.
> 
> Signed-off-by: Alistair Popple <alistair@popple.id.au>
> ---
>  libpdbg/target.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/libpdbg/target.c b/libpdbg/target.c
> index 73ad98f..d6604c2 100644
> --- a/libpdbg/target.c
> +++ b/libpdbg/target.c
> @@ -402,15 +402,16 @@ enum pdbg_target_status
> pdbg_target_probe(struct pdbg_target *target)
>  	}
>  
>  	/* At this point any parents must exist and have already been
> probed */
> -	if (target->probe && target->probe(target)) {
> -		/* Could not find the target */
> -		assert(pdbg_target_status(target) !=
> PDBG_TARGET_MUSTEXIST);
> +	if (target->backend && target->backend->probe && target-
> >backend->probe(target->backend))
> +		target->backend->status = target->status =
> PDBG_TARGET_NONEXISTENT;
> +	else if (target->probe && target->probe(target))
>  		target->status = PDBG_TARGET_NONEXISTENT;
> -		return PDBG_TARGET_NONEXISTENT;
> -	}
> +	else
> +		target->status = PDBG_TARGET_ENABLED;
> +
> +	assert(target->status != PDBG_TARGET_NONEXISTENT && target-
> >status != PDBG_TARGET_MUSTEXIST);
>  
> -	target->status = PDBG_TARGET_ENABLED;
> -	return PDBG_TARGET_ENABLED;
> +	return target->status;
>  }
>  
>  /* Releases a target by first recursively releasing all its children
> */
> -- 
> 2.20.1
> 

Amitay.
diff mbox series

Patch

diff --git a/libpdbg/target.c b/libpdbg/target.c
index 73ad98f..d6604c2 100644
--- a/libpdbg/target.c
+++ b/libpdbg/target.c
@@ -402,15 +402,16 @@  enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target)
 	}
 
 	/* At this point any parents must exist and have already been probed */
-	if (target->probe && target->probe(target)) {
-		/* Could not find the target */
-		assert(pdbg_target_status(target) != PDBG_TARGET_MUSTEXIST);
+	if (target->backend && target->backend->probe && target->backend->probe(target->backend))
+		target->backend->status = target->status = PDBG_TARGET_NONEXISTENT;
+	else if (target->probe && target->probe(target))
 		target->status = PDBG_TARGET_NONEXISTENT;
-		return PDBG_TARGET_NONEXISTENT;
-	}
+	else
+		target->status = PDBG_TARGET_ENABLED;
+
+	assert(target->status != PDBG_TARGET_NONEXISTENT && target->status != PDBG_TARGET_MUSTEXIST);
 
-	target->status = PDBG_TARGET_ENABLED;
-	return PDBG_TARGET_ENABLED;
+	return target->status;
 }
 
 /* Releases a target by first recursively releasing all its children */