Re: [PATCH 2/2] mdadm: replace container level checking with inline

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/23/22 5:10 PM, Kinga Tanska wrote:
To unify all containers checks in code, is_container() function is
added and propagated.

Signed-off-by: Kinga Tanska <kinga.tanska@xxxxxxxxx>
---
  Assemble.c    |  5 ++---
  Create.c      |  6 +++---
  Grow.c        |  6 +++---
  Incremental.c |  4 ++--
  mdadm.h       | 14 ++++++++++++++
  super-ddf.c   |  6 +++---
  super-intel.c |  4 ++--
  super0.c      |  2 +-
  super1.c      |  2 +-
  sysfs.c       |  2 +-
  10 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/Assemble.c b/Assemble.c
index f31372db..27324939 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -1123,7 +1123,7 @@ static int start_array(int mdfd,
  			       i/2, mddev);
  	}
- if (content->array.level == LEVEL_CONTAINER) {
+	if (is_container(content->array.level)) {
  		sysfs_rules_apply(mddev, content);
  		if (c->verbose >= 0) {
  			pr_err("Container %s has been assembled with %d drive%s",
[snipped]
  		sysfs_uevent(sra, "change");
diff --git a/mdadm.h b/mdadm.h
index c7268a71..371927ae 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1885,3 +1885,17 @@ enum r0layout {
   * This is true for native and DDF, IMSM allows 16.
   */
  #define MD_NAME_MAX 32
+
+/**
+ * is_container() - check if @level is &LEVEL_CONTAINER
+ * @level: level value
+ *
+ * return:
+ * &true if level is equal to &LEVEL_CONTAINER, &false otherwise.
+ */
+static inline bool is_container(const int level)
+{
+	if (level == LEVEL_CONTAINER)
+		return true;
+	return false;
+}
\ No newline at end of file

I am overall fine with this idea. Just one thing to ask, is_container() is the only is_xxx() routine with bool type, others are in type int. Maybe is_container() may follow existing code style?


Coly Li




[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux