Skip to content

Commit

Permalink
mdadm: Add mdadm_status.h
Browse files Browse the repository at this point in the history
Move mdadm_status_t to mdadm_status.h file. Add status for memory
allocation failure.

Signed-off-by: Anna Sztukowska <[email protected]>
  • Loading branch information
asztukow authored and mtkaczyk committed Oct 10, 2024
1 parent 70f3a1b commit f2f938b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
7 changes: 1 addition & 6 deletions mdadm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions mdadm_status.h
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions xmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

#include "xmalloc.h"
#include "mdadm_status.h"

#include <string.h>
#include <stdio.h>
Expand All @@ -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)
Expand Down

0 comments on commit f2f938b

Please sign in to comment.