diff mbox series

[2/2] diskpart_handler: rename diskpart_partition_cmp -> is_diskpart_different

Message ID 20211105083803.332678-2-michael.adler@siemens.com
State Accepted
Headers show
Series [1/2] diskpart_handler: support for GPT PARTUUIDs | expand

Commit Message

Michael Adler Nov. 5, 2021, 8:38 a.m. UTC
Usually the suffix `_cmp` indicates that the function decides if two
values are less-than (LT), equal (EQ) or greater-than (GT).
This method simply returns true or false, hence using the prefix `is_`
makes this clear without having to read the method documentation.

Signed-off-by: Michael Adler <michael.adler@siemens.com>
Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 handlers/diskpart_handler.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stefano Babic Nov. 18, 2021, 10:46 a.m. UTC | #1
On 05.11.21 09:38, Michael Adler wrote:
> Usually the suffix `_cmp` indicates that the function decides if two
> values are less-than (LT), equal (EQ) or greater-than (GT).
> This method simply returns true or false, hence using the prefix `is_`
> makes this clear without having to read the method documentation.
> 
> Signed-off-by: Michael Adler <michael.adler@siemens.com>
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>   handlers/diskpart_handler.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c
> index 21efc8f..b11f749 100644
> --- a/handlers/diskpart_handler.c
> +++ b/handlers/diskpart_handler.c
> @@ -431,7 +431,7 @@ static void diskpart_partition_info(struct fdisk_context *cxt, const char *name,
>   /*
>    * Return true if partition differs
>    */
> -static bool diskpart_partition_cmp(struct fdisk_partition *firstpa, struct fdisk_partition *secondpa)
> +static bool is_diskpart_different(struct fdisk_partition *firstpa, struct fdisk_partition *secondpa)
>   {
>   	if (!firstpa || !secondpa)
>   		return true;
> @@ -620,7 +620,7 @@ static int diskpart_table_cmp(struct fdisk_context *cxt, struct fdisk_table *tb,
>   				fdisk_table_next_partition (oldtb, olditr, &pa)) {
>   				TRACE("Partition not found, something went wrong %lu !", i);
>   				ret = -EFAULT;
> -			} else if (diskpart_partition_cmp(pa, newpa)) {
> +			} else if (is_diskpart_different(pa, newpa)) {
>   				TRACE("Partition differ:");
>   				diskpart_partition_info(cxt, "Original", pa);
>   				diskpart_partition_info(cxt, "New", newpa);
> 

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
Stefano Babic Nov. 29, 2021, 10:31 a.m. UTC | #2
On 05.11.21 09:38, Michael Adler wrote:
> Usually the suffix `_cmp` indicates that the function decides if two
> values are less-than (LT), equal (EQ) or greater-than (GT).
> This method simply returns true or false, hence using the prefix `is_`
> makes this clear without having to read the method documentation.
> 
> Signed-off-by: Michael Adler <michael.adler@siemens.com>
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>   handlers/diskpart_handler.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c
> index 21efc8f..b11f749 100644
> --- a/handlers/diskpart_handler.c
> +++ b/handlers/diskpart_handler.c
> @@ -431,7 +431,7 @@ static void diskpart_partition_info(struct fdisk_context *cxt, const char *name,
>   /*
>    * Return true if partition differs
>    */
> -static bool diskpart_partition_cmp(struct fdisk_partition *firstpa, struct fdisk_partition *secondpa)
> +static bool is_diskpart_different(struct fdisk_partition *firstpa, struct fdisk_partition *secondpa)
>   {
>   	if (!firstpa || !secondpa)
>   		return true;
> @@ -620,7 +620,7 @@ static int diskpart_table_cmp(struct fdisk_context *cxt, struct fdisk_table *tb,
>   				fdisk_table_next_partition (oldtb, olditr, &pa)) {
>   				TRACE("Partition not found, something went wrong %lu !", i);
>   				ret = -EFAULT;
> -			} else if (diskpart_partition_cmp(pa, newpa)) {
> +			} else if (is_diskpart_different(pa, newpa)) {
>   				TRACE("Partition differ:");
>   				diskpart_partition_info(cxt, "Original", pa);
>   				diskpart_partition_info(cxt, "New", newpa);
> 

Applied to -master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c
index 21efc8f..b11f749 100644
--- a/handlers/diskpart_handler.c
+++ b/handlers/diskpart_handler.c
@@ -431,7 +431,7 @@  static void diskpart_partition_info(struct fdisk_context *cxt, const char *name,
 /*
  * Return true if partition differs
  */
-static bool diskpart_partition_cmp(struct fdisk_partition *firstpa, struct fdisk_partition *secondpa)
+static bool is_diskpart_different(struct fdisk_partition *firstpa, struct fdisk_partition *secondpa)
 {
 	if (!firstpa || !secondpa)
 		return true;
@@ -620,7 +620,7 @@  static int diskpart_table_cmp(struct fdisk_context *cxt, struct fdisk_table *tb,
 				fdisk_table_next_partition (oldtb, olditr, &pa)) {
 				TRACE("Partition not found, something went wrong %lu !", i);
 				ret = -EFAULT;
-			} else if (diskpart_partition_cmp(pa, newpa)) {
+			} else if (is_diskpart_different(pa, newpa)) {
 				TRACE("Partition differ:");
 				diskpart_partition_info(cxt, "Original", pa);
 				diskpart_partition_info(cxt, "New", newpa);