diff mbox series

acpi: uniqueid: clean up pedantic static analysis warnings

Message ID 20211130082052.27579-1-ivan.hu@canonical.com
State Accepted
Headers show
Series acpi: uniqueid: clean up pedantic static analysis warnings | expand

Commit Message

ivanhu Nov. 30, 2021, 8:20 a.m. UTC
Clean up static analysis warning of dereference before null check
(REVERSE_INULL).

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/acpi/uniqueid/uniqueid.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Alex Hung Dec. 4, 2021, 2:03 a.m. UTC | #1
On 2021-11-30 1:20 a.m., Ivan Hu wrote:
> Clean up static analysis warning of dereference before null check
> (REVERSE_INULL).
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/acpi/uniqueid/uniqueid.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/acpi/uniqueid/uniqueid.c b/src/acpi/uniqueid/uniqueid.c
> index f745dfe5..7d150015 100644
> --- a/src/acpi/uniqueid/uniqueid.c
> +++ b/src/acpi/uniqueid/uniqueid.c
> @@ -108,11 +108,11 @@ static bool is_uniqueid_equal(acpi_ids *obj1, acpi_ids *obj2)
>  {
>  	bool hid_match = false;
>  
> -	/* _HID and _CID are in the same device */
> -	if (!strncmp(obj1->hid_name, obj2->hid_name, strlen(obj1->hid_name) - 4))
> +	if (obj1 == NULL || obj2 == NULL)
>  		return false;
>  
> -	if (obj1 == NULL || obj2 == NULL)
> +	/* _HID and _CID are in the same device */
> +	if (!strncmp(obj1->hid_name, obj2->hid_name, strlen(obj1->hid_name) - 4))
>  		return false;
>  
>  	if ((obj1->hid_obj->Type != obj2->hid_obj->Type) || (obj1->uid_obj->Type != obj2->uid_obj->Type))
> 


Acked-by: Alex Hung <alex.hung@canonical.com>
diff mbox series

Patch

diff --git a/src/acpi/uniqueid/uniqueid.c b/src/acpi/uniqueid/uniqueid.c
index f745dfe5..7d150015 100644
--- a/src/acpi/uniqueid/uniqueid.c
+++ b/src/acpi/uniqueid/uniqueid.c
@@ -108,11 +108,11 @@  static bool is_uniqueid_equal(acpi_ids *obj1, acpi_ids *obj2)
 {
 	bool hid_match = false;
 
-	/* _HID and _CID are in the same device */
-	if (!strncmp(obj1->hid_name, obj2->hid_name, strlen(obj1->hid_name) - 4))
+	if (obj1 == NULL || obj2 == NULL)
 		return false;
 
-	if (obj1 == NULL || obj2 == NULL)
+	/* _HID and _CID are in the same device */
+	if (!strncmp(obj1->hid_name, obj2->hid_name, strlen(obj1->hid_name) - 4))
 		return false;
 
 	if ((obj1->hid_obj->Type != obj2->hid_obj->Type) || (obj1->uid_obj->Type != obj2->uid_obj->Type))