Skip to contentSkip to conversation

platform/x86: hp: hp-bioscfg: remove redundant if statement

PATCH In review Colin Ian King 3 participants 3 messages Nov 7, 2024 – Nov 12, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: hp: hp-bioscfg: remove redundant if statement

The if statement performs the same action if the strcmp result is true or false since there is identical code on both branches. The if statement is redundant and can be replaced with just one call to sysfs_remove_group.

---
 .../platform/x86/hp/hp-bioscfg/passwdobj-attributes.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c +3 -8
index 35936c05e45b..187b372123ed 100644
@@ -531,14 +531,9 @@ void hp_exit_password_attributes(void)
 		struct kobject *attr_name_kobj =
 			bioscfg_drv.password_data[instance_id].attr_name_kobj;
 
-		if (attr_name_kobj) {
-			if (!strcmp(attr_name_kobj->name, SETUP_PASSWD))
-				sysfs_remove_group(attr_name_kobj,
-						   &password_attr_group);
-			else
-				sysfs_remove_group(attr_name_kobj,
-						   &password_attr_group);
-		}
+		if (attr_name_kobj)
+			sysfs_remove_group(attr_name_kobj,
+					   &password_attr_group);
 	}
 	bioscfg_drv.password_instances_count = 0;
 	kfree(bioscfg_drv.password_data);
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 6 lines · Colin Ian King

The if statement performs the same action if the strcmp result is true or false since there is identical code on both branches. The if statement is redundant and can be replaced with just one call to sysfs_remove_group.

Thanks, patch looks good to me:

Regards,

Hans

Quoted 26 lines
---
 .../platform/x86/hp/hp-bioscfg/passwdobj-attributes.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c +3 -8
index 35936c05e45b..187b372123ed 100644
@@ -531,14 +531,9 @@ void hp_exit_password_attributes(void)
 		struct kobject *attr_name_kobj =
 			bioscfg_drv.password_data[instance_id].attr_name_kobj;
 
-		if (attr_name_kobj) {
-			if (!strcmp(attr_name_kobj->name, SETUP_PASSWD))
-				sysfs_remove_group(attr_name_kobj,
-						   &password_attr_group);
-			else
-				sysfs_remove_group(attr_name_kobj,
-						   &password_attr_group);
-		}
+		if (attr_name_kobj)
+			sysfs_remove_group(attr_name_kobj,
+					   &password_attr_group);
 	}
 	bioscfg_drv.password_instances_count = 0;
 	kfree(bioscfg_drv.password_data);
maintainer
#2 lore raw
In reply to Colin Ian King
Quoted 6 lines · Colin Ian King

The if statement performs the same action if the strcmp result is true or false since there is identical code on both branches. The if statement is redundant and can be replaced with just one call to sysfs_remove_group.

Thank you for your contribution, it has been applied to my local review-ilpo branch. Note it will show up in the public platform-drivers-x86/review-ilpo branch only once I've pushed my local branch there, which might take a while.

The list of commits applied:
[1/1] platform/x86: hp: hp-bioscfg: remove redundant if statement

      commit: 4ceb681f1822819f78b747ddc189479fead43be2

--
i.