]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm: Add mdadm_status.h
authorAnna Sztukowska <anna.sztukowska@intel.com>
Wed, 9 Oct 2024 06:14:05 +0000 (08:14 +0200)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Thu, 10 Oct 2024 14:16:31 +0000 (16:16 +0200)
Move mdadm_status_t to mdadm_status.h file. Add status for memory
allocation failure.

Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
mdadm.h
mdadm_status.h [new file with mode: 0644]
xmalloc.c

diff --git a/mdadm.h b/mdadm.h
index bbc1b97f566da07918ac8574541f087d0565fafb..5781948e4106750ad45e0ff9cbc2f3341bd5112a 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -166,6 +166,7 @@ struct dlm_lksb {
 #include       "md_p.h"
 #include       "bitmap.h"
 #include       "msg.h"
+#include       "mdadm_status.h"
 
 #include <endian.h>
 /* Redhat don't like to #include <asm/byteorder.h>, and
@@ -449,12 +450,6 @@ struct spare_criteria {
        struct dev_policy *pols;
 };
 
-typedef enum mdadm_status {
-       MDADM_STATUS_SUCCESS = 0,
-       MDADM_STATUS_ERROR,
-       MDADM_STATUS_UNDEF,
-} mdadm_status_t;
-
 enum mode {
        ASSEMBLE=1,
        BUILD,
diff --git a/mdadm_status.h b/mdadm_status.h
new file mode 100644 (file)
index 0000000..905105e
--- /dev/null
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#ifndef MDADM_STATUS_H
+#define MDADM_STATUS_H
+
+typedef enum mdadm_status {
+       MDADM_STATUS_SUCCESS = 0,
+       MDADM_STATUS_ERROR,
+       MDADM_STATUS_UNDEF,
+       MDADM_STATUS_MEM_FAIL
+} mdadm_status_t;
+
+#endif
index dac30eb6107f8cb2442b2ec89cce3513549393e9..e28d3bd6261cf7550a8e4bdda8a2fcc7c750291f 100644 (file)
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -22,6 +22,7 @@
  */
 
 #include "xmalloc.h"
+#include "mdadm_status.h"
 
 #include <string.h>
 #include <stdio.h>
@@ -32,8 +33,7 @@ static void *exit_memory_alloc_failure(void)
 {
        fprintf(stderr, "Memory allocation failure - aborting\n");
 
-       /* TODO: replace with MDADM_STATUS_MEM_FAIL */
-       exit(1);
+       exit(MDADM_STATUS_MEM_FAIL);
 }
 
 void *xmalloc(size_t len)