forked from md-raid-utilities/mdadm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move memory declaration helpers outside mdadm.h. They seems to be useful so keep them but include separatelly. Rework them to not reffer to Name[] declared internally in mdadm/mdmon. This is first step to start decomplexing mdadm.h. Signed-off-by: Mariusz Tkaczyk <[email protected]>
- Loading branch information
Showing
33 changed files
with
100 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,8 @@ | |
*/ | ||
|
||
#include "mdadm.h" | ||
#include "xmalloc.h" | ||
|
||
#include <ctype.h> | ||
|
||
mapping_t assemble_statuses[] = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,14 +22,16 @@ | |
* Email: <[email protected]> | ||
*/ | ||
|
||
#include "mdadm.h" | ||
#include "dlink.h" | ||
#include "mdadm.h" | ||
#include "md_u.h" | ||
#include "md_p.h" | ||
#include "xmalloc.h" | ||
|
||
#if ! defined(__BIG_ENDIAN) && ! defined(__LITTLE_ENDIAN) | ||
#error no endian defined | ||
#endif | ||
#include "md_u.h" | ||
#include "md_p.h" | ||
|
||
int Examine(struct mddev_dev *devlist, | ||
struct context *c, | ||
struct supertype *forcest) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
*/ | ||
|
||
#include "mdadm.h" | ||
#include "xmalloc.h" | ||
|
||
static inline void sb_le_to_cpu(bitmap_super_t *sb) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ | |
|
||
#include "mdadm.h" | ||
#include "dlink.h" | ||
#include "xmalloc.h" | ||
|
||
#include <ctype.h> | ||
#include <limits.h> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ | |
|
||
#include "mdadm.h" | ||
#include "md_p.h" | ||
#include "xmalloc.h" | ||
|
||
#include <ctype.h> | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ | |
|
||
#include "mdadm.h" | ||
#include "mdmon.h" | ||
#include "xmalloc.h" | ||
|
||
char const Name[] = "mdmon"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,64 +21,57 @@ | |
* Email: <[email protected]> | ||
*/ | ||
|
||
#include "mdadm.h" | ||
/*#include <sys/socket.h> | ||
#include <sys/utsname.h> | ||
#include <sys/wait.h> | ||
#include <sys/un.h> | ||
#include <ctype.h> | ||
#include <dirent.h> | ||
#include <signal.h> | ||
*/ | ||
#include "xmalloc.h" | ||
|
||
#include <string.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
static void *exit_memory_alloc_failure(void) | ||
{ | ||
fprintf(stderr, "Memory allocation failure - aborting\n"); | ||
|
||
/* TODO: replace with MDADM_STATUS_MEM_FAIL */ | ||
exit(1); | ||
} | ||
|
||
void *xmalloc(size_t len) | ||
{ | ||
void *rv = malloc(len); | ||
char *msg; | ||
int n; | ||
|
||
if (rv) | ||
return rv; | ||
msg = ": memory allocation failure - aborting\n"; | ||
n = write(2, Name, strlen(Name)); | ||
n += write(2, msg, strlen(msg)); | ||
exit(4+!!n); | ||
|
||
return exit_memory_alloc_failure(); | ||
} | ||
|
||
void *xrealloc(void *ptr, size_t len) | ||
{ | ||
void *rv = realloc(ptr, len); | ||
char *msg; | ||
int n; | ||
|
||
if (rv) | ||
return rv; | ||
msg = ": memory allocation failure - aborting\n"; | ||
n = write(2, Name, strlen(Name)); | ||
n += write(2, msg, strlen(msg)); | ||
exit(4+!!n); | ||
|
||
return exit_memory_alloc_failure(); | ||
} | ||
|
||
void *xcalloc(size_t num, size_t size) | ||
{ | ||
void *rv = calloc(num, size); | ||
char *msg; | ||
int n; | ||
|
||
if (rv) | ||
return rv; | ||
msg = ": memory allocation failure - aborting\n"; | ||
n = write(2, Name, strlen(Name)); | ||
n += write(2, msg, strlen(msg)); | ||
exit(4+!!n); | ||
|
||
return exit_memory_alloc_failure(); | ||
} | ||
|
||
char *xstrdup(const char *str) | ||
{ | ||
char *rv = strdup(str); | ||
char *msg; | ||
int n; | ||
|
||
if (rv) | ||
return rv; | ||
msg = ": memory allocation failure - aborting\n"; | ||
n = write(2, Name, strlen(Name)); | ||
n += write(2, msg, strlen(msg)); | ||
exit(4+!!n); | ||
|
||
return exit_memory_alloc_failure(); | ||
} |
Oops, something went wrong.